All-in-One Event Calendar - Version 2.0.6

Version Description

Download this release

Release Info

Developer jbutkus
Plugin Icon 128x128 All-in-One Event Calendar
Version 2.0.6
Comparing to
See all releases

Code changes from version 1.10.5 to 2.0.6

Files changed (127) hide show
  1. COPYING.txt +0 -674
  2. LICENSE +339 -0
  3. README.md +4 -0
  4. all-in-one-event-calendar.php +70 -331
  5. app/config/constants.php +461 -0
  6. app/config/exception.php +12 -0
  7. app/controller/calendar-feeds.php +84 -0
  8. app/controller/class-ai1ec-app-controller.php +0 -544
  9. app/controller/class-ai1ec-calendar-controller.php +0 -763
  10. app/controller/class-ai1ec-events-controller.php +0 -830
  11. app/controller/class-ai1ec-exporter-controller.php +0 -157
  12. app/controller/class-ai1ec-importer-controller.php +0 -209
  13. app/controller/class-ai1ec-settings-controller.php +0 -419
  14. app/controller/class-ai1ec-themes-controller.php +0 -448
  15. app/controller/exception/engine-not-set.php +13 -0
  16. app/controller/exception/file-not-found.php +13 -0
  17. app/controller/export.php +193 -0
  18. app/controller/extension-license.php +188 -0
  19. app/controller/extension.php +232 -0
  20. app/controller/front.php +941 -0
  21. app/controller/import-export.php +104 -0
  22. app/controller/javascript.php +647 -0
  23. app/controller/shutdown.php +99 -0
  24. app/exception/class-ai1ec-event-not-found.php +0 -18
  25. app/exception/class-ai1ec-file-not-found.php +0 -18
  26. app/exception/class-ai1ec-file-not-provided.php +0 -18
  27. app/exception/class-ai1ec-invalid-argument.php +0 -18
  28. app/helper/class-ai1ec-app-helper.php +0 -1058
  29. app/helper/class-ai1ec-calendar-helper.php +0 -1171
  30. app/helper/class-ai1ec-events-helper.php +0 -2091
  31. app/helper/class-ai1ec-exporter-helper.php +0 -192
  32. app/helper/class-ai1ec-importer-helper.php +0 -282
  33. app/helper/class-ai1ec-recurrence-helper.php +0 -110
  34. app/helper/class-ai1ec-settings-helper.php +0 -443
  35. app/helper/class-ai1ec-view-helper.php +0 -635
  36. app/model/app.php +34 -0
  37. app/model/class-ai1ec-event.php +0 -884
  38. app/model/class-ai1ec-exporter.php +0 -29
  39. app/model/class-ai1ec-importer.php +0 -30
  40. app/model/class-ai1ec-settings.php +0 -540
  41. app/model/event.php +760 -0
  42. app/model/event/creating.php +195 -0
  43. app/model/event/entity.php +331 -0
  44. app/model/event/instance.php +296 -0
  45. app/model/event/invalid-argument-exception.php +13 -0
  46. app/model/event/legacy.php +148 -0
  47. app/model/event/not-found-exception.php +14 -0
  48. app/model/event/taxonomy.php +145 -0
  49. app/model/event/trashing.php +87 -0
  50. app/model/filter/auth_ids.php +18 -0
  51. app/model/filter/cat_ids.php +18 -0
  52. app/model/filter/int.php +75 -0
  53. app/model/filter/interface.php +44 -0
  54. app/model/filter/post_ids.php +18 -0
  55. app/model/filter/tag_ids.php +18 -0
  56. app/model/filter/taxonomy.php +97 -0
  57. app/model/meta-post.php +15 -0
  58. app/model/meta-user.php +96 -0
  59. app/model/meta.php +194 -0
  60. app/model/option.php +117 -0
  61. app/model/search.php +582 -0
  62. app/model/settings-view.php +136 -0
  63. app/model/settings.php +773 -0
  64. app/model/settings/exception.php +12 -0
  65. app/model/taxonomy.php +79 -0
  66. app/view/admin/abstract.php +34 -0
  67. app/view/admin/add-new-event.php +348 -0
  68. app/view/admin/admin_notices.php +0 -10
  69. app/view/admin/agenda-widget-form.php +0 -69
  70. app/view/admin/all-events.php +151 -0
  71. app/view/admin/box_advanced_settings.php +0 -9
  72. app/view/admin/box_event_contact.php +0 -35
  73. app/view/admin/box_event_cost.php +0 -15
  74. app/view/admin/box_event_location.php +0 -44
  75. app/view/admin/box_feeds.php +0 -39
  76. app/view/admin/box_general_settings.php +0 -113
  77. app/view/admin/box_publish_button.php +0 -5
  78. app/view/admin/box_repeat.php +0 -53
  79. app/view/admin/box_support.php +0 -161
  80. app/view/admin/box_time_and_date.php +0 -90
  81. app/view/admin/calendar-feeds.php +102 -0
  82. app/view/admin/calendar_tasks.php +0 -82
  83. app/view/admin/class-ai1ec-agenda-widget.php +0 -218
  84. app/view/admin/css/add_new_event.css +0 -526
  85. app/view/admin/css/admin.css +0 -16
  86. app/view/admin/css/bootstrap.min.css +0 -9
  87. app/view/admin/css/colorpicker.css +0 -280
  88. app/view/admin/css/dashboard.css +0 -28
  89. app/view/admin/css/datepicker.css +0 -191
  90. app/view/admin/css/platform.css +0 -61
  91. app/view/admin/css/settings.css +0 -203
  92. app/view/admin/donate_button.php +0 -6
  93. app/view/admin/event-category.php +250 -0
  94. app/view/admin/event_categories-color_picker.php +0 -27
  95. app/view/admin/feed_row.php +0 -25
  96. app/view/admin/get-repeat-box.php +542 -0
  97. app/view/admin/img/admin-menu.png +0 -0
  98. app/view/admin/img/ajax-loader.gif +0 -0
  99. app/view/admin/img/logo.png +0 -0
  100. app/view/admin/js/add_new_event.js +0 -982
  101. app/view/admin/js/bootstrap-modal.js +0 -218
  102. app/view/admin/js/bootstrap-popover.js +0 -95
  103. app/view/admin/js/bootstrap-tooltip.js +0 -270
  104. app/view/admin/js/colorpicker.js +0 -599
  105. app/view/admin/js/datepicker.js +0 -891
  106. app/view/admin/js/element-selector.js +0 -51
  107. app/view/admin/js/geo_autocomplete.js +0 -68
  108. app/view/admin/js/jquery.autocomplete_geomod.js +0 -825
  109. app/view/admin/js/jquery.blockUI.js +0 -496
  110. app/view/admin/js/jquery.calendrical.js +0 -588
  111. app/view/admin/js/jquery.inputdate.js +0 -200
  112. app/view/admin/js/jquery.timespan.js +0 -374
  113. app/view/admin/js/jquery.tools.min.js +0 -47
  114. app/view/admin/js/platform-all.js +0 -11
  115. app/view/admin/js/platform.js +0 -15
  116. app/view/admin/js/settings.js +0 -4
  117. app/view/admin/js/widget.js +0 -6
  118. app/view/admin/less/bootstrap.less +0 -355
  119. app/view/admin/less/build-css.sh +0 -10
  120. app/view/admin/less/button-groups.less +0 -172
  121. app/view/admin/less/buttons.less +0 -187
  122. app/view/admin/less/close.less +0 -29
  123. app/view/admin/less/component-animations.less +0 -20
  124. app/view/admin/less/dropdowns.less +0 -148
  125. app/view/admin/less/grid.less +0 -5
  126. app/view/admin/less/hero-unit.less +0 -22
  127. app/view/admin/less/mixins.less +0 -497
COPYING.txt DELETED
@@ -1,674 +0,0 @@
1
- GNU GENERAL PUBLIC LICENSE
2
- Version 3, 29 June 2007
3
-
4
- Copyright (C) 2007 Free Software Foundation, Inc. <http://fsf.org/>
5
- Everyone is permitted to copy and distribute verbatim copies
6
- of this license document, but changing it is not allowed.
7
-
8
- Preamble
9
-
10
- The GNU General Public License is a free, copyleft license for
11
- software and other kinds of works.
12
-
13
- The licenses for most software and other practical works are designed
14
- to take away your freedom to share and change the works. By contrast,
15
- the GNU General Public License is intended to guarantee your freedom to
16
- share and change all versions of a program--to make sure it remains free
17
- software for all its users. We, the Free Software Foundation, use the
18
- GNU General Public License for most of our software; it applies also to
19
- any other work released this way by its authors. You can apply it to
20
- your programs, too.
21
-
22
- When we speak of free software, we are referring to freedom, not
23
- price. Our General Public Licenses are designed to make sure that you
24
- have the freedom to distribute copies of free software (and charge for
25
- them if you wish), that you receive source code or can get it if you
26
- want it, that you can change the software or use pieces of it in new
27
- free programs, and that you know you can do these things.
28
-
29
- To protect your rights, we need to prevent others from denying you
30
- these rights or asking you to surrender the rights. Therefore, you have
31
- certain responsibilities if you distribute copies of the software, or if
32
- you modify it: responsibilities to respect the freedom of others.
33
-
34
- For example, if you distribute copies of such a program, whether
35
- gratis or for a fee, you must pass on to the recipients the same
36
- freedoms that you received. You must make sure that they, too, receive
37
- or can get the source code. And you must show them these terms so they
38
- know their rights.
39
-
40
- Developers that use the GNU GPL protect your rights with two steps:
41
- (1) assert copyright on the software, and (2) offer you this License
42
- giving you legal permission to copy, distribute and/or modify it.
43
-
44
- For the developers' and authors' protection, the GPL clearly explains
45
- that there is no warranty for this free software. For both users' and
46
- authors' sake, the GPL requires that modified versions be marked as
47
- changed, so that their problems will not be attributed erroneously to
48
- authors of previous versions.
49
-
50
- Some devices are designed to deny users access to install or run
51
- modified versions of the software inside them, although the manufacturer
52
- can do so. This is fundamentally incompatible with the aim of
53
- protecting users' freedom to change the software. The systematic
54
- pattern of such abuse occurs in the area of products for individuals to
55
- use, which is precisely where it is most unacceptable. Therefore, we
56
- have designed this version of the GPL to prohibit the practice for those
57
- products. If such problems arise substantially in other domains, we
58
- stand ready to extend this provision to those domains in future versions
59
- of the GPL, as needed to protect the freedom of users.
60
-
61
- Finally, every program is threatened constantly by software patents.
62
- States should not allow patents to restrict development and use of
63
- software on general-purpose computers, but in those that do, we wish to
64
- avoid the special danger that patents applied to a free program could
65
- make it effectively proprietary. To prevent this, the GPL assures that
66
- patents cannot be used to render the program non-free.
67
-
68
- The precise terms and conditions for copying, distribution and
69
- modification follow.
70
-
71
- TERMS AND CONDITIONS
72
-
73
- 0. Definitions.
74
-
75
- "This License" refers to version 3 of the GNU General Public License.
76
-
77
- "Copyright" also means copyright-like laws that apply to other kinds of
78
- works, such as semiconductor masks.
79
-
80
- "The Program" refers to any copyrightable work licensed under this
81
- License. Each licensee is addressed as "you". "Licensees" and
82
- "recipients" may be individuals or organizations.
83
-
84
- To "modify" a work means to copy from or adapt all or part of the work
85
- in a fashion requiring copyright permission, other than the making of an
86
- exact copy. The resulting work is called a "modified version" of the
87
- earlier work or a work "based on" the earlier work.
88
-
89
- A "covered work" means either the unmodified Program or a work based
90
- on the Program.
91
-
92
- To "propagate" a work means to do anything with it that, without
93
- permission, would make you directly or secondarily liable for
94
- infringement under applicable copyright law, except executing it on a
95
- computer or modifying a private copy. Propagation includes copying,
96
- distribution (with or without modification), making available to the
97
- public, and in some countries other activities as well.
98
-
99
- To "convey" a work means any kind of propagation that enables other
100
- parties to make or receive copies. Mere interaction with a user through
101
- a computer network, with no transfer of a copy, is not conveying.
102
-
103
- An interactive user interface displays "Appropriate Legal Notices"
104
- to the extent that it includes a convenient and prominently visible
105
- feature that (1) displays an appropriate copyright notice, and (2)
106
- tells the user that there is no warranty for the work (except to the
107
- extent that warranties are provided), that licensees may convey the
108
- work under this License, and how to view a copy of this License. If
109
- the interface presents a list of user commands or options, such as a
110
- menu, a prominent item in the list meets this criterion.
111
-
112
- 1. Source Code.
113
-
114
- The "source code" for a work means the preferred form of the work
115
- for making modifications to it. "Object code" means any non-source
116
- form of a work.
117
-
118
- A "Standard Interface" means an interface that either is an official
119
- standard defined by a recognized standards body, or, in the case of
120
- interfaces specified for a particular programming language, one that
121
- is widely used among developers working in that language.
122
-
123
- The "System Libraries" of an executable work include anything, other
124
- than the work as a whole, that (a) is included in the normal form of
125
- packaging a Major Component, but which is not part of that Major
126
- Component, and (b) serves only to enable use of the work with that
127
- Major Component, or to implement a Standard Interface for which an
128
- implementation is available to the public in source code form. A
129
- "Major Component", in this context, means a major essential component
130
- (kernel, window system, and so on) of the specific operating system
131
- (if any) on which the executable work runs, or a compiler used to
132
- produce the work, or an object code interpreter used to run it.
133
-
134
- The "Corresponding Source" for a work in object code form means all
135
- the source code needed to generate, install, and (for an executable
136
- work) run the object code and to modify the work, including scripts to
137
- control those activities. However, it does not include the work's
138
- System Libraries, or general-purpose tools or generally available free
139
- programs which are used unmodified in performing those activities but
140
- which are not part of the work. For example, Corresponding Source
141
- includes interface definition files associated with source files for
142
- the work, and the source code for shared libraries and dynamically
143
- linked subprograms that the work is specifically designed to require,
144
- such as by intimate data communication or control flow between those
145
- subprograms and other parts of the work.
146
-
147
- The Corresponding Source need not include anything that users
148
- can regenerate automatically from other parts of the Corresponding
149
- Source.
150
-
151
- The Corresponding Source for a work in source code form is that
152
- same work.
153
-
154
- 2. Basic Permissions.
155
-
156
- All rights granted under this License are granted for the term of
157
- copyright on the Program, and are irrevocable provided the stated
158
- conditions are met. This License explicitly affirms your unlimited
159
- permission to run the unmodified Program. The output from running a
160
- covered work is covered by this License only if the output, given its
161
- content, constitutes a covered work. This License acknowledges your
162
- rights of fair use or other equivalent, as provided by copyright law.
163
-
164
- You may make, run and propagate covered works that you do not
165
- convey, without conditions so long as your license otherwise remains
166
- in force. You may convey covered works to others for the sole purpose
167
- of having them make modifications exclusively for you, or provide you
168
- with facilities for running those works, provided that you comply with
169
- the terms of this License in conveying all material for which you do
170
- not control copyright. Those thus making or running the covered works
171
- for you must do so exclusively on your behalf, under your direction
172
- and control, on terms that prohibit them from making any copies of
173
- your copyrighted material outside their relationship with you.
174
-
175
- Conveying under any other circumstances is permitted solely under
176
- the conditions stated below. Sublicensing is not allowed; section 10
177
- makes it unnecessary.
178
-
179
- 3. Protecting Users' Legal Rights From Anti-Circumvention Law.
180
-
181
- No covered work shall be deemed part of an effective technological
182
- measure under any applicable law fulfilling obligations under article
183
- 11 of the WIPO copyright treaty adopted on 20 December 1996, or
184
- similar laws prohibiting or restricting circumvention of such
185
- measures.
186
-
187
- When you convey a covered work, you waive any legal power to forbid
188
- circumvention of technological measures to the extent such circumvention
189
- is effected by exercising rights under this License with respect to
190
- the covered work, and you disclaim any intention to limit operation or
191
- modification of the work as a means of enforcing, against the work's
192
- users, your or third parties' legal rights to forbid circumvention of
193
- technological measures.
194
-
195
- 4. Conveying Verbatim Copies.
196
-
197
- You may convey verbatim copies of the Program's source code as you
198
- receive it, in any medium, provided that you conspicuously and
199
- appropriately publish on each copy an appropriate copyright notice;
200
- keep intact all notices stating that this License and any
201
- non-permissive terms added in accord with section 7 apply to the code;
202
- keep intact all notices of the absence of any warranty; and give all
203
- recipients a copy of this License along with the Program.
204
-
205
- You may charge any price or no price for each copy that you convey,
206
- and you may offer support or warranty protection for a fee.
207
-
208
- 5. Conveying Modified Source Versions.
209
-
210
- You may convey a work based on the Program, or the modifications to
211
- produce it from the Program, in the form of source code under the
212
- terms of section 4, provided that you also meet all of these conditions:
213
-
214
- a) The work must carry prominent notices stating that you modified
215
- it, and giving a relevant date.
216
-
217
- b) The work must carry prominent notices stating that it is
218
- released under this License and any conditions added under section
219
- 7. This requirement modifies the requirement in section 4 to
220
- "keep intact all notices".
221
-
222
- c) You must license the entire work, as a whole, under this
223
- License to anyone who comes into possession of a copy. This
224
- License will therefore apply, along with any applicable section 7
225
- additional terms, to the whole of the work, and all its parts,
226
- regardless of how they are packaged. This License gives no
227
- permission to license the work in any other way, but it does not
228
- invalidate such permission if you have separately received it.
229
-
230
- d) If the work has interactive user interfaces, each must display
231
- Appropriate Legal Notices; however, if the Program has interactive
232
- interfaces that do not display Appropriate Legal Notices, your
233
- work need not make them do so.
234
-
235
- A compilation of a covered work with other separate and independent
236
- works, which are not by their nature extensions of the covered work,
237
- and which are not combined with it such as to form a larger program,
238
- in or on a volume of a storage or distribution medium, is called an
239
- "aggregate" if the compilation and its resulting copyright are not
240
- used to limit the access or legal rights of the compilation's users
241
- beyond what the individual works permit. Inclusion of a covered work
242
- in an aggregate does not cause this License to apply to the other
243
- parts of the aggregate.
244
-
245
- 6. Conveying Non-Source Forms.
246
-
247
- You may convey a covered work in object code form under the terms
248
- of sections 4 and 5, provided that you also convey the
249
- machine-readable Corresponding Source under the terms of this License,
250
- in one of these ways:
251
-
252
- a) Convey the object code in, or embodied in, a physical product
253
- (including a physical distribution medium), accompanied by the
254
- Corresponding Source fixed on a durable physical medium
255
- customarily used for software interchange.
256
-
257
- b) Convey the object code in, or embodied in, a physical product
258
- (including a physical distribution medium), accompanied by a
259
- written offer, valid for at least three years and valid for as
260
- long as you offer spare parts or customer support for that product
261
- model, to give anyone who possesses the object code either (1) a
262
- copy of the Corresponding Source for all the software in the
263
- product that is covered by this License, on a durable physical
264
- medium customarily used for software interchange, for a price no
265
- more than your reasonable cost of physically performing this
266
- conveying of source, or (2) access to copy the
267
- Corresponding Source from a network server at no charge.
268
-
269
- c) Convey individual copies of the object code with a copy of the
270
- written offer to provide the Corresponding Source. This
271
- alternative is allowed only occasionally and noncommercially, and
272
- only if you received the object code with such an offer, in accord
273
- with subsection 6b.
274
-
275
- d) Convey the object code by offering access from a designated
276
- place (gratis or for a charge), and offer equivalent access to the
277
- Corresponding Source in the same way through the same place at no
278
- further charge. You need not require recipients to copy the
279
- Corresponding Source along with the object code. If the place to
280
- copy the object code is a network server, the Corresponding Source
281
- may be on a different server (operated by you or a third party)
282
- that supports equivalent copying facilities, provided you maintain
283
- clear directions next to the object code saying where to find the
284
- Corresponding Source. Regardless of what server hosts the
285
- Corresponding Source, you remain obligated to ensure that it is
286
- available for as long as needed to satisfy these requirements.
287
-
288
- e) Convey the object code using peer-to-peer transmission, provided
289
- you inform other peers where the object code and Corresponding
290
- Source of the work are being offered to the general public at no
291
- charge under subsection 6d.
292
-
293
- A separable portion of the object code, whose source code is excluded
294
- from the Corresponding Source as a System Library, need not be
295
- included in conveying the object code work.
296
-
297
- A "User Product" is either (1) a "consumer product", which means any
298
- tangible personal property which is normally used for personal, family,
299
- or household purposes, or (2) anything designed or sold for incorporation
300
- into a dwelling. In determining whether a product is a consumer product,
301
- doubtful cases shall be resolved in favor of coverage. For a particular
302
- product received by a particular user, "normally used" refers to a
303
- typical or common use of that class of product, regardless of the status
304
- of the particular user or of the way in which the particular user
305
- actually uses, or expects or is expected to use, the product. A product
306
- is a consumer product regardless of whether the product has substantial
307
- commercial, industrial or non-consumer uses, unless such uses represent
308
- the only significant mode of use of the product.
309
-
310
- "Installation Information" for a User Product means any methods,
311
- procedures, authorization keys, or other information required to install
312
- and execute modified versions of a covered work in that User Product from
313
- a modified version of its Corresponding Source. The information must
314
- suffice to ensure that the continued functioning of the modified object
315
- code is in no case prevented or interfered with solely because
316
- modification has been made.
317
-
318
- If you convey an object code work under this section in, or with, or
319
- specifically for use in, a User Product, and the conveying occurs as
320
- part of a transaction in which the right of possession and use of the
321
- User Product is transferred to the recipient in perpetuity or for a
322
- fixed term (regardless of how the transaction is characterized), the
323
- Corresponding Source conveyed under this section must be accompanied
324
- by the Installation Information. But this requirement does not apply
325
- if neither you nor any third party retains the ability to install
326
- modified object code on the User Product (for example, the work has
327
- been installed in ROM).
328
-
329
- The requirement to provide Installation Information does not include a
330
- requirement to continue to provide support service, warranty, or updates
331
- for a work that has been modified or installed by the recipient, or for
332
- the User Product in which it has been modified or installed. Access to a
333
- network may be denied when the modification itself materially and
334
- adversely affects the operation of the network or violates the rules and
335
- protocols for communication across the network.
336
-
337
- Corresponding Source conveyed, and Installation Information provided,
338
- in accord with this section must be in a format that is publicly
339
- documented (and with an implementation available to the public in
340
- source code form), and must require no special password or key for
341
- unpacking, reading or copying.
342
-
343
- 7. Additional Terms.
344
-
345
- "Additional permissions" are terms that supplement the terms of this
346
- License by making exceptions from one or more of its conditions.
347
- Additional permissions that are applicable to the entire Program shall
348
- be treated as though they were included in this License, to the extent
349
- that they are valid under applicable law. If additional permissions
350
- apply only to part of the Program, that part may be used separately
351
- under those permissions, but the entire Program remains governed by
352
- this License without regard to the additional permissions.
353
-
354
- When you convey a copy of a covered work, you may at your option
355
- remove any additional permissions from that copy, or from any part of
356
- it. (Additional permissions may be written to require their own
357
- removal in certain cases when you modify the work.) You may place
358
- additional permissions on material, added by you to a covered work,
359
- for which you have or can give appropriate copyright permission.
360
-
361
- Notwithstanding any other provision of this License, for material you
362
- add to a covered work, you may (if authorized by the copyright holders of
363
- that material) supplement the terms of this License with terms:
364
-
365
- a) Disclaiming warranty or limiting liability differently from the
366
- terms of sections 15 and 16 of this License; or
367
-
368
- b) Requiring preservation of specified reasonable legal notices or
369
- author attributions in that material or in the Appropriate Legal
370
- Notices displayed by works containing it; or
371
-
372
- c) Prohibiting misrepresentation of the origin of that material, or
373
- requiring that modified versions of such material be marked in
374
- reasonable ways as different from the original version; or
375
-
376
- d) Limiting the use for publicity purposes of names of licensors or
377
- authors of the material; or
378
-
379
- e) Declining to grant rights under trademark law for use of some
380
- trade names, trademarks, or service marks; or
381
-
382
- f) Requiring indemnification of licensors and authors of that
383
- material by anyone who conveys the material (or modified versions of
384
- it) with contractual assumptions of liability to the recipient, for
385
- any liability that these contractual assumptions directly impose on
386
- those licensors and authors.
387
-
388
- All other non-permissive additional terms are considered "further
389
- restrictions" within the meaning of section 10. If the Program as you
390
- received it, or any part of it, contains a notice stating that it is
391
- governed by this License along with a term that is a further
392
- restriction, you may remove that term. If a license document contains
393
- a further restriction but permits relicensing or conveying under this
394
- License, you may add to a covered work material governed by the terms
395
- of that license document, provided that the further restriction does
396
- not survive such relicensing or conveying.
397
-
398
- If you add terms to a covered work in accord with this section, you
399
- must place, in the relevant source files, a statement of the
400
- additional terms that apply to those files, or a notice indicating
401
- where to find the applicable terms.
402
-
403
- Additional terms, permissive or non-permissive, may be stated in the
404
- form of a separately written license, or stated as exceptions;
405
- the above requirements apply either way.
406
-
407
- 8. Termination.
408
-
409
- You may not propagate or modify a covered work except as expressly
410
- provided under this License. Any attempt otherwise to propagate or
411
- modify it is void, and will automatically terminate your rights under
412
- this License (including any patent licenses granted under the third
413
- paragraph of section 11).
414
-
415
- However, if you cease all violation of this License, then your
416
- license from a particular copyright holder is reinstated (a)
417
- provisionally, unless and until the copyright holder explicitly and
418
- finally terminates your license, and (b) permanently, if the copyright
419
- holder fails to notify you of the violation by some reasonable means
420
- prior to 60 days after the cessation.
421
-
422
- Moreover, your license from a particular copyright holder is
423
- reinstated permanently if the copyright holder notifies you of the
424
- violation by some reasonable means, this is the first time you have
425
- received notice of violation of this License (for any work) from that
426
- copyright holder, and you cure the violation prior to 30 days after
427
- your receipt of the notice.
428
-
429
- Termination of your rights under this section does not terminate the
430
- licenses of parties who have received copies or rights from you under
431
- this License. If your rights have been terminated and not permanently
432
- reinstated, you do not qualify to receive new licenses for the same
433
- material under section 10.
434
-
435
- 9. Acceptance Not Required for Having Copies.
436
-
437
- You are not required to accept this License in order to receive or
438
- run a copy of the Program. Ancillary propagation of a covered work
439
- occurring solely as a consequence of using peer-to-peer transmission
440
- to receive a copy likewise does not require acceptance. However,
441
- nothing other than this License grants you permission to propagate or
442
- modify any covered work. These actions infringe copyright if you do
443
- not accept this License. Therefore, by modifying or propagating a
444
- covered work, you indicate your acceptance of this License to do so.
445
-
446
- 10. Automatic Licensing of Downstream Recipients.
447
-
448
- Each time you convey a covered work, the recipient automatically
449
- receives a license from the original licensors, to run, modify and
450
- propagate that work, subject to this License. You are not responsible
451
- for enforcing compliance by third parties with this License.
452
-
453
- An "entity transaction" is a transaction transferring control of an
454
- organization, or substantially all assets of one, or subdividing an
455
- organization, or merging organizations. If propagation of a covered
456
- work results from an entity transaction, each party to that
457
- transaction who receives a copy of the work also receives whatever
458
- licenses to the work the party's predecessor in interest had or could
459
- give under the previous paragraph, plus a right to possession of the
460
- Corresponding Source of the work from the predecessor in interest, if
461
- the predecessor has it or can get it with reasonable efforts.
462
-
463
- You may not impose any further restrictions on the exercise of the
464
- rights granted or affirmed under this License. For example, you may
465
- not impose a license fee, royalty, or other charge for exercise of
466
- rights granted under this License, and you may not initiate litigation
467
- (including a cross-claim or counterclaim in a lawsuit) alleging that
468
- any patent claim is infringed by making, using, selling, offering for
469
- sale, or importing the Program or any portion of it.
470
-
471
- 11. Patents.
472
-
473
- A "contributor" is a copyright holder who authorizes use under this
474
- License of the Program or a work on which the Program is based. The
475
- work thus licensed is called the contributor's "contributor version".
476
-
477
- A contributor's "essential patent claims" are all patent claims
478
- owned or controlled by the contributor, whether already acquired or
479
- hereafter acquired, that would be infringed by some manner, permitted
480
- by this License, of making, using, or selling its contributor version,
481
- but do not include claims that would be infringed only as a
482
- consequence of further modification of the contributor version. For
483
- purposes of this definition, "control" includes the right to grant
484
- patent sublicenses in a manner consistent with the requirements of
485
- this License.
486
-
487
- Each contributor grants you a non-exclusive, worldwide, royalty-free
488
- patent license under the contributor's essential patent claims, to
489
- make, use, sell, offer for sale, import and otherwise run, modify and
490
- propagate the contents of its contributor version.
491
-
492
- In the following three paragraphs, a "patent license" is any express
493
- agreement or commitment, however denominated, not to enforce a patent
494
- (such as an express permission to practice a patent or covenant not to
495
- sue for patent infringement). To "grant" such a patent license to a
496
- party means to make such an agreement or commitment not to enforce a
497
- patent against the party.
498
-
499
- If you convey a covered work, knowingly relying on a patent license,
500
- and the Corresponding Source of the work is not available for anyone
501
- to copy, free of charge and under the terms of this License, through a
502
- publicly available network server or other readily accessible means,
503
- then you must either (1) cause the Corresponding Source to be so
504
- available, or (2) arrange to deprive yourself of the benefit of the
505
- patent license for this particular work, or (3) arrange, in a manner
506
- consistent with the requirements of this License, to extend the patent
507
- license to downstream recipients. "Knowingly relying" means you have
508
- actual knowledge that, but for the patent license, your conveying the
509
- covered work in a country, or your recipient's use of the covered work
510
- in a country, would infringe one or more identifiable patents in that
511
- country that you have reason to believe are valid.
512
-
513
- If, pursuant to or in connection with a single transaction or
514
- arrangement, you convey, or propagate by procuring conveyance of, a
515
- covered work, and grant a patent license to some of the parties
516
- receiving the covered work authorizing them to use, propagate, modify
517
- or convey a specific copy of the covered work, then the patent license
518
- you grant is automatically extended to all recipients of the covered
519
- work and works based on it.
520
-
521
- A patent license is "discriminatory" if it does not include within
522
- the scope of its coverage, prohibits the exercise of, or is
523
- conditioned on the non-exercise of one or more of the rights that are
524
- specifically granted under this License. You may not convey a covered
525
- work if you are a party to an arrangement with a third party that is
526
- in the business of distributing software, under which you make payment
527
- to the third party based on the extent of your activity of conveying
528
- the work, and under which the third party grants, to any of the
529
- parties who would receive the covered work from you, a discriminatory
530
- patent license (a) in connection with copies of the covered work
531
- conveyed by you (or copies made from those copies), or (b) primarily
532
- for and in connection with specific products or compilations that
533
- contain the covered work, unless you entered into that arrangement,
534
- or that patent license was granted, prior to 28 March 2007.
535
-
536
- Nothing in this License shall be construed as excluding or limiting
537
- any implied license or other defenses to infringement that may
538
- otherwise be available to you under applicable patent law.
539
-
540
- 12. No Surrender of Others' Freedom.
541
-
542
- If conditions are imposed on you (whether by court order, agreement or
543
- otherwise) that contradict the conditions of this License, they do not
544
- excuse you from the conditions of this License. If you cannot convey a
545
- covered work so as to satisfy simultaneously your obligations under this
546
- License and any other pertinent obligations, then as a consequence you may
547
- not convey it at all. For example, if you agree to terms that obligate you
548
- to collect a royalty for further conveying from those to whom you convey
549
- the Program, the only way you could satisfy both those terms and this
550
- License would be to refrain entirely from conveying the Program.
551
-
552
- 13. Use with the GNU Affero General Public License.
553
-
554
- Notwithstanding any other provision of this License, you have
555
- permission to link or combine any covered work with a work licensed
556
- under version 3 of the GNU Affero General Public License into a single
557
- combined work, and to convey the resulting work. The terms of this
558
- License will continue to apply to the part which is the covered work,
559
- but the special requirements of the GNU Affero General Public License,
560
- section 13, concerning interaction through a network will apply to the
561
- combination as such.
562
-
563
- 14. Revised Versions of this License.
564
-
565
- The Free Software Foundation may publish revised and/or new versions of
566
- the GNU General Public License from time to time. Such new versions will
567
- be similar in spirit to the present version, but may differ in detail to
568
- address new problems or concerns.
569
-
570
- Each version is given a distinguishing version number. If the
571
- Program specifies that a certain numbered version of the GNU General
572
- Public License "or any later version" applies to it, you have the
573
- option of following the terms and conditions either of that numbered
574
- version or of any later version published by the Free Software
575
- Foundation. If the Program does not specify a version number of the
576
- GNU General Public License, you may choose any version ever published
577
- by the Free Software Foundation.
578
-
579
- If the Program specifies that a proxy can decide which future
580
- versions of the GNU General Public License can be used, that proxy's
581
- public statement of acceptance of a version permanently authorizes you
582
- to choose that version for the Program.
583
-
584
- Later license versions may give you additional or different
585
- permissions. However, no additional obligations are imposed on any
586
- author or copyright holder as a result of your choosing to follow a
587
- later version.
588
-
589
- 15. Disclaimer of Warranty.
590
-
591
- THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY
592
- APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT
593
- HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY
594
- OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,
595
- THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
596
- PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM
597
- IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF
598
- ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
599
-
600
- 16. Limitation of Liability.
601
-
602
- IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
603
- WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS
604
- THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY
605
- GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE
606
- USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF
607
- DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD
608
- PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS),
609
- EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF
610
- SUCH DAMAGES.
611
-
612
- 17. Interpretation of Sections 15 and 16.
613
-
614
- If the disclaimer of warranty and limitation of liability provided
615
- above cannot be given local legal effect according to their terms,
616
- reviewing courts shall apply local law that most closely approximates
617
- an absolute waiver of all civil liability in connection with the
618
- Program, unless a warranty or assumption of liability accompanies a
619
- copy of the Program in return for a fee.
620
-
621
- END OF TERMS AND CONDITIONS
622
-
623
- How to Apply These Terms to Your New Programs
624
-
625
- If you develop a new program, and you want it to be of the greatest
626
- possible use to the public, the best way to achieve this is to make it
627
- free software which everyone can redistribute and change under these terms.
628
-
629
- To do so, attach the following notices to the program. It is safest
630
- to attach them to the start of each source file to most effectively
631
- state the exclusion of warranty; and each file should have at least
632
- the "copyright" line and a pointer to where the full notice is found.
633
-
634
- <one line to give the program's name and a brief idea of what it does.>
635
- Copyright (C) <year> <name of author>
636
-
637
- This program is free software: you can redistribute it and/or modify
638
- it under the terms of the GNU General Public License as published by
639
- the Free Software Foundation, either version 3 of the License, or
640
- (at your option) any later version.
641
-
642
- This program is distributed in the hope that it will be useful,
643
- but WITHOUT ANY WARRANTY; without even the implied warranty of
644
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
645
- GNU General Public License for more details.
646
-
647
- You should have received a copy of the GNU General Public License
648
- along with this program. If not, see <http://www.gnu.org/licenses/>.
649
-
650
- Also add information on how to contact you by electronic and paper mail.
651
-
652
- If the program does terminal interaction, make it output a short
653
- notice like this when it starts in an interactive mode:
654
-
655
- <program> Copyright (C) <year> <name of author>
656
- This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
657
- This is free software, and you are welcome to redistribute it
658
- under certain conditions; type `show c' for details.
659
-
660
- The hypothetical commands `show w' and `show c' should show the appropriate
661
- parts of the General Public License. Of course, your program's commands
662
- might be different; for a GUI interface, you would use an "about box".
663
-
664
- You should also get your employer (if you work as a programmer) or school,
665
- if any, to sign a "copyright disclaimer" for the program, if necessary.
666
- For more information on this, and how to apply and follow the GNU GPL, see
667
- <http://www.gnu.org/licenses/>.
668
-
669
- The GNU General Public License does not permit incorporating your program
670
- into proprietary programs. If your program is a subroutine library, you
671
- may consider it more useful to permit linking proprietary applications with
672
- the library. If this is what you want to do, use the GNU Lesser General
673
- Public License instead of this License. But first, please read
674
- <http://www.gnu.org/philosophy/why-not-lgpl.html>.
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
LICENSE ADDED
@@ -0,0 +1,339 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ GNU GENERAL PUBLIC LICENSE
2
+ Version 2, June 1991
3
+
4
+ Copyright (C) 1989, 1991 Free Software Foundation, Inc.,
5
+ 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
6
+ Everyone is permitted to copy and distribute verbatim copies
7
+ of this license document, but changing it is not allowed.
8
+
9
+ Preamble
10
+
11
+ The licenses for most software are designed to take away your
12
+ freedom to share and change it. By contrast, the GNU General Public
13
+ License is intended to guarantee your freedom to share and change free
14
+ software--to make sure the software is free for all its users. This
15
+ General Public License applies to most of the Free Software
16
+ Foundation's software and to any other program whose authors commit to
17
+ using it. (Some other Free Software Foundation software is covered by
18
+ the GNU Lesser General Public License instead.) You can apply it to
19
+ your programs, too.
20
+
21
+ When we speak of free software, we are referring to freedom, not
22
+ price. Our General Public Licenses are designed to make sure that you
23
+ have the freedom to distribute copies of free software (and charge for
24
+ this service if you wish), that you receive source code or can get it
25
+ if you want it, that you can change the software or use pieces of it
26
+ in new free programs; and that you know you can do these things.
27
+
28
+ To protect your rights, we need to make restrictions that forbid
29
+ anyone to deny you these rights or to ask you to surrender the rights.
30
+ These restrictions translate to certain responsibilities for you if you
31
+ distribute copies of the software, or if you modify it.
32
+
33
+ For example, if you distribute copies of such a program, whether
34
+ gratis or for a fee, you must give the recipients all the rights that
35
+ you have. You must make sure that they, too, receive or can get the
36
+ source code. And you must show them these terms so they know their
37
+ rights.
38
+
39
+ We protect your rights with two steps: (1) copyright the software, and
40
+ (2) offer you this license which gives you legal permission to copy,
41
+ distribute and/or modify the software.
42
+
43
+ Also, for each author's protection and ours, we want to make certain
44
+ that everyone understands that there is no warranty for this free
45
+ software. If the software is modified by someone else and passed on, we
46
+ want its recipients to know that what they have is not the original, so
47
+ that any problems introduced by others will not reflect on the original
48
+ authors' reputations.
49
+
50
+ Finally, any free program is threatened constantly by software
51
+ patents. We wish to avoid the danger that redistributors of a free
52
+ program will individually obtain patent licenses, in effect making the
53
+ program proprietary. To prevent this, we have made it clear that any
54
+ patent must be licensed for everyone's free use or not licensed at all.
55
+
56
+ The precise terms and conditions for copying, distribution and
57
+ modification follow.
58
+
59
+ GNU GENERAL PUBLIC LICENSE
60
+ TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
61
+
62
+ 0. This License applies to any program or other work which contains
63
+ a notice placed by the copyright holder saying it may be distributed
64
+ under the terms of this General Public License. The "Program", below,
65
+ refers to any such program or work, and a "work based on the Program"
66
+ means either the Program or any derivative work under copyright law:
67
+ that is to say, a work containing the Program or a portion of it,
68
+ either verbatim or with modifications and/or translated into another
69
+ language. (Hereinafter, translation is included without limitation in
70
+ the term "modification".) Each licensee is addressed as "you".
71
+
72
+ Activities other than copying, distribution and modification are not
73
+ covered by this License; they are outside its scope. The act of
74
+ running the Program is not restricted, and the output from the Program
75
+ is covered only if its contents constitute a work based on the
76
+ Program (independent of having been made by running the Program).
77
+ Whether that is true depends on what the Program does.
78
+
79
+ 1. You may copy and distribute verbatim copies of the Program's
80
+ source code as you receive it, in any medium, provided that you
81
+ conspicuously and appropriately publish on each copy an appropriate
82
+ copyright notice and disclaimer of warranty; keep intact all the
83
+ notices that refer to this License and to the absence of any warranty;
84
+ and give any other recipients of the Program a copy of this License
85
+ along with the Program.
86
+
87
+ You may charge a fee for the physical act of transferring a copy, and
88
+ you may at your option offer warranty protection in exchange for a fee.
89
+
90
+ 2. You may modify your copy or copies of the Program or any portion
91
+ of it, thus forming a work based on the Program, and copy and
92
+ distribute such modifications or work under the terms of Section 1
93
+ above, provided that you also meet all of these conditions:
94
+
95
+ a) You must cause the modified files to carry prominent notices
96
+ stating that you changed the files and the date of any change.
97
+
98
+ b) You must cause any work that you distribute or publish, that in
99
+ whole or in part contains or is derived from the Program or any
100
+ part thereof, to be licensed as a whole at no charge to all third
101
+ parties under the terms of this License.
102
+
103
+ c) If the modified program normally reads commands interactively
104
+ when run, you must cause it, when started running for such
105
+ interactive use in the most ordinary way, to print or display an
106
+ announcement including an appropriate copyright notice and a
107
+ notice that there is no warranty (or else, saying that you provide
108
+ a warranty) and that users may redistribute the program under
109
+ these conditions, and telling the user how to view a copy of this
110
+ License. (Exception: if the Program itself is interactive but
111
+ does not normally print such an announcement, your work based on
112
+ the Program is not required to print an announcement.)
113
+
114
+ These requirements apply to the modified work as a whole. If
115
+ identifiable sections of that work are not derived from the Program,
116
+ and can be reasonably considered independent and separate works in
117
+ themselves, then this License, and its terms, do not apply to those
118
+ sections when you distribute them as separate works. But when you
119
+ distribute the same sections as part of a whole which is a work based
120
+ on the Program, the distribution of the whole must be on the terms of
121
+ this License, whose permissions for other licensees extend to the
122
+ entire whole, and thus to each and every part regardless of who wrote it.
123
+
124
+ Thus, it is not the intent of this section to claim rights or contest
125
+ your rights to work written entirely by you; rather, the intent is to
126
+ exercise the right to control the distribution of derivative or
127
+ collective works based on the Program.
128
+
129
+ In addition, mere aggregation of another work not based on the Program
130
+ with the Program (or with a work based on the Program) on a volume of
131
+ a storage or distribution medium does not bring the other work under
132
+ the scope of this License.
133
+
134
+ 3. You may copy and distribute the Program (or a work based on it,
135
+ under Section 2) in object code or executable form under the terms of
136
+ Sections 1 and 2 above provided that you also do one of the following:
137
+
138
+ a) Accompany it with the complete corresponding machine-readable
139
+ source code, which must be distributed under the terms of Sections
140
+ 1 and 2 above on a medium customarily used for software interchange; or,
141
+
142
+ b) Accompany it with a written offer, valid for at least three
143
+ years, to give any third party, for a charge no more than your
144
+ cost of physically performing source distribution, a complete
145
+ machine-readable copy of the corresponding source code, to be
146
+ distributed under the terms of Sections 1 and 2 above on a medium
147
+ customarily used for software interchange; or,
148
+
149
+ c) Accompany it with the information you received as to the offer
150
+ to distribute corresponding source code. (This alternative is
151
+ allowed only for noncommercial distribution and only if you
152
+ received the program in object code or executable form with such
153
+ an offer, in accord with Subsection b above.)
154
+
155
+ The source code for a work means the preferred form of the work for
156
+ making modifications to it. For an executable work, complete source
157
+ code means all the source code for all modules it contains, plus any
158
+ associated interface definition files, plus the scripts used to
159
+ control compilation and installation of the executable. However, as a
160
+ special exception, the source code distributed need not include
161
+ anything that is normally distributed (in either source or binary
162
+ form) with the major components (compiler, kernel, and so on) of the
163
+ operating system on which the executable runs, unless that component
164
+ itself accompanies the executable.
165
+
166
+ If distribution of executable or object code is made by offering
167
+ access to copy from a designated place, then offering equivalent
168
+ access to copy the source code from the same place counts as
169
+ distribution of the source code, even though third parties are not
170
+ compelled to copy the source along with the object code.
171
+
172
+ 4. You may not copy, modify, sublicense, or distribute the Program
173
+ except as expressly provided under this License. Any attempt
174
+ otherwise to copy, modify, sublicense or distribute the Program is
175
+ void, and will automatically terminate your rights under this License.
176
+ However, parties who have received copies, or rights, from you under
177
+ this License will not have their licenses terminated so long as such
178
+ parties remain in full compliance.
179
+
180
+ 5. You are not required to accept this License, since you have not
181
+ signed it. However, nothing else grants you permission to modify or
182
+ distribute the Program or its derivative works. These actions are
183
+ prohibited by law if you do not accept this License. Therefore, by
184
+ modifying or distributing the Program (or any work based on the
185
+ Program), you indicate your acceptance of this License to do so, and
186
+ all its terms and conditions for copying, distributing or modifying
187
+ the Program or works based on it.
188
+
189
+ 6. Each time you redistribute the Program (or any work based on the
190
+ Program), the recipient automatically receives a license from the
191
+ original licensor to copy, distribute or modify the Program subject to
192
+ these terms and conditions. You may not impose any further
193
+ restrictions on the recipients' exercise of the rights granted herein.
194
+ You are not responsible for enforcing compliance by third parties to
195
+ this License.
196
+
197
+ 7. If, as a consequence of a court judgment or allegation of patent
198
+ infringement or for any other reason (not limited to patent issues),
199
+ conditions are imposed on you (whether by court order, agreement or
200
+ otherwise) that contradict the conditions of this License, they do not
201
+ excuse you from the conditions of this License. If you cannot
202
+ distribute so as to satisfy simultaneously your obligations under this
203
+ License and any other pertinent obligations, then as a consequence you
204
+ may not distribute the Program at all. For example, if a patent
205
+ license would not permit royalty-free redistribution of the Program by
206
+ all those who receive copies directly or indirectly through you, then
207
+ the only way you could satisfy both it and this License would be to
208
+ refrain entirely from distribution of the Program.
209
+
210
+ If any portion of this section is held invalid or unenforceable under
211
+ any particular circumstance, the balance of the section is intended to
212
+ apply and the section as a whole is intended to apply in other
213
+ circumstances.
214
+
215
+ It is not the purpose of this section to induce you to infringe any
216
+ patents or other property right claims or to contest validity of any
217
+ such claims; this section has the sole purpose of protecting the
218
+ integrity of the free software distribution system, which is
219
+ implemented by public license practices. Many people have made
220
+ generous contributions to the wide range of software distributed
221
+ through that system in reliance on consistent application of that
222
+ system; it is up to the author/donor to decide if he or she is willing
223
+ to distribute software through any other system and a licensee cannot
224
+ impose that choice.
225
+
226
+ This section is intended to make thoroughly clear what is believed to
227
+ be a consequence of the rest of this License.
228
+
229
+ 8. If the distribution and/or use of the Program is restricted in
230
+ certain countries either by patents or by copyrighted interfaces, the
231
+ original copyright holder who places the Program under this License
232
+ may add an explicit geographical distribution limitation excluding
233
+ those countries, so that distribution is permitted only in or among
234
+ countries not thus excluded. In such case, this License incorporates
235
+ the limitation as if written in the body of this License.
236
+
237
+ 9. The Free Software Foundation may publish revised and/or new versions
238
+ of the General Public License from time to time. Such new versions will
239
+ be similar in spirit to the present version, but may differ in detail to
240
+ address new problems or concerns.
241
+
242
+ Each version is given a distinguishing version number. If the Program
243
+ specifies a version number of this License which applies to it and "any
244
+ later version", you have the option of following the terms and conditions
245
+ either of that version or of any later version published by the Free
246
+ Software Foundation. If the Program does not specify a version number of
247
+ this License, you may choose any version ever published by the Free Software
248
+ Foundation.
249
+
250
+ 10. If you wish to incorporate parts of the Program into other free
251
+ programs whose distribution conditions are different, write to the author
252
+ to ask for permission. For software which is copyrighted by the Free
253
+ Software Foundation, write to the Free Software Foundation; we sometimes
254
+ make exceptions for this. Our decision will be guided by the two goals
255
+ of preserving the free status of all derivatives of our free software and
256
+ of promoting the sharing and reuse of software generally.
257
+
258
+ NO WARRANTY
259
+
260
+ 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY
261
+ FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN
262
+ OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES
263
+ PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED
264
+ OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
265
+ MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS
266
+ TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE
267
+ PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING,
268
+ REPAIR OR CORRECTION.
269
+
270
+ 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
271
+ WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR
272
+ REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES,
273
+ INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING
274
+ OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED
275
+ TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY
276
+ YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER
277
+ PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE
278
+ POSSIBILITY OF SUCH DAMAGES.
279
+
280
+ END OF TERMS AND CONDITIONS
281
+
282
+ How to Apply These Terms to Your New Programs
283
+
284
+ If you develop a new program, and you want it to be of the greatest
285
+ possible use to the public, the best way to achieve this is to make it
286
+ free software which everyone can redistribute and change under these terms.
287
+
288
+ To do so, attach the following notices to the program. It is safest
289
+ to attach them to the start of each source file to most effectively
290
+ convey the exclusion of warranty; and each file should have at least
291
+ the "copyright" line and a pointer to where the full notice is found.
292
+
293
+ All-in-One Event Calendar 2.0
294
+ Copyright (C) 2013 Timely Network Inc.
295
+
296
+ This program is free software; you can redistribute it and/or modify
297
+ it under the terms of the GNU General Public License as published by
298
+ the Free Software Foundation; either version 2 of the License, or
299
+ (at your option) any later version.
300
+
301
+ This program is distributed in the hope that it will be useful,
302
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
303
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
304
+ GNU General Public License for more details.
305
+
306
+ You should have received a copy of the GNU General Public License along
307
+ with this program; if not, write to the Free Software Foundation, Inc.,
308
+ 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
309
+
310
+ Also add information on how to contact you by electronic and paper mail.
311
+
312
+ If the program is interactive, make it output a short notice like this
313
+ when it starts in an interactive mode:
314
+
315
+ Gnomovision version 69, Copyright (C) year name of author
316
+ Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
317
+ This is free software, and you are welcome to redistribute it
318
+ under certain conditions; type `show c' for details.
319
+
320
+ The hypothetical commands `show w' and `show c' should show the appropriate
321
+ parts of the General Public License. Of course, the commands you use may
322
+ be called something other than `show w' and `show c'; they could even be
323
+ mouse-clicks or menu items--whatever suits your program.
324
+
325
+ You should also get your employer (if you work as a programmer) or your
326
+ school, if any, to sign a "copyright disclaimer" for the program, if
327
+ necessary. Here is a sample; alter the names:
328
+
329
+ Yoyodyne, Inc., hereby disclaims all copyright interest in the program
330
+ `Gnomovision' (which makes passes at compilers) written by James Hacker.
331
+
332
+ {signature of Ty Coon}, 1 April 1989
333
+ Ty Coon, President of Vice
334
+
335
+ This General Public License does not permit incorporating your program into
336
+ proprietary programs. If your program is a subroutine library, you may
337
+ consider it more useful to permit linking proprietary applications with the
338
+ library. If this is what you want to do, use the GNU Lesser General
339
+ Public License instead of this License.
README.md ADDED
@@ -0,0 +1,4 @@
 
 
 
 
1
+ all-in-one-event-calendar
2
+ =========================
3
+
4
+ All-in-One Event Calendar 2.0
all-in-one-event-calendar.php CHANGED
@@ -1,351 +1,90 @@
1
  <?php
2
  /**
3
- * Plugin Name: All-in-One Event Calendar by Timely
4
  * Plugin URI: http://time.ly/
5
  * Description: A calendar system with month, week, day, agenda views, upcoming events widget, color-coded categories, recurrence, and import/export of .ics feeds.
6
- * Author: Timely
7
  * Author URI: http://time.ly/
8
- * Version: 1.10.5
 
 
9
  */
10
- @set_time_limit( 0 );
11
- @ini_set( 'memory_limit', '256M' );
12
- @ini_set( 'max_input_time', '-1' );
13
 
14
- // ===============
15
- // = Plugin Name =
16
- // ===============
17
- define( 'AI1EC_PLUGIN_NAME', 'all-in-one-event-calendar' );
18
 
19
- // ===================
20
- // = Plugin Basename =
21
- // ===================
22
- define( 'AI1EC_PLUGIN_BASENAME', plugin_basename( __FILE__ ) );
23
 
24
- // ==================
25
- // = Plugin Version =
26
- // ==================
27
- define( 'AI1EC_VERSION', '1.10.5' );
28
-
29
- // ====================
30
- // = Database Version =
31
- // ====================
32
- define( 'AI1EC_DB_VERSION', 109 );
33
-
34
- // ==========================
35
- // = Bundled themes version =
36
- // ==========================
37
- define( 'AI1EC_THEMES_VERSION', 8 );
38
-
39
- // ================
40
- // = Cron Version =
41
- // ================
42
- define( 'AI1EC_CRON_VERSION', 105 );
43
- define( 'AI1EC_N_CRON_VERSION', 104 );
44
- define( 'AI1EC_N_CRON_FREQ', 'daily' );
45
-
46
- // ===============
47
- // = Plugin Path =
48
- // ===============
49
- define( 'AI1EC_PATH', dirname( __FILE__ ) );
50
-
51
- // ===================
52
- // = CSS Folder name =
53
- // ===================
54
- define( 'AI1EC_CSS_FOLDER', 'css' );
55
-
56
- // ==================
57
- // = JS Folder name =
58
- // ==================
59
- define( 'AI1EC_JS_FOLDER', 'js' );
60
-
61
- // =====================
62
- // = Image folder name =
63
- // =====================
64
- define( 'AI1EC_IMG_FOLDER', 'img' );
65
-
66
- // ============
67
- // = Lib Path =
68
- // ============
69
- define( 'AI1EC_LIB_PATH', AI1EC_PATH . '/lib' );
70
-
71
- // =================
72
- // = Language Path =
73
- // =================
74
- define( 'AI1EC_LANGUAGE_PATH', AI1EC_PLUGIN_NAME . '/language' );
75
-
76
- // ============
77
- // = App Path =
78
- // ============
79
- define( 'AI1EC_APP_PATH', AI1EC_PATH . '/app' );
80
-
81
- // ===================
82
- // = Controller Path =
83
- // ===================
84
- define( 'AI1EC_CONTROLLER_PATH', AI1EC_APP_PATH . '/controller' );
85
-
86
- // ==============
87
- // = Model Path =
88
- // ==============
89
- define( 'AI1EC_MODEL_PATH', AI1EC_APP_PATH . '/model' );
90
-
91
- // =============
92
- // = View Path =
93
- // =============
94
- define( 'AI1EC_VIEW_PATH', AI1EC_APP_PATH . '/view' );
95
-
96
- // ====================
97
- // = Admin Theme Path =
98
- // ====================
99
- define( 'AI1EC_ADMIN_THEME_PATH', AI1EC_VIEW_PATH . '/admin' );
100
-
101
- // =======================
102
- // = Admin Local JS Path =
103
- // =======================
104
- define( 'AI1EC_LOCAL_JS_THEME_PATH', AI1EC_PATH . '/themes-ai1ec/vortex/js' );
105
-
106
- // =======================
107
- // = Admin Local JS Path =
108
- // =======================
109
- define( 'AI1EC_LOCAL_CSS_THEME_PATH', AI1EC_PATH . '/themes-ai1ec/vortex/css' );
110
-
111
- // =======================
112
- // = Admin Local JS Path =
113
- // =======================
114
- define( 'AI1EC_LOCAL_VIEW_THEME_PATH', AI1EC_PATH . '/themes-ai1ec/vortex' );
115
-
116
- // ==================
117
- // = Admin theme CSS path =
118
- // ==================
119
- define( 'AI1EC_ADMIN_THEME_CSS_PATH', AI1EC_ADMIN_THEME_PATH . '/' . AI1EC_CSS_FOLDER );
120
-
121
- // =======================
122
- // = Admin theme JS path =
123
- // =======================
124
- define( 'AI1EC_ADMIN_THEME_JS_PATH', AI1EC_ADMIN_THEME_PATH . '/' . AI1EC_JS_FOLDER );
125
-
126
- // ========================
127
- // = Admin theme IMG path =
128
- // ========================
129
- define( 'AI1EC_ADMIN_THEME_IMG_PATH', AI1EC_ADMIN_THEME_PATH . '/' . AI1EC_IMG_FOLDER );
130
-
131
- // ===============
132
- // = Helper Path =
133
- // ===============
134
- define( 'AI1EC_HELPER_PATH', AI1EC_APP_PATH . '/helper' );
135
-
136
- // ==================
137
- // = Exception Path =
138
- // ==================
139
- define( 'AI1EC_EXCEPTION_PATH', AI1EC_APP_PATH . '/exception' );
140
-
141
- // ==============
142
- // = Plugin Url =
143
- // ==============
144
- define( 'AI1EC_URL', plugins_url( '', __FILE__ ) );
145
-
146
- // ==============
147
- // = Images URL =
148
- // ==============
149
- define( 'AI1EC_IMAGE_URL', AI1EC_URL . '/' . AI1EC_IMG_FOLDER );
150
-
151
- // ===========
152
- // = CSS URL =
153
- // ===========
154
- define( 'AI1EC_CSS_URL', AI1EC_URL . '/' . AI1EC_CSS_FOLDER );
155
-
156
- // ==========
157
- // = JS URL =
158
- // ==========
159
- define( 'AI1EC_JS_URL', AI1EC_URL . '/' . AI1EC_JS_FOLDER );
160
-
161
- // ================
162
- // = JS local URL =
163
- // ================
164
- define( 'AI1EC_LOCAL_JS_URL', AI1EC_URL . '/themes-ai1ec/vortex/js' );
165
-
166
- // =================
167
- // = CSS local URL =
168
- // =================
169
- define( 'AI1EC_LOCAL_CSS_URL', AI1EC_URL . '/themes-ai1ec/vortex/css' );
170
-
171
- // ================
172
- // = Admin JS URL =
173
- // ================
174
- define( 'AI1EC_ADMIN_THEME_JS_URL', AI1EC_URL . '/app/view/admin/' . AI1EC_JS_FOLDER );
175
-
176
- // =================
177
- // = Admin CSS URL =
178
- // =================
179
- define( 'AI1EC_ADMIN_THEME_CSS_URL', AI1EC_URL . '/app/view/admin/' . AI1EC_CSS_FOLDER );
180
-
181
- // =================
182
- // = Admin IMG URL =
183
- // =================
184
- define( 'AI1EC_ADMIN_THEME_IMG_URL', AI1EC_URL . '/app/view/admin/' . AI1EC_IMG_FOLDER );
185
-
186
- // =============
187
- // = POST TYPE =
188
- // =============
189
- define( 'AI1EC_POST_TYPE', 'ai1ec_event' );
190
-
191
- // =====================================================
192
- // = UPDATE THEMES PAGE BASE URL (wrap in admin_url()) =
193
- // =====================================================
194
- define( 'AI1EC_UPDATE_THEMES_BASE_URL', 'edit.php?post_type=' . AI1EC_POST_TYPE . '&page=' . AI1EC_PLUGIN_NAME . '-update-themes' );
195
-
196
- // =====================================================
197
- // = FEED SETTINGS PAGE BASE URL (wrap in admin_url()) =
198
- // =====================================================
199
- define( 'AI1EC_FEED_SETTINGS_BASE_URL', 'edit.php?post_type=' . AI1EC_POST_TYPE . '&page=' . AI1EC_PLUGIN_NAME . '-feeds' );
200
-
201
- // ================================================
202
- // = SETTINGS PAGE BASE URL (wrap in admin_url()) =
203
- // ================================================
204
- define( 'AI1EC_SETTINGS_BASE_URL', 'edit.php?post_type=' . AI1EC_POST_TYPE . '&page=' . AI1EC_PLUGIN_NAME . '-settings' );
205
-
206
- // ======================
207
- // = Default Theme Name =
208
- // ======================
209
- define( 'AI1EC_DEFAULT_THEME_NAME', 'vortex' );
210
-
211
- // =============================
212
- // = Default Theme folder name =
213
- // =============================
214
- define( 'AI1EC_THEMES_FOLDER', 'themes-ai1ec' );
215
-
216
- // ========================
217
- // = AI1EC Theme location =
218
- // ========================
219
- define( 'AI1EC_THEMES_ROOT', WP_CONTENT_DIR . '/' . AI1EC_THEMES_FOLDER );
220
-
221
- // ===================
222
- // = AI1EC Theme URL =
223
- // ===================
224
- define( 'AI1EC_THEMES_URL', WP_CONTENT_URL . '/' . AI1EC_THEMES_FOLDER );
225
-
226
- // ======================
227
- // = Default theme path =
228
- // ======================
229
- define( 'AI1EC_DEFAULT_THEME_PATH', AI1EC_THEMES_ROOT . '/' . AI1EC_DEFAULT_THEME_NAME );
230
-
231
- // =====================
232
- // = Default theme url =
233
- // =====================
234
- define( 'AI1EC_DEFAULT_THEME_URL', AI1EC_THEMES_URL . '/' . AI1EC_DEFAULT_THEME_NAME );
235
-
236
- // ======================================================
237
- // = INSTALL THEMES PAGE BASE URL (wrap in admin_url()) =
238
- // ======================================================
239
- define( 'AI1EC_INSTALL_THEMES_BASE_URL', 'themes.php?page=' . AI1EC_PLUGIN_NAME . '-install-themes' );
240
-
241
- // ================
242
- // = RSS FEED URL =
243
- // ================
244
- define( 'AI1EC_RSS_FEED', 'http://time.ly/feed/' );
245
-
246
- // ======================================
247
- // = FAKE CATEGORY ID FOR CALENDAR PAGE =
248
- // ======================================
249
- define( 'AI1EC_FAKE_CATEGORY_ID', -4113473042 ); // Numeric-only 1337-speak of AI1EC_CALENDAR - ID must be numeric
250
-
251
- // ==============
252
- // = SCRIPT URL =
253
- // ==============
254
- $ai1ec_script_url = get_option( 'home' ) . '/?plugin=' . AI1EC_PLUGIN_NAME;
255
- define( 'AI1EC_SCRIPT_URL', $ai1ec_script_url );
256
-
257
- // ====================================================
258
- // = Convert http:// to webcal:// in AI1EC_SCRIPT_URL =
259
- // = (webcal:// protocol does not support https://) =
260
- // ====================================================
261
- $tmp = str_replace( 'http://', 'webcal://', AI1EC_SCRIPT_URL );
262
-
263
- // ==============
264
- // = EXPORT URL =
265
- // ==============
266
- define( 'AI1EC_EXPORT_URL', $tmp . "&controller=ai1ec_exporter_controller&action=export_events&cb=" . rand() );
267
-
268
- require_once( AI1EC_LIB_PATH . '/iCalcreator-2.16/iCalcreator.class.php' );
269
-
270
- // include our global functions
271
- require_once( AI1EC_LIB_PATH . '/global-functions.php' );
272
 
273
- // ===============================
274
- // = The autoload function =
275
- // ===============================
276
- function ai1ec_autoload( $class_name )
277
- {
278
- // Convert class name to filename format.
279
- $class_name = strtr( strtolower( $class_name ), '_', '-' );
280
- $paths = array(
281
- AI1EC_CONTROLLER_PATH,
282
- AI1EC_MODEL_PATH,
283
- AI1EC_HELPER_PATH,
284
- AI1EC_EXCEPTION_PATH,
285
- AI1EC_LIB_PATH,
286
- AI1EC_VIEW_PATH,
287
- AI1EC_ADMIN_THEME_PATH,
288
- get_option( 'ai1ec_current_theme_path', AI1EC_DEFAULT_THEME_PATH ),
289
- AI1EC_DEFAULT_THEME_PATH
290
  );
291
-
292
- // remove duplicates from the paths array
293
- $paths = array_unique( $paths );
294
-
295
- // Search each path for the class.
296
- foreach( $paths as $path ) {
297
- if( file_exists( "$path/class-$class_name.php" ) )
298
- require_once( "$path/class-$class_name.php" );
299
- }
300
  }
301
- spl_autoload_register( 'ai1ec_autoload' );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
302
 
303
- // ===============================
304
- // = Initialize and setup MODELS =
305
- // ===============================
306
- global $ai1ec_settings;
307
 
308
- $ai1ec_settings = Ai1ec_Settings::get_instance();
 
309
 
 
 
310
 
311
- // ================================
312
- // = Initialize and setup HELPERS =
313
- // ================================
314
- global $ai1ec_view_helper,
315
- $ai1ec_settings_helper,
316
- $ai1ec_calendar_helper,
317
- $ai1ec_app_helper,
318
- $ai1ec_events_helper,
319
- $ai1ec_importer_helper,
320
- $ai1ec_exporter_helper;
321
 
322
- $ai1ec_view_helper = Ai1ec_View_Helper::get_instance();
323
- $ai1ec_settings_helper = Ai1ec_Settings_Helper::get_instance();
324
- $ai1ec_calendar_helper = Ai1ec_Calendar_Helper::get_instance();
325
- $ai1ec_app_helper = Ai1ec_App_Helper::get_instance();
326
- $ai1ec_events_helper = Ai1ec_Events_Helper::get_instance();
327
- $ai1ec_importer_helper = Ai1ec_Importer_Helper::get_instance();
328
- $ai1ec_exporter_helper = Ai1ec_Exporter_Helper::get_instance();
329
 
330
- // ====================================
331
- // = Initialize and setup CONTROLLERS =
332
- // ====================================
333
- global $ai1ec_app_controller,
334
- $ai1ec_settings_controller,
335
- $ai1ec_events_controller,
336
- $ai1ec_calendar_controller,
337
- $ai1ec_importer_controller,
338
- $ai1ec_exporter_controller,
339
- $ai1ec_themes_controller;
340
 
341
- $ai1ec_settings_controller = Ai1ec_Settings_Controller::get_instance();
342
- $ai1ec_events_controller = Ai1ec_Events_Controller::get_instance();
343
- $ai1ec_calendar_controller = Ai1ec_Calendar_Controller::get_instance();
344
- $ai1ec_importer_controller = Ai1ec_Importer_Controller::get_instance();
345
- $ai1ec_exporter_controller = Ai1ec_Exporter_Controller::get_instance();
346
- $ai1ec_themes_controller = Ai1ec_Themes_Controller::get_instance();
347
 
348
- // ==========================================================================
349
- // = All app initialization is done in Ai1ec_App_Controller::__construct(). =
350
- // ==========================================================================
351
- $ai1ec_app_controller = Ai1ec_App_Controller::get_instance();
1
  <?php
2
  /**
3
+ * Plugin Name: All-in-One Event Calendar by Time.ly
4
  * Plugin URI: http://time.ly/
5
  * Description: A calendar system with month, week, day, agenda views, upcoming events widget, color-coded categories, recurrence, and import/export of .ics feeds.
6
+ * Author: Time.ly Network Inc.
7
  * Author URI: http://time.ly/
8
+ * Version: 2.0.6
9
+ * Text Domain: all-in-one-event-calendar
10
+ * Domain Path: /language
11
  */
 
 
 
12
 
13
+ $ai1ec_base_dir = dirname( __FILE__ );
14
+ $ai1ec_base_url = plugins_url( '', __FILE__ );
 
 
15
 
16
+ $ai1ec_config_path = $ai1ec_base_dir . DIRECTORY_SEPARATOR . 'app' .
17
+ DIRECTORY_SEPARATOR . 'config' . DIRECTORY_SEPARATOR;
 
 
18
 
19
+ // Include configuration files and initiate global constants as they are used
20
+ // By the error/exception handler too.
21
+ foreach ( array( 'constants-local.php', 'constants.php' ) as $file ) {
22
+ if ( is_file( $ai1ec_config_path . $file ) ) {
23
+ require_once $ai1ec_config_path . $file;
24
+ }
25
+ }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
26
 
27
+ if ( ! function_exists( 'ai1ec_initiate_constants' ) ) {
28
+ throw new Ai1ec_Exception(
29
+ 'No constant file was found.'
 
 
 
 
 
 
 
 
 
 
 
 
 
 
30
  );
 
 
 
 
 
 
 
 
 
31
  }
32
+ ai1ec_initiate_constants( $ai1ec_base_dir, $ai1ec_base_url );
33
+
34
+ require $ai1ec_base_dir . DIRECTORY_SEPARATOR . 'lib' .
35
+ DIRECTORY_SEPARATOR . 'exception' . DIRECTORY_SEPARATOR . 'ai1ec.php';
36
+ require $ai1ec_base_dir . DIRECTORY_SEPARATOR . 'lib' .
37
+ DIRECTORY_SEPARATOR . 'exception' . DIRECTORY_SEPARATOR . 'error.php';
38
+ require $ai1ec_base_dir . DIRECTORY_SEPARATOR . 'lib' .
39
+ DIRECTORY_SEPARATOR . 'exception' . DIRECTORY_SEPARATOR . 'handler.php';
40
+ require $ai1ec_base_dir . DIRECTORY_SEPARATOR . 'lib' .
41
+ DIRECTORY_SEPARATOR . 'http' . DIRECTORY_SEPARATOR . 'response' .
42
+ DIRECTORY_SEPARATOR . 'helper.php';
43
+ $ai1ec_exception_handler = new Ai1ec_Exception_Handler(
44
+ 'Ai1ec_Exception',
45
+ 'Ai1ec_Error_Exception'
46
+ );
47
+
48
+ // if the user clicked the link to reactivate the plugin
49
+ if ( isset( $_GET[Ai1ec_Exception_Handler::DB_REACTIVATE_PLUGIN] ) ) {
50
+ $ai1ec_exception_handler->reactivate_plugin();
51
+ }
52
+ $soft_disable_message = $ai1ec_exception_handler->get_disabled_message();
53
+ if ( false !== $soft_disable_message ) {
54
+ return $ai1ec_exception_handler->show_notices( $soft_disable_message );
55
+ }
56
+
57
+ $prev_er_handler = set_error_handler(
58
+ array( $ai1ec_exception_handler, 'handle_error' )
59
+ );
60
+ $prev_ex_handler = set_exception_handler(
61
+ array( $ai1ec_exception_handler, 'handle_exception' )
62
+ );
63
+ $ai1ec_exception_handler->set_prev_er_handler( $prev_er_handler );
64
+ $ai1ec_exception_handler->set_prev_ex_handler( $prev_ex_handler );
65
 
66
+ // Regular startup sequence starts here
 
 
 
67
 
68
+ require $ai1ec_base_dir . DIRECTORY_SEPARATOR . 'lib' .
69
+ DIRECTORY_SEPARATOR . 'bootstrap' . DIRECTORY_SEPARATOR . 'loader.php';
70
 
71
+ require $ai1ec_base_dir . DIRECTORY_SEPARATOR . 'lib' .
72
+ DIRECTORY_SEPARATOR . 'global-functions.php';
73
 
74
+ require $ai1ec_base_dir . DIRECTORY_SEPARATOR . 'app' .
75
+ DIRECTORY_SEPARATOR . 'controller' . DIRECTORY_SEPARATOR . 'extension.php';
 
 
 
 
 
 
 
 
76
 
77
+ require $ai1ec_base_dir . DIRECTORY_SEPARATOR . 'app' .
78
+ DIRECTORY_SEPARATOR . 'controller' . DIRECTORY_SEPARATOR . 'extension-license.php';
 
 
 
 
 
79
 
80
+ $ai1ec_loader = new Ai1ec_Loader( $ai1ec_base_dir );
 
 
 
 
 
 
 
 
 
81
 
82
+ $ai1ec_loader->register_map(
83
+ $ai1ec_base_dir . DIRECTORY_SEPARATOR . 'vendor' . DIRECTORY_SEPARATOR .
84
+ 'composer' . DIRECTORY_SEPARATOR . 'autoload_classmap.php'
85
+ );
86
+ @ini_set( 'unserialize_callback_func', 'spl_autoload_call' );
87
+ spl_autoload_register( array( $ai1ec_loader, 'load' ) );
88
 
89
+ $ai1ec_front_controller = new Ai1ec_Front_Controller();
90
+ $ai1ec_front_controller->initialize( $ai1ec_loader );
 
 
app/config/constants.php ADDED
@@ -0,0 +1,461 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * Define required constants, if these have not been defined already.
5
+ *
6
+ * @param string $ai1ec_base_dir Sanitized, absolute, path to Ai1EC base dir
7
+ *
8
+ * @uses plugin_basename To determine plug-in folder+file name
9
+ * @uses plugins_url To determine absolute URI to plug-ins' folder
10
+ * @uses get_option To fetch 'home' URI value
11
+ *
12
+ * @return void Method does not return
13
+ */
14
+ function ai1ec_initiate_constants( $ai1ec_base_dir, $ai1ec_base_url ) {
15
+
16
+ // ===============
17
+ // = Plugin Path =
18
+ // ===============
19
+ if ( ! defined( 'AI1EC_PATH' ) ) {
20
+ define( 'AI1EC_PATH', $ai1ec_base_dir );
21
+ }
22
+
23
+ // =======================
24
+ // = Extensions base dir =
25
+ // =======================
26
+ if ( ! defined( 'AI1EC_EXTENSIONS_BASEDIR' ) ) {
27
+ define(
28
+ 'AI1EC_EXTENSIONS_BASEDIR',
29
+ dirname( $ai1ec_base_dir ) . DIRECTORY_SEPARATOR
30
+ );
31
+ }
32
+
33
+ // ===============
34
+ // = Plugin Name =
35
+ // ===============
36
+ if ( ! defined( 'AI1EC_PLUGIN_NAME' ) ) {
37
+ define( 'AI1EC_PLUGIN_NAME', 'all-in-one-event-calendar' );
38
+ }
39
+
40
+ // ===================
41
+ // = Plugin Basename =
42
+ // ===================
43
+ if ( ! defined( 'AI1EC_PLUGIN_BASENAME' ) ) {
44
+ $plugin = AI1EC_PATH . DIRECTORY_SEPARATOR . AI1EC_PLUGIN_NAME . '.php';
45
+ define( 'AI1EC_PLUGIN_BASENAME', plugin_basename( $plugin ) );
46
+ unset( $plugin );
47
+ }
48
+
49
+ // ==================
50
+ // = Plugin Version =
51
+ // ==================
52
+ if ( ! defined( 'AI1EC_VERSION' ) ) {
53
+ define( 'AI1EC_VERSION', '2.0.6' );
54
+ }
55
+
56
+ // ================
57
+ // = RSS FEED URL =
58
+ // ================
59
+ if ( ! defined( 'AI1EC_RSS_FEED' ) ) {
60
+ define( 'AI1EC_RSS_FEED', 'http://time.ly/feed/' );
61
+ }
62
+
63
+ // =================
64
+ // = Language Path =
65
+ // =================
66
+ if ( ! defined( 'AI1EC_LANGUAGE_PATH' ) ) {
67
+ define(
68
+ 'AI1EC_LANGUAGE_PATH',
69
+ AI1EC_PLUGIN_NAME . DIRECTORY_SEPARATOR . 'language' . DIRECTORY_SEPARATOR
70
+ );
71
+ }
72
+ // ================
73
+ // = Cron Version =
74
+ // ================
75
+ if ( ! defined( 'AI1EC_CRON_VERSION' ) ) {
76
+ define( 'AI1EC_CRON_VERSION', AI1EC_VERSION );
77
+ }
78
+ if ( ! defined( 'AI1EC_N_CRON_VERSION' ) ) {
79
+ define( 'AI1EC_N_CRON_VERSION', AI1EC_VERSION );
80
+ }
81
+ if ( ! defined( 'AI1EC_N_CRON_FREQ' ) ) {
82
+ define( 'AI1EC_N_CRON_FREQ', 'daily' );
83
+ }
84
+ if ( ! defined( 'AI1EC_U_CRON_VERSION' ) ) {
85
+ define( 'AI1EC_U_CRON_VERSION', AI1EC_VERSION );
86
+ }
87
+ if ( ! defined( 'AI1EC_U_CRON_FREQ' ) ) {
88
+ define( 'AI1EC_U_CRON_FREQ', 'hourly' );
89
+ }
90
+ if ( ! defined( 'AI1EC_UPDATES_URL' ) ) {
91
+ define( 'AI1EC_UPDATES_URL', 'http://api.time.ly/plugin/pro/latest' );
92
+ }
93
+
94
+
95
+ // ==============
96
+ // = Plugin Url =
97
+ // ==============
98
+ if ( ! defined( 'AI1EC_URL' ) ) {
99
+ define( 'AI1EC_URL', $ai1ec_base_url );
100
+ }
101
+
102
+ // ===============
103
+ // = VENDOR PATH =
104
+ // ===============
105
+ if ( ! defined( 'AI1EC_VENDOR_PATH' ) ) {
106
+ define(
107
+ 'AI1EC_VENDOR_PATH',
108
+ AI1EC_PATH . DIRECTORY_SEPARATOR . 'vendor' .
109
+ DIRECTORY_SEPARATOR
110
+ );
111
+ }
112
+
113
+ // ===============
114
+ // = ADMIN PATH =
115
+ // ===============
116
+ if ( ! defined( 'AI1EC_ADMIN_PATH' ) ) {
117
+ define(
118
+ 'AI1EC_ADMIN_PATH',
119
+ AI1EC_PATH . DIRECTORY_SEPARATOR . 'public' .
120
+ DIRECTORY_SEPARATOR . 'admin' . DIRECTORY_SEPARATOR
121
+ );
122
+ }
123
+
124
+ // ===============
125
+ // = ADMIN URL =
126
+ // ===============
127
+ if ( ! defined( 'AI1EC_ADMIN_URL' ) ) {
128
+ define(
129
+ 'AI1EC_ADMIN_URL',
130
+ AI1EC_URL . '/public/admin/'
131
+ );
132
+ }
133
+
134
+ // ==============
135
+ // = CACHE PATH =
136
+ // ==============
137
+ if ( ! defined( 'AI1EC_CACHE_PATH' ) ) {
138
+ define(
139
+ 'AI1EC_CACHE_PATH',
140
+ AI1EC_PATH . DIRECTORY_SEPARATOR . 'cache' .
141
+ DIRECTORY_SEPARATOR
142
+ );
143
+ }
144
+
145
+ // ==============
146
+ // = TWIG CACHE PATH =
147
+ // ==============
148
+ if ( ! defined( 'AI1EC_TWIG_CACHE_PATH' ) ) {
149
+ define(
150
+ 'AI1EC_TWIG_CACHE_PATH',
151
+ AI1EC_CACHE_PATH . DIRECTORY_SEPARATOR . 'twig' .
152
+ DIRECTORY_SEPARATOR
153
+ );
154
+ }
155
+
156
+ // ======================
157
+ // = Default theme name =
158
+ // ======================
159
+ if ( ! defined( 'AI1EC_DEFAULT_THEME_NAME' ) ) {
160
+ define( 'AI1EC_DEFAULT_THEME_NAME', 'vortex' );
161
+ }
162
+ // ================
163
+ // = THEME FOLDER =
164
+ // ================
165
+ if ( ! defined( 'AI1EC_THEME_FOLDER' ) ) {
166
+ define( 'AI1EC_THEME_FOLDER', 'themes-ai1ec' );
167
+ }
168
+
169
+ // =======================
170
+ // = DEFAULT THEME PATH =
171
+ // =======================
172
+ if ( ! defined( 'AI1EC_DEFAULT_THEME_ROOT' ) ) {
173
+ define(
174
+ 'AI1EC_DEFAULT_THEME_ROOT',
175
+ AI1EC_PATH . DIRECTORY_SEPARATOR . 'public' .
176
+ DIRECTORY_SEPARATOR . AI1EC_THEME_FOLDER
177
+ );
178
+ }
179
+
180
+ // =======================
181
+ // = DEFAULT THEME PATH =
182
+ // =======================
183
+ if ( ! defined( 'AI1EC_DEFAULT_THEME_PATH' ) ) {
184
+ define(
185
+ 'AI1EC_DEFAULT_THEME_PATH',
186
+ AI1EC_DEFAULT_THEME_ROOT . DIRECTORY_SEPARATOR .
187
+ AI1EC_DEFAULT_THEME_NAME
188
+ );
189
+ }
190
+
191
+ // ===================
192
+ // = AI1EC Theme URL =
193
+ // ===================
194
+ if ( ! defined( 'AI1EC_THEMES_URL' ) ) {
195
+ define(
196
+ 'AI1EC_THEMES_URL',
197
+ AI1EC_URL . '/public/' . AI1EC_THEME_FOLDER
198
+ );
199
+ }
200
+
201
+
202
+ // =====================
203
+ // = AI1EC Core themes =
204
+ // =====================
205
+ if ( ! defined( 'AI1EC_CORE_THEMES' ) ) {
206
+ define( 'AI1EC_CORE_THEMES', 'vortex,umbra,gamma,plana' );
207
+ }
208
+
209
+ // ===================
210
+ // = AI1EC Theme URL =
211
+ // ===================
212
+ if ( ! defined( 'AI1EC_THEMES_URL' ) ) {
213
+ define( 'AI1EC_THEMES_URL', AI1EC_URL . '/public/' . AI1EC_THEME_FOLDER . '/' );
214
+ }
215
+
216
+ // =================
217
+ // = Admin CSS URL =
218
+ // =================
219
+ if ( ! defined( 'AI1EC_ADMIN_THEME_CSS_URL' ) ) {
220
+ define( 'AI1EC_ADMIN_THEME_CSS_URL', AI1EC_URL .'/public/admin/css/' );
221
+ }
222
+
223
+ // =================
224
+ // = Admin Font URL =
225
+ // =================
226
+ if ( ! defined( 'AI1EC_ADMIN_THEME_FONT_URL' ) ) {
227
+ define( 'AI1EC_ADMIN_THEME_FONT_URL', AI1EC_URL .'/public/admin/font/' );
228
+ }
229
+
230
+ // =================
231
+ // = Admin Js URL =
232
+ // =================
233
+ if ( ! defined( 'AI1EC_ADMIN_THEME_JS_URL' ) ) {
234
+ define( 'AI1EC_ADMIN_THEME_JS_URL', AI1EC_URL .'/public/js/' );
235
+ }
236
+
237
+ // =============
238
+ // = POST TYPE =
239
+ // =============
240
+ if ( ! defined( 'AI1EC_POST_TYPE' ) ) {
241
+ define( 'AI1EC_POST_TYPE', 'ai1ec_event' );
242
+ }
243
+
244
+ // ==============
245
+ // = SCRIPT URL =
246
+ // ==============
247
+ if ( ! defined( 'AI1EC_SCRIPT_URL' ) ) {
248
+ define(
249
+ 'AI1EC_SCRIPT_URL',
250
+ get_option( 'home' ) . '/?plugin=' . AI1EC_PLUGIN_NAME
251
+ );
252
+ }
253
+
254
+ // =========================================
255
+ // = BASE URL FOR ALL CALENDAR ADMIN PAGES =
256
+ // =========================================
257
+ if ( ! defined( 'AI1EC_ADMIN_BASE_URL' ) ) {
258
+ define( 'AI1EC_ADMIN_BASE_URL', 'edit.php?post_type=' . AI1EC_POST_TYPE );
259
+ }
260
+
261
+
262
+ // =====================================================
263
+ // = THEME OPTIONS PAGE BASE URL (wrap in admin_url()) =
264
+ // =====================================================
265
+ if ( ! defined( 'AI1EC_THEME_OPTIONS_BASE_URL' ) ) {
266
+ define( 'AI1EC_THEME_OPTIONS_BASE_URL', AI1EC_ADMIN_BASE_URL . '&page=' . AI1EC_PLUGIN_NAME . '-edit-css' );
267
+ }
268
+
269
+ // =======================================================
270
+ // = THEME SELECTION PAGE BASE URL (wrap in admin_url()) =
271
+ // =======================================================
272
+ if ( ! defined( 'AI1EC_THEME_SELECTION_BASE_URL' ) ) {
273
+ define(
274
+ 'AI1EC_THEME_SELECTION_BASE_URL',
275
+ AI1EC_ADMIN_BASE_URL . '&page=' . AI1EC_PLUGIN_NAME . '-themes'
276
+ );
277
+ }
278
+
279
+
280
+ // =====================================================
281
+ // = FEED SETTINGS PAGE BASE URL (wrap in admin_url()) =
282
+ // =====================================================
283
+ if ( ! defined( 'AI1EC_FEED_SETTINGS_BASE_URL' ) ) {
284
+ define( 'AI1EC_FEED_SETTINGS_BASE_URL', AI1EC_ADMIN_BASE_URL . '&page=' . AI1EC_PLUGIN_NAME . '-feeds' );
285
+ }
286
+
287
+ // ================================================
288
+ // = SETTINGS PAGE BASE URL (wrap in admin_url()) =
289
+ // ================================================
290
+ if ( ! defined( 'AI1EC_SETTINGS_BASE_URL' ) ) {
291
+ define(
292
+ 'AI1EC_SETTINGS_BASE_URL',
293
+ AI1EC_ADMIN_BASE_URL . '&page=' . AI1EC_PLUGIN_NAME . '-settings'
294
+ );
295
+ }
296
+
297
+ // ==============
298
+ // = EXPORT URL =
299
+ // ==============
300
+ if ( ! defined( 'AI1EC_EXPORT_URL' ) ) {
301
+ // ====================================================
302
+ // = Convert http:// to webcal:// in AI1EC_SCRIPT_URL =
303
+ // = (webcal:// protocol does not support https://) =
304
+ // ====================================================
305
+ $webcal_url = str_replace( 'http://', 'webcal://', AI1EC_SCRIPT_URL );
306
+ define(
307
+ 'AI1EC_EXPORT_URL',
308
+ $webcal_url . '&controller=ai1ec_exporter_controller' .
309
+ '&action=export_events&cb=' . rand()
310
+ );
311
+ unset( $webcal_url );
312
+ }
313
+
314
+ // =================
315
+ // = LOCATIONS API =
316
+ // =================
317
+ if ( ! defined( 'AI1EC_LOCATIONS_API' ) ) {
318
+ define( 'AI1EC_LOCATIONS_API', 'http://api.time.ly:32000' );
319
+ }
320
+
321
+ // =============
322
+ // = STATS API =
323
+ // =============
324
+ if ( ! defined( 'AI1EC_STATS_API' ) ) {
325
+ define( 'AI1EC_STATS_API', 'http://api.time.ly:31000' );
326
+ }
327
+
328
+ if ( ! defined( 'AI1EC_CA_ROOT_PEM' ) ) {
329
+ define(
330
+ 'AI1EC_CA_ROOT_PEM',
331
+ AI1EC_PATH . DIRECTORY_SEPARATOR . 'ca_cert' .
332
+ DIRECTORY_SEPARATOR . 'ca_cert.pem'
333
+ );
334
+ }
335
+
336
+ // ====================
337
+ // = SPECIAL SETTINGS =
338
+ // ====================
339
+
340
+ // Set AI1EC_EVENT_PLATFORM to TRUE to turn WordPress into an events-only
341
+ // platform. For a multi-site install, setting this to TRUE is equivalent to a
342
+ // super-administrator selecting the
343
+ // "Turn this blog into an events-only platform" checkbox
344
+ // on the Calendar Settings page of every blog on the network.
345
+ // This mode, when enabled on blogs where this plugin is active, hides all
346
+ // administrative functions unrelated to events and the calendar (except to
347
+ // super-administrators), and sets default WordPress settings appropriate for
348
+ // pure event management.
349
+ if ( ! defined( 'AI1EC_EVENT_PLATFORM' ) ) {
350
+ define( 'AI1EC_EVENT_PLATFORM', false );
351
+ }
352
+
353
+ // If i choose to use the calendar url as the base for events permalinks,
354
+ // i must specify another name for the events archive.
355
+ if ( ! defined( 'AI1EC_ALTERNATIVE_ARCHIVE_URL' ) ) {
356
+ define( 'AI1EC_ALTERNATIVE_ARCHIVE_URL', 'ai1ec_events_archive' );
357
+ }
358
+
359
+ // ===============================
360
+ // = Time.ly redirection service =
361
+ // ===============================
362
+ if ( ! defined( 'AI1EC_REDIRECTION_SERVICE' ) ) {
363
+ define(
364
+ 'AI1EC_REDIRECTION_SERVICE',
365
+ 'http://aggregator.time.ly/ticket_redirect/'
366
+ );
367
+ }
368
+
369
+
370
+ // ===================
371
+ // = AI1EC Theme URL =
372
+ // ===================
373
+ if ( ! defined( 'AI1EC_THEMES_URL_LEGACY' ) ) {
374
+ define( 'AI1EC_THEMES_URL_LEGACY', WP_CONTENT_URL . '/' . AI1EC_THEME_FOLDER );
375
+ }
376
+
377
+ // =====================
378
+ // = Default theme url legacy=
379
+ // =====================
380
+ if ( ! defined( 'AI1EC_DEFAULT_THEME_URL_LEGACY' ) ) {
381
+ define( 'AI1EC_DEFAULT_THEME_URL_LEGACY', AI1EC_THEMES_URL . '/' . AI1EC_DEFAULT_THEME_NAME . '/' );
382
+ }
383
+
384
+ // =====================
385
+ // = Default theme url =
386
+ // =====================
387
+ if ( ! defined( 'AI1EC_DEFAULT_THEME_URL' ) ) {
388
+ define( 'AI1EC_DEFAULT_THEME_URL', AI1EC_THEMES_URL . '/' . AI1EC_DEFAULT_THEME_NAME . '/' );
389
+ }
390
+
391
+ // ===================
392
+ // = CSS Folder name =
393
+ // ===================
394
+ if ( ! defined( 'AI1EC_CSS_FOLDER' ) ) {
395
+ define( 'AI1EC_CSS_FOLDER', 'css' );
396
+ }
397
+
398
+ // ==================
399
+ // = JS Folder name =
400
+ // ==================
401
+ if ( ! defined( 'AI1EC_JS_FOLDER' ) ) {
402
+ define( 'AI1EC_JS_FOLDER', 'js' );
403
+ }
404
+
405
+ // =====================
406
+ // = Image folder name =
407
+ // =====================
408
+ if ( ! defined( 'AI1EC_IMG_FOLDER' ) ) {
409
+ define( 'AI1EC_IMG_FOLDER', 'img' );
410
+ }
411
+
412
+
413
+
414
+ // ========================
415
+ // = Admin theme CSS path =
416
+ // ========================
417
+ if ( ! defined( 'AI1EC_ADMIN_THEME_CSS_PATH' ) ) {
418
+ define( 'AI1EC_ADMIN_THEME_CSS_PATH', AI1EC_ADMIN_PATH . AI1EC_CSS_FOLDER );
419
+ }
420
+
421
+ // =======================
422
+ // = Admin theme JS path =
423
+ // =======================
424
+ if ( ! defined( 'AI1EC_ADMIN_THEME_JS_PATH' ) ) {
425
+ define( 'AI1EC_ADMIN_THEME_JS_PATH', AI1EC_PATH . DIRECTORY_SEPARATOR . 'public' .
426
+ DIRECTORY_SEPARATOR . AI1EC_JS_FOLDER );
427
+ }
428
+
429
+ // =================
430
+ // = Admin IMG URL =
431
+ // =================
432
+ if ( ! defined( 'AI1EC_ADMIN_THEME_IMG_URL' ) ) {
433
+ define( 'AI1EC_ADMIN_THEME_IMG_URL', AI1EC_URL . '/public/admin/' . AI1EC_IMG_FOLDER );
434
+ }
435
+
436
+
437
+ // Enable All-in-One-Event-Calendar to work in debug mode, which means,
438
+ // that cache is ignored, extra output may appear at places, etc.
439
+ // Do not set this to any other value than `false` on production even if
440
+ // you know what you are doing, because you will waste valuable
441
+ // resources - save the Earth, at least.
442
+ if ( ! defined( 'AI1EC_DEBUG' ) ) {
443
+ define( 'AI1EC_DEBUG', false );
444
+ }
445
+
446
+ // Enable Ai1EC cache functionality. If you set this to false, only cache
447
+ // that is based on request, will remain active.
448
+ // This is pointless in any case other than development, where literary
449
+ // every second refresh needs to take fresh copy of everything.
450
+ if ( ! defined( 'AI1EC_CACHE' ) ) {
451
+ define( 'AI1EC_CACHE', true );
452
+ }
453
+
454
+ // A value identifying that cache is not available.
455
+ // Used in place of actual path for cache to use.
456
+ // Named constant allows reuse of a single typed variable.
457
+ if ( ! defined( 'AI1EC_CACHE_UNAVAILABLE' ) ) {
458
+ define( 'AI1EC_CACHE_UNAVAILABLE', 'AI1EC_CACHE_UNAVAILABLE' );
459
+ }
460
+
461
+ }
app/config/exception.php ADDED
@@ -0,0 +1,12 @@
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * This exception is thrown when no constant function is found.
4
+ *
5
+ * @author Time.ly Network Inc.
6
+ * @since 2.0
7
+ *
8
+ * @package AI1EC
9
+ * @subpackage AI1EC.Config
10
+ */
11
+ class Ai1ec_Constants_Not_Set_Exception extends Ai1ec_Exception {
12
+ }
app/controller/calendar-feeds.php ADDED
@@ -0,0 +1,84 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * Feeds (import and export streams) mediator.
5
+ *
6
+ * @author Time.ly Network Inc.
7
+ * @since 2.0
8
+ *
9
+ * @package AI1EC
10
+ * @subpackage AI1EC.Controller
11
+ */
12
+ class Ai1ec_Controller_Calendar_Feeds extends Ai1ec_Base {
13
+
14
+ /**
15
+ * @var array Holds the instances of registered plugins.
16
+ */
17
+ protected $_plugins = array();
18
+
19
+ /**
20
+ * Add plugin to the internal array.
21
+ *
22
+ * This assure us that the plugins extends our base abstract class.
23
+ *
24
+ * @param Ai1ec_Connector_Plugin $plugin Plugin to add.
25
+ *
26
+ * @return void
27
+ */
28
+ public function add_plugin( Ai1ec_Connector_Plugin $plugin ) {
29
+ $plugin->initialize_settings_if_not_set();
30
+ $this->_plugins[] = $plugin;
31
+ }
32
+
33
+ /**
34
+ * Get an instance of a plugin class
35
+ *
36
+ * @param string $class
37
+ * @throws Exception
38
+ * @return Ai1ec_Connector_Plugin
39
+ */
40
+ public function get_plugin_instance( $class ) {
41
+ foreach ( $this->_plugins as $plugin ) {
42
+ if( get_class( $plugin ) === $class ) {
43
+ return $plugin;
44
+ }
45
+ }
46
+ throw new Exception( "Class not found" );
47
+ }
48
+
49
+ /**
50
+ * Give the plugins the possibility to handle data posted in the calendar feeds page
51
+ *
52
+ * @return void
53
+ */
54
+ public function handle_feeds_page_post() {
55
+ // Iterate over the plugins and call the methods
56
+ foreach ( $this->_plugins as $plugin ) {
57
+ $plugin->handle_feeds_page_post();
58
+ }
59
+ }
60
+
61
+ /**
62
+ * Render the tab header for each plugin
63
+ *
64
+ * @param $active_feed
65
+ * The tab that should be visualized
66
+ */
67
+ public function render_tab_headers() {
68
+ foreach ( $this->_plugins as $plugin ) {
69
+ $plugin->render_tab_header();
70
+ }
71
+ }
72
+ /**
73
+ * Render the tab body for each plugin
74
+ *
75
+ * @param $active_feed
76
+ * The tab that should be visualized
77
+ */
78
+ public function render_tab_contents() {
79
+ foreach ( $this->_plugins as $plugin ) {
80
+ $plugin->render_tab_content();
81
+ }
82
+ }
83
+
84
+ }
app/controller/class-ai1ec-app-controller.php DELETED
@@ -1,544 +0,0 @@
1
- <?php
2
- //
3
- // class-ai1ec-app-controller.php
4
- // all-in-one-event-calendar
5
- //
6
- // Created by The Seed Studio on 2011-07-13.
7
- //
8
-
9
- /**
10
- * Ai1ec_App_Controller class
11
- *
12
- * @package Controllers
13
- * @author time.ly
14
- **/
15
- class Ai1ec_App_Controller {
16
- /**
17
- * _instance class variable
18
- *
19
- * Class instance
20
- *
21
- * @var null | object
22
- **/
23
- private static $_instance = NULL;
24
-
25
- /**
26
- * _load_domain class variable
27
- *
28
- * Load domain
29
- *
30
- * @var bool
31
- **/
32
- private static $_load_domain = FALSE;
33
-
34
- /**
35
- * page_content class variable
36
- *
37
- * String storing page content for output by the_content()
38
- *
39
- * @var null | string
40
- **/
41
- private $page_content = NULL;
42
-
43
- /**
44
- * get_instance function
45
- *
46
- * Return singleton instance
47
- *
48
- * @return object
49
- **/
50
- static function get_instance() {
51
- if( self::$_instance === NULL ) {
52
- self::$_instance = new self();
53
- }
54
-
55
- return self::$_instance;
56
- }
57
-
58
- /**
59
- * Constructor
60
- *
61
- * Default constructor - application initialization
62
- **/
63
- private function __construct() {
64
- global $wpdb,
65
- $ai1ec_app_helper,
66
- $ai1ec_events_controller,
67
- $ai1ec_events_helper,
68
- $ai1ec_importer_controller,
69
- $ai1ec_exporter_controller,
70
- $ai1ec_settings_controller,
71
- $ai1ec_settings,
72
- $ai1ec_themes_controller;
73
-
74
- // register_activation_hook
75
- register_activation_hook(
76
- AI1EC_PLUGIN_NAME . '/' . AI1EC_PLUGIN_NAME . '.php',
77
- array( $this, 'activation_hook' )
78
- );
79
-
80
- // Configure MySQL to operate in GMT time
81
- $wpdb->query( "SET time_zone = '+0:00'" );
82
-
83
- // Load plugin text domain
84
- $this->load_textdomain();
85
-
86
- // Install/update database schema as necessary
87
- $this->install_schema();
88
-
89
- // Install/update cron as necessary
90
- $this->install_cron();
91
-
92
- // Enable stats collection
93
- $this->install_n_cron();
94
-
95
- // Continue loading hooks only if themes are installed. Otherwise
96
- // display a notification on the backend with instructions how to
97
- // install themes.
98
- if ( ! $ai1ec_themes_controller->are_themes_available() ) {
99
- // Enables the hidden themes installer page
100
- add_action( 'admin_menu', array( $ai1ec_themes_controller, 'register_theme_installer' ), 1 );
101
- // Redirects the user to install theme page
102
- add_action( 'admin_notices', array( $ai1ec_app_helper, 'admin_notices_themes' ) );
103
- return NULL;
104
- }
105
-
106
- // ===========
107
- // = ACTIONS =
108
- // ===========
109
- // Calendar theme initialization
110
- add_action( 'after_setup_theme', array( $ai1ec_themes_controller, 'setup_theme' ) );
111
- // Create custom post type
112
- add_action( 'init', array( $ai1ec_app_helper, 'create_post_type' ) );
113
- // Handle ICS export requests
114
- add_action( 'init', array( $this, 'parse_standalone_request' ) );
115
- // General initialization
116
- add_action( 'init', array( $ai1ec_events_controller, 'init' ) );
117
- // Load plugin text domain
118
- add_action( 'init', array( $this, 'load_textdomain' ) );
119
- // Register The Event Calendar importer
120
- add_action( 'admin_init', array( $ai1ec_importer_controller, 'register_importer' ) );
121
- // Install admin menu items.
122
- add_action( 'admin_menu', array( $this, 'admin_menu' ), 9 );
123
- // Enable theme updater page if last version of core themes is older than
124
- // current version.
125
- if ( $ai1ec_themes_controller->are_themes_outdated() ) {
126
- add_action( 'admin_menu', array( $ai1ec_themes_controller, 'register_theme_updater' ) );
127
- }
128
- // Add Event counts to dashboard.
129
- add_action( 'right_now_content_table_end', array( $ai1ec_app_helper, 'right_now_content_table_end' ) );
130
- // add content for our custom columns
131
- add_action( 'manage_posts_custom_column', array( $ai1ec_app_helper, 'custom_columns' ), 10, 2 );
132
- // Add filtering dropdowns for event categories and tags
133
- add_action( 'restrict_manage_posts', array( $ai1ec_app_helper, 'taxonomy_filter_restrict_manage_posts' ) );
134
- // Trigger display of page in front-end depending on request
135
- add_action( 'template_redirect', array( $this, 'route_request' ) );
136
- // Add meta boxes to event creation/edit form.
137
- add_action( 'add_meta_boxes', array( $ai1ec_app_helper, 'add_meta_boxes' ) );
138
- add_filter( 'screen_layout_columns', array( $ai1ec_app_helper, 'screen_layout_columns' ), 10, 2 );
139
- // Save event data when post is saved
140
- add_action( 'save_post', array( $ai1ec_events_controller, 'save_post' ), 10, 2 );
141
- // Delete event data when post is deleted
142
- add_action( 'delete_post', array( $ai1ec_events_controller, 'delete_post' ) );
143
- // Cron job hook
144
- add_action( 'ai1ec_cron', array( &$ai1ec_importer_controller, 'cron' ) );
145
- // Notification cron job hook
146
- add_action( 'ai1ec_n_cron', array( $ai1ec_exporter_controller, 'n_cron' ) );
147
- // Category colors
148
- add_action( 'events_categories_add_form_fields', array( $ai1ec_events_controller, 'events_categories_add_form_fields' ) );
149
- add_action( 'events_categories_edit_form_fields', array( $ai1ec_events_controller, 'events_categories_edit_form_fields' ) );
150
- add_action( 'created_events_categories', array( $ai1ec_events_controller, 'created_events_categories' ) );
151
- add_action( 'edited_events_categories', array( $ai1ec_events_controller, 'edited_events_categories' ) );
152
- add_action( 'admin_notices', array( $ai1ec_app_helper, 'admin_notices' ) );
153
- // Scripts/styles for settings and widget admin screens.
154
- add_action( 'admin_enqueue_scripts', array( $ai1ec_app_helper, 'admin_enqueue_scripts' ) );
155
- // Widgets
156
- add_action( 'widgets_init', create_function( '', "return register_widget( 'Ai1ec_Agenda_Widget' );" ) );
157
-
158
- // ===========
159
- // = FILTERS =
160
- // ===========
161
- add_filter( 'posts_orderby', array( $ai1ec_app_helper, 'orderby' ), 10, 2 );
162
- // add custom column names and change existing columns
163
- add_filter( 'manage_ai1ec_event_posts_columns', array( $ai1ec_app_helper, 'change_columns' ) );
164
- // filter the post lists by custom filters
165
- add_filter( 'parse_query', array( $ai1ec_app_helper, 'taxonomy_filter_post_type_request' ) );
166
- // Filter event post content, in single- and multi-post views
167
- add_filter( 'the_content', array( $ai1ec_events_controller, 'event_content' ), PHP_INT_MAX - 1 );
168
- // Override excerpt filters for proper event display in excerpt form
169
- add_filter( 'get_the_excerpt', array( $ai1ec_events_controller, 'event_excerpt' ), 11 );
170
- add_filter( 'the_excerpt', array( $ai1ec_events_controller, 'event_excerpt_noautop' ), 11 );
171
- remove_filter( 'the_excerpt', 'wpautop', 10 );
172
- // Update event post update messages
173
- add_filter( 'post_updated_messages', array( $ai1ec_events_controller, 'post_updated_messages' ) );
174
- // Sort the custom columns
175
- add_filter( 'manage_edit-ai1ec_event_sortable_columns', array( $ai1ec_app_helper, 'sortable_columns' ) );
176
- add_filter( 'map_meta_cap', array( $ai1ec_app_helper, 'map_meta_cap' ), 10, 4 );
177
- // Inject event categories, only in front-end, depending on setting
178
- if( $ai1ec_settings->inject_categories && ! is_admin() ) {
179
- add_filter( 'get_terms', array( $ai1ec_app_helper, 'inject_categories' ), 10, 3 );
180
- add_filter( 'wp_list_categories', array( $ai1ec_app_helper, 'selected_category_link' ), 10, 2 );
181
- }
182
- // Rewrite event category URLs to point to calendar page.
183
- add_filter( 'term_link', array( $ai1ec_app_helper, 'calendar_term_link' ), 10, 3 );
184
- // Add a link to settings page on the plugin list page.
185
- add_filter( 'plugin_action_links_' . AI1EC_PLUGIN_BASENAME, array( $ai1ec_settings_controller, 'plugin_action_links' ) );
186
- // Add a link to donate page on plugin list page.
187
- add_filter( 'plugin_row_meta', array( $ai1ec_settings_controller, 'plugin_row_meta' ), 10, 2 );
188
- add_filter( 'post_type_link', array( $ai1ec_events_helper, 'post_type_link' ), 10, 3 );
189
- add_filter( 'ai1ec_template_root_path', array( $ai1ec_themes_controller, 'template_root_path' ) );
190
- add_filter( 'ai1ec_template_root_url', array( $ai1ec_themes_controller, 'template_root_url' ) );
191
-
192
- // ========
193
- // = AJAX =
194
- // ========
195
- // Add iCalendar feed
196
- add_action( 'wp_ajax_ai1ec_add_ics', array( $ai1ec_settings_controller, 'add_ics_feed' ) );
197
- // Delete iCalendar feed
198
- add_action( 'wp_ajax_ai1ec_delete_ics', array( $ai1ec_settings_controller, 'delete_ics_feed' ) );
199
- // Flush iCalendar feed
200
- add_action( 'wp_ajax_ai1ec_flush_ics', array( $ai1ec_settings_controller, 'flush_ics_feed' ) );
201
- // Update iCalendar feed
202
- add_action( 'wp_ajax_ai1ec_update_ics', array( $ai1ec_settings_controller, 'update_ics_feed' ) );
203
-
204
- // RRule to Text
205
- add_action( 'wp_ajax_ai1ec_rrule_to_text', array( $ai1ec_events_helper, 'convert_rrule_to_text' ) );
206
-
207
- // Display Repeat Box
208
- add_action( 'wp_ajax_ai1ec_get_repeat_box', array( $ai1ec_events_helper, 'get_repeat_box' ) );
209
- add_action( 'wp_ajax_ai1ec_get_date_picker_box', array( $ai1ec_events_helper, 'get_date_picker_box' ) );
210
-
211
- // Disable notifications
212
- add_action( 'wp_ajax_ai1ec_disable_notification', array( $ai1ec_settings_controller, 'disable_notification' ) );
213
- add_action( 'wp_ajax_ai1ec_disable_intro_video', array( $ai1ec_settings_controller, 'disable_intro_video' ) );
214
- add_action( 'wp_ajax_ai1ec_disable_standard_notice', array( $ai1ec_settings_controller, 'disable_standard_notice' ) );
215
- // ==============
216
- // = Shortcodes =
217
- // ==============
218
- add_shortcode( 'ai1ec', array( $ai1ec_events_helper, 'shortcode' ) );
219
-
220
- }
221
-
222
- /**
223
- * activation_hook function
224
- *
225
- * This function is called when activating the plugin
226
- *
227
- * @return void
228
- **/
229
- function activation_hook() {
230
- // Load plugin text domain.
231
- $this->load_textdomain();
232
-
233
- // Flush rewrite rules.
234
- $this->rewrite_flush();
235
- }
236
-
237
- /**
238
- * load_textdomain function
239
- *
240
- * Loads plugin text domain
241
- *
242
- * @return void
243
- **/
244
- function load_textdomain() {
245
- if ( false === self::$_load_domain ) {
246
- load_plugin_textdomain(
247
- AI1EC_PLUGIN_NAME,
248
- false,
249
- AI1EC_LANGUAGE_PATH
250
- );
251
- self::$_load_domain = true;
252
- }
253
- }
254
-
255
- /**
256
- * rewrite_flush function
257
- *
258
- * Get permalinks to work when activating the plugin
259
- *
260
- * @return void
261
- **/
262
- function rewrite_flush() {
263
- global $ai1ec_app_helper;
264
- $ai1ec_app_helper->create_post_type();
265
- flush_rewrite_rules( true );
266
- }
267
-
268
- /**
269
- * install_schema function
270
- *
271
- * This function sets up the database, and upgrades it if it is out of date.
272
- *
273
- * @return void
274
- **/
275
- function install_schema() {
276
- global $wpdb;
277
-
278
- // If existing DB version is not consistent with current plugin's version,
279
- // or does not exist, then create/update table structure using dbDelta().
280
- if( get_option( 'ai1ec_db_version' ) != AI1EC_DB_VERSION )
281
- {
282
- // =======================
283
- // = Create table events =
284
- // =======================
285
- $table_name = $wpdb->prefix . 'ai1ec_events';
286
- $sql = "CREATE TABLE $table_name (
287
- post_id bigint(20) NOT NULL,
288
- start datetime NOT NULL,
289
- end datetime,
290
- allday tinyint(1) NOT NULL,
291
- recurrence_rules longtext,
292
- exception_rules longtext,
293
- recurrence_dates longtext,
294
- exception_dates longtext,
295
- venue varchar(255),
296
- country varchar(255),
297
- address varchar(255),
298
- city varchar(255),
299
- province varchar(255),
300
- postal_code varchar(32),
301
- show_map tinyint(1),
302
- contact_name varchar(255),
303
- contact_phone varchar(32),
304
- contact_email varchar(128),
305
- cost varchar(255),
306
- ical_feed_url varchar(255),
307
- ical_source_url varchar(255),
308
- ical_organizer varchar(255),
309
- ical_contact varchar(255),
310
- ical_uid varchar(255),
311
- PRIMARY KEY (post_id)
312
- ) CHARACTER SET utf8;";
313
-
314
- // ==========================
315
- // = Create table instances =
316
- // ==========================
317
- $table_name = $wpdb->prefix . 'ai1ec_event_instances';
318
- $sql .= "CREATE TABLE $table_name (
319
- id bigint(20) NOT NULL AUTO_INCREMENT,
320
- post_id bigint(20) NOT NULL,
321
- start datetime NOT NULL,
322
- end datetime NOT NULL,
323
- PRIMARY KEY (id)
324
- ) CHARACTER SET utf8;";
325
-
326
- // ======================
327
- // = Create table feeds =
328
- // ======================
329
- $table_name = $wpdb->prefix . 'ai1ec_event_feeds';
330
- $sql .= "CREATE TABLE $table_name (
331
- feed_id bigint(20) NOT NULL AUTO_INCREMENT,
332
- feed_url varchar(255) NOT NULL,
333
- feed_category bigint(20) NOT NULL,
334
- feed_tags varchar(255) NOT NULL,
335
- PRIMARY KEY (feed_id)
336
- ) CHARACTER SET utf8;";
337
-
338
- // ================================
339
- // = Create table category colors =
340
- // ================================
341
- $table_name = $wpdb->prefix . 'ai1ec_event_category_colors';
342
- $sql .= "CREATE TABLE $table_name (
343
- term_id bigint(20) NOT NULL,
344
- term_color varchar(255) NOT NULL,
345
- PRIMARY KEY (term_id)
346
- ) CHARACTER SET utf8;";
347
-
348
- require_once( ABSPATH . 'wp-admin/includes/upgrade.php' );
349
- dbDelta( $sql );
350
-
351
- update_option( 'ai1ec_db_version', AI1EC_DB_VERSION );
352
- }
353
- }
354
-
355
- /**
356
- * install_cron function
357
- *
358
- * This function sets up the cron job for updating the events, and upgrades it if it is out of date.
359
- *
360
- * @return void
361
- **/
362
- function install_cron() {
363
- // If existing CRON version is not consistent with current plugin's version,
364
- // or does not exist, then create/update cron using
365
- if( get_option( 'ai1ec_cron_version' ) != AI1EC_CRON_VERSION ) {
366
- global $ai1ec_settings;
367
- // delete our scheduled crons
368
- wp_clear_scheduled_hook( 'ai1ec_cron' );
369
- // set the new cron
370
- wp_schedule_event( time(), $ai1ec_settings->cron_freq, 'ai1ec_cron' );
371
- // update the cron version
372
- update_option( 'ai1ec_cron_version', AI1EC_CRON_VERSION );
373
- }
374
- }
375
-
376
- /**
377
- * install_notification_cron function
378
- *
379
- * This function sets up the cron job for collecting stats
380
- *
381
- * @return void
382
- **/
383
- function install_n_cron() {
384
- global $ai1ec_settings;
385
-
386
- $hook_name = 'ai1ec_n_cron';
387
- $optn_name = $hook_name . '_version';
388
-
389
- // delete our scheduled crons
390
- wp_clear_scheduled_hook( $hook_name );
391
-
392
- // if stats are disabled, cancel the cron
393
- if ( ! $ai1ec_settings->allow_statistics ) {
394
- delete_option( $optn_name ); // remove the cron version
395
- return NULL; // prevent the execution of the code below
396
- }
397
-
398
- // If existing CRON version is not consistent with current plugin's
399
- // version, or does not exist, then create/update cron using
400
- if ( AI1EC_N_CRON_VERSION != get_option( $optn_name ) ) {
401
- // set the new cron
402
- wp_schedule_event( time(), AI1EC_N_CRON_FREQ, $hook_name );
403
- // update the cron version
404
- update_option( $optn_name, AI1EC_N_CRON_VERSION );
405
- }
406
- }
407
-
408
- /**
409
- * admin_menu function
410
- * Display the admin menu items using the add_menu_page WP function.
411
- *
412
- * @return void
413
- */
414
- function admin_menu() {
415
- global $ai1ec_settings_controller,
416
- $ai1ec_settings_helper,
417
- $ai1ec_settings,
418
- $ai1ec_themes_controller,
419
- $submenu;
420
-
421
- // =======================
422
- // = Calendar Feeds Page =
423
- // =======================
424
- $ai1ec_settings->feeds_page = add_submenu_page(
425
- 'edit.php?post_type=' . AI1EC_POST_TYPE,
426
- __( 'Calendar Feeds', AI1EC_PLUGIN_NAME ),
427
- __( 'Calendar Feeds', AI1EC_PLUGIN_NAME ),
428
- 'manage_ai1ec_feeds',
429
- AI1EC_PLUGIN_NAME . '-feeds',
430
- array( &$ai1ec_settings_controller, 'view_feeds' )
431
- );
432
- // Allow feeds page to have additional meta boxes added to it.
433
- add_action( "load-{$ai1ec_settings->feeds_page}", array( &$ai1ec_settings_helper, 'add_feeds_meta_boxes') );
434
- // Load our plugin's meta boxes.
435
- add_action( "load-{$ai1ec_settings->feeds_page}", array( &$ai1ec_settings_controller, 'add_feeds_meta_boxes' ) );
436
-
437
- // =================
438
- // = Settings Page =
439
- // =================
440
- $ai1ec_settings->settings_page = add_submenu_page(
441
- 'edit.php?post_type=' . AI1EC_POST_TYPE,
442
- __( 'Settings', AI1EC_PLUGIN_NAME ),
443
- __( 'Settings', AI1EC_PLUGIN_NAME ),
444
- 'manage_ai1ec_options',
445
- AI1EC_PLUGIN_NAME . '-settings',
446
- array( &$ai1ec_settings_controller, 'view_settings' )
447
- );
448
- // Make copy of Settings page at its old location.
449
- $submenu['options-general.php'][] = array(
450
- __( 'Calendar', AI1EC_PLUGIN_NAME ),
451
- 'manage_ai1ec_options',
452
- AI1EC_SETTINGS_BASE_URL,
453
- );
454
- // Allow settings page to have additional meta boxes added to it.
455
- add_action( "load-{$ai1ec_settings->settings_page}", array( &$ai1ec_settings_helper, 'add_settings_meta_boxes') );
456
- // Load our plugin's meta boxes.
457
- add_action( "load-{$ai1ec_settings->settings_page}", array( &$ai1ec_settings_controller, 'add_settings_meta_boxes' ) );
458
-
459
- }
460
-
461
- /**
462
- * route_request function
463
- *
464
- * Determines if the page viewed should be handled by this plugin, and if so
465
- * schedule new content to be displayed.
466
- *
467
- * @return void
468
- **/
469
- function route_request() {
470
- global $ai1ec_settings,
471
- $ai1ec_calendar_controller,
472
- $ai1ec_events_controller,
473
- $ai1ec_events_helper,
474
- $post;
475
-
476
- // Find out if the calendar page ID is defined, and we're on it
477
- if( $ai1ec_settings->calendar_page_id &&
478
- is_page( $ai1ec_settings->calendar_page_id ) )
479
- {
480
- // Proceed only if the page password is correctly entered OR
481
- // the page doesn't require a password
482
- if( ! post_password_required( $ai1ec_settings->calendar_page_id ) ) {
483
- ob_start();
484
- // Render view
485
- $ai1ec_calendar_controller->view();
486
- // Save page content to local variable
487
- $this->page_content = ob_get_contents();
488
- ob_end_clean();
489
-
490
- // Replace page content - make sure it happens at (almost) the very end of
491
- // page content filters (some themes are overly ambitious here)
492
- add_filter( 'the_content', array( &$this, 'append_content' ), PHP_INT_MAX - 1 );
493
- }
494
- }
495
- }
496
-
497
- /**
498
- * parse_standalone_request function
499
- *
500
- * @return void
501
- **/
502
- function parse_standalone_request() {
503
- global $ai1ec_exporter_controller,
504
- $ai1ec_app_helper;
505
-
506
- $plugin = $ai1ec_app_helper->get_param('plugin');
507
- $action = $ai1ec_app_helper->get_param('action');
508
- $controller = $ai1ec_app_helper->get_param('controller');
509
-
510
- if( ! empty( $plugin ) && $plugin == AI1EC_PLUGIN_NAME && ! empty( $controller ) && ! empty( $action ) ) {
511
- if( $controller == "ai1ec_exporter_controller" ) :
512
- switch( $action ) :
513
- case 'export_events':
514
- $ai1ec_exporter_controller->export_events();
515
- break;
516
- endswitch;
517
- endif; // ai1ec_exporter_controller
518
- }
519
- }
520
-
521
- /**
522
- * append_content function
523
- *
524
- * Append locally generated content to normal page content (if in the loop;
525
- * don't want to do it for all instances of the_content() on the page!)
526
- *
527
- * @param string $content Post/Page content
528
- * @return string Post/Page content
529
- **/
530
- function append_content( $content )
531
- {
532
- // Enclose entire content (including any admin-provided page content) in
533
- // the calendar container div
534
- if( in_the_loop() )
535
- $content =
536
- '<div id="ai1ec-container" class="ai1ec-container timely">' .
537
- $content . $this->page_content .
538
- '</div>';
539
-
540
- return $content;
541
- }
542
-
543
- }
544
- // END class
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/controller/class-ai1ec-calendar-controller.php DELETED
@@ -1,763 +0,0 @@
1
- <?php
2
- //
3
- // class-ai1ec-calendar-controller.php
4
- // all-in-one-event-calendar
5
- //
6
- // Created by The Seed Studio on 2011-07-13.
7
- //
8
-
9
- /**
10
- * Ai1ec_Calendar_Controller class
11
- *
12
- * @package Controllers
13
- * @author time.ly
14
- **/
15
- class Ai1ec_Calendar_Controller {
16
- /**
17
- * _instance class variable
18
- *
19
- * Class instance
20
- *
21
- * @var null | object
22
- **/
23
- static $_instance = NULL;
24
-
25
- /**
26
- * request class variable
27
- *
28
- * Stores a custom $_REQUEST array for all calendar requests
29
- *
30
- * @var array
31
- **/
32
- private $request = array();
33
-
34
- /**
35
- * __construct function
36
- *
37
- * Default constructor - calendar initialization
38
- **/
39
- private function __construct() {
40
- // ===========
41
- // = ACTIONS =
42
- // ===========
43
- // Handle AJAX requests
44
- // Strange! Now regular WordPress requests will respond to the below AJAX
45
- // hooks! Thus we need to check to make sure we are being called by the
46
- // AJAX script before returning AJAX responses.
47
- if( basename( $_SERVER['SCRIPT_NAME'] ) == 'admin-ajax.php' )
48
- {
49
- add_action( 'wp_ajax_ai1ec_month', array( &$this, 'ajax_month' ) );
50
- add_action( 'wp_ajax_ai1ec_oneday', array( &$this, 'ajax_oneday' ) );
51
- add_action( 'wp_ajax_ai1ec_week', array( &$this, 'ajax_week' ) );
52
- add_action( 'wp_ajax_ai1ec_agenda', array( &$this, 'ajax_agenda' ) );
53
- add_action( 'wp_ajax_ai1ec_term_filter', array( &$this, 'ajax_term_filter' ) );
54
-
55
- add_action( 'wp_ajax_nopriv_ai1ec_month', array( &$this, 'ajax_month' ) );
56
- add_action( 'wp_ajax_nopriv_ai1ec_oneday', array( &$this, 'ajax_oneday' ) );
57
- add_action( 'wp_ajax_nopriv_ai1ec_week', array( &$this, 'ajax_week' ) );
58
- add_action( 'wp_ajax_nopriv_ai1ec_agenda', array( &$this, 'ajax_agenda' ) );
59
- add_action( 'wp_ajax_nopriv_ai1ec_term_filter', array( &$this, 'ajax_term_filter' ) );
60
- }
61
- }
62
-
63
- /**
64
- * process_request function
65
- *
66
- * Initialize/validate custom request array, based on contents of $_REQUEST,
67
- * to keep track of this component's request variables.
68
- *
69
- * @return void
70
- **/
71
- function process_request()
72
- {
73
- global $ai1ec_settings;
74
-
75
- // Find out which view of the calendar page was requested, then validate
76
- // request parameters accordingly and save them to our custom request
77
- // object
78
- $this->request['action'] = isset( $_REQUEST['action'] ) ? $_REQUEST['action'] : '';
79
- if( ! in_array( $this->request['action'],
80
- array( 'ai1ec_month', 'ai1ec_oneday', 'ai1ec_week', 'ai1ec_agenda', 'ai1ec_term_filter' ) ) )
81
- $this->request['action'] = 'ai1ec_' . $ai1ec_settings->default_calendar_view;
82
-
83
- switch( $this->request['action'] )
84
- {
85
- case 'ai1ec_month':
86
- $this->request['ai1ec_month_offset'] =
87
- isset( $_REQUEST['ai1ec_month_offset'] ) ? intval( $_REQUEST['ai1ec_month_offset'] ) : 0;
88
- // Parse active event parameter as an integer ID
89
- $this->request['ai1ec_active_event'] = isset( $_REQUEST['ai1ec_active_event'] ) ? intval( $_REQUEST['ai1ec_active_event'] ) : null;
90
- // Category/tag filter parameters
91
- $this->request['ai1ec_cat_ids'] = isset( $_REQUEST['ai1ec_cat_ids'] ) ? $_REQUEST['ai1ec_cat_ids'] : null;
92
- $this->request['ai1ec_tag_ids'] = isset( $_REQUEST['ai1ec_tag_ids'] ) ? $_REQUEST['ai1ec_tag_ids'] : null;
93
- $this->request['ai1ec_post_ids'] = isset( $_REQUEST['ai1ec_post_ids'] ) ? $_REQUEST['ai1ec_post_ids'] : null;
94
- break;
95
-
96
- case 'ai1ec_oneday':
97
- $this->request['ai1ec_oneday_offset'] =
98
- isset( $_REQUEST['ai1ec_oneday_offset'] ) ? intval( $_REQUEST['ai1ec_oneday_offset'] ) : 0;
99
- // Parse active event parameter as an integer ID
100
- $this->request['ai1ec_active_event'] = isset( $_REQUEST['ai1ec_active_event'] ) ? intval( $_REQUEST['ai1ec_active_event'] ) : null;
101
- // Category/tag filter parameters
102
- $this->request['ai1ec_cat_ids'] = isset( $_REQUEST['ai1ec_cat_ids'] ) ? $_REQUEST['ai1ec_cat_ids'] : null;
103
- $this->request['ai1ec_tag_ids'] = isset( $_REQUEST['ai1ec_tag_ids'] ) ? $_REQUEST['ai1ec_tag_ids'] : null;
104
- $this->request['ai1ec_post_ids'] = isset( $_REQUEST['ai1ec_post_ids'] ) ? $_REQUEST['ai1ec_post_ids'] : null;
105
- break;
106
-
107
- case 'ai1ec_week':
108
- $this->request['ai1ec_week_offset'] =
109
- isset( $_REQUEST['ai1ec_week_offset'] ) ? intval( $_REQUEST['ai1ec_week_offset'] ) : 0;
110
- // Parse active event parameter as an integer ID
111
- $this->request['ai1ec_active_event'] = isset( $_REQUEST['ai1ec_active_event'] ) ? intval( $_REQUEST['ai1ec_active_event'] ) : null;
112
- // Category/tag filter parameters
113
- $this->request['ai1ec_cat_ids'] = isset( $_REQUEST['ai1ec_cat_ids'] ) ? $_REQUEST['ai1ec_cat_ids'] : null;
114
- $this->request['ai1ec_tag_ids'] = isset( $_REQUEST['ai1ec_tag_ids'] ) ? $_REQUEST['ai1ec_tag_ids'] : null;
115
- $this->request['ai1ec_post_ids'] = isset( $_REQUEST['ai1ec_post_ids'] ) ? $_REQUEST['ai1ec_post_ids'] : null;
116
- break;
117
-
118
- case 'ai1ec_agenda':
119
- $this->request['ai1ec_page_offset'] =
120
- isset( $_REQUEST['ai1ec_page_offset'] ) ? intval( $_REQUEST['ai1ec_page_offset'] ) : 0;
121
- // Parse active event parameter as an integer ID
122
- $this->request['ai1ec_active_event'] = isset( $_REQUEST['ai1ec_active_event'] ) ? intval( $_REQUEST['ai1ec_active_event'] ) : null;
123
- // Category/tag filter parameters
124
- $this->request['ai1ec_cat_ids'] = isset( $_REQUEST['ai1ec_cat_ids'] ) ? $_REQUEST['ai1ec_cat_ids'] : null;
125
- $this->request['ai1ec_tag_ids'] = isset( $_REQUEST['ai1ec_tag_ids'] ) ? $_REQUEST['ai1ec_tag_ids'] : null;
126
- $this->request['ai1ec_post_ids'] = isset( $_REQUEST['ai1ec_post_ids'] ) ? $_REQUEST['ai1ec_post_ids'] : null;
127
- $this->request['ai1ec_time_limit'] = (isset( $_REQUEST['ai1ec_time_limit'] ))
128
- ? (int)$_REQUEST['ai1ec_time_limit']
129
- : 0;
130
- break;
131
-
132
- case 'ai1ec_term_filter':
133
- $this->request['ai1ec_post_ids'] = isset( $_REQUEST['ai1ec_post_ids'] ) ? $_REQUEST['ai1ec_post_ids'] : null;
134
- $this->request['ai1ec_term_ids'] = isset( $_REQUEST['ai1ec_term_ids'] ) ? $_REQUEST['ai1ec_term_ids'] : null;
135
- break;
136
- }
137
- }
138
-
139
- /**
140
- * get_instance function
141
- *
142
- * Return singleton instance
143
- *
144
- * @return object
145
- **/
146
- static function get_instance() {
147
- if( self::$_instance === NULL ) {
148
- self::$_instance = new self();
149
- }
150
-
151
- return self::$_instance;
152
- }
153
-
154
- /**
155
- * view function
156
- *
157
- * Display requested calendar page.
158
- *
159
- * @return void
160
- **/
161
- function view()
162
- {
163
- global $ai1ec_view_helper,
164
- $ai1ec_settings,
165
- $ai1ec_events_helper,
166
- $ai1ec_themes_controller;
167
-
168
- if ( $ai1ec_themes_controller->frontend_outdated_themes_notice() ) {
169
- return;
170
- }
171
-
172
- $this->process_request();
173
-
174
- // Set body class
175
- add_filter( 'body_class', array( &$this, 'body_class' ) );
176
- // Queue any styles, scripts
177
- $this->load_css();
178
- $this->load_js();
179
-
180
- $post_ids = array_filter( explode( ',', $this->request['ai1ec_post_ids'] ), 'is_numeric' );
181
- // Define arguments for specific calendar sub-view (month, agenda, etc.)
182
- $args = array(
183
- 'active_event' => $this->request['ai1ec_active_event'],
184
- 'post_ids' => $post_ids,
185
- );
186
-
187
- // Find out which view of the calendar page was requested
188
- switch( $this->request['action'] )
189
- {
190
- case 'ai1ec_month':
191
- $args['month_offset'] = $this->request['ai1ec_month_offset'];
192
- $view = $this->get_month_view( $args );
193
- break;
194
-
195
- case 'ai1ec_oneday':
196
- $args['oneday_offset'] = $this->request['ai1ec_oneday_offset'];
197
- $view = $this->get_oneday_view( $args );
198
- break;
199
-
200
- case 'ai1ec_week':
201
- $args['week_offset'] = $this->request['ai1ec_week_offset'];
202
- $view = $this->get_week_view( $args );
203
- break;
204
-
205
- case 'ai1ec_agenda':
206
- $args['page_offset'] = $this->request['ai1ec_page_offset'];
207
- $args['time_limit'] = $this->request['ai1ec_time_limit'];
208
- $view = $this->get_agenda_view( $args );
209
- break;
210
- }
211
-
212
- if( $ai1ec_settings->show_create_event_button && current_user_can( 'edit_ai1ec_events' ) )
213
- $create_event_url = admin_url( 'post-new.php?post_type=' . AI1EC_POST_TYPE );
214
- else
215
- $create_event_url = false;
216
-
217
- // Validate preselected category/tag/post IDs
218
- $cat_ids = join( ',', array_filter( explode( ',', $this->request['ai1ec_cat_ids'] ), 'is_numeric' ) );
219
- $tag_ids = join( ',', array_filter( explode( ',', $this->request['ai1ec_tag_ids'] ), 'is_numeric' ) );
220
- $post_ids = join( ',', $post_ids );
221
-
222
- $categories = get_terms( 'events_categories', array( 'orderby' => 'name' ) );
223
- foreach( $categories as &$cat ) {
224
- $cat->color = $ai1ec_events_helper->get_category_color_square( $cat->term_id );
225
- }
226
-
227
- // Supply view names and current view.
228
- $view_names = array(
229
- 'month' => __( 'Month', AI1EC_PLUGIN_NAME ),
230
- 'week' => __( 'Week', AI1EC_PLUGIN_NAME ),
231
- 'oneday' => __( 'Day', AI1EC_PLUGIN_NAME ),
232
- 'agenda' => __( 'Agenda', AI1EC_PLUGIN_NAME ),
233
- );
234
- $current_view = substr( $this->request['action'], 6 );
235
-
236
- // Define new arguments for overall calendar view
237
- $args = array(
238
- 'view_names' => $view_names,
239
- 'current_view' => $current_view,
240
- 'view' => $view,
241
- 'create_event_url' => $create_event_url,
242
- 'categories' => $categories,
243
- 'tags' => get_terms( 'events_tags', array( 'orderby' => 'name' ) ),
244
- 'selected_cat_ids' => $cat_ids,
245
- 'selected_tag_ids' => $tag_ids,
246
- 'selected_post_ids' => $post_ids,
247
- 'show_subscribe_buttons' => ! $ai1ec_settings->turn_off_subscription_buttons,
248
- 'ai1ec_view_helper' => $ai1ec_view_helper,
249
- );
250
-
251
- // Feed month view into generic calendar view
252
- echo apply_filters( 'ai1ec_view', $ai1ec_view_helper->get_theme_view( 'calendar.php', $args ), $args );
253
- }
254
-
255
- /**
256
- * get_month_view function
257
- *
258
- * Return the embedded month view of the calendar, optionally filtered by
259
- * event categories and tags.
260
- *
261
- * @param array $args associative array with any of these elements:
262
- * int month_offset => specifies which month to display relative to the
263
- * current month
264
- * int active_event => specifies which event to make visible when
265
- * page is loaded
266
- * array categories => restrict events returned to the given set of
267
- * event category slugs
268
- * array tags => restrict events returned to the given set of
269
- * event tag names
270
- * array post_ids => restrict events returned to the given set of
271
- * post IDs
272
- *
273
- * @return string returns string of view output
274
- **/
275
- function get_month_view( $args )
276
- {
277
- global $ai1ec_view_helper,
278
- $ai1ec_events_helper,
279
- $ai1ec_calendar_helper,
280
- $ai1ec_settings;
281
-
282
- $defaults = array(
283
- 'month_offset' => 0,
284
- 'active_event' => null,
285
- 'categories' => array(),
286
- 'tags' => array(),
287
- 'post_ids' => array(),
288
- );
289
- $args = wp_parse_args( $args, $defaults );
290
-
291
- extract( $args );
292
-
293
- // Get components of localized time
294
- $bits = $ai1ec_events_helper->gmgetdate( $ai1ec_events_helper->gmt_to_local( time() ) );
295
- // Use first day of the month as reference timestamp, and apply month offset
296
- $timestamp = gmmktime( 0, 0, 0, $bits['mon'] + $month_offset, 1, $bits['year'] );
297
-
298
- $days_events = $ai1ec_calendar_helper->get_events_for_month( $timestamp,
299
- array( 'cat_ids' => $categories, 'cat_ids' => $tags, 'post_ids' => $post_ids ) );
300
- $cell_array = $ai1ec_calendar_helper->get_month_cell_array( $timestamp, $days_events );
301
- $pagination_links = $ai1ec_calendar_helper->get_month_pagination_links( $month_offset );
302
-
303
- $view_args = array(
304
- 'title' => date_i18n( 'F Y', $timestamp, true ),
305
- 'weekdays' => $ai1ec_calendar_helper->get_weekdays(),
306
- 'cell_array' => $cell_array,
307
- 'show_location_in_title' => $ai1ec_settings->show_location_in_title,
308
- 'pagination_links' => $pagination_links,
309
- 'active_event' => $active_event,
310
- 'post_ids' => join( ',', $post_ids ),
311
- );
312
-
313
- return apply_filters( 'ai1ec_get_month_view', $ai1ec_view_helper->get_theme_view( 'month.php', $view_args ), $view_args );
314
- }
315
-
316
- /**
317
- * get_oneday_view function
318
- *
319
- * Return the embedded dayh view of the calendar, optionally filtered by
320
- * event categories and tags.
321
- *
322
- * @param array $args associative array with any of these elements:
323
- * int oneday_offset => specifies which day to display relative to the
324
- * current day
325
- * int active_event => specifies which event to make visible when
326
- * page is loaded
327
- * array categories => restrict events returned to the given set of
328
- * event category slugs
329
- * array tags => restrict events returned to the given set of
330
- * event tag names
331
- * array post_ids => restrict events returned to the given set of
332
- * post IDs
333
- *
334
- * @return string returns string of view output
335
- **/
336
- function get_oneday_view( $args )
337
- {
338
- global $ai1ec_view_helper,
339
- $ai1ec_events_helper,
340
- $ai1ec_calendar_helper,
341
- $ai1ec_settings;
342
-
343
- $defaults = array(
344
- 'oneday_offset' => 0,
345
- 'active_event' => null,
346
- 'categories' => array(),
347
- 'tags' => array(),
348
- 'post_ids' => array(),
349
- );
350
- $args = wp_parse_args( $args, $defaults );
351
-
352
- extract( $args );
353
- // Get components of localized time
354
- $bits = $ai1ec_events_helper->gmgetdate( $ai1ec_events_helper->gmt_to_local( time() ) );
355
- // Use actually day of the month as reference timestamp, and apply day offset
356
- $timestamp = gmmktime( 0, 0, 0, $bits['mon'], $bits['mday'], $bits['year'] );
357
- $day_shift = 0;
358
- // Then apply one-day offset
359
- $day_shift += $args['oneday_offset'];
360
- $timestamp = gmmktime( 0, 0, 0, $bits['mon'], $bits['mday'] + $day_shift, $bits['year'] );
361
-
362
- $cell_array = $ai1ec_calendar_helper->get_oneday_cell_array( $timestamp, array( 'cat_ids' => $categories, 'cat_ids' => $tags, 'post_ids' => $post_ids ) );
363
- $pagination_links = $ai1ec_calendar_helper->get_oneday_pagination_links( $oneday_offset );
364
-
365
- $view_args = array(
366
- 'title' => date_i18n( 'j F Y', $timestamp, true ),
367
- 'cell_array' => $cell_array,
368
- 'show_location_in_title' => $ai1ec_settings->show_location_in_title,
369
- 'now_top' => $bits['hours'] * 60 + $bits['minutes'],
370
- 'pagination_links' => $pagination_links,
371
- 'active_event' => $active_event,
372
- 'post_ids' => join( ',', $post_ids ),
373
- 'time_format' => get_option( 'time_format', 'g a' ),
374
- 'done_allday_label' => false,
375
- 'done_grid' => false
376
- );
377
- return apply_filters( 'ai1ec_get_oneday_view', $ai1ec_view_helper->get_theme_view( 'oneday.php', $view_args ), $view_args );
378
- }
379
-
380
- /**
381
- * get_week_view function
382
- *
383
- * Return the embedded week view of the calendar, optionally filtered by
384
- * event categories and tags.
385
- *
386
- * @param array $args associative array with any of these elements:
387
- * int week_offset => specifies which week to display relative to the
388
- * current week
389
- * int active_event => specifies which event to make visible when
390
- * page is loaded
391
- * array categories => restrict events returned to the given set of
392
- * event category slugs
393
- * array tags => restrict events returned to the given set of
394
- * event tag names
395
- * array post_ids => restrict events returned to the given set of
396
- * post IDs
397
- *
398
- * @return string returns string of view output
399
- */
400
- function get_week_view( $args )
401
- {
402
- global $ai1ec_view_helper,
403
- $ai1ec_events_helper,
404
- $ai1ec_calendar_helper,
405
- $ai1ec_settings;
406
-
407
- $defaults = array(
408
- 'week_offset' => 0,
409
- 'active_event' => null,
410
- 'categories' => array(),
411
- 'tags' => array(),
412
- 'post_ids' => array(),
413
- );
414
- $args = wp_parse_args( $args, $defaults );
415
-
416
- extract( $args );
417
-
418
- // Get components of localized time
419
- $bits = $ai1ec_events_helper->gmgetdate( $ai1ec_events_helper->gmt_to_local( time() ) );
420
- // Day shift is initially the first day of the week according to settings
421
- $day_shift = $ai1ec_events_helper->get_week_start_day_offset( $bits['wday'] );
422
- // Then apply week offset
423
- $day_shift += $args['week_offset'] * 7;
424
-
425
- // Now apply to reference timestamp
426
- $timestamp = gmmktime( 0, 0, 0, $bits['mon'], $bits['mday'] + $day_shift, $bits['year'] );
427
-
428
- $cell_array = $ai1ec_calendar_helper->get_week_cell_array( $timestamp,
429
- array( 'cat_ids' => $categories, 'cat_ids' => $tags, 'post_ids' => $post_ids ) );
430
- $pagination_links = $ai1ec_calendar_helper->get_week_pagination_links( $week_offset );
431
-
432
- // Translators: "%s" below represents the week's start date.
433
- $view_args = array(
434
- 'title' => sprintf( __( 'Week of %s', AI1EC_PLUGIN_NAME ), date_i18n( __( 'F j', AI1EC_PLUGIN_NAME ), $timestamp, true ) ),
435
- 'cell_array' => $cell_array,
436
- 'show_location_in_title' => $ai1ec_settings->show_location_in_title,
437
- 'now_top' => $bits['hours'] * 60 + $bits['minutes'],
438
- 'pagination_links' => $pagination_links,
439
- 'active_event' => $active_event,
440
- 'post_ids' => join( ',', $post_ids ),
441
- 'time_format' => get_option( 'time_format', 'g a' ),
442
- 'done_allday_label' => false,
443
- 'done_grid' => false
444
- );
445
- return apply_filters( 'ai1ec_get_week_view', $ai1ec_view_helper->get_theme_view( 'week.php', $view_args ), $view_args );
446
- }
447
-
448
- /**
449
- * get_agenda_view function
450
- *
451
- * Return the embedded agenda view of the calendar, optionally filtered by
452
- * event categories and tags.
453
- *
454
- * @param array $args associative array with any of these elements:
455
- * int page_offset => specifies which page to display relative to today's page
456
- * int time_limit => specifies upper/lower (depending on direction) time limit
457
- * int active_event => specifies which event to make visible when
458
- * page is loaded
459
- * array categories => restrict events returned to the given set of
460
- * event category slugs
461
- * array tags => restrict events returned to the given set of
462
- * event tag names
463
- *
464
- * @return string returns string of view output
465
- **/
466
- function get_agenda_view( $args )
467
- {
468
- global $ai1ec_view_helper,
469
- $ai1ec_events_helper,
470
- $ai1ec_calendar_helper,
471
- $ai1ec_settings;
472
-
473
- extract( $args );
474
-
475
- // Get localized time
476
- $timestamp = $ai1ec_events_helper->gmt_to_local( time() );
477
-
478
- // Get events, then classify into date array
479
- $event_results = $ai1ec_calendar_helper->get_events_relative_to(
480
- $timestamp,
481
- $ai1ec_settings->agenda_events_per_page,
482
- $page_offset,
483
- array( 'post_ids' => $post_ids ),
484
- $time_limit
485
- );
486
- $last_event = end( $event_results['events'] );
487
- $dates = $ai1ec_calendar_helper->get_agenda_date_array( $event_results['events'] );
488
-
489
- $pagination_links = $ai1ec_calendar_helper->get_agenda_pagination_links(
490
- $page_offset,
491
- $event_results['prev'],
492
- $event_results['next'],
493
- $event_results['date_first'],
494
- $event_results['date_last']
495
- );
496
-
497
- // Incorporate offset into date
498
- $args = array(
499
- 'title' => __( 'Agenda', AI1EC_PLUGIN_NAME ),
500
- 'dates' => $dates,
501
- 'show_location_in_title' => $ai1ec_settings->show_location_in_title,
502
- 'show_year_in_agenda_dates' => $ai1ec_settings->show_year_in_agenda_dates,
503
- 'page_offset' => $page_offset,
504
- 'pagination_links' => $pagination_links,
505
- 'active_event' => $active_event,
506
- 'expanded' => $ai1ec_settings->agenda_events_expanded,
507
- 'post_ids' => join( ',', $post_ids )
508
- );
509
- return apply_filters( 'ai1ec_get_agenda_view', $ai1ec_view_helper->get_theme_view( 'agenda.php', $args ), $args );
510
- }
511
-
512
- /**
513
- * ajax_month function
514
- *
515
- * AJAX request handler for month view.
516
- *
517
- * @return void
518
- */
519
- function ajax_month() {
520
- global $ai1ec_view_helper;
521
-
522
- $this->process_request();
523
-
524
- // View arguments
525
- $args = array(
526
- 'month_offset' => $this->request['ai1ec_month_offset'],
527
- 'active_event' => $this->request['ai1ec_active_event'],
528
- 'post_ids' => array_filter( explode( ',', $this->request['ai1ec_post_ids'] ), 'is_numeric' ),
529
- );
530
-
531
- // Return this data structure to the client
532
- $data = array(
533
- 'body_class' => join( ' ', $this->body_class() ),
534
- 'html' => $this->get_month_view( $args ),
535
- );
536
- $ai1ec_view_helper->json_response( $data );
537
- }
538
-
539
- /**
540
- * ajax_oneday function
541
- *
542
- * AJAX request handler for day view.
543
- *
544
- * @return void
545
- */
546
- function ajax_oneday() {
547
- global $ai1ec_view_helper;
548
-
549
- $this->process_request();
550
-
551
- // View arguments
552
- $args = array(
553
- 'oneday_offset' => $this->request['ai1ec_oneday_offset'],
554
- 'active_event' => $this->request['ai1ec_active_event'],
555
- 'post_ids' => array_filter( explode( ',', $this->request['ai1ec_post_ids'] ), 'is_numeric' ),
556
- );
557
-
558
- // Return this data structure to the client
559
- $data = array(
560
- 'body_class' => join( ' ', $this->body_class() ),
561
- 'html' => $this->get_oneday_view( $args ),
562
- );
563
- $ai1ec_view_helper->json_response( $data );
564
- }
565
-
566
- /**
567
- * ajax_week function
568
- *
569
- * AJAX request handler for week view.
570
- *
571
- * @return void
572
- */
573
- function ajax_week() {
574
- global $ai1ec_view_helper;
575
-
576
- $this->process_request();
577
-
578
- // View arguments
579
- $args = array(
580
- 'week_offset' => $this->request['ai1ec_week_offset'],
581
- 'active_event' => $this->request['ai1ec_active_event'],
582
- 'post_ids' => array_filter( explode( ',', $this->request['ai1ec_post_ids'] ), 'is_numeric' ),
583
- );
584
-
585
- // Return this data structure to the client
586
- $data = array(
587
- 'body_class' => join( ' ', $this->body_class() ),
588
- 'html' => $this->get_week_view( $args ),
589
- );
590
- $ai1ec_view_helper->json_response( $data );
591
- }
592
-
593
- /**
594
- * ajax_agenda function
595
- *
596
- * AJAX request handler for agenda view.
597
- *
598
- * @return void
599
- **/
600
- function ajax_agenda() {
601
- global $ai1ec_view_helper;
602
-
603
- $this->process_request();
604
-
605
- // View arguments
606
- $args = array(
607
- 'page_offset' => $this->request['ai1ec_page_offset'],
608
- 'time_limit' => $this->request['ai1ec_time_limit'],
609
- 'active_event' => $this->request['ai1ec_active_event'],
610
- 'post_ids' => array_filter( explode( ',', $this->request['ai1ec_post_ids'] ), 'is_numeric' ),
611
- );
612
-
613
- // Return this data structure to the client
614
- $data = array(
615
- 'body_class' => join( ' ', $this->body_class() ),
616
- 'html' => $this->get_agenda_view( $args ),
617
- );
618
- $ai1ec_view_helper->json_response( $data );
619
- }
620
-
621
- /**
622
- * ajax_term_filter function
623
- *
624
- * AJAX request handler that takes a comma-separated list of event IDs and
625
- * comma-separated list of term IDs and returns those event IDs within the
626
- * set that have any of the term IDs.
627
- *
628
- * @return void
629
- **/
630
- function ajax_term_filter() {
631
- global $ai1ec_view_helper, $ai1ec_events_helper;
632
-
633
- $this->process_request();
634
-
635
- $post_ids = array_unique( explode( ',', $this->request['ai1ec_post_ids'] ) );
636
-
637
- if( $this->request['ai1ec_term_ids'] ) {
638
- $term_ids = explode( ',', $this->request['ai1ec_term_ids'] );
639
- $matching_ids = $ai1ec_events_helper->filter_by_terms( $post_ids, $term_ids );
640
- } else {
641
- // If no term IDs were provided for filtering, then return all posts
642
- $matching_ids = $post_ids;
643
- }
644
-
645
- $unmatching_ids = array_diff( $post_ids, $matching_ids );
646
-
647
- $data = array(
648
- 'matching_ids' => $matching_ids,
649
- 'unmatching_ids' => $unmatching_ids,
650
- );
651
- $ai1ec_view_helper->json_response( $data );
652
- }
653
-
654
- /**
655
- * body_class function
656
- *
657
- * Append custom classes to body element.
658
- *
659
- * @return void
660
- **/
661
- function body_class( $classes = array() ) {
662
- $classes[] = 'ai1ec-calendar';
663
-
664
- // Reformat action for body class
665
- $action = $this->request['action'];
666
- $action = strtr( $action, '_', '-' );
667
- $action = preg_replace( '/^ai1ec-/', '', $action );
668
-
669
- $classes[] = "ai1ec-action-$action";
670
- if( isset( $this->request['ai1ec_month_offset'] ) && ! $this->request['ai1ec_month_offset'] &&
671
- isset( $this->request['ai1ec_page_offset'] ) && ! $this->request['ai1ec_page_offset'] ) {
672
- $classes[] = 'ai1ec-today';
673
- }
674
- return $classes;
675
- }
676
-
677
- /**
678
- * load_css function
679
- *
680
- * Enqueue any CSS files required by the calendar views, as well as embeds any
681
- * CSS rules necessary for calendar container replacement.
682
- *
683
- * @return void
684
- */
685
- function load_css() {
686
- global $ai1ec_settings, $ai1ec_view_helper;
687
-
688
- $ai1ec_view_helper->theme_enqueue_style( 'ai1ec-general', 'style.css' );
689
- $ai1ec_view_helper->theme_enqueue_style( 'ai1ec-calendar', 'calendar.css' );
690
-
691
- if( $ai1ec_settings->calendar_css_selector )
692
- add_action( 'wp_head', array( &$this, 'selector_css' ) );
693
- }
694
-
695
- /**
696
- * selector_css function
697
- *
698
- * Inserts dynamic CSS rules into <head> section of page to replace
699
- * desired CSS selector with calendar.
700
- */
701
- function selector_css() {
702
- global $ai1ec_view_helper, $ai1ec_settings;
703
-
704
- $ai1ec_view_helper->display_admin_css(
705
- 'selector.css',
706
- array( 'selector' => $ai1ec_settings->calendar_css_selector )
707
- );
708
- }
709
-
710
- /**
711
- * load_js function
712
- *
713
- * Enqueue any JavaScript files required by the calendar views.
714
- *
715
- * @return void
716
- **/
717
- function load_js()
718
- {
719
- global $ai1ec_settings, $ai1ec_view_helper;
720
-
721
- // Include dependent scripts (jQuery plugins, modernizr)
722
- $ai1ec_view_helper->theme_enqueue_script( 'jquery.scrollTo', 'jquery.scrollTo-min.js', array( 'jquery' ) );
723
- $ai1ec_view_helper->theme_enqueue_script( 'jquery.tableScroll', 'jquery.tablescroll.js', array( 'jquery' ) );
724
- $ai1ec_view_helper->theme_enqueue_script( 'modernizr.custom.78720', 'modernizr.custom.78720.js' );
725
- // Include element selector function
726
- $ai1ec_view_helper->admin_enqueue_script( 'ai1ec-element-selector', 'element-selector.js', array( 'jquery' ) );
727
- // Include custom script
728
- $ai1ec_view_helper->theme_enqueue_script( 'ai1ec-calendar', 'calendar.min.js',
729
- array( 'jquery', 'jquery.scrollTo', 'jquery.tableScroll', 'modernizr.custom.78720' ) );
730
-
731
- $data = array(
732
- // Point script to AJAX URL - use relative to plugin URL to fix domain mapping issues
733
- 'ajaxurl' => site_url( 'wp-admin/admin-ajax.php' ),
734
- // What this view defaults to, in case there is no #hash appended
735
- 'default_hash' => '#' . http_build_query( $this->request ),
736
- 'export_url' => AI1EC_EXPORT_URL,
737
- // Body classes if need to be set manually
738
- 'body_class' => join( ' ', $this->body_class() ),
739
- );
740
- // Replace desired CSS selector with calendar, if selector has been set
741
- if( $ai1ec_settings->calendar_css_selector )
742
- {
743
- $page = get_post( $ai1ec_settings->calendar_post_id );
744
- $data['selector'] = $ai1ec_settings->calendar_css_selector;
745
- $data['title'] = $page->post_title;
746
- }
747
-
748
- wp_localize_script( 'ai1ec-calendar', 'ai1ec_calendar', $data );
749
- }
750
-
751
- /**
752
- * function is_category_requested
753
- *
754
- * Returns the comma-separated list of category IDs that the calendar page
755
- * was requested to be prefiltered by.
756
- *
757
- * @return string
758
- */
759
- function get_requested_categories() {
760
- return $this->request['ai1ec_cat_ids'];
761
- }
762
- }
763
- // END class
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/controller/class-ai1ec-events-controller.php DELETED
@@ -1,830 +0,0 @@
1
- <?php
2
- //
3
- // class-ai1ec-events-controller.php
4
- // all-in-one-event-calendar
5
- //
6
- // Created by The Seed Studio on 2011-07-13.
7
- //
8
-
9
- /**
10
- * Ai1ec_Events_Controller class
11
- *
12
- * @package Controllers
13
- * @author time.ly
14
- **/
15
- class Ai1ec_Events_Controller {
16
- /**
17
- * _instance class variable
18
- *
19
- * Class instance
20
- *
21
- * @var null | object
22
- **/
23
- private static $_instance = NULL;
24
-
25
- /**
26
- * get_instance function
27
- *
28
- * Return singleton instance
29
- *
30
- * @return object
31
- **/
32
- static function get_instance() {
33
- if( self::$_instance === NULL ) {
34
- self::$_instance = new self();
35
- }
36
-
37
- return self::$_instance;
38
- }
39
-
40
- /**
41
- * Constructor
42
- *
43
- **/
44
- private function __construct() { }
45
-
46
- /**
47
- * delete_hook function
48
- *
49
- * If the deleted post is an event
50
- * then all entries that match the post_id are
51
- * removed from ai1ec_events and ai1ec_event_instances tables
52
- *
53
- * @param int $pid Post ID
54
- *
55
- * @return bool | int
56
- **/
57
- function delete_post( $pid ) {
58
- global $wpdb;
59
-
60
- $pid = (int)$pid;
61
- $sql = '
62
- SELECT
63
- ID
64
- FROM
65
- ' . $wpdb->posts . '
66
- WHERE
67
- ID = ' . $pid . ' AND
68
- post_type = \'' . AI1EC_POST_TYPE . '\'';
69
-
70
- // is this post an event?
71
- if ( $wpdb->get_var( $sql ) ) {
72
- try {
73
- $table_name = $wpdb->prefix . 'ai1ec_events';
74
- $sql = '
75
- DELETE FROM
76
- ' . $table_name . '
77
- WHERE
78
- post_id = ' . $pid;
79
- // delete from ai1ec_events
80
- $wpdb->query( $sql );
81
-
82
- $table_name = $wpdb->prefix . 'ai1ec_event_instances';
83
- $sql = '
84
- DELETE FROM
85
- ' . $table_name . '
86
- WHERE
87
- post_id = ' . $pid;
88
- // delete from ai1ec_event_instances
89
- return $wpdb->query( $sql );
90
- } catch ( Ai1ec_Event_Not_Found $exception ) {
91
- /**
92
- * Possible reason, why event `delete` is triggered, albeit
93
- * no details are found corresponding to it - the WordPress
94
- * is not transactional - it uses no means, to ensure, that
95
- * everything is deleted once and forever and thus it could
96
- * happen so, that partial records are left in DB.
97
- */
98
- return true; // already deleted
99
- }
100
- }
101
- return true;
102
- }
103
-
104
- /**
105
- * init function
106
- *
107
- * This function is executed when admin_head hook is called.
108
- * Adds CSS and JS files.
109
- *
110
- * @return void
111
- **/
112
- public function init()
113
- {
114
- global $ai1ec_events_helper, $ai1ec_settings, $wp_locale, $ai1ec_view_helper;
115
-
116
- // Initialize dashboard view
117
- if( is_admin() ) {
118
- // ======
119
- // = JS =
120
- // ======
121
- // Include timespan helper functions
122
- $ai1ec_view_helper->admin_enqueue_script( 'jquery.calendrical', 'jquery.calendrical.js', array( 'jquery' ) );
123
- // Include timespan plugin
124
- $ai1ec_view_helper->admin_enqueue_script( 'jquery.timespan', 'jquery.timespan.js', array( 'jquery', 'jquery.calendrical' ) );
125
- // Include timespan plugin
126
- $ai1ec_view_helper->admin_enqueue_script( 'jquery.inputdate', 'jquery.inputdate.js', array( 'jquery', 'jquery.calendrical' ) );
127
- // Include Google Maps API
128
- wp_enqueue_script( 'gmap_api', 'http://maps.google.com/maps/api/js?sensor=false&language=' . $ai1ec_events_helper->get_lang() );
129
- // Include autocomplete_geomod plugin
130
- $ai1ec_view_helper->admin_enqueue_script( 'autocomplete_geomod', 'jquery.autocomplete_geomod.js', array( 'jquery' ) );
131
- // Include geo_autocomplete plugin
132
- $ai1ec_view_helper->admin_enqueue_script( 'geo_autocomplete', 'geo_autocomplete.js', array( 'jquery', 'autocomplete_geomod' ) );
133
- // Include element selector function
134
- $ai1ec_view_helper->admin_enqueue_script( 'ai1ec-element-selector', 'element-selector.js', array( 'jquery' ) );
135
- // Include jQuery Tools form elements
136
- $ai1ec_view_helper->admin_enqueue_script( 'jquery.tools', 'jquery.tools.min.js', array( 'jquery' ) );
137
- // Include add new event script
138
- $ai1ec_view_helper->admin_enqueue_script( 'ai1ec-blockui', 'jquery.blockUI.js', array( 'jquery' ) );
139
- // Include date picker plugin
140
- $ai1ec_view_helper->admin_enqueue_script( 'ai1ec-datepicker', 'datepicker.js', array( 'jquery' ) );
141
-
142
- $ai1ec_view_helper->admin_enqueue_script( 'ai1ec-bootstrap-tooltip', 'bootstrap-tooltip.js', array( 'jquery' ) );
143
- $ai1ec_view_helper->admin_enqueue_script( 'ai1ec-bootstrap-popover', 'bootstrap-popover.js', array( 'jquery', 'ai1ec-bootstrap-tooltip' ) );
144
- $ai1ec_view_helper->admin_enqueue_script(
145
- 'ai1ec-add_new_event',
146
- 'add_new_event.js',
147
- array(
148
- 'jquery',
149
- 'jquery.timespan',
150
- 'ai1ec-element-selector',
151
- 'jquery.tools',
152
- 'ai1ec-blockui',
153
- 'ai1ec-datepicker',
154
- 'ai1ec-bootstrap-popover',
155
- )
156
- );
157
-
158
- $ai1ec_view_helper->admin_enqueue_script( 'ai1ec-color-picker', 'colorpicker.js', array( 'jquery' ) );
159
-
160
- // Supply custom value to JavaScript from PHP
161
- wp_localize_script( 'ai1ec-add_new_event', 'ai1ec_add_new_event', array(
162
- // Current time, used for date/time pickers
163
- 'now' => $ai1ec_events_helper->gmt_to_local( time() ),
164
- // Date format for date pickers
165
- 'date_format' => $ai1ec_settings->input_date_format,
166
- // Names for months in date picker header (escaping is done in wp_localize_script)
167
- 'month_names' => implode( ',', $wp_locale->month ),
168
- // Names for days in date picker header (escaping is done in wp_localize_script)
169
- 'day_names' => implode( ',', $wp_locale->weekday_initial ),
170
- // Start the week on this day in the date picker
171
- 'week_start_day' => $ai1ec_settings->week_start_day,
172
- // 24h time format for time pickers
173
- 'twentyfour_hour' => $ai1ec_settings->input_24h_time,
174
- // Set region biasing for geo_autocomplete plugin
175
- 'region' => ( $ai1ec_settings->geo_region_biasing ) ? $ai1ec_events_helper->get_region() : '',
176
- // ICS feed error messages
177
- 'duplicate_feed_message' => esc_html__( 'This feed is already being imported.', AI1EC_PLUGIN_NAME ),
178
- 'invalid_url_message' => esc_html__( 'Please enter a valid iCalendar URL.', AI1EC_PLUGIN_NAME ),
179
- 'disable_autocompletion' => $ai1ec_settings->disable_autocompletion,
180
- ) );
181
-
182
- // =======
183
- // = CSS =
184
- // =======
185
- // include autocomplete style
186
- $ai1ec_view_helper->admin_enqueue_style( 'autocomplete', 'jquery.autocomplete.css' );
187
- // include colorpicker style
188
- $ai1ec_view_helper->admin_enqueue_style( 'colorpicker', 'colorpicker.css' );
189
- // include add new event style
190
- $ai1ec_view_helper->admin_enqueue_style( 'ai1ec_add_new_event', 'add_new_event.css' );
191
- // include datepicker style
192
- $ai1ec_view_helper->admin_enqueue_style( 'ai1ec_datepicker', 'datepicker.css' );
193
- }
194
- // Initialize front-end view
195
- else
196
- {
197
- // ======
198
- // = JS =
199
- // ======
200
- $ai1ec_view_helper->theme_enqueue_script( 'ai1ec-event', 'event.min.js', array( 'jquery' ) );
201
- // Supply custom value to JavaScript from PHP
202
- wp_localize_script( 'ai1ec-event', 'ai1ec_event', array(
203
- // Language for Google Map
204
- 'language' => $ai1ec_events_helper->get_lang()
205
- ) );
206
-
207
- // =======
208
- // = CSS =
209
- // =======
210
- $ai1ec_view_helper->theme_enqueue_style( 'ai1ec-general', 'style.css' );
211
- $ai1ec_view_helper->theme_enqueue_style( 'ai1ec-event', 'event.css' );
212
- // Load the print style only if the parameter print is set to true.
213
- if( isset( $_GET['print'] ) && $_GET['print'] === 'true' ) {
214
- $ai1ec_view_helper->theme_enqueue_style( 'ai1ec-print', 'print.css' );
215
- }
216
- }
217
- }
218
-
219
- /**
220
- * meta_box_view function
221
- *
222
- * Add Events Calculator box to the Add New Event page
223
- *
224
- * @return void
225
- **/
226
- function meta_box_view() {
227
- global $ai1ec_view_helper,
228
- $ai1ec_events_helper,
229
- $post,
230
- $wpdb,
231
- $ai1ec_settings;
232
-
233
- // ==================
234
- // = Default values =
235
- // ==================
236
- $all_day_event = '';
237
- $start_timestamp = '';
238
- $end_timestamp = '';
239
- $show_map = false;
240
- $google_map = '';
241
- $venue = '';
242
- $country = '';
243
- $address = '';
244
- $city = '';
245
- $province = '';
246
- $postal_code = '';
247
- $contact_name = '';
248
- $contact_phone = '';
249
- $contact_email = '';
250
- $cost = '';
251
- $rrule = '';
252
- $rrule_text = '';
253
- $repeating_event = false;
254
- $exrule = '';
255
- $exrule_text = '';
256
- $exclude_event = false;
257
- $exdate = '';
258
-
259
- try
260
- {
261
- $event = new Ai1ec_Event( $post->ID );
262
-
263
- // Existing event was found. Initialize form values with values from
264
- // event object.
265
-
266
- $all_day_event = $event->allday ? 'checked="checked"' : '';
267
-
268
-
269
- $start_timestamp = $ai1ec_events_helper->gmt_to_local( $event->start );
270
- $end_timestamp = $ai1ec_events_helper->gmt_to_local( $event->end );
271
-
272
- $multi_day = $event->multiday;
273
-
274
- $show_map = $event->show_map;
275
- $google_map = $show_map ? 'checked="checked"' : '';
276
-
277
- $venue = $event->venue;
278
- $country = $event->country;
279
- $address = $event->address;
280
- $city = $event->city;
281
- $province = $event->province;
282
- $postal_code = $event->postal_code;
283
- $contact_name = $event->contact_name;
284
- $contact_phone = $event->contact_phone;
285
- $contact_email = $event->contact_email;
286
- $cost = $event->cost;
287
- $rrule = empty( $event->recurrence_rules ) ? '' : $ai1ec_events_helper->ics_rule_to_local( $event->recurrence_rules );
288
- $exrule = empty( $event->exception_rules ) ? '' : $ai1ec_events_helper->ics_rule_to_local( $event->exception_rules );
289
- $exdate = empty( $event->exception_dates ) ? '' : $ai1ec_events_helper->exception_dates_to_local( $event->exception_dates );
290
- $repeating_event = empty( $rrule ) ? false : true;
291
- $exclude_event = empty( $exrule ) ? false : true;
292
-
293
- if( $repeating_event )
294
- $rrule_text = $ai1ec_events_helper->rrule_to_text( $rrule );
295
-
296
- if( $exclude_event )
297
- $exrule_text = $ai1ec_events_helper->rrule_to_text( $exrule );
298
- }
299
- catch( Ai1ec_Event_Not_Found $e ) {
300
- // Event does not exist.
301
- // Leave form fields undefined (= zero-length strings)
302
- $event = null;
303
- }
304
-
305
- // Time zone
306
- $timezone = get_option( 'gmt_offset' );
307
- $timezone = sprintf( '(GMT%+d:%02d)', intval( $timezone ), ( abs( $timezone ) * 60 ) % 60 );
308
-
309
- // ===============================
310
- // = Display event time and date =
311
- // ===============================
312
- $args = array(
313
- 'all_day_event' => $all_day_event,
314
- 'start_timestamp' => $start_timestamp,
315
- 'end_timestamp' => $end_timestamp,
316
- 'repeating_event' => $repeating_event,
317
- 'rrule' => $rrule,
318
- 'rrule_text' => $rrule_text,
319
- 'exclude_event' => $exclude_event,
320
- 'exrule' => $exrule,
321
- 'exrule_text' => $exrule_text,
322
- 'timezone' => $timezone,
323
- 'exdate' => $exdate
324
- );
325
- $ai1ec_view_helper->display_admin( 'box_time_and_date.php', $args );
326
-
327
- // =================================================
328
- // = Display event location details and Google map =
329
- // =================================================
330
- $args = array(
331
- 'venue' => $venue,
332
- 'country' => $country,
333
- 'address' => $address,
334
- 'city' => $city,
335
- 'province' => $province,
336
- 'postal_code' => $postal_code,
337
- 'google_map' => $google_map,
338
- 'show_map' => $show_map,
339
- );
340
- $ai1ec_view_helper->display_admin( 'box_event_location.php', $args );
341
-
342
- // ======================
343
- // = Display event cost =
344
- // ======================
345
- $args = array(
346
- 'cost' => $cost
347
- );
348
- $ai1ec_view_helper->display_admin( 'box_event_cost.php', $args );
349
-
350
- // =========================================
351
- // = Display organizer contact information =
352
- // =========================================
353
- $args = array(
354
- 'contact_name' => $contact_name,
355
- 'contact_phone' => $contact_phone,
356
- 'contact_email' => $contact_email,
357
- );
358
- $ai1ec_view_helper->display_admin( 'box_event_contact.php', $args );
359
-
360
- if( $ai1ec_settings->show_publish_button ) {
361
- $args = array();
362
- $post_type = $post->post_type;
363
- $post_type_object = get_post_type_object( $post_type );
364
- if( current_user_can( $post_type_object->cap->publish_posts ) )
365
- $args["button_value"] = is_null( $event ) ? __( 'Publish', AI1EC_PLUGIN_NAME ) : __( 'Update', AI1EC_PLUGIN_NAME );
366
- else
367
- $args["button_value"] = __( 'Submit for Review', AI1EC_PLUGIN_NAME );
368
-
369
- $ai1ec_view_helper->display_admin( 'box_publish_button.php', $args );
370
- }
371
-
372
- /*
373
- TODO Display Eventbrite ticketing
374
- $ai1ec_view_helper->display( 'box_eventbrite.php' );
375
- */
376
- }
377
-
378
- /**
379
- * save_post function
380
- *
381
- * Saves meta post data
382
- *
383
- * @param int $post_id Post ID
384
- *
385
- * @return void
386
- **/
387
- function save_post( $post_id, $post ) {
388
- global $wpdb, $ai1ec_events_helper;
389
-
390
- // verify this came from the our screen and with proper authorization,
391
- // because save_post can be triggered at other times
392
- if( isset( $_POST[AI1EC_POST_TYPE] ) && ! wp_verify_nonce( $_POST[AI1EC_POST_TYPE], 'ai1ec' ) ) {
393
- return;
394
- } else if( ! isset( $_POST[AI1EC_POST_TYPE] ) ) {
395
- return;
396
- }
397
-
398
- if( isset( $post->post_status ) && $post->post_status == 'auto-draft' )
399
- return;
400
-
401
- // verify if this is not inline-editing
402
- if( isset( $_REQUEST['action'] ) && $_REQUEST['action'] == 'inline-save' ) {
403
- return;
404
- }
405
-
406
- // verify that the post_type is that of an event
407
- if( isset( $_POST['post_type'] ) && $_POST['post_type'] != AI1EC_POST_TYPE ) {
408
- return;
409
- }
410
-
411
- $all_day = isset( $_POST['ai1ec_all_day_event'] ) ? 1 : 0;
412
- $start_time = isset( $_POST['ai1ec_start_time'] ) ? $_POST['ai1ec_start_time'] : '';
413
- $end_time = isset( $_POST['ai1ec_end_time'] ) ? $_POST['ai1ec_end_time'] : '';
414
- $venue = isset( $_POST['ai1ec_venue'] ) ? stripslashes( $_POST['ai1ec_venue'] ) : '';
415
- $address = isset( $_POST['ai1ec_address'] ) ? stripslashes( $_POST['ai1ec_address'] ) : '';
416
- $city = isset( $_POST['ai1ec_city'] ) ? stripslashes( $_POST['ai1ec_city'] ) : '';
417
- $province = isset( $_POST['ai1ec_province'] ) ? stripslashes( $_POST['ai1ec_province'] ) : '';
418
- $postal_code = isset( $_POST['ai1ec_postal_code'] ) ? stripslashes( $_POST['ai1ec_postal_code'] ) : '';
419
- $country = isset( $_POST['ai1ec_country'] ) ? stripslashes( $_POST['ai1ec_country'] ) : '';
420
- $google_map = isset( $_POST['ai1ec_google_map'] ) ? 1 : 0;
421
- $cost = isset( $_POST['ai1ec_cost'] ) ? stripslashes( $_POST['ai1ec_cost'] ) : '';
422
- $contact_name = isset( $_POST['ai1ec_contact_name'] ) ? stripslashes( $_POST['ai1ec_contact_name'] ) : '';
423
- $contact_phone = isset( $_POST['ai1ec_contact_phone'] ) ? stripslashes( $_POST['ai1ec_contact_phone'] ) : '';
424
- $contact_email = isset( $_POST['ai1ec_contact_email'] ) ? stripslashes( $_POST['ai1ec_contact_email'] ) : '';
425
-
426
- $rrule = null;
427
- $exrule = null;
428
- $exdate = null;
429
-
430
- // if rrule is set, convert it from local to UTC time
431
- if( isset( $_POST['ai1ec_repeat'] ) && ! empty( $_POST['ai1ec_repeat'] ) )
432
- $rrule = $ai1ec_events_helper->ics_rule_to_gmt( $_POST['ai1ec_rrule'] );
433
-
434
- // if exrule is set, convert it from local to UTC time
435
- if( isset( $_POST['ai1ec_exclude'] ) && ! empty( $_POST['ai1ec_exclude'] ) )
436
- $exrule = $ai1ec_events_helper->ics_rule_to_gmt( $_POST['ai1ec_exrule'] );
437
-
438
- // if exdate is set, convert it from local to UTC time
439
- if( isset( $_POST['ai1ec_exdate'] ) && ! empty( $_POST['ai1ec_exdate'] ) )
440
- $exdate = $ai1ec_events_helper->exception_dates_to_gmt( $_POST['ai1ec_exdate'] );
441
-
442
- $is_new = false;
443
- $event = null;
444
- try {
445
- $event = new Ai1ec_Event( $post_id ? $post_id : null );
446
- } catch( Ai1ec_Event_Not_Found $e ) {
447
- // Post exists, but event data hasn't been saved yet. Create new event
448
- // object.
449
- $is_new = true;
450
- $event = new Ai1ec_Event();
451
- $event->post_id = $post_id;
452
- }
453
-
454
- $event->start = $ai1ec_events_helper->local_to_gmt( $start_time );
455
- $event->end = $ai1ec_events_helper->local_to_gmt( $end_time );
456
- $event->allday = $all_day;
457
- $event->venue = $venue;
458
- $event->address = $address;
459
- $event->city = $city;
460
- $event->province = $province;
461
- $event->postal_code = $postal_code;
462
- $event->country = $country;
463
- $event->show_map = $google_map;
464
- $event->cost = $cost;
465
- $event->contact_name = $contact_name;
466
- $event->contact_phone = $contact_phone;
467
- $event->contact_email = $contact_email;
468
- $event->recurrence_rules = $rrule;
469
- $event->exception_rules = $exrule;
470
- $event->exception_dates = $exdate;
471
-
472
- $event->save( ! $is_new );
473
-
474
- $ai1ec_events_helper->delete_event_cache( $post_id );
475
- $ai1ec_events_helper->cache_event( $event );
476
- return;
477
- }
478
-
479
- /**
480
- * post_updated_messages function
481
- *
482
- * Filter success messages returned by WordPress when an event post is
483
- * updated/saved.
484
- */
485
- function post_updated_messages( $messages )
486
- {
487
- global $post, $post_ID;
488
-
489
- $messages[AI1EC_POST_TYPE] = array(
490
- 0 => '', // Unused. Messages start at index 1.
491
- 1 => sprintf( __( 'Event updated. <a href="%s">View event</a>', AI1EC_PLUGIN_NAME ), esc_url( get_permalink( $post_ID ) ) ),
492
- 2 => __( 'Custom field updated.', AI1EC_PLUGIN_NAME ),
493
- 3 => __( 'Custom field deleted.', AI1EC_PLUGIN_NAME ),
494
- 4 => __( 'Event updated.', AI1EC_PLUGIN_NAME ),
495
- /* translators: %s: date and time of the revision */
496
- 5 => isset( $_GET['revision'] ) ? sprintf( __( 'Event restored to revision from %s', AI1EC_PLUGIN_NAME ), wp_post_revision_title( (int) $_GET['revision'], false ) ) : false,
497
- 6 => sprintf( __( 'Event published. <a href="%s">View event</a>', AI1EC_PLUGIN_NAME ), esc_url( get_permalink($post_ID) ) ),
498
- 7 => __( 'Event saved.' ),
499
- 8 => sprintf( __( 'Event submitted. <a target="_blank" href="%s">Preview event</a>', AI1EC_PLUGIN_NAME ), esc_url( add_query_arg( 'preview', 'true', get_permalink( $post_ID ) ) ) ),
500
- 9 => sprintf( __( 'Event scheduled for: <strong>%1$s</strong>. <a target="_blank" href="%2$s">Preview event</a>', AI1EC_PLUGIN_NAME ),
501
- // translators: Publish box date format, see http://php.net/date
502
- date_i18n( __( 'M j, Y @ G:i', AI1EC_PLUGIN_NAME ), strtotime( $post->post_date ) ), esc_url( get_permalink($post_ID) ) ),
503
- 10 => sprintf( __( 'Event draft updated. <a target="_blank" href="%s">Preview event</a>', AI1EC_PLUGIN_NAME ), esc_url( add_query_arg( 'preview', 'true', get_permalink( $post_ID ) ) ) ),
504
- );
505
-
506
- return $messages;
507
- }
508
-
509
- /**
510
- * event_content function
511
- *
512
- * Filter event post content by inserting relevant details of the event
513
- * alongside the regular post content.
514
- *
515
- * @param string $content Post/Page content
516
- *
517
- * @return string Post/Page content
518
- **/
519
- function event_content( $content )
520
- {
521
- global $ai1ec_events_helper;
522
-
523
- if( get_post_type() == AI1EC_POST_TYPE ) {
524
- $event = $ai1ec_events_helper->get_event( get_the_ID() );
525
- $content = $this->get_view( $event, $content );
526
- }
527
- return $content;
528
- }
529
-
530
- /**
531
- * event_excerpt function
532
- *
533
- * Overrides what wp_trim_excerpt() returned if the post is an event,
534
- * and outputs better rich-text (but not too rich) excerpt instead.
535
- *
536
- * @return void
537
- **/
538
- function event_excerpt( $text )
539
- {
540
- global $ai1ec_view_helper,
541
- $ai1ec_events_helper;
542
-
543
- if( get_post_type() != AI1EC_POST_TYPE )
544
- return $text;
545
-
546
- $event = new Ai1ec_Event( get_the_ID() );
547
-
548
- ob_start();
549
-
550
- $this->excerpt_view( $event );
551
-
552
- // Re-apply any filters to the post content that normally would have been
553
- // applied if it weren't for our interference (below).
554
- echo
555
- shortcode_unautop( wpautop(
556
- $ai1ec_events_helper->trim_excerpt( $event->post->post_content )
557
- ) );
558
-
559
- $page_content = ob_get_contents();
560
- ob_end_clean();
561
-
562
- return $page_content;
563
- }
564
-
565
- /**
566
- * event_excerpt_noautop function
567
- *
568
- * Conditionally apply wpautop() filter to content, only if it is not an
569
- * event.
570
- *
571
- * @return void
572
- **/
573
- function event_excerpt_noautop( $content )
574
- {
575
- if( get_post_type() != AI1EC_POST_TYPE )
576
- return wpautop( $content );
577
- return $content;
578
- }
579
-
580
- /**
581
- * get_view function
582
- *
583
- * Returns the appropriate output to prepend to an event post, depending on
584
- * WP loop context.
585
- *
586
- * @param Ai1ec_Event $event The event post being displayed
587
- * @param string $content The post's original content
588
- *
589
- * @return string The event data markup to prepend to the post content
590
- **/
591
- function get_view( &$event, &$content )
592
- {
593
- global $ai1ec_view_helper;
594
-
595
- ob_start();
596
-
597
- if( is_single() ) {
598
- $this->single_view( $event );
599
- } else {
600
- $this->multi_view( $event );
601
- }
602
-
603
- echo $content;
604
-
605
- if( is_single() )
606
- $this->single_event_footer( $event );
607
-
608
- $page_content = ob_get_contents();
609
- ob_end_clean();
610
-
611
- return $page_content;
612
- }
613
-
614
- /**
615
- * single_view function
616
- *
617
- * Outputs event-specific details as HTML to be prepended to post content
618
- * when displayed as a single page.
619
- *
620
- * @param Ai1ec_Event $event The event being displayed
621
- *
622
- * @return void
623
- **/
624
- function single_view( &$event )
625
- {
626
- global $ai1ec_view_helper,
627
- $ai1ec_calendar_helper,
628
- $ai1ec_settings;
629
-
630
- $subscribe_url = AI1EC_EXPORT_URL . "&ai1ec_post_ids=$event->post_id";
631
- $subscribe_url = str_replace( 'webcal://', 'http://', $subscribe_url );
632
-
633
- $args = array(
634
- 'event' => &$event,
635
- 'recurrence' => $event->recurrence_html,
636
- 'exclude' => $event->exclude_html,
637
- 'categories' => $event->categories_html,
638
- 'tags' => $event->tags_html,
639
- 'location' => nl2br( esc_html( $event->location ) ),
640
- 'map' => $this->get_map_view( $event ),
641
- 'contact' => $event->contact_html,
642
- 'calendar_url' => $ai1ec_calendar_helper->get_calendar_url( $event ),
643
- 'subscribe_url' => $subscribe_url,
644
- 'google_url' => 'http://www.google.com/calendar/render?cid=' . urlencode( $subscribe_url ),
645
- 'show_subscribe_buttons' => ! $ai1ec_settings->turn_off_subscription_buttons
646
- );
647
- $ai1ec_view_helper->display_theme( 'event-single.php', $args );
648
- }
649
-
650
- /**
651
- * multi_view function
652
- *
653
- * Outputs event-specific details as HTML to be prepended to post content
654
- * when displayed in a loop alongside other posts.
655
- *
656
- * @param Ai1ec_Event $event The event being displayed
657
- *
658
- * @return void
659
- **/
660
- function multi_view( &$event )
661
- {
662
- global $ai1ec_view_helper,
663
- $ai1ec_calendar_helper;
664
-
665
- $location = esc_html(
666
- str_replace( "\n", ', ', rtrim( $event->location ) )
667
- );
668
-
669
- $args = array(
670
- 'event' => $event,
671
- 'recurrence' => $event->recurrence_html,
672
- 'categories' => $event->categories_html,
673
- 'tags' => $event->tags_html,
674
- 'location' => $location,
675
- 'contact' => $event->contact_html,
676
- 'calendar_url' => $ai1ec_calendar_helper->get_calendar_url( $event ),
677
- );
678
- $ai1ec_view_helper->display_theme( 'event-multi.php', $args );
679
- }
680
-
681
- /**
682
- * excerpt_view function
683
- *
684
- * Outputs event-specific details as HTML to be prepended to post content
685
- * when displayed in an excerpt format.
686
- *
687
- * @param Ai1ec_Event $event The event being displayed
688
- *
689
- * @return void
690
- **/
691
- function excerpt_view( &$event )
692
- {
693
- global $ai1ec_view_helper,
694
- $ai1ec_calendar_helper;
695
-
696
- $location = esc_html(
697
- str_replace( "\n", ', ', rtrim( $event->location ) )
698
- );
699
-
700
- $args = array(
701
- 'event' => $event,
702
- 'location' => $location,
703
- );
704
- $ai1ec_view_helper->display_theme( 'event-excerpt.php', $args );
705
- }
706
-
707
- /**
708
- * get_map_view function
709
- *
710
- * Returns HTML markup displaying a Google map of the given event, if the event
711
- * has show_map set to true. Returns a zero-length string otherwise.
712
- *
713
- * @return void
714
- **/
715
- function get_map_view( &$event )
716
- {
717
- global $ai1ec_view_helper, $ai1ec_events_helper, $ai1ec_settings;
718
-
719
- if( ! $event->show_map )
720
- return '';
721
-
722
- $args = array(
723
- 'address' => $event->address,
724
- 'gmap_url_link' => $ai1ec_events_helper->get_gmap_url( $event, false ),
725
- 'hide_maps_until_clicked' => $ai1ec_settings->hide_maps_until_clicked,
726
- );
727
- return $ai1ec_view_helper->get_theme_view( 'event-map.php', $args );
728
- }
729
-
730
- /**
731
- * single_event_footer function
732
- *
733
- * Outputs any markup that should appear below the post's content on the
734
- * single post page for this event.
735
- *
736
- * @return void
737
- **/
738
- function single_event_footer( &$event )
739
- {
740
- global $ai1ec_view_helper;
741
-
742
- $args = array(
743
- 'event' => &$event,
744
- );
745
- return $ai1ec_view_helper->display_theme( 'event-single-footer.php', $args );
746
- }
747
-
748
- /**
749
- * events_categories_add_form_fields function
750
- *
751
- *
752
- *
753
- * @return void
754
- **/
755
- function events_categories_add_form_fields() {
756
- global $ai1ec_view_helper;
757
-
758
- $args = array( 'edit' => false );
759
- $ai1ec_view_helper->display_admin( 'event_categories-color_picker.php', $args );
760
- }
761
-
762
- /**
763
- * events_categories_edit_form_fields function
764
- *
765
- *
766
- *
767
- * @return void
768
- **/
769
- function events_categories_edit_form_fields( $term ) {
770
- global $ai1ec_view_helper, $wpdb;
771
-
772
- $table_name = $wpdb->prefix . 'ai1ec_event_category_colors';
773
- $color = $wpdb->get_var( $wpdb->prepare( "SELECT term_color FROM {$table_name} WHERE term_id = %d ", $term->term_id ) );
774
-
775
- $style = '';
776
- $clr = '';
777
-
778
- if( ! is_null( $color ) && ! empty( $color ) ) {
779
- $style = 'style="background-color: ' . $color . '"';
780
- $clr = $color;
781
- }
782
-
783
- $args = array(
784
- 'style' => $style,
785
- 'color' => $clr,
786
- 'edit' => true,
787
- );
788
- $ai1ec_view_helper->display_admin( 'event_categories-color_picker.php', $args );
789
- }
790
-
791
- /**
792
- * edited_events_categories function
793
- *
794
- *
795
- *
796
- * @return void
797
- **/
798
- function created_events_categories( $term_id ) {
799
- global $wpdb;
800
- $tag_color_value = '';
801
- if( isset( $_POST["tag-color-value"] ) && ! empty( $_POST["tag-color-value"] ) ) {
802
- $tag_color_value = $_POST["tag-color-value"];
803
- }
804
-
805
- $table_name = $wpdb->prefix . 'ai1ec_event_category_colors';
806
- $wpdb->insert( $table_name, array( 'term_id' => $term_id, 'term_color' => $tag_color_value ), array( '%d', '%s' ) );
807
- }
808
-
809
- function edited_events_categories( $term_id ) {
810
- global $wpdb;
811
- $tag_color_value = '';
812
- if( isset( $_POST["tag-color-value"] ) && ! empty( $_POST["tag-color-value"] ) ) {
813
- $tag_color_value = $_POST["tag-color-value"];
814
- }
815
-
816
- $table_name = $wpdb->prefix . 'ai1ec_event_category_colors';
817
- $term = $wpdb->get_var( $wpdb->prepare( "SELECT term_id FROM {$table_name} WHERE term_id = %d", $term_id ) );
818
-
819
- if( is_null( $term ) ) {
820
- // term doesn't exist, create it
821
- $wpdb->insert( $table_name, array( 'term_id' => $term_id, 'term_color' => $tag_color_value ), array( '%d', '%s' ) );
822
- } else {
823
- // term exist, update it
824
- $wpdb->update( $table_name, array( 'term_color' => $tag_color_value ), array( 'term_id' => $term_id ), array( '%s' ), array( '%d' ) );
825
- }
826
-
827
-
828
- }
829
- }
830
- // END class
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/controller/class-ai1ec-exporter-controller.php DELETED
@@ -1,157 +0,0 @@
1
- <?php
2
- //
3
- // class-ai1ec-exporter-controller.php
4
- // all-in-one-event-calendar
5
- //
6
- // Created by The Seed Studio on 2011-07-13.
7
- //
8
-
9
- /**
10
- * Ai1ec_Exporter_Controller class
11
- *
12
- * @package Controllers
13
- * @author time.ly
14
- **/
15
- class Ai1ec_Exporter_Controller {
16
- /**
17
- * _instance class variable
18
- *
19
- * Class instance
20
- *
21
- * @var null | object
22
- **/
23
- private static $_instance = NULL;
24
-
25
- /**
26
- * get_instance function
27
- *
28
- * Return singleton instance
29
- *
30
- * @return object
31
- **/
32
- static function get_instance() {
33
- if( self::$_instance === NULL ) {
34
- self::$_instance = new self();
35
- }
36
-
37
- return self::$_instance;
38
- }
39
-
40
- /**
41
- * Constructor
42
- *
43
- * Default constructor
44
- **/
45
- private function __construct() { }
46
-
47
- /**
48
- * n_cron function
49
- *
50
- * @return void
51
- **/
52
- function n_cron() {
53
- global $ai1ec_settings, $wpdb;
54
-
55
- // send data only if cURL is available
56
- if( is_curl_available() ) {
57
- $query = "SELECT COUNT( ID ) as num_events " .
58
- "FROM $wpdb->posts " .
59
- "WHERE post_type = '" . AI1EC_POST_TYPE . "' AND " .
60
- "post_status = 'publish'";
61
- $n_events = $wpdb->get_var( $query );
62
-
63
- $query = "SELECT COUNT( ID ) FROM $wpdb->users";
64
- $n_users = $wpdb->get_var( $query );
65
-
66
- $categories = $tags = array();
67
- foreach( get_terms( 'events_categories', array( 'hide_empty' => false ) ) as $term ) {
68
- if( isset( $term->name ) )
69
- $categories[] = $term->name;
70
- }
71
- foreach( get_terms( 'events_tags', array( 'hide_empty' => false ) ) as $term ) {
72
- if( isset( $term->name ) )
73
- $tags[] = $term->name;
74
- }
75
- $data = array(
76
- 'n_users' => $n_users,
77
- 'n_events' => $n_events,
78
- 'categories' => $categories,
79
- 'tags' => $tags,
80
- 'blog_name' => get_bloginfo( 'name' ),
81
- 'cal_url' => get_permalink( $ai1ec_settings->calendar_page_id ),
82
- 'ics_url' => AI1EC_EXPORT_URL,
83
- 'php_version' => phpversion(),
84
- 'wp_version' => get_bloginfo( 'version' ),
85
- 'wp_lang' => get_bloginfo( 'language' ),
86
- 'wp_url' => home_url(),
87
- 'timezone' => get_option( 'timezone_string', 'America/Los_Angeles' ),
88
- 'privacy' => get_option( 'blog_public' ),
89
- 'plugin_version' => AI1EC_VERSION
90
- );
91
-
92
- $ch = curl_init( 'http://184.169.144.10:24132/data' );
93
- curl_setopt( $ch, CURLOPT_POST, count( $data ) );
94
- curl_setopt( $ch, CURLOPT_POSTFIELDS, http_build_query( $data ) );
95
- curl_setopt( $ch, CURLOPT_RETURNTRANSFER, 1 );
96
-
97
- //execute post
98
- $result = curl_exec( $ch );
99
-
100
- //close connection
101
- curl_close( $ch );
102
- }
103
- }
104
-
105
- /**
106
- * export_events function
107
- *
108
- * Export events
109
- *
110
- * @return void
111
- **/
112
- function export_events() {
113
- global $ai1ec_events_helper,
114
- $ai1ec_exporter_helper;
115
- $ai1ec_cat_ids = isset( $_REQUEST['ai1ec_cat_ids'] ) && ! empty( $_REQUEST['ai1ec_cat_ids'] ) ? $_REQUEST['ai1ec_cat_ids'] : false;
116
- $ai1ec_tag_ids = isset( $_REQUEST['ai1ec_tag_ids'] ) && ! empty( $_REQUEST['ai1ec_tag_ids'] ) ? $_REQUEST['ai1ec_tag_ids'] : false;
117
- $ai1ec_post_ids = isset( $_REQUEST['ai1ec_post_ids'] ) && ! empty( $_REQUEST['ai1ec_post_ids'] ) ? $_REQUEST['ai1ec_post_ids'] : false;
118
- $filter = array();
119
-
120
- if ( $ai1ec_cat_ids ) {
121
- $filter['cat_ids'] = ai1ec_make_ints_array( $ai1ec_cat_ids );
122
- }
123
- if ( $ai1ec_tag_ids ) {
124
- $filter['tag_ids'] = ai1ec_make_ints_array( $ai1ec_tag_ids );
125
- }
126
- if ( $ai1ec_post_ids ) {
127
- $filter['post_ids'] = ai1ec_make_ints_array( $ai1ec_post_ids );
128
- }
129
-
130
- // when exporting events by post_id, do not look up the event's start/end date/time
131
- $start = $ai1ec_post_ids !== false ? false : gmmktime() - 24 * 60 * 60; // Include any events ending today
132
- $end = false;
133
- $events = $ai1ec_events_helper->get_matching_events( $start, $end, $filter );
134
- $c = new vcalendar();
135
- $c->setProperty( 'calscale', 'GREGORIAN' );
136
- $c->setProperty( 'method', 'PUBLISH' );
137
- $c->setProperty( 'X-WR-CALNAME', get_bloginfo( 'name' ) );
138
- $c->setProperty( 'X-WR-CALDESC', get_bloginfo( 'description' ) );
139
- // Timezone setup
140
- $tz = get_option( 'timezone_string' );
141
- if( $tz ) {
142
- $c->setProperty( 'X-WR-TIMEZONE', $tz );
143
- $tz_xprops = array( 'X-LIC-LOCATION' => $tz );
144
- iCalUtilityFunctions::createTimezone( $c, $tz, $tz_xprops );
145
- }
146
-
147
- foreach( $events as $event ) {
148
- $ai1ec_exporter_helper->insert_event_in_calendar( $event, $c, $export = true );
149
- }
150
- $str = ltrim( $c->createCalendar() );
151
-
152
- header( 'Content-type: text/calendar; charset=utf-8' );
153
- echo $str;
154
- exit;
155
- }
156
- }
157
- // END class
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/controller/class-ai1ec-importer-controller.php DELETED
@@ -1,209 +0,0 @@
1
- <?php
2
- //
3
- // class-ai1ec-importer-controller.php
4
- // all-in-one-event-calendar
5
- //
6
- // Created by The Seed Studio on 2011-07-13.
7
- //
8
-
9
- /**
10
- * Ai1ec_Importer_Controller class
11
- *
12
- * @package Controllers
13
- * @author time.ly
14
- **/
15
- class Ai1ec_Importer_Controller {
16
- /**
17
- * _instance class variable
18
- *
19
- * Class instance
20
- *
21
- * @var null | object
22
- **/
23
- private static $_instance = NULL;
24
-
25
- /**
26
- * get_instance function
27
- *
28
- * Return singleton instance
29
- *
30
- * @return object
31
- **/
32
- static function get_instance() {
33
- if( self::$_instance === NULL ) {
34
- self::$_instance = new self();
35
- }
36
-
37
- return self::$_instance;
38
- }
39
-
40
- /**
41
- * Constructor
42
- *
43
- * Default constructor
44
- **/
45
- private function __construct() { }
46
-
47
- /**
48
- * cron function
49
- *
50
- * Import all ICS feeds
51
- *
52
- * @return void
53
- **/
54
- function cron()
55
- {
56
- global $wpdb,
57
- $ai1ec_importer_helper,
58
- $ai1ec_events_helper,
59
- $ai1ec_app_helper,
60
- $ai1ec_settings_controller;
61
-
62
- // Initializing custom post type and custom taxonomies
63
- $ai1ec_app_helper->create_post_type();
64
-
65
- // ====================
66
- // = Select all feeds =
67
- // ====================
68
- $table_name = $wpdb->prefix . 'ai1ec_event_feeds';
69
- $sql = "SELECT * FROM {$table_name}";
70
- $feeds = $wpdb->get_results( $sql );
71
-
72
- // ===============================
73
- // = go over each iCalendar feed =
74
- // ===============================
75
- foreach( $feeds as $feed ) {
76
- // flush the feed
77
- $ai1ec_settings_controller->flush_ics_feed( false, $feed->feed_url );
78
- // import the feed
79
- $ai1ec_importer_helper->parse_ics_feed( $feed );
80
- }
81
- }
82
-
83
- /**
84
- * register_importer function
85
- *
86
- * Registers the event calendar importer
87
- *
88
- * @return void
89
- **/
90
- function register_importer() {
91
- global $wp_importers;
92
-
93
- if( ! isset( $wp_importers['ai1ec_the_events_calendar'] ) ) {
94
- $wp_importers['ai1ec_the_events_calendar'] = array(
95
- __( 'The Events Calendar → All-in-One Event Calendar', AI1EC_PLUGIN_NAME ),
96
- __( 'Imports events created using The Events Calendar plugin into the All-in-One Event Calendar', AI1EC_PLUGIN_NAME ),
97
- array( &$this, 'import_the_events_calendar' )
98
- );
99
- }
100
- }
101
-
102
- /**
103
- * import_the_events_calendar function
104
- *
105
- * Import events from The Events Calendar into Ai1ec.
106
- *
107
- * @return void
108
- **/
109
- function import_the_events_calendar() {
110
- global $ai1ec_view_helper,
111
- $ai1ec_events_helper;
112
-
113
- $args = array(
114
- 'post_type' => 'post',
115
- 'numberposts' => -1,
116
- 'meta_key' => '_isEvent',
117
- 'meta_value' => 'yes'
118
- );
119
- $posts = get_posts( $args );
120
-
121
- $imported_events = 0;
122
- foreach( $posts as $post )
123
- {
124
- $event = new Ai1ec_Event( null );
125
- $postmeta = get_post_custom( $post->ID );
126
-
127
- // Need this to offset dates coming from The Events Calendar
128
- $gm_diff = mktime( 0 ) - gmmktime( 0 );
129
-
130
- $event->allday = $postmeta['_EventAllDay'][0] == 'yes' || $postmeta['_EventAllDay'][0] == 1;
131
- $event->start = strtotime( $postmeta['_EventStartDate'][0] ) - $gm_diff;
132
- $event->end = strtotime( $postmeta['_EventEndDate'][0] ) - $gm_diff;
133
- // If all-day event, align start/end to start/end of day
134
- if( $event->allday ) {
135
- $event->start = $ai1ec_events_helper->gmgetdate( $event->start );
136
- $event->start = gmmktime( 0, 0, 0, $event->start['mon'], $event->start['mday'], $event->start['year'] );
137
- $event->end = $ai1ec_events_helper->gmgetdate( $event->end );
138
- $event->end = gmmktime( 0, 0, 0, $event->end['mon'], $event->end['mday'], $event->end['year'] );
139
- }
140
- // Finally, convert to GMT storage format
141
- $event->start = $ai1ec_events_helper->local_to_gmt( $event->start );
142
- $event->end = $ai1ec_events_helper->local_to_gmt( $event->end );
143
- // Bug in The Events Calendar where some all-day events start and end at the same time
144
- if( $event->allday && $event->end - $event->start < ( 24 * 60 * 60 ) )
145
- $event->end = $event->start + 24 * 60 * 60;
146
- $event->venue = $postmeta['_EventVenue'][0];
147
- $event->country = $postmeta['_EventCountry'][0];
148
- $event->city = $postmeta['_EventCity'][0];
149
- $event->province = $postmeta['_EventState'][0];
150
- $event->postal_code = $postmeta['_EventZip'][0];
151
- $event->address = array();
152
- if( $postmeta['$_EventAddress'] ) $event->address[] = $postmeta['$_EventAddress'];
153
- if( $event->city ) $event->address[] = $event->city;
154
- if( $event->province ) $event->address[] = $event->province;
155
- if( $event->postal_code ) $event->address[] = $event->postal_code;
156
- if( $event->country ) $event->address[] = $event->country;
157
- $event->address = join( ', ', $event->address );
158
- $event->show_map = $postmeta['_EventShowMapLink'][0] == 'true' || $postmeta['_EventShowMap'][0] == 'true';
159
- $event->cost = $postmeta['_EventCost'][0];
160
- $event->contact_phone = $postmeta['_EventPhone'][0];
161
- $event->post = get_object_vars( $post );
162
- $event->post["post_type"] = AI1EC_POST_TYPE;
163
- unset( $event->post["ID"] );
164
-
165
- // Transfer post categories => event categories, post tags => event tags
166
- $terms = wp_get_post_terms( $post->ID, array( 'category', 'post_tag' ) );
167
- $event->categories = array();
168
- $event->tags = array();
169
- foreach( $terms as $term )
170
- {
171
- switch( $term->taxonomy )
172
- {
173
- case 'category':
174
- // Ignore special "Events" category by The Events Calendar
175
- if( $term->name == 'Events' )
176
- break;
177
- // Need to find out the category ID, if it exists.
178
- $event_term = get_term_by( 'name', $term->name, 'events_categories' );
179
- // If no category exists, create it.
180
- if( $event_term === false )
181
- $event_term = (object) wp_insert_term(
182
- $term->name,
183
- 'events_categories',
184
- array(
185
- 'description' => $term->description,
186
- 'slug' => $term->slug
187
- )
188
- );
189
- $event->categories[] = $event_term->term_id;
190
- break;
191
-
192
- case 'post_tag':
193
- // For some reason tag-like taxonomies are treated differently; term
194
- // IDs cannot be used; instead the actual term name must be appended
195
- $event->tags[] = $term->name;
196
- break;
197
- }
198
- }
199
-
200
- $post_id = $event->save();
201
- $ai1ec_events_helper->cache_event( $event, $post_id );
202
-
203
- $imported_events++;
204
- }
205
-
206
- $ai1ec_view_helper->display_admin( "import.php", array( 'imported_events' => $imported_events ) );
207
- }
208
- }
209
- // END class
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/controller/class-ai1ec-settings-controller.php DELETED
@@ -1,419 +0,0 @@
1
- <?php
2
- //
3
- // class-ai1ec-settings-controller.php
4
- // all-in-one-event-calendar
5
- //
6
- // Created by The Seed Studio on 2011-07-13.
7
- //
8
-
9
- /**
10
- * Ai1ec_Settings_Controller class
11
- *
12
- * @package Controllers
13
- * @author time.ly
14
- **/
15
- class Ai1ec_Settings_Controller {
16
- /**
17
- * _instance class variable
18
- *
19
- * Class instance
20
- *
21
- * @var null | object
22
- **/
23
- private static $_instance = NULL;
24
-
25
- /**
26
- * Constructor
27
- *
28
- * Default constructor
29
- **/
30
- private function __construct() { }
31
-
32
- /**
33
- * get_instance function
34
- *
35
- * Return singleton instance
36
- *
37
- * @return object
38
- **/
39
- static function get_instance() {
40
- if( self::$_instance === NULL ) {
41
- self::$_instance = new self();
42
- }
43
-
44
- return self::$_instance;
45
- }
46
-
47
- /**
48
- * Display this plugin's settings page in the admin.
49
- *
50
- * @return void
51
- */
52
- function view_settings() {
53
- global $ai1ec_view_helper,
54
- $ai1ec_settings;
55
-
56
- if( isset( $_REQUEST['ai1ec_save_settings'] ) ) {
57
- $this->save( 'settings' );
58
- }
59
- $args = array(
60
- 'title' => __( 'All-in-One Event Calendar: Settings', AI1EC_PLUGIN_NAME ),
61
- 'settings_page' => $ai1ec_settings->settings_page,
62
- );
63
- $ai1ec_view_helper->display_admin( 'settings.php', $args );
64
- }
65
-
66
- /**
67
- * Display this plugin's feeds page in the admin.
68
- *
69
- * @return void
70
- */
71
- function view_feeds() {
72
- global $ai1ec_view_helper,
73
- $ai1ec_settings;
74
-
75
- if( isset( $_REQUEST['ai1ec_save_settings'] ) ) {
76
- $this->save( 'feeds' );
77
- }
78
- $args = array(
79
- 'title' => __( 'All-in-One Event Calendar: Calendar Feeds', AI1EC_PLUGIN_NAME ),
80
- 'settings_page' => $ai1ec_settings->feeds_page,
81
- );
82
- $ai1ec_view_helper->display_admin( 'settings.php', $args );
83
- }
84
-
85
- /**
86
- * Save the submitted settings form.
87
- *
88
- * @param string $settings_page Which settings page is being saved.
89
- * @return void
90
- */
91
- function save( $settings_page ) {
92
- global $ai1ec_settings,
93
- $ai1ec_view_helper;
94
-
95
- $ai1ec_settings->update( $settings_page, $_REQUEST );
96
- do_action( 'ai1ec_save_settings', $settings_page, $_REQUEST );
97
- $ai1ec_settings->save();
98
-
99
- $args = array(
100
- 'msg' => __( 'Settings Updated.', AI1EC_PLUGIN_NAME )
101
- );
102
-
103
- $ai1ec_view_helper->display_admin( "save_successful.php", $args );
104
- }
105
-
106
- /**
107
- * add_ics_feed function
108
- *
109
- * Adds submitted ics feed to the database
110
- *
111
- * @return string JSON output
112
- **/
113
- function add_ics_feed() {
114
- global $ai1ec_view_helper,
115
- $wpdb;
116
-
117
- $table_name = $wpdb->prefix . 'ai1ec_event_feeds';
118
-
119
- $wpdb->insert(
120
- $table_name,
121
- array(
122
- 'feed_url' => $_REQUEST["feed_url"], // convert webcal to http
123
- 'feed_category' => $_REQUEST["feed_category"],
124
- 'feed_tags' => $_REQUEST["feed_tags"],
125
- ),
126
- array(
127
- '%s',
128
- '%d',
129
- '%s'
130
- )
131
- );
132
- $feed_id = $wpdb->insert_id;
133
- ob_start();
134
- $feed_category = get_term( $_REQUEST["feed_category"], 'events_categories' );
135
- $args = array(
136
- 'feed_url' => $_REQUEST["feed_url"],
137
- 'event_category' => $feed_category->name,
138
- 'tags' => $_REQUEST["feed_tags"],
139
- 'feed_id' => $feed_id,
140
- 'events' => 0
141
- );
142
- // display added feed row
143
- $ai1ec_view_helper->display_admin( 'feed_row.php', $args );
144
-
145
- $output = ob_get_contents();
146
- ob_end_clean();
147
-
148
- $output = array(
149
- "error" => 0,
150
- "message" => stripslashes( $output )
151
- );
152
-
153
- echo json_encode( $output );
154
- exit();
155
- }
156
-
157
- /**
158
- * flush_ics_feed function
159
- *
160
- * Deletes all event posts that are from that selected feed
161
- *
162
- * @param bool $ajax When set to TRUE, the data is outputted using json_response
163
- * @param bool|string $feed_url Feed URL
164
- *
165
- * @return void
166
- **/
167
- function flush_ics_feed( $ajax = TRUE, $feed_url = FALSE ) {
168
- global $wpdb,
169
- $ai1ec_view_helper;
170
- $ics_id = isset( $_REQUEST['ics_id'] ) ? (int) $_REQUEST['ics_id'] : 0;
171
- $table_name = $wpdb->prefix . 'ai1ec_event_feeds';
172
-
173
- if( $feed_url === FALSE ) {
174
- $feed_url = $wpdb->get_var( $wpdb->prepare( "SELECT feed_url FROM $table_name WHERE feed_id = %d", $ics_id ) );
175
- }
176
-
177
- if( $feed_url ) {
178
- $table_name = $wpdb->prefix . 'ai1ec_events';
179
- $sql = "SELECT post_id FROM {$table_name} WHERE ical_feed_url = '%s'";
180
- $events = $wpdb->get_results( $wpdb->prepare( $sql, $feed_url ) );
181
- $total = count( $events );
182
-
183
- foreach( $events as $event ) {
184
- // delete post (this will trigger deletion of cached events, and remove the event from events table)
185
- wp_delete_post( $event->post_id, 'true' );
186
- }
187
-
188
- $output = array(
189
- 'error' => FALSE,
190
- 'message' => sprintf( __( 'Flushed %d events', AI1EC_PLUGIN_NAME ), $total ),
191
- 'count' => $total,
192
- );
193
- } else {
194
- $output = array(
195
- 'error' => TRUE,
196
- 'message' => __( 'Invalid ICS feed ID', AI1EC_PLUGIN_NAME )
197
- );
198
- }
199
-
200
- if( $ajax ) {
201
- $ai1ec_view_helper->json_response( $output );
202
- }
203
- }
204
-
205
- /**
206
- * update_ics_feed function
207
- *
208
- * Imports the selected iCalendar feed
209
- *
210
- * @return void
211
- **/
212
- function update_ics_feed() {
213
- global $wpdb,
214
- $ai1ec_view_helper,
215
- $ai1ec_importer_helper;
216
-
217
- $feed_id = (int) $_REQUEST['ics_id'];
218
- $table_name = $wpdb->prefix . 'ai1ec_event_feeds';
219
- $feed = $wpdb->get_row( $wpdb->prepare( "SELECT * FROM $table_name WHERE feed_id = %d", $feed_id ) );
220
-
221
- if( $feed ) {
222
- // flush the feed
223
- $this->flush_ics_feed( false, $feed->feed_url );
224
- // reimport the feed
225
- $count = @$ai1ec_importer_helper->parse_ics_feed( $feed );
226
- if ( $count == 0 ) {
227
- // If results are 0, it could be result of a bad URL or other error, send a specific message
228
- $output = array(
229
- 'error' => true,
230
- 'message' => __( 'No events were found', AI1EC_PLUGIN_NAME )
231
- );
232
- } else {
233
- $output = array(
234
- 'error' => false,
235
- 'message' => sprintf( __( 'Imported %d events', AI1EC_PLUGIN_NAME ), $count ),
236
- 'flush_label' => sprintf( _n( 'Flush 1 event', 'Flush %s events', $count, AI1EC_PLUGIN_NAME ), $count ),
237
- 'count' => $count,
238
- );
239
- }
240
- } else {
241
- $output = array(
242
- 'error' => true,
243
- 'message' => __( 'Invalid ICS feed ID', AI1EC_PLUGIN_NAME )
244
- );
245
- }
246
-
247
- $ai1ec_view_helper->json_response( $output );
248
- }
249
-
250
- /**
251
- * delete_ics_feed function
252
- *
253
- * Deletes submitted ics feed id from the database
254
- *
255
- * @return String JSON output
256
- **/
257
- function delete_ics_feed() {
258
- global $wpdb,
259
- $ai1ec_view_helper;
260
-
261
- $ics_id = (int) $_REQUEST['ics_id'];
262
- $table_name = $wpdb->prefix . 'ai1ec_event_feeds';
263
- $wpdb->query( $wpdb->prepare( "DELETE FROM {$table_name} WHERE feed_id = %d", $ics_id ) );
264
- $output = array(
265
- 'error' => false,
266
- 'message' => 'Request successful.'
267
- );
268
-
269
- $ai1ec_view_helper->json_response( $output );
270
- }
271
-
272
- /**
273
- * Disable data notification (AJAX callback).
274
- *
275
- * @return void
276
- **/
277
- function disable_notification() {
278
- global $ai1ec_view_helper, $ai1ec_settings;
279
-
280
- $ai1ec_settings->update_notification( false );
281
- $output = array(
282
- 'error' => false,
283
- 'message' => 'Request successful.'
284
- );
285
-
286
- $ai1ec_view_helper->json_response( $output );
287
- }
288
-
289
- /**
290
- * Disable standard notification (AJAX callback).
291
- *
292
- * @return void
293
- **/
294
- function disable_standard_notice() {
295
- global $ai1ec_view_helper, $ai1ec_settings;
296
-
297
- $ai1ec_settings->update_standard_notification( false );
298
- $output = array(
299
- 'error' => false,
300
- 'message' => 'Request successful.'
301
- );
302
-
303
- $ai1ec_view_helper->json_response( $output );
304
- }
305
- /**
306
- * Disable intro video (AJAX callback).
307
- *
308
- * @return void
309
- **/
310
- function disable_intro_video() {
311
- global $ai1ec_view_helper, $ai1ec_settings;
312
-
313
- $ai1ec_settings->update_intro_video( false );
314
- $output = array(
315
- 'error' => false,
316
- 'message' => 'Request successful.'
317
- );
318
-
319
- $ai1ec_view_helper->json_response( $output );
320
- }
321
-
322
- /**
323
- * Add meta boxes to settings screen.
324
- *
325
- * @return void
326
- */
327
- function add_settings_meta_boxes() {
328
- global $ai1ec_settings_helper,
329
- $ai1ec_settings;
330
-
331
- // Add the 'General Settings' meta box.
332
- add_meta_box(
333
- 'ai1ec-general-settings',
334
- _x( 'General Settings', 'meta box', AI1EC_PLUGIN_NAME ),
335
- array( &$ai1ec_settings_helper, 'general_settings_meta_box' ),
336
- $ai1ec_settings->settings_page,
337
- 'left-side',
338
- 'default'
339
- );
340
- // Add the 'Advanced Settings' meta box.
341
- add_meta_box(
342
- 'ai1ec-advanced-settings',
343
- _x( 'Advanced Settings', 'meta box', AI1EC_PLUGIN_NAME ),
344
- array( &$ai1ec_settings_helper, 'advanced_settings_meta_box' ),
345
- $ai1ec_settings->settings_page,
346
- 'left-side',
347
- 'default'
348
- );
349
- // Add the 'Timely Support' meta box.
350
- add_meta_box(
351
- 'ai1ec-support',
352
- _x( 'Timely Support', 'meta box', AI1EC_PLUGIN_NAME ),
353
- array( &$ai1ec_settings_helper, 'support_meta_box' ),
354
- $ai1ec_settings->settings_page,
355
- 'right-side',
356
- 'default'
357
- );
358
- }
359
-
360
- /**
361
- * Add meta boxes to feeds screen.
362
- *
363
- * @return void
364
- */
365
- function add_feeds_meta_boxes() {
366
- global $ai1ec_settings_helper,
367
- $ai1ec_settings;
368
-
369
- // Add the 'ICS Import Settings' meta box.
370
- add_meta_box(
371
- 'ai1ec-feeds',
372
- _x( 'Feed Subscriptions', 'meta box', AI1EC_PLUGIN_NAME ),
373
- array( &$ai1ec_settings_helper, 'feeds_meta_box' ),
374
- $ai1ec_settings->feeds_page,
375
- 'left-side',
376
- 'default'
377
- );
378
- // Add the 'Timely Support' meta box.
379
- add_meta_box(
380
- 'ai1ec-support',
381
- _x( 'Timely Support', 'meta box', AI1EC_PLUGIN_NAME ),
382
- array( &$ai1ec_settings_helper, 'support_meta_box' ),
383
- $ai1ec_settings->feeds_page,
384
- 'right-side',
385
- 'default'
386
- );
387
- }
388
-
389
- /**
390
- * plugin_action_links function
391
- *
392
- * Adds a link to Settings page in plugin list page.
393
- *
394
- * @return array
395
- **/
396
- function plugin_action_links( $links ) {
397
- $settings = sprintf( __( '<a href="%s">Settings</a>', AI1EC_PLUGIN_NAME ), admin_url( AI1EC_SETTINGS_BASE_URL ) );
398
- array_unshift( $links, $settings );
399
- return $links;
400
- }
401
-
402
- /**
403
- * plugin_row_meta function
404
- *
405
- *
406
- *
407
- * @return void
408
- **/
409
- function plugin_row_meta( $links, $file ) {
410
- if( $file == AI1EC_PLUGIN_BASENAME ) {
411
- $links[] = sprintf( __( '<a href="%s" target="_blank">Donate</a>', AI1EC_PLUGIN_NAME ), 'https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=9JJMUW48W2ED8' );
412
- $links[] = sprintf( __( '<a href="%s" target="_blank">Get Support</a>', AI1EC_PLUGIN_NAME ), 'http://help.time.ly/' );
413
- }
414
-
415
- return $links;
416
- }
417
-
418
- }
419
- // END class
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/controller/class-ai1ec-themes-controller.php DELETED
@@ -1,448 +0,0 @@
1
- <?php
2
- //
3
- // class-ai1ec-themes-controller.php
4
- // all-in-one-event-calendar
5
- //
6
- // Created by The Seed Studio on 2012-04-05.
7
- //
8
-
9
- /**
10
- * Ai1ec_Themes_Controller class
11
- *
12
- * @package Controllers
13
- * @author time.ly
14
- **/
15
- class Ai1ec_Themes_Controller {
16
- /**
17
- * _instance class variable
18
- *
19
- * Class instance
20
- *
21
- * @var null | object
22
- **/
23
- private static $_instance = NULL;
24
-
25
- /**
26
- * get_instance function
27
- *
28
- * Return singleton instance
29
- *
30
- * @return object
31
- **/
32
- static function get_instance() {
33
- if( self::$_instance === NULL ) {
34
- self::$_instance = new self();
35
- }
36
-
37
- return self::$_instance;
38
- }
39
-
40
- /**
41
- * Constructor
42
- *
43
- * Default constructor
44
- **/
45
- private function __construct() { }
46
-
47
- /**
48
- * Returns the root path of ai1ec-themes.
49
- *
50
- * @return string
51
- **/
52
- public function template_root_path( $template ) {
53
- return AI1EC_THEMES_ROOT . '/' . $template;
54
- }
55
-
56
- /**
57
- * Returns the root URL of ai1ec-themes.
58
- *
59
- * @return string
60
- **/
61
- public function template_root_url( $template ) {
62
- return AI1EC_THEMES_URL . '/' . $template;
63
- }
64
-
65
- /**
66
- * Returns the path to the active calendar theme.
67
- *
68
- * @return string
69
- */
70
- public function active_template_path() {
71
- return apply_filters(
72
- 'ai1ec_template_root_path',
73
- apply_filters(
74
- 'ai1ec_template',
75
- get_option( 'ai1ec_template', AI1EC_DEFAULT_THEME_NAME )
76
- )
77
- );
78
- }
79
-
80
- /**
81
- * Returns the URL to the active calendar theme.
82
- *
83
- * @return string
84
- */
85
- public function active_template_url() {
86
- return apply_filters(
87
- 'ai1ec_template_root_url',
88
- apply_filters(
89
- 'ai1ec_template',
90
- get_option( 'ai1ec_template', AI1EC_DEFAULT_THEME_NAME )
91
- )
92
- );
93
- }
94
-
95
- /**
96
- * Check if core calendar theme folder is present in wp-content/ directory
97
- *
98
- * @return bool Existence
99
- */
100
- public function are_themes_available() {
101
- if (
102
- true === @is_dir( AI1EC_THEMES_ROOT ) &&
103
- true === @is_dir( AI1EC_DEFAULT_THEME_PATH )
104
- ) {
105
- return true;
106
- }
107
- return false;
108
- }
109
-
110
- /**
111
- * Register Install Calendar Themes page in wp-admin.
112
- */
113
- function register_theme_installer() {
114
- // Add menu item for theme install page, but remove it using
115
- // `remove_submenu_page()` to generate a "ghost" page
116
- add_submenu_page(
117
- 'themes.php',
118
- __( 'Install Calendar Themes', AI1EC_PLUGIN_NAME ),
119
- __( 'Install Calendar Themes', AI1EC_PLUGIN_NAME ),
120
- 'install_themes',
121
- AI1EC_PLUGIN_NAME . '-install-themes',
122
- array( $this, 'install_themes' )
123
- );
124
- remove_submenu_page(
125
- 'themes.php',
126
- AI1EC_PLUGIN_NAME . '-install-themes'
127
- );
128
- }
129
-
130
- /**
131
- * Returns whether core theme files need to be updated (only if core theme
132
- * files exist in the first place, checked using above function).
133
- *
134
- * @return bool
135
- */
136
- public function are_themes_outdated() {
137
- if ( ! $this->are_themes_available() ) {
138
- return FALSE;
139
- }
140
- if ( get_option( 'ai1ec_themes_version', 1 ) >= AI1EC_THEMES_VERSION ) {
141
- return FALSE;
142
- }
143
- return TRUE;
144
- }
145
-
146
- /**
147
- * Returns a notice informing admin to update the core theme files if core
148
- * theme files are determined to be out of date. Else returns '' (evaluates
149
- * to false). If $echo is true, outputs the notice. Else outputs nothing.
150
- *
151
- * @see Ai1ec_Themes_Controller::are_themes_outdated()
152
- *
153
- * @param boolean $echo Whether to output the message or just return it.
154
- * @return boolean Whether core theme files are out of date.
155
- */
156
- public function frontend_outdated_themes_notice( $echo = true ) {
157
- $output = '';
158
- if ( $this->are_themes_outdated() ) {
159
- $output .= '<p><em>';
160
- $output .= __( 'The All-in-One Event Calendar core theme files are out of date and the calendar has been temporarily disabled.', AI1EC_PLUGIN_NAME );
161
- $output .= ' ';
162
- if ( current_user_can( 'install_themes' ) ) {
163
- $output .= sprintf(
164
- __( 'To enable the calendar, please <a href="%s">log into the WordPress dashboard</a> and follow the instructions.', AI1EC_PLUGIN_NAME ),
165
- esc_attr( admin_url() )
166
- );
167
- }
168
- else {
169
- $output .= __( 'To enable the calendar, an administrator must log into the WordPress dashboard and follow the instructions.', AI1EC_PLUGIN_NAME );
170
- }
171
- $output .= '</em></p>';
172
- }
173
-
174
- if ( $echo ) {
175
- echo $output;
176
- }
177
-
178
- return $output;
179
- }
180
-
181
- /**
182
- * copy_directory function
183
- *
184
- * @return void
185
- **/
186
- private function copy_directory( $source, $destination ) {
187
- if( is_dir( $source ) ) {
188
- @mkdir( $destination );
189
- $directory = dir( $source );
190
- while( FALSE !== ( $readdirectory = $directory->read() ) ) {
191
- if( $readdirectory == '.' || $readdirectory == '..' ) {
192
- continue;
193
- }
194
- $PathDir = $source . '/' . $readdirectory;
195
- if( is_dir( $PathDir ) ) {
196
- $this->copy_directory( $PathDir, $destination . '/' . $readdirectory );
197
- continue;
198
- }
199
- copy( $PathDir, $destination . '/' . $readdirectory );
200
- }
201
-
202
- $directory->close();
203
- } else {
204
- copy( $source, $destination );
205
- }
206
- }
207
-
208
-
209
- /**
210
- * install_themes function
211
- *
212
- * @return void
213
- **/
214
- function install_themes() {
215
- ?>
216
- <div class="wrap">
217
- <?php
218
- screen_icon();
219
- ?>
220
- <h2><?php _e( 'Install Calendar Themes', AI1EC_PLUGIN_NAME ) ?></h2>
221
- <?php
222
- // WP_Filesystem figures it out by itself, but the filesystem method may be overriden here
223
- $method = '';
224
- $url = wp_nonce_url( AI1EC_INSTALL_THEMES_BASE_URL, AI1EC_PLUGIN_NAME . '-theme-installer' );
225
- if( false === ( $creds = request_filesystem_credentials( $url, $method, false, false ) ) ) {
226
- // if we get here, then we don't have credentials yet,
227
- // but have just produced a form for the user to fill in,
228
- // so stop processing for now
229
- return false; // stop the normal page form from displaying
230
- }
231
-
232
- // now we have some credentials, try to get the wp_filesystem running
233
- if( ! WP_Filesystem( $creds ) ) {
234
- // our credentials were no good, ask the user for them again
235
- request_filesystem_credentials( $url, $method, true, false );
236
- return false;
237
- }
238
- global $wp_filesystem;
239
- $themes_root = $wp_filesystem->wp_content_dir() . AI1EC_THEMES_FOLDER;
240
- $result = $wp_filesystem->mkdir( $themes_root );
241
- if( $result === false ) {
242
- ?>
243
- <p><?php _e( sprintf( 'Unable to create %s folder', AI1EC_THEMES_ROOT ), AI1EC_PLUGIN_NAME ) ?></p>
244
- <p><?php _e( sprintf( 'Try to create %s folder manually and then restart the process',
245
- AI1EC_THEMES_ROOT ), AI1EC_PLUGIN_NAME ) ?></p>
246
- </div>
247
- <?php
248
- return false;
249
- }
250
- $plugin_themes_dir = $wp_filesystem->wp_plugins_dir() . AI1EC_PLUGIN_NAME . DIRECTORY_SEPARATOR . AI1EC_THEMES_FOLDER;
251
- $result = copy_dir( $plugin_themes_dir, $themes_root );
252
- if( is_wp_error( $result ) ) {
253
- ?>
254
- <div id="message" class="error">
255
- <h3>
256
- <?php _e( 'Errors occurred while we tried to install your core Calendar Themes', AI1EC_PLUGIN_NAME ) ?>.
257
- </h3>
258
- <p>
259
- <strong>
260
- <?php _e(
261
- sprintf( 'Please fix the error listed below or your calendar may malfunction: %s', $result->get_error_message() ),
262
- AI1EC_PLUGIN_NAME
263
- ) ?>
264
- </strong>
265
- </p>
266
- </div>
267
- <?php
268
- } else {
269
- update_option( 'ai1ec_themes_version', AI1EC_THEMES_VERSION );
270
- ?>
271
- <div id="message" class="updated"><h3><?php _e( 'Calendar themes were installed successfully', AI1EC_PLUGIN_NAME ) ?>.</h3></div>
272
- <p>
273
- <a class="button" href="<?php echo AI1EC_SETTINGS_BASE_URL; ?>">
274
- <?php _e( 'All-in-One Event Calendar Settings »', AI1EC_PLUGIN_NAME ); ?>
275
- </a>
276
- </p>
277
- <?php
278
- }
279
- ?>
280
- </div>
281
- <?php
282
- }
283
-
284
- /**
285
- * Register Update Calendar Themes page in wp-admin.
286
- */
287
- function register_theme_updater() {
288
- // Add menu item for theme update page, but without the actual menu item
289
- // by removing it again right away.
290
- add_submenu_page(
291
- 'edit.php?post_type=' . AI1EC_POST_TYPE,
292
- __( 'Update Core Calendar Files', AI1EC_PLUGIN_NAME ),
293
- __( 'Update Core Calendar Files', AI1EC_PLUGIN_NAME ),
294
- 'install_themes',
295
- AI1EC_PLUGIN_NAME . '-update-themes',
296
- array( &$this, 'update_core_themes' )
297
- );
298
- remove_submenu_page(
299
- 'edit.php?post_type=' . AI1EC_POST_TYPE,
300
- AI1EC_PLUGIN_NAME . '-update-themes'
301
- );
302
- }
303
-
304
- /**
305
- * Called by the Update Calendar Themes page. Updates core themes with any
306
- * files that have changed since the last time a theme update has run.
307
- */
308
- function update_core_themes() {
309
- global $ai1ec_view_helper;
310
-
311
- $src_dir = trailingslashit( AI1EC_PATH . DIRECTORY_SEPARATOR . AI1EC_THEMES_FOLDER );
312
- $dest_dir = trailingslashit( AI1EC_THEMES_ROOT );
313
-
314
- // List of core themes.
315
- $folders = array(
316
- 'vortex',
317
- );
318
-
319
- // Array to hold error notifications to the user while updating the themes.
320
- $delete_errors = array();
321
- $copy_errors = array();
322
-
323
- // WP_Filesystem figures it out by itself, but the filesystem method may be
324
- // overriden here.
325
- $method = '';
326
- $url = wp_nonce_url(
327
- AI1EC_UPDATE_THEMES_BASE_URL,
328
- AI1EC_PLUGIN_NAME . '-theme-updater'
329
- );
330
- $creds = request_filesystem_credentials( $url, $method, false, false );
331
- if ( false === $creds ) {
332
- // If we get here, then we don't have credentials yet,
333
- // but have just produced a form for the user to fill in,
334
- // so stop processing for now.
335
- return false; // Stop the normal page form from displaying.
336
- }
337
-
338
- // Now we have some credentials, try to get the wp_filesystem running.
339
- if ( ! WP_Filesystem( $creds ) ) {
340
- // Our credentials were no good, ask the user for them again.
341
- request_filesystem_credentials( $url, $method, true, false );
342
- return false;
343
- }
344
-
345
- global $wp_filesystem;
346
-
347
- // 1. Remove old folders.
348
- foreach ( $folders as $folder ) {
349
- $folder = $dest_dir . $folder;
350
- // Check if folder exists.
351
- if ( $wp_filesystem->is_dir( $folder ) ) {
352
- // Try to delete it recusively.
353
- if ( false === $wp_filesystem->delete( $folder, true ) ) {
354
- // If delete failed, chmod folder recursively to 0644 and try again.
355
- $wp_filesystem->chmod( $folder, 0644, $recursive );
356
- if ( false === $wp_filesystem->delete( $folder, true ) ) {
357
- // We were not able to remove the folder; notify the user.
358
- $delete_errors[] = $folder;
359
- }
360
- }
361
- }
362
- }
363
-
364
- // 2. Copy fresh versions of folders.
365
- foreach ( $folders as $folder ) {
366
- $src_folder = $src_dir . $folder;
367
- $dest_folder = $dest_dir . $folder;
368
- // Try to copy the folder.
369
- $result = copy_dir( $src_dir, $dest_dir );
370
- if ( is_wp_error( $result ) ) {
371
- // We were not able to copy the folder; notify the user.
372
- $copy_errors[] = $src_folder;
373
- }
374
- }
375
-
376
- $errors = array();
377
-
378
- if ( $delete_errors ) {
379
- $error = '<div class="error"><p><strong>';
380
- $error .= __( 'There was an error while removing outdated core themes from your themes folder.', AI1EC_PLUGIN_NAME );
381
- $error .= '</strong> ';
382
- $error .= __( 'Please FTP to your web server and manually delete:', AI1EC_PLUGIN_NAME );
383
- $error .= '</p><blockquote><div><code>';
384
- $error .= implode( '</code></div><div><code>', $delete_errors );
385
- $error .= '</code></div></blockquote></div>';
386
- $errors[] = $error;
387
- }
388
-
389
- if ( $copy_errors ) {
390
- $error = '<div class="error"><p><strong>';
391
- $error .= __( 'There was an error while copying core themes from the plugin into the themes folder.', AI1EC_PLUGIN_NAME );
392
- $error .= '</strong> ';
393
- $error .= __( 'Please FTP to your web server and manually copy the folders:', AI1EC_PLUGIN_NAME );
394
- $error .= '</p><blockquote><div><code>';
395
- $error .= implode( '</code></div><div><code>', $copy_errors );
396
- $error .= '</code></div></blockquote>';
397
- $error .= '<p>' . __( 'to', AI1EC_PLUGIN_NAME ) . ' <code>' . $dest_dir .
398
- '</code></p></div>';
399
- $errors[] = $error;
400
- }
401
-
402
- // Unsuccessful core theme file update.
403
- if ( $errors ) {
404
- array_unshift(
405
- $errors,
406
- __( '<div id="message" class="error"><h3>Errors occurred while we tried to update your core Calendar Themes</h3><p><strong>Please follow any instructions listed below or your calendar may malfunction:</strong></p></div>', AI1EC_PLUGIN_NAME )
407
- );
408
- }
409
- // Successful core theme file update.
410
- else {
411
- // Update theme version
412
- update_option( 'ai1ec_themes_version', AI1EC_THEMES_VERSION );
413
-
414
- $msg = '<div id="message" class="updated"><h3>';
415
- $msg .= __( 'Your core Calendar Themes were updated successfully', AI1EC_PLUGIN_NAME );
416
- $msg .= '</h3><p>';
417
- $msg .= __( 'Be sure to <strong>reload your browser</strong> when viewing your site to make sure the most current scripts are used.', AI1EC_PLUGIN_NAME );
418
- $msg .= '</p></div>';
419
- }
420
-
421
- $args = array(
422
- 'msg' => $msg,
423
- 'errors' => $errors,
424
- );
425
-
426
- $ai1ec_view_helper->display_admin( 'themes-updated.php', $args );
427
- }
428
-
429
- /**
430
- * Called immediately after WP theme's functions.php is loaded. Load our own
431
- * theme's functions.php at this time, and the default theme's functions.php.
432
- */
433
- function setup_theme() {
434
- $functions_files = array(
435
- $this->active_template_path() . '/functions.php',
436
- AI1EC_DEFAULT_THEME_PATH . '/functions.php',
437
- );
438
-
439
- $functions_files = array_unique( $functions_files );
440
-
441
- foreach( $functions_files as $file ) {
442
- if ( file_exists( $file ) ) {
443
- include( $file );
444
- }
445
- }
446
- }
447
- }
448
- // END class
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/controller/exception/engine-not-set.php ADDED
@@ -0,0 +1,13 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * The exception thrown when an engine is not set..
5
+ *
6
+ * @author Time.ly Network Inc.
7
+ * @since 2.0
8
+ *
9
+ * @package AI1EC
10
+ * @subpackage AI1EC.Controller.Exception
11
+ */
12
+ class Ai1ec_Engine_Not_Set_Exception extends Ai1ec_Exception {
13
+ }
app/controller/exception/file-not-found.php ADDED
@@ -0,0 +1,13 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * The exception thrown when an engine is not set..
5
+ *
6
+ * @author Time.ly Network Inc.
7
+ * @since 2.0
8
+ *
9
+ * @package AI1EC
10
+ * @subpackage AI1EC.Controller.Exception
11
+ */
12
+ class Ai1ec_File_Not_Found_Exception extends Ai1ec_Exception {
13
+ }
app/controller/export.php ADDED
@@ -0,0 +1,193 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Ai1ec_Export_Controller extends Ai1ec_Base {
4
+
5
+ /**
6
+ * export_location function
7
+ *
8
+ * @param array $data
9
+ * @param bool $update
10
+ *
11
+ * @return void
12
+ **/
13
+ public function export_location( $data, $update = false ) {
14
+ // if there is no data to send, return
15
+ if (
16
+ empty( $data['venue'] ) &&
17
+ empty( $data['country'] ) &&
18
+ empty( $data['address'] ) &&
19
+ empty( $data['city'] ) &&
20
+ empty( $data['province'] ) &&
21
+ empty( $data['postal_code'] ) &&
22
+ empty( $data['latitude'] ) &&
23
+ empty( $data['longitude'] )
24
+ ) {
25
+ return;
26
+ }
27
+
28
+ // For this remote call we need to remove cUrl, because the minimum timeout
29
+ // of cUrl is 1 second. This causes Facebook import to fail when importing
30
+ // many events (even from just a few friends). A timeout greater than 0.05s
31
+ // will be a great hindrance to performance.
32
+ add_filter( 'use_curl_transport', array( $this, 'remove_curl' ) );
33
+
34
+ // Send data using post to locations API.
35
+ wp_remote_post( AI1EC_LOCATIONS_API,
36
+ array(
37
+ 'body' => array(
38
+ 'venue' => $data['venue'],
39
+ 'country' => $data['country'],
40
+ 'address' => $data['address'],
41
+ 'city' => $data['city'],
42
+ 'province' => $data['province'],
43
+ 'postal_code' => $data['postal_code'],
44
+ 'latitude' => $data['latitude'],
45
+ 'longitude' => $data['longitude'],
46
+ 'update' => $update,
47
+ ),
48
+ 'timeout' => 0.01,
49
+ 'blocking' => false,
50
+ )
51
+ );
52
+
53
+ // Revert cUrl setting to what it was.
54
+ remove_filter( 'use_curl_transport', array( $this, 'remove_curl' ) );
55
+ }
56
+
57
+ /**
58
+ * Simple function that returns false, intended for the use_curl_transport
59
+ * filter to disable the use of cUrl.
60
+ *
61
+ * @return boolean
62
+ */
63
+ public function remove_curl() {
64
+ return false;
65
+ }
66
+
67
+ /**
68
+ * Statistics collection cron.
69
+ *
70
+ * @return void
71
+ */
72
+ public function n_cron() {
73
+ $xguard = $this->_registry->get( 'compatibility.xguard' );
74
+ $guard_name = 'n_cron';
75
+
76
+ // Acquire Cron
77
+ if ( ! $xguard->acquire( $guard_name ) ) {
78
+ return null;
79
+ }
80
+ $dbi = $this->_registry->get( 'dbi.dbi' );
81
+ $ai1ec_settings = $this->_registry->get( 'model.settings' );
82
+
83
+ $query = 'SELECT COUNT( ID ) as num_events
84
+ FROM ' . $dbi->get_table_name( 'posts' ) . '
85
+ WHERE post_type = \'' . AI1EC_POST_TYPE . '\'
86
+ AND post_status = \'publish\'';
87
+ $n_events = $dbi->get_var( $query );
88
+
89
+ $query = 'SELECT COUNT( ID ) FROM ' . $dbi->get_table_name( 'users' );
90
+ $n_users = $dbi->get_var( $query );
91
+
92
+ $categories = $tags = array();
93
+ $term_list = get_terms(
94
+ 'events_categories',
95
+ array( 'hide_empty' => false )
96
+ );
97
+ foreach ( $term_list as $term ) {
98
+ if ( isset( $term->name ) ) {
99
+ $categories[] = $term->name;
100
+ }
101
+ }
102
+ $term_list = get_terms(
103
+ 'events_tags',
104
+ array( 'hide_empty' => false )
105
+ );
106
+ foreach ( $term_list as $term ) {
107
+ if ( isset( $term->name ) ) {
108
+ $tags[] = $term->name;
109
+ }
110
+ }
111
+ $fs_method = 'UNKNOWN';
112
+ global $wp_filesystem;
113
+ if ( is_object( $wp_filesystem ) && isset( $wp_filesystem->method ) ) {
114
+ $fs_method = $wp_filesystem->method;
115
+ }
116
+ $options = $this->_registry->get( 'model.option' );
117
+ $data = array(
118
+ 'n_users' => $n_users,
119
+ 'n_events' => $n_events,
120
+ 'categories' => $categories,
121
+ 'tags' => $tags,
122
+ 'blog_name' => get_bloginfo( 'name' ),
123
+ 'cal_url' => get_permalink(
124
+ $ai1ec_settings->get( 'calendar_page_id' )
125
+ ),
126
+ 'ics_url' => AI1EC_EXPORT_URL,
127
+ 'php_version' => phpversion(),
128
+ 'mysql_version' => $this->_registry->get( 'dbi.dbi' )
129
+ ->db_version(),
130
+ 'wp_version' => get_bloginfo( 'version' ),
131
+ 'wp_lang' => get_bloginfo( 'language' ),
132
+ 'wp_url' => home_url(),
133
+ 'timezone' => $this->_registry->get( 'date.timezone' )
134
+ ->get_default_timezone(),
135
+ 'privacy' => $options->get( 'blog_public' ),
136
+ 'plugin_version' => AI1EC_VERSION,
137
+ 'addons' => $this->_get_addons(),
138
+ 'wp_filesystem' => $fs_method,
139
+ 'wp_debug' => WP_DEBUG,
140
+ 'ai1ec_debug' => AI1EC_DEBUG,
141
+ 'active_theme' => $options->get(
142
+ 'ai1ec_template',
143
+ AI1EC_DEFAULT_THEME_NAME
144
+ ),
145
+ );
146
+ // send request
147
+ wp_remote_post(
148
+ AI1EC_STATS_API,
149
+ array(
150
+ 'body' => $data,
151
+ )
152
+ );
153
+
154
+ // Release lock
155
+ $xguard->release( $guard_name );
156
+ }
157
+
158
+ /**
159
+ * Return a map of add-ons installed on site.
160
+ *
161
+ * Map contains following keys for each entry:
162
+ * - v - version of add-on;
163
+ * - u - plugin URI (if non-official add-on is used);
164
+ * - a - bool flag to indicate if plugin is active.
165
+ *
166
+ * @return array Map of add-ons.
167
+ */
168
+ protected function _get_addons() {
169
+ $addons = array();
170
+ if ( ! function_exists( 'get_plugins' ) ) {
171
+ require_once ABSPATH . 'wp-admin/includes/plugin.php';
172
+ }
173
+ $all_plugins = get_plugins();
174
+ foreach ( $all_plugins as $plugin => $options ) {
175
+ $addons[$plugin] = array(
176
+ 'v' => $options['Version'],
177
+ 'u' => $options['PluginURI'],
178
+ 'a' => is_plugin_active( $plugin ),
179
+ );
180
+ }
181
+ return $addons;
182
+ }
183
+
184
+ /**
185
+ * Send stats if user agrees by clicking on the optin pointer
186
+ */
187
+ public function track_optin() {
188
+ $send_stats = $_POST['tracking'] === 'true';
189
+ $settings = $this->_registry->get( 'model.settings' );
190
+ $settings->set( 'allow_statistics', $send_stats );
191
+ $settings->set( 'show_tracking_popup', false );
192
+ }
193
+ }
app/controller/extension-license.php ADDED
@@ -0,0 +1,188 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * Abstract class for extensions which are sold.
5
+ *
6
+ * @author Time.ly Network Inc.
7
+ * @since 2.0
8
+ *
9
+ * @package AI1EC
10
+ * @subpackage AI1EC.Controller
11
+ */
12
+ abstract class Ai1ec_Base_License_Controller extends Ai1ec_Base_Extension_Controller {
13
+
14
+ /**
15
+ * @var string Settings entry name for license key.
16
+ */
17
+ protected $_licence;
18
+
19
+ /**
20
+ * @var string Settings entry name for license status output.
21
+ */
22
+ protected $_licence_status;
23
+
24
+ /**
25
+ * @var string Licensing API endpoint URI.
26
+ */
27
+ protected $_store = 'http://time.ly/';
28
+
29
+ /**
30
+ * Get label to be used for license input field.
31
+ *
32
+ * @return string Localized label field.
33
+ */
34
+ abstract public function get_license_label();
35
+
36
+ /**
37
+ * @param Ai1ec_Registry_Object $registry
38
+ */
39
+ public function initialize_licence_actions() {
40
+ $this->_register_licence_actions();
41
+ $this->_register_licence_fields();
42
+ $this->_register_updating();
43
+ }
44
+
45
+ /**
46
+ * Add the extension tab if not present
47
+ *
48
+ * @param array $tabs
49
+ * @return array
50
+ */
51
+ public function add_tabs( array $tabs ) {
52
+ if ( ! isset( $tabs['extensions'] ) ) {
53
+ $tabs['extensions'] = array(
54
+ 'name' => Ai1ec_I18n::__( 'Add-ons' ),
55
+ 'items' => array(
56
+ 'licenses' => Ai1ec_I18n::__( 'Licenses' ),
57
+ ),
58
+ );
59
+ } else if ( ! isset( $tabs['extensions']['items']['license'] ) ) {
60
+ $tabs['extensions']['items']['license'] = Ai1ec_I18n::__( 'Licences' );
61
+ }
62
+ return $tabs;
63
+ }
64
+
65
+ /**
66
+ * Check the licence if it has changed and adds the status
67
+ *
68
+ * @param array $old_options
69
+ * @param array $new_options
70
+ *
71
+ */
72
+ public function check_licence( array $old_options, array $new_options ) {
73
+ $old_licence = $old_options[$this->_licence]['value'];
74
+ $new_licence = $new_options[$this->_licence]['value'];
75
+
76
+ if ( $new_licence !== $old_licence && ! empty( $new_licence ) ) {
77
+ $license = trim( $new_licence );
78
+ // data to send in our API request
79
+ $api_params = array(
80
+ 'edd_action' => 'activate_license',
81
+ 'license' => $license,
82
+ 'item_name' => urlencode( $this->get_name() ),// the name of our product in EDD,
83
+ 'url' => home_url()
84
+ );
85
+
86
+ // Call the custom API.
87
+ $response = wp_remote_get( add_query_arg( $api_params, $this->_store ) );
88
+
89
+ // make sure the response came back okay
90
+ if ( is_wp_error( $response ) ) {
91
+ return false;
92
+ }
93
+
94
+ // decode the license data
95
+ $license_data = json_decode( wp_remote_retrieve_body( $response ) );
96
+ // $license_data->license will be either "active" or "inactive"
97
+
98
+ $this->_registry->get( 'model.settings' )
99
+ ->set( $this->_licence_status, $license_data->license );
100
+
101
+ }
102
+ }
103
+
104
+ /**
105
+ * Register action for licences.
106
+ */
107
+ protected function _register_licence_actions() {
108
+ $dispatcher = $this->_registry->get( 'event.dispatcher' );
109
+ // we need the super class so we use get_class()
110
+ $class = explode( '_', get_class( $this ) );
111
+ $controller = strtolower( end( $class ) );
112
+ $dispatcher->register_filter(
113
+ 'ai1ec_add_setting_tabs',
114
+ array( 'controller.' . $controller, 'add_tabs' )
115
+ );
116
+ $dispatcher->register_action(
117
+ 'ai1ec_settings_updated',
118
+ array( 'controller.' . $controller, 'check_licence' ),
119
+ 10,
120
+ 2
121
+ );
122
+ }
123
+
124
+ /**
125
+ * Register EDD updater class
126
+ */
127
+ protected function _register_updating() {
128
+ $license_key = $this->_registry->get( 'model.settings' )
129
+ ->get( $this->_licence );
130
+ // setup the updater
131
+ $edd_updater = new EDD_SL_Plugin_Updater(
132
+ $this->_store,
133
+ $this->get_file(),
134
+ array(
135
+ 'version' => $this->get_version(), // current version number
136
+ 'license' => $license_key, // license key (used get_option above to retrieve from DB)
137
+ 'item_name' => $this->get_name(), // name of this plugin
138
+ 'author' => 'Time.ly Network Inc.', // author of this plugin
139
+ 'url' => home_url(),
140
+ )
141
+ );
142
+ }
143
+
144
+ /**
145
+ * Register fields for licence
146
+ */
147
+ protected function _register_licence_fields() {
148
+ $plugin_id = $this->get_machine_name();
149
+ $this->_licence = 'ai1ec_licence_' . $plugin_id;
150
+ $this->_licence_status = 'ai1ec_licence_status_' . $plugin_id;
151
+ $options = array(
152
+ $this->_licence => array(
153
+ 'type' => 'string',
154
+ 'version' => $this->get_version(),
155
+ 'renderer' => array(
156
+ 'class' => 'input',
157
+ 'group-class' => 'ai1ec-col-sm-7',
158
+ 'tab' => 'extensions',
159
+ 'item' => 'licenses',
160
+ 'type' => 'normal',
161
+ 'label' => $this->get_license_label(),
162
+ 'status' => $this->_licence_status,
163
+ ),
164
+ 'default' => '',
165
+ ),
166
+ $this->_licence_status => array(
167
+ 'type' => 'string',
168
+ 'version' => $this->get_version(),
169
+ 'default' => 'invalid',
170
+ ),
171
+ );
172
+ $settings = $this->_registry->get( 'model.settings' );
173
+ foreach ( $options as $key => $option ) {
174
+ $renderer = null;
175
+ if ( isset( $option['renderer'] ) ) {
176
+ $renderer = $option['renderer'];
177
+ }
178
+ $settings->register(
179
+ $key,
180
+ $option['default'],
181
+ $option['type'],
182
+ $renderer,
183
+ $option['version']
184
+ );
185
+ }
186
+ }
187
+
188
+ }
app/controller/extension.php ADDED
@@ -0,0 +1,232 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * Basic extension controller.
5
+ *
6
+ * @author Time.ly Network Inc.
7
+ * @since 2.0
8
+ *
9
+ * @package AI1EC
10
+ * @subpackage AI1EC.Controller
11
+ */
12
+ abstract class Ai1ec_Base_Extension_Controller {
13
+
14
+ /**
15
+ * @var Ai1ec_Registry_Object
16
+ */
17
+ protected $_registry;
18
+
19
+ /**
20
+ * @var array
21
+ */
22
+ protected $_settings;
23
+
24
+ /**
25
+ * @var Ai1ec_Registry_Object
26
+ */
27
+ protected static $_registry_static;
28
+
29
+ /**
30
+ * @var array
31
+ */
32
+ protected static $_settings_static;
33
+
34
+ /**
35
+ * @var array
36
+ */
37
+ protected static $_schema;
38
+
39
+ /**
40
+ * Get the long name of the extension
41
+ */
42
+ abstract public function get_name();
43
+
44
+ /**
45
+ * Get the machine name of the extension
46
+ */
47
+ abstract public function get_machine_name();
48
+
49
+ /**
50
+ * Get the version of the extension
51
+ */
52
+ abstract public function get_version();
53
+
54
+ /**
55
+ * Get the name of the main plugin file
56
+ */
57
+ abstract public function get_file();
58
+
59
+ /**
60
+ * Add extension specific settings
61
+ */
62
+ abstract protected function _get_settings();
63
+
64
+ /**
65
+ * Register action/filters/shortcodes for the extension
66
+ *
67
+ * @param Ai1ec_Event_Dispatcher $dispatcher
68
+ */
69
+ abstract protected function _register_actions(
70
+ Ai1ec_Event_Dispatcher $dispatcher
71
+ );
72
+
73
+ /**
74
+ * Removes options when uninstalling the plugin.
75
+ */
76
+ public static function on_uninstall() {
77
+ global $wpdb;
78
+ if ( ! current_user_can( 'activate_plugins' ) ) {
79
+ return;
80
+ }
81
+ $settings = self::$_registry_static->get( 'model.settings' );
82
+ foreach ( self::$_settings_static as $name => $params ) {
83
+ $settings->remove_option( $name );
84
+ }
85
+ $schema = self::$_schema;
86
+ foreach ( $schema['tables'] as $table_name ) {
87
+ // Delete table events
88
+ $wpdb->query( 'DROP TABLE IF EXISTS ' . $table_name );
89
+ }
90
+ }
91
+
92
+ /**
93
+ * Public constructor
94
+ */
95
+ public function __construct() {
96
+ global $wpdb;
97
+ self::$_schema = $this->_get_schema( $wpdb->prefix );
98
+ $settings = $this->_get_settings();
99
+ $this->_settings = $settings;
100
+ self::$_settings_static = $settings;
101
+ }
102
+
103
+ /**
104
+ * initialize the extension.
105
+ */
106
+ public function init( Ai1ec_Registry_Object $registry ) {
107
+ $this->_registry = $registry;
108
+ // static properties are needed as uninstall hook must be static
109
+ // http://wpseek.com/register_uninstall_hook/
110
+ self::$_registry_static = $registry;
111
+ register_deactivation_hook(
112
+ $this->get_file(),
113
+ array( $this, 'on_deactivation' )
114
+ );
115
+
116
+ $this->_install_schema( $registry );
117
+ $this->_register_actions( $registry->get( 'event.dispatcher' ) );
118
+ $this->_add_settings( $registry->get( 'model.settings' ) );
119
+ if ( method_exists( $this, 'initialize_licence_actions' ) ) {
120
+ $this->initialize_licence_actions();
121
+ }
122
+ }
123
+
124
+ /**
125
+ * Hides settings on deactivation.
126
+ */
127
+ public function on_deactivation() {
128
+ if ( ! current_user_can( 'activate_plugins' ) ) {
129
+ return;
130
+ }
131
+ $plugin = isset( $_REQUEST['plugin'] ) ? $_REQUEST['plugin'] : '';
132
+ check_admin_referer( "deactivate-plugin_{$plugin}" );
133
+ $settings = $this->_registry->get( 'model.settings' );
134
+ foreach ( $this->_settings as $name => $params ) {
135
+ $settings->hide_option( $name );
136
+ }
137
+ }
138
+
139
+ /**
140
+ * Show the settings
141
+ */
142
+ public function show_settings( Ai1ec_Registry_Object $registry ) {
143
+ $settings = $registry->get( 'model.settings' );
144
+ foreach ( $this->_settings as $name => $params ) {
145
+ $settings->show_option( $name, $params['renderer'] );
146
+ }
147
+ $settings->set( 'allow_statistics', true );
148
+ }
149
+
150
+ /**
151
+ * If extensions need to add tables, they will need to override the function to add a schema.
152
+ *
153
+ * @param string $prefix Database prefix to use for table names.
154
+ *
155
+ * @return array An array with two keys, schema and tables which are used
156
+ * for installing and dropping the table.
157
+ */
158
+ protected static function _get_schema( $prefix ) {
159
+ return array(
160
+ 'tables' => array(),
161
+ 'schema' => '',
162
+ );
163
+ }
164
+
165
+ /**
166
+ * Since the call the to the uninstall hook it's static, if a different behaviour
167
+ * is needed also this call must be overridden.
168
+ */
169
+ protected function _register_uninstall_hook() {
170
+ register_uninstall_hook(
171
+ $this->get_file(),
172
+ array( get_class( $this ), 'on_uninstall' )
173
+ );
174
+ }
175
+
176
+ /**
177
+ * Adds extension settings
178
+ *
179
+ * @param Ai1ec_Settings $settings
180
+ */
181
+ protected function _add_settings( Ai1ec_Settings $settings ) {
182
+ foreach ( $this->_settings as $name => $params ) {
183
+ $renderer = null;
184
+ if ( isset( $params['renderer'] ) ) {
185
+ $renderer = $params['renderer'];
186
+ }
187
+ $settings->register(
188
+ $name,
189
+ $params['value'],
190
+ $params['type'],
191
+ $renderer,
192
+ $this->get_version()
193
+ );
194
+ }
195
+ }
196
+
197
+ /**
198
+ * Check if the schema needs to be updated
199
+ *
200
+ * @param Ai1ec_Registry_Object $registry
201
+ * @throws Ai1ec_Database_Update_Exception
202
+ */
203
+ protected function _install_schema( Ai1ec_Registry_Object $registry ) {
204
+ $option = $registry->get( 'model.option' );
205
+ $schema = self::$_schema;
206
+ if (
207
+ is_admin() &&
208
+ ! empty( $schema['schema'] )
209
+ ) {
210
+ $db_version_variable = 'ai1ec_' . $this->get_machine_name() .
211
+ '_db_version';
212
+ $version = sha1( $schema['schema'] );
213
+ if (
214
+ $option->get( $db_version_variable ) !== $version
215
+ ) {
216
+ if (
217
+ $registry->get( 'database.helper' )->apply_delta(
218
+ $schema['schema']
219
+ )
220
+ ) {
221
+ $option->set( $db_version_variable, $version );
222
+ } else {
223
+ throw new Ai1ec_Database_Update_Exception(
224
+ 'Database upgrade for ' . $this->get_name() .
225
+ ' failed'
226
+ );
227
+ }
228
+ }
229
+ }
230
+ }
231
+
232
+ }
app/controller/front.php ADDED
@@ -0,0 +1,941 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * The front controller of the plugin.
5
+ *
6
+ * @author Time.ly Network Inc.
7
+ * @since 2.0
8
+ *
9
+ * @package AI1EC
10
+ * @subpackage AI1EC.Controller
11
+ */
12
+ class Ai1ec_Front_Controller {
13
+
14
+ /**
15
+ * @var Ai1ec_Registry_Object The Object registry.
16
+ */
17
+ protected $_registry;
18
+
19
+ /**
20
+ * @var bool Whether the domain has alredy been loaded or not.
21
+ */
22
+ protected $_domain_loaded = false;
23
+
24
+ /**
25
+ * @var string The pagebase used by Ai1ec_Href_Helper.
26
+ */
27
+ protected $_pagebase_for_href;
28
+
29
+ /**
30
+ * @var Ai1ec_Request_Parser Instance of the request pa
31
+ */
32
+ protected $_request;
33
+
34
+ /**
35
+ * Initialize the controller.
36
+ *
37
+ * @param Ai1ec_Loader $ai1ec_loader Instance of Ai1EC classes loader
38
+ *
39
+ * @return void
40
+ */
41
+ public function initialize( $ai1ec_loader ) {
42
+ ai1ec_start();
43
+ $this->_init( $ai1ec_loader );
44
+ $this->_compile_themes();
45
+ $this->_initialize_dispatcher();
46
+ $lessphp = $this->_registry->get( 'less.lessphp' );
47
+ $lessphp->initialize_less_variables_if_not_set();
48
+ $this->_registry->get( 'controller.shutdown' )
49
+ ->register( 'ai1ec_stop' );
50
+ add_action( 'plugins_loaded', array( $this, 'register_extensions' ), 1 );
51
+ add_action( 'init', array( $lessphp, 'invalidate_css_cache_if_requested' ) );
52
+ }
53
+
54
+ /**
55
+ * Notify extensions and pass them instance of objects registry.
56
+ *
57
+ * @return void
58
+ */
59
+ public function register_extensions() {
60
+ do_action( 'ai1ec_loaded', $this->_registry );
61
+ }
62
+
63
+ /**
64
+ * Returns the registry object
65
+ *
66
+ * @param mixed $discard not used. Always return the registry.
67
+ *
68
+ * @return Ai1ec_Registry_Object
69
+ */
70
+ public function return_registry( $discard ) {
71
+ return $this->_registry;
72
+ }
73
+
74
+ /**
75
+ * Perform actions needed when our plugin is activated.
76
+ *
77
+ * @wp_hook activate_all-in-one-event-calendar/all-in-one-event-calendar.php
78
+ *
79
+ * @return void
80
+ */
81
+ public function activation_hook() {
82
+ $this->_registry->get( 'app' )->register_post_type();
83
+ // Flush rewrite rules.
84
+ $this->_registry->get( 'rewrite' )->check_rewrites();
85
+ }
86
+
87
+ /**
88
+ * Execute commands if our plugin must handle the request.
89
+ *
90
+ * @wp_hook init
91
+ *
92
+ * @return void
93
+ */
94
+ public function route_request() {
95
+ $this->_process_request();
96
+ // get the resolver
97
+ $resolver = $this->_registry->get(
98
+ 'command.resolver',
99
+ $this->_request
100
+ );
101
+ // get the command
102
+ $command = $resolver->get_command();
103
+ // if we have a command
104
+ if ( null !== $command ) {
105
+ $command->execute();
106
+ }
107
+ }
108
+
109
+ /**
110
+ * Initializes the URL router used by our plugin.
111
+ *
112
+ * @wp_hook init
113
+ *
114
+ * @return void
115
+ */
116
+ public function initialize_router() {
117
+ $settings = $this->_registry->get( 'model.settings' );
118
+
119
+ $cal_page = $settings->get( 'calendar_page_id' );
120
+
121
+ if (
122
+ ! $cal_page ||
123
+ $cal_page < 1
124
+ ) { // Routing may not be affected in any way if no calendar page exists.
125
+ return null;
126
+ }
127
+ $router = $this->_registry->get( 'routing.router' );
128
+ $localization_helper = $this->_registry->get( 'p28n.wpml' );
129
+ $page_base = '';
130
+ $clang = '';
131
+
132
+ if ( $localization_helper->is_wpml_active() ) {
133
+ $trans = $localization_helper
134
+ ->get_wpml_translations_of_page(
135
+ $cal_page,
136
+ true
137
+ );
138
+ $clang = $localization_helper->get_language();
139
+ if ( isset( $trans[$clang] ) ) {
140
+ $cal_page = $trans[$clang];
141
+ }
142
+ }
143
+ $template_link_helper = $this->_registry->get( 'template.link.helper' );
144
+
145
+ if ( ! get_post( $cal_page ) ) {
146
+ return null;
147
+ }
148
+
149
+ $page_base = $template_link_helper->get_page_link(
150
+ $cal_page
151
+ );
152
+
153
+ $page_base = Ai1ec_Wp_Uri_Helper::get_pagebase( $page_base );
154
+ $page_link = 'index.php?page_id=' .
155
+ $cal_page;
156
+ $pagebase_for_href = Ai1ec_Wp_Uri_Helper::get_pagebase_for_links(
157
+ get_page_link( $cal_page ),
158
+ $clang
159
+ );
160
+
161
+ // save the pagebase to set up the factory later
162
+ $application = $this->_registry->get( 'bootstrap.registry.application' );
163
+ $application->set( 'calendar_base_page', $pagebase_for_href );
164
+ $option = $this->_registry->get( 'model.option' );
165
+
166
+ // If the calendar is set as the front page, disable permalinks.
167
+ // They would not be legal under a Windows server. See:
168
+ // https://issues.apache.org/bugzilla/show_bug.cgi?id=41441
169
+ if (
170
+ $option->get( 'permalink_structure' ) &&
171
+ ( int ) get_option( 'page_on_front' ) !==
172
+ ( int ) $settings->get( 'calendar_page_id' )
173
+ ) {
174
+ $application->set( 'permalinks_enabled', true );
175
+ }
176
+
177
+ $router->asset_base( $page_base )
178
+ ->register_rewrite( $page_link );
179
+ }
180
+
181
+ /**
182
+ * Initialize the system.
183
+ *
184
+ * Perform all the inizialization needed for the system.
185
+ * Throws some uncatched exception for critical failures.
186
+ * Plugin will be disabled by the exception handler on those failures.
187
+ *
188
+ * @param Ai1ec_Loader $ai1ec_loader Instance of Ai1EC classes loader
189
+ *
190
+ * @throws Ai1ec_Constants_Not_Set_Exception
191
+ * @throws Ai1ec_Database_Update_Exception
192
+ * @throws Ai1ec_Database_Schema_Exception
193
+ *
194
+ * @return void Method does not return
195
+ */
196
+ protected function _init( $ai1ec_loader ) {
197
+ $exception = null;
198
+ // Load the textdomain
199
+ add_action( 'plugins_loaded', array( $this, 'load_textdomain' ) );
200
+ try {
201
+ // Initialize the registry object
202
+ $this->_initialize_registry( $ai1ec_loader );
203
+ $this->_registry->get( 'event.dispatcher' )->register_filter(
204
+ 'ai1ec_perform_scheme_update',
205
+ array( 'database.datetime-migration', 'filter_scheme_update' )
206
+ );
207
+ // Load the css if needed
208
+ $this->_load_css_if_needed();
209
+ // Initialize the crons
210
+ $this->_install_crons();
211
+ // Register the activation hook
212
+ $this->_initialize_schema();
213
+ // set the default theme if not set
214
+ $this->_add_default_theme_if_not_set();
215
+ } catch ( Ai1ec_Constants_Not_Set_Exception $e ) {
216
+ // This is blocking, throw it and disable the plugin
217
+ $exception = $e;
218
+ } catch ( Ai1ec_Database_Update_Exception $e ) {
219
+ // Blocking throw it so that the plugin is disabled
220
+ $exception = $e;
221
+ } catch ( Ai1ec_Database_Schema_Exception $e ) {
222
+ // Blocking throw it so that the plugin is disabled
223
+ $exception = $e;
224
+ } catch ( Ai1ec_Scheduling_Exception $e ) {
225
+ // not blocking
226
+ }
227
+
228
+ if ( null !== $exception ) {
229
+ throw $exception;
230
+ }
231
+ }
232
+
233
+ /**
234
+ * Set the default theme if no theme is set, or populate theme info array if
235
+ * insufficient information is currently being stored.
236
+ *
237
+ * @uses apply_filters() Calls 'ai1ec_pre_save_current_theme' hook to allow
238
+ * overwriting of theme information before being stored.
239
+ */
240
+ protected function _add_default_theme_if_not_set() {
241
+ $option = $this->_registry->get( 'model.option' );
242
+ $theme = $option->get( 'ai1ec_current_theme', array() );
243
+ $update = false;
244
+
245
+ // Theme setting is undefined; default to Vortex.
246
+ if ( empty( $theme ) ) {
247
+ $theme = array(
248
+ 'theme_dir' => AI1EC_DEFAULT_THEME_PATH,
249
+ 'theme_root' => AI1EC_DEFAULT_THEME_ROOT,
250
+ 'theme_url' => AI1EC_THEMES_URL . '/' . AI1EC_DEFAULT_THEME_NAME,
251
+ 'stylesheet' => AI1EC_DEFAULT_THEME_NAME,
252
+ 'legacy' => false,
253
+ );
254
+ $update = true;
255
+ }
256
+ // Legacy settings; in 1.x the active theme was stored as a bare string,
257
+ // and they were located in a different folder than they are now.
258
+ else if ( is_string( $theme ) ) {
259
+ $theme_name = strtolower( $theme );
260
+ $core_themes = explode( ',', AI1EC_CORE_THEMES );
261
+ $legacy = ! in_array( $theme_name, $core_themes );
262
+
263
+ if ( $legacy ) {
264
+ $root = WP_CONTENT_DIR . DIRECTORY_SEPARATOR . AI1EC_THEMES_FOLDER;
265
+ $url = WP_CONTENT_URL . '/' . AI1EC_THEMES_FOLDER . '/' . $theme_name;
266
+ } else {
267
+ $root = AI1EC_DEFAULT_THEME_ROOT;
268
+ $url = AI1EC_THEMES_URL . '/' . $theme_name;
269
+ }
270
+
271
+ // Ensure existence of theme directory.
272
+ if ( ! is_dir( $root . DIRECTORY_SEPARATOR . $theme_name ) ) {
273
+ // It's missing; something is wrong with this theme. Reset theme to
274
+ // Vortex and warn the user accordingly.
275
+ $option->set( 'ai1ec_current_theme', $default_theme );
276
+
277
+ $notification = $this->_registry->get( 'notification.admin',
278
+ sprintf(
279
+ Ai1ec_I18n::__(
280
+ 'Your active calendar theme could not be properly initialized. The default theme has been activated instead. Please visit %s and try reactivating your theme manually.'
281
+ ),
282
+ '<a href="' . admin_url( AI1EC_THEME_SELECTION_BASE_URL ) . '">' .
283
+ Ai1ec_I18n::__( 'Calendar Themes' ) . '</a>'
284
+ ),
285
+ 'error',
286
+ 1
287
+ );
288
+ }
289
+
290
+ $theme = array(
291
+ 'theme_dir' => $root . DIRECTORY_SEPARATOR . $theme_name,
292
+ 'theme_root' => $root,
293
+ 'theme_url' => $url,
294
+ 'stylesheet' => $theme_name,
295
+ 'legacy' => $legacy,
296
+ );
297
+ $update = true;
298
+ }
299
+ // Ensure 'theme_url' is defined, as this property was added after the first
300
+ // public beta release.
301
+ else if ( ! isset( $theme['theme_url'] ) ) {
302
+ if ( $theme['legacy'] ) {
303
+ $theme['theme_url'] = WP_CONTENT_URL . '/' . AI1EC_THEMES_FOLDER . '/' .
304
+ $theme['stylesheet'];
305
+ } else {
306
+ $theme['theme_url'] = AI1EC_THEMES_URL . '/' . $theme['stylesheet'];
307
+ }
308
+ $update = true;
309
+ }
310
+
311
+ if ( $update ) {
312
+ $theme = apply_filters( 'ai1ec_pre_save_current_theme', $theme );
313
+ $option->set( 'ai1ec_current_theme', $theme );
314
+ }
315
+ }
316
+
317
+ /**
318
+ * Adds actions handled by the front controller.
319
+ */
320
+ protected function _add_front_controller_actions() {
321
+ // Initialize router. I use add_action as the dispatcher would just add
322
+ // overhead.
323
+ add_action(
324
+ 'init',
325
+ array( $this, 'initialize_router' ),
326
+ PHP_INT_MAX - 1
327
+ );
328
+ // Route the request.
329
+ $action = 'template_redirect';
330
+ if ( is_admin() ) {
331
+ $action = 'init';
332
+ }
333
+ add_action( $action, array( $this, 'route_request' ) );
334
+ add_filter( 'ai1ec_registry', array( $this, 'return_registry' ) );
335
+ }
336
+
337
+ /**
338
+ * Initialize the dispatcher.
339
+ *
340
+ * Complete this when writing the dispatcher.
341
+ *
342
+ * @return void
343
+ */
344
+ protected function _initialize_dispatcher() {
345
+ $dispatcher = $this->_registry->get( 'event.dispatcher' );
346
+ $dispatcher->register_action(
347
+ 'init',
348
+ array( 'post.custom-type', 'register' )
349
+ );
350
+ $this->_add_front_controller_actions();
351
+ if ( isset( $_GET[Ai1ec_Javascript_Controller::LOAD_JS_PARAMETER] ) ) {
352
+ $dispatcher->register_action(
353
+ 'wp_loaded',
354
+ array( 'controller.javascript', 'render_js' )
355
+ );
356
+ }
357
+ $dispatcher->register_action(
358
+ 'delete_post',
359
+ array( 'model.event.trashing', 'delete' )
360
+ );
361
+ $dispatcher->register_action(
362
+ 'trashed_post',
363
+ array( 'model.event.trashing', 'trash' )
364
+ );
365
+ $dispatcher->register_action(
366
+ 'untrashed_post',
367
+ array( 'model.event.trashing', 'untrash' )
368
+ );
369
+ $dispatcher->register_action(
370
+ 'pre_http_request',
371
+ array( 'http.request', 'pre_http_request' ),
372
+ 10,
373
+ 3
374
+ );
375
+ $dispatcher->register_action(
376
+ 'http_request_args',
377
+ array( 'http.request', 'init_certificate' ),
378
+ 10,
379
+ 2
380
+ );
381
+ $dispatcher->register_filter(
382
+ 'get_the_excerpt',
383
+ array( 'view.event.content', 'event_excerpt' ),
384
+ 11
385
+ );
386
+ remove_filter( 'the_excerpt', 'wpautop', 10 );
387
+ $dispatcher->register_filter(
388
+ 'the_excerpt',
389
+ array( 'view.event.content', 'event_excerpt_noautop' ),
390
+ 11
391
+ );
392
+ $dispatcher->register_filter(
393
+ 'robots_txt',
394
+ array( 'robots.helper', 'rules' ),
395
+ 10,
396
+ 2
397
+ );
398
+
399
+ // Category colors
400
+ $dispatcher->register_action(
401
+ 'events_categories_add_form_fields',
402
+ array( 'view.admin.event-category', 'events_categories_add_form_fields' )
403
+ );
404
+ $dispatcher->register_action(
405
+ 'events_categories_edit_form_fields',
406
+ array( 'view.admin.event-category', 'events_categories_edit_form_fields' )
407
+ );
408
+ $dispatcher->register_action(
409
+ 'created_events_categories',
410
+ array( 'view.admin.event-category', 'created_events_categories' )
411
+ );
412
+ $dispatcher->register_action(
413
+ 'edited_events_categories',
414
+ array( 'view.admin.event-category', 'edited_events_categories' )
415
+ );
416
+ $dispatcher->register_action(
417
+ 'manage_edit-events_categories_columns',
418
+ array( 'view.admin.event-category', 'manage_event_categories_columns' )
419
+ );
420
+ $dispatcher->register_action(
421
+ 'manage_events_categories_custom_column',
422
+ array( 'view.admin.event-category', 'manage_events_categories_custom_column' ),
423
+ 10,
424
+ 3
425
+ );
426
+ $dispatcher->register_action(
427
+ 'widgets_init',
428
+ array( 'view.calendar.widget', 'register_widget' )
429
+ );
430
+
431
+ if ( is_admin() ) {
432
+ // get the repeat box
433
+ $dispatcher->register_action(
434
+ 'wp_ajax_ai1ec_get_repeat_box',
435
+ array( 'view.admin.get-repeat-box', 'get_repeat_box' )
436
+ );
437
+ // save rrurle and convert it to text
438
+ $dispatcher->register_action(
439
+ 'wp_ajax_ai1ec_rrule_to_text',
440
+ array( 'view.admin.get-repeat-box', 'convert_rrule_to_text' )
441
+ );
442
+ // tracking opt in ai1ec_tracking
443
+ $dispatcher->register_action(
444
+ 'wp_ajax_ai1ec_tracking',
445
+ array( 'controller.export', 'track_optin' )
446
+ );
447
+ // taxonomy filter
448
+ $dispatcher->register_action(
449
+ 'restrict_manage_posts',
450
+ array( 'view.admin.all-events', 'taxonomy_filter_restrict_manage_posts' )
451
+ );
452
+ $dispatcher->register_action(
453
+ 'parse_query',
454
+ array( 'view.admin.all-events', 'taxonomy_filter_post_type_request' )
455
+ );
456
+ $dispatcher->register_action(
457
+ 'admin_enqueue_scripts',
458
+ array( 'css.admin', 'admin_enqueue_scripts' )
459
+ );
460
+ $dispatcher->register_action(
461
+ 'admin_menu',
462
+ array( 'view.admin.calendar-feeds', 'add_page' )
463
+ );
464
+ $dispatcher->register_action(
465
+ 'current_screen',
466
+ array( 'view.admin.calendar-feeds', 'add_meta_box' )
467
+ );
468
+ $dispatcher->register_action(
469
+ 'admin_menu',
470
+ array( 'view.admin.theme-switching', 'add_page' )
471
+ );
472
+ $dispatcher->register_action(
473
+ 'admin_menu',
474
+ array( 'view.admin.theme-options', 'add_page' )
475
+ );
476
+ $dispatcher->register_action(
477
+ 'current_screen',
478
+ array( 'view.admin.theme-options', 'add_meta_box' )
479
+ );
480
+ $dispatcher->register_action(
481
+ 'admin_menu',
482
+ array( 'view.admin.settings', 'add_page' )
483
+ );
484
+ $dispatcher->register_action(
485
+ 'current_screen',
486
+ array( 'view.admin.settings', 'add_meta_box' )
487
+ );
488
+ $dispatcher->register_action(
489
+ 'init',
490
+ array( 'controller.javascript', 'load_admin_js' )
491
+ );
492
+ $dispatcher->register_action(
493
+ 'wp_ajax_ai1ec_add_ics',
494
+ array( 'calendar-feed.ics', 'add_ics_feed' )
495
+ );
496
+ $dispatcher->register_action(
497
+ 'wp_ajax_ai1ec_delete_ics',
498
+ array( 'calendar-feed.ics', 'delete_feeds_and_events' )
499
+ );
500
+ $dispatcher->register_action(
501
+ 'wp_ajax_ai1ec_update_ics',
502
+ array( 'calendar-feed.ics', 'update_ics_feed' )
503
+ );
504
+ $dispatcher->register_action(
505
+ 'network_admin_notices',
506
+ array( 'notification.admin', 'send' )
507
+ );
508
+ $dispatcher->register_action(
509
+ 'admin_notices',
510
+ array( 'notification.admin', 'send' )
511
+ );
512
+ $dispatcher->register_action(
513
+ 'admin_footer-edit.php',
514
+ array( 'clone.renderer-helper', 'duplicate_custom_bulk_admin_footer' )
515
+ );
516
+ $dispatcher->register_filter(
517
+ 'post_row_actions',
518
+ array( 'clone.renderer-helper', 'duplicate_post_make_duplicate_link_row' ),
519
+ 10,
520
+ 2
521
+ );
522
+ $dispatcher->register_action(
523
+ 'add_meta_boxes',
524
+ array( 'view.admin.add-new-event', 'event_meta_box_container' )
525
+ );
526
+ $dispatcher->register_action(
527
+ 'save_post',
528
+ array( 'model.event.creating', 'save_post' ),
529
+ 10,
530
+ 2
531
+ );
532
+ $dispatcher->register_action(
533
+ 'manage_ai1ec_event_posts_custom_column',
534
+ array( 'view.admin.all-events', 'custom_columns' ),
535
+ 10,
536
+ 2
537
+ );
538
+ $dispatcher->register_filter(
539
+ 'manage_ai1ec_event_posts_columns',
540
+ array( 'view.admin.all-events', 'change_columns' )
541
+ );
542
+ $dispatcher->register_filter(
543
+ 'manage_edit-ai1ec_event_sortable_columns',
544
+ array( 'view.admin.all-events', 'sortable_columns' )
545
+ );
546
+ $dispatcher->register_filter(
547
+ 'posts_orderby',
548
+ array( 'view.admin.all-events', 'orderby' ),
549
+ 10,
550
+ 2
551
+ );
552
+ $dispatcher->register_filter(
553
+ 'post_updated_messages',
554
+ array( 'view.event.post', 'post_updated_messages' )
555
+ );
556
+ add_action( 'admin_head', array( $this, 'admin_head' ) );
557
+ $dispatcher->register_action(
558
+ 'plugin_action_links_' . AI1EC_PLUGIN_BASENAME,
559
+ array( 'view.admin.nav', 'plugin_action_links' )
560
+ );
561
+ $dispatcher->register_action(
562
+ 'admin_init',
563
+ array( 'robots.helper', 'install' )
564
+ );
565
+ $dispatcher->register_action(
566
+ 'wp_ajax_ai1ec_rescan_cache',
567
+ array( 'twig.cache', 'rescan' )
568
+ );
569
+ } else { // ! is_admin()
570
+ $dispatcher->register_shortcode(
571
+ 'ai1ec',
572
+ array( 'view.calendar.shortcode', 'shortcode' )
573
+ );
574
+ $dispatcher->register_action(
575
+ 'after_setup_theme',
576
+ array( 'theme.loader', 'execute_theme_functions' )
577
+ );
578
+ }
579
+ }
580
+
581
+ /**
582
+ * Outputs menu icon between head tags
583
+ */
584
+ public function admin_head() {
585
+ global $wp_version;
586
+ $argv = array(
587
+ 'before_font_icons' => version_compare( $wp_version, '3.8', '<' ),
588
+ 'admin_theme_img_url' => AI1EC_ADMIN_THEME_IMG_URL,
589
+ 'admin_theme_font_url' => AI1EC_ADMIN_THEME_FONT_URL,
590
+ );
591
+ $this->_registry->get( 'theme.loader' )
592
+ ->get_file( 'timely-menu-icon.twig', $argv, true )
593
+ ->render();
594
+ }
595
+
596
+ /**
597
+ * _add_defaults method
598
+ *
599
+ * Add (merge) default options to given query variable.
600
+ *
601
+ * @param string settingsquery variable to ammend
602
+ *
603
+ * @return string|NULL Modified variable values or NULL on failure
604
+ *
605
+ * @global Ai1ec_Settings $ai1ec_settings Instance of settings object
606
+ * to pull data from
607
+ * @staticvar array $mapper Mapping of query names to
608
+ * default in settings
609
+ */
610
+ protected function _add_defaults( $name ) {
611
+ $settings = $this->_registry->get( 'model.settings' );
612
+ static $mapper = array(
613
+ 'cat' => 'categories',
614
+ 'tag' => 'tags',
615
+ );
616
+ $rq_name = 'ai1ec_' . $name . '_ids';
617
+ if (
618
+ ! isset( $mapper[$name] ) ||
619
+ ! array_key_exists( $rq_name, $this->_request )
620
+ ) {
621
+ return NULL;
622
+ }
623
+ $options = explode( ',', $this->_request[$rq_name] );
624
+ $property = 'default_' . $mapper[$name];
625
+ $options = array_merge(
626
+ $options,
627
+ $settings->get( $property )
628
+ );
629
+ $filtered = array();
630
+ foreach ( $options as $item ) { // avoid array_filter + is_numeric
631
+ $item = (int)$item;
632
+ if ( $item > 0 ) {
633
+ $filtered[] = $item;
634
+ }
635
+ }
636
+ unset( $options );
637
+ if ( empty( $filtered ) ) {
638
+ return NULL;
639
+ }
640
+ return implode( ',', $filtered );
641
+ }
642
+
643
+ /**
644
+ * Process_request function.
645
+ *
646
+ * Initialize/validate custom request array, based on contents of $_REQUEST,
647
+ * to keep track of this component's request variables.
648
+ *
649
+ * @return void
650
+ **/
651
+ protected function _process_request() {
652
+ $settings = $this->_registry->get( 'model.settings' );
653
+ $this->_request = $this->_registry->get( 'http.request.parser' );
654
+ $aco = $this->_registry->get( 'acl.aco' );
655
+ $page_id = $settings->get( 'calendar_page_id' );
656
+ if (
657
+ ! $aco->is_admin() &&
658
+ $page_id &&
659
+ is_page( $page_id )
660
+ ) {
661
+ foreach ( array( 'cat', 'tag' ) as $name ) {
662
+ $implosion = $this->_add_defaults( $name );
663
+ if ( $implosion ) {
664
+ $this->request['ai1ec_' . $name . '_ids'] = $implosion;
665
+ $_REQUEST['ai1ec_' . $name . '_ids'] = $implosion;
666
+ }
667
+ }
668
+ }
669
+ }
670
+
671
+ /**
672
+ * Initialize cron functions.
673
+ *
674
+ * @throws Ai1ec_Scheduling_Exception
675
+ *
676
+ * @return void
677
+ */
678
+ protected function _install_crons() {
679
+ $scheduling = $this->_registry->get( 'scheduling.utility', $this->_registry );
680
+ $allow = $this->_registry->get( 'model.settings', $this->_registry )
681
+ ->get( 'allow_statistics' );
682
+ $correct = false;
683
+ // install the cron for stats
684
+ $hook_name = 'ai1ec_n_cron';
685
+ // if stats are disabled, cancel the cron
686
+ if ( false === $allow ) {
687
+ $scheduling->delete( $hook_name );
688
+ $correct = true;
689
+ } else {
690
+ $correct = $scheduling->reschedule(
691
+ $hook_name,
692
+ AI1EC_N_CRON_FREQ,
693
+ AI1EC_N_CRON_VERSION
694
+ );
695
+ $this->_registry->get( 'event.dispatcher' )
696
+ ->register_action(
697
+ $hook_name,
698
+ array( 'controller.export', 'n_cron' )
699
+ );
700
+ }
701
+ if ( false === $correct ) {
702
+ throw new Ai1ec_Scheduling_Exception(
703
+ 'Some CRON function might not have been installed'
704
+ );
705
+ }
706
+ }
707
+
708
+ /**
709
+ * Register the activation hook for the plugin.
710
+ *
711
+ * @return void
712
+ */
713
+ protected function _register_activation_hook() {
714
+ // register_activation_hook
715
+ register_activation_hook(
716
+ AI1EC_PLUGIN_NAME . '/' . AI1EC_PLUGIN_NAME . '.php',
717
+ array( $this, 'activation_hook' )
718
+ );
719
+ }
720
+
721
+ /**
722
+ * Initialize the registry object.
723
+ *
724
+ * @param Ai1ec_Loader $ai1ec_loader Instance of Ai1EC classes loader
725
+ *
726
+ * @return void Method does not return
727
+ */
728
+ protected function _initialize_registry( $ai1ec_loader ) {
729
+ global $ai1ec_registry;
730
+ $this->_registry = new Ai1ec_Registry_Object( $ai1ec_loader );
731
+ $ai1ec_registry = $this->_registry;
732
+ Ai1ec_Time_Utility::set_registry( $this->_registry );
733
+ }
734
+
735
+ /**
736
+ * Loads the CSS for the plugin
737
+ *
738
+ */
739
+ protected function _load_css_if_needed() {
740
+ // ==================================
741
+ // = Add the hook to render the css =
742
+ // ==================================
743
+ if ( isset( $_GET[Ai1ec_Css_Frontend::QUERY_STRING_PARAM] ) ) {
744
+ // we need to wait for the extension to be registered if the css
745
+ // needs to be compiled. Will find a better way when compiling css.
746
+ $css_controller = $this->_registry->get( 'css.frontend' );
747
+ add_action( 'plugins_loaded', array( $css_controller, 'render_css' ), 2 );
748
+ }
749
+ }
750
+
751
+ /**
752
+ * Load the texdomain for the plugin.
753
+ *
754
+ * @wp_hook plugins_loaded
755
+ *
756
+ * @return void
757
+ */
758
+ public function load_textdomain() {
759
+ if ( false === $this->_domain_loaded ) {
760
+ load_plugin_textdomain(
761
+ AI1EC_PLUGIN_NAME, false, AI1EC_LANGUAGE_PATH
762
+ );
763
+ $this->_domain_loaded = true;
764
+ }
765
+ }
766
+
767
+ /**
768
+ * Check if the schema is up to date.
769
+ *
770
+ * @throws Ai1ec_Database_Schema_Exception
771
+ * @throws Ai1ec_Database_Update_Exception
772
+ *
773
+ * @return void
774
+ */
775
+ protected function _initialize_schema() {
776
+ $option = $this->_registry->get( 'model.option' );
777
+ $schema_sql = $this->get_current_db_schema();
778
+ $version = sha1( $schema_sql );
779
+ // If existing DB version is not consistent with current plugin's version,
780
+ // or does not exist, then create/update table structure using dbDelta().
781
+ if ( $option->get( 'ai1ec_db_version' ) != $version ) {
782
+
783
+ $errors = $this->_registry->get( 'database.applicator' )
784
+ ->check_db_consistency_for_date_migration() ;
785
+ if ( ! empty( $errors ) ) {
786
+ $message = Ai1ec_I18n::__(
787
+ 'Your database is found to be corrupt. Likely previous update has failed. Please restore All-in-One Event Calendar tables from a backup and retry.<br>Following errors were found:<br>%s'
788
+ );
789
+ $message = sprintf( $message, implode( $errors, '<br>' ) );
790
+ throw new Ai1ec_Database_Update_Exception( $message );
791
+ }
792
+ $this->_registry->get( 'database.applicator' )
793
+ ->remove_instance_duplicates();
794
+
795
+ if (
796
+ apply_filters( 'ai1ec_perform_scheme_update', true ) &&
797
+ $this->_registry->get( 'database.helper' )->apply_delta(
798
+ $schema_sql
799
+ )
800
+ ) {
801
+ $option->set( 'ai1ec_db_version', $version );
802
+ } else {
803
+ throw new Ai1ec_Database_Update_Exception();
804
+ }
805
+
806
+ // If the schema structure upgrade is complete move contents
807
+ $categories_key = 'ai1ec_category_meta_ported';
808
+ if ( ! $option->get( $categories_key ) ) {
809
+ $this->_migrate_categories_meta();
810
+ $option->set( $categories_key, true );
811
+ }
812
+ }
813
+ }
814
+
815
+ /**
816
+ * Transform categories meta information.
817
+ *
818
+ * Use new `meta` table instead of legacy `colors` table.
819
+ *
820
+ * @return void Method does not return.
821
+ */
822
+ protected function _migrate_categories_meta() {
823
+ $db = $this->_registry->get( 'dbi.dbi' );
824
+ $table_name = $db->get_table_name( 'ai1ec_event_category_colors' );
825
+ $db_h = $this->_registry->get( 'database.helper' );
826
+ if ( $db_h->table_exists( $table_name ) ) { // if old table exists otherwise ignore it
827
+ // Migrate color information
828
+ $dest_table = $db->get_table_name( 'ai1ec_event_category_meta' );
829
+ $colors = $db->select(
830
+ $table_name,
831
+ array( 'term_id', 'term_color'),
832
+ ARRAY_A
833
+ );
834
+ if ( ! empty( $colors ) ) {
835
+ foreach ( $colors as $color ) {
836
+ $db->insert( $dest_table, $color );
837
+ }
838
+ }
839
+ // Drop the old table
840
+ $db->query( 'DROP TABLE IF EXISTS ' . $table_name );
841
+ }
842
+ }
843
+
844
+ /**
845
+ * Get current database schema as a multi SQL statement.
846
+ *
847
+ * @return string Multiline SQL statement.
848
+ */
849
+ public function get_current_db_schema() {
850
+ $dbi = $this->_registry->get( 'dbi.dbi' );
851
+ // =======================
852
+ // = Create table events =
853
+ // =======================
854
+ $table_name = $dbi->get_table_name( 'ai1ec_events' );
855
+ $sql = "CREATE TABLE $table_name (
856
+ post_id bigint(20) NOT NULL,
857
+ start int(10) UNSIGNED NOT NULL,
858
+ end int(10) UNSIGNED,
859
+ timezone_name varchar(50),
860
+ allday tinyint(1) NOT NULL,
861
+ instant_event tinyint(1) NOT NULL DEFAULT 0,
862
+ recurrence_rules longtext,
863
+ exception_rules longtext,
864
+ recurrence_dates longtext,
865
+ exception_dates longtext,
866
+ venue varchar(255),
867
+ country varchar(255),
868
+ address varchar(255),
869
+ city varchar(255),
870
+ province varchar(255),
871
+ postal_code varchar(32),
872
+ show_map tinyint(1),
873
+ contact_name varchar(255),
874
+ contact_phone varchar(32),
875
+ contact_email varchar(128),
876
+ contact_url varchar(255),
877
+ cost varchar(255),
878
+ ticket_url varchar(255),
879
+ ical_feed_url varchar(255),
880
+ ical_source_url varchar(255),
881
+ ical_organizer varchar(255),
882
+ ical_contact varchar(255),
883
+ ical_uid varchar(255),
884
+ show_coordinates tinyint(1),
885
+ latitude decimal(20,15),
886
+ longitude decimal(20,15),
887
+ force_regenerate tinyint(1) NOT NULL DEFAULT 0,
888
+ PRIMARY KEY (post_id),
889
+ KEY feed_source (ical_feed_url)
890
+ ) CHARACTER SET utf8;";
891
+
892
+ // ==========================
893
+ // = Create table instances =
894
+ // ==========================
895
+ $table_name = $dbi->get_table_name( 'ai1ec_event_instances' );
896
+ $sql .= "CREATE TABLE $table_name (
897
+ id bigint(20) NOT NULL AUTO_INCREMENT,
898
+ post_id bigint(20) NOT NULL,
899
+ start int(10) UNSIGNED NOT NULL,
900
+ end int(10) UNSIGNED NOT NULL,
901
+ PRIMARY KEY (id),
902
+ UNIQUE KEY evt_instance (post_id,start)
903
+ ) CHARACTER SET utf8;";
904
+
905
+ // ================================
906
+ // = Create table category colors =
907
+ // ================================
908
+ $table_name = $dbi->get_table_name( 'ai1ec_event_category_meta' );
909
+ $sql .= "CREATE TABLE $table_name (
910
+ term_id bigint(20) NOT NULL,
911
+ term_color varchar(255) NOT NULL,
912
+ term_image varchar(254) NULL DEFAULT NULL,
913
+ PRIMARY KEY (term_id)
914
+ ) CHARACTER SET utf8;";
915
+
916
+ return $sql;
917
+ }
918
+
919
+ /**
920
+ * Compile theme files for shipping.
921
+ *
922
+ * @return bool Whereas recompilation will happen.
923
+ */
924
+ protected function _compile_themes() {
925
+ if (
926
+ ! AI1EC_DEBUG ||
927
+ ! isset( $_GET['ai1ec_recompile_templates'] ) ||
928
+ $_SERVER['REMOTE_ADDR'] !== $_SERVER['SERVER_ADDR']
929
+ ) {
930
+ return false;
931
+ }
932
+ $compiler = $this->_registry->get( 'theme.compiler' );
933
+ add_action(
934
+ 'plugins_loaded',
935
+ array( $compiler, 'generate' ),
936
+ PHP_INT_MAX
937
+ );
938
+ return true;
939
+ }
940
+
941
+ }
app/controller/import-export.php ADDED
@@ -0,0 +1,104 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * The controller which handles import/export.
5
+ *
6
+ * @author Time.ly Network Inc.
7
+ * @since 2.0
8
+ *
9
+ * @package AI1EC
10
+ * @subpackage AI1EC.Controller
11
+ */
12
+ class Ai1ec_Import_Export_Controller {
13
+
14
+ /**
15
+ * @var array The registered engines.
16
+ */
17
+ protected $_engines = array();
18
+
19
+
20
+ /**
21
+ * @var Ai1ec_Registry_Object
22
+ */
23
+ protected $_registry;
24
+
25
+ /**
26
+ * This controller is instanciated only if we need to import/export something.
27
+ *
28
+ * When it is instanciated it allows other engines to be injected through a
29
+ * filter. If we do not plan to ship core engines, let's skip the
30
+ * $core_engines param.
31
+ *
32
+ * @param Ai1ec_Registry_Object $registry
33
+ * @param array $core_engines
34
+ */
35
+ public function __construct(
36
+ Ai1ec_Registry_Object $registry,
37
+ array $core_engines = array( 'ics' )
38
+ ) {
39
+ $this->_registry = $registry;
40
+ $known_engines = apply_filters(
41
+ 'ai1ec_register_import_export_engines',
42
+ $core_engines
43
+ );
44
+ foreach ( $known_engines as $engine ) {
45
+ $this->register( $engine );
46
+ }
47
+ }
48
+
49
+ /**
50
+ * Register an import-export engine.
51
+ *
52
+ * @param string $engine
53
+ */
54
+ public function register( $engine ) {
55
+ $this->_engines[$engine] = true;
56
+ }
57
+
58
+ /**
59
+ * Import events into the calendar.
60
+ *
61
+ * @param string $engine
62
+ * @param array $args
63
+ *
64
+ * @throws Ai1ec_Engine_Not_Set_Exception If the engine is not set.
65
+ * @throws Ai1ec_Parse_Exception If an error happens during parse.
66
+ *
67
+ * @return int The number of imported events
68
+ */
69
+ public function import_events( $engine, array $args ) {
70
+ if ( ! isset( $this->_engines[$engine] ) ) {
71
+ throw new Ai1ec_Engine_Not_Set_Exception(
72
+ 'The engine ' . $engine . 'is not registered.'
73
+ );
74
+ }
75
+ // external engines must register themselves into the registry.
76
+ $engine = $this->_registry->get( 'import-export.' . $engine );
77
+ $exception = null;
78
+ try {
79
+ return $engine->import( $args );
80
+ } catch ( Ai1ec_Parse_Exception $parse_exception ) {
81
+ $exception = $parse_exception;
82
+ }
83
+ throw $exception;
84
+ }
85
+
86
+ /**
87
+ * Export the events using the specified engine.
88
+ *
89
+ * @param string $engine
90
+ * @param array $args
91
+ *
92
+ * @throws Ai1ec_Engine_Not_Set_Exception
93
+ */
94
+ public function export_events( $engine, array $args ) {
95
+ if ( ! isset( $this->_engines[$engine] ) ) {
96
+ throw new Ai1ec_Engine_Not_Set_Exception(
97
+ 'The engine ' . $engine . 'is not registered.'
98
+ );
99
+ }
100
+ // external engines must register themselves into the registry.
101
+ $engine = $this->_registry->get( 'import-export.' . $engine );
102
+ return $engine->export( $args );
103
+ }
104
+ }
app/controller/javascript.php ADDED
@@ -0,0 +1,647 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Controller that handles javascript related functions.
4
+ *
5
+ * @author Time.ly Network Inc.
6
+ * @since 2.0
7
+ *
8
+ * @package AI1EC
9
+ * @subpackage AI1EC.Controller
10
+ */
11
+ class Ai1ec_Javascript_Controller {
12
+
13
+ // The js handle used when enqueueing
14
+ const JS_HANDLE = 'ai1ec_requirejs';
15
+
16
+ // The namespace for require.js functions
17
+ const REQUIRE_NAMESPACE = 'timely';
18
+
19
+ // the name of the configuration module for the frontend
20
+ const FRONTEND_CONFIG_MODULE = 'ai1ec_calendar';
21
+
22
+ //the name of the get parameter we use for loading js
23
+ const LOAD_JS_PARAMETER = 'ai1ec_render_js';
24
+
25
+ // just load backend scripts
26
+ const LOAD_ONLY_BACKEND_SCRIPTS = 'common_backend';
27
+
28
+ // just load backend scripts
29
+ const LOAD_ONLY_FRONTEND_SCRIPTS = 'common_frontend';
30
+
31
+ // Are we in the backend
32
+ const IS_BACKEND_PARAMETER = 'is_backend';
33
+
34
+ // Are we on the calendar page
35
+ const IS_CALENDAR_PAGE = 'is_calendar_page';
36
+
37
+ // this is the value of IS_BACKEND_PARAMETER which triggers loading of backend script
38
+ const TRUE_PARAM = 'true';
39
+
40
+ // the javascript file for event page
41
+ const EVENT_PAGE_JS = 'event.js';
42
+
43
+ // the javascript file for calendar page
44
+ const CALENDAR_PAGE_JS = 'calendar.js';
45
+
46
+ // the file for the calendar feedsa page
47
+ const CALENDAR_FEEDS_PAGE = 'calendar_feeds.js';
48
+
49
+ // add new event page js
50
+ const ADD_NEW_EVENT_PAGE = 'add_new_event.js';
51
+
52
+ // event category page js
53
+ const EVENT_CATEGORY_PAGE = 'event_category.js';
54
+
55
+ // less variable editing page
56
+ const LESS_VARIBALES_PAGE = 'less_variables_editing.js';
57
+
58
+ // settings page
59
+ const SETTINGS_PAGE = 'admin_settings.js';
60
+
61
+ /**
62
+ * @var Ai1ec_Registry_Object
63
+ */
64
+ private $_registry;
65
+
66
+ /**
67
+ * The core js pages to load.
68
+ * Used to avoid errors when extensions add pages.
69
+ *
70
+ * @var array
71
+ */
72
+ private $_core_pages = array(
73
+ self::CALENDAR_FEEDS_PAGE => true,
74
+ self::ADD_NEW_EVENT_PAGE => true,
75
+ self::EVENT_CATEGORY_PAGE => true,
76
+ self::LESS_VARIBALES_PAGE => true,
77
+ self::SETTINGS_PAGE => true,
78
+ self::EVENT_PAGE_JS => true,
79
+ self::CALENDAR_PAGE_JS => true,
80
+ );
81
+
82
+ /**
83
+ * Holds an instance of the settings object
84
+ *
85
+ * @var Ai1ec_Settings
86
+ */
87
+ private $_settings;
88
+
89
+ /**
90
+ * @var Ai1ec_Locale
91
+ */
92
+ private $_locale;
93
+
94
+ /**
95
+ * @var Ai1ec_Scripts
96
+ */
97
+ private $_scripts_helper;
98
+
99
+ /**
100
+ * @var Ai1ec_Acl_Aco
101
+ */
102
+ private $_aco;
103
+
104
+ /**
105
+ * @var Ai1ec_Template_Link_Helper
106
+ */
107
+ private $_template_link_helper;
108
+
109
+ /**
110
+ * @var bool
111
+ */
112
+ protected $_frontend_scripts_loaded = false;
113
+
114
+ /**
115
+ * Public constructor.
116
+ *
117
+ * @param Ai1ec_Registry_Object $registry
118
+ *
119
+ * @return void
120
+ */
121
+ public function __construct( Ai1ec_Registry_Object $registry ) {
122
+ $this->_registry = $registry;
123
+ $this->_settings = $registry->get( 'model.settings' );
124
+ $this->_locale = $registry->get( 'p28n.wpml' );
125
+ $this->_aco = $registry->get( 'acl.aco' );
126
+ $this->_template_link_helper = $registry->get( 'template.link.helper' );
127
+ // this will need to be modified
128
+ $this->_scripts_helper = $registry->get( 'script.helper' );
129
+ }
130
+
131
+ /**
132
+ * Load javascript files for frontend pages.
133
+ *
134
+ * @wp-hook ai1ec_load_frontend_js
135
+ *
136
+ * @param $is_calendar_page boolean Whether we are displaying the main
137
+ * calendar page or not
138
+ *
139
+ * @return void
140
+ */
141
+ public function load_frontend_js( $is_calendar_page, $is_shortcode = false ) {
142
+ $page = null;
143
+
144
+ // ======
145
+ // = JS =
146
+ // ======
147
+ if( $this->_are_we_accessing_the_single_event_page() === true ) {
148
+ $page = self::EVENT_PAGE_JS;
149
+ }
150
+ if( $is_calendar_page === true ) {
151
+ $page = self::CALENDAR_PAGE_JS;
152
+ }
153
+ if( null !== $page ) {
154
+ $this->add_link_to_render_js( $page, false );
155
+ }
156
+ }
157
+
158
+ /**
159
+ * Render the javascript for the appropriate page.
160
+ *
161
+ * @return void
162
+ */
163
+ public function render_js() {
164
+ $js_path = AI1EC_ADMIN_THEME_JS_PATH . DIRECTORY_SEPARATOR;
165
+ $common_js = '';
166
+ if ( ! isset( $_GET[self::LOAD_JS_PARAMETER] ) ) {
167
+ return null;
168
+ }
169
+ $page_to_load = $_GET[self::LOAD_JS_PARAMETER];
170
+
171
+ if (
172
+ isset( $_GET[self::IS_BACKEND_PARAMETER] ) &&
173
+ $_GET[self::IS_BACKEND_PARAMETER] === self::TRUE_PARAM
174
+ ) {
175
+ $common_js = file_get_contents( $js_path . 'pages/common_backend.js' );
176
+ } else if (
177
+ $page_to_load === self::EVENT_PAGE_JS ||
178
+ $page_to_load === self::CALENDAR_PAGE_JS ||
179
+ $page_to_load === self::LOAD_ONLY_FRONTEND_SCRIPTS
180
+ ) {
181
+ if (
182
+ $page_to_load === self::LOAD_ONLY_FRONTEND_SCRIPTS &&
183
+ true === $this->_frontend_scripts_loaded
184
+ ) {
185
+ return;
186
+ }
187
+ if ( false === $this->_frontend_scripts_loaded ) {
188
+ $common_js = file_get_contents(
189
+ $js_path . 'pages/common_frontend.js'
190
+ );
191
+ $this->_frontend_scripts_loaded = true;
192
+ }
193
+ }
194
+
195
+ // Create the config object for Require.js.
196
+ $require_config = $this->_create_require_js_config_object();
197
+
198
+ // Load Require.js script.
199
+ $require = file_get_contents( $js_path . 'require.js' );
200
+
201
+ // Load appropriate jQuery script based on browser.
202
+ $jquery = $this->get_jquery_version_based_on_browser(
203
+ $_SERVER['HTTP_USER_AGENT']
204
+ );
205
+
206
+ // Load the main script for the page.
207
+ $page_js = '';
208
+ if ( isset( $this->_core_pages[$page_to_load] ) ) {
209
+ $page_js = file_get_contents( $js_path . 'pages/' . $page_to_load );
210
+ }
211
+
212
+ // Load translation module.
213
+ $translation = $this->get_frontend_translation_data();
214
+ $permalink = $this->_template_link_helper
215
+ ->get_permalink( $this->_settings->get( 'calendar_page_id' ) );
216
+ $translation['calendar_url'] = $permalink;
217
+ $translation_module = $this->create_require_js_module(
218
+ self::FRONTEND_CONFIG_MODULE,
219
+ $translation
220
+ );
221
+
222
+ // Load Ai1ec config script.
223
+ $config = $this->create_require_js_module(
224
+ 'ai1ec_config',
225
+ $this->get_translation_data()
226
+ );
227
+
228
+ // Let extensions add their scripts.
229
+ $extension_files = array();
230
+ $extension_files = apply_filters(
231
+ 'ai1ec_render_js',
232
+ $extension_files,
233
+ $page_to_load
234
+ );
235
+ $ext_js = '';
236
+ foreach ( $extension_files as $file ) {
237
+ $ext_js .= file_get_contents( $file );
238
+ }
239
+
240
+ // Finally, load the page_ready script to execute code that must run after
241
+ // all scripts have been loaded.
242
+ $page_ready = file_get_contents(
243
+ $js_path . 'scripts/common_scripts/page_ready.js'
244
+ );
245
+
246
+ $javascript = $require . $require_config . $translation_module .
247
+ $config . $jquery . $page_js . $common_js . $ext_js . $page_ready;
248
+ $this->_echo_javascript( $javascript );
249
+ }
250
+
251
+
252
+ /**
253
+ * Get a compiled javascript file ( used by extensions )
254
+ *
255
+ * @param string $name
256
+ *
257
+ * @return string
258
+ */
259
+ public function get_module( $name ) {
260
+ $js_path = AI1EC_ADMIN_THEME_JS_PATH . DIRECTORY_SEPARATOR;
261
+ return file_get_contents( $js_path . $name );
262
+ }
263
+
264
+ /**
265
+ * Check what file needs to be loaded and add the correct link.
266
+ *
267
+ * @wp-hook init
268
+ *
269
+ * @return void
270
+ */
271
+ public function load_admin_js() {
272
+ // Initialize dashboard view
273
+
274
+ $script_to_load = FALSE;
275
+ if ( $this->are_we_on_calendar_feeds_page() === TRUE ) {
276
+ // Load script for the importer plugins
277
+ $script_to_load = self::CALENDAR_FEEDS_PAGE;
278
+ }
279
+ // Start the scripts for the event category page
280
+ if ( $this->_are_we_editing_event_categories() === TRUE ) {
281
+ // Load script required when editing categories
282
+ $script_to_load = self::EVENT_CATEGORY_PAGE;
283
+ }
284
+ if ( $this->_are_we_editing_less_variables() === TRUE ) {
285
+ // Load script required when editing categories
286
+ $script_to_load = self::LESS_VARIBALES_PAGE;
287
+ }
288
+ // Load the js needed when you edit an event / add a new event
289
+ if (
290
+ true === $this->_are_we_creating_a_new_event() ||
291
+ true === $this->_are_we_editing_an_event()
292
+ ) {
293
+ // Load script for adding / modifying events
294
+ $script_to_load = self::ADD_NEW_EVENT_PAGE;
295
+ }
296
+ if ( $this->_are_we_accessing_the_calendar_settings_page() === TRUE ) {
297
+ $script_to_load = self::SETTINGS_PAGE;
298
+ }
299
+
300
+ if ( false === $script_to_load ) {
301
+ $script_to_load = apply_filters( 'ai1ec_backend_js', self::LOAD_ONLY_BACKEND_SCRIPTS );
302
+ }
303
+ if ( current_user_can( 'manage_options' ) &&
304
+ $this->_registry->get( 'model.settings' )->get( 'show_tracking_popup' )
305
+ ) {
306
+ wp_enqueue_style( 'wp-pointer' );
307
+ wp_enqueue_script( 'jquery-ui' );
308
+ wp_enqueue_script( 'wp-pointer' );
309
+ wp_enqueue_script( 'utils' );
310
+ }
311
+
312
+ $this->add_link_to_render_js( $script_to_load, true );
313
+
314
+ }
315
+
316
+ /**
317
+ * Loads version 1.9 or 2.0 of jQuery based on user agent.
318
+ *
319
+ * @param string $user_agent
320
+ *
321
+ * @return string
322
+ */
323
+ public function get_jquery_version_based_on_browser( $user_agent ) {
324
+ $js_path = AI1EC_ADMIN_THEME_JS_PATH . DIRECTORY_SEPARATOR;
325
+ $jquery = 'jquery_timely20.js';
326
+ preg_match( '/MSIE (.*?);/', $user_agent, $matches );
327
+ if ( count( $matches ) > 1 ) {
328
+ //Then we're using IE
329
+ $version = (int) $matches[1];
330
+ if ( $version <= 8 ) {
331
+ //IE 8 or under!
332
+ $jquery = 'jquery_timely19.js';
333
+ }
334
+ }
335
+ return file_get_contents( $js_path . $jquery );
336
+ }
337
+
338
+ /**
339
+ * Creates a requirejs module that can be used for translations
340
+ *
341
+ * @param string $object_name
342
+ * @param array $data
343
+ *
344
+ * @return string
345
+ */
346
+ public function create_require_js_module( $object_name, array $data ) {
347
+ foreach ( (array) $data as $key => $value ) {
348
+ if ( ! is_scalar( $value ) )
349
+ continue;
350
+ $data[$key] = html_entity_decode( (string) $value, ENT_QUOTES, 'UTF-8');
351
+ }
352
+ $json_data = json_encode( $data );
353
+ $prefix = self::REQUIRE_NAMESPACE;
354
+ $script = "$prefix.define( '$object_name', $json_data );";
355
+
356
+ return $script;
357
+ }
358
+
359
+ /**
360
+ * Create the array needed for translation and passing other settings to JS.
361
+ *
362
+ * @return $data array the dynamic data array
363
+ */
364
+ public function get_translation_data() {
365
+
366
+ $force_ssl_admin = force_ssl_admin();
367
+ if ( $force_ssl_admin && ! is_ssl() ) {
368
+ force_ssl_admin( false );
369
+ }
370
+ $ajax_url = admin_url( 'admin-ajax.php' );
371
+ force_ssl_admin( $force_ssl_admin );
372
+ $settings = $this->_registry->get( 'model.settings' );
373
+ $locale = $this->_registry->get( 'p28n.wpml' );
374
+ $blog_timezone = $this->_registry->get( 'model.option' )
375
+ ->get( 'gmt_offset' );
376
+
377
+ $data = array(
378
+ // ICS feed error messages
379
+ 'duplicate_feed_message' => esc_html(
380
+ Ai1ec_I18n::__( 'This feed is already being imported.' )
381
+ ),
382
+ 'invalid_url_message' => esc_html(
383
+ Ai1ec_I18n::__( 'Please enter a valid iCalendar URL.' )
384
+ ),
385
+ 'invalid_email_message' => esc_html(
386
+ Ai1ec_I18n::__( 'Please enter a valid email address.' )
387
+ ),
388
+ 'choose_image_message' => Ai1ec_I18n::__( 'Choose Image' ),
389
+ 'now' => $this->_registry->get( 'date.system' )
390
+ ->current_time(),
391
+ 'size_less_variable_not_ok' => Ai1ec_I18n::__(
392
+ 'The value you have entered is not a valid CSS length.'
393
+ ),
394
+ 'confirm_reset_theme' => Ai1ec_I18n::__(
395
+ 'Are you sure you want to reset your theme options to their default values?'
396
+ ),
397
+ 'error_message_not_valid_lat' => Ai1ec_I18n::__(
398
+ 'Please enter a valid latitude. A valid latitude is comprised between +90 and -90.'
399
+ ),
400
+ 'error_message_not_valid_long' => Ai1ec_I18n::__(
401
+ 'Please enter a valid longitude. A valid longitude is comprised between +180 and -180.'
402
+ ),
403
+ 'error_message_not_entered_lat' => Ai1ec_I18n::__(
404
+ 'When the "Input coordinates" checkbox is checked, "Latitude" is a required field.'
405
+ ),
406
+ 'error_message_not_entered_long' => Ai1ec_I18n::__(
407
+ 'When the "Input coordinates" checkbox is checked, "Longitude" is a required field.'
408
+ ),
409
+ 'url_not_valid' => Ai1ec_I18n::__(
410
+ 'The URL you have entered seems to be invalid. Please remember that URLs must start with either "http://" or "https://".'
411
+ ),
412
+ 'language' => $this->_registry->get( 'p28n.wpml' )->get_lang(),
413
+ 'ajax_url' => $ajax_url,
414
+ // 24h time format for time pickers
415
+ 'twentyfour_hour' => $settings->get( 'input_24h_time' ),
416
+ // Date format for date pickers
417
+ 'date_format' => $settings->get( 'input_date_format' ),
418
+ // Names for months in date picker header (escaping is done in wp_localize_script)
419
+ 'month_names' => $locale->get_localized_month_names(),
420
+ // Names for days in date picker header (escaping is done in wp_localize_script)
421
+ 'day_names' => $locale->get_localized_week_names(),
422
+ // Start the week on this day in the date picker
423
+ 'week_start_day' => $settings->get( 'week_start_day' ),
424
+ 'blog_timezone' => $blog_timezone,
425
+ 'show_tracking_popup' =>
426
+ current_user_can( 'manage_options' ) && $settings->get( 'show_tracking_popup' ),
427
+ );
428
+ return $data;
429
+ }
430
+
431
+ /**
432
+ * Get the array with translated data for the frontend
433
+ *
434
+ * @return array
435
+ */
436
+ public function get_frontend_translation_data() {
437
+ $data = array(
438
+ 'export_url' => AI1EC_EXPORT_URL,
439
+ );
440
+
441
+ // Replace desired CSS selector with calendar, if selector has been set
442
+ $calendar_selector = $this->_settings->get( 'calendar_css_selector' );
443
+ if( $calendar_selector ) {
444
+ $page = get_post(
445
+ $this->_settings->get( 'calendar_page_id' )
446
+ );
447
+ $data['selector'] = $calendar_selector;
448
+ $data['title'] = $page->post_title;
449
+ }
450
+
451
+ // DEPRECATED: Only still here for backwards compatibility with Ai1ec 1.x.
452
+ $data['fonts'] = array();
453
+ $fonts_dir = AI1EC_DEFAULT_THEME_URL . 'font_css/';
454
+ $data['fonts'][] = array(
455
+ 'name' => 'League Gothic',
456
+ 'url' => $fonts_dir . 'font-league-gothic.css',
457
+ );
458
+ $data['fonts'][] = array(
459
+ 'name' => 'fontawesome',
460
+ 'url' => $fonts_dir . 'font-awesome.css',
461
+ );
462
+ return $data;
463
+ }
464
+
465
+ /**
466
+ * Echoes the Javascript if not cached.
467
+ *
468
+ * Echoes the javascript with the correct content.
469
+ * Since the content is dinamic, i use the hash function.
470
+ *
471
+ * @param string $javascript
472
+ *
473
+ * @return void
474
+ */
475
+ private function _echo_javascript( $javascript ) {
476
+ $conditional_get = new HTTP_ConditionalGet( array(
477
+ 'contentHash' => md5( $javascript )
478
+ )
479
+ );
480
+ $conditional_get->sendHeaders();
481
+ if ( ! $conditional_get->cacheIsValid ) {
482
+ $http_encoder = new HTTP_Encoder( array(
483
+ 'content' => $javascript,
484
+ 'type' => 'text/javascript'
485
+ )
486
+ );
487
+ $http_encoder->encode();
488
+ $http_encoder->sendAll();
489
+ }
490
+ Ai1ec_Http_Response_Helper::stop( 0 );
491
+ }
492
+
493
+ /**
494
+ * Create the config object for requirejs.
495
+ *
496
+ * @return string
497
+ */
498
+ private function _create_require_js_config_object() {
499
+ $js_url = AI1EC_ADMIN_THEME_JS_URL;
500
+ $version = AI1EC_VERSION;
501
+ $namespace = self::REQUIRE_NAMESPACE;
502
+ $config = <<<JSC
503
+ $namespace.require.config( {
504
+ waitSeconds : 15,
505
+ urlArgs : 'ver=$version',
506
+ baseUrl : '$js_url'
507
+ } );
508
+ JSC;
509
+ return $config;
510
+ }
511
+
512
+ /**
513
+ * Check if we are in the calendar feeds page
514
+ *
515
+ * @return boolean TRUE if we are in the calendar feeds page FALSE otherwise
516
+ */
517
+ public function are_we_on_calendar_feeds_page() {
518
+ $path_details = pathinfo( $_SERVER["SCRIPT_NAME"] );
519
+ $post_type = isset( $_GET['post_type'] ) ? $_GET['post_type'] : FALSE;
520
+ $page = isset( $_GET['page'] ) ? $_GET['page'] : FALSE;
521
+ if( $post_type === FALSE || $page === FALSE ) {
522
+ return FALSE;
523
+ }
524
+ $is_calendar_feed_page = $path_details['basename'] === 'edit.php' &&
525
+ $post_type === 'ai1ec_event' &&
526
+ $page === 'all-in-one-event-calendar-feeds';
527
+ return $is_calendar_feed_page;
528
+ }
529
+
530
+ /**
531
+ * Add the link to render the javascript
532
+ *
533
+ * @param string $page
534
+ * @param boolean $backend
535
+ *
536
+ * @return void
537
+ */
538
+ public function add_link_to_render_js( $page, $backend ) {
539
+ $load_backend_script = 'false';
540
+ if ( true === $backend ) {
541
+ $load_backend_script = self::TRUE_PARAM;
542
+ }
543
+ $is_calendar_page = false;
544
+ if( true === is_page( $this->_settings->get( 'calendar_page_id' ) ) ) {
545
+ $is_calendar_page = self::TRUE_PARAM;
546
+ }
547
+ $url = $this->_template_link_helper->get_site_url() . '?' .
548
+ // Add the page to load
549
+ self::LOAD_JS_PARAMETER . '=' . $page . '&' .
550
+ // If we are in the backend, we must load the common scripts
551
+ self::IS_BACKEND_PARAMETER . '=' . $load_backend_script . '&' .
552
+ // If we are on the calendar page we must load the correct option
553
+ self::IS_CALENDAR_PAGE . '=' . $is_calendar_page;
554
+ if ( true === $backend ) {
555
+ $this->_scripts_helper->enqueue_script(
556
+ self::JS_HANDLE,
557
+ $url,
558
+ array( 'postbox' ),
559
+ true
560
+ );
561
+ } else {
562
+ $this->_scripts_helper->enqueue_script(
563
+ self::JS_HANDLE,
564
+ $url,
565
+ array(),
566
+ true
567
+ );
568
+ }
569
+ }
570
+
571
+ /**
572
+ * check if we are editing an event
573
+ *
574
+ * @return boolean TRUE if we are editing an event FALSE otherwise
575
+ */
576
+ private function _are_we_editing_an_event() {
577
+ $path_details = pathinfo( $_SERVER["SCRIPT_NAME"] );
578
+ $post_id = isset( $_GET['post'] ) ? $_GET['post'] : FALSE;
579
+ $action = isset( $_GET['action'] ) ? $_GET['action'] : FALSE;
580
+ if( $post_id === FALSE || $action === FALSE ) {
581
+ return FALSE;
582
+ }
583
+
584
+ $editing = (
585
+ 'post.php' === $path_details['basename'] &&
586
+ 'edit' === $action &&
587
+ $this->_aco->is_our_post_type( $post_id )
588
+ );
589
+ return $editing;
590
+ }
591
+
592
+ /**
593
+ * check if we are creating a new event
594
+ *
595
+ * @return boolean TRUE if we are creating a new event FALSE otherwise
596
+ */
597
+ private function _are_we_creating_a_new_event() {
598
+ $path_details = pathinfo( $_SERVER["SCRIPT_NAME"] );
599
+ $post_type = isset( $_GET['post_type'] ) ? $_GET['post_type'] : '';
600
+ return $path_details['basename'] === 'post-new.php' &&
601
+ $post_type === AI1EC_POST_TYPE;
602
+ }
603
+
604
+ /**
605
+ * Check if we are accessing the settings page
606
+ *
607
+ * @return boolean TRUE if we are accessing the settings page FALSE otherwise
608
+ */
609
+ private function _are_we_accessing_the_calendar_settings_page() {
610
+ $path_details = pathinfo( $_SERVER["SCRIPT_NAME"] );
611
+ $page = isset( $_GET['page'] ) ? $_GET['page'] : '';
612
+ return $path_details['basename'] === 'edit.php' &&
613
+ $page === AI1EC_PLUGIN_NAME . '-settings';
614
+ }
615
+
616
+ /**
617
+ * Check if we are editing less variables
618
+ *
619
+ * @return boolean TRUE if we are accessing a single event page FALSE otherwise
620
+ */
621
+ private function _are_we_editing_less_variables() {
622
+ $path_details = pathinfo( $_SERVER["SCRIPT_NAME"] );
623
+ $page = isset( $_GET['page'] ) ? $_GET['page'] : '';
624
+ return $path_details['basename'] === 'edit.php' && $page === AI1EC_PLUGIN_NAME . '-edit-css';
625
+ }
626
+
627
+ /**
628
+ * Check if we are accessing the events category page
629
+ *
630
+ * @return boolean TRUE if we are accessing the events category page FALSE otherwise
631
+ */
632
+ private function _are_we_editing_event_categories() {
633
+ $path_details = pathinfo( $_SERVER["SCRIPT_NAME"] );
634
+ $post_type = isset( $_GET['post_type'] ) ? $_GET['post_type'] : '';
635
+ return $path_details['basename'] === 'edit-tags.php' && $post_type === AI1EC_POST_TYPE;
636
+ }
637
+
638
+ /**
639
+ * Check if we are accessing a single event page
640
+ *
641
+ * @return boolean TRUE if we are accessing a single event page FALSE otherwise
642
+ */
643
+ private function _are_we_accessing_the_single_event_page() {
644
+ return $this->_aco->is_our_post_type();
645
+ }
646
+
647
+ }
app/controller/shutdown.php ADDED
@@ -0,0 +1,99 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * Controller that handles shutdown functions.
5
+ *
6
+ * @author Time.ly Network Inc.
7
+ * @since 2.0
8
+ *
9
+ * @package AI1EC
10
+ * @subpackage AI1EC.Controller
11
+ */
12
+ class Ai1ec_Shutdown_Controller {
13
+
14
+ /**
15
+ * @var array Map of object names and class names they represent to preserve
16
+ */
17
+ protected $_preserve = array(
18
+ 'wpdb' => 'wpdb',
19
+ 'wp_object_cache' => 'WP_Object_Cache',
20
+ );
21
+
22
+ /**
23
+ * @var array Map of object names and their representation from global scope
24
+ */
25
+ protected $_restorables = array();
26
+
27
+ /**
28
+ * @var array List of callbacks to be executed during shutdown sequence
29
+ */
30
+ protected $_callbacks = array();
31
+
32
+
33
+ /**
34
+ * Destructor
35
+ *
36
+ * Here processing of globals is made - values are replaced, callbacks
37
+ * are executed and globals are restored to the previous state.
38
+ *
39
+ * @return void Destructor does not return
40
+ */
41
+ public function __destruct() {
42
+ // replace globals from our internal store
43
+ $restore = array();
44
+ foreach ( $this->_preserve as $name => $class ) {
45
+ if (
46
+ ! isset( $GLOBALS[$name] ) ||
47
+ ! ( $GLOBALS[$name] instanceof $class )
48
+ ) {
49
+ $restore[$name] = NULL;
50
+ if ( isset( $GLOBALS[$name] ) ) {
51
+ $restore[$name] = $GLOBALS[$name];
52
+ }
53
+ $GLOBALS[$name] = $this->_restorables[$name];
54
+ }
55
+ }
56
+ // execute callbacks
57
+ foreach ( $this->_callbacks as $callback ) {
58
+ call_user_func( $callback );
59
+ }
60
+ // restore globals to previous state
61
+ foreach ( $restore as $name => $object ) {
62
+ if ( NULL === $object ) {
63
+ unset( $GLOBALS[$name] );
64
+ } else {
65
+ $GLOBALS[$name] = $object;
66
+ }
67
+ }
68
+ // destroy local references
69
+ foreach ( $this->_restorables as $name => $object ) {
70
+ unset( $object, $this->_restorables[$name] );
71
+ }
72
+ }
73
+
74
+ /**
75
+ * Register a callback to be executed during shutdown sequence
76
+ *
77
+ * @param callback $callback Valid PHP callback
78
+ *
79
+ * @return Ai1ec_Shutdown_Utility Self instance for chaining
80
+ */
81
+ public function register( $callback ) {
82
+ $this->_callbacks[] = $callback;
83
+ return $this;
84
+ }
85
+
86
+ /**
87
+ * Constructor
88
+ *
89
+ * Here global variables are referenced locally to ensure their preservation
90
+ *
91
+ * @return void Constructor does not return
92
+ */
93
+ public function __construct() {
94
+ foreach ( $this->_preserve as $name => $class ) {
95
+ $this->_restorables[$name] = $GLOBALS[$name];
96
+ }
97
+ }
98
+
99
+ }
app/exception/class-ai1ec-event-not-found.php DELETED
@@ -1,18 +0,0 @@
1
- <?php
2
- //
3
- // class-ai1ec-event-not-found.php
4
- // all-in-one-event-calendar
5
- //
6
- // Created by The Seed Studio on 2011-07-13.
7
- //
8
-
9
- /**
10
- * Ai1ec_Event_Not_Found class
11
- *
12
- * @package Exceptions
13
- * @author time.ly
14
- **/
15
- class Ai1ec_Event_Not_Found extends Exception {
16
-
17
- }
18
- // END class
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/exception/class-ai1ec-file-not-found.php DELETED
@@ -1,18 +0,0 @@
1
- <?php
2
- //
3
- // class-ai1ec-file-not-found.php
4
- // all-in-one-event-calendar
5
- //
6
- // Created by The Seed Studio on 2011-07-13.
7
- //
8
-
9
- /**
10
- * Ai1ec_File_Not_Found class
11
- *
12
- * @package Exceptions
13
- * @author time.ly
14
- **/
15
- class Ai1ec_File_Not_Found extends Exception {
16
-
17
- }
18
- // END class
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/exception/class-ai1ec-file-not-provided.php DELETED
@@ -1,18 +0,0 @@
1
- <?php
2
- //
3
- // class-ai1ec-file-not-provided.php
4
- // all-in-one-event-calendar
5
- //
6
- // Created by The Seed Studio on 2011-07-13.
7
- //
8
-
9
- /**
10
- * Ai1ec_File_Not_Provided class
11
- *
12
- * @package Exceptions
13
- * @author time.ly
14
- **/
15
- class Ai1ec_File_Not_Provided extends Exception {
16
-
17
- }
18
- // END class
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/exception/class-ai1ec-invalid-argument.php DELETED
@@ -1,18 +0,0 @@
1
- <?php
2
- //
3
- // class-ai1ec-invalid-argument.php
4
- // all-in-one-event-calendar
5
- //
6
- // Created by The Seed Studio on 2011-07-13.
7
- //
8
-
9
- /**
10
- * Ai1ec_Invalid_Argument class
11
- *
12
- * @package Exceptions
13
- * @author time.ly
14
- **/
15
- class Ai1ec_Invalid_Argument extends Exception {
16
-
17
- }
18
- // END class
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/helper/class-ai1ec-app-helper.php DELETED
@@ -1,1058 +0,0 @@
1
- <?php
2
- //
3
- // class-ai1ec-app-helper.php
4
- // all-in-one-event-calendar
5
- //
6
- // Created by The Seed Studio on 2011-07-13.
7
- //
8
-
9
- /**
10
- * Ai1ec_App_Helper class
11
- *
12
- * @package Helpers
13
- * @author time.ly
14
- **/
15
- class Ai1ec_App_Helper {
16
- /**
17
- * _instance class variable
18
- *
19
- * Class instance
20
- *
21
- * @var null | object
22
- **/
23
- private static $_instance = NULL;
24
-
25
- /**
26
- * Constructor
27
- *
28
- * Default constructor
29
- **/
30
- private function __construct() { }
31
-
32
- /**
33
- * get_instance function
34
- *
35
- * Return singleton instance
36
- *
37
- * @return object
38
- **/
39
- static function get_instance() {
40
- if( self::$_instance === NULL ) {
41
- self::$_instance = new self();
42
- }
43
-
44
- return self::$_instance;
45
- }
46
-
47
- /**
48
- * map_meta_cap function
49
- *
50
- * Assigns proper capability
51
- *
52
- * @return void
53
- **/
54
- function map_meta_cap( $caps, $cap, $user_id, $args ) {
55
- // If editing, deleting, or reading an event, get the post and post type object.
56
- if( 'edit_ai1ec_event' == $cap || 'delete_ai1ec_event' == $cap || 'read_ai1ec_event' == $cap ) {
57
- $post = get_post( $args[0] );
58
- $post_type = get_post_type_object( $post->post_type );
59
- /* Set an empty array for the caps. */
60
- $caps = array();
61
- }
62
-
63
- /* If editing an event, assign the required capability. */
64
- if( 'edit_ai1ec_event' == $cap ) {
65
- if( $user_id == $post->post_author )
66
- $caps[] = $post_type->cap->edit_posts;
67
- else
68
- $caps[] = $post_type->cap->edit_others_posts;
69
- }
70
-
71
- /* If deleting an event, assign the required capability. */
72
- else if( 'delete_ai1ec_event' == $cap ) {
73
- if( $user_id == $post->post_author )
74
- $caps[] = $post_type->cap->delete_posts;
75
- else
76
- $caps[] = $post_type->cap->delete_others_posts;
77
- }
78
-
79
- /* If reading a private event, assign the required capability. */
80
- else if( 'read_ai1ec_event' == $cap ) {
81
- if( 'private' != $post->post_status )
82
- $caps[] = 'read';
83
- elseif ( $user_id == $post->post_author )
84
- $caps[] = 'read';
85
- else
86
- $caps[] = $post_type->cap->read_private_posts;
87
- }
88
-
89
- /* Return the capabilities required by the user. */
90
- return $caps;
91
- }
92
-
93
- /**
94
- * create_post_type function
95
- *
96
- * Create event's custom post type
97
- * and registers events_categories and events_tags under
98
- * event's custom post type taxonomy
99
- *
100
- * @return void
101
- **/
102
- function create_post_type() {
103
- global $ai1ec_settings;
104
-
105
- // Create event contributor role with the same capabilities
106
- // as subscriber role, plus event managing capabilities - if we haven't done
107
- // so yet.
108
- if( ! get_role( 'ai1ec_event_assistant' ) ) {
109
- $caps = get_role( 'subscriber' )->capabilities;
110
- $role = add_role( 'ai1ec_event_assistant', 'Event Contributor', $caps );
111
- $role->add_cap( 'edit_ai1ec_events' );
112
- $role->add_cap( 'delete_ai1ec_event' );
113
- $role->add_cap( 'read' );
114
- }
115
-
116
- // Add event managing capabilities to administrator, editor, author. (The
117
- // last created capability is "manage_ai1ec_feeds", so check for that one.)
118
- if( ! get_role( 'administrator' )->has_cap( 'manage_ai1ec_feeds' ) ) {
119
- foreach( array( 'administrator', 'editor', 'author' ) as $role_name ) {
120
- $role = get_role( $role_name );
121
- // Read events.
122
- $role->add_cap( 'read_ai1ec_event' );
123
- // Edit events.
124
- $role->add_cap( 'edit_ai1ec_event' );
125
- $role->add_cap( 'edit_ai1ec_events' );
126
- $role->add_cap( 'edit_others_ai1ec_events' );
127
- $role->add_cap( 'edit_private_ai1ec_events' );
128
- $role->add_cap( 'edit_published_ai1ec_events' );
129
- // Delete events.
130
- $role->add_cap( 'delete_ai1ec_event' );
131
- $role->add_cap( 'delete_ai1ec_events' );
132
- $role->add_cap( 'delete_others_ai1ec_events' );
133
- $role->add_cap( 'delete_published_ai1ec_events' );
134
- $role->add_cap( 'delete_private_ai1ec_events' );
135
- // Publish events.
136
- $role->add_cap( 'publish_ai1ec_events' );
137
- // Read private events.
138
- $role->add_cap( 'read_private_ai1ec_events' );
139
- // Manage categories & tags.
140
- $role->add_cap( 'manage_events_categories' );
141
- // Manage calendar feeds.
142
- $role->add_cap( 'manage_ai1ec_feeds' );
143
-
144
- if( $role_name == 'administrator' ) {
145
- // Change calendar themes & manage calendar options.
146
- $role->add_cap( 'switch_ai1ec_themes' );
147
- $role->add_cap( 'manage_ai1ec_options' );
148
- }
149
- }
150
- }
151
-
152
- // ===============================
153
- // = labels for custom post type =
154
- // ===============================
155
- $labels = array(
156
- 'name' => _x( 'Events', 'Custom post type name', AI1EC_PLUGIN_NAME ),
157
- 'singular_name' => _x( 'Event', 'Custom post type name (singular)', AI1EC_PLUGIN_NAME ),
158
- 'add_new' => __( 'Add New', AI1EC_PLUGIN_NAME ),
159
- 'add_new_item' => __( 'Add New Event', AI1EC_PLUGIN_NAME ),
160
- 'edit_item' => __( 'Edit Event', AI1EC_PLUGIN_NAME ),
161
- 'new_item' => __( 'New Event', AI1EC_PLUGIN_NAME ),
162
- 'view_item' => __( 'View Event', AI1EC_PLUGIN_NAME ),
163
- 'search_items' => __( 'Search Events', AI1EC_PLUGIN_NAME ),
164
- 'not_found' => __( 'No Events found', AI1EC_PLUGIN_NAME ),
165
- 'not_found_in_trash' => __( 'No Events found in Trash', AI1EC_PLUGIN_NAME ),
166
- 'parent_item_colon' => __( 'Parent Event', AI1EC_PLUGIN_NAME ),
167
- 'menu_name' => __( 'Events', AI1EC_PLUGIN_NAME ),
168
- 'all_items' => $this->get_all_items_name()
169
- );
170
-
171
-
172
- // ================================
173
- // = support for custom post type =
174
- // ================================
175
- $supports = array( 'title', 'editor', 'comments', 'custom-fields', 'thumbnail' );
176
-
177
- // =============================
178
- // = args for custom post type =
179
- // =============================
180
- $args = array(
181
- 'labels' => $labels,
182
- 'public' => true,
183
- 'publicly_queryable' => true,
184
- 'show_ui' => true,
185
- 'show_in_menu' => true,
186
- 'query_var' => true,
187
- 'rewrite' => true,
188
- 'capability_type' => array( 'ai1ec_event', 'ai1ec_events' ),
189
- 'capabilities' => array(
190
- 'read_post' => 'read_ai1ec_event',
191
- 'edit_post' => 'edit_ai1ec_event',
192
- 'edit_posts' => 'edit_ai1ec_events',
193
- 'edit_others_posts' => 'edit_others_ai1ec_events',
194
- 'edit_private_posts' => 'edit_private_ai1ec_events',
195
- 'edit_published_posts' => 'edit_published_ai1ec_events',
196
- 'delete_post' => 'delete_ai1ec_event',
197
- 'delete_posts' => 'delete_ai1ec_events',
198
- 'delete_others_posts' => 'delete_others_ai1ec_events',
199
- 'delete_published_posts' => 'delete_published_ai1ec_events',
200
- 'delete_private_posts' => 'delete_private_ai1ec_events',
201
- 'publish_posts' => 'publish_ai1ec_events',
202
- 'read_private_posts' => 'read_private_ai1ec_events' ),
203
- 'has_archive' => true,
204
- 'hierarchical' => false,
205
- 'menu_position' => 5,
206
- 'supports' => $supports,
207
- 'exclude_from_search' => $ai1ec_settings->exclude_from_search,
208
- );
209
-
210
- // ========================================
211
- // = labels for event categories taxonomy =
212
- // ========================================
213
- $events_categories_labels = array(
214
- 'name' => _x( 'Event Categories', 'Event categories taxonomy', AI1EC_PLUGIN_NAME ),
215
- 'singular_name' => _x( 'Event Category', 'Event categories taxonomy (singular)', AI1EC_PLUGIN_NAME )
216
- );
217
-
218
- // ==================================
219
- // = labels for event tags taxonomy =
220
- // ==================================
221
- $events_tags_labels = array(
222
- 'name' => _x( 'Event Tags', 'Event tags taxonomy', AI1EC_PLUGIN_NAME ),
223
- 'singular_name' => _x( 'Event Tag', 'Event tags taxonomy (singular)', AI1EC_PLUGIN_NAME )
224
- );
225
-
226
- // ==================================
227
- // = labels for event feeds taxonomy =
228
- // ==================================
229
- $events_feeds_labels = array(
230
- 'name' => _x( 'Event Feeds', 'Event feeds taxonomy', AI1EC_PLUGIN_NAME ),
231
- 'singular_name' => _x( 'Event Feed', 'Event feed taxonomy (singular)', AI1EC_PLUGIN_NAME )
232
- );
233
-
234
- // ======================================
235
- // = args for event categories taxonomy =
236
- // ======================================
237
- $events_categories_args = array(
238
- 'labels' => $events_categories_labels,
239
- 'hierarchical' => true,
240
- 'rewrite' => array( 'slug' => 'events_categories' ),
241
- 'capabilities' => array(
242
- 'manage_terms' => 'manage_events_categories',
243
- 'edit_terms' => 'manage_events_categories',
244
- 'delete_terms' => 'manage_events_categories',
245
- 'assign_terms' => 'edit_ai1ec_events'
246
- )
247
- );
248
-
249
- // ================================
250
- // = args for event tags taxonomy =
251
- // ================================
252
- $events_tags_args = array(
253
- 'labels' => $events_tags_labels,
254
- 'hierarchical' => false,
255
- 'rewrite' => array( 'slug' => 'events_tags' ),
256
- 'capabilities' => array(
257
- 'manage_terms' => 'manage_events_categories',
258
- 'edit_terms' => 'manage_events_categories',
259
- 'delete_terms' => 'manage_events_categories',
260
- 'assign_terms' => 'edit_ai1ec_events'
261
- )
262
- );
263
-
264
- // ================================
265
- // = args for event feeds taxonomy =
266
- // ================================
267
- $events_feeds_args = array(
268
- 'labels' => $events_feeds_labels,
269
- 'hierarchical' => false,
270
- 'rewrite' => array( 'slug' => 'events_feeds' ),
271
- 'capabilities' => array(
272
- 'manage_terms' => 'manage_events_categories',
273
- 'edit_terms' => 'manage_events_categories',
274
- 'delete_terms' => 'manage_events_categories',
275
- 'assign_terms' => 'edit_ai1ec_events'
276
- ),
277
- 'public' => false // don't show taxonomy in admin UI
278
- );
279
-
280
- // ======================================
281
- // = register event categories taxonomy =
282
- // ======================================
283
- register_taxonomy( 'events_categories', array( AI1EC_POST_TYPE ), $events_categories_args );
284
-
285
- // ================================
286
- // = register event tags taxonomy =
287
- // ================================
288
- register_taxonomy( 'events_tags', array( AI1EC_POST_TYPE ), $events_tags_args );
289
-
290
- // ================================
291
- // = register event tags taxonomy =
292
- // ================================
293
- register_taxonomy( 'events_feeds', array( AI1EC_POST_TYPE ), $events_feeds_args );
294
-
295
- // ========================================
296
- // = register custom post type for events =
297
- // ========================================
298
- register_post_type( AI1EC_POST_TYPE, $args );
299
- }
300
-
301
- /**
302
- * taxonomy_filter_restrict_manage_posts function
303
- *
304
- * Adds filter dropdowns for event categories and event tags
305
- *
306
- * @return void
307
- **/
308
- function taxonomy_filter_restrict_manage_posts() {
309
- global $typenow;
310
-
311
- // =============================================
312
- // = add the dropdowns only on the events page =
313
- // =============================================
314
- if( $typenow == AI1EC_POST_TYPE ) {
315
- $filters = get_object_taxonomies( $typenow );
316
- foreach( $filters as $tax_slug ) {
317
- $tax_obj = get_taxonomy( $tax_slug );
318
- wp_dropdown_categories( array(
319
- 'show_option_all' => __( 'Show All ', AI1EC_PLUGIN_NAME ) . $tax_obj->label,
320
- 'taxonomy' => $tax_slug,
321
- 'name' => $tax_obj->name,
322
- 'orderby' => 'name',
323
- 'selected' => isset( $_GET[$tax_slug] ) ? $_GET[$tax_slug] : '',
324
- 'hierarchical' => $tax_obj->hierarchical,
325
- 'show_count' => true,
326
- 'hide_if_empty' => true
327
- ));
328
- }
329
- }
330
- }
331
-
332
- /**
333
- * get_all_items_name function
334
- *
335
- * If current user can publish events and there
336
- * is at least 1 event pending, append the pending
337
- * events number to the menu
338
- *
339
- * @return string
340
- **/
341
- function get_all_items_name() {
342
-
343
- // if current user can publish events
344
- if( current_user_can( 'publish_ai1ec_events' ) ) {
345
- // get all pending events
346
- $query = new WP_Query( array ( 'post_type' => 'ai1ec_event', 'post_status' => 'pending', 'posts_per_page' => -1, ) );
347
-
348
- // at least 1 pending event?
349
- if( $query->post_count > 0 ) {
350
- // append the pending events number to the menu
351
- return sprintf(
352
- __( 'All Events <span class="update-plugins count-%d" title="%d Pending Events"><span class="update-count">%d</span></span>', AI1EC_PLUGIN_NAME ),
353
- $query->post_count, $query->post_count, $query->post_count );
354
- }
355
- }
356
-
357
- // no pending events, or the user doesn't have sufficient capabilities
358
- return __( 'All Events', AI1EC_PLUGIN_NAME );
359
- }
360
-
361
- /**
362
- * taxonomy_filter_post_type_request function
363
- *
364
- * Adds filtering of events list by event tags and event categories
365
- *
366
- * @return void
367
- **/
368
- function taxonomy_filter_post_type_request( $query ) {
369
- global $pagenow, $typenow;
370
- if( 'edit.php' == $pagenow ) {
371
- $filters = get_object_taxonomies( $typenow );
372
- foreach( $filters as $tax_slug ) {
373
- $var = &$query->query_vars[$tax_slug];
374
- if( isset( $var ) ) {
375
- $term = null;
376
-
377
- if( is_numeric( $var ) )
378
- $term = get_term_by( 'id', $var, $tax_slug );
379
- else
380
- $term = get_term_by( 'slug', $var, $tax_slug );
381
-
382
- if( isset( $term->slug ) ) {
383
- $var = $term->slug;
384
- }
385
- }
386
- }
387
- }
388
- // ===========================
389
- // = Order by Event date ASC =
390
- // ===========================
391
- if( $typenow == 'ai1ec_event' ) {
392
- if( ! array_key_exists( 'orderby', $query->query_vars ) ) {
393
- $query->query_vars["orderby"] = 'ai1ec_event_date';
394
- $query->query_vars["order"] = 'desc';
395
- }
396
- }
397
- }
398
-
399
- /**
400
- * orderby function
401
- *
402
- * Orders events by event date
403
- *
404
- * @param string $orderby Orderby sql
405
- * @param object $wp_query
406
- *
407
- * @return void
408
- **/
409
- function orderby( $orderby, $wp_query ) {
410
- global $typenow, $wpdb, $post;
411
-
412
- if( $typenow == 'ai1ec_event' ) {
413
- $wp_query->query = wp_parse_args( $wp_query->query );
414
- $table_name = $wpdb->prefix . 'ai1ec_events';
415
- if( 'ai1ec_event_date' == @$wp_query->query['orderby'] ) {
416
- $orderby = "(SELECT start FROM {$table_name} WHERE post_id = $wpdb->posts.ID) " . $wp_query->get('order');
417
- } else if( empty( $wp_query->query['orderby'] ) ) {
418
- $orderby = "(SELECT start FROM {$table_name} WHERE post_id = $wpdb->posts.ID) " . 'desc';
419
- }
420
- }
421
- return $orderby;
422
- }
423
-
424
- /**
425
- * add_meta_boxes function
426
- *
427
- * Display event meta box when creating or editing an event.
428
- *
429
- * @return void
430
- **/
431
- function add_meta_boxes() {
432
- global $ai1ec_events_controller;
433
-
434
- add_meta_box(
435
- AI1EC_POST_TYPE,
436
- __( 'Event Details', AI1EC_PLUGIN_NAME ),
437
- array( &$ai1ec_events_controller, 'meta_box_view' ),
438
- AI1EC_POST_TYPE,
439
- 'normal',
440
- 'high'
441
- );
442
- }
443
-
444
- /**
445
- * screen_layout_columns function
446
- *
447
- * Since WordPress 2.8 we have to tell, that we support 2 columns!
448
- *
449
- * @return void
450
- **/
451
- function screen_layout_columns( $columns, $screen ) {
452
- global $ai1ec_settings;
453
-
454
- if( isset( $ai1ec_settings->settings_page ) && $screen == $ai1ec_settings->settings_page )
455
- $columns[$ai1ec_settings->settings_page] = 2;
456
-
457
- return $columns;
458
- }
459
-
460
- /**
461
- * change_columns function
462
- *
463
- * Adds Event date/time column to our custom post type
464
- * and renames Date column to Post Date
465
- *
466
- * @param array $columns Existing columns
467
- *
468
- * @return array Updated columns array
469
- **/
470
- function change_columns( $columns ) {
471
- $columns["date"] = __( 'Post Date', AI1EC_PLUGIN_NAME );
472
- $columns["ai1ec_event_date"] = __( 'Event date/time', AI1EC_PLUGIN_NAME );
473
- return $columns;
474
- }
475
-
476
- /**
477
- * custom_columns function
478
- *
479
- * Adds content for custom columns
480
- *
481
- * @return void
482
- **/
483
- function custom_columns( $column, $post_id ) {
484
- global $ai1ec_events_helper;
485
- switch( $column ) {
486
- case 'ai1ec_event_date':
487
- try {
488
- $e = new Ai1ec_Event( $post_id );
489
- echo $e->short_start_date . ' ' . $e->short_start_time . " - " . $e->short_end_date . ' ' .$e->short_end_time;
490
- } catch( Exception $e ) {
491
- // event wasn't found, output empty string
492
- echo "";
493
- }
494
- break;
495
- }
496
- }
497
-
498
- /**
499
- * sortable_columns function
500
- *
501
- * Enable sorting of columns
502
- *
503
- * @return void
504
- **/
505
- function sortable_columns( $columns ) {
506
- $columns["ai1ec_event_date"] = 'ai1ec_event_date';
507
- return $columns;
508
- }
509
-
510
- /**
511
- * get_param function
512
- *
513
- * Tries to return the parameter from POST and GET
514
- * incase it is missing, default value is returned
515
- *
516
- * @param string $param Parameter to return
517
- * @param mixed $default Default value
518
- *
519
- * @return mixed
520
- **/
521
- function get_param( $param, $default='' ) {
522
- if( isset( $_POST[$param] ) )
523
- return $_POST[$param];
524
- if( isset( $_GET[$param] ) )
525
- return $_GET[$param];
526
- return $default;
527
- }
528
-
529
- /**
530
- * get_param_delimiter_char function
531
- *
532
- * Returns the delimiter character in a link
533
- *
534
- * @param string $link Link to parse
535
- *
536
- * @return string
537
- **/
538
- function get_param_delimiter_char( $link ) {
539
- return strpos( $link, '?' ) === false ? '?' : '&';
540
- }
541
-
542
- /**
543
- * inject_categories function
544
- *
545
- * Displays event categories whenever post categories are requested
546
- *
547
- * @param array $terms Terms to be returned by get_terms()
548
- * @param array $taxonomies Taxonomies requested in get_terms()
549
- * @param array $args Args passed to get_terms()
550
- *
551
- * @return string|array If "category" taxonomy was requested, then returns
552
- * $terms with fake category pointing to calendar page
553
- * with its children being the event categories
554
- **/
555
- function inject_categories( $terms, $taxonomies, $args )
556
- {
557
- global $ai1ec_settings;
558
-
559
- if( in_array( 'category', $taxonomies ) )
560
- {
561
- // Create fake calendar page category
562
- $count_args = $args;
563
- $count_args['fields'] = 'count';
564
- $count = get_terms( 'events_categories', $count_args );
565
- $post = get_post( $ai1ec_settings->calendar_page_id );
566
- switch( $args['fields'] )
567
- {
568
- case 'all':
569
- $calendar = (object) array(
570
- 'term_id' => AI1EC_FAKE_CATEGORY_ID,
571
- 'name' => $post->post_title,
572
- 'slug' => $post->post_name,
573
- 'taxonomy' => 'events_categories',
574
- 'description' => '',
575
- 'parent' => 0,
576
- 'count' => $count,
577
- );
578
- break;
579
- case 'ids':
580
- $calendar = 'ai1ec_calendar';
581
- break;
582
- case 'names':
583
- $calendar = $post->post_title;
584
- break;
585
- }
586
- $terms[] = $calendar;
587
-
588
- if( $args['hierarchical'] ) {
589
- $children = get_terms( 'events_categories', $args );
590
- foreach( $children as &$child ) {
591
- if( is_object( $child ) && $child->parent == 0 )
592
- $child->parent = AI1EC_FAKE_CATEGORY_ID;
593
- $terms[] = $child;
594
- }
595
- }
596
- }
597
-
598
- return $terms;
599
- }
600
-
601
- /**
602
- * function calendar_term_link
603
- *
604
- * Corrects the URL for the calendar page when injected into the post
605
- * categories.
606
- *
607
- * @param string $link The normally generated link
608
- * @param object $term The term that we're getting the link for
609
- * @param string $taxonomy The name of the taxonomy of interest
610
- *
611
- * @return string The correct link to the calendar page
612
- */
613
- function calendar_term_link( $link, $term, $taxonomy )
614
- {
615
- global $ai1ec_calendar_helper;
616
-
617
- if( $taxonomy == 'events_categories' ) {
618
- if( $term->term_id == AI1EC_FAKE_CATEGORY_ID )
619
- $link = $ai1ec_calendar_helper->get_calendar_url( null );
620
- else
621
- $link = $ai1ec_calendar_helper->get_calendar_url( null,
622
- array( 'cat_ids' => array( $term->term_id ) )
623
- );
624
- }
625
-
626
- return $link;
627
- }
628
-
629
- /**
630
- * function selected_category_link
631
- *
632
- * Corrects the output of wp_list_categories so that the currently viewed
633
- * event category (in calendar view) has the "active" CSS class applied to it.
634
- *
635
- * @param string $output The normally generated output of wp_list_categories()
636
- * @param object $args The args passed to wp_list_categories()
637
- *
638
- * @return string The corrected output
639
- */
640
- function selected_category_link( $output, $args )
641
- {
642
- global $ai1ec_calendar_controller, $ai1ec_settings;
643
-
644
- // First check if current page is calendar
645
- if( is_page( $ai1ec_settings->calendar_page_id ) )
646
- {
647
- $cat_ids = array_filter( explode( ',', $ai1ec_calendar_controller->get_requested_categories() ), 'is_numeric' );
648
- if( $cat_ids ) {
649
- // Mark each filtered event category link as selected
650
- foreach( $cat_ids as $cat_id ) {
651
- $output = str_replace(
652
- 'class="cat-item cat-item-' . $cat_id . '"',
653
- 'class="cat-item cat-item-' . $cat_id . ' current-cat current_page_item"',
654
- $output );
655
- }
656
- // Mark calendar page link as selected parent
657
- $output = str_replace(
658
- 'class="cat-item cat-item-' . AI1EC_FAKE_CATEGORY_ID . '"',
659
- 'class="cat-item cat-item-' . AI1EC_FAKE_CATEGORY_ID . ' current-cat-parent"',
660
- $output );
661
- } else {
662
- // No categories filtered, so mark calendar page link as selected
663
- $output = str_replace(
664
- 'class="cat-item cat-item-' . AI1EC_FAKE_CATEGORY_ID . '"',
665
- 'class="cat-item cat-item-' . AI1EC_FAKE_CATEGORY_ID . ' current-cat current_page_item"',
666
- $output );
667
- }
668
- }
669
-
670
- return $output;
671
- }
672
-
673
- /**
674
- * Display notice when themes are unavailable
675
- *
676
- * Provide some instructions how to re-install themes.
677
- *
678
- * @return void Method doesn't return
679
- */
680
- public function admin_notices_themes() {
681
- if (
682
- ! $this->_are_notices_available( 2 ) ||
683
- isset( $_GET['page'] ) &&
684
- AI1EC_PLUGIN_NAME . '-install-themes' === $_GET['page']
685
- ) {
686
- return NULL;
687
- }
688
- global $ai1ec_view_helper;
689
- $args = array(
690
- 'label' => __( 'All-in-One Event Calendar Notice', AI1EC_PLUGIN_NAME ),
691
- 'msg' => sprintf(
692
- __(
693
- '<p><strong>Core calendar files are not installed.</strong></p>' .
694
- '<p>Please visit the <a href="%s">Themes Installer page</a> to fix this issue. Until then, the calendar will be unavailable.</p>',
695
- AI1EC_PLUGIN_NAME
696
- ),
697
- admin_url( AI1EC_INSTALL_THEMES_BASE_URL )
698
- ),
699
- );
700
- $ai1ec_view_helper->display_admin( 'admin_notices.php', $args );
701
- }
702
-
703
- /**
704
- * Notify the user about anything special.
705
- *
706
- * @return void
707
- */
708
- function admin_notices() {
709
- if ( ! $this->_are_notices_available( 1 ) ) {
710
- return NULL;
711
- }
712
- global $ai1ec_view_helper,
713
- $ai1ec_settings,
714
- $plugin_page,
715
- $ai1ec_themes_controller;
716
-
717
- // If calendar page or time zone has not been set, this is a fresh install.
718
- // Additionally, if we're not already updating the settings, alert user
719
- // appropriately that the calendar is not properly set up.
720
- if (
721
- (
722
- ! $ai1ec_settings->calendar_page_id ||
723
- ! get_option( 'timezone_string' )
724
- ) &&
725
- ! isset( $_REQUEST['ai1ec_save_settings'] )
726
- ) {
727
- $args = array();
728
- $messages = array();
729
-
730
- // Display messages for blog admin.
731
- if ( current_user_can( 'manage_ai1ec_options' ) ) {
732
- // If on the settings page, instruct user as to what to do.
733
- if ( $plugin_page == AI1EC_PLUGIN_NAME . '-settings' ) {
734
- if ( ! $ai1ec_settings->calendar_page_id ) {
735
- $messages[] = __(
736
- 'Select an option in the <strong>Calendar page</strong> dropdown list.',
737
- AI1EC_PLUGIN_NAME
738
- );
739
- }
740
- if ( ! get_option( 'timezone_string' ) ) {
741
- $messages[] = __(
742
- 'Select an option in the <strong>Timezone</strong> dropdown list.',
743
- AI1EC_PLUGIN_NAME
744
- );
745
- }
746
- $messages[] = __(
747
- 'Click <strong>Update Settings</strong>.',
748
- AI1EC_PLUGIN_NAME
749
- );
750
- } else { // Else, not on the settings page, so direct user there.
751
- $msg = sprintf(
752
- __(
753
- 'The plugin is installed, but has not been configured. <a href="%s">Click here to set it up now &raquo;</a>',
754
- AI1EC_PLUGIN_NAME
755
- ),
756
- admin_url( AI1EC_SETTINGS_BASE_URL )
757
- );
758
- $messages[] = $msg;
759
- }
760
- } else { // Else display messages for other blog users
761
- $messages[] = __(
762
- 'The plugin is installed, but has not been configured. Please log in as an Administrator to set it up.',
763
- AI1EC_PLUGIN_NAME
764
- );
765
- }
766
-
767
- // Format notice message.
768
- if ( count($messages) > 1 ) {
769
- $args['msg'] = __(
770
- '<p>To set up the plugin:</p>',
771
- AI1EC_PLUGIN_NAME
772
- );
773
- $args['msg'] .= '<ol><li>';
774
- $args['msg'] .= implode( '</li><li>', $messages );
775
- $args['msg'] .= '</li></ol>';
776
- } else {
777
- $args['msg'] = '<p>' . $messages[0] . '</p>';
778
- }
779
- $args['label'] = __(
780
- 'All-in-One Event Calendar Notice',
781
- AI1EC_PLUGIN_NAME
782
- );
783
- $ai1ec_view_helper->display_admin( 'admin_notices.php', $args );
784
- }
785
-
786
- if ( ! $this->_are_notices_available( 0 ) ) {
787
- return NULL;
788
- }
789
-
790
- if ( $ai1ec_settings->show_standard_notice ) {
791
- // Display Lite version unsupported notice.
792
- $args = array(
793
- 'msg' => '<p class="timely ai1ec-upgrade-notice"><span><strong>' .
794
- __( 'All-in-One Event Calendar Notice', AI1EC_PLUGIN_NAME ) .
795
- ':</strong> ' .
796
- __( 'You are using the <strong>"Lite"</strong> Timely calendar. Visit ', AI1EC_PLUGIN_NAME ) .
797
- '</span> <a href="' .
798
- esc_attr( "http://time.ly" ) .
799
- '" target="_BLANK">' .
800
- __( '<span><strong>our website</strong></span>', AI1EC_PLUGIN_NAME ) .
801
- '</a> and follow ' .
802
- '<a href=" ' .
803
- esc_attr( 'http://support.time.ly/difference-lite-standard-versions/' ) .
804
- '" target="_BLANK">' .
805
- __( '<span><strong>this guide</strong></span>', AI1EC_PLUGIN_NAME ) .
806
- '</a> to upgrade to the free "Standard" version with additional features.',
807
- 'button' => (object) array(
808
- 'class' => 'ai1ec-dismiss-standard-notification',
809
- 'value' => __( 'Dismiss', AI1EC_PLUGIN_NAME ),
810
- ),
811
- );
812
- $ai1ec_view_helper->display_admin( 'admin_notices.php', $args );
813
- }
814
-
815
- // Display introductory video notice if not disabled.
816
- if ( $ai1ec_settings->show_intro_video ) {
817
- $args = array(
818
- 'label' => __( 'Welcome to the All-in-One Event Calendar, by Timely', AI1EC_PLUGIN_NAME ),
819
- 'msg' => sprintf(
820
- '<div class="timely"><a href="#ai1ec-video-modal" data-toggle="modal" ' .
821
- 'class="button-primary pull-left">%s</a>' .
822
- '<div class="pull-left">&nbsp;</div></div>',
823
- __( 'Watch the introductory video »', AI1EC_PLUGIN_NAME )
824
- ),
825
- 'button' => (object) array(
826
- 'class' => 'ai1ec-dismiss-intro-video',
827
- 'value' => __( 'Dismiss', AI1EC_PLUGIN_NAME ),
828
- ),
829
- );
830
- $ai1ec_view_helper->display_admin( 'admin_notices.php', $args );
831
- $args = array(
832
- 'modal_id' => 'ai1ec-video-modal',
833
- 'video_container_id' => 'ai1ec-video',
834
- 'title' => __(
835
- 'Introducing the All-in-One Event Calendar, by Timely',
836
- AI1EC_PLUGIN_NAME
837
- ),
838
- 'youtube_id' => 'XJ-KHOqBKuQ',
839
- 'footer' => sprintf(
840
- '<div style="text-align: center;">' .
841
- '<a class="btn btn-large btn-primary" href="%s">' .
842
- '<i class="timely-icon-arrow-down timely-icon-large"></i> %s</a></div>',
843
- 'http://support.time.ly/manually-upgrading-the-calendar/',
844
- __( 'Upgrade to Standard for Free', AI1EC_PLUGIN_NAME )
845
- ),
846
- // Required CSS and JS may not have has been attached. Let template know
847
- // about it so that it can be dynamically added to <head> (it's now too
848
- // late in the WP bootstrap to add CSS/JS to <head>).
849
- 'css_loaded' => wp_style_is( 'timely-bootstrap' ),
850
- 'css_url' => AI1EC_ADMIN_THEME_CSS_URL . '/bootstrap.min.css',
851
- 'js_loaded' => wp_script_is( 'timely-bootstrap-modal' ),
852
- 'js_url' => AI1EC_ADMIN_THEME_JS_URL . '/bootstrap-modal.js',
853
- );
854
- $ai1ec_view_helper->display_admin( 'video_modal.php', $args );
855
- }
856
-
857
- // No themes available notice.
858
- if ( ! $ai1ec_themes_controller->are_themes_available() ) {
859
- $args = array(
860
- 'label' => __( 'All-in-One Event Calendar Notice', AI1EC_PLUGIN_NAME ),
861
- 'msg' => sprintf(
862
- __( '<p><strong>Core calendar files are not installed.</strong></p>' .
863
- '<p>Our automated install couldn\'t install certain core files automatically. ' .
864
- 'You will need to install these files manually by following these steps:</p>' .
865
- '<ol><li>Gain access to your WordPress files. Either direct filesystem access or FTP access is fine.</li>' .
866
- '<li>Navigate to the <strong>%s</strong> folder.</li>' .
867
- '<li>Copy the <strong>%s</strong> folder and all of its contents into the <strong>%s</strong> folder.</li>' .
868
- '<li>You should now have a folder named <strong>%s</strong> containing all the same files and sub-folders as <strong>%s</strong> does.</li>' .
869
- '<li>Refresh this page and if this notice is gone, the core files are installed.</li></ol>', AI1EC_PLUGIN_NAME ),
870
- AI1EC_PATH,
871
- AI1EC_THEMES_FOLDER,
872
- WP_CONTENT_DIR,
873
- WP_CONTENT_DIR . '/' . AI1EC_THEMES_FOLDER,
874
- AI1EC_PATH . '/' . AI1EC_THEMES_FOLDER )
875
- );
876
- $ai1ec_view_helper->display_admin( 'admin_notices.php', $args );
877
- }
878
-
879
- // Outdated themes notice (on all pages except update themes page).
880
- if (
881
- $plugin_page != AI1EC_PLUGIN_NAME . '-update-themes' &&
882
- $ai1ec_themes_controller->are_themes_outdated()
883
- ) {
884
- $args = array(
885
- 'label' => __( 'All-in-One Event Calendar Notice', AI1EC_PLUGIN_NAME ),
886
- 'msg' => sprintf(
887
- __( '<p><strong>Core calendar files are out of date.</strong> ' .
888
- 'We have found updates for some of your core calendar files and you should update them now to ensure proper functioning of your calendar.</p>' .
889
- '<p><strong>Warning:</strong> If you have previously modified any core calendar files, ' .
890
- 'your changes may be lost during update. Please make a backup of all modifications before proceeding.</p>' .
891
- '<p>Once you are ready, please <a href="%s">update your core calendar files</a>.</p>', AI1EC_PLUGIN_NAME ),
892
- admin_url( AI1EC_UPDATE_THEMES_BASE_URL )
893
- ),
894
- );
895
- $ai1ec_view_helper->display_admin( 'admin_notices.php', $args );
896
- }
897
-
898
- if ( $ai1ec_settings->show_data_notification ) {
899
- $args = array(
900
- 'label' => __( 'All-in-One Event Calendar Notice', AI1EC_PLUGIN_NAME ),
901
- 'msg' =>
902
- sprintf(
903
- __( '<p>We would like to collect some basic information about how your calendar works in order to deliver a better ' .
904
- 'and faster calendar system and one that will help you promote your events even more.</p>' .
905
- '<p>You can find more detailed information by <a href="%s" target="_blank">clicking here</a>.</p>' .
906
- '<p>You may opt in by checking the <strong>Publicize, promote, and share my events</strong> checkbox located on the <a href="%s">Settings page</a>.</p>', AI1EC_PLUGIN_NAME ),
907
- 'http://time.ly/event-search-calendar',
908
- admin_url( AI1EC_SETTINGS_BASE_URL )
909
- ),
910
- 'button' => (object) array(
911
- 'class' => 'ai1ec-dismiss-notification',
912
- 'value' => __( 'Dismiss', AI1EC_PLUGIN_NAME ),
913
- ),
914
- );
915
- $ai1ec_view_helper->display_admin( 'admin_notices.php', $args );
916
- }
917
-
918
- }
919
-
920
- /**
921
- * Check whereas our notices should be displayed on this page.
922
- *
923
- * Limits notices to Ai1EC pages and WordPress "Plugins", "Updates" pages.
924
- * Important notices are also displayable in WordPress "Dashboard".
925
- * Levels of importance (see $importance) are as following:
926
- * - 0 - messages limited to Ai1EC pages;
927
- * - 1 - messages limited to [0] and Plugins/Updates pages;
928
- * - 2 - messages limited to [1] and Dashboard.
929
- *
930
- * @param int $importance The level of importance. See above for details.
931
- *
932
- * @return bool Availability
933
- */
934
- protected function _are_notices_available( $importance = 0 ) {
935
- // In CRON `get_current_screen()` is not present
936
- // and we wish to have notice on all "our" pages
937
- if (
938
- isset( $_GET['page'] ) &&
939
- 0 === strncasecmp(
940
- $_GET['page'],
941
- AI1EC_PLUGIN_NAME,
942
- strlen( AI1EC_PLUGIN_NAME )
943
- ) ||
944
- isset( $_GET['post_type'] ) &&
945
- AI1EC_POST_TYPE === $_GET['post_type'] ||
946
- ! function_exists( 'get_current_screen' )
947
- ) {
948
- return true;
949
- }
950
- if ( $importance < 1 ) {
951
- return false;
952
- }
953
- $screen = get_current_screen();
954
- $allow_on = array(
955
- 'plugins',
956
- 'update-core',
957
- );
958
- if ( $importance > 1 ) {
959
- $allow_on[] = 'dashboard';
960
- }
961
- if (
962
- is_object( $screen ) &&
963
- isset( $screen->id ) &&
964
- in_array( $screen->id, $allow_on )
965
- ) {
966
- return true;
967
- }
968
- return false;
969
- }
970
-
971
- /**
972
- * Add Events items to "Right Now" widget in Dashboard.
973
- *
974
- * @return void
975
- */
976
- function right_now_content_table_end() {
977
- $num_events = wp_count_posts( AI1EC_POST_TYPE );
978
- $num_cats = wp_count_terms( 'events_categories' );
979
- $num_tags = wp_count_terms( 'events_tags' );
980
-
981
- // Events.
982
- $num = number_format_i18n( $num_events->publish );
983
- $text = _n( 'Event', 'Events', $num_events->publish );
984
- if ( current_user_can( 'edit_ai1ec_events' ) ) {
985
- $num = "<a href='edit.php?post_type=" . AI1EC_POST_TYPE . "'>$num</a>";
986
- $text = "<a href='edit.php?post_type=" . AI1EC_POST_TYPE . "'>$text</a>";
987
- }
988
- echo '<td class="first b b-ai1ec-event">' . $num . '</td>';
989
- echo '<td class="t ai1ec-event">' . $text . '</td>';
990
-
991
- echo '</tr><tr>';
992
-
993
- // Event categories.
994
- $num = number_format_i18n( $num_cats );
995
- $text = _n( 'Event Category', 'Event Categories', $num_cats );
996
- if ( current_user_can( 'manage_events_categories' ) ) {
997
- $num = "<a href='edit-tags.php?taxonomy=events_categories'>$num</a>";
998
- $text = "<a href='edit-tags.php?taxonomy=events_categories'>$text</a>";
999
- }
1000
- echo '<td class="first b b-events-categories">' . $num . '</td>';
1001
- echo '<td class="t events-categories">' . $text . '</td>';
1002
-
1003
- echo '</tr><tr>';
1004
-
1005
- // Event tags.
1006
- $num = number_format_i18n( $num_tags );
1007
- $text = _n( 'Event Tag', 'Event Tags', $num_tags );
1008
- if ( current_user_can( 'manage_events_categories' ) ) {
1009
- $num = "<a href='edit-tags.php?taxonomy=events_tags'>$num</a>";
1010
- $text = "<a href='edit-tags.php?taxonomy=events_tags'>$text</a>";
1011
- }
1012
- echo '<td class="first b b-events-tags">' . $num . '</td>';
1013
- echo '<td class="t events-tags">' . $text . '</td>';
1014
- }
1015
-
1016
- /**
1017
- * admin_enqueue_scripts function
1018
- *
1019
- * Enqueue any scripts and styles in the admin side, depending on context.
1020
- *
1021
- * @return void
1022
- */
1023
- function admin_enqueue_scripts( $hook_suffix ) {
1024
- global $ai1ec_settings, $ai1ec_view_helper;
1025
-
1026
- // Common styles.
1027
- $ai1ec_view_helper->admin_enqueue_style( 'ai1ec-admin', 'admin.css' );
1028
- $ai1ec_view_helper->admin_enqueue_style( 'timely-bootstrap', 'bootstrap.min.css' );
1029
-
1030
- switch( $hook_suffix ) {
1031
- // Event lists.
1032
- // Widgets screen.
1033
- case 'widgets.php':
1034
- // Scripts.
1035
- $ai1ec_view_helper->admin_enqueue_script( 'ai1ec-widget', 'widget.js', array( 'jquery' ), AI1EC_VERSION );
1036
- // Styles.
1037
- $ai1ec_view_helper->admin_enqueue_style( 'ai1ec-widget', 'widget.css', array(), AI1EC_VERSION );
1038
- break;
1039
-
1040
- // Calendar settings & feeds screens.
1041
- case $ai1ec_settings->settings_page:
1042
- case $ai1ec_settings->feeds_page:
1043
- // Scripts.
1044
- wp_enqueue_script( 'common' );
1045
- wp_enqueue_script( 'wp-lists' );
1046
- wp_enqueue_script( 'postbox' );
1047
-
1048
- $ai1ec_view_helper->admin_enqueue_script( 'ai1ec-settings', 'settings.js', array( 'jquery' ) );
1049
- wp_localize_script( 'ai1ec-settings', 'ai1ec_settings', array(
1050
- 'page' => $ai1ec_settings->settings_page,
1051
- ) );
1052
- // Styles.
1053
- $ai1ec_view_helper->admin_enqueue_style( 'ai1ec-settings', 'settings.css' );
1054
- break;
1055
- }
1056
- }
1057
- }
1058
- // END class
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/helper/class-ai1ec-calendar-helper.php DELETED
@@ -1,1171 +0,0 @@
1
- <?php
2
- //
3
- // class-ai1ec-calendar-helper.php
4
- // all-in-one-event-calendar
5
- //
6
- // Created by The Seed Studio on 2011-07-13.
7
- //
8
-
9
- /**
10
- * Ai1ec_Calendar_Helper class
11
- *
12
- * @package Helpers
13
- * @author time.ly
14
- **/
15
- class Ai1ec_Calendar_Helper {
16
- /**
17
- * _instance class variable
18
- *
19
- * Class instance
20
- *
21
- * @var null | object
22
- **/
23
- private static $_instance = NULL;
24
-
25
- /**
26
- * Constructor
27
- *
28
- * Default constructor
29
- **/
30
- private function __construct() { }
31
-
32
- /**
33
- * get_instance function
34
- *
35
- * Return singleton instance
36
- *
37
- * @return object
38
- **/
39
- static function get_instance() {
40
- if( self::$_instance === NULL ) {
41
- self::$_instance = new self();
42
- }
43
-
44
- return self::$_instance;
45
- }
46
-
47
- /**
48
- * get_events_for_month function
49
- *
50
- * Return an array of all dates for the given month as an associative
51
- * array, with each element's value being another array of event objects
52
- * representing the events occuring on that date.
53
- *
54
- * @param int $time the UNIX timestamp of a date within the desired month
55
- * @param array $filter Array of filters for the events returned:
56
- * ['cat_ids'] => non-associatative array of category IDs
57
- * ['tag_ids'] => non-associatative array of tag IDs
58
- * ['post_ids'] => non-associatative array of post IDs
59
- *
60
- * @return array array of arrays as per function description
61
- **/
62
- function get_events_for_month( $time, $filter = array() )
63
- {
64
- global $ai1ec_events_helper;
65
-
66
- $days_events = array();
67
-
68
- $bits = $ai1ec_events_helper->gmgetdate( $time );
69
- $last_day = gmdate( 't', $time );
70
-
71
- $start_time = $the_first = gmmktime( 0, 0, 0, $bits['mon'], 1, $bits['year'] );
72
- $end_time = $the_last = gmmktime( 0, 0, 0, $bits['mon'], $last_day + 1, $bits['year'] );
73
-
74
- $month_events = $this->get_events_between( $start_time, $end_time, $filter, TRUE );
75
-
76
- // ==========================================
77
- // = Iterate through each date of the month =
78
- // ==========================================
79
- for ( $day = 1; $day <= $last_day; $day++ ) {
80
- $start_time = gmmktime( 0, 0, 0, $bits['mon'], $day, $bits['year'] );
81
- $end_time = gmmktime( 0, 0, 0, $bits['mon'], $day + 1, $bits['year'] );
82
-
83
- // Itemize events that fall under the current day
84
- $_events = array();
85
- $_allday_events = array();
86
- $_multiday_events = array();
87
- foreach ( $month_events as $event ) {
88
- $event_start = $ai1ec_events_helper->gmt_to_local( $event->start );
89
- $event_end = $ai1ec_events_helper->gmt_to_local( $event->end );
90
- // Add this event if:
91
- // 1. we are populating the 1st & this event starts before the 1st, or
92
- // 2. this event starts on the currently populated day
93
- if ( $day == 1 && $event_start < $the_first ||
94
- $event_start >= $start_time && $event_start < $end_time ) {
95
- // Set multiday properties. TODO: Should these be made event object
96
- // properties? They probably shouldn't be saved to the DB, so I'm not
97
- // sure. Just creating properties dynamically for now.
98
- if ( $event_start < $the_first ) {
99
- $event->start_truncated = TRUE;
100
- }
101
- if ( $event_end >= $the_last ) {
102
- $event->end_truncated = TRUE;
103
- }
104
- // Categorize event.
105
- if ( $event->allday ) {
106
- $_allday_events[] = $event;
107
- }
108
- elseif ( $event->multiday ) {
109
- $_multiday_events[] = $event;
110
- }
111
- else {
112
- $_events[] = $event;
113
- }
114
- }
115
- }
116
-
117
- $days_events[$day] = array_merge( $_multiday_events, $_allday_events, $_events );
118
- }
119
-
120
- return apply_filters( 'ai1ec_get_events_for_month', $days_events, $time, $filter );
121
- }
122
-
123
- /**
124
- * get_month_cell_array function
125
- *
126
- * Return an array of weeks, each containing an array of days, each
127
- * containing the date for the day ['date'] (if inside the month) and
128
- * the events ['events'] (if any) for the day, and a boolean ['today']
129
- * indicating whether that day is today.
130
- *
131
- * @param int $timestamp UNIX timestamp of the 1st day of the desired
132
- * month to display
133
- * @param array $days_events list of events for each day of the month in
134
- * the format returned by get_events_for_month()
135
- *
136
- * @return void
137
- **/
138
- function get_month_cell_array( $timestamp, $days_events )
139
- {
140
- global $ai1ec_settings, $ai1ec_events_helper;
141
-
142
- // Decompose date into components, used for calculations below
143
- $bits = $ai1ec_events_helper->gmgetdate( $timestamp );
144
- $today = $ai1ec_events_helper->gmgetdate( $ai1ec_events_helper->gmt_to_local( time() ) ); // Used to flag today's cell
145
-
146
- // Figure out index of first table cell
147
- $first_cell_index = gmdate( 'w', $timestamp );
148
- // Modify weekday based on start of week setting
149
- $first_cell_index = ( 7 + $first_cell_index - $ai1ec_settings->week_start_day ) % 7;
150
-
151
- // Get the last day of the month
152
- $last_day = gmdate( 't', $timestamp );
153
- $last_timestamp = gmmktime( 0, 0, 0, $bits['mon'], $last_day, $bits['year'] );
154
- // Figure out index of last table cell
155
- $last_cell_index = gmdate( 'w', $last_timestamp );
156
- // Modify weekday based on start of week setting
157
- $last_cell_index = ( 7 + $last_cell_index - $ai1ec_settings->week_start_day ) % 7;
158
-
159
- $weeks = array();
160
- $week = 0;
161
- $weeks[$week] = array();
162
-
163
- // Insert any needed blank cells into first week
164
- for( $i = 0; $i < $first_cell_index; $i++ ) {
165
- $weeks[$week][] = array( 'date' => null, 'events' => array() );
166
- }
167
-
168
- // Insert each month's day and associated events
169
- for( $i = 1; $i <= $last_day; $i++ ) {
170
- $weeks[$week][] = array(
171
- 'date' => $i,
172
- 'today' =>
173
- $bits['year'] == $today['year'] &&
174
- $bits['mon'] == $today['mon'] &&
175
- $i == $today['mday'],
176
- 'events' => $days_events[$i]
177
- );
178
- // If reached the end of the week, increment week
179
- if( count( $weeks[$week] ) == 7 )
180
- $week++;
181
- }
182
-
183
- // Insert any needed blank cells into last week
184
- for( $i = $last_cell_index + 1; $i < 7; $i++ ) {
185
- $weeks[$week][] = array( 'date' => null, 'events' => array() );
186
- }
187
-
188
- return $weeks;
189
- }
190
-
191
- /**
192
- * get_week_cell_array function
193
- *
194
- * Return an associative array of weekdays, indexed by the day's date,
195
- * starting the day given by $timestamp, each element an associative array
196
- * containing three elements:
197
- * ['today'] => whether the day is today
198
- * ['allday'] => non-associative ordered array of events that are all-day
199
- * ['notallday'] => non-associative ordered array of non-all-day events to
200
- * display for that day, each element another associative
201
- * array like so:
202
- * ['top'] => how many minutes offset from the start of the day
203
- * ['height'] => how many minutes this event spans
204
- * ['indent'] => how much to indent this event to accommodate multiple
205
- * events occurring at the same time (0, 1, 2, etc., to
206
- * be multiplied by whatever desired px/em amount)
207
- * ['event'] => event data object
208
- *
209
- * @param int $timestamp the UNIX timestamp of the first day of the week
210
- * @param array $filter Array of filters for the events returned:
211
- * ['cat_ids'] => non-associatative array of category IDs
212
- * ['tag_ids'] => non-associatative array of tag IDs
213
- * ['post_ids'] => non-associatative array of post IDs
214
- *
215
- * @return array array of arrays as per function description
216
- **/
217
- function get_week_cell_array( $timestamp, $filter = array() )
218
- {
219
- global $ai1ec_events_helper, $ai1ec_settings;
220
-
221
- // Decompose given date and current time into components, used below
222
- $bits = $ai1ec_events_helper->gmgetdate( $timestamp );
223
- $now = $ai1ec_events_helper->gmgetdate( $ai1ec_events_helper->gmt_to_local( time() ) );
224
-
225
- // Do one SQL query to find all events for the week, including spanning
226
- $week_events = $this->get_events_between(
227
- $timestamp,
228
- gmmktime( 0, 0, 0, $bits['mon'], $bits['mday'] + 7, $bits['year'] ),
229
- $filter,
230
- true );
231
-
232
- // Split up events on a per-day basis
233
- $all_events = array();
234
- foreach( $week_events as $evt ) {
235
- $evt_start = $ai1ec_events_helper->gmt_to_local( $evt->start );
236
- $evt_end = $ai1ec_events_helper->gmt_to_local( $evt->end );
237
-
238
- // Iterate through each day of the week and generate new event object
239
- // based on this one for each day that it spans
240
- for( $day = $bits['mday']; $day < $bits['mday'] + 7; $day++ ) {
241
- $day_start = gmmktime( 0, 0, 0, $bits['mon'], $day, $bits['year'] );
242
- $day_end = gmmktime( 0, 0, 0, $bits['mon'], $day + 1, $bits['year'] );
243
-
244
- // If event falls on this day, make a copy.
245
- if( $evt_end > $day_start && $evt_start < $day_end ) {
246
- $_evt = clone $evt;
247
- if( $evt_start < $day_start ) {
248
- // If event starts before this day, adjust copy's start time
249
- $_evt->start = $ai1ec_events_helper->local_to_gmt( $day_start );
250
- $_evt->start_truncated = true;
251
- }
252
- if( $evt_end > $day_end ) {
253
- // If event ends after this day, adjust copy's end time
254
- $_evt->end = $ai1ec_events_helper->local_to_gmt( $day_end );
255
- $_evt->end_truncated = true;
256
- }
257
-
258
- // Place copy of event in appropriate category
259
- if( $_evt->allday || $_evt->multiday)
260
- $all_events[$day_start]['allday'][] = $_evt;
261
- else
262
- $all_events[$day_start]['notallday'][] = $_evt;
263
- }
264
- }
265
- }
266
-
267
- // This will store the returned array
268
- $days = array();
269
- // =========================================
270
- // = Iterate through each date of the week =
271
- // =========================================
272
- for( $day = $bits['mday']; $day < $bits['mday'] + 7; $day++ )
273
- {
274
- $day_date = gmmktime( 0, 0, 0, $bits['mon'], $day, $bits['year'] );
275
- // Re-fetch date bits, since $bits['mday'] + 7 might be in the next month
276
- $day_bits = $ai1ec_events_helper->gmgetdate( $day_date );
277
-
278
- // Initialize empty arrays for this day if no events to minimize warnings
279
- if( ! isset( $all_events[$day_date]['allday'] ) ) $all_events[$day_date]['allday'] = array();
280
- if( ! isset( $all_events[$day_date]['notallday'] ) ) $all_events[$day_date]['notallday'] = array();
281
-
282
- $notallday = array();
283
- $evt_stack = array( 0 ); // Stack to keep track of indentation
284
- foreach( $all_events[$day_date]['notallday'] as $evt )
285
- {
286
- $start_bits = $ai1ec_events_helper->gmgetdate( $ai1ec_events_helper->gmt_to_local( $evt->start ) );
287
-
288
- // Calculate top and bottom edges of current event
289
- $top = $start_bits['hours'] * 60 + $start_bits['minutes'];
290
- $bottom = min( $top + $evt->getDuration() / 60, 1440 );
291
-
292
- // While there's more than one event in the stack and this event's top
293
- // position is beyond the last event's bottom, pop the stack
294
- while( count( $evt_stack ) > 1 && $top >= end( $evt_stack ) )
295
- array_pop( $evt_stack );
296
- // Indentation is number of stacked events minus 1
297
- $indent = count( $evt_stack ) - 1;
298
- // Push this event onto the top of the stack
299
- array_push( $evt_stack, $bottom );
300
-
301
- $notallday[] = array(
302
- 'top' => $top,
303
- 'height' => $bottom - $top,
304
- 'indent' => $indent,
305
- 'event' => $evt,
306
- );
307
- }
308
-
309
- $days[$day_date] = array(
310
- 'today' =>
311
- $day_bits['year'] == $now['year'] &&
312
- $day_bits['mon'] == $now['mon'] &&
313
- $day_bits['mday'] == $now['mday'],
314
- 'allday' => $all_events[$day_date]['allday'],
315
- 'notallday' => $notallday,
316
- );
317
- }
318
-
319
- return apply_filters( 'ai1ec_get_week_cell_array', $days, $timestamp, $filter );
320
- }
321
-
322
- /**
323
- * get_oneday_cell_array function
324
- *
325
- * Return an associative array of weekdays, indexed by the day's date,
326
- * starting the day given by $timestamp, each element an associative array
327
- * containing three elements:
328
- * ['today'] => whether the day is today
329
- * ['allday'] => non-associative ordered array of events that are all-day
330
- * ['notallday'] => non-associative ordered array of non-all-day events to
331
- * display for that day, each element another associative
332
- * array like so:
333
- * ['top'] => how many minutes offset from the start of the day
334
- * ['height'] => how many minutes this event spans
335
- * ['indent'] => how much to indent this event to accommodate multiple
336
- * events occurring at the same time (0, 1, 2, etc., to
337
- * be multiplied by whatever desired px/em amount)
338
- * ['event'] => event data object
339
- *
340
- * @param int $timestamp the UNIX timestamp of the first day of the week
341
- * @param array $filter Array of filters for the events returned:
342
- * ['cat_ids'] => non-associatative array of category IDs
343
- * ['tag_ids'] => non-associatative array of tag IDs
344
- * ['post_ids'] => non-associatative array of post IDs
345
- *
346
- * @return array array of arrays as per function description
347
- **/
348
- function get_oneday_cell_array( $timestamp, $filter = array() )
349
- {
350
- global $ai1ec_events_helper, $ai1ec_settings;
351
-
352
- // Decompose given date and current time into components, used below
353
- $bits = $ai1ec_events_helper->gmgetdate( $timestamp );
354
- $now = $ai1ec_events_helper->gmgetdate( $ai1ec_events_helper->gmt_to_local( time() ) );
355
- $day_events = $this->get_events_between( $timestamp, gmmktime( 0, 0, 0, $bits['mon'], $bits['mday'] + 1, $bits['year'] ), $filter, true );
356
-
357
- // Split up events on a per-day basis
358
- $all_events = array();
359
-
360
- foreach( $day_events as $evt ) {
361
- $evt_start = $ai1ec_events_helper->gmt_to_local( $evt->start );
362
- $evt_end = $ai1ec_events_helper->gmt_to_local( $evt->end );
363
-
364
- // generate new event object
365
- // based on this one day
366
- $day_start = gmmktime( 0, 0, 0, $bits['mon'], $bits['mday'], $bits['year'] );
367
- $day_end = gmmktime( 0, 0, 0, $bits['mon'], $bits['mday']+1, $bits['year'] );
368
-
369
- // If event falls on this day, make a copy.
370
- if( $evt_end > $day_start && $evt_start < $day_end ) {
371
- $_evt = clone $evt;
372
- if( $evt_start < $day_start ) {
373
- // If event starts before this day, adjust copy's start time
374
- $_evt->start = $ai1ec_events_helper->local_to_gmt( $day_start );
375
- $_evt->start_truncated = true;
376
- }
377
- if( $evt_end > $day_end ) {
378
- // If event ends after this day, adjust copy's end time
379
- $_evt->end = $ai1ec_events_helper->local_to_gmt( $day_end );
380
- $_evt->end_truncated = true;
381
- }
382
-
383
- // Place copy of event in appropriate category
384
- if( $_evt->allday || $_evt->multiday)
385
- $all_events[$day_start]['allday'][] = $_evt;
386
- else
387
- $all_events[$day_start]['notallday'][] = $_evt;
388
- }
389
- }
390
-
391
- // This will store the returned array
392
- $days = array();
393
- $day = $bits['mday'];
394
-
395
- $day_date = gmmktime( 0, 0, 0, $bits['mon'], $day, $bits['year'] );
396
- // Re-fetch date bits, since $bits['mday'] + 1 might be in the next month
397
- $day_bits = $ai1ec_events_helper->gmgetdate( $day_date );
398
-
399
- // Initialize empty arrays for this day if no events to minimize warnings
400
- if( ! isset( $all_events[$day_date]['allday'] ) ) $all_events[$day_date]['allday'] = array();
401
- if( ! isset( $all_events[$day_date]['notallday'] ) ) $all_events[$day_date]['notallday'] = array();
402
-
403
- $notallday = array();
404
- $evt_stack = array( 0 ); // Stack to keep track of indentation
405
- foreach( $all_events[$day_date]['notallday'] as $evt )
406
- {
407
- $start_bits = $ai1ec_events_helper->gmgetdate( $ai1ec_events_helper->gmt_to_local( $evt->start ) );
408
-
409
- // Calculate top and bottom edges of current event
410
- $top = $start_bits['hours'] * 60 + $start_bits['minutes'];
411
- $bottom = min( $top + $evt->getDuration() / 60, 1440 );
412
-
413
- // While there's more than one event in the stack and this event's top
414
- // position is beyond the last event's bottom, pop the stack
415
- while( count( $evt_stack ) > 1 && $top >= end( $evt_stack ) )
416
- array_pop( $evt_stack );
417
- // Indentation is number of stacked events minus 1
418
- $indent = count( $evt_stack ) - 1;
419
- // Push this event onto the top of the stack
420
- array_push( $evt_stack, $bottom );
421
-
422
- $notallday[] = array(
423
- 'top' => $top,
424
- 'height' => $bottom - $top,
425
- 'indent' => $indent,
426
- 'event' => $evt,
427
- );
428
- }
429
-
430
- $days[$day_date] = array(
431
- 'today' =>
432
- $day_bits['year'] == $now['year'] &&
433
- $day_bits['mon'] == $now['mon'] &&
434
- $day_bits['mday'] == $now['mday'],
435
- 'allday' => $all_events[$day_date]['allday'],
436
- 'notallday' => $notallday,
437
- );
438
-
439
- // =========================================
440
- // = Set one oneday events =
441
- // =========================================
442
-
443
- return apply_filters( 'ai1ec_get_oneday_cell_array', $days, $timestamp, $filter );
444
- }
445
-
446
- /**
447
- * get_events_between function
448
- *
449
- * Return all events starting after the given start time and before the
450
- * given end time that the currently logged in user has permission to view.
451
- * If $spanning is true, then also include events that span this
452
- * period. All-day events are returned first.
453
- *
454
- * @param int $start_time limit to events starting after this (local) UNIX time
455
- * @param int $end_time limit to events starting before this (local) UNIX time
456
- * @param array $filter Array of filters for the events returned:
457
- * ['cat_ids'] => non-associatative array of category IDs
458
- * ['tag_ids'] => non-associatative array of tag IDs
459
- * ['post_ids'] => non-associatative array of post IDs
460
- * @param bool $spanning also include events that span this period
461
- *
462
- * @return array list of matching event objects
463
- **/
464
- function get_events_between( $start_time, $end_time, $filter, $spanning = false ) {
465
-
466
- global $wpdb, $ai1ec_events_helper;
467
-
468
- // Convert timestamps to MySQL format in GMT time
469
- $start_time = $ai1ec_events_helper->local_to_gmt( $start_time );
470
- $end_time = $ai1ec_events_helper->local_to_gmt( $end_time );
471
-
472
- // Query arguments
473
- $args = array( $start_time, $end_time );
474
-
475
- // Get post status Where snippet and associated SQL arguments
476
- $this->_get_post_status_sql( $post_status_where, $args );
477
-
478
- // Get the Join (filter_join) and Where (filter_where) statements based on
479
- // $filter elements specified
480
- $this->_get_filter_sql( $filter );
481
-
482
- $query = $wpdb->prepare(
483
- "SELECT p.*, e.post_id, i.id AS instance_id, " .
484
- "UNIX_TIMESTAMP( i.start ) AS start, " .
485
- "UNIX_TIMESTAMP( i.end ) AS end, " .
486
- // Treat event instances that span 24 hours as all-day
487
- "IF( e.allday, e.allday, i.end = DATE_ADD( i.start, INTERVAL 1 DAY ) ) AS allday, " .
488
- "e.recurrence_rules, e.exception_rules, e.recurrence_dates, e.exception_dates, " .
489
- "e.venue, e.country, e.address, e.city, e.province, e.postal_code, " .
490
- "e.show_map, e.contact_name, e.contact_phone, e.contact_email, e.cost, " .
491
- "e.ical_feed_url, e.ical_source_url, e.ical_organizer, e.ical_contact, e.ical_uid " .
492
- "FROM {$wpdb->prefix}ai1ec_events e " .
493
- "INNER JOIN $wpdb->posts p ON p.ID = e.post_id " .
494
- "INNER JOIN {$wpdb->prefix}ai1ec_event_instances i ON e.post_id = i.post_id " .
495
- $filter['filter_join'] .
496
- "WHERE post_type = '" . AI1EC_POST_TYPE . "' " .
497
- "AND " .
498
- ( $spanning ? "i.end > FROM_UNIXTIME( %d ) AND i.start < FROM_UNIXTIME( %d ) "
499
- : "i.start >= FROM_UNIXTIME( %d ) AND i.start < FROM_UNIXTIME( %d ) " ) .
500
- $filter['filter_where'] .
501
- $post_status_where .
502
- "ORDER BY allday DESC, i.start ASC, post_title ASC",
503
- $args );
504
-
505
- $events = $wpdb->get_results( $query, ARRAY_A );
506
- foreach( $events as &$event ) {
507
- $event = new Ai1ec_Event( $event );
508
- }
509
-
510
- return $events;
511
- }
512
-
513
- /**
514
- * get_events_relative_to function
515
- *
516
- * Return all events starting after the given reference time, limiting the
517
- * result set to a maximum of $limit items, offset by $page_offset. A
518
- * negative $page_offset can be provided, which will return events *before*
519
- * the reference time, as expected.
520
- *
521
- * @param int $time limit to events starting after this (local) UNIX time
522
- * @param int $limit return a maximum of this number of items
523
- * @param int $page_offset offset the result set by $limit times this number
524
- * @param array $filter Array of filters for the events returned.
525
- * ['cat_ids'] => non-associatative array of category IDs
526
- * ['tag_ids'] => non-associatative array of tag IDs
527
- * ['post_ids'] => non-associatative array of post IDs
528
- * @param int $last_day Last day (time), that was displayed
529
- *
530
- * @return array five-element array:
531
- * ['events'] an array of matching event objects
532
- * ['prev'] true if more previous events
533
- * ['next'] true if more next events
534
- * ['date_first'] UNIX timestamp (date part) of first event
535
- * ['date_last'] UNIX timestamp (date part) of last event
536
- **/
537
- function get_events_relative_to( $time, $limit = 0, $page_offset = 0, $filter = array(), $last_day = null ) {
538
-
539
- global $wpdb, $ai1ec_events_helper;
540
-
541
- // Figure out what the beginning of the day is to properly query all-day
542
- // events; then convert to GMT time
543
- $bits = $ai1ec_events_helper->gmgetdate( $time );
544
-
545
- // Even if there ARE more than 5 times the limit results - we shall not
546
- // try to fetch and display these, as it would crash system
547
- $upper_boundary = ( false !== $last_day ) ? 5 * $limit : $limit;
548
-
549
- // Convert timestamp to GMT time
550
- $time = $ai1ec_events_helper->local_to_gmt( $time );
551
-
552
- // Query arguments
553
- $args = array( $time );
554
-
555
- if( $page_offset >= 0 )
556
- $first_record = $page_offset * $limit;
557
- else
558
- $first_record = ( -$page_offset - 1 ) * $limit;
559
-
560
- // Get post status Where snippet and associated SQL arguments
561
- $this->_get_post_status_sql( $post_status_where, $args );
562
-
563
- // Get the Join (filter_join) and Where (filter_where) statements based on
564
- // $filter elements specified
565
- $this->_get_filter_sql( $filter );
566
-
567
- $filter_date_clause = ( $page_offset >= 0 )
568
- ? 'i.end >= FROM_UNIXTIME( %d ) '
569
- : 'i.start < FROM_UNIXTIME( %d ) ';
570
- $order_direction = ( $page_offset >= 0 ) ? 'ASC' : 'DESC';
571
- if ( false !== $last_day ) {
572
- if ( 0 == $last_day ) {
573
- $last_day = (int)$_SERVER['REQUEST_TIME'];
574
- }
575
- $filter_date_clause = ' i.start ';
576
- if ( $page_offset < 0 ) {
577
- $filter_date_clause .= '<';
578
- $order_direction = 'DESC';
579
- } else {
580
- $filter_date_clause .= '>';
581
- $order_direction = 'ASC';
582
- }
583
- $filter_date_clause .= ' FROM_UNIXTIME( %d ) ';
584
- $args[0] = $last_day;
585
- $first_record = 0;
586
- }
587
-
588
- $query = $wpdb->prepare(
589
- 'SELECT SQL_CALC_FOUND_ROWS p.*, e.post_id, i.id AS instance_id, ' .
590
- 'UNIX_TIMESTAMP( i.start ) AS start, ' .
591
- 'UNIX_TIMESTAMP( i.end ) AS end, ' .
592
- // Treat event instances that span 24 hours as all-day
593
- 'IF( e.allday, e.allday, i.end = DATE_ADD( i.start, INTERVAL 1 DAY ) ) AS allday, ' .
594
- 'e.recurrence_rules, e.exception_rules, e.recurrence_dates, e.exception_dates, ' .
595
- 'e.venue, e.country, e.address, e.city, e.province, e.postal_code, ' .
596
- 'e.show_map, e.contact_name, e.contact_phone, e.contact_email, e.cost, ' .
597
- 'e.ical_feed_url, e.ical_source_url, e.ical_organizer, e.ical_contact, e.ical_uid ' .
598
- 'FROM ' . $wpdb->prefix . 'ai1ec_events e ' .
599
- 'INNER JOIN ' . $wpdb->posts . ' p ON e.post_id = p.ID ' .
600
- 'INNER JOIN ' . $wpdb->prefix . 'ai1ec_event_instances i ON e.post_id = i.post_id ' .
601
- $filter['filter_join'] .
602
- "WHERE post_type = '" . AI1EC_POST_TYPE . "' " .
603
- 'AND ' . $filter_date_clause .
604
- $filter['filter_where'] .
605
- $post_status_where .
606
- // Reverse order when viewing negative pages, to get correct set of
607
- // records. Then reverse results later to order them properly.
608
- 'ORDER BY i.start ' . $order_direction .
609
- ', post_title ' . $order_direction .
610
- ' LIMIT ' . $first_record . ', ' . $upper_boundary,
611
- $args );
612
-
613
- $events = $wpdb->get_results( $query, ARRAY_A );
614
-
615
- // Limit the number of records to convert to data-object
616
- $events = $this->_limit_result_set( $events, $limit, ( false !== $last_day ) );
617
-
618
- // Reorder records if in negative page offset
619
- if( $page_offset < 0 ) $events = array_reverse( $events );
620
-
621
- $date_first = $date_last = null;
622
- foreach ( $events as &$event ) {
623
- if ( null === $date_first ) {
624
- $date_first = $event['start'];
625
- }
626
- $date_last = $event['start'];
627
- $event = new Ai1ec_Event( $event );
628
- }
629
-
630
- // Find out if there are more records in the current nav direction
631
- $more = $wpdb->get_var( 'SELECT FOUND_ROWS()' ) > $first_record + $limit;
632
-
633
- // Navigating in the future
634
- if( $page_offset > 0 ) {
635
- $prev = true;
636
- $next = $more;
637
- }
638
- // Navigating in the past
639
- elseif( $page_offset < 0 ) {
640
- $prev = $more;
641
- $next = true;
642
- }
643
- // Navigating from the reference time
644
- else {
645
- $query = $wpdb->prepare(
646
- "SELECT COUNT(*) " .
647
- "FROM {$wpdb->prefix}ai1ec_events e " .
648
- "INNER JOIN {$wpdb->prefix}ai1ec_event_instances i ON e.post_id = i.post_id " .
649
- "INNER JOIN $wpdb->posts p ON e.post_id = p.ID " .
650
- $filter['filter_join'] .
651
- "WHERE post_type = '" . AI1EC_POST_TYPE . "' " .
652
- "AND i.start < FROM_UNIXTIME( %d ) " .
653
- $filter['filter_where'] .
654
- $post_status_where,
655
- $args );
656
- $prev = $wpdb->get_var( $query );
657
- $next = $more;
658
- }
659
- return array(
660
- 'events' => $events,
661
- 'prev' => $prev,
662
- 'next' => $next,
663
- 'date_first' => $date_first,
664
- 'date_last' => $date_last,
665
- );
666
- }
667
-
668
- /**
669
- * _limit_result_set function
670
- *
671
- * Slice given number of events from list, with exception when all
672
- * events from last day shall be included.
673
- *
674
- * @param array $events List of events to slice
675
- * @param int $limit Number of events to slice-off
676
- * @param bool $last_day Set to true to include all events from last day ignoring {$limit}
677
- *
678
- * @return array Sliced events list
679
- */
680
- protected function _limit_result_set( array $events, $limit, $last_day )
681
- {
682
- global $ai1ec_events_helper;
683
- $limited_events = array();
684
- $start_day_previous = null;
685
- foreach ( $events as $event ) {
686
- $start_day = $ai1ec_events_helper->date_to_gmdatestamp( $event['start'] );
687
- if ( --$limit < 0 ) {
688
- if ( true === $last_day ) {
689
- if ( $start_day != $start_day_previous ) {
690
- break;
691
- }
692
- } else {
693
- break;
694
- }
695
- }
696
- $limited_events[] = $event;
697
- $start_day_previous = $start_day;
698
- }
699
- return $limited_events;
700
- }
701
-
702
- /**
703
- * get_agenda_date_array function
704
- *
705
- * Breaks down the given ordered array of event objects into dates, and
706
- * outputs an ordered array of two-element associative arrays in the
707
- * following format:
708
- * key: localized UNIX timestamp of date
709
- * value:
710
- * ['events'] => two-element associatative array broken down thus:
711
- * ['allday'] => all-day events occurring on this day
712
- * ['notallday'] => all other events occurring on this day
713
- * ['today'] => whether or not this date is today
714
- *
715
- * @param array $events
716
- *
717
- * @return array
718
- **/
719
- function get_agenda_date_array( $events ) {
720
- global $ai1ec_events_helper;
721
-
722
- $dates = array();
723
-
724
- // Classify each event into a date/allday category
725
- foreach( $events as $event ) {
726
- $date = $ai1ec_events_helper->gmt_to_local( $event->start );
727
- $date = $ai1ec_events_helper->gmgetdate( $date );
728
- $timestamp = gmmktime( 0, 0, 0, $date['mon'], $date['mday'], $date['year'] );
729
- // Ensure all-day & non all-day categories are created in correct order.
730
- if ( ! isset( $dates[$timestamp]['events'] ) ) {
731
- $dates[$timestamp]['events'] = array(
732
- 'allday' => array(),
733
- 'notallday' => array(),
734
- );
735
- }
736
- // Add the event.
737
- $category = $event->allday ? 'allday' : 'notallday';
738
- $dates[$timestamp]['events'][$category][] = $event;
739
- }
740
-
741
- // Flag today
742
- $today = $ai1ec_events_helper->gmt_to_local( time() );
743
- $today = $ai1ec_events_helper->gmgetdate( $today );
744
- $today = gmmktime( 0, 0, 0, $today['mon'], $today['mday'], $today['year'] );
745
- if( isset( $dates[$today] ) )
746
- $dates[$today]['today'] = true;
747
-
748
- return $dates;
749
- }
750
-
751
- /**
752
- * get_calendar_url function
753
- *
754
- * Returns the URL of the configured calendar page in the default view,
755
- * optionally preloaded at the month containing the given event (rather than
756
- * today's date), and optionally prefiltered by the given filters.
757
- *
758
- * @param object|null $event The event to focus the calendar on
759
- * @param array $filter Array of filters for the events returned.
760
- * ['cat_ids'] => non-associatative array of category IDs
761
- * ['tag_ids'] => non-associatative array of tag IDs
762
- * ['post_ids'] => non-associatative array of post IDs
763
- *
764
- * @return string The URL for this calendar
765
- **/
766
- function get_calendar_url( $event = null, $filter = array() ) {
767
- global $ai1ec_settings, $ai1ec_events_helper, $ai1ec_app_helper, $wpdb;
768
-
769
- $url = get_permalink( $ai1ec_settings->calendar_page_id );
770
-
771
- if( $event )
772
- {
773
- $url .= $ai1ec_app_helper->get_param_delimiter_char( $url );
774
-
775
- switch( $ai1ec_settings->default_calendar_view )
776
- {
777
- case 'month':
778
- // Get components of localized timstamps and calculate month offset
779
- $today = $ai1ec_events_helper->gmgetdate( $ai1ec_events_helper->gmt_to_local( time() ) );
780
- $desired = $ai1ec_events_helper->gmgetdate( $ai1ec_events_helper->gmt_to_local( $event->start ) );
781
- $month_offset =
782
- ( $desired['year'] - $today['year'] ) * 12 +
783
- $desired['mon'] - $today['mon'];
784
-
785
- $url .= "ai1ec_month_offset=$month_offset";
786
- break;
787
-
788
- case 'week':
789
- // Get components of localized timstamps and calculate week offset
790
- /* TODO - code this; first need to find out first day of week based on week start day,
791
- then calculate how many weeks off we are from that one
792
- $today = $ai1ec_events_helper->gmgetdate( $ai1ec_events_helper->gmt_to_local( time() ) );
793
- $desired = $ai1ec_events_helper->gmgetdate( $ai1ec_events_helper->gmt_to_local( $event->start ) );
794
- $week_offset =
795
- ( $desired['year'] - $today['year'] ) * 12 +
796
- $desired['mon'] - $today['mon'];
797
-
798
- $url .= "ai1ec_week_offset=$week_offset";*/
799
- break;
800
-
801
- case 'agenda':
802
- // Find out how many event instances are between today's first
803
- // instance and the desired event's instance
804
- $now = $ai1ec_events_helper->local_to_gmt( time() );
805
- $after_today = $event->end >= $now;
806
- $query = $wpdb->prepare(
807
- "SELECT COUNT(*) FROM {$wpdb->prefix}ai1ec_events e " .
808
- "INNER JOIN $wpdb->posts p ON e.post_id = p.ID " .
809
- "INNER JOIN {$wpdb->prefix}ai1ec_event_instances i ON e.post_id = i.post_id " .
810
- "WHERE post_type = '" . AI1EC_POST_TYPE . "' " .
811
- "AND post_status = 'publish' " .
812
- ( $after_today
813
- ? "AND i.end >= FROM_UNIXTIME( %d ) AND i.end < FROM_UNIXTIME( %d ) "
814
- : "AND i.start < FROM_UNIXTIME( %d ) AND i.start >= FROM_UNIXTIME( %d ) "
815
- ) .
816
- "ORDER BY i.start ASC",
817
- array( $now, $after_today ? $event->end : $event->start ) );
818
- $count = $wpdb->get_var( $query );
819
- // ( $count - 1 ) below solves boundary case for first event of each agenda page
820
- $page_offset = intval( ( $count - 1 ) / $ai1ec_settings->agenda_events_per_page );
821
- if( ! $after_today ) $page_offset = -1 - $page_offset;
822
-
823
- $url .= "ai1ec_page_offset=$page_offset";
824
- break;
825
- }
826
-
827
- $url .= "&ai1ec_active_event=$event->post_id";
828
- }
829
-
830
- // Add filter parameters
831
- foreach( $filter as $key => $val ) {
832
- if( $val ) {
833
- $url .= $ai1ec_app_helper->get_param_delimiter_char( $url ) .
834
- "ai1ec_$key=" . join( ',', $val );
835
- }
836
- }
837
-
838
- return $url;
839
- }
840
-
841
- /**
842
- * get_weekdays function
843
- *
844
- * Returns a list of abbreviated weekday names starting on the configured
845
- * week start day setting.
846
- *
847
- * @return array
848
- **/
849
- function get_weekdays() {
850
- global $ai1ec_settings;
851
- static $weekdays;
852
-
853
- if( ! isset( $weekdays ) ) {
854
- $time = strtotime( 'next Sunday' );
855
- $time = strtotime( "+{$ai1ec_settings->week_start_day} days", $time );
856
-
857
- $weekdays = array();
858
- for( $i = 0; $i < 7; $i++ ) {
859
- $weekdays[] = date_i18n( 'D', $time );
860
- $time = strtotime( '+1 day', $time ); // Add a day
861
- }
862
- }
863
- return $weekdays;
864
- }
865
-
866
- /**
867
- * Returns a non-associative array of four links for the day view of the
868
- * calendar:
869
- * previous day, next day, in that order.
870
- * Each element's key is an associative array containing the link's ID
871
- * ['id'], text ['text'] and value to assign to link's href ['href'].
872
- *
873
- * @param int $cur_offset day offset of current day, needed for hrefs
874
- *
875
- * @return array array of link information as described above
876
- */
877
- function get_oneday_pagination_links( $cur_offset ) {
878
- global $ai1ec_events_helper;
879
-
880
- $links = array();
881
-
882
- // Base timestamp on offset week
883
- $bits = $ai1ec_events_helper->gmgetdate( $ai1ec_events_helper->gmt_to_local( time() ) );
884
- $bits['mday'] += $cur_offset;
885
-
886
- /* translators: "%s" represents the week's starting date */
887
- $links[] = array(
888
- 'id' => 'ai1ec-prev-day',
889
- 'text' =>
890
- '‹ ' .
891
- date_i18n( __( 'j F Y', AI1EC_PLUGIN_NAME ), gmmktime( 0, 0, 0, $bits['mon'], $bits['mday'] - 1, $bits['year'] )
892
- ),
893
- 'href' => '#action=ai1ec_oneday&ai1ec_oneday_offset=' . ( $cur_offset - 1 ),
894
- );
895
- $links[] = array(
896
- 'id' => 'ai1ec-next-day',
897
- 'text' =>
898
- date_i18n( __( 'j F Y', AI1EC_PLUGIN_NAME ), gmmktime( 0, 0, 0, $bits['mon'], $bits['mday'] + 1, $bits['year'] ))
899
- .' ›',
900
- 'href' => '#action=ai1ec_oneday&ai1ec_oneday_offset=' . ( $cur_offset + 1 ),
901
- );
902
-
903
- return $links;
904
- }
905
-
906
- /**
907
- * get_month_pagination_links function
908
- *
909
- * Returns a non-associative array of four links for the month view of the
910
- * calendar:
911
- * previous year, previous month, next month, and next year, in that order.
912
- * Each element's key is an associative array containing the link's ID
913
- * ['id'], text ['text'] and value to assign to link's href ['href'].
914
- *
915
- * @param int $cur_offset month offset of current month, needed for hrefs
916
- *
917
- * @return array array of link information as described above
918
- **/
919
- function get_month_pagination_links( $cur_offset ) {
920
- global $ai1ec_events_helper;
921
-
922
- $links = array();
923
-
924
- // Base timestamp on offset month
925
- $bits = $ai1ec_events_helper->gmgetdate( $ai1ec_events_helper->gmt_to_local( time() ) );
926
- $bits['mon'] += $cur_offset;
927
- // 'mon' may now be out of range (< 1 or > 12), so recreate $bits to make sane
928
- $bits = $ai1ec_events_helper->gmgetdate( gmmktime( 0, 0, 0, $bits['mon'], 1, $bits['year'] ) );
929
-
930
- $links[] = array(
931
- 'id' => 'ai1ec-prev-year',
932
- 'text' => '« ' . ( $bits['year'] - 1 ),
933
- 'href' => '#action=ai1ec_month&ai1ec_month_offset=' . ( $cur_offset - 12 ),
934
- );
935
- $links[] = array(
936
- 'id' => 'ai1ec-prev-month',
937
- 'text' => '‹ ' . date_i18n( 'M', gmmktime( 0, 0, 0, $bits['mon'] - 1, 1, $bits['year'] ), true ),
938
- 'href' => '#action=ai1ec_month&ai1ec_month_offset=' . ( $cur_offset - 1 ),
939
- );
940
- $links[] = array(
941
- 'id' => 'ai1ec-next-month',
942
- 'text' => date_i18n( 'M', gmmktime( 0, 0, 0, $bits['mon'] + 1, 1, $bits['year'] ), true ) . ' ›',
943
- 'href' => '#action=ai1ec_month&ai1ec_month_offset=' . ( $cur_offset + 1 ),
944
- );
945
- $links[] = array(
946
- 'id' => 'ai1ec-next-year',
947
- 'text' => ( $bits['year'] + 1 ) . ' »',
948
- 'href' => '#action=ai1ec_month&ai1ec_month_offset=' . ( $cur_offset + 12 ),
949
- );
950
-
951
- return $links;
952
- }
953
-
954
- /**
955
- * get_week_pagination_links function
956
- *
957
- * Returns a non-associative array of two links for the week view of the
958
- * calendar:
959
- * previous week, next week, in that order.
960
- * Each element's key is an associative array containing the link's ID
961
- * ['id'], text ['text'] and value to assign to link's href ['href'].
962
- *
963
- * @param int $cur_offset week offset of current week, needed for hrefs
964
- *
965
- * @return array array of link information as described above
966
- **/
967
- function get_week_pagination_links( $cur_offset ) {
968
- global $ai1ec_events_helper;
969
-
970
- $links = array();
971
-
972
- // Base timestamp on offset week
973
- $bits = $ai1ec_events_helper->gmgetdate( $ai1ec_events_helper->gmt_to_local( time() ) );
974
- $bits['mday'] += $ai1ec_events_helper->get_week_start_day_offset( $bits['wday'] );
975
- $bits['mday'] += $cur_offset * 7;
976
-
977
- /* translators: "%s" represents the week's starting date */
978
- $links[] = array(
979
- 'id' => 'ai1ec-prev-week',
980
- 'text' =>
981
- '‹ ' .
982
- sprintf(
983
- __( 'Week of %s', AI1EC_PLUGIN_NAME ),
984
- date_i18n( __( 'M j', AI1EC_PLUGIN_NAME ), gmmktime( 0, 0, 0, $bits['mon'], $bits['mday'] - 7, $bits['year'] ), true )
985
- ),
986
- 'href' => '#action=ai1ec_week&ai1ec_week_offset=' . ( $cur_offset - 1 ),
987
- );
988
- $links[] = array(
989
- 'id' => 'ai1ec-next-week',
990
- 'text' =>
991
- sprintf(
992
- __( 'Week of %s', AI1EC_PLUGIN_NAME ),
993
- date_i18n( __( 'M j', AI1EC_PLUGIN_NAME ), gmmktime( 0, 0, 0, $bits['mon'], $bits['mday'] + 7, $bits['year'] ), true )
994
- )
995
- . ' ›',
996
- 'href' => '#action=ai1ec_week&ai1ec_week_offset=' . ( $cur_offset + 1 ),
997
- );
998
-
999
- return $links;
1000
- }
1001
-
1002
- /**
1003
- * get_agenda_pagination_links function
1004
- *
1005
- * Returns an associative array of two links for the agenda view of the
1006
- * calendar: previous page (if previous events exist), next page (if next
1007
- * events exist), in that order.
1008
- * Each element' is an associative array containing the link ID ['id'],
1009
- * text ['text'] and value to assign to link's href ['href'].
1010
- *
1011
- * @param int $cur_offset page offset of agenda view, needed for hrefs
1012
- * @param int $prev whether there are more events before the current page
1013
- * @param int $next whether there are more events after the current page
1014
- * @param int $date_first UNIX timestamp (date part) for first event in display list
1015
- * @param int $date_last UNIX timestamp (date part) for last event in display list
1016
- *
1017
- * @return array array of link information as described above
1018
- **/
1019
- function get_agenda_pagination_links(
1020
- $cur_offset,
1021
- $prev = false,
1022
- $next = false,
1023
- $date_first = null,
1024
- $date_last = null
1025
- ) {
1026
- global $ai1ec_settings;
1027
-
1028
- $links = array();
1029
-
1030
- $href_format = '#action=ai1ec_agenda&ai1ec_page_offset=%d'
1031
- . '&ai1ec_time_limit=%d';
1032
- if ( $prev ) {
1033
- $text = sprintf(
1034
- __( '« Previous Events', AI1EC_PLUGIN_NAME ),
1035
- $ai1ec_settings->agenda_events_per_page
1036
- );
1037
- $links['prev'] = array(
1038
- 'id' => 'ai1ec-prev-page',
1039
- 'text' => $text,
1040
- 'href' => sprintf( $href_format, -1, $date_first - 1 ),
1041
- );
1042
- }
1043
- if ( $next ) {
1044
- $text = sprintf(
1045
- __( 'Next Events »', AI1EC_PLUGIN_NAME ),
1046
- $ai1ec_settings->agenda_events_per_page
1047
- );
1048
- $links['next'] = array(
1049
- 'id' => 'ai1ec-next-page',
1050
- 'text' => $text,
1051
- 'href' => sprintf( $href_format, 1, $date_last + 1 ),
1052
- );
1053
- }
1054
-
1055
- return $links;
1056
- }
1057
-
1058
- /**
1059
- * _get_post_status_sql function
1060
- *
1061
- * Returns SQL snippet for properly matching event posts, as well as array
1062
- * of arguments to pass to $wpdb->prepare, in function argument references.
1063
- * Nothing is returned by the function.
1064
- *
1065
- * @param string &$sql The variable to store the SQL snippet into
1066
- * @param array &$args The variable to store the SQL arguments into
1067
- *
1068
- * @return void
1069
- */
1070
- function _get_post_status_sql( &$post_status_where = '', &$args )
1071
- {
1072
- global $current_user;
1073
-
1074
- // Query the correct post status
1075
- if( current_user_can( 'administrator' ) || current_user_can( 'editor' ) )
1076
- {
1077
- // User has privilege of seeing all published and private
1078
-
1079
- $post_status_where = "AND ( post_status = %s OR post_status = %s ) ";
1080
- $args[] = 'publish';
1081
- $args[] = 'private';
1082
- }
1083
- elseif( is_user_logged_in() )
1084
- {
1085
- // User has privilege of seeing all published and only their own private
1086
- // posts.
1087
-
1088
- // get user info
1089
- get_currentuserinfo();
1090
-
1091
- // include post_status = published
1092
- // OR
1093
- // post_status = private AND post_author = userID
1094
- $post_status_where =
1095
- "AND ( " .
1096
- "post_status = %s " .
1097
- "OR ( post_status = %s AND post_author = %d ) " .
1098
- ") ";
1099
-
1100
- $args[] = 'publish';
1101
- $args[] = 'private';
1102
- $args[] = $current_user->ID;
1103
- } else {
1104
- // User can only see published posts.
1105
- $post_status_where = "AND post_status = %s ";
1106
- $args[] = 'publish';
1107
- }
1108
- }
1109
-
1110
- /**
1111
- * _get_filter_sql function
1112
- *
1113
- * Takes an array of filtering options and turns it into JOIN and WHERE statements
1114
- * for running an SQL query limited to the specified options
1115
- *
1116
- * @param array &$filter Array of filters for the events returned.
1117
- * ['cat_ids'] => non-associatative array of category IDs
1118
- * ['tag_ids'] => non-associatative array of tag IDs
1119
- * ['post_ids'] => non-associatative array of event post IDs
1120
- * This array is modified to have:
1121
- * ['filter_join'] the Join statements for the SQL
1122
- * ['filter_where'] the Where statements for the SQL
1123
- *
1124
- * @return void
1125
- */
1126
- function _get_filter_sql( &$filter ) {
1127
- global $wpdb;
1128
-
1129
- // Set up the filter join and where strings
1130
- $filter['filter_join'] = '';
1131
- $filter['filter_where'] = '';
1132
-
1133
- // By default open the Where with an AND ( .. ) to group all statements.
1134
- // Later, set it to OR to join statements together.
1135
- // TODO - make this cleaner by supporting the choice of AND/OR logic
1136
- $where_logic = ' AND (';
1137
-
1138
- foreach( $filter as $filter_type => $filter_ids ) {
1139
- // If no filter elements specified, don't do anything
1140
- if( $filter_ids && is_array( $filter_ids ) ) {
1141
- switch ( $filter_type ) {
1142
- // Limit by Category IDs
1143
- case 'cat_ids':
1144
- $filter['filter_join'] .= " LEFT JOIN $wpdb->term_relationships AS trc ON e.post_id = trc.object_id ";
1145
- $filter['filter_join'] .= " LEFT JOIN $wpdb->term_taxonomy ttc ON trc.term_taxonomy_id = ttc.term_taxonomy_id AND ttc.taxonomy = 'events_categories' ";
1146
- $filter['filter_where'] .= $where_logic . " ttc.term_id IN ( " . join( ',', $filter_ids ) . " ) ";
1147
- $where_logic = ' OR ';
1148
- break;
1149
- // Limit by Tag IDs
1150
- case 'tag_ids':
1151
- $filter['filter_join'] .= " LEFT JOIN $wpdb->term_relationships AS trt ON e.post_id = trt.object_id ";
1152
- $filter['filter_join'] .= " LEFT JOIN $wpdb->term_taxonomy ttt ON trt.term_taxonomy_id = ttt.term_taxonomy_id AND ttt.taxonomy = 'events_tags' ";
1153
- $filter['filter_where'] .= $where_logic . " ttt.term_id IN ( " . join( ',', $filter_ids ) . " ) ";
1154
- $where_logic = ' OR ';
1155
- break;
1156
- // Limit by post IDs
1157
- case 'post_ids':
1158
- $filter['filter_where'] .= $where_logic . " e.post_id IN ( " . join( ',', $filter_ids ) . " ) ";
1159
- $where_logic = ' OR ';
1160
- break;
1161
- }
1162
- }
1163
- }
1164
-
1165
- // Close the Where statement bracket if any Where statements were set
1166
- if( $filter['filter_where'] != '' ) {
1167
- $filter['filter_where'] .= ' ) ';
1168
- }
1169
- }
1170
- }
1171
- // END class
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/helper/class-ai1ec-events-helper.php DELETED
@@ -1,2091 +0,0 @@
1
- <?php
2
- //
3
- // class-ai1ec-events-helper.php
4
- // all-in-one-event-calendar
5
- //
6
- // Created by The Seed Studio on 2011-07-13.
7
- //
8
-
9
- /**
10
- * Ai1ec_Events_Helper class
11
- *
12
- * @package Helpers
13
- * @author time.ly
14
- **/
15
- class Ai1ec_Events_Helper {
16
- /**
17
- * _instance class variable
18
- *
19
- * Class instance
20
- *
21
- * @var null | object
22
- **/
23
- private static $_instance = NULL;
24
-
25
- /**
26
- * Constructor
27
- *
28
- * Default constructor
29
- **/
30
- private function __construct() { }
31
-
32
- /**
33
- * get_instance function
34
- *
35
- * Return singleton instance
36
- *
37
- * @return object
38
- **/
39
- static function get_instance() {
40
- if( self::$_instance === NULL ) {
41
- self::$_instance = new self();
42
- }
43
-
44
- return self::$_instance;
45
- }
46
-
47
- /**
48
- * get_event function
49
- *
50
- * Fetches the event object with the given post ID. Uses the WP cache to
51
- * make this more efficient if possible.
52
- *
53
- * @param int $post_id The ID of the post associated with the event
54
- *
55
- * @return Ai1ec_Event The associated event object
56
- **/
57
- static function get_event( $post_id )
58
- {
59
- $event = wp_cache_get( $post_id, AI1EC_POST_TYPE );
60
- if( $event === false ) {
61
- // try to get the event instance id, if it is not set get the post id
62
- $instance_id = isset( $_REQUEST["instance_id"] ) ? (int) $_REQUEST["instance_id"] : false;
63
- $event = new Ai1ec_Event( $post_id, $instance_id );
64
-
65
- if( ! $event->post_id )
66
- throw new Ai1ec_Event_Not_Found( "Event with ID '$post_id' could not be retrieved from the database." );
67
-
68
- // Cache the event data
69
- wp_cache_add( $post_id, $event, AI1EC_POST_TYPE );
70
- }
71
- return $event;
72
- }
73
-
74
- /**
75
- * get_matching_event function
76
- *
77
- * Return event ID by iCalendar UID, feed url, start time and whether the
78
- * event has recurrence rules (to differentiate between an event with a UID
79
- * defining the recurrence pattern, and other events with with the same UID,
80
- * which are just RECURRENCE-IDs).
81
- *
82
- * @param int $uid iCalendar UID property
83
- * @param string $feed Feed URL
84
- * @param int $start Start timestamp (GMT)
85
- * @param bool $has_recurrence Whether the event has recurrence rules
86
- * @param int|null $exclude_post_id Do not match against this post ID
87
- *
88
- * @return object|null Matching event's post ID, or null if no match
89
- **/
90
- function get_matching_event_id( $uid, $feed, $start, $has_recurrence = false, $exclude_post_id = null ) {
91
- global $wpdb;
92
-
93
- $table_name = $wpdb->prefix . 'ai1ec_events';
94
- $query = "SELECT post_id FROM {$table_name} " .
95
- "WHERE ical_feed_url = %s " .
96
- "AND ical_uid = %s " .
97
- "AND start = FROM_UNIXTIME( %d ) " .
98
- ( $has_recurrence ? 'AND NOT ' : 'AND ' ) .
99
- "( recurrence_rules IS NULL OR recurrence_rules = '' )";
100
- $args = array( $feed, $uid, $start );
101
- if( ! is_null( $exclude_post_id ) ) {
102
- $query .= 'AND post_id <> %d';
103
- $args[] = $exclude_post_id;
104
- }
105
-
106
- return $wpdb->get_var( $wpdb->prepare( $query, $args ) );
107
- }
108
-
109
- /**
110
- * delete_event_cache function
111
- *
112
- * Delete cache of event
113
- *
114
- * @param int $pid Event post ID
115
- *
116
- * @return void
117
- **/
118
- function delete_event_cache( $pid ) {
119
- global $wpdb;
120
-
121
- $table_name = $wpdb->prefix . 'ai1ec_event_instances';
122
- $wpdb->query( $wpdb->prepare( "DELETE FROM $table_name WHERE post_id = %d", $pid ) );
123
- }
124
-
125
- /**
126
- * when using BYday you need an array of arrays.
127
- * This function create valid arrays that keep into account the presence
128
- * of a week number beofre the day
129
- *
130
- * @param string $val
131
- *
132
- * @return array
133
- */
134
- private function create_byday_array( $val ) {
135
- $week = substr( $val, 0, 1 );
136
- if ( is_numeric( $week ) ) {
137
- return array( $week, 'DAY' => substr( $val, 1 ) );
138
- }
139
- return array( 'DAY' => $val );
140
- }
141
-
142
- /**
143
- * Parse a `recurrence rule' into an array that can be used to calculate
144
- * recurrence instances.
145
- *
146
- * @see http://kigkonsult.se/iCalcreator/docs/using.html#EXRULE
147
- *
148
- * @param string $rule
149
- * @return array
150
- */
151
- private function build_recurrence_rules_array( $rule ) {
152
- $rules = array();
153
- $rule_list = explode( ';', $rule );
154
- foreach ( $rule_list as $single_rule ) {
155
- if ( false === strpos( $single_rule, '=' ) ) {
156
- continue;
157
- }
158
- list( $key, $val ) = explode( '=', $single_rule );
159
- $key = strtoupper( $key );
160
- switch ( $key ) {
161
- case 'BYDAY':
162
- $rules['BYDAY'] = array();
163
- foreach ( explode( ',', $val ) as $day ) {
164
- $rule_map = $this->create_byday_array( $day );
165
- $rules['BYDAY'][] = $rule_map;
166
- if (
167
- preg_match( '/FREQ=(MONTH|YEAR)LY/i', $rule ) &&
168
- 1 === count( $rule_map )
169
- ) {
170
- // monthly/yearly "last" recurrences need day name
171
- $rules['BYDAY']['DAY'] = substr(
172
- $rule_map['DAY'],
173
- -2
174
- );
175
- }
176
- }
177
- break;
178
-
179
- case 'BYMONTHDAY':
180
- case 'BYMONTH':
181
- if ( false === strpos( $val, ',' ) ) {
182
- $rules[$key] = $val;
183
- } else {
184
- $rules[$key] = explode( ',', $val );
185
- }
186
- break;
187
-
188
- default:
189
- $rules[$key] = $val;
190
- }
191
- }
192
- return $rules;
193
- }
194
-
195
- /**
196
- * cache_event function
197
- *
198
- * Creates a new entry in the cache table for each date that the event appears
199
- * (and does not already have an explicit RECURRENCE-ID instance, given its
200
- * iCalendar UID).
201
- *
202
- * @param object $event Event to generate cache table for
203
- *
204
- * @return void
205
- */
206
- public function cache_event( $event ) {
207
- global $wpdb;
208
-
209
- // Convert event timestamps to local for correct calculations of
210
- // recurrence. Need to also remove PHP timezone offset for each date for
211
- // SG_iCal to calculate correct recurring instances.
212
- $event->start = $this->gmt_to_local( $event->start )
213
- - date( 'Z', $event->start );
214
- $event->end = $this->gmt_to_local( $event->end )
215
- - date( 'Z', $event->end );
216
-
217
- $evs = array();
218
- $e = array(
219
- 'post_id' => $event->post_id,
220
- 'start' => $event->start,
221
- 'end' => $event->end,
222
- );
223
- $duration = $event->getDuration();
224
-
225
- // Timestamp of today date + 3 years (94608000 seconds)
226
- $tif = gmmktime() + 94608000;
227
- // Always cache initial instance
228
- $evs[] = $e;
229
-
230
- $_start = $event->start;
231
- $_end = $event->end;
232
-
233
- if ( $event->recurrence_rules ) {
234
- $start = $event->start;
235
- $wdate = $startdate = iCalUtilityFunctions::_timestamp2date( $_start, 6 );
236
- $enddate = iCalUtilityFunctions::_timestamp2date( $tif, 6 );
237
- $exclude_dates = array();
238
- $recurrence_dates = array();
239
- if ( $event->exception_rules ) {
240
- // creat an array for the rules
241
- $exception_rules = $this->build_recurrence_rules_array( $event->exception_rules );
242
- $exception_rules = iCalUtilityFunctions::_setRexrule( $exception_rules );
243
- $result = array();
244
- // The first array is the result and it is passed by reference
245
- iCalUtilityFunctions::_recur2date(
246
- $exclude_dates,
247
- $exception_rules,
248
- $wdate,
249
- $startdate,
250
- $enddate
251
- );
252
- }
253
- $recurrence_rules = $this->build_recurrence_rules_array( $event->recurrence_rules );
254
- $recurrence_rules = iCalUtilityFunctions::_setRexrule( $recurrence_rules );
255
- iCalUtilityFunctions::_recur2date(
256
- $recurrence_dates,
257
- $recurrence_rules,
258
- $wdate,
259
- $startdate,
260
- $enddate
261
- );
262
- // Add the instances
263
- foreach ( $recurrence_dates as $date => $bool ) {
264
- // The arrays are in the form timestamp => true so an isset call is what we need
265
- if( isset( $exclude_dates[$date] ) ) {
266
- continue;
267
- }
268
- $e['start'] = $date;
269
- $e['end'] = $date + $duration;
270
- $excluded = false;
271
-
272
-
273
- // Check if exception dates match this occurence
274
- if( $event->exception_dates ) {
275
- if( $this->date_match_exdates( $date, $event->exception_dates ) )
276
- $excluded = true;
277
- }
278
-
279
- // Add event only if it is not excluded
280
- if ( $excluded == false ) {
281
- $evs[] = $e;
282
- }
283
- }
284
- }
285
-
286
- // Make entries unique (sometimes recurrence generator creates duplicates?)
287
- $evs_unique = array();
288
- foreach ( $evs as $ev ) {
289
- $evs_unique[md5( serialize( $ev ) )] = $ev;
290
- }
291
-
292
- foreach ( $evs_unique as $e ) {
293
- // Find out if this event instance is already accounted for by an
294
- // overriding 'RECURRENCE-ID' of the same iCalendar feed (by comparing the
295
- // UID, start date, recurrence). If so, then do not create duplicate
296
- // instance of event.
297
- $start = $this->local_to_gmt( $e['start'] )
298
- - date( 'Z', $e['start'] );
299
- $matching_event_id = $event->ical_uid ?
300
- $this->get_matching_event_id(
301
- $event->ical_uid,
302
- $event->ical_feed_url,
303
- $start,
304
- false, // Only search events that does not define
305
- // recurrence (i.e. only search for RECURRENCE-ID events)
306
- $event->post_id
307
- )
308
- : NULL;
309
-
310
-
311
- // If no other instance was found
312
- if ( NULL === $matching_event_id ) {
313
- $start = getdate( $e['start'] );
314
- $end = getdate( $e['end'] );
315
- $this->insert_event_in_cache_table( $e );
316
- }
317
- }
318
-
319
- }
320
-
321
- /**
322
- * date_match_exdates function
323
- *
324
- * @return bool
325
- **/
326
- function date_match_exdates( $date, $ics_rule ) {
327
- foreach( explode( ",", $ics_rule ) as $_date ) {
328
- // convert to timestamp
329
- $_date_start = strtotime( $_date );
330
- // convert from UTC to local time
331
- $_date_start = $this->gmt_to_local( $_date_start ) - date( 'Z', $_date_start );
332
- if( $_date_start != false ) {
333
- // add 23h 59m 59s so the whole day is excluded
334
- $_date_end = $_date_start + (24 * 60 * 60) - 1;
335
- if( $date >= $_date_start && $date <= $_date_end ) {
336
- // event is within the time-frame
337
- return true;
338
- }
339
- }
340
- }
341
- return false;
342
- }
343
-
344
- /**
345
- * generate_dates_array_from_ics_rule function
346
- *
347
- * @return array
348
- **/
349
- function generate_dates_array_from_ics_rule( $start, $ics_rule ) {
350
- $freq = new SG_iCal_Freq( $ics_rule, $start, array(), array(), true );
351
- return $freq->getAllOccurrences();
352
- }
353
-
354
- /**
355
- * insert_event_in_cache_table function
356
- *
357
- * Inserts a new record in the cache table
358
- *
359
- * @param array $event Event array
360
- *
361
- * @return void
362
- **/
363
- function insert_event_in_cache_table( $event ) {
364
- global $wpdb;
365
-
366
- // Return the start/end times to GMT zone
367
- $event['start'] = $this->local_to_gmt( $event['start'] ) + date( 'Z', $event['start'] );
368
- $event['end'] = $this->local_to_gmt( $event['end'] ) + date( 'Z', $event['end'] );
369
-
370
- $wpdb->query(
371
- $wpdb->prepare(
372
- "INSERT INTO {$wpdb->prefix}ai1ec_event_instances " .
373
- " ( post_id, start, end ) " .
374
- "VALUES ( %d, FROM_UNIXTIME( %d ), FROM_UNIXTIME( %d ) )",
375
- $event
376
- )
377
- );
378
- }
379
-
380
- /**
381
- * create_cache_table_entries function
382
- *
383
- * Create a new entry for each day that the event spans.
384
- *
385
- * @param array $e Event array
386
- *
387
- * @return void
388
- **/
389
- function create_cache_table_entries( $e )
390
- {
391
- global $ai1ec_events_helper;
392
-
393
- // Decompose start dates into components
394
- $start_bits = getdate( $e['start'] );
395
-
396
- // ============================================
397
- // = Calculate the time for event's first day =
398
- // ============================================
399
- // Start time is event's original start time
400
- $event_start = $e['start'];
401
- // End time is beginning of next day
402
- $event_end = mktime(
403
- 0, // hour
404
- 0, // minute
405
- 0, // second
406
- $start_bits['mon'], // month
407
- $start_bits['mday'] + 1, // day
408
- $start_bits['year'] // year
409
- );
410
- // Cache first day
411
- $this->insert_event_in_cache_table( array( 'post_id' => $e['post_id'], 'start' => $event_start, 'end' => $event_end ) );
412
-
413
- // ====================================================
414
- // = Calculate the time for event's intermediate days =
415
- // ====================================================
416
- // Start time is previous end time
417
- $event_start = $event_end;
418
- // End time one day ahead
419
- $event_end += 60 * 60 * 24;
420
- // Cache intermediate days
421
- while( $event_end < $e['end'] ) {
422
- $this->insert_event_in_cache_table( array( 'post_id' => $e['post_id'], 'start' => $event_start, 'end' => $event_end ) );
423
- $event_start = $event_end; // Start time is previous end time
424
- $event_end += 24 * 60 * 60; // Increment end time by 1 day
425
- }
426
-
427
- // ===========================================
428
- // = Calculate the time for event's last day =
429
- // ===========================================
430
- // Start time is already correct (previous end time)
431
- // End time is event end time
432
- // Only insert if the last event instance if span is > 0
433
- $event_end = $e['end'];
434
- if( $event_end > $event_start )
435
- // Cache last day
436
- $this->insert_event_in_cache_table( array( 'post_id' => $e['post_id'], 'start' => $event_start, 'end' => $event_end ) );
437
- }
438
-
439
- /**
440
- * Returns the various preset recurrence options available (e.g.,
441
- * 'DAILY', 'WEEKENDS', etc.).
442
- *
443
- * @return string An associative array of pattern names to English
444
- * equivalents
445
- */
446
- function get_repeat_patterns() {
447
- // Calling functions when creating an array does not seem to work when
448
- // the assigned to variable is static. This is a workaround.
449
- static $options;
450
- if( !isset( $options ) ) {
451
- $temp = array(
452
- ' ' => __( 'No repeat', AI1EC_PLUGIN_NAME ),
453
- '1' => __( 'Every day', AI1EC_PLUGIN_NAME ),
454
- '2' => __( 'Every week', AI1EC_PLUGIN_NAME ),
455
- '3' => __( 'Every month', AI1EC_PLUGIN_NAME ),
456
- '4' => __( 'Every year', AI1EC_PLUGIN_NAME ),
457
- '5' => '-----------',
458
- '6' => __( 'Custom...', AI1EC_PLUGIN_NAME ),
459
- );
460
- $options = $temp;
461
- }
462
- return $options;
463
- }
464
-
465
- /**
466
- * Generates and returns repeat dropdown
467
- *
468
- * @param Integer|NULL $selected Selected option
469
- *
470
- * @return String Repeat dropdown
471
- */
472
- function create_repeat_dropdown( $selected = null ) {
473
- $options = array(
474
- ' ' => __( 'No repeat', AI1EC_PLUGIN_NAME ),
475
- 1 => __( 'Every day', AI1EC_PLUGIN_NAME ),
476
- 2 => __( 'Every week', AI1EC_PLUGIN_NAME ),
477
- 3 => __( 'Every month', AI1EC_PLUGIN_NAME ),
478
- 4 => __( 'Every year', AI1EC_PLUGIN_NAME ),
479
- 5 => '-----------',
480
- 6 => __( 'Custom...', AI1EC_PLUGIN_NAME ),
481
- );
482
- return $this->create_select_element( 'ai1ec_repeat', $options, $selected, array( 5 ) );
483
- }
484
-
485
-
486
- /**
487
- * Generates and returns "End after X times" input
488
- *
489
- * @param Integer|NULL $count Initial value of range input
490
- *
491
- * @return String Repeat dropdown
492
- */
493
- function create_count_input( $name, $count = 100, $max = 365 ) {
494
- ob_start();
495
-
496
- if( ! $count ) $count = 100;
497
- ?>
498
- <input type="range" name="<?php echo $name ?>" id="<?php echo $name ?>" min="1" max="<?php echo $max ?>"
499
- <?php if( $count ) echo 'value="' . $count . '"' ?> />
500
- <?php
501
- return ob_get_clean();
502
- }
503
-
504
- /**
505
- * create_select_element function
506
- *
507
- *
508
- *
509
- * @return void
510
- **/
511
- function create_select_element( $name, $options = array(), $selected = false, $disabled_keys = array() ) {
512
- ob_start();
513
- ?>
514
- <select name="<?php echo $name ?>" id="<?php echo $name ?>">
515
- <?php foreach( $options as $key => $val ): ?>
516
- <option value="<?php echo $key ?>" <?php echo $key === $selected ? 'selected="selected"' : '' ?><?php echo in_array( $key, $disabled_keys ) ? 'disabled="disabled"' : '' ?>>
517
- <?php echo $val ?>
518
- </option>
519
- <?php endforeach ?>
520
- </select>
521
- <?php
522
- return ob_get_clean();
523
- }
524
-
525
- /**
526
- * create_on_the_select function
527
- *
528
- *
529
- *
530
- * @return void
531
- **/
532
- function create_on_the_select( $f_selected = false, $s_selected = false ) {
533
- $ret = "";
534
-
535
- $first_options = array(
536
- '0' => __( 'first', AI1EC_PLUGIN_NAME ),
537
- '1' => __( 'second', AI1EC_PLUGIN_NAME ),
538
- '2' => __( 'third', AI1EC_PLUGIN_NAME ),
539
- '3' => __( 'fourth', AI1EC_PLUGIN_NAME ),
540
- '4' => '------',
541
- '5' => __( 'last', AI1EC_PLUGIN_NAME )
542
- );
543
- $ret = $this->create_select_element( 'ai1ec_monthly_each_select', $first_options, $f_selected, array( 4 ) );
544
-
545
- $second_options = array(
546
- '0' => __( 'Sunday', AI1EC_PLUGIN_NAME ),
547
- '1' => __( 'Monday', AI1EC_PLUGIN_NAME ),
548
- '2' => __( 'Tuesday', AI1EC_PLUGIN_NAME ),
549
- '3' => __( 'Wednesday', AI1EC_PLUGIN_NAME ),
550
- '4' => __( 'Thursday', AI1EC_PLUGIN_NAME ),
551
- '5' => __( 'Friday', AI1EC_PLUGIN_NAME ),
552
- '6' => __( 'Saturday', AI1EC_PLUGIN_NAME ),
553
- '7' => '--------',
554
- '8' => __( 'day', AI1EC_PLUGIN_NAME ),
555
- '9' => __( 'weekday', AI1EC_PLUGIN_NAME ),
556
- '10' => __( 'weekend day', AI1EC_PLUGIN_NAME )
557
- );
558
-
559
- return $ret . $this->create_select_element( 'ai1ec_monthly_on_the_select', $second_options, $s_selected, array( 7 ) );
560
- }
561
-
562
- /**
563
- * undocumented function
564
- *
565
- *
566
- *
567
- * @return void
568
- **/
569
- function create_list_element( $name, $options = array(), $selected = array() ) {
570
- ob_start();
571
- ?>
572
- <ul class="ai1ec_date_select <?php echo $name?>" id="<?php echo $name?>">
573
- <?php foreach( $options as $key => $val ): ?>
574
- <li<?php echo in_array( $key, $selected ) ? 'class="ai1ec_selected"' : '' ?>>
575
- <?php echo $val ?>
576
- <input type="hidden" name="<?php echo $name . '_' . $key ?>" value="<?php echo $key ?>" />
577
- </li>
578
- <?php endforeach ?>
579
- </ul>
580
- <input type="hidden" name="<?php echo $name ?>" value="<?php echo implode( ',', $selected ) ?>" />
581
- <?php
582
- return ob_get_clean();
583
- }
584
-
585
- /**
586
- * create_montly_date_select function
587
- *
588
- *
589
- *
590
- * @return void
591
- **/
592
- function create_montly_date_select( $selected = array() ) {
593
- $options = array();
594
-
595
- for( $i = 1; $i <= 31; ++$i )
596
- $options[$i] = $i;
597
-
598
- return $this->create_list_element( 'ai1ec_montly_date_select', $options, $selected );
599
- }
600
-
601
- /**
602
- * create_yearly_date_select function
603
- *
604
- *
605
- *
606
- * @return void
607
- **/
608
- function create_yearly_date_select( $selected = array() ) {
609
- global $wp_locale;
610
- $options = array();
611
-
612
- for( $i = 1; $i <= 12; ++$i ) {
613
- $x = $i < 10 ? 0 . $i : $i;
614
- $options[$i] = $wp_locale->month_abbrev[$wp_locale->month[$x]];
615
- }
616
-
617
- return $this->create_list_element( 'ai1ec_yearly_date_select', $options, $selected );
618
- }
619
-
620
- function get_frequency( $index ) {
621
- $frequency = array(
622
- 0 => __( 'Daily', AI1EC_PLUGIN_NAME ),
623
- 1 => __( 'Weekly', AI1EC_PLUGIN_NAME ),
624
- 2 => __( 'Monthly', AI1EC_PLUGIN_NAME ),
625
- 3 => __( 'Yearly', AI1EC_PLUGIN_NAME ),
626
- );
627
- return $frequency[$index];
628
- }
629
-
630
- /**
631
- * row_frequency function
632
- *
633
- * @return void
634
- **/
635
- function row_frequency( $visible = false, $selected = false ) {
636
- global $ai1ec_view_helper;
637
-
638
- $frequency = array(
639
- 0 => __( 'Daily', AI1EC_PLUGIN_NAME ),
640
- 1 => __( 'Weekly', AI1EC_PLUGIN_NAME ),
641
- 2 => __( 'Monthly', AI1EC_PLUGIN_NAME ),
642
- 3 => __( 'Yearly', AI1EC_PLUGIN_NAME ),
643
- );
644
-
645
- $args = array(
646
- 'visible' => $visible,
647
- 'frequency' => $this->create_select_element( 'ai1ec_frequency', $frequency, $selected )
648
- );
649
- return $ai1ec_view_helper->get_admin_view( 'row_frequency.php', $args );
650
- }
651
-
652
- /**
653
- * row_daily function
654
- *
655
- * Returns daily selector
656
- *
657
- * @return void
658
- **/
659
- function row_daily( $visible = false, $selected = 1 ) {
660
- global $ai1ec_view_helper;
661
-
662
- $args = array(
663
- 'visible' => $visible,
664
- 'count' => $this->create_count_input( 'ai1ec_daily_count', $selected, 365 ) . __( 'day(s)', AI1EC_PLUGIN_NAME )
665
- );
666
- return $ai1ec_view_helper->get_admin_view( 'row_daily.php', $args );
667
- }
668
-
669
- /**
670
- * row_weekly function
671
- *
672
- * Returns weekly selector
673
- *
674
- * @return void
675
- **/
676
- function row_weekly( $visible = false, $count = 1, $selected = array() ) {
677
- global $ai1ec_view_helper, $wp_locale;
678
- $start_of_week = get_option( 'start_of_week', 1 );
679
-
680
- $options = array();
681
- // get days from start_of_week until the last day
682
- for( $i = $start_of_week; $i <= 6; ++$i )
683
- $options[$this->get_weekday_by_id( $i )] = $wp_locale->weekday_initial[$wp_locale->weekday[$i]];
684
-
685
- // get days from 0 until start_of_week
686
- if( $start_of_week > 0 ) {
687
- for( $i = 0; $i < $start_of_week; $i++ )
688
- $options[$this->get_weekday_by_id( $i )] = $wp_locale->weekday_initial[$wp_locale->weekday[$i]];
689
- }
690
-
691
- $args = array(
692
- 'visible' => $visible,
693
- 'count' => $this->create_count_input( 'ai1ec_weekly_count', $count, 52 ) . __( 'week(s)', AI1EC_PLUGIN_NAME ),
694
- 'week_days' => $this->create_list_element( 'ai1ec_weekly_date_select', $options, $selected )
695
- );
696
- return $ai1ec_view_helper->get_admin_view( 'row_weekly.php', $args );
697
- }
698
-
699
- /**
700
- * get_weekday_by_id function
701
- *
702
- * Returns weekday name in English
703
- *
704
- * @param int $day_id Day ID
705
- *
706
- * @return string
707
- **/
708
- function get_weekday_by_id( $day_id, $by_value = false ) {
709
- // do not translate this !!!
710
- $week_days = array(
711
- 0 => 'SU',
712
- 1 => 'MO',
713
- 2 => 'TU',
714
- 3 => 'WE',
715
- 4 => 'TH',
716
- 5 => 'FR',
717
- 6 => 'SA'
718
- );
719
-
720
- if( $by_value ) {
721
- while( $_name = current( $week_days ) ) {
722
- if( $_name == $day_id ) {
723
- return key( $week_days );
724
- }
725
- next( $week_days );
726
- }
727
- return false;
728
- }
729
- else
730
- return $week_days[$day_id];
731
- }
732
-
733
- /**
734
- * row_monthly function
735
- *
736
- * Returns monthly selector
737
- *
738
- * @return void
739
- **/
740
- function row_monthly( $visible = false, $count = 1, $ai1ec_monthly_each = 0, $ai1ec_monthly_on_the = 0, $month = array(), $first = false, $second = false ) {
741
- global $ai1ec_view_helper, $wp_locale;
742
- $start_of_week = get_option( 'start_of_week', 1 );
743
-
744
- $options_wd = array();
745
- // get days from start_of_week until the last day
746
- for( $i = $start_of_week; $i <= 6; ++$i )
747
- $options_wd[$this->get_weekday_by_id( $i )] = $wp_locale->weekday[$i];
748
-
749
- // get days from 0 until start_of_week
750
- if( $start_of_week > 0 ) {
751
- for( $i = 0; $i < $start_of_week; $i++ )
752
- $options_wd[$this->get_weekday_by_id( $i )] = $wp_locale->weekday[$i];
753
- }
754
-
755
- // get options like 1st/2nd/3rd for "day number"
756
- $options_dn = array( 1 => 1, 2 => 2, 3 => 3, 4 => 4, 5 => 5 );
757
- foreach( $options_dn as $_dn ) {
758
- $options_dn[ $_dn ] = date_i18n( "jS", strtotime( $_dn . "-01-1998 12:00:00" ) );
759
- }
760
-
761
- $args = array(
762
- 'visible' => $visible,
763
- 'count' => $this->create_count_input( 'ai1ec_monthly_count', $count, 12 ) . __( 'month(s)', AI1EC_PLUGIN_NAME ),
764
- 'ai1ec_monthly_each' => $ai1ec_monthly_each,
765
- 'ai1ec_monthly_on_the' => $ai1ec_monthly_on_the,
766
- 'month' => $this->create_montly_date_select( $month ),
767
- 'on_the_select' => $this->create_on_the_select( $first, $second ),
768
- 'day_nums' => $this->create_select_element( 'ai1ec_monthly_byday_num', $options_dn ),
769
- 'week_days' => $this->create_select_element( 'ai1ec_monthly_byday_weekday', $options_wd )
770
- );
771
- return $ai1ec_view_helper->get_admin_view( 'row_monthly.php', $args );
772
- }
773
-
774
- /**
775
- * row_yearly function
776
- *
777
- * Returns yearly selector
778
- *
779
- * @return void
780
- **/
781
- function row_yearly( $visible = false, $count = 1, $year = array(), $first = false, $second = false ) {
782
- global $ai1ec_view_helper;
783
-
784
- $args = array(
785
- 'visible' => $visible,
786
- 'count' => $this->create_count_input( 'ai1ec_yearly_count', $count, 10 ) . __( 'year(s)', AI1EC_PLUGIN_NAME ),
787
- 'year' => $this->create_yearly_date_select( $year ),
788
- 'on_the_select' => $this->create_on_the_select( $first, $second )
789
- );
790
- return $ai1ec_view_helper->get_admin_view( 'row_yearly.php', $args );
791
- }
792
-
793
- /**
794
- * get_all_matching_posts function
795
- *
796
- * Gets existing event posts that are between the interval
797
- *
798
- * @param int $s_time Start time
799
- * @param int $e_time End time
800
- *
801
- * @return Array of matching event posts
802
- **/
803
- function get_all_matching_posts( $s_time, $e_time ) {
804
- global $ai1ec_calendar_helper;
805
- return $ai1ec_calendar_helper->get_events_between( $s_time, $e_time );
806
- }
807
-
808
- /**
809
- * get_matching_events function
810
- *
811
- * Get events that match with the arguments provided.
812
- *
813
- * @param int | bool $start Events start before this (GMT) time
814
- * @param int | bool $end Events end before this (GMT) time
815
- * @param array $filter Array of filters for the events returned.
816
- * ['cat_ids'] => non-associatative array of category IDs
817
- * ['tag_ids'] => non-associatative array of tag IDs
818
- * ['post_ids'] => non-associatative array of post IDs
819
- *
820
- * @return array Matching events
821
- **/
822
- function get_matching_events( $start = false, $end = false, $filter = array() ) {
823
- global $wpdb, $ai1ec_calendar_helper;
824
-
825
- // holds event_categories sql
826
- $c_sql = '';
827
- $c_where_sql = '';
828
- // holds event_tags sql
829
- $t_sql = '';
830
- $t_where_sql ='';
831
- // holds posts sql
832
- $p_where_sql = '';
833
- // holds start sql
834
- $start_where_sql = '';
835
- // holds end sql
836
- $end_where_sql = '';
837
- // hold escape values
838
- $args = array();
839
-
840
- // =============================
841
- // = Generating start date sql =
842
- // =============================
843
- if( $start !== false ) {
844
- $start_where_sql = "AND (e.start >= FROM_UNIXTIME( %d ) OR e.recurrence_rules != '')";
845
- $args[] = $start;
846
- }
847
-
848
- // ===========================
849
- // = Generating end date sql =
850
- // ===========================
851
- if( $end !== false ) {
852
- $end_where_sql = "AND (e.end <= FROM_UNIXTIME( %d ) OR e.recurrence_rules != '')";
853
- $args[] = $end;
854
- }
855
-
856
- // Get the Join (filter_join) and Where (filter_where) statements based on $filter elements specified
857
- $ai1ec_calendar_helper->_get_filter_sql( $filter );
858
-
859
- $query = $wpdb->prepare(
860
- "SELECT *, e.post_id, UNIX_TIMESTAMP( e.start ) as start, UNIX_TIMESTAMP( e.end ) as end, e.allday, e.recurrence_rules, e.exception_rules,
861
- e.recurrence_dates, e.exception_dates, e.venue, e.country, e.address, e.city, e.province, e.postal_code,
862
- e.show_map, e.contact_name, e.contact_phone, e.contact_email, e.cost, e.ical_feed_url, e.ical_source_url,
863
- e.ical_organizer, e.ical_contact, e.ical_uid " .
864
- "FROM $wpdb->posts " .
865
- "INNER JOIN {$wpdb->prefix}ai1ec_events AS e ON e.post_id = ID " .
866
- $filter['filter_join'] .
867
- "WHERE post_type = '" . AI1EC_POST_TYPE . "' " .
868
- "AND post_status = 'publish' " .
869
- $filter['filter_where'] .
870
- $start_where_sql .
871
- $end_where_sql,
872
- $args );
873
-
874
- $events = $wpdb->get_results( $query, ARRAY_A );
875
-
876
- foreach( $events as &$event ) {
877
- try{
878
- $event = new Ai1ec_Event( $event );
879
- } catch( Ai1ec_Event_Not_Found $n ) {
880
- unset( $event );
881
- // The event is not found, continue to the next event
882
- continue;
883
- }
884
-
885
- // if there are recurrence rules, include the event, else...
886
- if( empty( $event->recurrence_rules ) ) {
887
- // if start time is set, and event start time is before the range
888
- // it, continue to the next event
889
- if( $start !== false && $event->start < $start ) {
890
- unset( $event );
891
- continue;
892
- }
893
- // if end time is set, and event end time is after
894
- // it, continue to the next event
895
- if( $end !== false && $ev->end < $end ) {
896
- unset( $event );
897
- continue;
898
- }
899
- }
900
- }
901
-
902
- return $events;
903
- }
904
-
905
- /**
906
- * fuzzy_string_compare function
907
- *
908
- * Compares string A to string B using fuzzy comparison algorithm
909
- *
910
- * @param String $a String to compare
911
- * @param String $b String to compare
912
- *
913
- * @return boolean True if the two strings match, false otherwise
914
- **/
915
- function fuzzy_string_compare( $a, $b ) {
916
- $percent = 0;
917
- similar_text( $a, $b, $percent );
918
- return ( $percent > 50 );
919
- }
920
-
921
- /**
922
- * get_short_time function
923
- *
924
- * Format a short-form time for use in compressed (e.g. month) views;
925
- * this is also converted to the local timezone.
926
- *
927
- * @param int $timestamp
928
- * @param bool $convert_from_gmt Whether to convert from GMT time to local
929
- *
930
- * @return string
931
- **/
932
- function get_short_time( $timestamp, $convert_from_gmt = true ) {
933
- $time_format = get_option( 'time_format', 'g:ia' );
934
- if( $convert_from_gmt )
935
- $timestamp = $this->gmt_to_local( $timestamp );
936
- return date_i18n( $time_format, $timestamp, true );
937
- }
938
-
939
- /**
940
- * get_short_date function
941
- *
942
- * Format a short-form date for use in compressed (e.g. month) views;
943
- * this is also converted to the local timezone.
944
- *
945
- * @param int $timestamp
946
- * @param bool $convert_from_gmt Whether to convert from GMT time to local
947
- *
948
- * @return string
949
- **/
950
- function get_short_date( $timestamp, $convert_from_gmt = true ) {
951
- if( $convert_from_gmt )
952
- $timestamp = $this->gmt_to_local( $timestamp );
953
- return date_i18n( 'M j', $timestamp, true );
954
- }
955
-
956
- /**
957
- * Return the for use in JS functions to extend multiday bars;
958
- * this is also converted to the local timezone.
959
- *
960
- * @param int $timestamp
961
- * @param bool $convert_from_gmt Whether to convert from GMT time to local
962
- *
963
- * @return string
964
- **/
965
- function get_multiday_end_day( $timestamp, $convert_from_gmt = true ) {
966
- if( $convert_from_gmt )
967
- $timestamp = $this->gmt_to_local( $timestamp );
968
- return date_i18n( 'd', $timestamp, true );
969
- }
970
-
971
- /**
972
- * get_medium_time function
973
- *
974
- * Format a medium-length time for use in other views (e.g., Agenda);
975
- * this is also converted to the local timezone.
976
- *
977
- * @param int $timestamp
978
- *
979
- * @return string
980
- **/
981
- function get_medium_time( $timestamp, $convert_from_gmt = true ) {
982
- $time_format = get_option( 'time_format', 'g:ia' );
983
- if( $convert_from_gmt )
984
- $timestamp = $this->gmt_to_local( $timestamp );
985
- return date_i18n( $time_format, $timestamp, true );
986
- }
987
-
988
- /**
989
- * get_long_time function
990
- *
991
- * Format a long-length time for use in other views (e.g., single event);
992
- * this is also converted to the local timezone.
993
- *
994
- * @param int $timestamp
995
- * @param bool $convert_from_gmt Whether to convert from GMT time to local
996
- *
997
- * @return string
998
- **/
999
- function get_long_time( $timestamp, $convert_from_gmt = true ) {
1000
- $date_format = get_option( 'date_format', 'D, F j' );
1001
- $time_format = get_option( 'time_format', 'g:i' );
1002
- if( $convert_from_gmt )
1003
- $timestamp = $this->gmt_to_local( $timestamp );
1004
- return date_i18n( $date_format, $timestamp, true ) . ' @ ' . date_i18n( $time_format, $timestamp, true );
1005
- }
1006
-
1007
- /**
1008
- * get_long_date function
1009
- *
1010
- * Format a long-length date for use in other views (e.g., single event);
1011
- * this is also converted to the local timezone if desired.
1012
- *
1013
- * @param int $timestamp
1014
- * @param bool $convert_from_gmt Whether to convert from GMT time to local
1015
- *
1016
- * @return string
1017
- **/
1018
- function get_long_date( $timestamp, $convert_from_gmt = true ) {
1019
- $date_format = get_option( 'date_format', 'D, F j' );
1020
- if( $convert_from_gmt )
1021
- $timestamp = $this->gmt_to_local( $timestamp );
1022
- return date_i18n( $date_format, $timestamp, true );
1023
- }
1024
-
1025
- /**
1026
- * gmt_to_local function
1027
- *
1028
- * Returns the UNIX timestamp adjusted to the local timezone.
1029
- *
1030
- * @param int $timestamp
1031
- *
1032
- * @return int
1033
- **/
1034
- function gmt_to_local( $timestamp ) {
1035
- $offset = get_option( 'gmt_offset' );
1036
- $tz = get_option( 'timezone_string', 'America/Los_Angeles' );
1037
-
1038
- $offset = $this->get_timezone_offset( 'UTC', $tz, $timestamp );
1039
-
1040
- if( ! $offset )
1041
- $offset = get_option( 'gmt_offset' ) * 3600;
1042
-
1043
- return $timestamp + $offset;
1044
- }
1045
-
1046
- /**
1047
- * local_to_gmt function
1048
- *
1049
- * Returns the UNIX timestamp adjusted from the local timezone to GMT.
1050
- *
1051
- * @param int $timestamp
1052
- *
1053
- * @return int
1054
- **/
1055
- function local_to_gmt( $timestamp ) {
1056
- $offset = get_option( 'gmt_offset' );
1057
- $tz = get_option( 'timezone_string', 'America/Los_Angeles' );
1058
-
1059
- $offset = $this->get_timezone_offset( 'UTC', $tz, $timestamp );
1060
-
1061
- if( ! $offset )
1062
- $offset = get_option( 'gmt_offset' ) * 3600;
1063
-
1064
- return $timestamp - $offset;
1065
- }
1066
-
1067
- /**
1068
- * get_timezone_offset function
1069
- *
1070
- * Returns the offset from the origin timezone to the remote timezone, in seconds.
1071
- *
1072
- * @param string $remote_tz Remote TimeZone
1073
- * @param string $origin_tz Origin TimeZone
1074
- * @param string/int $timestamp Unix Timestamp or 'now'
1075
- *
1076
- * @return int
1077
- **/
1078
- function get_timezone_offset( $remote_tz, $origin_tz = null, $timestamp = false ) {
1079
- // set timestamp to time now
1080
- if( $timestamp == false ) {
1081
- $timestamp = gmmktime();
1082
- }
1083
-
1084
- if( $origin_tz === null ) {
1085
- if( ! is_string( $origin_tz = date_default_timezone_get() ) ) {
1086
- return false; // A UTC timestamp was returned -- bail out!
1087
- }
1088
- }
1089
-
1090
- try {
1091
- $origin_dtz = new DateTimeZone( $origin_tz );
1092
- $remote_dtz = new DateTimeZone( $remote_tz );
1093
-
1094
- // if DateTimeZone fails, throw exception
1095
- if( $origin_dtz == false || $remote_dtz == false )
1096
- throw new Exception( 'DateTimeZone class failed' );
1097
-
1098
- $origin_dt = new DateTime( gmdate( 'Y-m-d H:i:s', $timestamp ), $origin_dtz );
1099
- $remote_dt = new DateTime( gmdate( 'Y-m-d H:i:s', $timestamp ), $remote_dtz );
1100
-
1101
- // if DateTime fails, throw exception
1102
- if( $origin_dt == false || $remote_dt == false )
1103
- throw new Exception( 'DateTime class failed' );
1104
-
1105
- $offset = $origin_dtz->getOffset( $origin_dt ) - $remote_dtz->getOffset( $remote_dt );
1106
- } catch( Exception $e ) {
1107
- return false;
1108
- }
1109
-
1110
- return $offset;
1111
- }
1112
-
1113
- /**
1114
- * A GMT-version of PHP getdate().
1115
- *
1116
- * @param int $timestamp UNIX timestamp
1117
- * @return array Same result as getdate(), but based in GMT time.
1118
- **/
1119
- function gmgetdate( $timestamp = null ) {
1120
- if( ! $timestamp ) $timestamp = time();
1121
- $bits = explode( ',', gmdate( 's,i,G,j,w,n,Y,z,l,F,U', $timestamp ) );
1122
- $bits = array_combine(
1123
- array( 'seconds', 'minutes', 'hours', 'mday', 'wday', 'mon', 'year', 'yday', 'weekday', 'month', 0 ),
1124
- $bits
1125
- );
1126
- return $bits;
1127
- }
1128
-
1129
- /**
1130
- * time_to_gmt function
1131
- *
1132
- * Converts time to GMT
1133
- *
1134
- * @param int $timestamp
1135
- *
1136
- * @return int
1137
- **/
1138
- function time_to_gmt( $timestamp ) {
1139
- return strtotime( gmdate( 'M d Y H:i:s', $timestamp ) );
1140
- }
1141
-
1142
- /**
1143
- * date_to_gmdatestamp function
1144
- *
1145
- * Converts date (date-time) to GMT date expressed as UNIX timestamp
1146
- *
1147
- * @param int $input_time Local timestamp
1148
- *
1149
- * @return int Timestamp date representation in GMT zone
1150
- **/
1151
- function date_to_gmdatestamp( $input_time ) {
1152
- $time = $this->gmt_to_local( $input_time );
1153
- $time = $this->gmgetdate( $time );
1154
- $stamp = gmmktime(
1155
- 0, // hour
1156
- 0, // minute
1157
- 0, // second
1158
- $time['mon'], // month
1159
- $time['mday'], // day-of-month
1160
- $time['year'] // year
1161
- );
1162
- return $stamp;
1163
- }
1164
-
1165
- /**
1166
- * get_gmap_url function
1167
- *
1168
- * Returns the URL to the Google Map for the given event object.
1169
- *
1170
- * @param Ai1ec_Event &$event The event object to display a map for
1171
- *
1172
- * @return string
1173
- **/
1174
- function get_gmap_url( &$event ) {
1175
- return "http://www.google.com/maps?f=q&hl=" . $this->get_lang() . "&source=embed&q=" . urlencode( $event->address );
1176
- }
1177
-
1178
- /**
1179
- * get_lang function
1180
- *
1181
- * Returns the ISO-639 part of the configured locale. The default
1182
- * language is English (en).
1183
- *
1184
- * @return string
1185
- **/
1186
- function get_lang() {
1187
- $locale = explode( '_', get_locale() );
1188
-
1189
- return ( isset( $locale[0] ) && $locale[0] != '' ) ? $locale[0] : 'en';
1190
- }
1191
-
1192
- /**
1193
- * get_region function
1194
- *
1195
- * Returns the ISO-3166 part of the configured locale as a ccTLD.
1196
- * Used for region biasing in the geo autocomplete plugin.
1197
- *
1198
- * @return string
1199
- **/
1200
- function get_region() {
1201
- $locale = explode( '_', get_locale() );
1202
-
1203
- $region = ( isset( $locale[1] ) && $locale[1] != '' ) ? strtolower( $locale[1] ) : '';
1204
-
1205
- // Primary ccTLD for United Kingdom is uk.
1206
- return ( $region == 'gb' ) ? 'uk' : $region;
1207
- }
1208
-
1209
- /**
1210
- * trim_excerpt function
1211
- *
1212
- * Generates an excerpt from the given content string. Adapted from
1213
- * WordPress's wp_trim_excerpt function that is not useful for applying
1214
- * to custom content.
1215
- *
1216
- * @param string $text The content to trim.
1217
- *
1218
- * @return string The excerpt.
1219
- **/
1220
- function trim_excerpt( $text )
1221
- {
1222
- $raw_excerpt = $text;
1223
-
1224
- $text = strip_shortcodes( $text );
1225
-
1226
- $text = str_replace(']]>', ']]&gt;', $text);
1227
- $text = strip_tags($text);
1228
- $excerpt_length = apply_filters('excerpt_length', 55);
1229
- $excerpt_more = apply_filters('excerpt_more', ' ' . '[...]');
1230
- $words = preg_split("/[\n\r\t ]+/", $text, $excerpt_length + 1, PREG_SPLIT_NO_EMPTY);
1231
- if ( count($words) > $excerpt_length ) {
1232
- array_pop($words);
1233
- $text = implode(' ', $words);
1234
- $text = $text . $excerpt_more;
1235
- } else {
1236
- $text = implode(' ', $words);
1237
- }
1238
- return apply_filters('wp_trim_excerpt', $text, $raw_excerpt);
1239
- }
1240
-
1241
- /**
1242
- * filter_by_terms function
1243
- *
1244
- * Returns a subset of post IDs from the given set of post IDs that have any
1245
- * of the given taxonomy term IDs. This is actually useful for all posts and
1246
- * taxonomies in general, not just event posts and event-specific taxonomies.
1247
- *
1248
- * @param array|string $post_ids Post IDs as an array of ints or
1249
- * comma-separated string
1250
- * @param array|string $term_ids Term IDs as an array of ints or
1251
- * comma-separated string
1252
- *
1253
- * @return array Filtered post IDs as an array of ints
1254
- */
1255
- function filter_by_terms( $post_ids, $term_ids )
1256
- {
1257
- global $wpdb;
1258
-
1259
- // ===============================================
1260
- // = Sanitize provided IDs against SQL injection =
1261
- // ===============================================
1262
- if( ! is_array( $post_ids ) )
1263
- $post_ids = explode( ',', $post_ids );
1264
- foreach( $post_ids as &$post_id ) {
1265
- $post_id = intval( $post_id );
1266
- }
1267
- $post_ids = join( ',', $post_ids );
1268
-
1269
- if( ! is_array( $term_ids ) )
1270
- $term_ids = explode( ',', $term_ids );
1271
- foreach( $term_ids as &$term_id ) {
1272
- $term_id = intval( $term_id );
1273
- }
1274
- $term_ids = join( ',', $term_ids );
1275
-
1276
- $query =
1277
- "SELECT DISTINCT p.ID " .
1278
- "FROM $wpdb->posts p " .
1279
- "INNER JOIN $wpdb->term_relationships tr ON p.ID = tr.object_id " .
1280
- "INNER JOIN $wpdb->term_taxonomy tt ON tr.term_taxonomy_id = tt.term_taxonomy_id " .
1281
- "WHERE p.ID IN ( " . $post_ids . " ) " .
1282
- "AND tt.term_id IN ( " . $term_ids . " )";
1283
-
1284
- return $wpdb->get_col( $query );
1285
- }
1286
-
1287
- /**
1288
- * get_category_color function
1289
- *
1290
- * Returns the color of the Event Category having the given term ID.
1291
- *
1292
- * @param int $term_id The ID of the Event Category
1293
- * @return string
1294
- */
1295
- function get_category_color( $term_id ) {
1296
- global $wpdb;
1297
-
1298
- $term_id = (int) $term_id;
1299
- $table_name = $wpdb->prefix . 'ai1ec_event_category_colors';
1300
- $color = $wpdb->get_var( $wpdb->prepare( "SELECT term_color FROM {$table_name} WHERE term_id = %d", $term_id ) );
1301
- return $color;
1302
- }
1303
-
1304
- /**
1305
- * get_category_color_square function
1306
- *
1307
- * Returns the HTML markup for the category color square of the given Event
1308
- * Category term ID.
1309
- *
1310
- * @param int $term_id The Event Category's term ID
1311
- * @return string
1312
- **/
1313
- function get_category_color_square( $term_id ) {
1314
- $color = $this->get_category_color( $term_id );
1315
- $cat = get_term( $term_id, 'events_categories' );
1316
- if( ! is_null( $color ) && ! empty( $color ) )
1317
- return '<div class="ai1ec-category-color" style="background:' . $color . '" rel="tooltip" title="' . esc_attr( $cat->name ) . '"></div>';
1318
-
1319
- return '';
1320
- }
1321
-
1322
- /**
1323
- * get_event_category_color_style function
1324
- *
1325
- * Returns the style attribute assigning the category color style to an event.
1326
- *
1327
- * @param int $term_id The Event Category's term ID
1328
- * @param bool $allday Whether the event is all-day
1329
- * @return string
1330
- **/
1331
- function get_event_category_color_style( $term_id, $allday = false ) {
1332
- $color = $this->get_category_color( $term_id );
1333
- if( ! is_null( $color ) && ! empty( $color ) ) {
1334
- if( $allday )
1335
- return 'background-color: ' . $color . ';';
1336
- else
1337
- return 'color: ' . $color . ' !important;';
1338
- }
1339
-
1340
- return '';
1341
- }
1342
-
1343
- /**
1344
- * Returns a faded version of the event's category color in hex format.
1345
- *
1346
- * @param int $term_id The Event Category's term ID
1347
- *
1348
- * @return string
1349
- */
1350
- function get_event_category_faded_color( $term_id ) {
1351
- $color = $this->get_category_color( $term_id );
1352
- if( ! is_null( $color ) && ! empty( $color ) ) {
1353
-
1354
- $color1 = substr( $color, 1 );
1355
- $color2 = 'ffffff';
1356
-
1357
- $c1_p1 = hexdec( substr( $color1, 0, 2 ) );
1358
- $c1_p2 = hexdec( substr( $color1, 2, 2 ) );
1359
- $c1_p3 = hexdec( substr( $color1, 4, 2 ) );
1360
-
1361
- $c2_p1 = hexdec( substr( $color2, 0, 2 ) );
1362
- $c2_p2 = hexdec( substr( $color2, 2, 2 ) );
1363
- $c2_p3 = hexdec( substr( $color2, 4, 2 ) );
1364
-
1365
- $m_p1 = dechex( round( $c1_p1 * 0.3 + $c2_p1 * 0.7 ) );
1366
- $m_p2 = dechex( round( $c1_p2 * 0.3 + $c2_p2 * 0.7 ) );
1367
- $m_p3 = dechex( round( $c1_p3 * 0.3 + $c2_p3 * 0.7 ) );
1368
-
1369
- return '#' . $m_p1 . $m_p2 . $m_p3;
1370
- }
1371
-
1372
- return '';
1373
- }
1374
-
1375
- /**
1376
- * Returns an opacity-faded version of the event's category color in rgba
1377
- * format.
1378
- *
1379
- * @param int $term_id The Event Category's term ID
1380
- *
1381
- * @return string
1382
- */
1383
- function get_event_category_rgba_color( $term_id ) {
1384
- $color = $this->get_category_color( $term_id );
1385
- if( ! is_null( $color ) && ! empty( $color ) ) {
1386
- $p1 = hexdec( substr( $color, 1, 2 ) );
1387
- $p2 = hexdec( substr( $color, 3, 2 ) );
1388
- $p3 = hexdec( substr( $color, 5, 2 ) );
1389
- return "rgba($p1, $p2, $p3, 0.3)";
1390
- }
1391
-
1392
- return '';
1393
- }
1394
-
1395
- /**
1396
- * get_event_category_colors function
1397
- *
1398
- * Returns category color squares for the list of Event Category objects.
1399
- *
1400
- * @param array $cats The Event Category objects as returned by get_terms()
1401
- * @return string
1402
- **/
1403
- function get_event_category_colors( $cats ) {
1404
- $sqrs = '';
1405
-
1406
- foreach( $cats as $cat ) {
1407
- $tmp = $this->get_category_color_square( $cat->term_id );
1408
- if( ! empty( $tmp ) )
1409
- $sqrs .= $tmp;
1410
- }
1411
-
1412
- return $sqrs;
1413
- }
1414
-
1415
- /**
1416
- * create_end_dropdown function
1417
- *
1418
- * Outputs the dropdown list for the recurrence end option.
1419
- *
1420
- * @param int $selected The index of the selected option, if any
1421
- * @return void
1422
- **/
1423
- function create_end_dropdown( $selected = null ) {
1424
- ob_start();
1425
-
1426
- $options = array(
1427
- 0 => __( 'Never', AI1EC_PLUGIN_NAME ),
1428
- 1 => __( 'After', AI1EC_PLUGIN_NAME ),
1429
- 2 => __( 'On date', AI1EC_PLUGIN_NAME )
1430
- );
1431
-
1432
- ?>
1433
- <select name="ai1ec_end" id="ai1ec_end">
1434
- <?php foreach( $options as $key => $val ): ?>
1435
- <option value="<?php echo $key ?>" <?php if( $key === $selected ) echo 'selected="selected"' ?>>
1436
- <?php echo $val ?>
1437
- </option>
1438
- <?php endforeach ?>
1439
- </select>
1440
- <?php
1441
-
1442
- $output = ob_get_contents();
1443
- ob_end_clean();
1444
-
1445
- return $output;
1446
- }
1447
-
1448
- /**
1449
- * rrule_to_text function
1450
- *
1451
- *
1452
- *
1453
- * @return string
1454
- **/
1455
- function rrule_to_text( $rrule = '') {
1456
- $txt = '';
1457
- $rc = new Ai1ec_Recurrence_Helper( $rrule );
1458
- switch( $rc->get_property( 'freq' ) ) {
1459
- case 'DAILY':
1460
- $this->_get_interval( $txt, 'daily', $rc->get_property( 'interval' ) );
1461
- $this->_ending_sentence( $txt, $rc );
1462
- break;
1463
- case 'WEEKLY':
1464
- $this->_get_interval( $txt, 'weekly', $rc->get_property( 'interval' ) );
1465
- $this->_get_sentence_by( $txt, 'weekly', $rc );
1466
- $this->_ending_sentence( $txt, $rc );
1467
- break;
1468
- case 'MONTHLY':
1469
- $this->_get_interval( $txt, 'monthly', $rc->get_property( 'interval' ) );
1470
- $this->_get_sentence_by( $txt, 'monthly', $rc );
1471
- $this->_ending_sentence( $txt, $rc );
1472
- break;
1473
- case 'YEARLY':
1474
- $this->_get_interval( $txt, 'yearly', $rc->get_property( 'interval' ) );
1475
- $this->_get_sentence_by( $txt, 'yearly', $rc );
1476
- $this->_ending_sentence( $txt, $rc );
1477
- break;
1478
- default:
1479
- $txt = $rrule;
1480
- }
1481
- return $txt;
1482
- }
1483
-
1484
- /**
1485
- * exdate_to_text function
1486
- *
1487
- * @return string
1488
- **/
1489
- function exdate_to_text( $exception_dates ) {
1490
- $dates_to_add = array();
1491
- foreach( explode( ",", $exception_dates ) as $_exdate ) {
1492
- // convert to timestamp
1493
- $_exdate = strtotime( $_exdate );
1494
- $dates_to_add[] = $this->get_long_date( $_exdate, true );
1495
- }
1496
- // append dates to the string and return it;
1497
- return implode( ", ", $dates_to_add );
1498
- }
1499
-
1500
- /**
1501
- * ics_rule_to_local function
1502
- *
1503
- * @return void
1504
- **/
1505
- function ics_rule_to_local( $rule ) {
1506
- return $this->ics_rule_to( $rule, false );
1507
- }
1508
-
1509
- /**
1510
- * ics_rule_to_gmt function
1511
- *
1512
- * @return void
1513
- **/
1514
- function ics_rule_to_gmt( $rule ) {
1515
- return $this->ics_rule_to( $rule, true );
1516
- }
1517
-
1518
- /**
1519
- * ics_rule_to function
1520
- *
1521
- * @return void
1522
- **/
1523
- private function ics_rule_to( $rule, $to_gmt = false ) {
1524
- $rc = new Ai1ec_Recurrence_Helper( $rule );
1525
- if( $until = $rc->get_property( 'until' ) ) {
1526
- if( ! is_int( $until ) ) {
1527
- $until = strtotime( $until );
1528
- }
1529
- if( $to_gmt ) {
1530
- $until = $this->local_to_gmt( $until );
1531
- } else {
1532
- $until = $this->gmt_to_local( $until );
1533
- }
1534
-
1535
- $until = gmdate( "Ymd\THis\Z", $until );
1536
- $rule_props = explode( ';', $rule );
1537
- $_rule = array();
1538
- foreach( $rule_props as $property ) {
1539
- // don't apply any logic to empty properties
1540
- if( empty( $property ) ) {
1541
- $_rule[] = $property;
1542
- continue;
1543
- }
1544
- $name_and_value = explode( '=', $property );
1545
- if( isset( $name_and_value[0] ) && strtolower( $name_and_value[0] ) == 'until' ) {
1546
- if( isset( $name_and_value[1] ) ) {
1547
- $_rule[] = "UNTIL=" . $until;
1548
- }
1549
- } else {
1550
- $_rule[] = $property;
1551
- }
1552
- }
1553
- $rule = implode( ';', $_rule );
1554
- }
1555
- return $rule;
1556
- }
1557
-
1558
- /**
1559
- * exception_dates_to_local function
1560
- *
1561
- * @return string
1562
- **/
1563
- function exception_dates_to_local( $exception_dates ) {
1564
- return $this->exception_dates_to( $exception_dates, false );
1565
- }
1566
-
1567
- /**
1568
- * exception_dates_to_gmt function
1569
- *
1570
- * @return string
1571
- **/
1572
- function exception_dates_to_gmt( $exception_dates ) {
1573
- return $this->exception_dates_to( $exception_dates, true );
1574
- }
1575
-
1576
- /**
1577
- * exception_dates_to function
1578
- *
1579
- * @return string
1580
- **/
1581
- private function exception_dates_to( $exception_dates, $to_gmt = false ) {
1582
- $dates_to_add = array();
1583
- foreach( explode( ",", $exception_dates ) as $_exdate ) {
1584
- // convert to timestamp
1585
- $_exdate = strtotime( $_exdate );
1586
- if( $to_gmt ) {
1587
- $_exdate = $this->local_to_gmt( $_exdate );
1588
- } else {
1589
- $_exdate = $this->gmt_to_local( $_exdate );
1590
- }
1591
-
1592
- $dates_to_add[] = gmdate( "Ymd\THis\Z", $_exdate );
1593
- }
1594
- // append dates to the string and return it;
1595
- return implode( ",", $dates_to_add );
1596
- }
1597
-
1598
- /**
1599
- * _get_sentence_by function
1600
- *
1601
- * @internal
1602
- *
1603
- * @return void
1604
- **/
1605
- function _get_sentence_by( &$txt, $freq, $rc ) {
1606
- global $wp_locale;
1607
-
1608
- switch( $freq ) {
1609
- case 'weekly':
1610
- if( $rc->get_property( 'byday' ) ) {
1611
- if( count( $rc->get_property( 'byday' ) ) > 1 ) {
1612
- // if there are more than 3 days
1613
- // use days's abbr
1614
- if( count( $rc->get_property( 'byday' ) ) > 2 ) {
1615
- $_days = '';
1616
- foreach( $rc->get_property( 'byday' ) as $d ) {
1617
- $day = $this->get_weekday_by_id( $d, true );
1618
- $_days .= ' ' . $wp_locale->weekday_abbrev[$wp_locale->weekday[$day]] . ',';
1619
- }
1620
- // remove the last ' and'
1621
- $_days = substr( $_days, 0, -1 );
1622
- $txt .= ' ' . _x( 'on', 'Recurrence editor - weekly tab', AI1EC_PLUGIN_NAME ) . $_days;
1623
- } else {
1624
- $_days = '';
1625
- foreach( $rc->get_property( 'byday' ) as $d ) {
1626
- $day = $this->get_weekday_by_id( $d, true );
1627
- $_days .= ' ' . $wp_locale->weekday[$day] . ' ' . __( 'and', AI1EC_PLUGIN_NAME );
1628
- }
1629
- // remove the last ' and'
1630
- $_days = substr( $_days, 0, -4 );
1631
- $txt .= ' ' . _x( 'on', 'Recurrence editor - weekly tab', AI1EC_PLUGIN_NAME ) . $_days;
1632
- }
1633
- } else {
1634
- $_days = '';
1635
- foreach( $rc->get_property( 'byday' ) as $d ) {
1636
- $day = $this->get_weekday_by_id( $d, true );
1637
- $_days .= ' ' . $wp_locale->weekday[$day];
1638
- }
1639
- $txt .= ' ' . _x( 'on', 'Recurrence editor - weekly tab', AI1EC_PLUGIN_NAME ) . $_days;
1640
- }
1641
- }
1642
- break;
1643
- case 'monthly':
1644
- if( $rc->get_property( 'bymonthday' ) ) {
1645
- // if there are more than 2 days
1646
- if( count( $rc->get_property( 'bymonthday' ) ) > 2 ) {
1647
- $_days = '';
1648
- foreach( $rc->get_property( 'bymonthday' ) as $m_day ) {
1649
- $_days .= ' ' . $this->_ordinal( $m_day ) . ',';
1650
- }
1651
- $_days = substr( $_days, 0, -1 );
1652
- $txt .= ' ' . _x( 'on', 'Recurrence editor - monthly tab', AI1EC_PLUGIN_NAME ) . $_days . ' ' . __( 'of the month', AI1EC_PLUGIN_NAME );
1653
- } else if( count( $rc->get_property( 'bymonthday' ) ) > 1 ) {
1654
- $_days = '';
1655
- foreach( $rc->get_property( 'bymonthday' ) as $m_day ) {
1656
- $_days .= ' ' . $this->_ordinal( $m_day ) . ' ' . __( 'and', AI1EC_PLUGIN_NAME );
1657
- }
1658
- $_days = substr( $_days, 0, -4 );
1659
- $txt .= ' ' . _x( 'on', 'Recurrence editor - monthly tab', AI1EC_PLUGIN_NAME ) . $_days . ' ' . __( 'of the month', AI1EC_PLUGIN_NAME );
1660
- } else {
1661
- $_days = '';
1662
- foreach( $rc->get_property( 'bymonthday' ) as $m_day ) {
1663
- $_days .= ' ' . $this->_ordinal( $m_day );
1664
- }
1665
- $txt .= ' ' . _x( 'on', 'Recurrence editor - monthly tab', AI1EC_PLUGIN_NAME ) . $_days . ' ' . __( 'of the month', AI1EC_PLUGIN_NAME );
1666
- }
1667
- } elseif( $rc->get_property( 'byday' ) ) {
1668
- $_days = '';
1669
- foreach( $rc->get_property( 'byday' ) as $d ) {
1670
- $_dnum = substr( $d, 0, 1);
1671
- $_day = substr( $d, 1, 3 );
1672
- $dnum = ' ' . date_i18n( "jS", strtotime( $_dnum . '-01-1998 12:00:00' ) );
1673
- $day = $this->get_weekday_by_id( $_day, true );
1674
- $_days .= ' ' . $wp_locale->weekday[$day];
1675
- }
1676
- $txt .= ' ' . _x( 'on', 'Recurrence editor - monthly tab', AI1EC_PLUGIN_NAME ) . $dnum . $_days;
1677
- }
1678
- break;
1679
- case 'yearly':
1680
- if( $rc->get_property( 'bymonth' )) {
1681
- // if there are more than 2 months
1682
- if( count( $rc->get_property( 'bymonth' )) > 2 ) {
1683
- $_months = '';
1684
- foreach( $rc->get_property( 'bymonth' )as $_m ) {
1685
- $_m = $_m < 10 ? 0 . $_m : $_m;
1686
- $_months .= ' ' . $wp_locale->month_abbrev[$wp_locale->month[$_m]] . ',';
1687
- }
1688
- $_months = substr( $_months, 0, -1 );
1689
- $txt .= ' ' . _x( 'on', 'Recurrence editor - yearly tab', AI1EC_PLUGIN_NAME ) . $_months;
1690
- } else if( count( $rc->get_property( 'bymonth' )) > 1 ) {
1691
- $_months = '';
1692
- foreach( $rc->get_property( 'bymonth' )as $_m ) {
1693
- $_m = $_m < 10 ? 0 . $_m : $_m;
1694
- $_months .= ' ' . $wp_locale->month[$_m] . ' ' . __( 'and', AI1EC_PLUGIN_NAME );
1695
- }
1696
- $_months = substr( $_months, 0, -4 );
1697
- $txt .= ' ' . _x( 'on', 'Recurrence editor - yearly tab', AI1EC_PLUGIN_NAME ) . $_months;
1698
- } else {
1699
- $_months = '';
1700
- foreach( $rc->get_property( 'bymonth' )as $_m ) {
1701
- $_m = $_m < 10 ? 0 . $_m : $_m;
1702
- $_months .= ' ' . $wp_locale->month[$_m];
1703
- }
1704
- $txt .= ' ' . _x( 'on', 'Recurrence editor - yearly tab', AI1EC_PLUGIN_NAME ) . $_months;
1705
- }
1706
- }
1707
- break;
1708
- }
1709
- }
1710
-
1711
- /**
1712
- * _ordinal function
1713
- *
1714
- * @internal
1715
- *
1716
- * @return void
1717
- **/
1718
- function _ordinal( $cdnl ) {
1719
- $locale = explode( '_', get_locale() );
1720
-
1721
- if( isset( $locale[0] ) && $locale[0] != 'en' )
1722
- return $cdnl;
1723
-
1724
- $test_c = abs($cdnl) % 10;
1725
- $ext = ( ( abs( $cdnl ) % 100 < 21 && abs( $cdnl ) % 100 > 4 ) ? 'th'
1726
- : ( ( $test_c < 4 ) ? ( $test_c < 3 ) ? ( $test_c < 2 ) ? ( $test_c < 1 )
1727
- ? 'th' : 'st' : 'nd' : 'rd' : 'th' ) );
1728
- return $cdnl.$ext;
1729
- }
1730
-
1731
- /**
1732
- * _get_interval function
1733
- *
1734
- * @internal
1735
- *
1736
- * @return void
1737
- **/
1738
- function _get_interval( &$txt, $freq, $interval ) {
1739
- switch( $freq ) {
1740
- case 'daily':
1741
- // check if interval is set
1742
- if( ! $interval || $interval == 1 ) {
1743
- $txt = __( 'Daily', AI1EC_PLUGIN_NAME );
1744
- } else {
1745
- if( $interval == 2 ) {
1746
- $txt = __( 'Every other day', AI1EC_PLUGIN_NAME );
1747
- } else {
1748
- $txt = sprintf( __( 'Every %d days', AI1EC_PLUGIN_NAME ), $interval );
1749
- }
1750
- }
1751
- break;
1752
- case 'weekly':
1753
- // check if interval is set
1754
- if( ! $interval || $interval == 1 ) {
1755
- $txt = __( 'Weekly', AI1EC_PLUGIN_NAME );
1756
- } else {
1757
- if( $interval == 2 ) {
1758
- $txt = __( 'Every other week', AI1EC_PLUGIN_NAME );
1759
- } else {
1760
- $txt = sprintf( __( 'Every %d weeks', AI1EC_PLUGIN_NAME ), $interval );
1761
- }
1762
- }
1763
- break;
1764
- case 'monthly':
1765
- // check if interval is set
1766
- if( ! $interval || $interval == 1 ) {
1767
- $txt = __( 'Monthly', AI1EC_PLUGIN_NAME );
1768
- } else {
1769
- if( $interval == 2 ) {
1770
- $txt = __( 'Every other month', AI1EC_PLUGIN_NAME );
1771
- } else {
1772
- $txt = sprintf( __( 'Every %d months', AI1EC_PLUGIN_NAME ), $interval );
1773
- }
1774
- }
1775
- break;
1776
- case 'yearly':
1777
- // check if interval is set
1778
- if( ! $interval || $interval == 1 ) {
1779
- $txt = __( 'Yearly', AI1EC_PLUGIN_NAME );
1780
- } else {
1781
- if( $interval == 2 ) {
1782
- $txt = __( 'Every other year', AI1EC_PLUGIN_NAME );
1783
- } else {
1784
- $txt = sprintf( __( 'Every %d years', AI1EC_PLUGIN_NAME ), $interval );
1785
- }
1786
- }
1787
- break;
1788
- }
1789
- }
1790
-
1791
- /**
1792
- * _ending_sentence function
1793
- *
1794
- * Ends rrule to text sentence
1795
- *
1796
- * @internal
1797
- *
1798
- * @return void
1799
- **/
1800
- function _ending_sentence( &$txt, &$rc ) {
1801
- if( $until = $rc->get_property( 'until' ) ) {
1802
- if( ! is_int( $until ) )
1803
- $until = strtotime( $until );
1804
- $txt .= ' ' . sprintf( __( 'until %s', AI1EC_PLUGIN_NAME ), date_i18n( get_option( 'date_format' ), $until, true ) );
1805
- }
1806
- else if( $count = $rc->get_property( 'count' ) )
1807
- $txt .= ' ' . sprintf( __( 'for %d occurrences', AI1EC_PLUGIN_NAME ), $count );
1808
- else
1809
- $txt .= ' - ' . __( 'forever', AI1EC_PLUGIN_NAME );
1810
- }
1811
-
1812
- /**
1813
- * undocumented function
1814
- *
1815
- *
1816
- *
1817
- * @return void
1818
- **/
1819
- function convert_rrule_to_text() {
1820
- $error = false;
1821
- // check to see if RRULE is set
1822
- if( isset( $_REQUEST["rrule"] ) ) {
1823
-
1824
- // check to see if rrule is empty
1825
- if( empty( $_REQUEST["rrule"] ) ) {
1826
- $error = true;
1827
- $message = 'Recurrence rule cannot be empty!';
1828
- } else {
1829
- // convert rrule to text
1830
- $message = $this->rrule_to_text( $_REQUEST["rrule"] );
1831
- }
1832
-
1833
- } else {
1834
- $error = true;
1835
- $message = 'Recurrence rule is not provided!';
1836
- }
1837
-
1838
- $output = array(
1839
- "error" => $error,
1840
- "message" => stripslashes( $message )
1841
- );
1842
-
1843
- echo json_encode( $output );
1844
- exit();
1845
- }
1846
-
1847
- /**
1848
- * post_type_link function
1849
- *
1850
- *
1851
- *
1852
- * @return void
1853
- **/
1854
- function post_type_link( $permalink, $post, $leavename ) {
1855
- global $ai1ec_app_helper;
1856
-
1857
- if( $post->post_type == AI1EC_POST_TYPE ) {
1858
- $delimiter = $ai1ec_app_helper->get_param_delimiter_char( $permalink );
1859
- return $permalink . $delimiter . 'instance_id=';
1860
- }
1861
-
1862
- return $permalink;
1863
- }
1864
-
1865
- /**
1866
- * get_repeat_box function
1867
- *
1868
- * @return string
1869
- **/
1870
- function get_repeat_box() {
1871
- global $ai1ec_view_helper;
1872
-
1873
- $repeat = (int) $_REQUEST["repeat"];
1874
- $repeat = $repeat == 1 ? 1 : 0;
1875
- $post_id = (int) $_REQUEST["post_id"];
1876
- $count = 100;
1877
- $end = null;
1878
- $until = gmmktime();
1879
-
1880
- // try getting the event
1881
- try {
1882
- $event = new Ai1ec_Event( $post_id );
1883
- $rule = '';
1884
-
1885
- if( $repeat ) {
1886
- $rule = empty( $event->recurrence_rules ) ? '' : $event->recurrence_rules;
1887
- } else {
1888
- $rule = empty( $event->exception_rules ) ? '' : $event->exception_rules;
1889
- }
1890
-
1891
- $recurrence_helper = new Ai1ec_Recurrence_Helper( $rule );
1892
-
1893
- if( $until = $recurrence_helper->get_property( 'until' ) ) {
1894
- $until = ( is_numeric( $until ) ) ? $until : strtotime( $until );
1895
- }
1896
- else if( $count = $recurrence_helper->get_property( 'count' ) ) {
1897
- $count = ( is_numeric( $count ) ) ? $count : 100;
1898
- }
1899
- } catch( Ai1ec_Event_Not_Found $e ) { /* event wasn't found, keep defaults */ }
1900
-
1901
- $args = array(
1902
- 'row_daily' => $this->row_daily(),
1903
- 'row_weekly' => $this->row_weekly(),
1904
- 'row_monthly' => $this->row_monthly(),
1905
- 'row_yearly' => $this->row_yearly(),
1906
- 'count' => $this->create_count_input( 'ai1ec_count', $count ) . __( 'times', AI1EC_PLUGIN_NAME ),
1907
- 'end' => $this->create_end_dropdown( $end ),
1908
- 'until' => $until,
1909
- 'repeat' => $repeat
1910
- );
1911
- $output = array(
1912
- "error" => false,
1913
- "message" => $ai1ec_view_helper->get_admin_view( 'box_repeat.php', $args ),
1914
- "repeat" => $repeat
1915
- );
1916
-
1917
- echo json_encode( $output );
1918
- exit();
1919
- }
1920
- /**
1921
- * get_date_picker_box function
1922
- *
1923
- * @return string
1924
- **/
1925
- function get_date_picker_box() {
1926
- global $ai1ec_view_helper;
1927
-
1928
- $dates = '';
1929
-
1930
- $args = array(
1931
- 'dates' => $dates
1932
- );
1933
-
1934
- $output = array(
1935
- "error" => false,
1936
- "message" => $ai1ec_view_helper->get_admin_view( 'box_date_picker.php', $args ),
1937
- );
1938
-
1939
- echo json_encode( $output );
1940
- exit();
1941
- }
1942
-
1943
- /**
1944
- * shortcode method
1945
- *
1946
- * Generate replacement content for [ai1ec] shortcode.
1947
- *
1948
- * @param array $atts Attributes provided on shortcode
1949
- * @param string $content Tag internal content (shall be empty)
1950
- * @param string $tag Used tag name (must be 'ai1ec' always)
1951
- *
1952
- * @staticvar $call_count Used to restrict to single calendar per page
1953
- *
1954
- * @return string Replacement for shortcode entry
1955
- **/
1956
- function shortcode( $atts, $content = '', $tag = 'ai1ec' ) {
1957
- static $call_count = 0;
1958
- global $ai1ec_settings;
1959
- ++$call_count;
1960
- if ( $call_count > 1 ) { // not implemented
1961
- return false; // so far process only first request
1962
- }
1963
- $view = $ai1ec_settings->default_calendar_view;
1964
- $categories = $tags = $post_ids = array();
1965
- $known_views = array(
1966
- 'agenda' => true,
1967
- 'month' => true,
1968
- 'week' => true,
1969
- );
1970
- if ( isset( $atts['view'] ) ) {
1971
- if ( 'ly' === substr( $atts['view'], -2 ) ) {
1972
- $atts['view'] = substr( $atts['view'], 0, -2 );
1973
- }
1974
- if ( ! isset( $known_views[$atts['view']] ) ) {
1975
- return false;
1976
- }
1977
- $view = $atts['view'];
1978
- }
1979
- $view = 'ai1ec_' . $view;
1980
- $mappings = array(
1981
- 'cat_name' => 'categories',
1982
- 'cat_id' => 'categories',
1983
- 'tag_name' => 'tags',
1984
- 'tag_id' => 'tags',
1985
- 'post_id' => 'post_ids',
1986
- );
1987
- foreach ( $mappings as $att_name => $type ) {
1988
- if ( ! isset( $atts[$att_name] ) ) {
1989
- continue;
1990
- }
1991
- $raw_values = explode( ',', $atts[$att_name] );
1992
- foreach ( $raw_values as $argument ) {
1993
- if ( 'post_id' === $att_name ) {
1994
- if ( ( $argument = (int)$argument ) > 0 ) {
1995
- $post_ids[] = $argument;
1996
- }
1997
- } else {
1998
- if ( ! is_numeric( $argument ) ) {
1999
- $argument = trim( $argument );
2000
- foreach ( array( 'name', 'slug' ) as $field ) {
2001
- $record = get_term_by(
2002
- $field,
2003
- $argument,
2004
- 'events_' . $type
2005
- );
2006
- if ( false !== $record ) {
2007
- $argument = $record;
2008
- break;
2009
- }
2010
- }
2011
- if ( false === $argument ) {
2012
- continue;
2013
- }
2014
- $argument = (int)$argument->term_id;
2015
- } else {
2016
- if ( ( $argument = (int)$argument ) <= 0 ) {
2017
- continue;
2018
- }
2019
- }
2020
- ${$type}[] = $argument;
2021
- }
2022
- }
2023
- }
2024
- $query = array(
2025
- 'ai1ec_cat_ids' => implode( ',', $categories ),
2026
- 'ai1ec_tag_ids' => implode( ',', $tags ),
2027
- 'ai1ec_post_ids' => implode( ',', $post_ids ),
2028
- 'action' => $view,
2029
- );
2030
- return $this->_get_view_and_restore_globals( $query );
2031
- }
2032
-
2033
- /**
2034
- * get_week_start_day_offset function
2035
- *
2036
- * Returns the day offset of the first day of the week given a weekday in
2037
- * question.
2038
- *
2039
- * @param int $wday The weekday to get information about
2040
- * @return int A value between -6 and 0 indicating the week start
2041
- * day relative to the given weekday.
2042
- */
2043
- function get_week_start_day_offset( $wday ) {
2044
- global $ai1ec_settings;
2045
-
2046
- return - ( 7 - ( $ai1ec_settings->week_start_day - $wday ) ) % 7;
2047
- }
2048
-
2049
- /**
2050
- * _get_view_and_restore_globals method
2051
- *
2052
- * Set global request ($_REQUEST) variables, call rendering routines
2053
- * and reset $_REQUEST afterwards.
2054
- *
2055
- * @uses do_action To launch
2056
- * 'ai1ec_load_frontend_js' action
2057
- * @uses Ai1ec_App_Controller::append_content() To wrap output in
2058
- * namespaced container
2059
- *
2060
- * @param array $arguments Arguments to set for rendering
2061
- *
2062
- * @return string Rendered view
2063
- */
2064
- protected function _get_view_and_restore_globals( $arguments ) {
2065
- global $ai1ec_calendar_controller, $ai1ec_app_controller;
2066
- $restore_map = array();
2067
- foreach ( $arguments as $key => $value ) {
2068
- if ( isset( $_REQUEST[$key] ) ) {
2069
- $restore_map[$key] = $_REQUEST[$key];
2070
- } else {
2071
- $restore_map[$key] = NULL;
2072
- }
2073
- $_REQUEST[$key] = $value;
2074
- }
2075
- ob_start();
2076
- $ai1ec_calendar_controller->view();
2077
- $page_content = ob_get_clean();
2078
- $page_content = $ai1ec_app_controller->append_content( $page_content );
2079
- do_action( 'ai1ec_load_frontend_js', true );
2080
- foreach ( $restore_map as $key => $value ) {
2081
- if ( NULL === $value ) {
2082
- unset( $_REQUEST[$key] );
2083
- } else {
2084
- $_REQUEST[$key] = $value;
2085
- }
2086
- }
2087
- return $page_content;
2088
- }
2089
-
2090
- }
2091
- // END class
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/helper/class-ai1ec-exporter-helper.php DELETED
@@ -1,192 +0,0 @@
1
- <?php
2
- //
3
- // class-ai1ec-exporter-helper.php
4
- // all-in-one-event-calendar
5
- //
6
- // Created by The Seed Studio on 2011-07-13.
7
- //
8
-
9
- /**
10
- * Ai1ec_Exporter_Helper class
11
- *
12
- * @package Helpers
13
- * @author time.ly
14
- **/
15
- class Ai1ec_Exporter_Helper {
16
- /**
17
- * _instance class variable
18
- *
19
- * Class instance
20
- *
21
- * @var null | object
22
- **/
23
- private static $_instance = NULL;
24
-
25
- /**
26
- * Constructor
27
- *
28
- * Default constructor
29
- **/
30
- private function __construct() { }
31
-
32
- /**
33
- * get_instance function
34
- *
35
- * Return singleton instance
36
- *
37
- * @return object
38
- **/
39
- static function get_instance() {
40
- if( self::$_instance === NULL ) {
41
- self::$_instance = new self();
42
- }
43
-
44
- return self::$_instance;
45
- }
46
-
47
- /**
48
- * insert_event_in_calendar function
49
- *
50
- * Add event to the calendar
51
- *
52
- * @param object $event Event object
53
- * @param object $c Calendar object
54
- * @param bool $export States whether events are created for export
55
- *
56
- * @return void
57
- **/
58
- function insert_event_in_calendar( $event, &$c, $export = false )
59
- {
60
- global $ai1ec_events_helper;
61
-
62
- $tz = get_option( 'timezone_string' );
63
-
64
- $e = & $c->newComponent( 'vevent' );
65
- $uid = $event->ical_uid ?
66
- $event->ical_uid : addcslashes( $event->post->guid, "\\;,\n" );
67
- $e->setProperty( 'uid', $uid );
68
- $e->setProperty( 'url', get_permalink( $event->post_id ) );
69
- $e->setProperty( 'summary', html_entity_decode( apply_filters( 'the_title', $event->post->post_title ), ENT_QUOTES, 'UTF-8' ) );
70
- $content = apply_filters( 'the_content', $event->post->post_content );
71
- $content = str_replace(']]>', ']]&gt;', $content);
72
- $e->setProperty( 'description', $content );
73
- if ( $event->allday ) {
74
- $dtstart = $dtend = array();
75
- $dtstart["VALUE"] = $dtend["VALUE"] = 'DATE';
76
- // For exporting all day events, don't set a timezone
77
- if ( $tz && !$export ) {
78
- $dtstart["TZID"] = $dtend["TZID"] = $tz;
79
- }
80
-
81
- // For exporting all day events, only set the date not the time
82
- if ( $export ) {
83
- $e->setProperty( 'dtstart', gmdate( "Ymd", $ai1ec_events_helper->gmt_to_local( $event->start ) ), $dtstart );
84
- $e->setProperty( 'dtend', gmdate( "Ymd", $ai1ec_events_helper->gmt_to_local( $event->end ) ), $dtend );
85
- } else {
86
- $e->setProperty( 'dtstart', gmdate( "Ymd\T", $ai1ec_events_helper->gmt_to_local( $event->start ) ), $dtstart );
87
- $e->setProperty( 'dtend', gmdate( "Ymd\T", $ai1ec_events_helper->gmt_to_local( $event->end ) ), $dtend );
88
- }
89
- } else {
90
- $dtstart = $dtend = array();
91
- if ( $tz ) {
92
- $dtstart["TZID"] = $dtend["TZID"] = $tz;
93
- }
94
-
95
- $e->setProperty( 'dtstart', gmdate( "Ymd\THis\Z", $ai1ec_events_helper->gmt_to_local( $event->start ) ), $dtstart );
96
-
97
- $e->setProperty( 'dtend', gmdate( "Ymd\THis\Z", $ai1ec_events_helper->gmt_to_local( $event->end ) ), $dtend );
98
- }
99
- if ( $event->address ) {
100
- $e->setProperty( 'location', $event->address );
101
- }
102
-
103
- $contact = ! empty( $event->contact_name ) ? $event->contact_name : '';
104
- $contact .= ! empty( $event->contact_phone ) ? " ($event->contact_phone)" : '';
105
- $contact .= ! empty( $event->contact_email ) ? " <$event->contact_email>" : '';
106
- $e->setProperty( 'contact', $contact );
107
-
108
- $rrule = array();
109
- if ( ! empty( $event->recurrence_rules ) ) {
110
- $rules = array();
111
- foreach ( explode( ';', $event->recurrence_rules ) as $v) {
112
- if ( strpos( $v, '=' ) === false ) continue;
113
-
114
- list($k, $v) = explode( '=', $v );
115
- $k = strtoupper( $k );
116
- // If $v is a comma-separated list, turn it into array for iCalcreator
117
- switch ( $k ) {
118
- case 'BYSECOND':
119
- case 'BYMINUTE':
120
- case 'BYHOUR':
121
- case 'BYDAY':
122
- case 'BYMONTHDAY':
123
- case 'BYYEARDAY':
124
- case 'BYWEEKNO':
125
- case 'BYMONTH':
126
- case 'BYSETPOS':
127
- $exploded = explode( ',', $v );
128
- break;
129
- default:
130
- $exploded = $v;
131
- break;
132
- }
133
- // iCalcreator requires a more complex array structure for BYDAY...
134
- if ( $k == 'BYDAY' ) {
135
- $v = array();
136
- foreach ( $exploded as $day ) {
137
- $v[] = array( 'DAY' => $day );
138
- }
139
- } else {
140
- $v = $exploded;
141
- }
142
- $rrule[ $k ] = $v;
143
- }
144
- }
145
-
146
- $exrule = array();
147
- if ( ! empty( $event->exception_rules ) ) {
148
- $rules = array();
149
- foreach ( explode( ';', $event->exception_rules ) as $v) {
150
- if ( strpos( $v, '=' ) === false ) continue;
151
-
152
- list($k, $v) = explode( '=', $v );
153
- $k = strtoupper( $k );
154
- // If $v is a comma-separated list, turn it into array for iCalcreator
155
- switch ( $k ) {
156
- case 'BYSECOND':
157
- case 'BYMINUTE':
158
- case 'BYHOUR':
159
- case 'BYDAY':
160
- case 'BYMONTHDAY':
161
- case 'BYYEARDAY':
162
- case 'BYWEEKNO':
163
- case 'BYMONTH':
164
- case 'BYSETPOS':
165
- $exploded = explode( ',', $v );
166
- break;
167
- default:
168
- $exploded = $v;
169
- break;
170
- }
171
- // iCalcreator requires a more complex array structure for BYDAY...
172
- if ( $k == 'BYDAY' ) {
173
- $v = array();
174
- foreach ( $exploded as $day ) {
175
- $v[] = array( 'DAY' => $day );
176
- }
177
- } else {
178
- $v = $exploded;
179
- }
180
- $exrule[ $k ] = $v;
181
- }
182
- }
183
-
184
- // add rrule to exported calendar
185
- if ( ! empty( $rrule ) ) $e->setProperty( 'rrule', $rrule );
186
- // add exrule to exported calendar
187
- if ( ! empty( $exrule ) ) $e->setProperty( 'exrule', $exrule );
188
- // add exdates to exported calendar
189
- if ( ! empty( $event->exception_dates ) )
190
- $e->setProperty( 'exdate', explode( ',', $event->exception_dates ) );
191
- }
192
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/helper/class-ai1ec-importer-helper.php DELETED
@@ -1,282 +0,0 @@
1
- <?php
2
- //
3
- // class-ai1ec-importer-helper.php
4
- // all-in-one-event-calendar
5
- //
6
- // Created by The Seed Studio on 2011-07-13.
7
- //
8
-
9
- /**
10
- * Ai1ec_Importer_Helper class
11
- *
12
- * @package Helpers
13
- * @author time.ly
14
- **/
15
- class Ai1ec_Importer_Helper {
16
- /**
17
- * _instance class variable
18
- *
19
- * Class instance
20
- *
21
- * @var null | object
22
- **/
23
- private static $_instance = NULL;
24
-
25
- /**
26
- * Constructor
27
- *
28
- * Default constructor
29
- **/
30
- private function __construct() { }
31
-
32
- /**
33
- * get_instance function
34
- *
35
- * Return singleton instance
36
- *
37
- * @return object
38
- **/
39
- static function get_instance() {
40
- if( self::$_instance === NULL ) {
41
- self::$_instance = new self();
42
- }
43
-
44
- return self::$_instance;
45
- }
46
-
47
- /**
48
- * time_array_to_timestamp function
49
- *
50
- * Converts time array to time string.
51
- * Passed array: Array( 'year', 'month', 'day', ['hour', 'min', 'sec', ['tz']] )
52
- * Return int: UNIX timestamp in GMT
53
- *
54
- * @param array $t iCalcreator's time property array (*full* format expected)
55
- * @param string $def_timezone Default time zone in case not defined in $t
56
- *
57
- * @return int UNIX timestamp
58
- **/
59
- function time_array_to_timestamp( $t, $def_timezone ) {
60
- $ret = $t['value']['year'] .
61
- '-' . $t['value']['month'] .
62
- '-' . $t['value']['day'];
63
- if( isset( $t['value']['hour'] ) )
64
- $ret .= ' ' . $t['value']['hour'] .
65
- ':' . $t['value']['min'] .
66
- ':' . $t['value']['sec'];
67
- $timezone = '';
68
- if( isset( $t['value']['tz'] ) && $t['value']['tz'] == 'Z' )
69
- $timezone = 'Z';
70
- elseif( isset( $t['params']['TZID'] ) )
71
- $timezone = $t['params']['TZID'];
72
-
73
- if( empty( $timezone ) ) $timezone = $def_timezone;
74
- if( $timezone )
75
- $ret .= ' ' . $timezone;
76
- return strtotime( $ret );
77
- }
78
-
79
- /**
80
- * Gets and parses an iCalendar feed into an array of Ai1ec_Event objects
81
- *
82
- * @param object $feed Row from the ai1ec_event_feeds table
83
- *
84
- * @return int Number of events imported
85
- */
86
- function parse_ics_feed( &$feed )
87
- {
88
- global $ai1ec_events_helper;
89
-
90
- $count = 0;
91
-
92
- // include ical parser
93
- require_once( AI1EC_LIB_PATH . '/iCalcreator-2.16/iCalcreator.class.php' );
94
-
95
- // set unique id, required if any component UID is missing
96
- $config = array( 'unique_id' => 'ai1ec' );
97
-
98
- // create new instance
99
- $v = new vcalendar( array(
100
- 'unique_id' => $feed->feed_url,
101
- 'url' => $feed->feed_url,
102
- ) );
103
-
104
- // actual parse of the feed
105
- if( $v->parse() )
106
- {
107
- $v->sort();
108
- // Reverse the sort order, so that RECURRENCE-IDs are listed before the
109
- // defining recurrence events, and therefore take precedence during
110
- // caching.
111
- $v->components = array_reverse( $v->components );
112
-
113
- // TODO: select only VEVENT components that occur after, say, 1 month ago.
114
- // Maybe use $v->selectComponents(), which takes into account recurrence
115
-
116
- // Fetch default timezone in case individual properties don't define it
117
- $timezone = $v->getProperty( 'X-WR-TIMEZONE' );
118
- $timezone = $timezone[1];
119
-
120
- // go over each event
121
- while( $e = $v->getComponent( 'vevent' ) )
122
- {
123
- $start = $e->getProperty( 'dtstart', 1, true );
124
- $end = $e->getProperty( 'dtend', 1, true );
125
- // For cases where a "VEVENT" calendar component
126
- // specifies a "DTSTART" property with a DATE value type but no
127
- // "DTEND" nor "DURATION" property, the event's duration is taken to
128
- // be one day. For cases where a "VEVENT" calendar component
129
- // specifies a "DTSTART" property with a DATE-TIME value type but no
130
- // "DTEND" property, the event ends on the same calendar date and
131
- // time of day specified by the "DTSTART" property.
132
- if( empty( $end ) ) {
133
- // #1 if duration is present, assign it to end time
134
- $end = $e->getProperty( 'duration', 1, true, true );
135
- if( empty( $end ) ) {
136
- // #2 if only DATE value is set for start, set duration to 1 day
137
- if( ! isset( $start['value']['hour'] ) ) {
138
- $end = array(
139
- 'year' => $start['value']['year'],
140
- 'month' => $start['value']['month'],
141
- 'day' => $start['value']['day'],
142
- 'hour' => 23,
143
- 'min' => 59,
144
- 'sec' => 59,
145
- 'tz' => $start['value']['tz']
146
- );
147
- } else {
148
- // #3 set end date to start time
149
- $end = $start;
150
- }
151
- }
152
- }
153
-
154
- // Event is all-day if no time components are defined
155
- $allday = ! isset( $start['value']['hour'] );
156
- // Also check the proprietary MS all-day field.
157
- $ms_allday = $e->getProperty( 'X-MICROSOFT-CDO-ALLDAYEVENT' );
158
- if ( ! empty( $ms_allday ) && $ms_allday[1] == 'TRUE' ) {
159
- $allday = true;
160
- }
161
-
162
- // convert times to GMT UNIX timestamps
163
- $start = $this->time_array_to_timestamp( $start, $timezone );
164
- $end = $this->time_array_to_timestamp( $end, $timezone );
165
-
166
- // If all-day, and start and end times are equal, then this event has
167
- // invalid end time (happens sometimes with poorly implemented iCalendar
168
- // exports, such as in The Event Calendar), so set end time to 1 day
169
- // after start time.
170
- if( $allday && $start === $end )
171
- $end += 24 * 60 * 60;
172
-
173
- // Due to potential time zone differences (WP time zone vs. feed time
174
- // zone), must convert all-day event start/end dates to date only (the
175
- // *intended* local date, non-GMT-ified)
176
- if( $allday ) {
177
- // If feed hasn't provided a time zone, iCalcreator returns all-day
178
- // start & end times that are correct for the local time zone. We must
179
- // not localize again lest we cause incorrect offsets.
180
- if ( $timezone ) {
181
- $start = $ai1ec_events_helper->gmt_to_local( $start );
182
- $end = $ai1ec_events_helper->gmt_to_local( $end );
183
- }
184
-
185
- $start = $ai1ec_events_helper->gmgetdate( $start );
186
- $start = gmmktime( 0, 0, 0, $start['mon'], $start['mday'], $start['year'] );
187
- $start = $ai1ec_events_helper->local_to_gmt( $start );
188
- $end = $ai1ec_events_helper->gmgetdate( $end );
189
- $end = gmmktime( 0, 0, 0, $end['mon'], $end['mday'], $end['year'] );
190
- $end = $ai1ec_events_helper->local_to_gmt( $end );
191
- }
192
-
193
- if( $rrule = $e->createRrule() )
194
- $rrule = trim( end( explode( ':', $rrule ) ) );
195
- if( $exrule = $e->createExrule() )
196
- $exrule = trim( end( explode( ':', $exrule ) ) );
197
- if( $rdate = $e->createRdate() )
198
- $rdate = trim( end( explode( ':', $rdate ) ) );
199
- if( $exdate = $e->createExdate() )
200
- $exdate = trim( end( explode( ':', $exdate ) ) );
201
-
202
- $data = array(
203
- 'start' => $start,
204
- 'end' => $end,
205
- 'allday' => $allday,
206
- 'recurrence_rules' => $rrule,
207
- 'exception_rules' => $exrule,
208
- 'recurrence_dates' => $rdate,
209
- 'exception_dates' => $exdate,
210
- 'venue' => $e->getProperty( 'location' ),
211
- 'ical_feed_url' => $feed->feed_url,
212
- 'ical_source_url' => $e->getProperty( 'url' ),
213
- 'ical_organizer' => $e->getProperty( 'organizer' ),
214
- 'ical_contact' => $e->getProperty( 'contact' ),
215
- 'ical_uid' => $e->getProperty( 'uid' ),
216
- 'categories' => $feed->feed_category,
217
- 'tags' => $feed->feed_tags,
218
- 'feed' => $feed,
219
- 'post' => array(
220
- 'post_status' => 'publish',
221
- 'post_type' => AI1EC_POST_TYPE,
222
- 'post_author' => 1,
223
- 'post_title' => $e->getProperty( 'summary' ),
224
- 'post_content' => stripslashes( str_replace( '\n', "\n", $e->getProperty( 'description' ) ) ),
225
- ),
226
- );
227
-
228
- $event = new Ai1ec_Event( $data );
229
-
230
- // TODO: when singular events change their times in an ICS feed from one
231
- // import to another, the matching_event_id is null, which is wrong. We
232
- // want to match that event that previously had a different time.
233
- // However, we also want the function to NOT return a matching event in
234
- // the case of recurring events, and different events with different
235
- // RECURRENCE-IDs... ponder how to solve this.. may require saving the
236
- // RECURRENCE-ID as another field in the database.
237
- $matching_event_id = $ai1ec_events_helper->get_matching_event_id(
238
- $event->ical_uid,
239
- $event->ical_feed_url,
240
- $event->start,
241
- ! empty( $event->recurrence_rules )
242
- );
243
-
244
- if( is_null( $matching_event_id ) )
245
- {
246
- // =================================================
247
- // = Event was not found, so store it and the post =
248
- // =================================================
249
- $event->save();
250
- }
251
- else
252
- {
253
- // ======================================================
254
- // = Event was found, let's store the new event details =
255
- // ======================================================
256
-
257
- // Update the post
258
- $post = get_post( $matching_event_id );
259
- $post->post_title = $event->post->post_title;
260
- $post->post_content = $event->post->post_content;
261
- wp_update_post( $post );
262
-
263
- // Update the event
264
- $event->post_id = $matching_event_id;
265
- $event->post = $post;
266
- $event->save( true );
267
-
268
- // Delete event's cache
269
- $ai1ec_events_helper->delete_event_cache( $matching_event_id );
270
- }
271
-
272
- // Regenerate event's cache
273
- $ai1ec_events_helper->cache_event( $event );
274
-
275
- $count++;
276
- }
277
- }
278
-
279
- return $count;
280
- }
281
- }
282
- // END class
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/helper/class-ai1ec-recurrence-helper.php DELETED
@@ -1,110 +0,0 @@
1
- <?php
2
-
3
- /**
4
- * Handles parsing of ICS recurrence rules
5
- *
6
- * @author Time.ly Network, Inc.
7
- * @since 1.10.3
8
- */
9
- class Ai1ec_Recurrence_Helper
10
- {
11
-
12
- /**
13
- * @var string Parsed rule copy
14
- */
15
- public $rrule;
16
-
17
- /**
18
- * @var array Map of parsed rule keys and values
19
- */
20
- protected $_properties = array();
21
-
22
- /**
23
- * @var array Replacement keys to use in rules cleanup
24
- */
25
- protected $replacements = array(
26
- 'from' => array( '\\,', '\\n', '\\;', '\\:', '\\"',),
27
- 'to' => array( ',', "\n", ';', ':', '"', ),
28
- );
29
-
30
- /**
31
- * @var array Map of properties possibly having comma-separated values
32
- */
33
- protected $comma_separated_properties = array(
34
- 'bysecond' => true,
35
- 'byminute' => true,
36
- 'byhour' => true,
37
- 'byday' => true,
38
- 'bymonthday' => true,
39
- 'byyearday' => true,
40
- 'byyearno' => true,
41
- 'bymonth' => true,
42
- 'bysetpos' => true,
43
- );
44
-
45
- /**
46
- * Constructor
47
- *
48
- * @param string $rrule Recurrence rule to initiate with
49
- *
50
- * @return void Constructor does not return
51
- */
52
- public function __construct( $rrule ) {
53
- $this->parse_recurrence_rule( $rrule );
54
- }
55
-
56
- /**
57
- * Parse arbitrary recurrence rule into keys and values
58
- *
59
- * @param string $rrule Recurrence rule to initiate with
60
- *
61
- * @return void Method doesn't return
62
- */
63
- public function parse_recurrence_rule( $rrule ) {
64
- $this->_properties = array();
65
- // some clean up
66
- $rrule = trim( $rrule );
67
- $rrule = str_replace(
68
- $this->replacements['from'],
69
- $this->replacements['to'],
70
- $rrule
71
- );
72
-
73
- $this->rrule = $rrule;
74
- $recurrence_rule_properties = explode( ';', $rrule );
75
-
76
- foreach ( $recurrence_rule_properties as $property ) {
77
- $property = trim( $property );
78
- if ( empty( $property ) ) {
79
- continue;
80
- }
81
- // it's always name=value
82
- $exploded_property = explode( '=', $property );
83
-
84
- $property_name = strtolower( $exploded_property[0] );
85
- $property_value = $exploded_property[1];
86
-
87
- //split up the list of values into an array (if it's a list)
88
- if ( isset( $this->comma_separated_properties[$property_name] ) ) {
89
- $property_value = explode( ',', $property_value );
90
- }
91
- $this->_properties[$property_name] = $property_value;
92
- }
93
- }
94
-
95
- /**
96
- * Return the value for requested property
97
- *
98
- * @param string $property Name of property to get
99
- * @param mixed $default Value to return when property doesn't exist [optional=false]
100
- *
101
- * @return mixed Value or $default
102
- */
103
- public function get_property( $property, $default = false ) {
104
- if ( isset( $this->_properties[$property] ) ) {
105
- return $this->_properties[$property];
106
- }
107
- return $default;
108
- }
109
-
110
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/helper/class-ai1ec-settings-helper.php DELETED
@@ -1,443 +0,0 @@
1
- <?php
2
- //
3
- // class-ai1ec-settings-helper.php
4
- // all-in-one-event-calendar
5
- //
6
- // Created by The Seed Studio on 2011-07-13.
7
- //
8
-
9
- /**
10
- * Ai1ec_Settings_Helper class
11
- *
12
- * @package Helpers
13
- * @author time.ly
14
- **/
15
- class Ai1ec_Settings_Helper {
16
- /**
17
- * _instance class variable
18
- *
19
- * Class instance
20
- *
21
- * @var null | object
22
- **/
23
- private static $_instance = NULL;
24
-
25
- /**
26
- * get_instance function
27
- *
28
- * Return singleton instance
29
- *
30
- * @return object
31
- **/
32
- static function get_instance() {
33
- if( self::$_instance === NULL ) {
34
- self::$_instance = new self();
35
- }
36
-
37
- return self::$_instance;
38
- }
39
-
40
- /**
41
- * Constructor
42
- *
43
- * Default constructor
44
- **/
45
- private function __construct() { }
46
-
47
- /**
48
- * wp_pages_dropdown function
49
- *
50
- * Display drop-down list selector of pages, including an "Auto-Create New Page"
51
- * option which causes the plugin to generate a new page on user's behalf.
52
- *
53
- * @param string $field_name
54
- * @param int $selected_page_id
55
- * @param string $auto_page
56
- * @param bool $include_disabled
57
- *
58
- * @return string
59
- **/
60
- function wp_pages_dropdown( $field_name, $selected_page_id = 0, $auto_page = '', $include_disabled = false ) {
61
- global $wpdb;
62
- ob_start();
63
- $query = "SELECT
64
- *
65
- FROM
66
- {$wpdb->posts}
67
- WHERE
68
- post_status = %s
69
- AND
70
- post_type = %s";
71
-
72
- $query = $wpdb->prepare( $query, 'publish', 'page' );
73
- $results = $wpdb->get_results( $query );
74
- $pages = array();
75
- if( $results ) {
76
- $pages = $results;
77
- }
78
- $selected_title = '';
79
- ?>
80
- <select class="inputwidth" name="<?php echo $field_name; ?>"
81
- id="<?php echo $field_name; ?>"
82
- class="wafp-dropdown wafp-pages-dropdown">
83
- <?php if( ! empty( $auto_page ) ) { ?>
84
- <option value="__auto_page:<?php echo $auto_page; ?>">
85
- <?php _e( '- Auto-Create New Page -', AI1EC_PLUGIN_NAME ); ?>
86
- </option>
87
- <?php }
88
- foreach( $pages as $page ) {
89
- if( $selected_page_id == $page->ID ) {
90
- $selected = ' selected="selected"';
91
- $selected_title = $page->post_title;
92
- } else {
93
- $selected = '';
94
- }
95
- ?>
96
- <option value="<?php echo $page->ID ?>" <?php echo $selected; ?>>
97
- <?php echo $page->post_title ?>
98
- </option>
99
- <?php } ?>
100
- </select>
101
- <?php
102
- if( is_numeric( $selected_page_id ) && $selected_page_id > 0 ) {
103
- $permalink = get_permalink( $selected_page_id );
104
- ?>
105
- <div><a href="<?php echo $permalink ?>" target="_blank">
106
- <?php printf( __( 'View "%s" »', AI1EC_PLUGIN_NAME ), $selected_title ) ?>
107
- </a></div>
108
- <?php
109
- }
110
- return ob_get_clean();
111
- }
112
-
113
- /**
114
- * get_week_dropdown function
115
- *
116
- * Creates the dropdown element for selecting start of the week
117
- *
118
- * @param int $week_start_day Selected start day
119
- *
120
- * @return String dropdown element
121
- **/
122
- function get_week_dropdown( $week_start_day ) {
123
- global $wp_locale;
124
- ob_start();
125
- ?>
126
- <select class="inputwidth" name="week_start_day" id="week_start_day">
127
- <?php
128
- for( $day_index = 0; $day_index <= 6; $day_index++ ) :
129
- $selected = ( $week_start_day == $day_index ) ? 'selected="selected"' : '';
130
- echo "\n\t<option value='" . esc_attr($day_index) . "' $selected>" . $wp_locale->get_weekday($day_index) . '</option>';
131
- endfor;
132
- ?>
133
- </select>
134
- <?php
135
- return ob_get_clean();
136
- }
137
-
138
- /**
139
- * get_view_dropdown function
140
- *
141
- * @return void
142
- **/
143
- function get_view_dropdown( $view = null ) {
144
- ob_start();
145
- ?>
146
- <select name="default_calendar_view">
147
- <option value="oneday" <?php echo $view == 'oneday' ? 'selected' : '' ?>>
148
- <?php _e( 'Day', AI1EC_PLUGIN_NAME ) ?>
149
- </option>
150
- <option value="month" <?php echo $view == 'month' ? 'selected' : '' ?>>
151
- <?php _e( 'Month', AI1EC_PLUGIN_NAME ) ?>
152
- </option>
153
- <option value="week" <?php echo $view == 'week' ? 'selected' : '' ?>>
154
- <?php _e( 'Week', AI1EC_PLUGIN_NAME ) ?>
155
- </option>
156
- <option value="agenda" <?php echo $view == 'agenda' ? 'selected' : '' ?>>
157
- <?php _e( 'Agenda', AI1EC_PLUGIN_NAME ) ?>
158
- </option>
159
- </select>
160
- <?php
161
- return ob_get_clean();
162
- }
163
-
164
- /**
165
- * get_timezone_dropdown function
166
- *
167
- *
168
- *
169
- * @return void
170
- **/
171
- function get_timezone_dropdown( $timezone = null ) {
172
- $timezone_identifiers = DateTimeZone::listIdentifiers();
173
- ob_start();
174
- ?>
175
- <select id="timezone" name="timezone">
176
- <?php foreach( $timezone_identifiers as $value ) : ?>
177
- <?php if( preg_match( '/^(Africa|America|Antartica|Arctic|Asia|Atlantic|Australia|Europe|Indian|Pacific)\//', $value ) ) : ?>
178
- <?php $ex = explode( "/", $value ); //obtain continent,city ?>
179
- <?php if( isset( $continent ) && $continent != $ex[0] ) : ?>
180
- <?php if( ! empty( $continent ) ) : ?>
181
- </optgroup>
182
- <?php endif ?>
183
- <optgroup label="<?php echo $ex[0] ?>">
184
- <?php endif ?>
185
-
186
- <?php $city = isset( $ex[2] ) ? $ex[2] : $ex[1]; $continent = $ex[0]; ?>
187
- <option value="<?php echo $value ?>" <?php echo $value == $timezone ? 'selected' : '' ?>><?php echo $city ?></option>
188
- <?php endif ?>
189
- <?php endforeach ?>
190
- </optgroup>
191
- </select>
192
- <?php
193
- return ob_get_clean();
194
- }
195
-
196
- /**
197
- * get_date_format_dropdown function
198
- *
199
- * @return string
200
- **/
201
- function get_date_format_dropdown( $view = null ) {
202
- ob_start();
203
- ?>
204
- <select name="input_date_format">
205
- <option value="def" <?php echo $view == 'def' ? 'selected' : '' ?>>
206
- <?php _e( 'Default (d/m/y)', AI1EC_PLUGIN_NAME ) ?>
207
- </option>
208
- <option value="us" <?php echo $view == 'us' ? 'selected' : '' ?>>
209
- <?php _e( 'US (m/d/y)', AI1EC_PLUGIN_NAME ) ?>
210
- </option>
211
- <option value="iso" <?php echo $view == 'iso' ? 'selected' : '' ?>>
212
- <?php _e( 'ISO 8601 (y-m-d)', AI1EC_PLUGIN_NAME ) ?>
213
- </option>
214
- <option value="dot" <?php echo $view == 'dot' ? 'selected' : '' ?>>
215
- <?php _e( 'Dotted (m.d.y)', AI1EC_PLUGIN_NAME ) ?>
216
- </option>
217
-
218
- </select>
219
- <?php
220
- return ob_get_clean();
221
- }
222
-
223
- /**
224
- * get_cron_freq_dropdown function
225
- *
226
- * @return void
227
- **/
228
- function get_cron_freq_dropdown( $cron_freq = null ) {
229
- ob_start();
230
- ?>
231
- <select name="cron_freq">
232
- <option value="hourly" <?php echo $cron_freq == 'hourly' ? 'selected' : ''; ?>>
233
- <?php _e( 'Hourly', AI1EC_PLUGIN_NAME ) ?>
234
- </option>
235
- <option value="twicedaily" <?php echo $cron_freq == 'twicedaily' ? 'selected' : '' ?>>
236
- <?php _e( 'Twice Daily', AI1EC_PLUGIN_NAME ) ?>
237
- </option>
238
- <option value="daily" <?php echo $cron_freq == 'daily' ? 'selected' : '' ?>>
239
- <?php _e( 'Daily', AI1EC_PLUGIN_NAME ) ?>
240
- </option>
241
- </select>
242
- <?php
243
- return ob_get_clean();
244
- }
245
-
246
- /**
247
- * get_feed_rows function
248
- *
249
- * Creates feed rows to display on settings page
250
- *
251
- * @return String feed rows
252
- **/
253
- function get_feed_rows() {
254
- global $wpdb,
255
- $ai1ec_view_helper;
256
-
257
- // Select all added feeds
258
- $table_name = $wpdb->prefix . 'ai1ec_event_feeds';
259
- $sql = "SELECT * FROM {$table_name}";
260
- $rows = $wpdb->get_results( $sql );
261
-
262
- ob_start();
263
- foreach( $rows as $row ) :
264
- $feed_category = get_term( $row->feed_category, 'events_categories' );
265
- $table_name = $wpdb->prefix . 'ai1ec_events';
266
- $sql = "SELECT COUNT(*) FROM {$table_name} WHERE ical_feed_url = '%s'";
267
- $events = $wpdb->get_var( $wpdb->prepare( $sql, $row->feed_url ) );
268
- $args = array(
269
- 'feed_url' => $row->feed_url,
270
- 'event_category' => $feed_category->name,
271
- 'tags' => stripslashes( $row->feed_tags ),
272
- 'feed_id' => $row->feed_id,
273
- 'events' => $events
274
- );
275
- $ai1ec_view_helper->display_admin( 'feed_row.php', $args );
276
- endforeach;
277
-
278
- return ob_get_clean();
279
- }
280
-
281
- /**
282
- * get_event_categories_select function
283
- *
284
- * Creates the dropdown element for selecting feed category
285
- *
286
- * @param int|null $selected The selected category or null
287
- *
288
- * @return String dropdown element
289
- **/
290
- function get_event_categories_select( $selected = null) {
291
- ob_start();
292
- ?>
293
- <select name="ai1ec_feed_category" id="ai1ec_feed_category">
294
- <?php
295
- foreach( get_terms( 'events_categories', array( 'hide_empty' => false ) ) as $term ) :
296
- ?>
297
- <option value="<?php echo $term->term_id; ?>" <?php echo ( $selected === $term->term_id ) ? 'selected' : '' ?>>
298
- <?php echo $term->name; ?>
299
- </option>
300
- <?php
301
- endforeach;
302
- ?>
303
- </select>
304
- <?php
305
- return ob_get_clean();
306
- }
307
-
308
- /**
309
- * Displays the General Settings meta box.
310
- *
311
- * @return void
312
- */
313
- function general_settings_meta_box( $object, $box ) {
314
- global $ai1ec_view_helper,
315
- $ai1ec_settings;
316
-
317
- $calendar_page = $this->wp_pages_dropdown(
318
- 'calendar_page_id',
319
- $ai1ec_settings->calendar_page_id,
320
- __( 'Calendar', AI1EC_PLUGIN_NAME )
321
- );
322
- $week_start_day = $this->get_week_dropdown( get_option( 'start_of_week' ) );
323
- $agenda_events_per_page = $ai1ec_settings->agenda_events_per_page;
324
- $include_events_in_rss =
325
- '<input type="checkbox" name="include_events_in_rss"
326
- id="include_events_in_rss" value="1"'
327
- . ( $ai1ec_settings->include_events_in_rss ? ' checked="checked"' : '' )
328
- . '/>';
329
- $exclude_from_search = $ai1ec_settings->exclude_from_search ? 'checked=checked' : '';
330
- $show_publish_button = $ai1ec_settings->show_publish_button ? 'checked=checked' : '';
331
- $hide_maps_until_clicked = $ai1ec_settings->hide_maps_until_clicked ? 'checked=checked' : '';
332
- $agenda_events_expanded = $ai1ec_settings->agenda_events_expanded ? 'checked=checked' : '';
333
- $turn_off_subscription_buttons = $ai1ec_settings->turn_off_subscription_buttons ? 'checked=checked' : '';
334
- $show_create_event_button = $ai1ec_settings->show_create_event_button ? 'checked=checked' : '';
335
- $inject_categories = $ai1ec_settings->inject_categories ? 'checked=checked' : '';
336
- $geo_region_biasing = $ai1ec_settings->geo_region_biasing ? 'checked=checked' : '';
337
- $input_date_format = $this->get_date_format_dropdown( $ai1ec_settings->input_date_format );
338
- $input_24h_time = $ai1ec_settings->input_24h_time ? 'checked=checked' : '';
339
- $default_calendar_view = $this->get_view_dropdown( $ai1ec_settings->default_calendar_view );
340
- $timezone_control = $this->get_timezone_dropdown( $ai1ec_settings->timezone );
341
- $allow_statistics = $ai1ec_settings->allow_statistics ? 'checked=checked' : '';
342
- $disable_autocompletion = $ai1ec_settings->disable_autocompletion ? 'checked=checked' : '';
343
- $show_location_in_title = $ai1ec_settings->show_location_in_title ? 'checked=checked' : '';
344
- $show_year_in_agenda_dates = $ai1ec_settings->show_year_in_agenda_dates ? 'checked=checked' : '';
345
- $show_timezone = $ai1ec_settings->is_timezone_open_for_change();
346
-
347
- $args = array(
348
- 'calendar_page' => $calendar_page,
349
- 'default_calendar_view' => $default_calendar_view,
350
- 'week_start_day' => $week_start_day,
351
- 'agenda_events_per_page' => $agenda_events_per_page,
352
- 'exclude_from_search' => $exclude_from_search,
353
- 'show_publish_button' => $show_publish_button,
354
- 'hide_maps_until_clicked' => $hide_maps_until_clicked,
355
- 'agenda_events_expanded' => $agenda_events_expanded,
356
- 'turn_off_subscription_buttons' => $turn_off_subscription_buttons,
357
- 'show_create_event_button' => $show_create_event_button,
358
- 'inject_categories' => $inject_categories,
359
- 'input_date_format' => $input_date_format,
360
- 'input_24h_time' => $input_24h_time,
361
- 'show_timezone' => $show_timezone,
362
- 'timezone_control' => $timezone_control,
363
- 'geo_region_biasing' => $geo_region_biasing,
364
- 'allow_statistics' => $allow_statistics,
365
- 'disable_autocompletion' => $disable_autocompletion,
366
- 'show_location_in_title' => $show_location_in_title,
367
- 'show_year_in_agenda_dates' => $show_year_in_agenda_dates,
368
- );
369
- $ai1ec_view_helper->display_admin( 'box_general_settings.php', $args );
370
- }
371
-
372
- /**
373
- * Displays the Advanced Settings meta box.
374
- *
375
- * @return void
376
- */
377
- function advanced_settings_meta_box( $object, $box ) {
378
- global $ai1ec_view_helper,
379
- $ai1ec_settings;
380
-
381
- $args = array(
382
- 'calendar_css_selector' => $ai1ec_settings->calendar_css_selector,
383
- );
384
- $ai1ec_view_helper->display_admin( 'box_advanced_settings.php', $args );
385
- }
386
-
387
- /**
388
- * Renders the contents of the Calendar Feeds meta box.
389
- *
390
- * @return void
391
- */
392
- function feeds_meta_box( $object, $box )
393
- {
394
- global $ai1ec_view_helper,
395
- $ai1ec_settings_helper,
396
- $ai1ec_settings;
397
-
398
- $args = array(
399
- 'cron_freq' => $ai1ec_settings_helper->get_cron_freq_dropdown( $ai1ec_settings->cron_freq ),
400
- 'event_categories' => $ai1ec_settings_helper->get_event_categories_select(),
401
- 'feed_rows' => $ai1ec_settings_helper->get_feed_rows()
402
- );
403
- $ai1ec_view_helper->display_admin( 'box_feeds.php', $args );
404
- }
405
-
406
- /**
407
- * Renders the contents of the Support meta box.
408
- *
409
- * @return void
410
- */
411
- function support_meta_box( $object, $box ) {
412
- global $ai1ec_view_helper;
413
- include_once( ABSPATH . WPINC . '/feed.php' );
414
- // Initialize new feed
415
- $newsItems = array();
416
- $feed = fetch_feed( AI1EC_RSS_FEED );
417
- $newsItems = is_wp_error( $feed ) ? array() : $feed->get_items( 0, 5 );
418
- $ai1ec_view_helper->display_admin( 'box_support.php', array( 'news' => $newsItems ) );
419
- }
420
-
421
- /**
422
- * This is called when the settings page is loaded, so that any additional
423
- * custom meta boxes can be added by other plugins, themes, etc.
424
- *
425
- * @return void
426
- */
427
- function add_settings_meta_boxes(){
428
- global $ai1ec_settings;
429
- do_action( 'add_meta_boxes', $ai1ec_settings->settings_page );
430
- }
431
-
432
- /**
433
- * This is called when the feeds page is loaded, so that any additional
434
- * custom meta boxes can be added by other plugins, themes, etc.
435
- *
436
- * @return void
437
- */
438
- function add_feeds_meta_boxes(){
439
- global $ai1ec_settings;
440
- do_action( 'add_meta_boxes', $ai1ec_settings->feeds_page );
441
- }
442
- }
443
- // END class
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/helper/class-ai1ec-view-helper.php DELETED
@@ -1,635 +0,0 @@
1
- <?php
2
- //
3
- // class-ai1ec-view-helper.php
4
- // all-in-one-event-calendar
5
- //
6
- // Created by The Seed Studio on 2011-07-13.
7
- //
8
-
9
- /**
10
- * Ai1ec_View_Helper class
11
- *
12
- * @package Helpers
13
- * @author time.ly
14
- **/
15
- class Ai1ec_View_Helper {
16
- /**
17
- * _instance class variable
18
- *
19
- * Class instance
20
- *
21
- * @var null | object
22
- **/
23
- private static $_instance = NULL;
24
-
25
- /**
26
- * Constructor
27
- *
28
- * Default constructor
29
- **/
30
- private function __construct() { }
31
-
32
- /**
33
- * get_instance function
34
- *
35
- * Return singleton instance
36
- *
37
- * @return object
38
- **/
39
- static function get_instance() {
40
- if( self::$_instance === NULL ) {
41
- self::$_instance = new self();
42
- }
43
-
44
- return self::$_instance;
45
- }
46
-
47
- /**
48
- * Enqueue a script from the admin resources directory (app/view/admin/js).
49
- *
50
- * @param string $name Unique identifer for the script
51
- * @param string $file Filename of the script
52
- * @param array $deps Dependencies of the script
53
- * @param bool $in_footer Whether to add the script to the footer of the page
54
- *
55
- * @return void
56
- */
57
- function admin_enqueue_script( $name, $file, $deps = array(), $in_footer = FALSE ) {
58
- if( ! $file || empty( $file ) ) {
59
- throw new Ai1ec_File_Not_Provided( "You need to specify a script file." );
60
- }
61
-
62
- $_file = AI1EC_ADMIN_THEME_JS_PATH . '/' . $file;
63
-
64
- if( ! file_exists( $_file ) ) {
65
- throw new Ai1ec_File_Not_Found( "The specified file " . $_file . " doesn't exist." );
66
- } else {
67
- $file = AI1EC_ADMIN_THEME_JS_URL . '/' . $file;
68
- wp_enqueue_script( $name, $file, $deps, AI1EC_VERSION, $in_footer );
69
- }
70
- }
71
-
72
- /**
73
- * Enqueue a script from the theme resources directory.
74
- *
75
- * @param string $name Unique identifer for the script
76
- * @param string $file Filename of the script
77
- * @param array $deps Dependencies of the script
78
- * @param bool $in_footer Whether to add the script to the footer of the page
79
- *
80
- * @return void
81
- */
82
- function theme_enqueue_script( $name, $file, $deps = array(), $in_footer = FALSE ) {
83
- global $ai1ec_themes_controller;
84
-
85
- if( ! $file || empty( $file ) ) {
86
- throw new Ai1ec_File_Not_Provided( "You need to specify a script file." );
87
- }
88
-
89
- // template path
90
- $active_template_path = $ai1ec_themes_controller->active_template_path();
91
- // template url
92
- $active_template_url = $ai1ec_themes_controller->active_template_url();
93
-
94
- // look for the file in the active theme
95
- $themes_root = array(
96
- (object) array(
97
- 'path' => $active_template_path . '/' . AI1EC_JS_FOLDER,
98
- 'url' => $active_template_url . '/' . AI1EC_JS_FOLDER
99
- ),
100
- (object) array(
101
- 'path' => AI1EC_DEFAULT_THEME_PATH . '/' . AI1EC_JS_FOLDER,
102
- 'url' => AI1EC_DEFAULT_THEME_URL . '/' . AI1EC_JS_FOLDER
103
- ),
104
- (object) array(
105
- 'path' => AI1EC_LOCAL_JS_THEME_PATH,
106
- 'url' => AI1EC_LOCAL_JS_URL
107
- ),
108
- );
109
-
110
-
111
- $file_found = false;
112
-
113
- // look for the file in each theme
114
- foreach( $themes_root as $theme_root ) {
115
- // $_file is a local var to hold the value of
116
- // the file we are looking for
117
- $_file = $theme_root->path . '/' . $file;
118
-
119
- if( file_exists( $_file ) ) {
120
- // file is found
121
- $file_found = true;
122
- // assign the found file
123
- $file = $theme_root->url . '/' . $file;
124
- // exit the loop;
125
- break;
126
- }
127
- }
128
-
129
- if( $file_found === false ) {
130
- throw new Ai1ec_File_Not_Found( "The specified file '" . $file . "' doesn't exist." );
131
- }
132
- else {
133
- // Append core themes version to version string to make sure recently
134
- // updated files are used.
135
- wp_enqueue_script(
136
- $name,
137
- $file,
138
- $deps,
139
- AI1EC_VERSION . '-' . get_option( 'ai1ec_themes_version', 1 ),
140
- $in_footer
141
- );
142
- }
143
- }
144
-
145
- /**
146
- * admin_enqueue_style function
147
- *
148
- * @return void
149
- **/
150
- function admin_enqueue_style( $name, $file, $deps = array() ) {
151
- if( ! $file || empty( $file ) ) {
152
- throw new Ai1ec_File_Not_Provided( "You need to specify a style file." );
153
- }
154
-
155
- $_file = AI1EC_ADMIN_THEME_CSS_PATH . '/' . $file;
156
-
157
- if( ! file_exists( $_file ) ) {
158
- throw new Ai1ec_File_Not_Found( "The specified file " . $file . " doesn't exist." );
159
- } else {
160
- $file = AI1EC_ADMIN_THEME_CSS_URL . '/' . $file;
161
- wp_enqueue_style( $name, $file, $deps, AI1EC_VERSION );
162
- }
163
- }
164
-
165
- /**
166
- * theme_enqueue_style function
167
- *
168
- * @return void
169
- **/
170
- function theme_enqueue_style( $name, $file, $deps = array() ) {
171
- global $ai1ec_themes_controller;
172
-
173
- if( ! $file || empty( $file ) ) {
174
- throw new Ai1ec_File_Not_Provided( "You need to specify a style file." );
175
- }
176
-
177
- // template path
178
- $active_template_path = $ai1ec_themes_controller->active_template_path();
179
- // template url
180
- $active_template_url = $ai1ec_themes_controller->active_template_url();
181
-
182
- // look for the file in the active theme
183
- $themes_root = array(
184
- (object) array(
185
- 'path' => $active_template_path . '/' . AI1EC_CSS_FOLDER,
186
- 'url' => $active_template_url . '/' . AI1EC_CSS_FOLDER
187
- ),
188
- (object) array(
189
- 'path' => $active_template_path,
190
- 'url' => $active_template_url
191
- ),
192
- (object) array(
193
- 'path' => AI1EC_DEFAULT_THEME_PATH . '/' . AI1EC_CSS_FOLDER,
194
- 'url' => AI1EC_DEFAULT_THEME_URL . '/' . AI1EC_CSS_FOLDER
195
- ),
196
- (object) array(
197
- 'path' => AI1EC_DEFAULT_THEME_PATH,
198
- 'url' => AI1EC_DEFAULT_THEME_URL
199
- ),
200
- (object) array(
201
- 'path' => AI1EC_LOCAL_CSS_THEME_PATH,
202
- 'url' => AI1EC_LOCAL_CSS_URL
203
- ),
204
- );
205
-
206
- $file_found = false;
207
-
208
- // look for the file in each theme
209
- foreach( $themes_root as $theme_root ) {
210
- // $_file is a local var to hold the value of
211
- // the file we are looking for
212
- $_file = $theme_root->path . '/' . $file;
213
- if( file_exists( $_file ) ) {
214
- // file is found
215
- $file_found = true;
216
- // assign the found file
217
- $file = $theme_root->url . '/' . $file;
218
- // exit the loop;
219
- break;
220
- }
221
- }
222
-
223
- if( $file_found === false ) {
224
- throw new Ai1ec_File_Not_Found( "The specified file '" . $file . "' doesn't exist." );
225
- }
226
- else {
227
- // Append core themes version to version string to make sure recently
228
- // updated files are used.
229
- wp_enqueue_style(
230
- $name,
231
- $file,
232
- $deps,
233
- AI1EC_VERSION . '-' . get_option( 'ai1ec_themes_version', 1 )
234
- );
235
- }
236
- }
237
-
238
- /**
239
- * display_admin function
240
- *
241
- * Display the view specified by file $file and passed arguments $args.
242
- *
243
- * @param string $file
244
- * @param array $args
245
- *
246
- * @return void
247
- **/
248
- function display_admin( $file = false, $args = array() ) {
249
- if( ! $file || empty( $file ) ) {
250
- throw new Ai1ec_File_Not_Provided( "You need to specify a view file." );
251
- }
252
-
253
- $file = AI1EC_ADMIN_THEME_PATH . '/' . $file;
254
-
255
- if( ! file_exists( $file ) ) {
256
- throw new Ai1ec_File_Not_Found( "The specified view file doesn't exist." );
257
- } else {
258
- extract( $args );
259
- require( $file );
260
- }
261
- }
262
-
263
- /**
264
- * display_theme function
265
- *
266
- * Display the view specified by file $file and passed arguments $args.
267
- *
268
- * @param string $file
269
- * @param array $args
270
- *
271
- * @return void
272
- **/
273
- function display_theme( $file = false, $args = array() ) {
274
- global $ai1ec_themes_controller;
275
-
276
- if( ! $file || empty( $file ) ) {
277
- throw new Ai1ec_File_Not_Provided( "You need to specify a view file." );
278
- }
279
-
280
- // look for the file in the selected theme
281
- $themes_root = array(
282
- $ai1ec_themes_controller->active_template_path(),
283
- AI1EC_DEFAULT_THEME_PATH,
284
- AI1EC_LOCAL_VIEW_THEME_PATH
285
- );
286
-
287
- // remove duplicates
288
- $themes_root = array_unique( $themes_root );
289
-
290
- $file_found = false;
291
-
292
- // look for the file in each theme
293
- foreach( $themes_root as $theme_root ) {
294
- // $_file is a local var to hold the value of
295
- // the file we are looking for
296
- $_file = $theme_root . '/' . $file;
297
- if( file_exists( $_file ) ) {
298
- // file is found
299
- $file_found = true;
300
- // assign the found file
301
- $file = $_file;
302
- // exit the loop;
303
- break;
304
- }
305
- }
306
-
307
- if( $file_found === false ) {
308
- throw new Ai1ec_File_Not_Found( "The specified view file '" . $file . "' doesn't exist." );
309
- } else {
310
- extract( $args );
311
- require( $file );
312
- }
313
- }
314
-
315
- /**
316
- * display_admin_css function
317
- *
318
- * Renders the given stylesheet inline. If stylesheet has already been
319
- * displayed once before with the same set of $args, does not display
320
- * it again.
321
- *
322
- * @param string $file
323
- * @param array $args
324
- *
325
- * @return void
326
- **/
327
- function display_admin_css( $file = false, $args = array() ) {
328
- static $displayed = array();
329
-
330
- if( ! $file || empty( $file ) ) {
331
- throw new Ai1ec_File_Not_Provided( 'You need to specify a css file.' );
332
- }
333
-
334
- $file = AI1EC_ADMIN_THEME_CSS_PATH . '/' . $file;
335
-
336
- if( isset( $displayed[$file] ) && $displayed[$file] === $args ) // Skip if already displayed
337
- return;
338
-
339
- if( ! file_exists( $file ) ) {
340
- throw new Ai1ec_File_Not_Found( "The specified css file doesn't exist." );
341
- } else {
342
- $displayed[$file] = $args; // Flag that we've displayed this file with these args
343
-
344
- extract( $args );
345
- echo '<style type="text/css">';
346
- require( $file );
347
- echo '</style>';
348
- }
349
- }
350
-
351
- /**
352
- * display_theme_css function
353
- *
354
- * Renders the given stylesheet inline. If stylesheet has already been
355
- * displayed once before with the same set of $args, does not display
356
- * it again.
357
- *
358
- * @param string $file
359
- * @param array $args
360
- *
361
- * @return void
362
- **/
363
- function display_theme_css( $file = false, $args = array() ) {
364
- global $ai1ec_themes_controller;
365
- static $displayed = array();
366
-
367
- if( ! $file || empty( $file ) ) {
368
- throw new Ai1ec_File_Not_Provided( 'You need to specify a CSS file.' );
369
- }
370
-
371
- // look for the file in the selected theme
372
- $themes_root = array(
373
- $ai1ec_themes_controller->active_template_path() . '/' . AI1EC_THEME_CSS_FOLDER,
374
- AI1EC_DEFAULT_THEME_PATH . '/' . AI1EC_THEME_CSS_FOLDER
375
- );
376
-
377
- // remove duplicates
378
- $themes_root = array_unique( $themes_root );
379
-
380
- $file_found = false;
381
-
382
- // look for the file in each theme
383
- foreach( $themes_root as $theme_root ) {
384
- // $_file is a local var to hold the value of
385
- // the file we are looking for
386
- $_file = $theme_root . '/' . $file;
387
- if( file_exists( $_file ) ) {
388
- // file is found
389
- $file_found = true;
390
- // assign the found file
391
- $file = $_file;
392
- // exit the loop;
393
- break;
394
- }
395
- }
396
-
397
- if( isset( $displayed[$file] ) && $displayed[$file] === $args ) // Skip if already displayed
398
- return;
399
-
400
- if( ! file_exists( $file ) ) {
401
- throw new Ai1ec_File_Not_Found( "The specified CSS file doesn't exist." );
402
- } else {
403
- $displayed[$file] = $args; // Flag that we've displayed this file with these args
404
-
405
- extract( $args );
406
- echo '<style type="text/css">';
407
- require( $file );
408
- echo '</style>';
409
- }
410
- }
411
-
412
- /**
413
- * display_admin_js function
414
- *
415
- * Renders the given script inline. If script has already been displayed
416
- * once before with the same set of $args, does not display it again.
417
- *
418
- * @param string $file
419
- * @param array $args
420
- *
421
- * @return void
422
- **/
423
- function display_admin_js( $file = false, $args = array() ) {
424
- static $displayed = array();
425
-
426
- if( ! $file || empty( $file ) ) {
427
- throw new Ai1ec_File_Not_Provided( "You need to specify a js file." );
428
- }
429
-
430
- $file = AI1EC_ADMIN_THEME_JS_PATH . '/' . $file;
431
-
432
- if( $displayed[$file] === $args) // Skip if already displayed
433
- return;
434
-
435
- if( ! file_exists( $file ) ) {
436
- throw new Ai1ec_File_Not_Found( "The specified js file doesn't exist." );
437
- } else {
438
- $displayed[$file] = $args; // Flag that we've displayed this file with these args
439
-
440
- extract( $args );
441
- echo '<script type="text/javascript" charset="utf-8">';
442
- echo '/* <![CDATA[ */';
443
- require( $file );
444
- echo '/* ]]> */';
445
- echo '</script>';
446
- }
447
- }
448
- /**
449
- * display_theme_js function
450
- *
451
- * Renders the given script inline. If script has already been displayed
452
- * once before with the same set of $args, does not display it again.
453
- *
454
- * @param string $file
455
- * @param array $args
456
- *
457
- * @return void
458
- **/
459
- function display_theme_js( $file = false, $args = array() ) {
460
- global $ai1ec_themes_controller;
461
- static $displayed = array();
462
-
463
- if( ! $file || empty( $file ) ) {
464
- throw new Ai1ec_File_Not_Provided( "You need to specify a JS file." );
465
- }
466
-
467
- // look for the file in the selected theme
468
- $themes_root = array(
469
- $ai1ec_themes_controller->active_template_path() . '/' . AI1EC_THEME_JS_FOLDER,
470
- AI1EC_DEFAULT_THEME_PATH . '/' . AI1EC_THEME_JS_FOLDER
471
- );
472
-
473
- // remove duplicates
474
- $themes_root = array_unique( $themes_root );
475
-
476
- $file_found = false;
477
-
478
- // look for the file in each theme
479
- foreach( $themes_root as $theme_root ) {
480
- // $_file is a local var to hold the value of
481
- // the file we are looking for
482
- $_file = $theme_root . '/' . $file;
483
- if( file_exists( $_file ) ) {
484
- // file is found
485
- $file_found = true;
486
- // assign the found file
487
- $file = $_file;
488
- // exit the loop;
489
- break;
490
- }
491
- }
492
-
493
- if( $displayed[$file] === $args) // Skip if already displayed
494
- return;
495
-
496
- if( ! file_exists( $file ) ) {
497
- throw new Ai1ec_File_Not_Found( "The specified JS file doesn't exist." );
498
- } else {
499
- $displayed[$file] = $args; // Flag that we've displayed this file with these args
500
-
501
- extract( $args );
502
- echo '<script type="text/javascript" charset="utf-8">';
503
- echo '/* <![CDATA[ */';
504
- require( $file );
505
- echo '/* ]]> */';
506
- echo '</script>';
507
- }
508
- }
509
-
510
- /**
511
- * get_admin_view function
512
- *
513
- * Return the output of a view as a string rather than output to response.
514
- *
515
- * @param string $file
516
- * @param array $args
517
- *
518
- * @return void
519
- **/
520
- function get_admin_view( $file = false, $args = array() ) {
521
- ob_start();
522
- $this->display_admin( $file, $args );
523
- return ob_get_clean();
524
- }
525
-
526
- /**
527
- * get_theme_view function
528
- *
529
- * Return the output of a view in the theme as a string rather than output to response.
530
- *
531
- * @param string $file
532
- * @param array $args
533
- *
534
- * @return void
535
- **/
536
- function get_theme_view( $file = false, $args = array() ) {
537
- ob_start();
538
- $this->display_theme( $file, $args );
539
- return ob_get_clean();
540
- }
541
-
542
- /**
543
- * get_admin_img_url function
544
- *
545
- * @return string
546
- **/
547
- public function get_admin_img_url( $file ) {
548
- if( ! $file || empty( $file ) ) {
549
- throw new Ai1ec_File_Not_Provided( "You need to specify an image file." );
550
- }
551
-
552
- $_file = AI1EC_ADMIN_THEME_IMG_PATH . '/' . $file;
553
-
554
- if( ! file_exists( $_file ) ) {
555
- throw new Ai1ec_File_Not_Found( "The specified file " . $_file . " doesn't exist." );
556
- } else {
557
- $file = AI1EC_ADMIN_THEME_IMG_URL . '/' . $file;
558
- return $file;
559
- }
560
- }
561
-
562
- /**
563
- * get_theme_img_url function
564
- *
565
- * @return string
566
- **/
567
- public function get_theme_img_url( $file ) {
568
- global $ai1ec_themes_controller;
569
-
570
- if( ! $file || empty( $file ) ) {
571
- throw new Ai1ec_File_Not_Provided( "You need to specify a style file." );
572
- }
573
-
574
- // template path
575
- $active_template_path = $ai1ec_themes_controller->active_template_path();
576
- // template url
577
- $active_template_url = $ai1ec_themes_controller->active_template_url();
578
-
579
- // look for the file in the active theme
580
- $themes_root = array(
581
- (object) array(
582
- 'path' => $active_template_path . '/' . AI1EC_IMG_FOLDER,
583
- 'url' => $active_template_url . '/' . AI1EC_IMG_FOLDER
584
- ),
585
- (object) array(
586
- 'path' => AI1EC_DEFAULT_THEME_PATH . '/' . AI1EC_IMG_FOLDER,
587
- 'url' => AI1EC_DEFAULT_THEME_URL . '/' . AI1EC_IMG_FOLDER
588
- ),
589
- );
590
-
591
- $file_found = false;
592
-
593
- // look for the file in each theme
594
- foreach( $themes_root as $theme_root ) {
595
- // $_file is a local var to hold the value of
596
- // the file we are looking for
597
- $_file = $theme_root->path . '/' . $file;
598
- if( file_exists( $_file ) ) {
599
- // file is found
600
- $file_found = true;
601
- // assign the found file
602
- $file = $theme_root->url . '/' . $file;
603
- // exit the loop;
604
- break;
605
- }
606
- }
607
-
608
- if( $file_found === false ) {
609
- throw new Ai1ec_File_Not_Found( "The specified file '" . $file . "' doesn't exist." );
610
- } else {
611
- return $file;
612
- }
613
- }
614
-
615
- /**
616
- * json_response function
617
- *
618
- * Utility for properly outputting JSON data as an AJAX response.
619
- *
620
- * @param array $data
621
- *
622
- * @return void
623
- **/
624
- function json_response( $data ) {
625
- header( 'Cache-Control: no-cache, must-revalidate' );
626
- header( 'Pragma: no-cache' );
627
- header( 'Content-type: application/json' );
628
-
629
- // Output JSON-encoded result and quit
630
- echo json_encode( ai1ec_utf8( $data ) );
631
- exit;
632
- }
633
-
634
- }
635
- // END class
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/model/app.php ADDED
@@ -0,0 +1,34 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * Base application model.
5
+ *
6
+ * @author Time.ly Network, Inc.
7
+ * @since 2.0
8
+ * @package Ai1EC
9
+ * @subpackage Ai1EC.Model
10
+ */
11
+ class Ai1ec_App extends Ai1ec_Base {
12
+
13
+ /**
14
+ * Initiate base objects.
15
+ *
16
+ * @param Ai1ec_Registry_Object $registry
17
+ * @internal param \Ai1ec_Registry_Object $system Injectable system object.
18
+ */
19
+ public function __construct( Ai1ec_Registry_Object $registry ) {
20
+ parent::__construct( $registry );
21
+ $this->_initialize();
22
+ }
23
+
24
+ /**
25
+ * Post construction routine.
26
+ *
27
+ * Override this method to perform post-construction tasks.
28
+ *
29
+ * @return void Return from this method is ignored.
30
+ */
31
+ protected function _initialize() {}
32
+
33
+
34
+ }
app/model/class-ai1ec-event.php DELETED
@@ -1,884 +0,0 @@
1
- <?php
2
- //
3
- // class-ai1ec-event.php
4
- // all-in-one-event-calendar
5
- //
6
- // Created by The Seed Studio on 2011-07-13.
7
- //
8
-
9
- /**
10
- * Ai1ec_Event class
11
- *
12
- * @package Models
13
- * @author time.ly
14
- **/
15
- class Ai1ec_Event {
16
- /**
17
- * post class variable
18
- *
19
- * @var object
20
- **/
21
- var $post;
22
-
23
- /**
24
- * post_id class variable
25
- *
26
- * @var int
27
- **/
28
- var $post_id;
29
-
30
- /**
31
- * instance_id class variable
32
- *
33
- * Uniquely identifies the recurrence instance of this event object. This
34
- * may be null.
35
- *
36
- * @var int|null
37
- **/
38
- var $instance_id;
39
-
40
- /**
41
- * start class variable
42
- *
43
- * @var int
44
- **/
45
- var $start;
46
-
47
- /**
48
- * end class variable
49
- *
50
- * @var int
51
- **/
52
- var $end;
53
-
54
- /**
55
- * start_truncated class variable
56
- *
57
- * Whether this copy of the event was broken up for rendering and the start
58
- * time is not its "real" start time.
59
- *
60
- * @var bool
61
- **/
62
- var $start_truncated;
63
-
64
- /**
65
- * end_truncated class variable
66
- *
67
- * Whether this copy of the event was broken up for rendering and the end
68
- * time is not its "real" end time.
69
- *
70
- * @var bool
71
- **/
72
- var $end_truncated;
73
-
74
- /**
75
- * allday class variable
76
- *
77
- * @var int
78
- **/
79
- var $allday;
80
-
81
- /**
82
- * recurrence_rules class variable
83
- *
84
- * @var string
85
- **/
86
- var $recurrence_rules;
87
-
88
- /**
89
- * exception_rules class variable
90
- *
91
- * @var string
92
- **/
93
- var $exception_rules;
94
-
95
- /**
96
- * recurrence_dates class variable
97
- *
98
- * @var string
99
- **/
100
- var $recurrence_dates;
101
-
102
- /**
103
- * exception_dates class variable
104
- *
105
- * @var string
106
- **/
107
- var $exception_dates;
108
-
109
- /**
110
- * venue class variable
111
- *
112
- * @var string
113
- **/
114
- var $venue;
115
-
116
- /**
117
- * country class variable
118
- *
119
- * @var string
120
- **/
121
- var $country;
122
-
123
- /**
124
- * address class variable
125
- *
126
- * @var string
127
- **/
128
- var $address;
129
-
130
- /**
131
- * city class variable
132
- *
133
- * @var string
134
- **/
135
- var $city;
136
-
137
- /**
138
- * province class variable
139
- *
140
- * @var string
141
- **/
142
- var $province;
143
-
144
- /**
145
- * postal_code class variable
146
- *
147
- * @var int
148
- **/
149
- var $postal_code;
150
-
151
- /**
152
- * show_map class variable
153
- *
154
- * @var int
155
- **/
156
- var $show_map;
157
-
158
- /**
159
- * contact_name class variable
160
- *
161
- * @var string
162
- **/
163
- var $contact_name;
164
-
165
- /**
166
- * contact_phone class variable
167
- *
168
- * @var string
169
- **/
170
- var $contact_phone;
171
-
172
- /**
173
- * contact_email class variable
174
- *
175
- * @var string
176
- **/
177
- var $contact_email;
178
-
179
- /**
180
- * cost class variable
181
- *
182
- * @var string
183
- **/
184
- var $cost;
185
-
186
- // ====================================
187
- // = iCalendar feed (.ics) properties =
188
- // ====================================
189
- /**
190
- * ical_feed_url class variable
191
- *
192
- * @var string
193
- **/
194
- var $ical_feed_url;
195
-
196
- /**
197
- * ical_source_url class variable
198
- *
199
- * @var string
200
- **/
201
- var $ical_source_url;
202
-
203
- /**
204
- * ical_organizer class variable
205
- *
206
- * @var string
207
- **/
208
- var $ical_organizer;
209
-
210
- /**
211
- * ical_contact class variable
212
- *
213
- * @var string
214
- **/
215
- var $ical_contact;
216
-
217
- /**
218
- * ical_uid class variable
219
- *
220
- * @var string | int
221
- **/
222
- var $ical_uid;
223
-
224
- // ============
225
- // = Taxonomy =
226
- // ============
227
- /**
228
- * tags class variable
229
- *
230
- * Associated event tag IDs, joined by commas.
231
- *
232
- * @var string
233
- **/
234
- var $tags;
235
-
236
- /**
237
- * categories class variable
238
- *
239
- * Associated event category IDs, joined by commas.
240
- *
241
- * @var string
242
- **/
243
- var $categories;
244
-
245
- /**
246
- * feed class variable
247
- *
248
- * Associated event feed object
249
- *
250
- * @var string
251
- **/
252
- var $feed;
253
-
254
- /**
255
- * category_colors class variable
256
- *
257
- * @var string
258
- **/
259
- private $category_colors;
260
-
261
- /**
262
- * color_style class variable
263
- *
264
- * @var string
265
- **/
266
- private $color_style;
267
-
268
- /**
269
- * faded_color class variable
270
- *
271
- * @var string
272
- **/
273
- private $faded_color;
274
-
275
- /**
276
- * tags_html class variable
277
- *
278
- * A cache variable, used by __get().
279
- *
280
- * @var string
281
- **/
282
- private $tags_html;
283
-
284
- /**
285
- * categories_html class variable
286
- *
287
- * A cache variable, used by __get().
288
- *
289
- * @var string
290
- **/
291
- private $categories_html;
292
-
293
- /**
294
- * __construct function
295
- *
296
- * Create new event object, using provided data for initialization.
297
- *
298
- * @param int|array $data Look up post with id $data, or initialize fields
299
- * with flat associative array $data containing both
300
- * post and event fields returned by join query
301
- *
302
- * @return void
303
- **/
304
- function __construct( $data = null, $instance = false ) {
305
- global $wpdb;
306
-
307
- if( $data == null )
308
- return;
309
-
310
- // ===========
311
- // = Post ID =
312
- // ===========
313
- if( is_numeric( $data ) )
314
- {
315
- // ============================
316
- // = Fetch post from database =
317
- // ============================
318
- $post = get_post( $data );
319
-
320
- if( ! $post || $post->post_status == 'auto-draft' )
321
- throw new Ai1ec_Event_Not_Found( "Post with ID '$data' could not be retrieved from the database." );
322
-
323
- $left_join = "";
324
- $select_sql = "e.post_id, e.recurrence_rules, e.exception_rules, e.allday, " .
325
- "e.recurrence_dates, e.exception_dates, e.venue, e.country, e.address, e.city, e.province, e.postal_code, " .
326
- "e.show_map, e.contact_name, e.contact_phone, e.contact_email, e.cost, e.ical_feed_url, e.ical_source_url, " .
327
- "e.ical_organizer, e.ical_contact, e.ical_uid, " .
328
- "GROUP_CONCAT( ttc.term_id ) AS categories, " .
329
- "GROUP_CONCAT( ttt.term_id ) AS tags ";
330
-
331
- if( $instance != false && is_numeric( $instance ) ) {
332
- $select_sql .= ", IF( aei.start IS NOT NULL, UNIX_TIMESTAMP( aei.start ), UNIX_TIMESTAMP( e.start ) ) as start," .
333
- " IF( aei.start IS NOT NULL, UNIX_TIMESTAMP( aei.end ), UNIX_TIMESTAMP( e.end ) ) as end ";
334
-
335
- $instance = (int) $instance;
336
- $left_join = "LEFT JOIN {$wpdb->prefix}ai1ec_event_instances aei ON aei.id = $instance AND e.post_id = aei.post_id ";
337
- } else {
338
- $select_sql .= ", UNIX_TIMESTAMP( e.start ) as start, UNIX_TIMESTAMP( e.end ) as end, e.allday ";
339
- }
340
- // =============================
341
- // = Fetch event from database =
342
- // =============================
343
- $query = $wpdb->prepare(
344
- "SELECT {$select_sql}" .
345
- "FROM {$wpdb->prefix}ai1ec_events e " .
346
- "LEFT JOIN $wpdb->term_relationships tr ON e.post_id = tr.object_id " .
347
- "LEFT JOIN $wpdb->term_taxonomy ttc ON tr.term_taxonomy_id = ttc.term_taxonomy_id AND ttc.taxonomy = 'events_categories' " .
348
- "LEFT JOIN $wpdb->term_taxonomy ttt ON tr.term_taxonomy_id = ttt.term_taxonomy_id AND ttt.taxonomy = 'events_tags' " .
349
- "{$left_join}" .
350
- "WHERE e.post_id = %d " .
351
- "GROUP BY e.post_id",
352
- $data );
353
- $event = $wpdb->get_row( $query );
354
-
355
- if( $event === null || $event->post_id === null )
356
- throw new Ai1ec_Event_Not_Found( "Event with ID '$data' could not be retrieved from the database." );
357
-
358
- // ===========================
359
- // = Assign post to property =
360
- // ===========================
361
- $this->post = $post;
362
-
363
- // ==========================
364
- // = Assign values to $this =
365
- // ==========================
366
- foreach( $this as $property => $value ) {
367
- if( $property != 'post' ) {
368
- if( isset( $event->{$property} ) )
369
- $this->{$property} = $event->{$property};
370
- }
371
- }
372
- }
373
- // ===================
374
- // = Post/event data =
375
- // ===================
376
- elseif( is_array( $data ) )
377
- {
378
- // =======================================================
379
- // = Assign each event field the value from the database =
380
- // =======================================================
381
- foreach( $this as $property => $value ) {
382
- if( $property != 'post' && array_key_exists( $property, $data ) ) {
383
- $this->{$property} = $data[$property];
384
- unset( $data[$property] );
385
- }
386
- }
387
- if( isset( $data['post'] ) ) {
388
- $this->post = (object) $data['post'];
389
- } else {
390
- // ========================================
391
- // = Remaining fields are the post fields =
392
- // ========================================
393
- $this->post = (object) $data;
394
- }
395
- }
396
- else {
397
- throw new Ai1ec_Invalid_Argument( "Argument to constructor must be integer, array or null, not '$data'." );
398
- }
399
- }
400
-
401
- /**
402
- * __set function
403
- *
404
- * Magic set function
405
- *
406
- * @param string $name Property name
407
- * @param mixed $value Property value
408
- *
409
- * @return void
410
- **/
411
- public function __set( $name, $value ) {
412
- // Not currently used...
413
- switch( $name ) {
414
- default:
415
- $this->{$name} = $value;
416
- break;
417
- }
418
- }
419
-
420
- /**
421
- * __get function
422
- *
423
- * Magic get function
424
- * Shortcuts for common formatted versions of event data.
425
- *
426
- * @param string $name Property name
427
- *
428
- * @return mixed Property value
429
- **/
430
- public function __get( $name ) {
431
- global $post, $more, $ai1ec_events_helper;
432
-
433
- switch( $name ) {
434
-
435
- case 'uid':
436
- return $this->post_id . '@' . bloginfo( 'url' );
437
-
438
- // ==================================
439
- // = Month view multiday properties =
440
- // ==================================
441
- case "multiday":
442
- // Event is multiday if it is longer than 24 hours, and it ends on a
443
- // different day than it starts.
444
- return
445
- $this->end - $this->start >= 24 * 60 * 60
446
- &&
447
- $ai1ec_events_helper->get_long_date( $this->start ) !=
448
- $ai1ec_events_helper->get_long_date( $this->end - 1 );
449
-
450
- case "multiday_end_day":
451
- return $ai1ec_events_helper->get_multiday_end_day( $this->end - 1 );
452
-
453
- // ========================
454
- // = Get short-form dates =
455
- // ========================
456
- case 'short_start_time':
457
- return $ai1ec_events_helper->get_short_time( $this->start );
458
-
459
- case 'short_end_time':
460
- return $ai1ec_events_helper->get_short_time( $this->end );
461
-
462
- case 'short_start_date':
463
- return $ai1ec_events_helper->get_short_date( $this->start );
464
-
465
- case 'short_end_date':
466
- // Subtract 1 second so that all-day events' end date still
467
- // falls within the logical duration of days (since the end date
468
- // is always midnight of the following day)
469
- return $ai1ec_events_helper->get_short_date( $this->end - 1 );
470
-
471
- // =========================
472
- // = Get medium-form dates =
473
- // =========================
474
- case 'start_time':
475
- return $ai1ec_events_helper->get_medium_time( $this->start );
476
-
477
- case 'end_time':
478
- return $ai1ec_events_helper->get_medium_time( $this->end );
479
-
480
- // =======================
481
- // = Get long-form times =
482
- // =======================
483
- case 'long_start_time':
484
- return $ai1ec_events_helper->get_long_time( $this->start );
485
-
486
- case 'long_end_time':
487
- return $ai1ec_events_helper->get_long_time( $this->end );
488
-
489
- // =======================
490
- // = Get long-form dates =
491
- // =======================
492
- case 'long_start_date':
493
- return $ai1ec_events_helper->get_long_date( $this->start );
494
-
495
- case 'long_end_date':
496
- // Subtract 1 second so that all-day events' end date still
497
- // falls within the logical duration of days (since the end date
498
- // is always midnight of the following day)
499
- return $ai1ec_events_helper->get_long_date( $this->end - 1 );
500
-
501
- case 'timespan_html':
502
- $timespan = '';
503
- $long_start_date = str_replace( ' ', '&nbsp;', esc_html( $this->long_start_date ) );
504
- $long_end_date = str_replace( ' ', '&nbsp;', esc_html( $this->long_end_date ) );
505
-
506
- if( $this->allday ) {
507
- $timespan .= $long_start_date;
508
- if( $long_end_date != $long_start_date ) {
509
- $timespan .= " – $long_end_date";
510
- }
511
- $timespan .= '<span class="ai1ec-allday-label">';
512
- $timespan .= __( ' (all-day)', AI1EC_PLUGIN_NAME );
513
- $timespan .= '</span>';
514
- }
515
- else {
516
- $long_start_time = str_replace( ' ', '&nbsp;', esc_html( $this->long_start_time ) );
517
- $long_end_time = str_replace( ' ', '&nbsp;', esc_html( $this->long_end_time ) );
518
- $end_time = str_replace( ' ', '&nbsp;', esc_html( $this->end_time ) );
519
-
520
- if( $long_end_date != $long_start_date ) {
521
- $timespan .= $long_start_time . ' – ' . $long_end_time;
522
- }
523
- elseif( $this->start != $this->end ) {
524
- $timespan .= $long_start_time . ' - ' . $end_time;
525
- }
526
- else {
527
- $timespan .= $long_start_time;
528
- }
529
- }
530
- return $timespan;
531
-
532
- // =====================================================
533
- // = Get the post's excerpt for display in popup view. =
534
- // =====================================================
535
- case 'post_excerpt':
536
- if( ! $this->post->post_excerpt ) {
537
- $content = strip_tags( strip_shortcodes( $this->post->post_content ) );
538
- $content = preg_replace( '/\s+/', ' ', $content );
539
- $words = explode( ' ', $content );
540
- if( count( $words ) > 25 )
541
- $this->post->post_excerpt = implode( ' ', array_slice( $words, 0, 25 ) ) . ' [...]';
542
- else
543
- $this->post->post_excerpt = $content;
544
- }
545
- return $this->post->post_excerpt;
546
-
547
- // ===============================================================
548
- // = Return any available location details separated by newlines =
549
- // ===============================================================
550
- case 'location':
551
- $location = '';
552
- if( $this->venue ) $location .= "$this->venue\n";
553
- if( $this->address ) {
554
- $bits = explode( ',', $this->address );
555
- $bits = array_map( 'trim', $bits );
556
-
557
- // If more than three comma-separated values, treat first value as
558
- // the street address, last value as the country, and everything
559
- // in the middle as the city, state, etc.
560
- if( count( $bits ) >= 3 ) {
561
- // Append the street address
562
- $street_address = array_shift( $bits ) . "\n";
563
- if( $street_address ) $location .= $street_address;
564
- // Save the country for the last line
565
- $country = array_pop( $bits );
566
- // Append the middle bit(s) (filtering out any zero-length strings)
567
- $bits = array_filter( $bits, 'strval' );
568
- if( $bits ) $location .= join( ',', $bits ) . "\n";
569
- if( $country ) $location .= $country . "\n";
570
- } else {
571
- // There are two or less comma-separated values, so just append
572
- // them each on their own line (filtering out any zero-length strings)
573
- $bits = array_filter( $bits, 'strval' );
574
- $location .= join( "\n", $bits );
575
- }
576
- }
577
- return $location;
578
-
579
- // ======================
580
- // = Categories as HTML =
581
- // ======================
582
- case 'categories_html':
583
- if( $this->categories_html === null ) {
584
- $categories = wp_get_post_terms( $this->post_id, 'events_categories' );
585
- foreach( $categories as &$category ) {
586
- $category =
587
- '<a class="ai1ec-category ai1ec-term-id-' . $category->term_id . '" ' .
588
- ( $category->description ? 'title="' . esc_attr( $category->description ) . '" ' : '' ) .
589
- 'href="' . get_term_link( $category ) . '">' .
590
- $ai1ec_events_helper->get_category_color_square( $category->term_id ) . ' ' . esc_html( $category->name ) . '</a>';
591
- }
592
- $this->categories_html = join( ' ', $categories );
593
- }
594
- return $this->categories_html;
595
-
596
- // ================
597
- // = Tags as HTML =
598
- // ================
599
- case 'tags_html':
600
- if( $this->tags_html === null ) {
601
- $tags = wp_get_post_terms( $this->post_id, 'events_tags' );
602
- foreach( $tags as &$tag ) {
603
- $tag =
604
- '<a class="ai1ec-tag ai1ec-term-id-' . $tag->term_id . '" ' .
605
- ( $tag->description ? 'title="' . esc_attr( $tag->description ) . '" ' : '' ) .
606
- 'href="' . get_term_link( $tag ) . '">' .
607
- esc_html( $tag->name ) . '</a>';
608
- }
609
- $this->tags_html = join( ' ', $tags );
610
- }
611
- return $this->tags_html;
612
-
613
- // ======================================
614
- // = Style attribute for event category =
615
- // ======================================
616
- case 'color_style':
617
- if( $this->color_style === null ) {
618
- $categories = wp_get_post_terms( $this->post_id, 'events_categories' );
619
- if( $categories && ! empty( $categories ) ) {
620
- $this->color_style = $ai1ec_events_helper->get_event_category_color_style( $categories[0]->term_id, $this->allday || $this->multiday );
621
- }
622
- }
623
- return $this->color_style;
624
-
625
- // =========================================
626
- // = Faded version of event category color =
627
- // =========================================
628
- case 'faded_color':
629
- if( $this->faded_color === null ) {
630
- $categories = wp_get_post_terms( $this->post_id, 'events_categories' );
631
- if( $categories && ! empty( $categories ) ) {
632
- $this->faded_color = $ai1ec_events_helper->get_event_category_faded_color( $categories[0]->term_id );
633
- }
634
- }
635
- return $this->faded_color;
636
-
637
- // ========================================
638
- // = RGBA version of faded category color =
639
- // ========================================
640
- case 'rgba_color':
641
- if( $this->rgba_color === null ) {
642
- $categories = wp_get_post_terms( $this->post_id, 'events_categories' );
643
- if( $categories && ! empty( $categories ) ) {
644
- $this->rgba_color = $ai1ec_events_helper->get_event_category_rgba_color( $categories[0]->term_id );
645
- }
646
- }
647
- return $this->rgba_color;
648
-
649
- // ===============================================
650
- // = HTML of category color boxes for this event =
651
- // ===============================================
652
- case 'category_colors':
653
- if( $this->category_colors === null ) {
654
- $categories = wp_get_post_terms( $this->post_id, 'events_categories' );
655
- $this->category_colors = $ai1ec_events_helper->get_event_category_colors( $categories );
656
- }
657
- return $this->category_colors;
658
-
659
- // ========================
660
- // = Contact info as HTML =
661
- // ========================
662
- case 'contact_html':
663
- $contact = '';
664
- if( $this->contact_name )
665
- $contact .= '<strong>' . esc_html( $this->contact_name ) . '</strong><br />';
666
- if( $this->contact_phone )
667
- $contact .= esc_html( $this->contact_phone ) . '<br />';
668
- if( $this->contact_email )
669
- $contact .= '<a href="mailto:' . esc_attr( $this->contact_email ) . '">' . esc_html( $this->contact_email ) . '</a>';
670
- return $contact;
671
-
672
- // ===========================
673
- // = Recurrence info as HTML =
674
- // ===========================
675
- case 'recurrence_html':
676
- if( ! $this->recurrence_rules || empty( $this->recurrence_rules ) )
677
- return null;
678
-
679
- return '<strong>' . esc_html( $ai1ec_events_helper->rrule_to_text( $this->recurrence_rules ) ) . '</strong>';
680
- case 'exclude_html':
681
- if( ! $this->exception_dates || empty( $this->exception_dates ) )
682
- return null;
683
-
684
- return '<strong>' . esc_html( $ai1ec_events_helper->exdate_to_text( $this->exception_dates ) ) . '</strong>';
685
- }
686
- }
687
-
688
- /**
689
- * save function
690
- *
691
- * Saves the current event data to the database. If $this->post_id exists,
692
- * but $update is false, creates a new record in the ai1ec_events table of
693
- * this event data, but does not try to create a new post. Else if $update
694
- * is true, updates existing event record. If $this->post_id is empty,
695
- * creates a new post AND record in the ai1ec_events table for this event.
696
- *
697
- * @param bool $update Whether to update an existing event or create a
698
- * new one
699
- * @return int The post_id of the new or existing event.
700
- **/
701
- function save( $update = false )
702
- {
703
- global $wpdb,
704
- $ai1ec_events_helper;
705
-
706
- // ===========================
707
- // = Insert events meta data =
708
- // ===========================
709
- $columns = array(
710
- 'post_id' => $this->post_id,
711
- 'start' => $this->start,
712
- 'end' => $this->end,
713
- 'allday' => $this->allday,
714
- 'recurrence_rules' => $this->recurrence_rules,
715
- 'exception_rules' => $this->exception_rules,
716
- 'recurrence_dates' => $this->recurrence_dates,
717
- 'exception_dates' => $this->exception_dates,
718
- 'venue' => $this->venue,
719
- 'country' => $this->country,
720
- 'address' => $this->address,
721
- 'city' => $this->city,
722
- 'province' => $this->province,
723
- 'postal_code' => $this->postal_code,
724
- 'show_map' => $this->show_map,
725
- 'contact_name' => $this->contact_name,
726
- 'contact_phone' => $this->contact_phone,
727
- 'contact_email' => $this->contact_email,
728
- 'cost' => $this->cost,
729
- 'ical_feed_url' => $this->ical_feed_url,
730
- 'ical_source_url' => $this->ical_source_url,
731
- 'ical_uid' => $this->ical_uid,
732
- );
733
-
734
- $format = array(
735
- '%d',
736
- 'FROM_UNIXTIME( %d )',
737
- 'FROM_UNIXTIME( %d )',
738
- '%d',
739
- '%s',
740
- '%s',
741
- '%s',
742
- '%s',
743
- '%s',
744
- '%s',
745
- '%s',
746
- '%s',
747
- '%s',
748
- '%s',
749
- '%d',
750
- '%s',
751
- '%s',
752
- '%s',
753
- '%s',
754
- '%s',
755
- '%s',
756
- '%s',
757
- );
758
-
759
- $table_name = $wpdb->prefix . 'ai1ec_events';
760
- if( $this->post_id )
761
- {
762
- if( ! $update ) {
763
- // =========================
764
- // = Insert new event data =
765
- // =========================
766
- $wpdb->query( $wpdb->prepare(
767
- "INSERT INTO $table_name ( " .
768
- join( ', ', array_keys( $columns ) ) .
769
- " ) VALUES ( " .
770
- join( ', ', $format ) .
771
- " )",
772
- $columns ) );
773
- } else {
774
- // ==============================
775
- // = Update existing event data =
776
- // ==============================
777
- $where = array( 'post_id' => $this->post_id );
778
- $where_escape = array( '%d' );
779
- $wpdb->update( $table_name, $columns, $where, $format, $where_escape );
780
- }
781
- } else {
782
- // ===================
783
- // = Insert new post =
784
- // ===================
785
- $this->post_id = wp_insert_post( $this->post );
786
- $columns['post_id'] = $this->post_id;
787
- wp_set_post_terms( $this->post_id, $this->categories, 'events_categories' );
788
- wp_set_post_terms( $this->post_id, $this->tags, 'events_tags' );
789
-
790
- if( isset( $this->feed ) && isset( $this->feed->feed_id ) ) {
791
- $url_components = parse_url( $this->feed->feed_url );
792
- $feed_name = $url_components["host"];
793
- $term = term_exists( $feed_name, 'events_feeds' );
794
- if( ! $term ) {
795
- // term doesn't exist, create it
796
- $term = wp_insert_term(
797
- $feed_name, // term
798
- 'events_feeds', // taxonomy
799
- array(
800
- 'description' => $this->feed->feed_url
801
- )
802
- );
803
- }
804
- // term_exists returns object, wp_insert_term returns array
805
- $term = (object)$term;
806
- if( isset( $term->term_id ) ) {
807
- // associate the event with the feed only if we have term id set
808
- $a = wp_set_object_terms( $this->post_id, (int)$term->term_id, 'events_feeds', false );
809
- }
810
- }
811
-
812
- // =========================
813
- // = Insert new event data =
814
- // =========================
815
- $wpdb->query( $wpdb->prepare(
816
- "INSERT INTO $table_name ( " .
817
- join( ', ', array_keys( $columns ) ) .
818
- " ) VALUES ( " .
819
- join( ', ', $format ) .
820
- " )",
821
- $columns ) );
822
- }
823
-
824
- return $this->post_id;
825
- }
826
-
827
- /**
828
- * getProperty function
829
- *
830
- * Returns $property value
831
- *
832
- * @param string $property Property name
833
- *
834
- * @return mixed
835
- **/
836
- function getProperty( $property ) {
837
- return $this->property;
838
- }
839
-
840
- /**
841
- * isWholeDay function
842
- *
843
- * Determines if an event is a whole day event
844
- *
845
- * @return bool
846
- **/
847
- function isWholeDay() {
848
- return ( bool ) $this->allday;
849
- }
850
-
851
- /**
852
- * getStart function
853
- *
854
- * Returns the start time of the event
855
- *
856
- * @return int
857
- **/
858
- function getStart() {
859
- return $this->start;
860
- }
861
-
862
- /**
863
- * getEnd function
864
- *
865
- * Returns the end time of the event
866
- *
867
- * @return int
868
- **/
869
- function getEnd() {
870
- return $this->end;
871
- }
872
-
873
- /**
874
- * getDuration function
875
- *
876
- * Returns the duration of the event
877
- *
878
- * @return int
879
- **/
880
- function getDuration() {
881
- return $this->end - $this->start;
882
- }
883
- }
884
- // END class
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/model/class-ai1ec-exporter.php DELETED
@@ -1,29 +0,0 @@
1
- <?php
2
- //
3
- // class-ai1ec-exporter.php
4
- // all-in-one-event-calendar
5
- //
6
- // Created by The Seed Studio on 2011-07-13.
7
- //
8
-
9
- /**
10
- * Ai1ec_Event class
11
- *
12
- * @package Models
13
- * @author time.ly
14
- **/
15
- class Ai1ec_Exporter {
16
-
17
- function __construct() {
18
-
19
- }
20
-
21
- function export( $events, $format = "ics" ) {
22
-
23
- }
24
-
25
- function export_to_ics() {
26
-
27
- }
28
- }
29
- // END class
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/model/class-ai1ec-importer.php DELETED
@@ -1,30 +0,0 @@
1
- <?php
2
- //
3
- // class-ai1ec-importer.php
4
- // all-in-one-event-calendar
5
- //
6
- // Created by The Seed Studio on 2011-07-13.
7
- //
8
-
9
- /**
10
- * Ai1ec_Importer class
11
- *
12
- * @package Models
13
- * @author time.ly
14
- **/
15
- class Ai1ec_Importer {
16
- var $events;
17
-
18
- function __construct() {
19
-
20
- }
21
-
22
- function parse_rss( $rss_feed ) {
23
-
24
- }
25
-
26
- function parse_file( $file ) {
27
-
28
- }
29
- }
30
- // END class
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/model/class-ai1ec-settings.php DELETED
@@ -1,540 +0,0 @@
1
- <?php
2
- //
3
- // class-ai1ec-settings.php
4
- // all-in-one-event-calendar
5
- //
6
- // Created by The Seed Studio on 2011-07-13.
7
- //
8
-
9
- /**
10
- * Ai1ec_Settings class
11
- *
12
- * @package Models
13
- * @author time.ly
14
- **/
15
- class Ai1ec_Settings {
16
- /**
17
- * _instance class variable
18
- *
19
- * Class instance
20
- *
21
- * @var null | object
22
- **/
23
- private static $_instance = NULL;
24
-
25
- /**
26
- * calendar_page_id class variable
27
- *
28
- * @var int
29
- **/
30
- var $calendar_page_id;
31
-
32
- /**
33
- * default_calendar_view class variable
34
- *
35
- * @var string
36
- **/
37
- var $default_calendar_view;
38
-
39
- /**
40
- * week_start_day class variable
41
- *
42
- * @var int
43
- **/
44
- var $week_start_day;
45
-
46
- /**
47
- * agenda_events_per_page class variable
48
- *
49
- * @var int
50
- **/
51
- var $agenda_events_per_page;
52
-
53
- /**
54
- * calendar_css_selector class variable
55
- *
56
- * @var string
57
- **/
58
- var $calendar_css_selector;
59
-
60
- /**
61
- * include_events_in_rss class variable
62
- *
63
- * @var bool
64
- **/
65
- var $include_events_in_rss;
66
-
67
- /**
68
- * allow_publish_to_facebook class variable
69
- *
70
- * @var bool
71
- **/
72
- var $allow_publish_to_facebook;
73
-
74
- /**
75
- * facebook_credentials class variable
76
- *
77
- * @var array
78
- **/
79
- var $facebook_credentials;
80
-
81
- /**
82
- * user_role_can_create_event class variable
83
- *
84
- * @var bool
85
- **/
86
- var $user_role_can_create_event;
87
-
88
- /**
89
- * cron_freq class variable
90
- *
91
- * Cron frequency
92
- *
93
- * @var string
94
- **/
95
- var $cron_freq;
96
-
97
- /**
98
- * timezone class variable
99
- *
100
- * @var string
101
- **/
102
- var $timezone;
103
-
104
- /**
105
- * exclude_from_search class variable
106
- *
107
- * Whether to exclude events from search results
108
- * @var bool
109
- **/
110
- var $exclude_from_search;
111
-
112
- /**
113
- * show_publish_button class variable
114
- *
115
- * Display publish button at the bottom of the
116
- * submission form
117
- *
118
- * @var bool
119
- **/
120
- var $show_publish_button;
121
-
122
- /**
123
- * hide_maps_until_clicked class variable
124
- *
125
- * When this setting is on, instead of showing the Google Map,
126
- * show a dotted-line box containing the text "Click to view map",
127
- * and when clicked, this box is replaced by the Google Map.
128
- *
129
- * @var bool
130
- **/
131
- var $hide_maps_until_clicked;
132
-
133
- /**
134
- * agenda_events_expanded class variable
135
- *
136
- * When this setting is on, events are expanded
137
- * in agenda view
138
- *
139
- * @var bool
140
- **/
141
- var $agenda_events_expanded;
142
-
143
- /**
144
- * show_create_event_button class variable
145
- *
146
- * Display "Post Your Event" button on the calendar page for those users with
147
- * the privilege.
148
- *
149
- * @var bool
150
- **/
151
- var $show_create_event_button;
152
-
153
- /**
154
- * turn_off_subscription_buttons class variable
155
- *
156
- * Hides "Subscribe"/"Add to Calendar" and same Google buttons in calendar and
157
- * single event views
158
- *
159
- * @var bool
160
- **/
161
- var $turn_off_subscription_buttons;
162
-
163
- /**
164
- * inject_categories class variable
165
- *
166
- * Include Event Categories as part of the output of the wp_list_categories()
167
- * template tag.
168
- *
169
- * @var bool
170
- **/
171
- var $inject_categories;
172
-
173
- /**
174
- * input_date_format class variable
175
- *
176
- * Date format used for date input. For supported formats
177
- * @see jquery.calendrical.js
178
- *
179
- * @var string
180
- **/
181
- var $input_date_format;
182
-
183
- /**
184
- * input_24h_time class variable
185
- *
186
- * Use 24h time in time pickers.
187
- *
188
- * @var bool
189
- **/
190
- var $input_24h_time;
191
-
192
- /**
193
- * settings_page class variable
194
- *
195
- * Stores a reference to the settings page added using the
196
- * add_submenu_page function.
197
- *
198
- * @var object
199
- */
200
- var $settings_page;
201
-
202
- /**
203
- * feeds_page class variable
204
- *
205
- * Stores a reference to the calendar feeds page added using the
206
- * add_submenu_page function.
207
- *
208
- * @var object
209
- */
210
- var $feeds_page;
211
-
212
- /**
213
- * geo_region_biasing class variable
214
- *
215
- * If set to TRUE the ISO-3166 part of the configured
216
- * locale in WordPress is going to be used to bias the
217
- * geo autocomplete plugin towards a specific region.
218
- *
219
- * @var bool
220
- **/
221
- var $geo_region_biasing;
222
-
223
- /**
224
- * Whether to display data collection notice on the admin side.
225
- *
226
- * @var bool
227
- */
228
- var $show_data_notification;
229
-
230
- /**
231
- * Whether to display the introductory video notice.
232
- *
233
- * @var bool
234
- */
235
- var $show_intro_video;
236
-
237
- /**
238
- * allow_statistics class variable
239
- *
240
- * @var bool
241
- **/
242
- var $allow_statistics;
243
-
244
- /**
245
- * disable_autocompletion class variable
246
- *
247
- * @var bool
248
- **/
249
- var $disable_autocompletion;
250
-
251
- /**
252
- * Show location name in event title in various calendar views.
253
- *
254
- * @var bool
255
- */
256
- var $show_location_in_title;
257
-
258
- /**
259
- * Show year in agenda date labels.
260
- *
261
- * @var bool
262
- */
263
- var $show_year_in_agenda_dates;
264
-
265
- /**
266
- * Show the standard notification.
267
- *
268
- * @var bool
269
- */
270
- var $show_standard_notice;
271
-
272
- /**
273
- * __construct function
274
- *
275
- * Default constructor
276
- **/
277
- private function __construct() {
278
- $this->set_defaults(); // set default settings
279
- }
280
-
281
- /**
282
- * get_instance function
283
- *
284
- * Return singleton instance
285
- *
286
- * @return object
287
- **/
288
- static function get_instance()
289
- {
290
- if( self::$_instance === NULL ) {
291
- // if W3TC is enabled, we have to empty the cache
292
- // before requesting it
293
- if( defined( 'W3TC' ) ) {
294
- wp_cache_delete( 'alloptions', 'options' );
295
- }
296
- // get the settings from the database
297
- self::$_instance = get_option( 'ai1ec_settings' );
298
-
299
- // if there are no settings in the database
300
- // save default values for the settings
301
- if( ! self::$_instance ) {
302
- self::$_instance = new self();
303
- delete_option( 'ai1ec_settings' );
304
- add_option( 'ai1ec_settings', self::$_instance );
305
- } else {
306
- self::$_instance->set_defaults(); // set default settings
307
- }
308
- }
309
-
310
- return self::$_instance;
311
- }
312
-
313
- /**
314
- * is_timezone_open_for_change method
315
- *
316
- * Check if it is allowed to change timezone.
317
- * It is *yes* (`bool(true)`) if WordPress timezone string was not set.
318
- *
319
- * @return bool True if timezone may be modified
320
- */
321
- static public function is_timezone_open_for_change() {
322
- return ( ! get_option( 'timezone_string' ) );
323
- }
324
-
325
- /**
326
- * save function
327
- *
328
- * Save settings to the database.
329
- *
330
- * @return void
331
- **/
332
- function save() {
333
- update_option( 'ai1ec_settings', $this );
334
- update_option( 'start_of_week', $this->week_start_day );
335
- update_option( 'ai1ec_cron_version', get_option( 'ai1ec_cron_version' ) + 1 );
336
- if ( $this->is_timezone_open_for_change() ) {
337
- update_option( 'timezone_string', $this->timezone );
338
- }
339
- }
340
-
341
- /**
342
- * set_defaults function
343
- *
344
- * Set default values for settings.
345
- *
346
- * @return void
347
- **/
348
- function set_defaults() {
349
- $defaults = array(
350
- 'calendar_page_id' => 0,
351
- 'default_calendar_view' => 'month',
352
- 'calendar_css_selector' => '',
353
- 'week_start_day' => get_option( 'start_of_week' ),
354
- 'agenda_events_per_page' => get_option( 'posts_per_page' ),
355
- 'agenda_events_expanded' => FALSE,
356
- 'include_events_in_rss' => FALSE,
357
- 'allow_publish_to_facebook' => FALSE,
358
- 'facebook_credentials' => NULL,
359
- 'user_role_can_create_event' => NULL,
360
- 'show_publish_button' => FALSE,
361
- 'hide_maps_until_clicked' => FALSE,
362
- 'exclude_from_search' => FALSE,
363
- 'show_create_event_button' => FALSE,
364
- 'turn_off_subscription_buttons' => FALSE,
365
- 'inject_categories' => FALSE,
366
- 'input_date_format' => 'def',
367
- 'input_24h_time' => FALSE,
368
- 'cron_freq' => 'daily',
369
- 'timezone' => get_option( 'timezone_string' ),
370
- 'geo_region_biasing' => FALSE,
371
- 'show_data_notification' => TRUE,
372
- 'show_intro_video' => TRUE,
373
- 'allow_statistics' => FALSE, // stats are opt-in
374
- 'disable_autocompletion' => FALSE,
375
- 'show_location_in_title' => TRUE,
376
- 'show_year_in_agenda_dates' => FALSE,
377
- 'show_standard_notice' => TRUE,
378
- );
379
-
380
- foreach( $defaults as $key => $default ) {
381
- if( ! isset( $this->$key ) )
382
- $this->$key = $default;
383
- }
384
- }
385
-
386
- /**
387
- * Updates field values with corresponding values found in $params
388
- * associative array.
389
- *
390
- * @param string $settings_page Which settings page is being updated.
391
- * @param array $params Assoc. array of new settings, e.g. from $_REQUEST.
392
- *
393
- * @return void
394
- */
395
- function update( $settings_page, $params ) {
396
- switch ($settings_page) {
397
- // ==================
398
- // = Settings page. =
399
- // ==================
400
- case 'settings':
401
- $field_names = array(
402
- 'default_calendar_view',
403
- 'calendar_css_selector',
404
- 'week_start_day',
405
- 'agenda_events_per_page',
406
- 'input_date_format',
407
- 'allow_events_posting_facebook',
408
- 'facebook_credentials',
409
- 'user_role_can_create_event',
410
- 'timezone',
411
- );
412
- $checkboxes = array(
413
- 'agenda_events_expanded',
414
- 'include_events_in_rss',
415
- 'show_publish_button',
416
- 'hide_maps_until_clicked',
417
- 'exclude_from_search',
418
- 'show_create_event_button',
419
- 'turn_off_subscription_buttons',
420
- 'inject_categories',
421
- 'input_24h_time',
422
- 'geo_region_biasing',
423
- 'allow_statistics',
424
- 'disable_autocompletion',
425
- 'show_location_in_title',
426
- 'show_year_in_agenda_dates',
427
- );
428
-
429
- // Assign parameters to settings.
430
- foreach( $field_names as $field_name ) {
431
- if( isset( $params[$field_name] ) ) {
432
- $this->$field_name = $params[$field_name];
433
- }
434
- }
435
- foreach( $checkboxes as $checkbox ) {
436
- $this->$checkbox = isset( $params[$checkbox] ) ? TRUE : FALSE;
437
- }
438
-
439
- // Validate specific parameters.
440
- $this->agenda_events_per_page = intval( $this->agenda_events_per_page );
441
- if( $this->agenda_events_per_page <= 0 ) {
442
- $this->agenda_events_per_page = 1;
443
- }
444
-
445
- // Update special parameters.
446
- $this->update_page( 'calendar_page_id', $params );
447
- break;
448
-
449
- // ===============
450
- // = Feeds page. =
451
- // ===============
452
- case 'feeds':
453
- // Assign parameters to settings.
454
- if( isset( $params['cron_freq'] ) ) {
455
- $this->cron_freq = $params['cron_freq'];
456
- }
457
- break;
458
- }
459
- }
460
-
461
- /**
462
- * Update setting of show_data_notification - whether to display data
463
- * collection notice on the admin side.
464
- *
465
- * @param boolean $value The new setting for show_data_notification.
466
- * @return void
467
- */
468
- function update_notification( $value = FALSE ) {
469
- $this->show_data_notification = $value;
470
- update_option( 'ai1ec_settings', $this );
471
- }
472
-
473
- /**
474
- * Update setting of show_data_notification - whether to display data
475
- * collection notice on the admin side.
476
- *
477
- * @param boolean $value The new setting for show_data_notification.
478
- * @return void
479
- */
480
- function update_standard_notification( $value = FALSE ) {
481
- $this->show_standard_notice = $value;
482
- update_option( 'ai1ec_settings', $this );
483
- }
484
-
485
- /**
486
- * Update setting of show_intro_video - whether to display the
487
- * intro video notice on the admin side.
488
- *
489
- * @param boolean $value The new setting for show_intro_video.
490
- * @return void
491
- */
492
- function update_intro_video( $value = FALSE ) {
493
- $this->show_intro_video = $value;
494
- update_option( 'ai1ec_settings', $this );
495
- }
496
-
497
- /**
498
- * update_page function
499
- *
500
- * Update page for the calendar with the one specified by the drop-down box.
501
- * If the value is not numeric, user chose to auto-create a new page,
502
- * therefore do so.
503
- *
504
- * @param string $field_name
505
- * @param array $params
506
- *
507
- * @return void
508
- **/
509
- function update_page( $field_name, &$params ) {
510
- if( ! is_numeric( $params[$field_name] ) &&
511
- preg_match( '#^__auto_page:(.*?)$#', $params[$field_name], $matches ) )
512
- {
513
- $this->$field_name = $params[$field_name] = $this->auto_add_page( $matches[1] );
514
- } else {
515
- $this->$field_name = (int) $params[$field_name];
516
- }
517
- }
518
-
519
- /**
520
- * auto_add_page function
521
- *
522
- * Auto-create a WordPress page with given name for use by this plugin.
523
- *
524
- * @param string page_name
525
- *
526
- * @return int the new page's ID.
527
- **/
528
- function auto_add_page( $page_name ) {
529
- return wp_insert_post(
530
- array(
531
- 'post_title' => $page_name,
532
- 'post_type' => 'page',
533
- 'post_status' => 'publish',
534
- 'comment_status' => 'closed'
535
- )
536
- );
537
- }
538
-
539
- }
540
- // END class
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/model/event.php ADDED
@@ -0,0 +1,760 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * Model representing an event or an event instance.
5
+ *
6
+ * @author Time.ly Network, Inc.
7
+ * @since 2.0
8
+ * @instantiator Ai1ec_Factory_Event.create_event_instance
9
+ * @package Ai1EC
10
+ * @subpackage Ai1EC.Model
11
+ */
12
+ class Ai1ec_Event extends Ai1ec_Base {
13
+
14
+ /**
15
+ * @var Ai1ec_Event_Entity Data store object reference.
16
+ */
17
+ protected $_entity = null;
18
+
19
+ /**
20
+ * @var array Map of fields that require special care during set/get
21
+ * operations. Values have following meanings:
22
+ * [0] - both way care required;
23
+ * [1] - only `set` operations require care;
24
+ * [-1] - only `get` (for storage) operations require care.
25
+ */
26
+ protected $_swizzable = array(
27
+ 'contact_url' => 0,
28
+ 'cost' => 0,
29
+ 'ticket_url' => 0,
30
+ 'start' => -1,
31
+ 'end' => -1,
32
+ 'timezone_name' => -1,
33
+ );
34
+
35
+ /**
36
+ * @var array Runtime properties
37
+ */
38
+ protected $_runtime_props = array();
39
+
40
+ /**
41
+ * @var bool|null Boolean cache-definition indicating if event is multiday.
42
+ */
43
+ protected $_is_multiday = null;
44
+
45
+ /**
46
+ * Wrapper to get property value.
47
+ *
48
+ * @param string $property Name of property to get.
49
+ *
50
+ * @return mixed Actual property.
51
+ */
52
+ public function get( $property ) {
53
+ return $this->_entity->get( $property );
54
+ }
55
+
56
+ /**
57
+ * Get properties generated at runtime
58
+ *
59
+ * @param string $property
60
+ *
61
+ * @return string
62
+ */
63
+ public function get_runtime( $property ) {
64
+
65
+ return isset( $this->_runtime_props[$property] ) ?
66
+ $this->_runtime_props[$property] :
67
+ '';
68
+ }
69
+
70
+ /**
71
+ * Set properties generated at runtime
72
+ *
73
+ * @param string $property
74
+ * @param string $value
75
+ */
76
+ public function set_runtime( $property, $value ) {
77
+ $this->_runtime_props[$property] = $value;
78
+ }
79
+
80
+ /**
81
+ * Handle property initiation.
82
+ *
83
+ * Decides, how to extract value stored in permanent storage.
84
+ *
85
+ * @param string $property Name of property to handle
86
+ * @param mixed $value Value, read from permanent storage
87
+ *
88
+ * @return bool Success
89
+ */
90
+ public function set( $property, $value ) {
91
+ if (
92
+ isset( $this->_swizzable[$property] ) &&
93
+ $this->_swizzable[$property] >= 0
94
+ ) {
95
+ $method = '_handle_property_construct_' . $property;
96
+ $value = $this->{$method}( $value );
97
+ }
98
+ $this->_entity->set( $property, $value );
99
+ return $this;
100
+ }
101
+
102
+ /**
103
+ * Set object fields from arbitrary array.
104
+ *
105
+ * @param array $data Supposedly map of fields to initiate.
106
+ *
107
+ * @return Ai1ec_Event Instance of self for chaining.
108
+ */
109
+ public function initialize_from_array( array $data ) {
110
+
111
+ // =======================================================
112
+ // = Assign each event field the value from the database =
113
+ // =======================================================
114
+ foreach ( $this->_entity->list_properties() as $property ) {
115
+ if ( 'post' !== $property && isset( $data[$property] ) ) {
116
+ $this->set( $property, $data[$property] );
117
+ unset( $data[$property] );
118
+ }
119
+ }
120
+ if ( isset( $data['post'] ) ) {
121
+ $this->set( 'post', (object)$data['post'] );
122
+ } else {
123
+ // ========================================
124
+ // = Remaining fields are the post fields =
125
+ // ========================================
126
+ $this->set( 'post', (object)$data );
127
+ }
128
+ return $this;
129
+ }
130
+
131
+ /**
132
+ * Initialize object from ID.
133
+ *
134
+ * Attempts to retrieve entity from database and if succeeds - uses
135
+ * {@see self::initialize_from_array} to initiate actual values.
136
+ *
137
+ * @param int $post_id ID of post (event) to initiate.
138
+ * @param int|bool $instance ID of event instance, false for base event.
139
+ *
140
+ * @return Ai1ec_Event Instance of self for chaining.
141
+ *
142
+ * @throws Ai1ec_Event_Not_Found_Exception If entity is not locatable.
143
+ */
144
+ public function initialize_from_id( $post_id, $instance = false ) {
145
+ $post = get_post( $post_id );
146
+ if ( ! $post || $post->post_status == 'auto-draft' ) {
147
+ throw new Ai1ec_Event_Not_Found_Exception(
148
+ 'Post with ID \'' . $post_id .
149
+ '\' could not be retrieved from the database.'
150
+ );
151
+ }
152
+ $post_id = (int)$post_id;
153
+ $dbi = $this->_registry->get( 'dbi.dbi' );
154
+
155
+ $left_join = '';
156
+ $select_sql = '
157
+ e.post_id,
158
+ e.timezone_name,
159
+ e.recurrence_rules,
160
+ e.exception_rules,
161
+ e.allday,
162
+ e.instant_event,
163
+ e.recurrence_dates,
164
+ e.exception_dates,
165
+ e.venue,
166
+ e.country,
167
+ e.address,
168
+ e.city,
169
+ e.province,
170
+ e.postal_code,
171
+ e.show_map,
172
+ e.contact_name,
173
+ e.contact_phone,
174
+ e.contact_email,
175
+ e.contact_url,
176
+ e.cost,
177
+ e.ticket_url,
178
+ e.ical_feed_url,
179
+ e.ical_source_url,
180
+ e.ical_organizer,
181
+ e.ical_contact,
182
+ e.ical_uid,
183
+ e.longitude,
184
+ e.latitude,
185
+ e.show_coordinates,
186
+ GROUP_CONCAT( ttc.term_id ) AS categories,
187
+ GROUP_CONCAT( ttt.term_id ) AS tags
188
+ ';
189
+
190
+ if ( false !== $instance && is_numeric( $instance ) ) {
191
+ $select_sql .= ", IF( aei.start IS NOT NULL, aei.start, e.start ) as start," .
192
+ " IF( aei.start IS NOT NULL, aei.end, e.end ) as end ";
193
+
194
+ $instance = (int)$instance;
195
+ $this->instance_id = $instance;
196
+ $left_join = 'LEFT JOIN ' . $dbi->get_table_name( 'ai1ec_event_instances' ) .
197
+ ' aei ON aei.id = ' . $instance . ' AND e.post_id = aei.post_id ';
198
+ } else {
199
+ $select_sql .= ', e.start as start, e.end as end, e.allday ';
200
+ }
201
+
202
+ // =============================
203
+ // = Fetch event from database =
204
+ // =============================
205
+ $query = 'SELECT ' . $select_sql . '
206
+ FROM ' . $dbi->get_table_name( 'ai1ec_events' ) . ' e
207
+ LEFT JOIN ' .
208
+ $dbi->get_table_name( 'term_relationships' ) . ' tr
209
+ ON ( e.post_id = tr.object_id )
210
+ LEFT JOIN ' . $dbi->get_table_name( 'term_taxonomy' ) . ' ttc
211
+ ON (
212
+ tr.term_taxonomy_id = ttc.term_taxonomy_id AND
213
+ ttc.taxonomy = \'events_categories\'
214
+ )
215
+ LEFT JOIN ' . $dbi->get_table_name( 'term_taxonomy' ) . ' ttt
216
+ ON (
217
+ tr.term_taxonomy_id = ttt.term_taxonomy_id AND
218
+ ttt.taxonomy = \'events_tags\'
219
+ )
220
+ ' . $left_join . '
221
+ WHERE e.post_id = ' . $post_id . '
222
+ GROUP BY e.post_id';
223
+
224
+ $event = $dbi->get_row( $query, ARRAY_A );
225
+ if ( null === $event || null === $event['post_id'] ) {
226
+ throw new Ai1ec_Event_Not_Found_Exception(
227
+ 'Event with ID \'' . $post_id .
228
+ '\' could not be retrieved from the database.'
229
+ );
230
+ }
231
+
232
+ $event['post'] = $post;
233
+ return $this->initialize_from_array( $event );
234
+ }
235
+
236
+ /**
237
+ * Create new event object, using provided data for initialization.
238
+ *
239
+ * @param Ai1ec_Registry_Object $registry Injected object registry.
240
+ * @param int|array|null $data Look up post with id $data, or
241
+ * initialize fields with associative
242
+ * array $data containing both post
243
+ * and event fields.
244
+ * @param bool $instance Optionally instance ID.
245
+ *
246
+ * @throws Ai1ec_Invalid_Argument_Exception When $data is not one
247
+ * of int|array|null.
248
+ * @throws Ai1ec_Event_Not_Found_Exception When $data relates to
249
+ * non-existent ID.
250
+ *
251
+ * @return void
252
+ */
253
+ function __construct(
254
+ Ai1ec_Registry_Object $registry,
255
+ $data = null,
256
+ $instance = false
257
+ ) {
258
+ parent::__construct( $registry );
259
+ $this->_entity = $this->_registry->get( 'model.event.entity' );
260
+ if ( null === $data ) {
261
+ return; // empty object
262
+ } else if ( is_numeric( $data ) ) {
263
+ $this->initialize_from_id( $data, $instance );
264
+ } else if ( is_array( $data ) ) {
265
+ $this->initialize_from_array( $data );
266
+ } else {
267
+ throw new Ai1ec_Invalid_Argument_Exception(
268
+ 'Argument to constructor must be integer, array or null' .
269
+ ', not ' . var_export( $data, true )
270
+ );
271
+ }
272
+
273
+ if ( $this->is_allday() ) {
274
+ try {
275
+ $timezone = $this->_registry->get( 'date.timezone' )
276
+ ->get( $this->get( 'timezone_name' ) );
277
+ $this->_entity->set_preferred_timezone( $timezone );
278
+ } catch ( Exception $excpt ) {
279
+ // ignore
280
+ }
281
+ }
282
+ }
283
+
284
+ /**
285
+ * Restore original URL from loggable event URL
286
+ *
287
+ * @param string $value URL as seen by visitor
288
+ *
289
+ * @return string Original URL
290
+ */
291
+ public function get_nonloggable_url( $value ) {
292
+ if (
293
+ empty( $value ) ||
294
+ false === strpos( $value, AI1EC_REDIRECTION_SERVICE )
295
+ ) {
296
+ return $value;
297
+ }
298
+ $decoded = json_decode(
299
+ base64_decode(
300
+ trim(
301
+ substr( $value, strlen( AI1EC_REDIRECTION_SERVICE ) ),
302
+ '/'
303
+ )
304
+ ),
305
+ true
306
+ );
307
+ if ( ! isset( $decoded['l'] ) ) {
308
+ return '';
309
+ }
310
+ return $decoded['l'];
311
+ }
312
+
313
+ /**
314
+ * Convert URL to a loggable form
315
+ *
316
+ * @param string $url URL to which access must be counted
317
+ * @param string $intent Char definition: 'b' - buy, 'd' - details
318
+ *
319
+ * @return string Loggable URL form
320
+ *
321
+ * @staticvar array $options Defaut options to persist between instances.
322
+ */
323
+ protected function _make_url_loggable( $url, $intent ) {
324
+ static $options = NULL;
325
+ $url = trim( $url );
326
+ if ( ! $url || ! filter_var( $url, FILTER_VALIDATE_URL ) ) {
327
+ return $url;
328
+ }
329
+ if ( ! isset( $options ) ) {
330
+ $options = array(
331
+ 'l' => NULL,
332
+ 'e' => ( false !== strpos( AI1EC_VERSION, 'pro' ) ) ? 'p' : 's',
333
+ 'v' => (string)AI1EC_VERSION,
334
+ 'i' => NULL,
335
+ 'c' => NULL,
336
+ 'o' => (string)get_site_url(),
337
+ );
338
+ }
339
+ $options['l'] = (string)$url;
340
+ $options['i'] = (string)$intent;
341
+ $options['c'] = (string)$this->get( 'cost' );
342
+ return AI1EC_REDIRECTION_SERVICE .
343
+ base64_encode( json_encode( $options ) );
344
+ }
345
+
346
+ /**
347
+ * Make `Ticket URL` loggable
348
+ *
349
+ * @param string $value Ticket URL stored in database
350
+ *
351
+ * @return bool Success
352
+ */
353
+ public function _handle_property_construct_ticket_url( $value ) {
354
+ return $this->_make_url_loggable( $value, 'b' );
355
+ }
356
+
357
+ /**
358
+ * Make `Contact URL` loggable
359
+ *
360
+ * @param string $value Contact URL stored in database
361
+ *
362
+ * @return bool Success
363
+ */
364
+ public function _handle_property_construct_contact_url( $value ) {
365
+ return $this->_make_url_loggable( $value, 'd' );
366
+ }
367
+
368
+ /**
369
+ * Handle `cost` value reading from permanent storage.
370
+ *
371
+ * @param string $value Value stored in permanent storage
372
+ *
373
+ * @return bool Success: true, always
374
+ */
375
+ protected function _handle_property_construct_cost( $value ) {
376
+ $test_value = false;
377
+ if (
378
+ isset( $value{1} ) && (
379
+ ':' === $value{1} || ';' === $value{1}
380
+ )
381
+ ) {
382
+ $test_value = unserialize( $value );
383
+ }
384
+ $cost = $is_free = NULL;
385
+ if ( false === $test_value ) {
386
+ $cost = trim( $value );
387
+ $is_free = false;
388
+ } else {
389
+ extract( $test_value, EXTR_IF_EXISTS );
390
+ }
391
+ $this->_entity->set( 'is_free', (bool)$is_free );
392
+ return (string)$cost;
393
+ }
394
+
395
+ /**
396
+ * Return UID to use according to ICS rules.
397
+ *
398
+ * @return string UID event identifier.
399
+ *
400
+ * @staticvar string $_blog_url Base URL of blog, used as part of UID.
401
+ */
402
+ public function get_uid() {
403
+ static $_blog_url = NULL;
404
+ if ( NULL === $_blog_url ) {
405
+ $_blog_url = bloginfo( 'url' );
406
+ }
407
+ return $this->get( 'post_id' ) . '@' . $_blog_url;
408
+ }
409
+
410
+ /**
411
+ * Check if event is free.
412
+ *
413
+ * @return bool Free status.
414
+ */
415
+ public function is_free() {
416
+ return (bool)$this->get( 'is_free' );
417
+ }
418
+
419
+ /**
420
+ * Check if event is taking all day.
421
+ *
422
+ * @return bool True for all-day long events.
423
+ */
424
+ public function is_allday() {
425
+ return (bool)$this->get( 'allday' );
426
+ }
427
+
428
+ /**
429
+ * Check if event has virtually no time.
430
+ *
431
+ * @return bool True for instant events.
432
+ */
433
+ public function is_instant() {
434
+ return (bool)$this->get( 'instant_event' );
435
+ }
436
+
437
+ /**
438
+ * Check if event is taking multiple days.
439
+ *
440
+ * Uses object-wide variable {@see self::$_is_multiday} to store
441
+ * calculated value after first call.
442
+ *
443
+ * @return bool True for multiday events.
444
+ */
445
+ public function is_multiday() {
446
+ if ( null === $this->_is_multiday ) {
447
+ $start = $this->get( 'start' );
448
+ $end = $this->get( 'end' );
449
+ $diff = $end->diff_sec( $start );
450
+ $this->_is_multiday = $diff > 86400 &&
451
+ $start->format( 'Y-m-d' ) !== $end->format( 'Y-m-d' );
452
+ }
453
+ return $this->_is_multiday;
454
+ }
455
+
456
+ /**
457
+ * Get the duration of the event
458
+ *
459
+ * @return number
460
+ */
461
+ public function get_duration() {
462
+ static $duration;
463
+ if ( null === $duration ) {
464
+ $duration = $this->get( 'end' )->format() -
465
+ $this->get( 'start' )->format();
466
+ }
467
+ return $duration;
468
+ }
469
+
470
+ /**
471
+ * Create/update entity representation.
472
+ *
473
+ * Saves the current event data to the database. If $this->post_id exists,
474
+ * but $update is false, creates a new record in the ai1ec_events table of
475
+ * this event data, but does not try to create a new post. Else if $update
476
+ * is true, updates existing event record. If $this->post_id is empty,
477
+ * creates a new post AND record in the ai1ec_events table for this event.
478
+ *
479
+ * @param bool $update Whether to update an existing event or create a
480
+ * new one
481
+ * @return int The post_id of the new or existing event.
482
+ */
483
+ function save( $update = false ) {
484
+ $dbi = $this->_registry->get( 'dbi.dbi' );
485
+ $columns = $this->prepare_store_entity();
486
+ $format = $this->prepare_store_format( $columns );
487
+ $table_name = $dbi->get_table_name( 'ai1ec_events' );
488
+ $post_id = $columns['post_id'];
489
+
490
+ if ( $post_id ) {
491
+
492
+ $success = false;
493
+ if ( ! $update ) {
494
+ $success = $dbi->insert(
495
+ $table_name,
496
+ $columns,
497
+ $format
498
+ );
499
+ } else {
500
+ $success = $dbi->update(
501
+ $table_name,
502
+ $columns,
503
+ array( 'post_id' => $columns['post_id'] ),
504
+ $format,
505
+ array( '%d' )
506
+ );
507
+ }
508
+ if ( false === $success ) {
509
+ return false;
510
+ }
511
+
512
+ } else {
513
+ // ===================
514
+ // = Insert new post =
515
+ // ===================
516
+ $post_id = wp_insert_post( $this->get( 'post' ), false );
517
+ if ( 0 === $post_id ) {
518
+ return false;
519
+ }
520
+ $this->set( 'post_id', $post_id );
521
+ $columns['post_id'] = $post_id;
522
+
523
+ $taxonomy = $this->_registry->get(
524
+ 'model.event.taxonomy',
525
+ $post_id
526
+ );
527
+ $taxonomy->set_categories( $this->get( 'categories' ) );
528
+ $taxonomy->set_tags( $this->get( 'tags' ) );
529
+
530
+ if (
531
+ $feed = $this->get( 'feed' ) &&
532
+ isset( $feed->feed_id )
533
+ ) {
534
+ $taxonomy->set_feed( $feed );
535
+ }
536
+
537
+ // =========================
538
+ // = Insert new event data =
539
+ // =========================
540
+ if ( false === $dbi->insert( $table_name, $columns, $format ) ) {
541
+ return false;
542
+ }
543
+ }
544
+
545
+ // give other plugins / extensions the ability to do things
546
+ // when saving, like fetching authors which i removed as it's not core.
547
+ do_action( 'ai1ec_save_event' );
548
+
549
+ $instance_model = $this->_registry->get( 'model.event.instance' );
550
+ $instance_model->recreate( $this );
551
+
552
+ do_action( 'ai1ec_event_saved', $post_id, $this );
553
+ return $post_id;
554
+ }
555
+
556
+ /**
557
+ * Prepare fields format flags to use in database operations.
558
+ *
559
+ * NOTICE: parameter $entity is ignored as of now.
560
+ *
561
+ * @param array $entity Serialized entity to prepare flags for.
562
+ *
563
+ * @return array List of format flags to use in integrations with DBI.
564
+ */
565
+ public function prepare_store_format( array $entity ) {
566
+ // ===============================================================
567
+ // ====== Sample implementation to follow method signature: ======
568
+ // ===============================================================
569
+ // static $format = array(
570
+ // 'post_id' => '%d',
571
+ // 'start' => '%d',
572
+ // 'end' => '%d',
573
+ // 'timezone_name' => '%s',
574
+ // // other keys to follow...
575
+ // );
576
+ // return array_values( array_intersect_key( $format, $entity ) );
577
+ // ===============================================================
578
+ $format = array(
579
+ '%d', // post_id
580
+ '%d', // start
581
+ '%d', // end
582
+ '%s', // timezone_name
583
+ '%d', // allday
584
+ '%d', // instant_event
585
+ '%s', // recurrence_rules
586
+ '%s', // exception_rules
587
+ '%s', // recurrence_dates
588
+ '%s', // exception_dates
589
+ '%s', // venue
590
+ '%s', // country
591
+ '%s', // address
592
+ '%s', // city
593
+ '%s', // province
594
+ '%s', // postal_code
595
+ '%d', // show_map
596
+ '%s', // contact_name
597
+ '%s', // contact_phone
598
+ '%s', // contact_email
599
+ '%s', // contact_url
600
+ '%s', // cost
601
+ '%s', // ticket_url
602
+ '%s', // ical_feed_url
603
+ '%s', // ical_source_url
604
+ '%s', // ical_uid
605
+ '%d', // show_coordinates
606
+ '%f', // latitude
607
+ '%f', // longitude
608
+ );
609
+ return $format;
610
+ }
611
+
612
+ /**
613
+ * Prepare event entity {@see self::$_entity} for persistent storage.
614
+ *
615
+ * Creates an array of database fields and corresponding values.
616
+ *
617
+ * @return array Map of fields to store.
618
+ */
619
+ public function prepare_store_entity() {
620
+ $entity = array(
621
+ 'post_id' => $this->storage_format( 'post_id' ),
622
+ 'start' => $this->storage_format( 'start' ),
623
+ 'end' => $this->storage_format( 'end' ),
624
+ 'timezone_name' => $this->storage_format( 'timezone_name' ),
625
+ 'allday' => $this->storage_format( 'allday' ),
626
+ 'instant_event' => $this->storage_format( 'instant_event' ),
627
+ 'recurrence_rules' => $this->storage_format( 'recurrence_rules' ),
628
+ 'exception_rules' => $this->storage_format( 'exception_rules' ),
629
+ 'recurrence_dates' => $this->storage_format( 'recurrence_dates' ),
630
+ 'exception_dates' => $this->storage_format( 'exception_dates' ),
631
+ 'venue' => $this->storage_format( 'venue' ),
632
+ 'country' => $this->storage_format( 'country' ),
633
+ 'address' => $this->storage_format( 'address' ),
634
+ 'city' => $this->storage_format( 'city' ),
635
+ 'province' => $this->storage_format( 'province' ),
636
+ 'postal_code' => $this->storage_format( 'postal_code' ),
637
+ 'show_map' => $this->storage_format( 'show_map' ),
638
+ 'contact_name' => $this->storage_format( 'contact_name' ),
639
+ 'contact_phone' => $this->storage_format( 'contact_phone' ),
640
+ 'contact_email' => $this->storage_format( 'contact_email' ),
641
+ 'contact_url' => $this->storage_format( 'contact_url' ),
642
+ 'cost' => $this->storage_format( 'cost' ),
643
+ 'ticket_url' => $this->storage_format( 'ticket_url' ),
644
+ 'ical_feed_url' => $this->storage_format( 'ical_feed_url' ),
645
+ 'ical_source_url' => $this->storage_format( 'ical_source_url' ),
646
+ 'ical_uid' => $this->storage_format( 'ical_uid' ),
647
+ 'show_coordinates' => $this->storage_format( 'show_coordinates' ),
648
+ 'latitude' => $this->storage_format( 'latitude', '' ),
649
+ 'longitude' => $this->storage_format( 'longitude', '' ),
650
+ );
651
+ return $entity;
652
+ }
653
+
654
+ /**
655
+ * Compact field for writing to persistent storage.
656
+ *
657
+ * @param string $field Name of field to compact.
658
+ * @param mixed $default Default value to use for undescribed fields.
659
+ *
660
+ * @return mixed Value or $default.
661
+ */
662
+ public function storage_format( $field, $default = null ) {
663
+ $value = $this->_entity->get( $field, $default );
664
+ if (
665
+ isset( $this->_swizzable[$field] ) &&
666
+ $this->_swizzable[$field] <= 0
667
+ ) {
668
+ $value = $this->{ '_handle_property_destruct_' . $field }( $value );
669
+ }
670
+ return $value;
671
+ }
672
+
673
+ /**
674
+ * Decode timezone to use for event.
675
+ *
676
+ * Following algorythm is used to detect a value:
677
+ * - take value provided in input;
678
+ * - if empty - take value associated with start time;
679
+ * - if empty - take current environment timezone.
680
+ *
681
+ * @param string $timezone_name Timezone provided in input.
682
+ *
683
+ * @return string Timezone name to use for event in future.
684
+ */
685
+ protected function _handle_property_destruct_timezone_name(
686
+ $timezone_name
687
+ ) {
688
+ if ( empty( $timezone_name ) ) {
689
+ $timezone_name = $this->get( 'start' )->get_timezone();
690
+ if ( empty( $timezone_name ) ) {
691
+ $timezone_name = $this->_registry->get( 'date.timezone' )
692
+ ->get_default_timezone();
693
+ }
694
+ }
695
+ return $timezone_name;
696
+ }
697
+
698
+ /**
699
+ * Store `Ticket URL` in non-loggable form
700
+ *
701
+ * @param string $ticket_url URL for buying tickets.
702
+ *
703
+ * @return string Non loggable URL
704
+ */
705
+ protected function _handle_property_destruct_ticket_url( $ticket_url ) {
706
+ return $this->get_nonloggable_url( $ticket_url );
707
+ }
708
+
709
+ /**
710
+ * Format datetime to UNIX timestamp for storage.
711
+ *
712
+ * @param Ai1ec_Date_Time $start Datetime object to compact.
713
+ *
714
+ * @return int UNIX timestamp.
715
+ */
716
+ protected function _handle_property_destruct_start( Ai1ec_Date_Time $start ) {
717
+ return $start->format_to_gmt();
718
+ }
719
+
720
+ /**
721
+ * Format datetime to UNIX timestamp for storage.
722
+ *
723
+ * @param Ai1ec_Date_Time $end Datetime object to compact.
724
+ *
725
+ * @return int UNIX timestamp.
726
+ */
727
+ protected function _handle_property_destruct_end( Ai1ec_Date_Time $end ) {
728
+ return $end->format_to_gmt();
729
+ }
730
+
731
+ /**
732
+ * Store `Contact URL` in non-loggable form.
733
+ *
734
+ * @param string $contact_url URL for contact details.
735
+ *
736
+ * @return string Non loggable URL.
737
+ */
738
+ protected function _handle_property_destruct_contact_url( $contact_url ) {
739
+ return $this->get_nonloggable_url( $contact_url );
740
+ }
741
+
742
+ /**
743
+ * Handle `cost` writing to permanent storage.
744
+ *
745
+ * @param string $cost Value of cost.
746
+ *
747
+ * @return string Serialized value to store.
748
+ */
749
+ protected function _handle_property_destruct_cost( $cost ) {
750
+ $cost = array(
751
+ 'cost' => $cost,
752
+ 'is_free' => false,
753
+ );
754
+ if ( $this->get( 'is_free' ) ) {
755
+ $cost['is_free'] = true;
756
+ }
757
+ return serialize( $cost );
758
+ }
759
+
760
+ }
app/model/event/creating.php ADDED
@@ -0,0 +1,195 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * Handles create/update operations.
5
+ *
6
+ * @author Time.ly Network Inc.
7
+ * @since 2.0
8
+ *
9
+ * @package AI1EC
10
+ * @subpackage AI1EC.Model
11
+ */
12
+ class Ai1ec_Event_Creating extends Ai1ec_Base {
13
+
14
+ /**
15
+ * Saves meta post data.
16
+ *
17
+ * @wp_hook save_post
18
+ *
19
+ * @param int $post_id Post ID.
20
+ * @param object $post Post object.
21
+ *
22
+ * @return object|null Saved Ai1ec_Event object if successful or null.
23
+ */
24
+ public function save_post( $post_id, $post ) {
25
+ // verify this came from the our screen and with proper authorization,
26
+ // because save_post can be triggered at other times
27
+ if (
28
+ ! isset( $_POST[AI1EC_POST_TYPE] ) ||
29
+ ! wp_verify_nonce( $_POST[AI1EC_POST_TYPE], 'ai1ec' )
30
+ ) {
31
+ return null;
32
+ }
33
+
34
+ if (
35
+ isset( $post->post_status ) &&
36
+ 'auto-draft' === $post->post_status
37
+ ) {
38
+ return null;
39
+ }
40
+
41
+ // verify if this is not inline-editing
42
+ if (
43
+ isset( $_REQUEST['action'] ) &&
44
+ 'inline-save' === $_REQUEST['action']
45
+ ) {
46
+ return null;
47
+ }
48
+
49
+ // verify that the post_type is that of an event
50
+ if ( ! $this->_registry->get( 'acl.aco' )->is_our_post_type( $post ) ) {
51
+ return null;
52
+ }
53
+
54
+ /**
55
+ * =====================================================================
56
+ *
57
+ * CHANGE CODE BELLOW TO HAVE FOLLOWING PROPERTIES:
58
+ * - be initializiable from model;
59
+ * - have sane defaults;
60
+ * - avoid that cluster of isset and ternary operator.
61
+ *
62
+ * =====================================================================
63
+ */
64
+
65
+ // LABEL:magicquotes
66
+ // remove WordPress `magical` slashes - we work around it ourselves
67
+ $_POST = stripslashes_deep( $_POST );
68
+
69
+ $all_day = isset( $_POST['ai1ec_all_day_event'] ) ? 1 : 0;
70
+ $instant_event = isset( $_POST['ai1ec_instant_event'] ) ? 1 : 0;
71
+ $timezone_name = isset( $_POST['ai1ec_timezone_name'] ) ? $_POST['ai1ec_timezone_name'] : 'sys.default';
72
+ $start_time = isset( $_POST['ai1ec_start_time'] ) ? $_POST['ai1ec_start_time'] : '';
73
+ $end_time = isset( $_POST['ai1ec_end_time'] ) ? $_POST['ai1ec_end_time'] : '';
74
+ $venue = isset( $_POST['ai1ec_venue'] ) ? $_POST['ai1ec_venue'] : '';
75
+ $address = isset( $_POST['ai1ec_address'] ) ? $_POST['ai1ec_address'] : '';
76
+ $city = isset( $_POST['ai1ec_city'] ) ? $_POST['ai1ec_city'] : '';
77
+ $province = isset( $_POST['ai1ec_province'] ) ? $_POST['ai1ec_province'] : '';
78
+ $postal_code = isset( $_POST['ai1ec_postal_code'] ) ? $_POST['ai1ec_postal_code'] : '';
79
+ $country = isset( $_POST['ai1ec_country'] ) ? $_POST['ai1ec_country'] : '';
80
+ $google_map = isset( $_POST['ai1ec_google_map'] ) ? 1 : 0;
81
+ $cost = isset( $_POST['ai1ec_cost'] ) ? $_POST['ai1ec_cost'] : '';
82
+ $is_free = isset( $_POST['ai1ec_is_free'] ) ? (bool)$_POST['ai1ec_is_free'] : false;
83
+ $ticket_url = isset( $_POST['ai1ec_ticket_url'] ) ? $_POST['ai1ec_ticket_url'] : '';
84
+ $contact_name = isset( $_POST['ai1ec_contact_name'] ) ? $_POST['ai1ec_contact_name'] : '';
85
+ $contact_phone = isset( $_POST['ai1ec_contact_phone'] ) ? $_POST['ai1ec_contact_phone'] : '';
86
+ $contact_email = isset( $_POST['ai1ec_contact_email'] ) ? $_POST['ai1ec_contact_email'] : '';
87
+ $contact_url = isset( $_POST['ai1ec_contact_url'] ) ? $_POST['ai1ec_contact_url'] : '';
88
+ $show_coordinates = isset( $_POST['ai1ec_input_coordinates'] )? 1 : 0;
89
+ $longitude = isset( $_POST['ai1ec_longitude'] ) ? $_POST['ai1ec_longitude'] : '';
90
+ $latitude = isset( $_POST['ai1ec_latitude'] ) ? $_POST['ai1ec_latitude'] : '';
91
+
92
+ $rrule = NULL;
93
+ $exrule = NULL;
94
+ $exdate = NULL;
95
+
96
+ // if rrule is set, convert it from local to UTC time
97
+ if (
98
+ isset( $_POST['ai1ec_repeat'] ) &&
99
+ ! empty( $_POST['ai1ec_repeat'] )
100
+ ) {
101
+ $rrule = $_POST['ai1ec_rrule'];
102
+ }
103
+
104
+ // if exrule is set, convert it from local to UTC time
105
+ if (
106
+ isset( $_POST['ai1ec_exclude'] ) &&
107
+ ! empty( $_POST['ai1ec_exclude'] ) &&
108
+ NULL !== $rrule // no point for exclusion, if repetition is not set
109
+ ) {
110
+ $exrule = $this->_registry->get( 'recurrence.rule' )->merge_exrule(
111
+ $_POST['ai1ec_exrule'],
112
+ $_POST['ai1ec_rrule']
113
+ );
114
+ }
115
+ // if exdate is set, convert it from local to UTC time
116
+ if (
117
+ isset( $_POST['ai1ec_exdate'] ) &&
118
+ ! empty( $_POST['ai1ec_exdate'] )
119
+ ) {
120
+ $exdate = $_POST['ai1ec_exdate'];
121
+ }
122
+
123
+ $is_new = false;
124
+ $event = null;
125
+ try {
126
+ $event = $this->_registry->get(
127
+ 'model.event',
128
+ $post_id ? $post_id : null
129
+ );
130
+ } catch ( Ai1ec_Event_Not_Found_Exception $excpt ) {
131
+ // Post exists, but event data hasn't been saved yet. Create new event
132
+ // object.
133
+ $is_new = true;
134
+ $event = $this->_registry->get( 'model.event' );
135
+ }
136
+
137
+ $start_time_entry = $this->_registry
138
+ ->get( 'date.time', $start_time, $timezone_name );
139
+ $end_time_entry = $this->_registry
140
+ ->get( 'date.time', $end_time, $timezone_name );
141
+ // If the events is marked as instant, make it last 30 minutes
142
+ if ( $instant_event ) {
143
+ $end_time_entry = $this->_registry
144
+ ->get( 'date.time', $start_time, $timezone_name );
145
+ $end_time_entry->set_time(
146
+ $end_time_entry->format( 'H' ),
147
+ $end_time_entry->format( 'i' ) + 30,
148
+ $end_time_entry->format( 's' )
149
+ );
150
+ }
151
+ $timezone_name = $start_time_entry->get_timezone();
152
+ if ( null === $timezone_name ) {
153
+ $timezone_name = $start_time_entry->get_default_format_timezone();
154
+ }
155
+
156
+ $event->set( 'post_id', $post_id );
157
+ $event->set( 'start', $start_time_entry );
158
+ $event->set( 'end', $end_time_entry );
159
+ $event->set( 'timezone_name', $timezone_name );
160
+ $event->set( 'allday', $all_day );
161
+ $event->set( 'instant_event', $instant_event );
162
+ $event->set( 'venue', $venue );
163
+ $event->set( 'address', $address );
164
+ $event->set( 'city', $city );
165
+ $event->set( 'province', $province );
166
+ $event->set( 'postal_code', $postal_code );
167
+ $event->set( 'country', $country );
168
+ $event->set( 'show_map', $google_map );
169
+ $event->set( 'cost', $cost );
170
+ $event->set( 'is_free', $is_free );
171
+ $event->set( 'ticket_url', $ticket_url );
172
+ $event->set( 'contact_name', $contact_name );
173
+ $event->set( 'contact_phone', $contact_phone );
174
+ $event->set( 'contact_email', $contact_email );
175
+ $event->set( 'contact_url', $contact_url );
176
+ $event->set( 'recurrence_rules', $rrule );
177
+ $event->set( 'exception_rules', $exrule );
178
+ $event->set( 'exception_dates', $exdate );
179
+ $event->set( 'show_coordinates', $show_coordinates );
180
+ $event->set( 'longitude', trim( $longitude ) );
181
+ $event->set( 'latitude', trim( $latitude ) );
182
+
183
+ // let other extensions save their fields.
184
+ do_action( 'ai1ec_save_post', $event );
185
+
186
+ $event->save( ! $is_new );
187
+
188
+
189
+ // LABEL:magicquotes
190
+ // restore `magic` WordPress quotes to maintain compatibility
191
+ $_POST = add_magic_quotes( $_POST );
192
+ return $event;
193
+ }
194
+
195
+ }
app/model/event/entity.php ADDED
@@ -0,0 +1,331 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * Event internal structure representation. Plain value object.
5
+ *
6
+ * @author Time.ly Network, Inc.
7
+ * @since 2.0
8
+ * @instantiator new
9
+ * @package Ai1EC
10
+ * @subpackage Ai1EC.Model
11
+ */
12
+ class Ai1ec_Event_Entity extends Ai1ec_Base {
13
+
14
+ /**
15
+ * Get list of object properties.
16
+ *
17
+ * Special value `registry` ({@see Ai1ec_Registry_Object}) is excluded.
18
+ *
19
+ * @return array List of accessible properties.
20
+ *
21
+ * @staticvar array $known List of properties.
22
+ */
23
+ public function list_properties() {
24
+ static $known = null;
25
+ if ( null === $known ) {
26
+ $known = array();
27
+ foreach ( $this as $name => $value ) {
28
+ $name = substr( $name, 1 );
29
+ if ( 'registry' === $name ) {
30
+ continue;
31
+ }
32
+ $known[] = $name;
33
+ }
34
+ }
35
+ return $known;
36
+ }
37
+
38
+ /**
39
+ * Change stored property.
40
+ *
41
+ * @param string $name Name of property to change.
42
+ * @param mixed $value Arbitrary value to use.
43
+ *
44
+ * @return Ai1ec_Event_Entity Instance of self for chaining.
45
+ *
46
+ * @staticvar array $time_fields Map of fields holding a value of
47
+ * {@see Ai1ec_Date_Time}, which
48
+ * require modification instead of
49
+ * replacement.
50
+ */
51
+ public function set( $name, $value ) {
52
+ static $time_fields = array(
53
+ 'start' => true,
54
+ 'end' => true,
55
+ );
56
+ if ( 'registry' === $name ) {
57
+ return $this; // short-circuit: protection mean.
58
+ }
59
+ $field = '_' . $name;
60
+ if ( isset( $time_fields[$name] ) ) {
61
+ // object of Ai1ec_Date_Time type is now handled in it itself
62
+ $this->{$field}->set_date_time(
63
+ $value,
64
+ ( null === $this->_timezone_name )
65
+ ? 'UTC'
66
+ : $this->_timezone_name
67
+ );
68
+ } else {
69
+ $this->{$field} = $value;
70
+ }
71
+ if ( 'timezone_name' === $name && ! empty( $value ) ) {
72
+ $this->_start->set_timezone( $value );
73
+ $this->_end ->set_timezone( $value );
74
+ }
75
+ return $this;
76
+ }
77
+
78
+ /**
79
+ * Set preferred timezone to datetime fields.
80
+ *
81
+ * @param DateTimeZone $timezone Preferred timezone instance.
82
+ *
83
+ * @return void
84
+ */
85
+ public function set_preferred_timezone( DateTimeZone $timezone ) {
86
+ $this->_start->set_preferred_timezone( $timezone );
87
+ $this->_end ->set_preferred_timezone( $timezone );
88
+ }
89
+
90
+ /**
91
+ * Get a value of some property.
92
+ *
93
+ * @param string $name Name of property to get.
94
+ * @param mixed $default Value to return if property is not defined.
95
+ *
96
+ * @return mixed Found value or $default.
97
+ */
98
+ public function get( $name, $default = null ) {
99
+ if ( ! isset( $this->{ '_' . $name } ) ) {
100
+ return $default;
101
+ }
102
+ return $this->{ '_' . $name };
103
+ }
104
+
105
+ /**
106
+ * Initialize values to some sane defaults.
107
+ *
108
+ * @param Ai1ec_Registry_Object $registry Injected registry.
109
+ *
110
+ * @return void
111
+ */
112
+ public function __construct( Ai1ec_Registry_Object $registry ) {
113
+ parent::__construct( $registry );
114
+ $this->_start = $this->_registry->get( 'date.time' );
115
+ $this->_end = $this->_registry->get( 'date.time', '+1 hour' );
116
+ }
117
+
118
+ /**
119
+ * @var object Instance of WP_Post object.
120
+ */
121
+ private $_post;
122
+
123
+ /**
124
+ * @var int Post ID.
125
+ */
126
+ private $_post_id;
127
+
128
+ /**
129
+ * @var int|null Uniquely identifies the recurrence instance of this event
130
+ * object. Value may be null.
131
+ */
132
+ private $_instance_id;
133
+
134
+ /**
135
+ * @var string Name of timezone to use for event times.
136
+ */
137
+ private $_timezone_name;
138
+
139
+ /**
140
+ * @var Ai1ec_Date_Time Start date-time specifier
141
+ */
142
+ private $_start;
143
+
144
+ /**
145
+ * @var Ai1ec_Date_Time End date-time specifier
146
+ */
147
+ private $_end;
148
+
149
+ /**
150
+ * @var bool Whether this copy of the event was broken up for rendering and
151
+ * the start time is not its "real" start time.
152
+ */
153
+ private $_start_truncated;
154
+
155
+ /**
156
+ * @var bool Whether this copy of the event was broken up for rendering and
157
+ * the end time is not its "real" end time.
158
+ */
159
+ private $_end_truncated;
160
+
161
+ /**
162
+ * @var int If event is all-day long
163
+ */
164
+ private $_allday;
165
+
166
+ /**
167
+ * @var int If event has no duration
168
+ */
169
+ private $_instant_event;
170
+
171
+ /**
172
+ * ==========================
173
+ * = Recurrence information =
174
+ * ==========================
175
+ */
176
+
177
+ /**
178
+ * @var string Recurrence rules
179
+ */
180
+ private $_recurrence_rules;
181
+
182
+ /**
183
+ * @var string Exception rules
184
+ */
185
+ private $_exception_rules;
186
+
187
+ /**
188
+ * @var string Recurrence dates
189
+ */
190
+ private $_recurrence_dates;
191
+
192
+ /**
193
+ * @var string Exception dates
194
+ */
195
+ private $_exception_dates;
196
+
197
+ /**
198
+ * @var string Venue name - free text
199
+ */
200
+ private $_venue;
201
+
202
+ /**
203
+ * @var string Country name - free text
204
+ */
205
+ private $_country;
206
+
207
+ /**
208
+ * @var string Address information - free text
209
+ */
210
+ private $_address;
211
+
212
+ /**
213
+ * @var string City name - free text
214
+ */
215
+ private $_city;
216
+
217
+ /**
218
+ * @var string Province free text definition
219
+ */
220
+ private $_province;
221
+
222
+ /**
223
+ * @var int Postal code
224
+ */
225
+ private $_postal_code;
226
+
227
+ /**
228
+ * @var int Set to true to display map
229
+ */
230
+ private $_show_map;
231
+
232
+ /**
233
+ * @var int Set to true to show coordinates in description
234
+ */
235
+ private $_show_coordinates;
236
+
237
+ /**
238
+ * @var float GEO information - longitude
239
+ */
240
+ private $_longitude;
241
+
242
+ /**
243
+ * @var float GEO information - latitude
244
+ */
245
+ private $_latitude;
246
+
247
+ /**
248
+ * @var string Event contact information - contact person
249
+ */
250
+ private $_contact_name;
251
+
252
+ /**
253
+ * @var string Event contact information - phone number
254
+ */
255
+ private $_contact_phone;
256
+
257
+ /**
258
+ * @var string Event contact information - email address
259
+ */
260
+ private $_contact_email;
261
+
262
+ /**
263
+ * @var string Event contact information - external URL.
264
+ */
265
+ private $_contact_url;
266
+
267
+ /**
268
+ * @var string Defines event cost.
269
+ */
270
+ private $_cost;
271
+
272
+ /**
273
+ * @var bool Indicates, whereas event is free.
274
+ */
275
+ private $_is_free;
276
+
277
+ /**
278
+ * @var string Link to buy tickets
279
+ */
280
+ private $_ticket_url;
281
+
282
+ // ====================================
283
+ // = iCalendar feed (.ics) properties =
284
+ // ====================================
285
+
286
+ /**
287
+ * @var string URI of source ICAL feed.
288
+ */
289
+ private $_ical_feed_url;
290
+
291
+ /**
292
+ * @var string|null URI of source ICAL entity.
293
+ */
294
+ private $_ical_source_url;
295
+
296
+ /**
297
+ * @var string Organiser details
298
+ */
299
+ private $_ical_organizer;
300
+
301
+ /**
302
+ * @var string Contact details
303
+ */
304
+ private $_ical_contact;
305
+
306
+ /**
307
+ * @var string|int UID of ICAL feed
308
+ */
309
+ private $_ical_uid;
310
+
311
+ // ===============================
312
+ // = taxonomy-related properties =
313
+ // ===============================
314
+
315
+ /**
316
+ * @var string Associated event tag names (*not* IDs), joined by commas.
317
+ */
318
+ private $_tags;
319
+
320
+ /**
321
+ * @var string Associated event category IDs, joined by commas.
322
+ */
323
+ private $_categories;
324
+
325
+ /**
326
+ * @var string Associated event feed object
327
+ */
328
+ private $_feed;
329
+
330
+
331
+ }
app/model/event/instance.php ADDED
@@ -0,0 +1,296 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * Event instance management model.
5
+ *
6
+ *
7
+ * @author Time.ly Network, Inc.
8
+ * @since 2.0
9
+ * @package Ai1EC
10
+ * @subpackage Ai1EC.Model
11
+ */
12
+ class Ai1ec_Event_Instance extends Ai1ec_Base {
13
+
14
+ /**
15
+ * @var Ai1ec_Dbi Instance of database abstraction.
16
+ */
17
+ protected $_dbi = null;
18
+
19
+ /**
20
+ * Store locally instance of Ai1ec_Dbi.
21
+ *
22
+ * @param Ai1ec_Registry_Object $registry Injected object registry.
23
+ *
24
+ * @return void
25
+ */
26
+ public function __construct( Ai1ec_Registry_Object $registry ) {
27
+ parent::__construct( $registry );
28
+ $this->_dbi = $this->_registry->get( 'dbi.dbi' );
29
+ }
30
+
31
+ /**
32
+ * Remove entries for given post. Optionally delete particular instance.
33
+ *
34
+ * @param int $post_id Event ID to remove instances for.
35
+ * @param int|null $instance_id Instance ID, or null for all.
36
+ *
37
+ * @return int|bool Number of entries removed, or false on failure.
38
+ */
39
+ public function clean( $post_id, $instance_id = null ) {
40
+ $where = array( 'post_id' => $post_id );
41
+ $format = array( '%d' );
42
+ if ( null !== $instance_id ) {
43
+ $where['instance_id'] = $instance_id;
44
+ $format[] = '%d';
45
+ }
46
+ return $this->_dbi->delete( 'ai1ec_event_instances', $where, $format );
47
+ }
48
+
49
+ /**
50
+ * Remove and then create instance entries for given event.
51
+ *
52
+ * @param Ai1ec_Event $event Instance of event to recreate entries for.
53
+ *
54
+ * @return bool Success.
55
+ */
56
+ public function recreate( Ai1ec_Event $event ) {
57
+ $this->clean( $event->get( 'post_id' ) );
58
+ return ( false !== $this->create( $event ) );
59
+ }
60
+
61
+ /**
62
+ * Create list of recurrent instances.
63
+ *
64
+ * @param Ai1ec_Event $event Event to generate instances for.
65
+ * @param array $event_instance First instance contents.
66
+ * @param int $_start Timestamp of first occurence.
67
+ * @param int $tif Timestamp of last occurence.
68
+ * @param int $duration Event duration in seconds.
69
+ * @param string $timezone Target timezone.
70
+ *
71
+ * @return array List of event instances.
72
+ */
73
+ public function create_instances_by_recurrence(
74
+ Ai1ec_Event $event,
75
+ array $event_instance,
76
+ $_start,
77
+ $tif,
78
+ $duration,
79
+ $timezone
80
+ ) {
81
+ $recurrence_parser = $this->_registry->get( 'recurrence.rule' );
82
+ $evs = array();
83
+
84
+ $startdate = array(
85
+ 'timestamp' => $_start,
86
+ 'tz' => $timezone,
87
+ );
88
+ $enddate = array(
89
+ 'timestamp' => $tif,
90
+ 'tz' => $timezone,
91
+ );
92
+ $start = $event_instance['start'];
93
+ $wdate = $startdate
94
+ = iCalUtilityFunctions::_timestamp2date( $startdate, 6 );
95
+ $enddate = iCalUtilityFunctions::_timestamp2date( $enddate, 6 );
96
+ $exclude_dates = array();
97
+ $recurrence_dates = array();
98
+ if ( $event->get( 'exception_rules' ) ) {
99
+ // creat an array for the rules
100
+ $exception_rules = $recurrence_parser
101
+ ->build_recurrence_rules_array(
102
+ $event->get( 'exception_rules' )
103
+ );
104
+ $exception_rules = iCalUtilityFunctions::_setRexrule(
105
+ $exception_rules
106
+ );
107
+ $result = array();
108
+ // The first array is the result and it is passed by reference
109
+ iCalUtilityFunctions::_recur2date(
110
+ $exclude_dates,
111
+ $exception_rules,
112
+ $wdate,
113
+ $startdate,
114
+ $enddate
115
+ );
116
+ }
117
+ $recurrence_rules = $recurrence_parser
118
+ ->build_recurrence_rules_array(
119
+ $event->get( 'recurrence_rules' )
120
+ );
121
+ $recurrence_rules = iCalUtilityFunctions::_setRexrule( $recurrence_rules );
122
+ iCalUtilityFunctions::_recur2date(
123
+ $recurrence_dates,
124
+ $recurrence_rules,
125
+ $wdate,
126
+ $startdate,
127
+ $enddate
128
+ );
129
+ $recurrence_dates = array_keys( $recurrence_dates );
130
+ // Add the instances
131
+ foreach ( $recurrence_dates as $date ) {
132
+ // The arrays are in the form timestamp => true so an isset call is what we need
133
+ if ( isset( $exclude_dates[$date] ) ) {
134
+ continue;
135
+ }
136
+ $event_instance['start'] = $date;
137
+ $event_instance['end'] = $date + $duration;
138
+ $excluded = false;
139
+
140
+ // Check if exception dates match this occurence
141
+ if ( $exception_dates = $event->get( 'exception_dates' ) ) {
142
+ $match_exdates = $this->date_match_exdates(
143
+ $date,
144
+ $exception_dates,
145
+ $timezone
146
+ );
147
+ if ( $match_exdates ) {
148
+ $excluded = true;
149
+ }
150
+ }
151
+
152
+ // Add event only if it is not excluded
153
+ if ( false === $excluded ) {
154
+ $evs[] = $event_instance;
155
+ }
156
+ }
157
+ return $evs;
158
+ }
159
+
160
+ /**
161
+ * Generate and store instance entries in database for given event.
162
+ *
163
+ * @param Ai1ec_Event $event Instance of event to create entries for.
164
+ *
165
+ * @return bool Success.
166
+ */
167
+ public function create( Ai1ec_Event $event ) {
168
+ $evs = array();
169
+ $e = array(
170
+ 'post_id' => $event->get( 'post_id' ),
171
+ 'start' => $event->get( 'start' )->format_to_gmt(),
172
+ 'end' => $event->get( 'end' )->format_to_gmt(),
173
+ );
174
+ $duration = $event->get( 'end' )->diff_sec( $event->get( 'start' ) );
175
+
176
+ // Timestamp of today date + 3 years (94608000 seconds)
177
+ $tif = $this->_registry->get( 'date.system' )
178
+ ->current_time( true ) + 94608000;
179
+ // Always cache initial instance
180
+ $evs[] = $e;
181
+
182
+ $_start = $event->get( 'start' )->format_to_gmt();
183
+ $_end = $event->get( 'end' )->format_to_gmt();
184
+
185
+ if ( $event->get( 'recurrence_rules' ) ) {
186
+ $_restore_default_tz = date_default_timezone_get();
187
+ $start_timezone = $event->get( 'start' )->get_timezone();
188
+ date_default_timezone_set( $start_timezone );
189
+ $evs = array_merge(
190
+ $evs,
191
+ $this->create_instances_by_recurrence(
192
+ $event,
193
+ $e,
194
+ $_start,
195
+ $tif,
196
+ $duration,
197
+ $start_timezone
198
+ )
199
+ );
200
+ date_default_timezone_set( $_restore_default_tz );
201
+ unset( $_restore_default_tz );
202
+ }
203
+
204
+ // Make entries unique (sometimes recurrence generator creates duplicates?)
205
+ $evs_unique = array();
206
+ foreach ( $evs as $ev ) {
207
+ $evs_unique[md5( serialize( $ev ) )] = $ev;
208
+ }
209
+
210
+ $search_helper = $this->_registry->get( 'model.search' );
211
+ foreach ( $evs_unique as $e ) {
212
+ // Find out if this event instance is already accounted for by an
213
+ // overriding 'RECURRENCE-ID' of the same iCalendar feed (by comparing the
214
+ // UID, start date, recurrence). If so, then do not create duplicate
215
+ // instance of event.
216
+ $start = $e['start'];
217
+ $matching_event_id = null;
218
+ if ( $event->get( 'ical_uid' ) ) {
219
+ $matching_event_id = $search_helper->get_matching_event_id(
220
+ $event->get( 'ical_uid' ),
221
+ $event->get( 'ical_feed_url' ),
222
+ $event->get( 'start' ),
223
+ false,
224
+ $event->get( 'post_id' )
225
+ );
226
+ }
227
+
228
+ // If no other instance was found
229
+ if ( null === $matching_event_id ) {
230
+ $this->_dbi->insert(
231
+ 'ai1ec_event_instances',
232
+ $e,
233
+ array( '%d', '%d', '%d' )
234
+ );
235
+ }
236
+ }
237
+
238
+ return true;
239
+ }
240
+
241
+ /**
242
+ * Check if given date match dates in EXDATES rule.
243
+ *
244
+ * @param string $date Date to check.
245
+ * @param string $ics_rule ICS EXDATES rule.
246
+ * @param string $timezone Timezone to evaluate value in.
247
+ *
248
+ * @return bool True if given date is in rule.
249
+ */
250
+ public function date_match_exdates( $date, $ics_rule, $timezone ) {
251
+ $ranges = $this->_get_date_ranges( $ics_rule, $timezone );
252
+ foreach ( $ranges as $interval ) {
253
+ if ( $date >= $interval[0] && $date <= $interval[1] ) {
254
+ return true;
255
+ }
256
+ if ( $date <= $interval[0] ) {
257
+ break;
258
+ }
259
+ }
260
+ return false;
261
+ }
262
+
263
+ /**
264
+ * Prepare date range list for fast exdate search.
265
+ *
266
+ * NOTICE: timezone is relevant in only first run.
267
+ *
268
+ * @param string $date_list ICS list provided from data model.
269
+ * @param string $timezone Timezone in which to evaluate.
270
+ *
271
+ * @return array List of date ranges, sorted in increasing order.
272
+ */
273
+ protected function _get_date_ranges( $date_list, $timezone ) {
274
+ static $ranges = array();
275
+ if ( ! isset( $ranges[$date_list] ) ) {
276
+ $ranges[$date_list] = array();
277
+ $exploded = explode( ',', $date_list );
278
+ sort( $exploded );
279
+ foreach ( $exploded as $date ) {
280
+ // COMMENT on `rtrim( $date, 'Z' )`:
281
+ // user selects exclusion date in event timezone thus it
282
+ // must be parsed as such as opposed to UTC which happen
283
+ // when 'Z' is preserved.
284
+ $date = $this->_registry
285
+ ->get( 'date.time', rtrim( $date, 'Z' ), $timezone )
286
+ ->format_to_gmt();
287
+ $ranges[$date_list][] = array(
288
+ $date,
289
+ $date + (24 * 60 * 60) - 1
290
+ );
291
+ }
292
+ }
293
+ return $ranges[$date_list];
294
+ }
295
+
296
+ }
app/model/event/invalid-argument-exception.php ADDED
@@ -0,0 +1,13 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * Some argument was of invalid type.
5
+ *
6
+ * @author Time.ly Network Inc.
7
+ * @since 2.0
8
+ *
9
+ * @package AI1EC
10
+ * @subpackage AI1EC.Model
11
+ */
12
+ class Ai1ec_Invalid_Argument_Exception extends Ai1ec_Exception {
13
+ }
app/model/event/legacy.php ADDED
@@ -0,0 +1,148 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * Model representing a legacy event.
5
+ *
6
+ * @author Time.ly Network, Inc.
7
+ * @since 2.0
8
+ * @instantiator new
9
+ * @package Ai1EC
10
+ * @subpackage Ai1EC.Model
11
+ */
12
+ class Ai1ec_Event_Legacy extends Ai1ec_Event {
13
+
14
+ /**
15
+ * @var array map of method => class for legacy code.
16
+ */
17
+ protected static $_classes = array(
18
+ 'get_category_colors' => 'taxonomy',
19
+ 'get_color_style' => 'taxonomy',
20
+ 'get_categories_html' => 'taxonomy',
21
+ 'get_tags_html' => 'taxonomy',
22
+ 'get_category_text_color' => 'taxonomy',
23
+ 'get_category_bg_color' => 'taxonomy',
24
+ 'get_faded_color' => 'color',
25
+ 'get_rgba_color' => 'color',
26
+ 'get_event_avatar' => 'avatar',
27
+ 'get_event_avatar_url' => 'avatar',
28
+ 'get_post_thumbnail_url' => 'avatar',
29
+ 'get_content_img_url' => 'avatar',
30
+ 'get_short_location' => 'location',
31
+ 'get_location' => 'location',
32
+ 'get_map_view' => 'location',
33
+ 'get_latlng' => 'location',
34
+ 'get_gmap_url' => 'location',
35
+ 'get_tickets_url_label' => 'ticket',
36
+ 'get_contact_html' => 'ticket',
37
+ 'get_timespan_html' => 'time',
38
+ 'get_exclude_html' => 'time',
39
+ 'get_back_to_calendar_button_html' => 'content',
40
+ 'get_post_excerpt' => 'content',
41
+ );
42
+
43
+ public function get_long_end_date( $adjust = 0 ) {
44
+ $time = $this->_registry->get( 'view.event.time' );
45
+ $end = $this->_registry->get( 'date.time', $this->get( 'end' ) );
46
+ if ( ! empty( $adjust ) ) {
47
+ $end->set_time(
48
+ $end->format( 'H' ),
49
+ $end->format( 'i' ),
50
+ $adjust
51
+ );
52
+ }
53
+ return $time->get_long_date( $end );
54
+ }
55
+
56
+ public function get_long_start_date() {
57
+ $time = $this->_registry->get( 'view.event.time' );
58
+ return $time->get_long_date( $this->get( 'start' ) );
59
+ }
60
+
61
+ public function get_multiday() {
62
+ return $this->is_multiday();
63
+ }
64
+
65
+ public function get_recurrence_html() {
66
+ $rrule = $this->_registry->get( 'recurrence.rule' );
67
+ return $rrule->rrule_to_text( $this->get( 'recurrence_rules' ) );
68
+ }
69
+
70
+ public function get_short_end_date() {
71
+ $time = $this->_registry->get( 'view.event.time' );
72
+ $end = $this->_registry->get( 'date.time', $this->get( 'end' ) );
73
+ $end->set_time(
74
+ $end->format( 'H' ),
75
+ $end->format( 'i' ),
76
+ -1
77
+ );
78
+ return $time->get_short_date( $end );
79
+ }
80
+
81
+ public function get_short_end_time() {
82
+ $time = $this->_registry->get( 'view.event.time' );
83
+ return $time->get_short_time( $this->get( 'end' ) );
84
+ }
85
+
86
+ public function get_short_start_date() {
87
+ $time = $this->_registry->get( 'view.event.time' );
88
+ return $time->get_short_date( $this->get( 'start' ) );
89
+ }
90
+
91
+ public function get_short_start_time() {
92
+ $time = $this->_registry->get( 'view.event.time' );
93
+ return $time->get_short_time( $this->get( 'start' ) );
94
+ }
95
+
96
+ /**
97
+ * Handles legacy property setters.
98
+ *
99
+ * @param string $property Name of property being set.
100
+ * @param mixed $value Value attempted to set.
101
+ *
102
+ * @return Ai1ec_Event Instance of self for chaining.
103
+ */
104
+ public function __set( $property, $value ) {
105
+ return $this->set( $property, $value );
106
+ }
107
+
108
+ /**
109
+ * Handle property accessors.
110
+ *
111
+ * @param string $name Property name
112
+ *
113
+ * @return mixed Property value
114
+ */
115
+ public function __get( $name ) {
116
+ $method = 'get_' . $name;
117
+ if ( method_exists( $this, $name ) ) {
118
+ return $this->{$method}();
119
+ }
120
+ return $this->get( $name );
121
+ }
122
+
123
+ /**
124
+ * Handle legacy methods calls.
125
+ *
126
+ * @param string $method Legacy method name.
127
+ * @param array $arguments Arguments passed to method.
128
+ *
129
+ * @return mixed
130
+ *
131
+ * @throws Ai1ec_Invalid_Argument_Exception If there is no method handler.
132
+ */
133
+ public function __call( $method, $arguments ) {
134
+ if ( ! isset( self::$_classes[$method] ) ) {
135
+ throw new Ai1ec_Invalid_Argument_Exception(
136
+ 'Requested method \'' . $method . '\' is unknown'
137
+ );
138
+ }
139
+ array_unshift( $arguments, $this );
140
+ $class = 'view.event.' . self::$_classes[$method];
141
+ return $this->_registry->dispatch(
142
+ $class,
143
+ $method,
144
+ $arguments
145
+ );
146
+ }
147
+
148
+ }
app/model/event/not-found-exception.php ADDED
@@ -0,0 +1,14 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * Event not found.
5
+ *
6
+ * @author Time.ly Network Inc.
7
+ * @since 2.0
8
+ *
9
+ * @package AI1EC
10
+ * @subpackage AI1EC.Model
11
+ */
12
+ class Ai1ec_Event_Not_Found_Exception extends Exception {
13
+
14
+ }
app/model/event/taxonomy.php ADDED
@@ -0,0 +1,145 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * Modal class representing an event or an event instance.
5
+ *
6
+ * @author Time.ly Network, Inc.
7
+ * @since 2.0
8
+ * @instantiator new
9
+ * @package Ai1EC
10
+ * @subpackage Ai1EC.Model
11
+ */
12
+ class Ai1ec_Event_Taxonomy {
13
+
14
+ /**
15
+ * @var string Name of categories taxonomy.
16
+ */
17
+ const CATEGORIES = 'events_categories';
18
+
19
+ /**
20
+ * @var string Name of tags taxonomy.
21
+ */
22
+ const TAGS = 'events_tags';
23
+
24
+ /**
25
+ * @var string Name of feeds taxonomy.
26
+ */
27
+ const FEEDS = 'events_feeds';
28
+
29
+ /**
30
+ * @var int ID of related post object
31
+ */
32
+ protected $_post_id = 0;
33
+
34
+ /**
35
+ * Store event ID in local variable.
36
+ *
37
+ * @param int $post_id ID of post being managed.
38
+ *
39
+ * @return void
40
+ */
41
+ public function __construct( $post_id = 0 ) {
42
+ $this->_post_id = (int)$post_id;
43
+ }
44
+
45
+ /**
46
+ * Get ID of term. Optionally create it if it doesn't exist.
47
+ *
48
+ * @param string $term Name of term to create.
49
+ * @param string $taxonomy Name of taxonomy to contain term within.
50
+ * @param bool $is_id Set to true if $term is ID.
51
+ * @param array $attrs Attributes to creatable entity.
52
+ *
53
+ * @return int|bool Created term ID or false on failure.
54
+ */
55
+ public function initiate_term(
56
+ $term,
57
+ $taxonomy,
58
+ $is_id = false,
59
+ array $attrs = array()
60
+ ) {
61
+ $field = ( $is_id ) ? 'id' : 'name';
62
+ $term_to_return = get_term_by( $field, $term, $taxonomy );
63
+ if ( false === $term_to_return ) {
64
+ $term_to_return = wp_insert_term( $term, $taxonomy, $attrs );
65
+ if ( is_wp_error( $term_to_return ) ) {
66
+ return false;
67
+ }
68
+ $term_to_return = (object)$term_to_return;
69
+ }
70
+ return (int)$term_to_return->term_id;
71
+ }
72
+
73
+ /**
74
+ * Wrapper for terms setting to post.
75
+ *
76
+ * @param array $terms List of terms to set.
77
+ * @param string $taxonomy Name of taxonomy to set terms to.
78
+ * @param bool $append When true post may have multiple same instances.
79
+ *
80
+ * @return bool Success.
81
+ */
82
+ public function set_terms( array $terms, $taxonomy, $append = false ) {
83
+ $result = wp_set_post_terms(
84
+ $this->_post_id,
85
+ $terms,
86
+ $taxonomy,
87
+ $append
88
+ );
89
+ if ( is_wp_error( $result ) ) {
90
+ return false;
91
+ }
92
+ return $result;
93
+ }
94
+
95
+ /**
96
+ * Update event categories.
97
+ *
98
+ * @param array $categories List of category IDs.
99
+ *
100
+ * @return bool Success.
101
+ */
102
+ public function set_categories( array $categories ) {
103
+ return $this->set_terms( $categories, self::CATEGORIES );
104
+ }
105
+
106
+ /**
107
+ * Update event tags.
108
+ *
109
+ * @param array $tags List of tag IDs.
110
+ *
111
+ * @return bool Success.
112
+ */
113
+ public function set_tags( array $tags ) {
114
+ return $this->set_terms( $tags, self::TAGS );
115
+ }
116
+
117
+ /**
118
+ * Update event feed description.
119
+ *
120
+ * @param object $feed Feed object.
121
+ *
122
+ * @return bool Success.
123
+ */
124
+ public function set_feed( $feed ) {
125
+ $feed_name = $feed->feed_url;
126
+ // If the feed is not from an imported file, parse the url.
127
+ if ( ! isset( $feed->feed_imported_file ) ) {
128
+ $url_components = parse_url( $feed->feed_url );
129
+ $feed_name = $url_components['host'];
130
+ }
131
+ $term_id = $this->initiate_term(
132
+ $feed_name,
133
+ self::FEEDS,
134
+ false,
135
+ array(
136
+ 'description' => $feed->feed_url,
137
+ )
138
+ );
139
+ if ( false === $term_id ) {
140
+ return false;
141
+ }
142
+ return $this->set_terms( array( $term_id ), self::FEEDS );
143
+ }
144
+
145
+ }
app/model/event/trashing.php ADDED
@@ -0,0 +1,87 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * Handles trash/delete operations.
5
+ *
6
+ * NOTICE: only operations on events entries themselve is handled.
7
+ * If plugins need some extra handling - they must bind to appropriate
8
+ * actions on their will.
9
+ *
10
+ * @author Time.ly Network Inc.
11
+ * @since 2.0
12
+ *
13
+ * @package AI1EC
14
+ * @subpackage AI1EC.Model
15
+ */
16
+ class Ai1ec_Event_Trashing extends Ai1ec_Base {
17
+
18
+ public function remove_childs( $post_id, $full_remove = false ) {
19
+ // to be filled when hierarchy is introduced
20
+ return true;
21
+ }
22
+
23
+ /**
24
+ * Handle post (event) trashing.
25
+ *
26
+ * @wp_hook trash_post
27
+ *
28
+ * @param int $post_id ID of post, which was trashed.
29
+ *
30
+ * @return bool Success.
31
+ */
32
+ public function trash( $post_id ) {
33
+ return $this->remove_childs( $post_id, false ) &&
34
+ $this->delete_cache( $post_id );
35
+ }
36
+
37
+ /**
38
+ * Handle post (event) untrashing.
39
+ *
40
+ * @wp_hook untrash_post
41
+ *
42
+ * @param int $post_id ID of post, which was untrashed.
43
+ *
44
+ * @return bool Success.
45
+ */
46
+ public function untrash( $post_id ) {
47
+ // to be filled when hierarchy is introduced
48
+ return true;
49
+ }
50
+
51
+ /**
52
+ * Handle post (event) deletion.
53
+ *
54
+ * Executed before post is deleted, but after meta is removed.
55
+ *
56
+ * @wp_hook delete_post
57
+ *
58
+ * @param int $post_id ID of post, which was trashed.
59
+ *
60
+ * @return bool Success.
61
+ */
62
+ public function delete( $post_id ) {
63
+ $post_id = (int)$post_id;
64
+ $where = array( 'post_id' => (int)$post_id );
65
+ $format = array( '%d' );
66
+ $dbi = $this->_registry->get( 'dbi.dbi' );
67
+ $success = $this->remove_childs( $post_id, true );
68
+ $success &= $dbi->delete( 'ai1ec_events', $where, $format );
69
+ $success &= $dbi->delete( 'ai1ec_event_instances', $where, $format );
70
+ unset( $where, $dbi );
71
+ return $success && $this->delete_cache( $post_id );
72
+ }
73
+
74
+ /**
75
+ * Remove the cache for a specific event
76
+ *
77
+ * @param $event_id
78
+ * @internal param $event_id
79
+ *
80
+ * @return boolean
81
+ */
82
+ public function delete_cache( $event_id ) {
83
+ // to be added with cache introduction
84
+ return true;
85
+ }
86
+
87
+ }
app/model/filter/auth_ids.php ADDED
@@ -0,0 +1,18 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * Authors filtering implementation.
5
+ *
6
+ * @instantiator new
7
+ * @author Time.ly Network Inc.
8
+ * @since 2.0
9
+ * @package AI1EC
10
+ * @subpackage AI1EC.Filter
11
+ */
12
+ class Ai1ec_Filter_Authors extends Ai1ec_Filter_Int {
13
+
14
+ public function get_field() {
15
+ return 'p.post_author';
16
+ }
17
+
18
+ }
app/model/filter/cat_ids.php ADDED
@@ -0,0 +1,18 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * Categories filtering implementation.
5
+ *
6
+ * @instantiator new
7
+ * @author Time.ly Network Inc.
8
+ * @since 2.0
9
+ * @package AI1EC
10
+ * @subpackage AI1EC.Filter
11
+ */
12
+ class Ai1ec_Filter_Categories extends Ai1ec_Filter_Taxonomy {
13
+
14
+ public function get_taxonomy() {
15
+ return 'events_categories';
16
+ }
17
+
18
+ }
app/model/filter/int.php ADDED
@@ -0,0 +1,75 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * Base class for integers-based filters.
5
+ *
6
+ * @author Time.ly Network Inc.
7
+ * @since 2.0
8
+ *
9
+ * @package AI1EC
10
+ * @subpackage AI1EC.Filter
11
+ */
12
+ abstract class Ai1ec_Filter_Int implements Ai1ec_Filter_Interface {
13
+
14
+ /**
15
+ * @var Ai1ec_Registry_Object Injected object registry.
16
+ */
17
+ protected $_registry = null;
18
+
19
+ /**
20
+ * @var array Sanitized input values with only positive integers kept.
21
+ */
22
+ protected $_values = array();
23
+
24
+ /**
25
+ * Sanitize input values upon construction.
26
+ *
27
+ * @param Ai1ec_Registry_Object $registry Injected registry.
28
+ * @param array $filter_values Values to sanitize.
29
+ *
30
+ * @return void
31
+ */
32
+ public function __construct(
33
+ Ai1ec_Registry_Object $registry,
34
+ array $filter_values = array()
35
+ ) {
36
+ $this->_registry = $registry;
37
+ $this->_values = array_filter(
38
+ array_map(
39
+ array( $this->_registry->get( 'primitive.int' ), 'positive' ),
40
+ $filter_values
41
+ )
42
+ );
43
+ }
44
+
45
+ /**
46
+ * These simple filters does not require new joins.
47
+ *
48
+ * @return string Empty string is returned.
49
+ */
50
+ public function get_join() {
51
+ return '';
52
+ }
53
+
54
+ /**
55
+ * Get condition part of query for single field.
56
+ *
57
+ * @param string $inner_operator Inner logics to use. It is ignored.
58
+ *
59
+ * @return string Conditional snippet for query.
60
+ */
61
+ public function get_where( $inner_operator = null ) {
62
+ if ( empty( $this->_values ) ) {
63
+ return '';
64
+ }
65
+ return $this->get_field() . ' IN ( ' . join( ',', $this->_values ) . ' )';
66
+ }
67
+
68
+ /**
69
+ * Require ancestors to override this to build correct conditional snippet.
70
+ *
71
+ * @return string Column alias to use in condition.
72
+ */
73
+ abstract public function get_field();
74
+
75
+ }
app/model/filter/interface.php ADDED
@@ -0,0 +1,44 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * Filter provider interface.
5
+ *
6
+ * @author Time.ly Network Inc.
7
+ * @since 2.0
8
+ *
9
+ * @package AI1EC
10
+ * @subpackage AI1EC.Filter
11
+ */
12
+ interface Ai1ec_Filter_Interface {
13
+
14
+ /**
15
+ * Store user-input locally.
16
+ *
17
+ * @param Ai1ec_Registry_Object $registry Injected registry.
18
+ * @param array $filter_values User provided input.
19
+ *
20
+ * @return void
21
+ */
22
+ public function __construct(
23
+ Ai1ec_Registry_Object $registry,
24
+ array $filter_values = array()
25
+ );
26
+
27
+ /**
28
+ * Return SQL snippet for `FROM` part.
29
+ *
30
+ * @return string Valid SQL snippet for `FROM` part.
31
+ */
32
+ public function get_join();
33
+
34
+ /**
35
+ * Return SQL snippet for `WHERE` part.
36
+ *
37
+ * Snippet should not be put in brackets - this will be performed
38
+ * in upper level.
39
+ *
40
+ * @return string Valid SQL snippet.
41
+ */
42
+ public function get_where();
43
+
44
+ }
app/model/filter/post_ids.php ADDED
@@ -0,0 +1,18 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * Posts (events) filtering implementation.
5
+ *
6
+ * @instantiator new
7
+ * @author Time.ly Network Inc.
8
+ * @since 2.0
9
+ * @package AI1EC
10
+ * @subpackage AI1EC.Filter
11
+ */
12
+ class Ai1ec_Filter_Posts extends Ai1ec_Filter_Int {
13
+
14
+ public function get_field() {
15
+ return 'e.post_id';
16
+ }
17
+
18
+ }
app/model/filter/tag_ids.php ADDED
@@ -0,0 +1,18 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * Tags filtering implementation.
5
+ *
6
+ * @instantiator new
7
+ * @author Time.ly Network Inc.
8
+ * @since 2.0
9
+ * @package AI1EC
10
+ * @subpackage AI1EC.Filter
11
+ */
12
+ class Ai1ec_Filter_Tags extends Ai1ec_Filter_Taxonomy {
13
+
14
+ public function get_taxonomy() {
15
+ return 'events_tags';
16
+ }
17
+
18
+ }
app/model/filter/taxonomy.php ADDED
@@ -0,0 +1,97 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * Base class for taxonomies filtering.
5
+ *
6
+ * @author Time.ly Network Inc.
7
+ * @since 2.0
8
+ *
9
+ * @package AI1EC
10
+ * @subpackage AI1EC.Filter
11
+ */
12
+ abstract class Ai1ec_Filter_Taxonomy extends Ai1ec_Filter_Int {
13
+
14
+ /**
15
+ * @var Ai1ec_Dbi Instance of database interface.
16
+ */
17
+ protected $_dbi = null;
18
+
19
+ /**
20
+ * Sanitize input values upon construction.
21
+ *
22
+ * @param Ai1ec_Registry_Object $registry Injected registry.
23
+ * @param array $filter_values Values to sanitize.
24
+ *
25
+ * @return void
26
+ */
27
+ public function __construct(
28
+ Ai1ec_Registry_Object $registry,
29
+ array $filter_values = array()
30
+ ) {
31
+ parent::__construct( $registry, $filter_values );
32
+ $this->_dbi = $this->_registry->get( 'dbi.dbi' );
33
+ }
34
+
35
+ /**
36
+ * Build SQL snippet for `FROM` particle.
37
+ *
38
+ * @return string Valid SQL snippet.
39
+ */
40
+ public function get_join() {
41
+ $sql_query = '
42
+ LEFT JOIN `{{RELATIONSHIPS_TABLE}}` AS `{{RELATIONSHIP_ALIAS}}`
43
+ ON ( `e` . `post_id` = `{{RELATIONSHIP_ALIAS}}` . `object_id` )
44
+ LEFT JOIN `{{TAXONOMY_TABLE}}` AS `{{TAXONOMY_ALIAS}}`
45
+ ON (
46
+ `{{RELATIONSHIP_ALIAS}}` . `term_taxonomy_id` =
47
+ `{{TAXONOMY_ALIAS}}` . `term_taxonomy_id`
48
+ AND `{{TAXONOMY_ALIAS}}` . taxonomy = {{TAXONOMY}}
49
+ )
50
+ ';
51
+ return str_replace(
52
+ array(
53
+ '{{RELATIONSHIPS_TABLE}}',
54
+ '{{RELATIONSHIP_ALIAS}}',
55
+ '{{TAXONOMY_TABLE}}',
56
+ '{{TAXONOMY_ALIAS}}',
57
+ '{{TAXONOMY}}',
58
+ ),
59
+ array(
60
+ $this->_dbi->get_table_name( 'term_relationships' ),
61
+ $this->_table_alias( 'term_relationships' ),
62
+ $this->_dbi->get_table_name( 'term_taxonomy' ),
63
+ $this->_table_alias( 'term_taxonomy' ),
64
+ '\'' . addslashes( $this->get_taxonomy() ) . '\'',
65
+ ),
66
+ $sql_query
67
+ );
68
+ }
69
+
70
+ /**
71
+ * Required by parent class. Using internal abstractions.
72
+ *
73
+ * @return string Field name to use in `WHERE` particle.
74
+ */
75
+ public function get_field() {
76
+ return $this->_table_alias( 'term_taxonomy' ) . '.term_id';
77
+ }
78
+
79
+ /**
80
+ * Return the qualified name for the taxonomy.
81
+ *
82
+ * @return string Valid taxonomy name (see `term_taxonomy` table).
83
+ */
84
+ abstract public function get_taxonomy();
85
+
86
+ /**
87
+ * Generate table alias given taxonomy.
88
+ *
89
+ * @param string $table Table to generate alias for.
90
+ *
91
+ * @return string Table alias.
92
+ */
93
+ protected function _table_alias( $table ) {
94
+ return $table . '_' . $this->get_taxonomy();
95
+ }
96
+
97
+ }
app/model/meta-post.php ADDED
@@ -0,0 +1,15 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * Post meta entries management.
5
+ *
6
+ * Meta entries management based on {@see Ai1ec_Meta} class.
7
+ *
8
+ * @author Time.ly Network, Inc.
9
+ * @since 2.0
10
+ * @package Ai1EC
11
+ * @subpackage Ai1EC.Model
12
+ */
13
+ class Ai1ec_Meta_Post extends Ai1ec_Meta {
14
+
15
+ }
app/model/meta-user.php ADDED
@@ -0,0 +1,96 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * User meta entries management.
5
+ *
6
+ * Meta entries management based on {@see Ai1ec_Meta} class.
7
+ *
8
+ * @author Time.ly Network, Inc.
9
+ * @since 2.0
10
+ * @package Ai1EC
11
+ * @subpackage Ai1EC.Model
12
+ */
13
+ class Ai1ec_Meta_User extends Ai1ec_Meta {
14
+
15
+ /**
16
+ * Get meta value for current user.
17
+ *
18
+ * @param string $meta_key Name of meta entry to get for current user.
19
+ * @param mixed $default Value to return if no entry found.
20
+ *
21
+ * @return mixed Current user's option or $default if none found.
22
+ */
23
+ public function get_current( $meta_key, $default = null ) {
24
+ $user_id = 0;
25
+ if ( is_callable( 'wp_get_current_user' ) ) {
26
+ $user = wp_get_current_user();
27
+ $user_id = (int)$user->ID;
28
+ unset( $user );
29
+ }
30
+ if ( $user_id <= 0 ) {
31
+ return $default;
32
+ }
33
+ return $this->get( $user_id, $meta_key, $default );
34
+ }
35
+
36
+ /**
37
+ * user_selected_tz method
38
+ *
39
+ * Get/set user selected (preferred) timezone.
40
+ * If only {@see $user_id} is provided - method acts as getter.
41
+ * Otherwise it acts as setter.
42
+ *
43
+ * @param int $user_id ID of user whose timezone is being checked/changed
44
+ * @param string $new_value New timezone string value to set user preferrence
45
+ * @param bool $force_update Set to true to force value update instead of add
46
+ *
47
+ * @return mixed Return value depends on activity:
48
+ * - [getter] string User preferred timezone name (might be empty string)
49
+ * - [setter] bool Success of preferrence change
50
+ */
51
+ public function user_selected_tz(
52
+ $user_id,
53
+ $new_value = NULL,
54
+ $force_update = false
55
+ ) {
56
+ $meta_key = 'ai1ec_timezone';
57
+ $user_id = (int)$user_id;
58
+ $old_value = $this->get(
59
+ $user_id,
60
+ $meta_key,
61
+ NULL,
62
+ true
63
+ );
64
+ if ( NULL !== $new_value ) {
65
+ if ( ! in_array( $new_value, timezone_identifiers_list() ) ) {
66
+ return false;
67
+ }
68
+ $success = false;
69
+ if ( true === $force_update || ! empty( $old_value ) ) {
70
+ $success = update_user_meta(
71
+ $user_id,
72
+ $meta_key,
73
+ $new_value,
74
+ $old_value
75
+ );
76
+ } else {
77
+ $success = add_user_meta(
78
+ $user_id,
79
+ $meta_key,
80
+ $new_value,
81
+ true
82
+ );
83
+ if ( false === $success ) {
84
+ return $this->user_selected_tz(
85
+ $user_id,
86
+ $new_value,
87
+ true
88
+ );
89
+ }
90
+ }
91
+ return $success;
92
+ }
93
+ return $old_value;
94
+ }
95
+
96
+ }
app/model/meta.php ADDED
@@ -0,0 +1,194 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * Abstract class for meta entries management.
5
+ *
6
+ * Via use of cache allows object-based access to meta entries.
7
+ *
8
+ * @author Time.ly Network, Inc.
9
+ * @since 2.0
10
+ * @package Ai1EC
11
+ * @subpackage Ai1EC.Model
12
+ */
13
+ abstract class Ai1ec_Meta extends Ai1ec_App {
14
+
15
+ /**
16
+ * @var string Name of base object for storage.
17
+ */
18
+ protected $_object = '';
19
+
20
+ /**
21
+ * @var Ai1ec_Cache_Memory In-memory cache operator.
22
+ */
23
+ protected $_cache = null;
24
+
25
+ /**
26
+ * Initialize instance-specific in-memory cache storage.
27
+ *
28
+ * @return void Method does not return.
29
+ */
30
+ protected function _initialize() {
31
+ $class = get_class( $this );
32
+ $this->_object = strtolower(
33
+ substr( $class, strlen( __CLASS__ ) + 1 )
34
+ );
35
+ $this->_cache = $this->_registry->get( 'cache.memory' );
36
+ }
37
+
38
+ /**
39
+ * Create new entry if it does not exist and cache provided value.
40
+ *
41
+ * @param string $object_id ID of object to store.
42
+ * @param string $key Key particle for ID to store.
43
+ * @param mixed $value Serializable value to store.
44
+ *
45
+ * @return bool Success.
46
+ */
47
+ final public function add( $object_id, $key, $value ) {
48
+ if ( ! $this->_add( $object_id, $key, $value ) ) {
49
+ return false;
50
+ }
51
+ $this->_cache->set( $this->_cache_key( $object_id, $key ), $value );
52
+ return true;
53
+ }
54
+
55
+ /**
56
+ * Update existing entry and cache it's value.
57
+ *
58
+ * @param string $object_id ID of object to store.
59
+ * @param string $key Key particle for ID to store.
60
+ * @param mixed $value Serializable value to store.
61
+ *
62
+ * @return bool Success.
63
+ */
64
+ final public function update( $object_id, $key, $value ) {
65
+ if ( ! $this->_update( $object_id, $key, $value ) ) {
66
+ return false;
67
+ }
68
+ $this->_cache->set( $this->_cache_key( $object_id, $key ), $value );
69
+ return true;
70
+ }
71
+
72
+ /**
73
+ * Get object value - from cache or actual store.
74
+ *
75
+ * @param string $object_id ID of object to get.
76
+ * @param string $key Key particle for ID to get.
77
+ * @param mixed $default Value to return if nothing found.
78
+ *
79
+ * @return mixed Value stored or {$default}.
80
+ */
81
+ final public function get( $object_id, $key, $default = null ) {
82
+ $cache_key = $this->_cache_key( $object_id, $key );
83
+ $value = $this->_cache->get( $cache_key, $default );
84
+ if ( $default === $value ) {
85
+ $value = $this->_get( $object_id, $key );
86
+ $this->_cache->set( $cache_key, $value );
87
+ }
88
+ return $value;
89
+ }
90
+
91
+ /**
92
+ * Create or update an entry cache new value.
93
+ *
94
+ * @param string $object_id ID of object to store.
95
+ * @param string $key Key particle for ID to store.
96
+ * @param mixed $value Serializable value to store.
97
+ *
98
+ * @return bool Success.
99
+ */
100
+ final public function set( $object_id, $key, $value ) {
101
+ if ( ! $this->get( $object_id, $key ) ) {
102
+ if ( ! $this->_add( $object_id, $key, $value ) ) {
103
+ return false;
104
+ }
105
+ } else {
106
+ if ( ! $this->_update( $object_id, $key, $value ) ) {
107
+ return false;
108
+ }
109
+ }
110
+ $this->_cache->set( $this->_cache_key( $object_id, $key ), $value );
111
+ return true;
112
+ }
113
+
114
+ /**
115
+ * Remove object entry based on ID and key.
116
+ *
117
+ * @param string $object_id ID of object to remove.
118
+ * @param string $key Key particle for ID to remove.
119
+ *
120
+ * @return bool Success.
121
+ */
122
+ final public function delete( $object_id, $key ) {
123
+ $this->_cache->delete( $this->_cache_key( $object_id, $key ) );
124
+ return $this->_delete( $object_id, $key );
125
+ }
126
+
127
+ /**
128
+ * Get object value from actual store.
129
+ *
130
+ * @param string $object_id ID of object to get.
131
+ * @param string $key Key particle for ID to get.
132
+ *
133
+ * @return mixed Value as found.
134
+ */
135
+ protected function _get( $object_id, $key ) {
136
+ $function = 'get_' . $this->_object . '_meta';
137
+ return $function( $object_id, $key, true );
138
+ }
139
+
140
+ /**
141
+ * Create new entry if it does not exist.
142
+ *
143
+ * @param string $object_id ID of object to store.
144
+ * @param string $key Key particle for ID to store.
145
+ * @param mixed $value Serializable value to store.
146
+ *
147
+ * @return bool Success.
148
+ */
149
+ protected function _add( $object_id, $key, $value ) {
150
+ $function = 'add_' . $this->_object . '_meta';
151
+ return $function( $object_id, $key, $value, true );
152
+ }
153
+
154
+ /**
155
+ * Update existing entry.
156
+ *
157
+ * @param string $object_id ID of object to store.
158
+ * @param string $key Key particle for ID to store.
159
+ * @param mixed $value Serializable value to store.
160
+ *
161
+ * @return bool Success.
162
+ */
163
+ protected function _update( $object_id, $key, $value ) {
164
+ $function = 'update_' . $this->_object . '_meta';
165
+ return $function( $object_id, $key, $value );
166
+ }
167
+
168
+ /**
169
+ * Remove object entry based on ID and key.
170
+ *
171
+ * @param string $object_id ID of object to remove.
172
+ * @param string $key Key particle for ID to remove.
173
+ *
174
+ * @return bool Success.
175
+ */
176
+ protected function _delete( $object_id, $key ) {
177
+ $function = 'delete_' . $this->_object . '_meta';
178
+ return $function( $object_id, $key );
179
+ }
180
+
181
+ /**
182
+ * Generate key for use with cache engine.
183
+ *
184
+ * @param string $object_id ID of object.
185
+ * @param string $key Key particle for ID.
186
+ *
187
+ * @return string Single identifier for given keys.
188
+ */
189
+ protected function _cache_key( $object_id, $key ) {
190
+ static $separator = "\0";
191
+ return $object_id . $separator . $key;
192
+ }
193
+
194
+ }
app/model/option.php ADDED
@@ -0,0 +1,117 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * Options management class.
5
+ *
6
+ * @author Time.ly Network, Inc.
7
+ * @since 2.0
8
+ * @package Ai1EC
9
+ * @subpackage Ai1EC.Model
10
+ */
11
+ class Ai1ec_Option extends Ai1ec_App {
12
+
13
+ /**
14
+ * @var Ai1ec_Cache_Memory In-memory cache storage engine for fast access.
15
+ */
16
+ protected $_cache = null;
17
+
18
+ /**
19
+ * @var Ai1ec_Registry_Object instance of the registry object.
20
+ */
21
+ protected $_registry;
22
+
23
+ /**
24
+ * Add cache instance to object scope.
25
+ *
26
+ * @return void
27
+ */
28
+ public function __construct( Ai1ec_Registry_Object $registry ) {
29
+ $this->_registry = $registry;
30
+ $this->_cache = $registry->get( 'cache.memory' );
31
+ }
32
+
33
+ /**
34
+ * Create an option if it does not exist.
35
+ *
36
+ * @param string $name Key to put value under.
37
+ * @param mixed $value Value to put to storage.
38
+ * @param bool $autoload Set to true to load on start.
39
+ *
40
+ * @return bool Success.
41
+ */
42
+ public function add( $name, $value, $autoload = false ) {
43
+ $autoload = $this->_parse_autoload( $autoload );
44
+ if ( ! add_option( $name, $value, '', $autoload ) ) {
45
+ return false;
46
+ }
47
+ $this->_cache->set( $name, $value );
48
+ return true;
49
+ }
50
+
51
+ /**
52
+ * Create an option if it does not exist, or update existing.
53
+ *
54
+ * @param string $name Key to put value under.
55
+ * @param mixed $value Value to put to storage.
56
+ * @param bool $autoload Set to true to load on start.
57
+ *
58
+ * @return bool Success.
59
+ */
60
+ public function set( $name, $value, $autoload = false ) {
61
+ $comparator = "\0t\0";
62
+ if ( $this->get( $name, $comparator ) === $comparator ) {
63
+ return $this->add( $name, $value, $autoload );
64
+ }
65
+ if ( ! update_option( $name, $value ) ) {
66
+ return false;
67
+ }
68
+ $this->_cache->set( $name, $value );
69
+ return true;
70
+ }
71
+
72
+ /**
73
+ * Get a value from storage.
74
+ *
75
+ * @param string $name Key to retrieve.
76
+ * @param mixed $default Value to return if key was not set previously.
77
+ *
78
+ * @return mixed Value from storage or {$default}.
79
+ */
80
+ public function get( $name, $default = null ) {
81
+ $value = $this->_cache->get( $name, $default );
82
+ if ( $default === $value ) {
83
+ $value = get_option( $name, $default );
84
+ $this->_cache->set( $name, $value );
85
+ }
86
+ return $value;
87
+ }
88
+
89
+ /**
90
+ * Delete value from storage.
91
+ *
92
+ * @param string $name Key to delete.
93
+ *
94
+ * @wp_hook deleted_option Fire after deletion.
95
+ *
96
+ * @return bool Success.
97
+ */
98
+ public function delete( $name ) {
99
+ $this->_cache->delete( $name );
100
+ if ( 'deleted_option' === current_filter() ) {
101
+ return true; // avoid loops
102
+ }
103
+ return delete_option( $name );
104
+ }
105
+
106
+ /**
107
+ * Convert autoload flag input to value recognized by WordPress.
108
+ *
109
+ * @param bool $input Autoload flag value.
110
+ *
111
+ * @return string Autoload identifier.
112
+ */
113
+ protected function _parse_autoload( $input ) {
114
+ return $input ? 'yes' : 'no';
115
+ }
116
+
117
+ }
app/model/search.php ADDED
@@ -0,0 +1,582 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * Search Event.
5
+ *
6
+ * @author Time.ly Network Inc.
7
+ * @since 2.0
8
+ *
9
+ * @package AI1EC
10
+ * @subpackage AI1EC.search
11
+ */
12
+ class Ai1ec_Event_Search extends Ai1ec_Base {
13
+
14
+ /**
15
+ * @var Ai1ec_Dbi instance
16
+ */
17
+ private $_dbi = null;
18
+
19
+ /**
20
+ * Creates local DBI instance.
21
+ */
22
+ public function __construct( Ai1ec_Registry_Object $registry ){
23
+ parent::__construct( $registry );
24
+ $this->_dbi = $this->_registry->get( 'dbi.dbi' );
25
+ }
26
+
27
+ /**
28
+ * Fetches the event object with the given post ID.
29
+ *
30
+ * Uses the WP cache to make this more efficient if possible.
31
+ *
32
+ * @param int $post_id The ID of the post associated.
33
+ * @param bool|int $instance_id Instance ID, to fetch post details for.
34
+ *
35
+ * @return Ai1ec_Event The associated event object.
36
+ */
37
+ public function get_event( $post_id, $instance_id = false ) {
38
+ $post_id = (int)$post_id;
39
+ $instance_id = (int)$instance_id;
40
+ if ( $instance_id < 1 ) {
41
+ $instance_id = false;
42
+ }
43
+ return new Ai1ec_Event( $post_id, $instance_id );
44
+ }
45
+
46
+ /**
47
+ * Return events falling within some time range.
48
+ *
49
+ * Return all events starting after the given start time and before the
50
+ * given end time that the currently logged in user has permission to view.
51
+ * If $spanning is true, then also include events that span this
52
+ * period. All-day events are returned first.
53
+ *
54
+ * @param Ai1ec_Date_Time $start Limit to events starting after this.
55
+ * @param Ai1ec_Date_Time $end Limit to events starting before this.
56
+ * @param array $filter Array of filters for the events returned:
57
+ * ['cat_ids'] => list of category IDs;
58
+ * ['tag_ids'] => list of tag IDs;
59
+ * ['post_ids'] => list of post IDs;
60
+ * ['auth_ids'] => list of author IDs.
61
+ * @param bool $spanning Also include events that span this period.
62
+ *
63
+ * @return array List of matching event objects.
64
+ */
65
+ public function get_events_between(
66
+ Ai1ec_Date_Time $start,
67
+ Ai1ec_Date_Time $end,
68
+ array $filter = array(),
69
+ $spanning = false
70
+ ) {
71
+ // Query arguments
72
+ $args = array(
73
+ $start->format_to_gmt(),
74
+ $end->format_to_gmt(),
75
+ );
76
+
77
+ // Get post status Where snippet and associated SQL arguments
78
+ $where_parameters = $this->_get_post_status_sql();
79
+ $post_status_where = $where_parameters['post_status_where'];
80
+ $args = array_merge( $args, $where_parameters['args'] );
81
+
82
+ // Get the Join (filter_join) and Where (filter_where) statements based
83
+ // on $filter elements specified
84
+ $filter = $this->_get_filter_sql( $filter );
85
+
86
+ $ai1ec_localization_helper = $this->_registry->get( 'p28n.wpml' );
87
+
88
+ $wpml_join_particle = $ai1ec_localization_helper
89
+ ->get_wpml_table_join( 'p.ID' );
90
+
91
+ $wpml_where_particle = $ai1ec_localization_helper
92
+ ->get_wpml_table_where();
93
+
94
+ if ( $spanning ) {
95
+ $spanning_string = 'i.end > %d AND i.start < %d ';
96
+ } else {
97
+ $spanning_string = 'i.start BETWEEN %d AND %d ';
98
+ }
99
+
100
+ $sql = '
101
+ SELECT
102
+ `p`.*,
103
+ `e`.`post_id`,
104
+ `i`.`id` AS `instance_id`,
105
+ `i`.`start` AS `start`,
106
+ `i`.`end` AS `end`,
107
+ `e`.`timezone_name` AS `timezone_name`,
108
+ `e`.`allday` AS `event_allday`,
109
+ `e`.`recurrence_rules`,
110
+ `e`.`exception_rules`,
111
+ `e`.`recurrence_dates`,
112
+ `e`.`exception_dates`,
113
+ `e`.`venue`,
114
+ `e`.`country`,
115
+ `e`.`address`,
116
+ `e`.`city`,
117
+ `e`.`province`,
118
+ `e`.`postal_code`,
119
+ `e`.`instant_event`,
120
+ `e`.`show_map`,
121
+ `e`.`contact_name`,
122
+ `e`.`contact_phone`,
123
+ `e`.`contact_email`,
124
+ `e`.`cost`,
125
+ `e`.`ticket_url`,
126
+ `e`.`ical_feed_url`,
127
+ `e`.`ical_source_url`,
128
+ `e`.`ical_organizer`,
129
+ `e`.`ical_contact`,
130
+ `e`.`ical_uid`
131
+ FROM
132
+ ' . $this->_dbi->get_table_name( 'ai1ec_events' ) . ' e
133
+ INNER JOIN
134
+ ' . $this->_dbi->get_table_name( 'posts' ) . ' p
135
+ ON ( `p`.`ID` = `e`.`post_id` )
136
+ ' . $wpml_join_particle . '
137
+ INNER JOIN
138
+ ' . $this->_dbi->get_table_name( 'ai1ec_event_instances' ) . ' i
139
+ ON ( `e`.`post_id` = `i`.`post_id` )
140
+ ' . $filter['filter_join'] . '
141
+ WHERE
142
+ post_type = \'' . AI1EC_POST_TYPE . '\'
143
+ ' . $wpml_where_particle . '
144
+ AND
145
+ ' . $spanning_string . '
146
+ ' . $filter['filter_where'] . '
147
+ ' . $post_status_where . '
148
+ GROUP BY
149
+ `i`.`id`
150
+ ORDER BY
151
+ `e` . `allday` DESC,
152
+ `i` . `start` ASC,
153
+ `p` . `post_title` ASC';
154
+
155
+ $query = $this->_dbi->prepare( $sql, $args );
156
+ $events = $this->_dbi->get_results( $query, ARRAY_A );
157
+
158
+ $id_list = array();
159
+ foreach ( $events as $event ) {
160
+ $id_list[] = $event['post_id'];
161
+ }
162
+
163
+ if ( ! empty( $id_list ) ) {
164
+ update_meta_cache( 'post', $id_list );
165
+ }
166
+
167
+ foreach ( $events as &$event ) {
168
+ $event['allday'] = $this->_is_all_day( $event );
169
+ $event = $this->_registry->get( 'model.event', $event );
170
+ }
171
+
172
+ return $events;
173
+ }
174
+
175
+ /**
176
+ * get_events_relative_to function
177
+ *
178
+ * Return all events starting after the given reference time, limiting the
179
+ * result set to a maximum of $limit items, offset by $page_offset. A
180
+ * negative $page_offset can be provided, which will return events *before*
181
+ * the reference time, as expected.
182
+ *
183
+ * @param int $time limit to events starting after this (local) UNIX time
184
+ * @param int $limit return a maximum of this number of items
185
+ * @param int $page_offset offset the result set by $limit times this number
186
+ * @param array $filter Array of filters for the events returned.
187
+ * ['cat_ids'] => non-associatative array of category IDs
188
+ * ['tag_ids'] => non-associatative array of tag IDs
189
+ * ['post_ids'] => non-associatative array of post IDs
190
+ * ['auth_ids'] => non-associatative array of author IDs
191
+ * @param int $last_day Last day (time), that was displayed.
192
+ * NOTE FROM NICOLA: be careful, if you want a query with events
193
+ * that have a start date which is greater than today, pass 0 as
194
+ * this parameter. If you pass false ( or pass nothing ) you end up with a query
195
+ * with events that finish before today. I don't know the rationale
196
+ * behind this but that's how it works
197
+ *
198
+ * @return array five-element array:
199
+ * ['events'] an array of matching event objects
200
+ * ['prev'] true if more previous events
201
+ * ['next'] true if more next events
202
+ * ['date_first'] UNIX timestamp (date part) of first event
203
+ * ['date_last'] UNIX timestamp (date part) of last event
204
+ */
205
+ function get_events_relative_to(
206
+ $time,
207
+ $limit = 0,
208
+ $page_offset = 0,
209
+ $filter = array(),
210
+ $last_day = false
211
+ ) {
212
+ $localization_helper = $this->_registry->get( 'p28n.wpml' );
213
+ $settings = $this->_registry->get( 'model.settings' );
214
+
215
+
216
+ // Even if there ARE more than 5 times the limit results - we shall not
217
+ // try to fetch and display these, as it would crash system
218
+ $upper_boundary = $limit;
219
+ if (
220
+ $settings->get( 'agenda_include_entire_last_day' ) &&
221
+ ( false !== $last_day )
222
+ ) {
223
+ $upper_boundary *= 5;
224
+ }
225
+
226
+ // Convert timestamp to GMT time
227
+ $time = $this->_registry->get( 'date.time' )->format_to_gmt();
228
+ // Get post status Where snippet and associated SQL arguments
229
+ $where_parameters = $this->_get_post_status_sql();
230
+ $post_status_where = $where_parameters['post_status_where'];
231
+
232
+ // Get the Join (filter_join) and Where (filter_where) statements based
233
+ // on $filter elements specified
234
+ $filter = $this->_get_filter_sql( $filter );
235
+
236
+ // Query arguments
237
+ $args = array( $time );
238
+ $args = array_merge( $args, $where_parameters['args'] );
239
+
240
+ if( $page_offset >= 0 ) {
241
+ $first_record = $page_offset * $limit;
242
+ } else {
243
+ $first_record = ( -$page_offset - 1 ) * $limit;
244
+ }
245
+
246
+
247
+ $wpml_join_particle = $localization_helper
248
+ ->get_wpml_table_join( 'p.ID' );
249
+
250
+ $wpml_where_particle = $localization_helper
251
+ ->get_wpml_table_where();
252
+
253
+ $filter_date_clause = ( $page_offset >= 0 )
254
+ ? 'i.end >= %d '
255
+ : 'i.start < %d ';
256
+ $order_direction = ( $page_offset >= 0 ) ? 'ASC' : 'DESC';
257
+ if ( false !== $last_day ) {
258
+ if ( 0 == $last_day ) {
259
+ $last_day = $this->_registry->get( 'date.system' )->current_time();
260
+ }
261
+ $filter_date_clause = ' i.end ';
262
+ if ( $page_offset < 0 ) {
263
+ $filter_date_clause .= '<';
264
+ $order_direction = 'DESC';
265
+ } else {
266
+ $filter_date_clause .= '>';
267
+ $order_direction = 'ASC';
268
+ }
269
+ $filter_date_clause .= ' %d ';
270
+ $args[0] = $last_day;
271
+ $first_record = 0;
272
+ }
273
+ $query = $this->_dbi->prepare(
274
+ 'SELECT DISTINCT p.*, e.post_id, i.id AS instance_id, ' .
275
+ 'i.start AS start, ' .
276
+ 'i.end AS end, ' .
277
+ 'e.allday AS event_allday, ' .
278
+ 'e.recurrence_rules, e.exception_rules, e.ticket_url, e.instant_event, e.recurrence_dates, e.exception_dates, ' .
279
+ 'e.venue, e.country, e.address, e.city, e.province, e.postal_code, ' .
280
+ 'e.show_map, e.contact_name, e.contact_phone, e.contact_email, e.cost, ' .
281
+ 'e.ical_feed_url, e.ical_source_url, e.ical_organizer, e.ical_contact, e.ical_uid, e.timezone_name ' .
282
+ 'FROM ' . $this->_dbi->get_table_name( 'ai1ec_events' ) . ' e ' .
283
+ 'INNER JOIN ' . $this->_dbi->get_table_name( 'posts' ) . ' p ON e.post_id = p.ID ' .
284
+ $wpml_join_particle .
285
+ 'INNER JOIN ' . $this->_dbi->get_table_name( 'ai1ec_event_instances' ) . ' i ON e.post_id = i.post_id ' .
286
+ $filter['filter_join'] .
287
+ "WHERE post_type = '" . AI1EC_POST_TYPE . "' " .
288
+ 'AND ' . $filter_date_clause .
289
+ $wpml_where_particle .
290
+ $filter['filter_where'] .
291
+ $post_status_where .
292
+ // Reverse order when viewing negative pages, to get correct set of
293
+ // records. Then reverse results later to order them properly.
294
+ 'ORDER BY i.start ' . $order_direction .
295
+ ', post_title ' . $order_direction .
296
+ ' LIMIT ' . $first_record . ', ' . $upper_boundary,
297
+ $args
298
+ );
299
+
300
+ $events = $this->_dbi->get_results( $query, ARRAY_A );
301
+
302
+ // Limit the number of records to convert to data-object
303
+ $events = $this->_limit_result_set(
304
+ $events,
305
+ $limit,
306
+ ( false !== $last_day )
307
+ );
308
+
309
+ // Reorder records if in negative page offset
310
+ if( $page_offset < 0 ) {
311
+ $events = array_reverse( $events );
312
+ }
313
+
314
+ $date_first = $date_last = NULL;
315
+
316
+ foreach ( $events as &$event ) {
317
+ $event['allday'] = $this->_is_all_day( $event );
318
+ $event = $this->_registry->get( 'model.event', $event );
319
+ if ( null === $date_first ) {
320
+ $date_first = $event->get( 'start' );
321
+ }
322
+ $date_last = $event->get( 'start' );
323
+ }
324
+ $date_first = $this->_registry->get( 'date.time', $date_first );
325
+ $date_last = $this->_registry->get( 'date.time', $date_last );
326
+
327
+ $next = false;
328
+ $prev = false;
329
+ // if there are enough events to display a page, presume that there might be more.
330
+ if ( count( $events ) === $limit ) {
331
+ $next = true;
332
+ $prev = true;
333
+ }
334
+ return array(
335
+ 'events' => $events,
336
+ 'prev' => $prev,
337
+ 'next' => $next,
338
+ 'date_first' => $date_first,
339
+ 'date_last' => $date_last,
340
+ );
341
+ }
342
+
343
+ /**
344
+ * Get ID of event in database, matching imported one.
345
+ *
346
+ * Return event ID by iCalendar UID, feed url, start time and whether the
347
+ * event has recurrence rules (to differentiate between an event with a UID
348
+ * defining the recurrence pattern, and other events with with the same UID,
349
+ * which are just RECURRENCE-IDs).
350
+ *
351
+ * @param int $uid iCalendar UID property
352
+ * @param string $feed Feed URL
353
+ * @param int $start Start timestamp (GMT)
354
+ * @param bool $has_recurrence Whether the event has recurrence rules
355
+ * @param int|null $exclude_post_id Do not match against this post ID
356
+ *
357
+ * @return object|null ID of matching event post, or NULL if no match
358
+ */
359
+ public function get_matching_event_id(
360
+ $uid,
361
+ $feed,
362
+ $start,
363
+ $has_recurrence = false,
364
+ $exclude_post_id = null
365
+ ) {
366
+ $dbi = $this->_registry->get( 'dbi.dbi' );
367
+ $table_name = $dbi->get_table_name( 'ai1ec_events' );
368
+ $query = 'SELECT `post_id` FROM ' . $table_name . '
369
+ WHERE
370
+ ical_feed_url = %s
371
+ AND ical_uid = %s
372
+ AND start = %d ' .
373
+ ( $has_recurrence ? 'AND NOT ' : 'AND ' ) .
374
+ ' ( recurrence_rules IS NULL OR recurrence_rules = \'\' )';
375
+ $args = array( $feed, $uid );
376
+ if ( $start instanceof Ai1ec_Date_Time ) {
377
+ $args[] = $start->format();
378
+ } else {
379
+ $args[] = (int)$start;
380
+ }
381
+ if ( null !== $exclude_post_id ) {
382
+ $query .= ' AND post_id <> %d';
383
+ $args[] = $exclude_post_id;
384
+ }
385
+
386
+ return $dbi->get_var( $dbi->prepare( $query, $args ) );
387
+ }
388
+
389
+ /**
390
+ * Check if given event must be treated as all-day event.
391
+ *
392
+ * Event instances that span 24 hours are treated as all-day.
393
+ * NOTICE: event is passed in before being transformed into
394
+ * Ai1ec_Event object, with Ai1ec_Date_Time fields.
395
+ *
396
+ * @param array $event Event data returned from database.
397
+ *
398
+ * @return bool True if event is all-day event.
399
+ */
400
+ protected function _is_all_day( array $event ) {
401
+ if ( isset( $event['event_allday'] ) && $event['event_allday'] ) {
402
+ return true;
403
+ }
404
+
405
+ if ( ! isset( $event['start'] ) || ! isset( $event['end'] ) ) {
406
+ return false;
407
+ }
408
+
409
+ return ( 86400 === $event['end'] - $event['start'] );
410
+ }
411
+
412
+ /**
413
+ * _limit_result_set function
414
+ *
415
+ * Slice given number of events from list, with exception when all
416
+ * events from last day shall be included.
417
+ *
418
+ * @param array $events List of events to slice
419
+ * @param int $limit Number of events to slice-off
420
+ * @param bool $last_day Set to true to include all events from last day ignoring {$limit}
421
+ *
422
+ * @return array Sliced events list
423
+ */
424
+ protected function _limit_result_set(
425
+ array $events,
426
+ $limit,
427
+ $last_day
428
+ ) {
429
+ $limited_events = array();
430
+ $start_day_previous = 0;
431
+ foreach ( $events as $event ) {
432
+ $start_day = date(
433
+ 'Y-m-d',
434
+ $event['start']
435
+ );
436
+ --$limit; // $limit = $limit - 1;
437
+ if ( $limit < 0 ) {
438
+ if ( true === $last_day ) {
439
+ if ( $start_day != $start_day_previous ) {
440
+ break;
441
+ }
442
+ } else {
443
+ break;
444
+ }
445
+ }
446
+ $limited_events[] = $event;
447
+ $start_day_previous = $start_day;
448
+ }
449
+ return $limited_events;
450
+ }
451
+
452
+ /**
453
+ * _get_post_status_sql function
454
+ *
455
+ * Returns SQL snippet for properly matching event posts, as well as array
456
+ * of arguments to pass to $this_dbi->prepare, in function argument
457
+ * references.
458
+ * Nothing is returned by the function.
459
+ *
460
+ * @return array An array containing post_status_where: the sql string,
461
+ * args: the arguments for prepare()
462
+ */
463
+ protected function _get_post_status_sql() {
464
+ global $current_user;
465
+
466
+ $args = array();
467
+
468
+ // Query the correct post status
469
+ if (
470
+ current_user_can( 'administrator' ) ||
471
+ current_user_can( 'editor' )
472
+ ) {
473
+ // User has privilege of seeing all published and private
474
+ $post_status_where = 'AND post_status IN ( %s, %s ) ';
475
+ $args[] = 'publish';
476
+ $args[] = 'private';
477
+ } elseif ( is_user_logged_in() ) {
478
+ // User has privilege of seeing all published and only their own
479
+ // private posts.
480
+
481
+ // get user info
482
+ get_currentuserinfo();
483
+
484
+ // include post_status = published
485
+ // OR
486
+ // post_status = private AND post_author = userID
487
+ $post_status_where =
488
+ 'AND ( ' .
489
+ 'post_status = %s ' .
490
+ 'OR ( post_status = %s AND post_author = %d ) ' .
491
+ ') ';
492
+
493
+ $args[] = 'publish';
494
+ $args[] = 'private';
495
+ $args[] = $current_user->ID;
496
+ } else {
497
+ // User can only see published posts.
498
+ $post_status_where = 'AND post_status = %s ';
499
+ $args[] = 'publish';
500
+ }
501
+
502
+ return array(
503
+ 'post_status_where' => $post_status_where,
504
+ 'args' => $args
505
+ );
506
+ }
507
+
508
+ /**
509
+ * Take filter and return SQL options.
510
+ *
511
+ * Takes an array of filtering options and turns it into JOIN and WHERE
512
+ * statements for running an SQL query limited to the specified options.
513
+ *
514
+ * @param array $filter Array of filters for the events returned:
515
+ * ['cat_ids'] => list of category IDs
516
+ * ['tag_ids'] => list of tag IDs
517
+ * ['post_ids'] => list of event post IDs
518
+ * ['auth_ids'] => list of event author IDs
519
+ *
520
+ * @return array The modified filter array to having:
521
+ * ['filter_join'] the Join statements for the SQL
522
+ * ['filter_where'] the Where statements for the SQL
523
+ */
524
+ protected function _get_filter_sql( $filter ) {
525
+ $filter_join = $filter_where = array();
526
+ foreach ( $filter as $filter_type => $filter_ids ) {
527
+ $filter_object = null;
528
+ try {
529
+ if ( empty( $filter_ids ) ) {
530
+ $filter_ids = array();
531
+ }
532
+ $filter_object = $this->_registry->get(
533
+ 'model.filter.' . $filter_type,
534
+ $filter_ids
535
+ );
536
+ if ( ! ( $filter_object instanceof Ai1ec_Filter_Interface ) ) {
537
+ throw new Ai1ec_Bootstrap_Exception(
538
+ 'Filter \'' . get_class( $filter_object ) .
539
+ '\' is not instance of Ai1ec_Filter_Interface'
540
+ );
541
+ }
542
+ } catch ( Ai1ec_Bootstrap_Exception $exception ) {
543
+ continue;
544
+ }
545
+ $filter_join[] = $filter_object->get_join();
546
+ $filter_where[] = $filter_object->get_where();
547
+ }
548
+
549
+ $filter_join = array_filter( $filter_join );
550
+ $filter_where = array_filter( $filter_where );
551
+ $filter_join = join( ' ', $filter_join );
552
+ if ( count( $filter_where ) > 0 ) {
553
+ $operator = $this->get_distinct_types_operator();
554
+ $filter_where = $operator . '( ' .
555
+ implode( ' ) ' . $operator . ' ( ', $filter_where ) .
556
+ ' ) ';
557
+ } else {
558
+ $filter_where = '';
559
+ }
560
+
561
+ return $filter + compact( 'filter_where', 'filter_join' );
562
+ }
563
+
564
+ /**
565
+ * Get operator for joining distinct filters in WHERE.
566
+ *
567
+ * @return string SQL operator.
568
+ */
569
+ public function get_distinct_types_operator() {
570
+ static $operators = array( 'AND' => 1, 'OR' => 2 );
571
+ $default = key( $operators );
572
+ $where_operator = strtoupper( trim( (string)apply_filters(
573
+ 'ai1ec_filter_distinct_types_logic',
574
+ $default
575
+ ) ) );
576
+ if ( ! isset( $operators[$where_operator] ) ) {
577
+ $where_operator = $default;
578
+ }
579
+ return $where_operator;
580
+ }
581
+
582
+ }
app/model/settings-view.php ADDED
@@ -0,0 +1,136 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * Settings extension for managing view-related settings.
5
+ *
6
+ * @author Time.ly Network, Inc.
7
+ * @since 2.0
8
+ * @package Ai1EC
9
+ * @subpackage Ai1EC.Model
10
+ */
11
+ class Ai1ec_Settings_View extends Ai1ec_App {
12
+
13
+ /**
14
+ * @var string Name of settings option to use for views map.
15
+ */
16
+ const SETTING_VIEWS_MAP = 'enabled_views';
17
+
18
+ /**
19
+ * @var Ai1ec_Settings Instance
20
+ */
21
+ protected $_settings = null;
22
+
23
+ /**
24
+ * Acquire Settings model instance for future reference.
25
+ *
26
+ * @return void
27
+ */
28
+ protected function _initialize() {
29
+ $this->_settings = $this->_registry->get( 'model.settings' );
30
+ }
31
+
32
+ /**
33
+ * Add a view if not set.
34
+ *
35
+ * @param array $view
36
+ */
37
+ public function add( array $view ) {
38
+ $enabled_views = $this->_get();
39
+ if ( isset( $enabled_views[$view['name']] ) ) {
40
+ return;
41
+ }
42
+ $enabled_views[$view['name']] = array(
43
+ 'enabled' => $view['enabled'],
44
+ 'default' => $view['default'],
45
+ 'longname' => $view['longname'],
46
+ );
47
+ $this->_set( $enabled_views );
48
+ }
49
+
50
+ /**
51
+ * Remove a view.
52
+ *
53
+ * @param string $view
54
+ */
55
+ public function remove( $view ) {
56
+ $enabled_views = $this->_get();
57
+ if ( isset( $enabled_views[$view] ) ) {
58
+ unset( $enabled_views[$view] );
59
+ $this->_set( $enabled_views );
60
+ }
61
+ }
62
+
63
+ /**
64
+ * Retrieve all configured views.
65
+ *
66
+ * @return array Map of configured view aliases and their details.
67
+ */
68
+ public function get_all() {
69
+ return $this->_get();
70
+ }
71
+
72
+ /**
73
+ * Get name of view to be rendered for requested alias.
74
+ *
75
+ * @param string $view Name of view requested.
76
+ *
77
+ * @return string Name of view to be rendered.
78
+ *
79
+ * @throws Ai1ec_Settings_Exception If no views are configured.
80
+ */
81
+ public function get_configured( $view ) {
82
+ $enabled_views = $this->_get();
83
+ if ( empty( $enabled_views ) ) {
84
+ throw new Ai1ec_Settings_Exception( 'No view is enabled' );
85
+ }
86
+ if (
87
+ isset( $enabled_views[$view] ) &&
88
+ $enabled_views[$view]['enabled']
89
+ ) {
90
+ return $view;
91
+ }
92
+ return $this->get_default();
93
+ }
94
+
95
+ /**
96
+ * Get default view to render.
97
+ *
98
+ *
99
+ * @return
100
+ */
101
+ public function get_default() {
102
+ $enabled_views = $this->_get();
103
+ $default = null;
104
+ foreach ( $enabled_views as $view => $details ) {
105
+ if ( $details['default'] && $details['enabled'] ) {
106
+ $default = $view;
107
+ break;
108
+ }
109
+ }
110
+ if ( null === $default ) {
111
+ $default = (string)current( array_keys( $enabled_views ) );
112
+ }
113
+ return $default;
114
+ }
115
+
116
+ /**
117
+ * Retrieve views maps from storage.
118
+ *
119
+ * @return array Current views map.
120
+ */
121
+ protected function _get() {
122
+ return (array)$this->_settings->get( self::SETTING_VIEWS_MAP, array() );
123
+ }
124
+
125
+ /**
126
+ * Update views map.
127
+ *
128
+ * @param array $enabled_views Map of enabled views.
129
+ *
130
+ * @return bool Success.
131
+ */
132
+ protected function _set( array $enabled_views ) {
133
+ return $this->_settings->set( self::SETTING_VIEWS_MAP, $enabled_views );
134
+ }
135
+
136
+ }
app/model/settings.php ADDED
@@ -0,0 +1,773 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * Model used for storing/retrieving plugin options.
5
+ *
6
+ * @author Time.ly Network, Inc.
7
+ * @since 2.0
8
+ * @package Ai1EC
9
+ * @subpackage Ai1EC.Model
10
+ */
11
+ class Ai1ec_Settings extends Ai1ec_App {
12
+
13
+ /**
14
+ * @constant string Name of WordPress options key used to store settings.
15
+ */
16
+ const WP_OPTION_KEY = 'ai1ec_settings';
17
+
18
+ /**
19
+ * @var array Map of value names and their representations.
20
+ */
21
+ protected $_options = array();
22
+
23
+ /**
24
+ * @var bool Indicator for modified object state.
25
+ */
26
+ protected $_updated = false;
27
+
28
+ /**
29
+ * @var array The core options of the plugin.
30
+ */
31
+ protected $_standard_options;
32
+
33
+ /**
34
+ * Register new option to be used.
35
+ *
36
+ * @param string $option Name of option.
37
+ * @param mixed $value The value.
38
+ * @param string $type Option type to be used for validation.
39
+ * @param string $renderer Name of class to render the option.
40
+ *
41
+ * @return Ai1ec_Settings Instance of self for chaining.
42
+ */
43
+ public function register(
44
+ $option,
45
+ $value,
46
+ $type,
47
+ $renderer,
48
+ $version = '2.0a'
49
+ ) {
50
+ if (
51
+ ! isset( $this->_options[$option] ) ||
52
+ ! isset( $this->_options[$option]['version'] ) ||
53
+ (string)$this->_options[$option]['version'] !== (string)$version
54
+ ) {
55
+ $this->_options[$option] = array(
56
+ 'value' => ( isset( $this->_options[$option] ) )
57
+ ? $this->_options[$option]['value']
58
+ : $value,
59
+ 'type' => $type,
60
+ 'legacy' => false,
61
+ 'version' => $version,
62
+ );
63
+ if ( null !== $renderer ) {
64
+ $this->_options[$option]['renderer'] = $renderer;
65
+ }
66
+ }
67
+ return $this;
68
+ }
69
+
70
+ /**
71
+ * Gets the options.
72
+ *
73
+ * @return array:
74
+ */
75
+ public function get_options() {
76
+ return $this->_options;
77
+ }
78
+
79
+ /**
80
+ * Get field options as registered.
81
+ *
82
+ * @param string $option Name of option field to describe.
83
+ *
84
+ * @return array|null Description or null if nothing is found.
85
+ */
86
+ public function describe( $option ) {
87
+ if ( ! isset( $this->_options[$option] ) ) {
88
+ return null;
89
+ }
90
+ return $this->_options[$option];
91
+ }
92
+
93
+ /**
94
+ * Get value for option.
95
+ *
96
+ * @param string $option Name of option to get value for.
97
+ * @param mixed $default Value to return if option is not found.
98
+ *
99
+ * @return mixed Value or $default if none is found.
100
+ */
101
+ public function get( $option, $default = null ) {
102
+ // notice, that `null` is not treated as a value
103
+ if ( ! isset( $this->_options[$option] ) ) {
104
+ return $default;
105
+ }
106
+ return $this->_options[$option]['value'];
107
+ }
108
+
109
+ /**
110
+ * Set new value for previously initialized option.
111
+ *
112
+ * @param string $option Name of option to update.
113
+ * @param mixed $value Actual value to be used for option.
114
+ *
115
+ * @throws Ai1ec_Settings_Exception
116
+ *
117
+ * @return Ai1ec_Settings Instance of self for chaining.
118
+ */
119
+ public function set( $option, $value ) {
120
+ if ( ! isset( $this->_options[$option] ) ) {
121
+ throw new Ai1ec_Settings_Exception(
122
+ 'Option "' . $option . '" was not registered'
123
+ );
124
+ }
125
+ if ( 'array' === $this->_options[$option]['type'] ) {
126
+ if (
127
+ ! is_array( $this->_options[$option]['value'] ) ||
128
+ ! is_array( $value ) ||
129
+ $value != $this->_options[$option]['value']
130
+ ) {
131
+ $this->_options[$option]['value'] = $value;
132
+ $this->_change_update_status ( true );
133
+ }
134
+ } else if (
135
+ (string)$value !== (string)$this->_options[$option]['value']
136
+ ) {
137
+ $this->_options[$option]['value'] = $value;
138
+ $this->_change_update_status ( true );
139
+ }
140
+ return $this;
141
+ }
142
+
143
+ /**
144
+ * Parse legacy values into new structure.
145
+ *
146
+ * @param mixed $values Expected legacy representation.
147
+ *
148
+ * @return array Parsed values representation, or input cast as array.
149
+ */
150
+ protected function _parse_legacy( Ai1ec_Settings $values ) {
151
+ $variables = get_object_vars( $values );
152
+ $default_tags_cat = array();
153
+ $legacy = array();
154
+ foreach ( $variables as $key => $value ) {
155
+ if ( 'default_categories' === $key ) {
156
+ $default_tags_cat['categories'] = $value;
157
+ continue;
158
+ }
159
+ if ( 'default_tags' === $key ) {
160
+ $default_tags_cat['tags'] = $value;
161
+ continue;
162
+ }
163
+ $type = 'string';
164
+ if ( is_array( $value ) ) {
165
+ $type = 'array';
166
+ } elseif ( is_bool( $value ) ) {
167
+ $type = 'bool';
168
+ } elseif ( is_int( $value ) ) {
169
+ $type = 'int';
170
+ }
171
+ if ( isset( $this->_options[$key] ) ) {
172
+ $this->_options[$key]['value'] = $value;
173
+ } else {
174
+ $legacy[$key] = array(
175
+ 'value' => $value,
176
+ 'type' => $type,
177
+ 'legacy' => true,
178
+ 'version' => AI1EC_VERSION
179
+ );
180
+ }
181
+ }
182
+ $this->_options['default_tags_categories']['value'] = $default_tags_cat;
183
+ $this->_options['legacy_options'] = $legacy;
184
+ }
185
+
186
+ /**
187
+ * Write object representation to persistence layer.
188
+ *
189
+ * Upon successful write to persistence layer the objects internal
190
+ * state {@see self::$_updated} is updated respectively.
191
+ *
192
+ * @return bool Success.
193
+ */
194
+ public function persist() {
195
+ $success = $this->_registry->get( 'model.option' )
196
+ ->set( self::WP_OPTION_KEY, $this->_options );
197
+ if ( $success ) {
198
+ $this->_change_update_status( false );
199
+ }
200
+ return $success;
201
+ }
202
+
203
+ /**
204
+ * Remove an option if is set.
205
+ *
206
+ * @param string $option
207
+ */
208
+ public function remove_option( $option ) {
209
+ if ( isset( $this->_options[$option] ) ) {
210
+ unset( $this->_options[$option] );
211
+ $this->_change_update_status( true );
212
+ }
213
+ }
214
+
215
+ /**
216
+ * Hide an option by unsetting it's renderer
217
+ *
218
+ * @param string $option
219
+ */
220
+ public function hide_option( $option ) {
221
+ if ( isset( $this->_options[$option] ) ) {
222
+ unset( $this->_options[$option]['renderer'] );
223
+ $this->_change_update_status( true );
224
+ }
225
+ }
226
+
227
+ /**
228
+ * Show an option by setting it's renderer
229
+ *
230
+ * @param string $option
231
+ */
232
+ public function show_option( $option, array $renderer ) {
233
+ if ( isset( $this->_options[$option] ) ) {
234
+ $this->_options[$option]['renderer'] = $renderer;
235
+ $this->_change_update_status( true );
236
+ }
237
+ }
238
+
239
+ /**
240
+ * Check object state and update it's database representation as needed.
241
+ *
242
+ * @return void Destructor does not return.
243
+ */
244
+ public function shutdown() {
245
+ if ( $this->_updated ) {
246
+ $this->persist();
247
+ }
248
+ }
249
+
250
+ /**
251
+ * Initiate options map from storage.
252
+ *
253
+ * @return void Return from this method is ignored.
254
+ */
255
+ protected function _initialize() {
256
+ $this->_set_standard_values();
257
+ $values = $this->_registry->get( 'model.option' )
258
+ ->get( self::WP_OPTION_KEY, array() );
259
+ $this->_change_update_status( false );
260
+ $test_version = false;
261
+ if ( is_array( $values ) ) { // always assign existing values, if any
262
+ $this->_options = $values;
263
+ if ( isset( $values['calendar_page_id'] ) ) {
264
+ $test_version = $values['calendar_page_id']['version'];
265
+ }
266
+ }
267
+ if ( // process meta updates changes
268
+ empty( $values ) || (
269
+ false !== $test_version &&
270
+ AI1EC_VERSION !== $test_version
271
+ )
272
+ ) {
273
+ $this->_register_standard_values();
274
+ $this->_change_update_status( true );
275
+ } else if ( $values instanceof Ai1ec_Settings ) { // process legacy
276
+ $this->_register_standard_values();
277
+ $this->_parse_legacy( $values );
278
+ $this->_change_update_status( true );
279
+ }
280
+ $this->_registry->get( 'controller.shutdown' )->register(
281
+ array( $this, 'shutdown' )
282
+ );
283
+ }
284
+
285
+ /**
286
+ * Set the standard values for the options of the core plugin.
287
+ *
288
+ */
289
+ protected function _set_standard_values() {
290
+ $this->_standard_options = array(
291
+ 'ai1ec_db_version' => array(
292
+ 'type' => 'int',
293
+ 'default' => false,
294
+ ),
295
+ 'feeds_page' => array(
296
+ 'type' => 'string',
297
+ 'default' => false,
298
+ ),
299
+ 'settings_page' => array(
300
+ 'type' => 'string',
301
+ 'default' => false,
302
+ ),
303
+ 'less_variables_page' => array(
304
+ 'type' => 'string',
305
+ 'default' => false,
306
+ ),
307
+ 'input_date_format' => array(
308
+ 'type' => 'string',
309
+ 'default' => 'd/m/yyyy',
310
+ ),
311
+ 'plugins_options' => array(
312
+ 'type' => 'array',
313
+ 'default' => array(),
314
+ ),
315
+ 'show_tracking_popup' => array(
316
+ 'type' => 'bool',
317
+ 'default' => true,
318
+ ),
319
+ 'calendar_page_id' => array(
320
+ 'type' => 'mixed',
321
+ 'renderer' => array(
322
+ 'class' => 'calendar-page-selector',
323
+ 'tab' => 'viewing-events',
324
+ 'item' => 'viewing-events',
325
+ 'label' => Ai1ec_I18n::__( 'Calendar page' )
326
+ ),
327
+ 'default' => false,
328
+ ),
329
+ 'week_start_day' => array(
330
+ 'type' => 'int',
331
+ 'renderer' => array(
332
+ 'class' => 'select',
333
+ 'tab' => 'viewing-events',
334
+ 'item' => 'viewing-events',
335
+ 'label' => Ai1ec_I18n::__( 'Week starts on' ),
336
+ 'options' => 'get_weekdays',
337
+ ),
338
+ 'default' => $this->_registry->get( 'model.option' )->get(
339
+ 'start_of_week'
340
+ ),
341
+ ),
342
+ 'enabled_views' => array(
343
+ 'type' => 'array',
344
+ 'renderer' => array(
345
+ 'class' => 'enabled-views',
346
+ 'tab' => 'viewing-events',
347
+ 'item' => 'viewing-events',
348
+ 'label' => Ai1ec_I18n::__( 'Available views' ),
349
+ ),
350
+ 'default' => array(
351
+ 'agenda' => array(
352
+ 'enabled' => true,
353
+ 'default' => true,
354
+ 'longname' => Ai1ec_I18n::__( 'Agenda' ),
355
+ ),
356
+ 'oneday' => array(
357
+ 'enabled' => true,
358
+ 'default' => false,
359
+ 'longname' => Ai1ec_I18n::__( 'Day' ),
360
+ ),
361
+ 'month' => array(
362
+ 'enabled' => true,
363
+ 'default' => false,
364
+ 'longname' => Ai1ec_I18n::__( 'Month' ),
365
+ ),
366
+ 'week' => array(
367
+ 'enabled' => true,
368
+ 'default' => false,
369
+ 'longname' => Ai1ec_I18n::__( 'Week' ),
370
+ ),
371
+ ),
372
+ ),
373
+ 'default_tags_categories' => array(
374
+ 'type' => 'array',
375
+ 'renderer' => array(
376
+ 'class' => 'tags-categories',
377
+ 'tab' => 'viewing-events',
378
+ 'item' => 'viewing-events',
379
+ 'label' => Ai1ec_I18n::__( 'Preselected calendar filters' ),
380
+ 'help' => Ai1ec_I18n::__(
381
+ 'To clear, hold &#8984;/<abbr class="initialism">CTRL</abbr> and click selection.'
382
+ )
383
+ ),
384
+ 'default' => array(
385
+ 'categories' => array(),
386
+ 'tags' => array(),
387
+ ),
388
+ ),
389
+ 'exact_date' => array(
390
+ 'type' => 'string',
391
+ 'renderer' => array(
392
+ 'class' => 'input',
393
+ 'tab' => 'viewing-events',
394
+ 'item' => 'viewing-events',
395
+ 'label' => Ai1ec_I18n::__( 'Default calendar start date (optional)' ),
396
+ 'type' => 'date',
397
+ ),
398
+ 'default' => '',
399
+ ),
400
+ 'agenda_events_per_page' => array(
401
+ 'type' => 'int',
402
+ 'renderer' => array(
403
+ 'class' => 'input',
404
+ 'tab' => 'viewing-events',
405
+ 'item' => 'viewing-events',
406
+ 'label' => Ai1ec_I18n::__( 'Agenda pages show at most' ),
407
+ 'type' => 'append',
408
+ 'append' => 'events',
409
+ 'validator' => 'numeric',
410
+ ),
411
+ 'default' => 10,
412
+ ),
413
+ 'month_word_wrap' => array(
414
+ 'type' => 'bool',
415
+ 'renderer' => array(
416
+ 'class' => 'checkbox',
417
+ 'tab' => 'viewing-events',
418
+ 'item' => 'viewing-events',
419
+ 'label' => Ai1ec_I18n::__(
420
+ '<strong>Word-wrap event stubs</strong> in Month view'
421
+ ),
422
+ 'help' => Ai1ec_I18n::__(
423
+ 'Only applies to events that span a single day.'
424
+ ),
425
+ ),
426
+ 'default' => false,
427
+ ),
428
+ 'agenda_include_entire_last_day' => array(
429
+ 'type' => 'bool',
430
+ 'renderer' => array(
431
+ 'class' => 'checkbox',
432
+ 'tab' => 'viewing-events',
433
+ 'item' => 'viewing-events',
434
+ 'label' => Ai1ec_I18n::__(
435
+ 'In <span class="ai1ec-tooltip-toggle"
436
+ data-original-title="These include Agenda view,
437
+ the Upcoming Events widget, and some extended views.">
438
+ Agenda-like views</span>, <strong>include all events
439
+ from last day shown</strong>'
440
+ )
441
+ ),
442
+ 'default' => false,
443
+ ),
444
+ 'agenda_events_expanded' => array(
445
+ 'type' => 'bool',
446
+ 'renderer' => array(
447
+ 'class' => 'checkbox',
448
+ 'tab' => 'viewing-events',
449
+ 'item' => 'viewing-events',
450
+ 'label' => Ai1ec_I18n::__(
451
+ 'Keep all events <strong>expanded</strong> in Agenda view'
452
+ )
453
+ ),
454
+ 'default' => false,
455
+ ),
456
+ 'show_year_in_agenda_dates' => array(
457
+ 'type' => 'bool',
458
+ 'renderer' => array(
459
+ 'class' => 'checkbox',
460
+ 'tab' => 'viewing-events',
461
+ 'item' => 'viewing-events',
462
+ 'label' => Ai1ec_I18n::__(
463
+ '<strong>Show year</strong> in calendar date labels'
464
+ )
465
+ ),
466
+ 'default' => false,
467
+ ),
468
+ 'show_location_in_title' => array(
469
+ 'type' => 'bool',
470
+ 'renderer' => array(
471
+ 'class' => 'checkbox',
472
+ 'tab' => 'viewing-events',
473
+ 'item' => 'viewing-events',
474
+ 'label' => Ai1ec_I18n::__(
475
+ '<strong>Show location in event titles</strong> in calendar views'
476
+ )
477
+ ),
478
+ 'default' => true,
479
+ ),
480
+ 'exclude_from_search' => array(
481
+ 'type' => 'bool',
482
+ 'renderer' => array(
483
+ 'class' => 'checkbox',
484
+ 'tab' => 'viewing-events',
485
+ 'item' => 'viewing-events',
486
+ 'label' => Ai1ec_I18n::__(
487
+ '<strong>Exclude</strong> events from search results'
488
+ )
489
+ ),
490
+ 'default' => false,
491
+ ),
492
+ 'turn_off_subscription_buttons' => array(
493
+ 'type' => 'bool',
494
+ 'renderer' => array(
495
+ 'class' => 'checkbox',
496
+ 'tab' => 'viewing-events',
497
+ 'item' => 'viewing-events',
498
+ 'label' => Ai1ec_I18n::__(
499
+ 'Hide <strong>Subscribe</strong>/<strong>Add to Calendar</strong> buttons in calendar and single event views '
500
+ )
501
+ ),
502
+ 'default' => false,
503
+ ),
504
+ 'hide_maps_until_clicked' => array(
505
+ 'type' => 'bool',
506
+ 'renderer' => array(
507
+ 'class' => 'checkbox',
508
+ 'tab' => 'viewing-events',
509
+ 'item' => 'viewing-events',
510
+ 'label' => Ai1ec_I18n::__(
511
+ ' Hide <strong>Google Maps</strong> until clicked'
512
+ )
513
+ ),
514
+ 'default' => false,
515
+ ),
516
+ 'hide_featured_image' => array(
517
+ 'type' => 'bool',
518
+ 'renderer' => array(
519
+ 'class' => 'checkbox',
520
+ 'tab' => 'viewing-events',
521
+ 'item' => 'viewing-events',
522
+ 'label' => Ai1ec_I18n::__(
523
+ ' <strong>Hide featured image</strong> from event details page'
524
+ ),
525
+ 'help' => Ai1ec_I18n::__(
526
+ "Select this option if your theme already displays each post's featured image."
527
+ ),
528
+ ),
529
+ 'default' => false,
530
+ ),
531
+ 'embedding' => array(
532
+ 'type' => 'html',
533
+ 'renderer' => array(
534
+ 'class' => 'html',
535
+ 'tab' => 'viewing-events',
536
+ 'item' => 'embedded-views',
537
+ ),
538
+ 'default' => null,
539
+ ),
540
+ 'input_date_format' => array(
541
+ 'type' => 'string',
542
+ 'renderer' => array(
543
+ 'class' => 'select',
544
+ 'tab' => 'editing-events',
545
+ 'label' => Ai1ec_I18n::__(
546
+ 'Input dates in this format'
547
+ ),
548
+ 'options' => array(
549
+ array(
550
+ 'text' => Ai1ec_I18n::__( 'Default (d/m/yyyy)' ),
551
+ 'value' => 'def'
552
+ ),
553
+ array(
554
+ 'text' => Ai1ec_I18n::__( 'US (m/d/yyyy)' ),
555
+ 'value' => 'us'
556
+ ),
557
+ array(
558
+ 'text' => Ai1ec_I18n::__( 'ISO 8601 (yyyy-m-d)' ),
559
+ 'value' => 'iso'
560
+ ),
561
+ array(
562
+ 'text' => Ai1ec_I18n::__( 'Dotted (m.d.yyyy)' ),
563
+ 'value' => 'dot'
564
+ ),
565
+ ),
566
+ ),
567
+ 'default' => 'def',
568
+ ),
569
+ 'input_24h_time' => array(
570
+ 'type' => 'bool',
571
+ 'renderer' => array(
572
+ 'class' => 'checkbox',
573
+ 'tab' => 'editing-events',
574
+ 'label' => Ai1ec_I18n::__(
575
+ ' Use <strong>24h time</strong> in time pickers'
576
+ )
577
+ ),
578
+ 'default' => false,
579
+ ),
580
+ 'disable_autocompletion' => array(
581
+ 'type' => 'bool',
582
+ 'renderer' => array(
583
+ 'class' => 'checkbox',
584
+ 'tab' => 'editing-events',
585
+ 'label' => Ai1ec_I18n::__(
586
+ '<strong>Disable address autocomplete</strong> function'
587
+ )
588
+ ),
589
+ 'default' => false,
590
+ ),
591
+ 'geo_region_biasing' => array(
592
+ 'type' => 'bool',
593
+ 'renderer' => array(
594
+ 'class' => 'checkbox',
595
+ 'tab' => 'editing-events',
596
+ 'label' => Ai1ec_I18n::__(
597
+ 'Use the configured <strong>region</strong> (WordPress locale) to bias the address autocomplete function '
598
+ )
599
+ ),
600
+ 'default' => false,
601
+ ),
602
+ 'show_publish_button' => array(
603
+ 'type' => 'bool',
604
+ 'renderer' => array(
605
+ 'class' => 'checkbox',
606
+ 'tab' => 'editing-events',
607
+ 'label' => Ai1ec_I18n::__(
608
+ 'Display <strong>Publish</strong> at bottom of Edit Event form'
609
+ )
610
+ ),
611
+ 'default' => false,
612
+ ),
613
+ 'show_create_event_button' => array(
614
+ 'type' => 'bool',
615
+ 'renderer' => array(
616
+ 'class' => 'checkbox',
617
+ 'tab' => 'editing-events',
618
+ 'label' => Ai1ec_I18n::__(
619
+ ' Show the old <strong>Post Your Event</strong> button above the calendar to privileged users'
620
+ ),
621
+ 'help' => Ai1ec_I18n::__(
622
+ 'Install the <a target="_blank" href="http://time.ly/">Interactive Frontend Extension</a> for the <strong>frontend Post Your Event form</strong>.'
623
+ ),
624
+ ),
625
+ 'default' => false,
626
+ ),
627
+ 'calendar_css_selector' => array(
628
+ 'type' => 'string',
629
+ 'renderer' => array(
630
+ 'class' => 'input',
631
+ 'tab' => 'advanced',
632
+ 'item' => 'advanced',
633
+ 'label' => Ai1ec_I18n::__( 'Move calendar into this DOM element' ),
634
+ 'type' => 'normal',
635
+ 'help' => Ai1ec_I18n::__(
636
+ 'Optional. Use this JavaScript-based shortcut to place the
637
+ calendar a DOM element other than the usual page content container
638
+ if you are unable to create an appropriate page template
639
+ for the calendar page. To use, enter a
640
+ <a target="_blank" href="http://api.jquery.com/category/selectors/">
641
+ jQuery selector</a> that evaluates to a single DOM element.
642
+ Any existing markup found within the target will be replaced
643
+ by the calendar.'
644
+ ),
645
+ ),
646
+ 'default' => '',
647
+ ),
648
+ 'skip_in_the_loop_check' => array(
649
+ 'type' => 'bool',
650
+ 'renderer' => array(
651
+ 'class' => 'checkbox',
652
+ 'tab' => 'advanced',
653
+ 'item' => 'advanced',
654
+ 'label' => Ai1ec_I18n::__(
655
+ '<strong>Skip <tt>in_the_loop()</tt> check </strong> that protects against multiple calendar output'
656
+ ),
657
+ 'help' => Ai1ec_I18n::__(
658
+ 'Try enabling this option if your calendar does not appear on the calendar page. It is needed for compatibility with a small number of themes that call <tt>the_content()</tt> from outside of The Loop. Leave disabled otherwise.'
659
+ ),
660
+ ),
661
+ 'default' => false,
662
+ ),
663
+ 'disable_gzip_compression' => array(
664
+ 'type' => 'bool',
665
+ 'renderer' => array(
666
+ 'class' => 'checkbox',
667
+ 'tab' => 'advanced',
668
+ 'item' => 'advanced',
669
+ 'label' => Ai1ec_I18n::__(
670
+ 'Disable <strong>gzip</strong> compression.'
671
+ ),
672
+ 'help' => Ai1ec_I18n::__(
673
+ 'Use this option if calendar is non-responsive. <a href="http://support.time.ly/disable-gzip-compression/">Read more</a> about the issue.'
674
+ ),
675
+ ),
676
+ 'default' => false,
677
+ ),
678
+ 'edit_robots_txt' => array(
679
+ 'type' => 'string',
680
+ 'renderer' => array(
681
+ 'class' => 'textarea',
682
+ 'tab' => 'advanced',
683
+ 'item' => 'advanced',
684
+ 'label' => Ai1ec_I18n::__( 'Current <strong>robots.txt</strong> on this site' ),
685
+ 'type' => 'normal',
686
+ 'rows' => 6,
687
+ 'readonly' => 'readonly',
688
+ 'help' => Ai1ec_I18n::__(
689
+ 'The Robot Exclusion Standard, also known as the Robots Exclusion Protocol or
690
+ <code><a href="http://en.wikipedia.org/wiki/Robots.txt" target="_blank">robots.txt</a></code>
691
+ protocol, is a convention for cooperating web crawlers and other web robots
692
+ about accessing all or part of a website that is otherwise publicly viewable.
693
+ You can change it manually by editing <code>robots.txt</code> in your root WordPress directory.'
694
+ ),
695
+ ),
696
+ 'default' => '',
697
+ ),
698
+ 'allow_statistics' => array(
699
+ 'type' => 'bool',
700
+ 'renderer' => array(
701
+ 'class' => 'checkbox',
702
+ 'tab' => 'advanced',
703
+ 'item' => 'advanced',
704
+ 'label' => sprintf(
705
+ Ai1ec_I18n::__(
706
+ '<strong>Publicize, promote, and share my events</strong> marked as public on the Timely network. (<a href="%s" target="_blank">Learn more »</a>)'
707
+ ),
708
+ 'http://time.ly/event-search-calendar'
709
+ ),
710
+ ),
711
+ 'default' => false,
712
+ ),
713
+ 'legacy_options' => array(
714
+ 'type' => 'legacy_options',
715
+ 'default' => null,
716
+ ),
717
+ 'ics_cron_freq' => array(
718
+ 'type' => 'string',
719
+ 'default' => 'hourly',
720
+ ),
721
+ 'twig_cache' => array(
722
+ 'type' => 'string',
723
+ 'renderer' => array(
724
+ 'class' => 'cache',
725
+ 'tab' => 'advanced',
726
+ 'item' => 'cache',
727
+ 'label' => sprintf(
728
+ Ai1ec_I18n::__(
729
+ 'Templates cache improves site performance'
730
+ )
731
+ ),
732
+ ),
733
+ 'default' => '',
734
+ )
735
+ );
736
+ }
737
+
738
+ /**
739
+ * Register the standard setting values.
740
+ *
741
+ * @return void Method doesn't return.
742
+ */
743
+ protected function _register_standard_values() {
744
+ foreach ( $this->_standard_options as $key => $option ) {
745
+ $renderer = null;
746
+ $value = $option['default'];
747
+ if ( isset( $option['renderer'] ) ) {
748
+ $renderer = $option['renderer'];
749
+ }
750
+ $this->register(
751
+ $key,
752
+ $value,
753
+ $option['type'],
754
+ $renderer,
755
+ AI1EC_VERSION
756
+ );
757
+ }
758
+ }
759
+
760
+ /**
761
+ * Change `updated` flag value.
762
+ *
763
+ * @param bool $new_status Status to change to.
764
+ *
765
+ * @return bool Previous status flag value.
766
+ */
767
+ protected function _change_update_status( $new_status ) {
768
+ $previous = $this->_updated;
769
+ $this->_updated = (bool)$new_status;
770
+ return $previous;
771
+ }
772
+
773
+ }
app/model/settings/exception.php ADDED
@@ -0,0 +1,12 @@
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * Exception occuring during settings modification.
5
+ *
6
+ * @author Time.ly Network, Inc.
7
+ * @since 2.0
8
+ * @package Ai1EC
9
+ * @subpackage Ai1EC.Html
10
+ */
11
+ class Ai1ec_Settings_Exception extends Ai1ec_Exception {
12
+ }
app/model/taxonomy.php ADDED
@@ -0,0 +1,79 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * Model used for storing/retrieving taxonomy.
5
+ *
6
+ * @author Time.ly Network, Inc.
7
+ * @since 2.0
8
+ * @package Ai1EC
9
+ * @subpackage Ai1EC.Html
10
+ */
11
+ class Ai1ec_Taxonomy extends Ai1ec_Base {
12
+
13
+ /**
14
+ * Re-fetch category entries map from database.
15
+ *
16
+ * @return array Map of category entries.
17
+ */
18
+ public function fetch_category_map() {
19
+ $category_map = array();
20
+ $records = (array)$this->_registry->get( 'dbi.dbi' )->select(
21
+ 'ai1ec_event_category_meta',
22
+ array( 'term_id', 'term_image', 'term_color' )
23
+ );
24
+ foreach ( $records as $row ) {
25
+ $image = $color = null;
26
+ if ( $row->term_image ) {
27
+ $image = $row->term_image;
28
+ }
29
+ if ( $row->term_color ) {
30
+ $color = $row->term_color;
31
+ }
32
+ $category_map[(int)$row->term_id] = compact( 'image', 'color' );
33
+ }
34
+ return $category_map;
35
+ }
36
+
37
+ /**
38
+ * Get cached category description field.
39
+ *
40
+ * @param int $term_id Category ID.
41
+ * @param string $field Name of field, one of 'image', 'color'.
42
+ *
43
+ * @return string|null Field value or null if entry is not found.
44
+ */
45
+ public function get_category_field( $term_id, $field ) {
46
+ static $category_meta = null;
47
+ if ( null === $category_meta ) {
48
+ $category_meta = $this->fetch_category_map();
49
+ }
50
+ $term_id = (int)$term_id;
51
+ if ( ! isset( $category_meta[$term_id] ) ) {
52
+ return null;
53
+ }
54
+ return $category_meta[$term_id][$field];
55
+ }
56
+
57
+ /**
58
+ * Returns the color of the Event Category having the given term ID.
59
+ *
60
+ * @param int $term_id The ID of the Event Category.
61
+ *
62
+ * @return string|null Color to use
63
+ */
64
+ public function get_category_color( $term_id ) {
65
+ return $this->get_category_field( $term_id, 'color' );
66
+ }
67
+
68
+ /**
69
+ * Returns the image of the Event Category having the given term ID.
70
+ *
71
+ * @param int $term_id The ID of the Event Category.
72
+ *
73
+ * @return string|null Image url to use.
74
+ */
75
+ public function get_category_image( $term_id ) {
76
+ return $this->get_category_field( $term_id, 'image' );
77
+ }
78
+
79
+ }
app/view/admin/abstract.php ADDED
@@ -0,0 +1,34 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * The abstract class for a admin page.
5
+ *
6
+ * @author Time.ly Network Inc.
7
+ * @since 2.0
8
+ *
9
+ * @package AI1EC
10
+ * @subpackage AI1EC.View
11
+ */
12
+ abstract class Ai1ec_View_Admin_Abstract extends Ai1ec_Base {
13
+
14
+ /**
15
+ * Adds the page to the correct menu.
16
+ */
17
+ abstract public function add_page();
18
+
19
+ /**
20
+ * Adds the page to the correct menu.
21
+ */
22
+ abstract public function add_meta_box();
23
+
24
+ /**
25
+ * Display the page html
26
+ */
27
+ abstract public function display_page();
28
+
29
+ /**
30
+ * Handle post, likely to be deprecated to use commands.
31
+ */
32
+ abstract public function handle_post();
33
+
34
+ }
app/view/admin/add-new-event.php ADDED
@@ -0,0 +1,348 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * Event create/update form backend view layer.
5
+ *
6
+ * Manage creation of boxes (containers) for our control elements
7
+ * and instantiating, as well as updating them.
8
+ *
9
+ * @author Time.ly Network, Inc.
10
+ * @since 2.0
11
+ * @package Ai1EC
12
+ * @subpackage Ai1EC.View
13
+ */
14
+ class Ai1ec_View_Add_New_Event extends Ai1ec_Base {
15
+
16
+ /**
17
+ * Create hook to display event meta box when creating or editing an event.
18
+ *
19
+ * @wp_hook add_meta_boxes
20
+ *
21
+ * @return void
22
+ */
23
+ public function event_meta_box_container() {
24
+ add_meta_box(
25
+ AI1EC_POST_TYPE,
26
+ Ai1ec_I18n::__( 'Event Details' ),
27
+ array( $this, 'meta_box_view' ),
28
+ AI1EC_POST_TYPE,
29
+ 'normal',
30
+ 'high'
31
+ );
32
+ }
33
+
34
+ /**
35
+ * Add Event Details meta box to the Add/Edit Event screen in the dashboard.
36
+ *
37
+ * @return void
38
+ */
39
+ public function meta_box_view() {
40
+
41
+ $theme_loader = $this->_registry->get( 'theme.loader' );
42
+ $empty_event = $this->_registry->get( 'model.event' );
43
+
44
+ // ==================
45
+ // = Default values =
46
+ // ==================
47
+ // ATTENTION - When adding new fields to the event remember that you must
48
+ // also set up the duplicate-controller.
49
+ // TODO: Fix this duplication.
50
+ $all_day_event = '';
51
+ $instant_event = '';
52
+ $start = $this->_registry->get( 'date.time' );
53
+ $end = $this->_registry->get( 'date.time', '+1 hour' );
54
+ $timezone_name = null;
55
+ $show_map = false;
56
+ $google_map = '';
57
+ $venue = '';
58
+ $country = '';
59
+ $address = '';
60
+ $city = '';
61
+ $province = '';
62
+ $postal_code = '';
63
+ $contact_name = '';
64
+ $contact_phone = '';
65
+ $contact_email = '';
66
+ $contact_url = '';
67
+ $cost = '';
68
+ $is_free = '';
69
+ $rrule = '';
70
+ $rrule_text = '';
71
+ $repeating_event = false;
72
+ $exrule = '';
73
+ $exrule_text = '';
74
+ $exclude_event = false;
75
+ $exdate = '';
76
+ $show_coordinates = false;
77
+ $longitude = '';
78
+ $latitude = '';
79
+ $coordinates = '';
80
+ $ticket_url = '';
81
+
82
+ $instance_id = false;
83
+ if ( isset( $_REQUEST['instance'] ) ) {
84
+ $instance_id = absint( $_REQUEST['instance'] );
85
+ }
86
+ if ( $instance_id ) {
87
+ add_filter(
88
+ 'print_scripts_array',
89
+ array( $this, 'disable_autosave' )
90
+ );
91
+ }
92
+
93
+ try {
94
+ // on some php version, nested try catch blocks fail and the exception would never be caught.
95
+ // this is why we use this approach.
96
+ $excpt = null;
97
+ $event = null;
98
+ try {
99
+ $event = $this->_registry->get(
100
+ 'model.event',
101
+ get_the_ID(),
102
+ $instance_id
103
+ );
104
+ } catch ( Ai1ec_Event_Not_Found $excpt ) {
105
+ $ai1ec_localization_helper = $this->_registry
106
+ ->get( 'p28n.wpml' );
107
+ $translatable_id = $ai1ec_localization_helper
108
+ ->get_translatable_id();
109
+ if ( false !== $translatable_id ) {
110
+ $event = $this->_registry->get(
111
+ 'model.event',
112
+ $translatable_id,
113
+ $instance_id
114
+ );
115
+ }
116
+ }
117
+ if ( null !== $excpt ) {
118
+ throw $excpt;
119
+ }
120
+
121
+ // Existing event was found. Initialize form values with values from
122
+ // event object.
123
+ $all_day_event = $event->is_allday() ? 'checked' : '';
124
+ $instant_event = $event->is_instant() ? 'checked' : '';
125
+
126
+ $start = $event->get( 'start' );
127
+ $end = $event->get( 'end' );
128
+ $timezone_name = $event->get( 'timezone_name' );
129
+
130
+ $multi_day = $event->is_multiday();
131
+
132
+ $show_map = $event->get( 'show_map' );
133
+ $google_map = $show_map ? 'checked="checked"' : '';
134
+
135
+ $show_coordinates = $event->get( 'show_coordinates' );
136
+ $coordinates = $show_coordinates ? 'checked="checked"' : '';
137
+ $longitude = (float)$event->get( 'longitude', 0 );
138
+ $latitude = (float)$event->get( 'latitude', 0 );
139
+ // There is a known bug in Wordpress (https://core.trac.wordpress.org/ticket/15158) that saves 0 to the DB instead of null.
140
+ // We handle a special case here to avoid having the fields with a value of 0 when the user never inputted any coordinates
141
+ if ( ! $show_coordinates ) {
142
+ $longitude = '';
143
+ $latitude = '';
144
+ }
145
+
146
+ $venue = $event->get( 'venue' );
147
+ $country = $event->get( 'country' );
148
+ $address = $event->get( 'address' );
149
+ $city = $event->get( 'city' );
150
+ $province = $event->get( 'province' );
151
+ $postal_code = $event->get( 'postal_code' );
152
+ $contact_name = $event->get( 'contact_name' );
153
+ $contact_phone = $event->get( 'contact_phone' );
154
+ $contact_email = $event->get( 'contact_email' );
155
+ $contact_url = $event->get( 'contact_url' );
156
+ $cost = $event->get( 'cost' );
157
+ $ticket_url = $event->get( 'ticket_url' );
158
+ $rrule = $event->get( 'recurrence_rules' );
159
+ $exrule = $event->get( 'exception_rules' );
160
+ $exdate = $event->get( 'exception_dates' );
161
+ $repeating_event = ! empty( $rrule );
162
+ $exclude_event = ! empty( $exrule );
163
+
164
+ $is_free = '';
165
+ $free = $event->is_free();
166
+ if ( ! empty( $free ) ) {
167
+ $is_free = 'checked="checked" ';
168
+ $cost = '';
169
+ }
170
+
171
+ if ( $repeating_event ) {
172
+ $rrule_text = ucfirst(
173
+ $this->_registry->get( 'recurrence.rule' )
174
+ ->rrule_to_text( $rrule )
175
+ );
176
+ }
177
+
178
+ if ( $exclude_event ) {
179
+ $exrule_text = ucfirst(
180
+ $this->_registry->get( 'recurrence.rule' )
181
+ ->rrule_to_text( $exrule )
182
+ );
183
+ }
184
+ } catch ( Ai1ec_Event_Not_Found_Exception $excpt ) {
185
+ // Event does not exist.
186
+ // Leave form fields undefined (= zero-length strings)
187
+ $event = null;
188
+ }
189
+
190
+ // Time zone; display if set.
191
+ $timezone = '';
192
+
193
+ $timezone_string = $this->_registry->get( 'date.timezone' )
194
+ ->get_default_timezone();
195
+
196
+ if ( $timezone_string ) {
197
+ $timezone = $this->_registry->get( 'date.system' )
198
+ ->get_gmt_offset_expr();
199
+ }
200
+
201
+ if ( empty( $timezone_name ) ) {
202
+ /**
203
+ * Actual Olsen timezone name is used when value is to be directly
204
+ * exposed to user in some mean. It's possible to use named const.
205
+ * `'sys.default'` only when passing value to date.time library.
206
+ */
207
+ $timezone_name = $this->_registry->get( 'date.timezone' )
208
+ ->get_default_timezone();
209
+ }
210
+
211
+ // This will store each of the accordion tabs' markup, and passed as an
212
+ // argument to the final view.
213
+ $boxes = array();
214
+
215
+ // ===============================
216
+ // = Display event time and date =
217
+ // ===============================
218
+ $args = array(
219
+ 'all_day_event' => $all_day_event,
220
+ 'instant_event' => $instant_event,
221
+ 'start' => $start,
222
+ 'end' => $end,
223
+ 'repeating_event' => $repeating_event,
224
+ 'rrule' => $rrule,
225
+ 'rrule_text' => $rrule_text,
226
+ 'exclude_event' => $exclude_event,
227
+ 'exrule' => $exrule,
228
+ 'exrule_text' => $exrule_text,
229
+ 'timezone' => $timezone,
230
+ 'timezone_string' => $timezone_string,
231
+ 'timezone_name' => $timezone_name,
232
+ 'exdate' => $exdate,
233
+ 'instance_id' => $instance_id,
234
+ );
235
+
236
+ $boxes[] = $theme_loader
237
+ ->get_file( 'box_time_and_date.php', $args, true )
238
+ ->get_content();
239
+
240
+ // =================================================
241
+ // = Display event location details and Google map =
242
+ // =================================================
243
+ $args = array(
244
+ 'select_venue' => apply_filters( 'ai1ec_admin_pre_venue_html', '' ),
245
+ 'save_venue' => apply_filters( 'ai1ec_admin_post_venue_html', '' ),
246
+ 'venue' => $venue,
247
+ 'country' => $country,
248
+ 'address' => $address,
249
+ 'city' => $city,
250
+ 'province' => $province,
251
+ 'postal_code' => $postal_code,
252
+ 'google_map' => $google_map,
253
+ 'show_map' => $show_map,
254
+ 'show_coordinates' => $show_coordinates,
255
+ 'longitude' => $longitude,
256
+ 'latitude' => $latitude,
257
+ 'coordinates' => $coordinates,
258
+ );
259
+ $boxes[] = $theme_loader
260
+ ->get_file( 'box_event_location.php', $args, true )
261
+ ->get_content();
262
+
263
+ // ======================
264
+ // = Display event cost =
265
+ // ======================
266
+ $args = array(
267
+ 'cost' => $cost,
268
+ 'is_free' => $is_free,
269
+ 'ticket_url' => $ticket_url,
270
+ 'event' => $empty_event,
271
+ );
272
+ $boxes[] = $theme_loader
273
+ ->get_file( 'box_event_cost.php', $args, true )
274
+ ->get_content();
275
+
276
+
277
+
278
+ // =========================================
279
+ // = Display organizer contact information =
280
+ // =========================================
281
+ $args = array(
282
+ 'contact_name' => $contact_name,
283
+ 'contact_phone' => $contact_phone,
284
+ 'contact_email' => $contact_email,
285
+ 'contact_url' => $contact_url,
286
+ 'event' => $empty_event,
287
+ );
288
+ $boxes[] = $theme_loader
289
+ ->get_file( 'box_event_contact.php', $args, true )
290
+ ->get_content();
291
+
292
+ // ==================
293
+ // = Publish button =
294
+ // ==================
295
+ $publish_button = '';
296
+ if (
297
+ $this->_registry->get( 'model.settings' )
298
+ ->get( 'show_publish_button' )
299
+ ) {
300
+ $args = array();
301
+ $post_type_object = get_post_type_object(
302
+ get_post()->post_type
303
+ );
304
+ if ( current_user_can( $post_type_object->cap->publish_posts ) ) {
305
+ $args['button_value'] = is_null( $event )
306
+ ? Ai1ec_I18n::__( 'Publish' )
307
+ : Ai1ec_I18n::__( 'Update' );
308
+ } else {
309
+ $args['button_value'] = Ai1ec_I18n::__( 'Submit for Review' );
310
+ }
311
+
312
+ $boxes[] = $theme_loader
313
+ ->get_file( 'box_publish_button.php', $args, true )
314
+ ->get_content();
315
+
316
+ }
317
+
318
+ // Display the final view of the meta box.
319
+ $args = array(
320
+ 'boxes' => $boxes,
321
+ 'publish_button' => $publish_button,
322
+ );
323
+
324
+ echo $theme_loader
325
+ ->get_file( 'add_new_event_meta_box.php', $args, true )
326
+ ->get_content();
327
+ }
328
+
329
+ /**
330
+ * disable_autosave method
331
+ *
332
+ * Callback to disable autosave script
333
+ *
334
+ * @param array $input List of scripts registered
335
+ *
336
+ * @return array Modified scripts list
337
+ */
338
+ public function disable_autosave( array $input ) {
339
+ wp_deregister_script( 'autosave' );
340
+ $autosave_key = array_search( 'autosave', $input );
341
+ if ( false === $autosave_key || ! is_scalar( $autosave_key ) ) {
342
+ unset( $input[$autosave_key] );
343
+ }
344
+ return $input;
345
+ }
346
+
347
+
348
+ }
app/view/admin/admin_notices.php DELETED
@@ -1,10 +0,0 @@
1
- <div class="message updated">
2
- <?php if ( isset( $label ) && ! empty( $label ) ) : ?>
3
- <h3><?php echo $label; ?></h3>
4
- <?php endif; ?>
5
- <?php echo $msg; ?>
6
- <?php if ( isset( $button ) ) : ?>
7
- <div><input type="button" class="button <?php echo $button->class ?>" value="<?php echo $button->value ?>" /></div>
8
- <p></p>
9
- <?php endif ?>
10
- </div>
 
 
 
 
 
 
 
 
 
 
app/view/admin/agenda-widget-form.php DELETED
@@ -1,69 +0,0 @@
1
- <p>
2
- <label for="<?php echo $title['id'] ?>"><?php _e( 'Title:', AI1EC_PLUGIN_NAME ) ?></label>
3
- <input class="widefat" id="<?php echo $title['id'] ?>" name="<?php echo $title['name'] ?>" type="text" value="<?php echo $title['value'] ?>" />
4
- </p>
5
- <p>
6
- <label for="<?php echo $events_per_page['id'] ?>"><?php _e( 'Number of events to show:', AI1EC_PLUGIN_NAME ) ?></label>
7
- <input id="<?php echo $events_per_page['id'] ?>" name="<?php echo $events_per_page['name'] ?>" type="text" size="3" value="<?php echo $events_per_page['value'] ?>" />
8
- </p>
9
- <p class="ai1ec-limit-by-container">
10
- Limit to:
11
- <br />
12
- <!-- Limit by Category -->
13
- <input id="<?php echo $limit_by_cat['id'] ?>" class="ai1ec-limit-by-cat" name="<?php echo $limit_by_cat['name'] ?>" type="checkbox" value="1" <?php if( $limit_by_cat['value'] ) echo 'checked="checked"' ?> />
14
- <label for="<?php echo $limit_by_cat['id'] ?>"><?php _e( 'Events with these <strong>Categories</strong>', AI1EC_PLUGIN_NAME ) ?></label>
15
- </p>
16
- <div class="ai1ec-limit-by-options-container" <?php if( ! $limit_by_cat['value'] ) { ?> style="display: none;" <?php } ?>>
17
- <!-- Limit by Category Select box -->
18
- <select id="<?php echo $event_cat_ids['id'] ?>" class="ai1ec-widget-cat-ids" name="<?php echo $event_cat_ids['name'] ?>[]" size="5" multiple="multiple">
19
- <?php foreach( $event_cat_ids['options'] as $event_cat ): ?>
20
- <option value="<?php echo $event_cat->term_id; ?>"<?php if( in_array( $event_cat->term_id, $event_cat_ids['value'] ) ) { ?> selected="selected"<?php } ?>><?php echo $event_cat->name; ?></option>
21
- <?php endforeach ?>
22
- <?php if( count( $event_cat_ids['options'] ) == 0 ) : ?>
23
- <option disabled="disabled"><?php _e( 'No categories found.', AI1EC_PLUGIN_NAME ) ?></option>
24
- <?php endif ?>
25
- </select>
26
- </div>
27
- <p class="ai1ec-limit-by-container">
28
- <!-- Limit by Tag -->
29
- <input id="<?php echo $limit_by_tag['id'] ?>" class="ai1ec-limit-by-tag" name="<?php echo $limit_by_tag['name'] ?>" type="checkbox" value="1" <?php if( $limit_by_tag['value'] ) echo 'checked="checked"' ?> />
30
- <label for="<?php echo $limit_by_tag['id'] ?>"><?php _e( '<strong>Or</strong> events with these <strong>Tags</strong>', AI1EC_PLUGIN_NAME ) ?></label>
31
- </p>
32
- <div class="ai1ec-limit-by-options-container" <?php if( ! $limit_by_tag['value'] ) { ?> style="display: none;" <?php } ?>>
33
- <!-- Limit by Tag Select box -->
34
- <select id="<?php echo $event_tag_ids['id'] ?>" class="ai1ec-widget-tag-ids" name="<?php echo $event_tag_ids['name'] ?>[]" size="5" multiple="multiple">
35
- <?php foreach( $event_tag_ids['options'] as $event_tag ): ?>
36
- <option value="<?php echo $event_tag->term_id; ?>"<?php if( in_array( $event_tag->term_id, $event_tag_ids['value'] ) ) { ?> selected="selected"<?php } ?>><?php echo $event_tag->name; ?></option>
37
- <?php endforeach ?>
38
- <?php if( count( $event_tag_ids['options'] ) == 0 ) : ?>
39
- <option disabled="disabled"><?php _e( 'No tags found.', AI1EC_PLUGIN_NAME ) ?></option>
40
- <?php endif ?>
41
- </select>
42
- </div>
43
- <p class="ai1ec-limit-by-container">
44
- <!-- Limit by Event -->
45
- <input id="<?php echo $limit_by_post['id'] ?>" class="ai1ec-limit-by-event" name="<?php echo $limit_by_post['name'] ?>" type="checkbox" value="1" <?php if( $limit_by_post['value'] ) echo 'checked="checked"' ?> />
46
- <label for="<?php echo $limit_by_post['id'] ?>"><?php _e( '<strong>Or</strong> any of these <strong>Events</strong>', AI1EC_PLUGIN_NAME ) ?></label>
47
- </p>
48
- <div class="ai1ec-limit-by-options-container" <?php if( ! $limit_by_post['value'] ) { ?> style="display: none;" <?php } ?>>
49
- <!-- Limit by Event Select box -->
50
- <select id="<?php echo $event_post_ids['id'] ?>" class="ai1ec-widget-event-ids" name="<?php echo $event_post_ids['name'] ?>[]" size="5" multiple="multiple">
51
- <?php foreach( $event_post_ids['options'] as $event_post ): ?>
52
- <option value="<?php echo $event_post->ID; ?>"<?php if( in_array( $event_post->ID, $event_post_ids['value'] ) ) { ?> selected="selected"<?php } ?>><?php echo $event_post->post_title; ?></option>
53
- <?php endforeach ?>
54
- <?php if( count( $event_post_ids['options'] ) == 0 ) : ?>
55
- <option disabled="disabled"><?php _e( 'No events found.', AI1EC_PLUGIN_NAME ) ?></option>
56
- <?php endif ?>
57
- </select>
58
- </div>
59
- <br />
60
- <p>
61
- <input id="<?php echo $show_calendar_button['id'] ?>" name="<?php echo $show_calendar_button['name'] ?>" type="checkbox" value="1" <?php if( $show_calendar_button['value'] ) echo 'checked="checked"' ?> />
62
- <label for="<?php echo $show_calendar_button['id'] ?>"><?php _e( 'Show <strong>View Calendar</strong> button', AI1EC_PLUGIN_NAME ) ?></label>
63
- <br />
64
- <input id="<?php echo $show_subscribe_buttons['id'] ?>" name="<?php echo $show_subscribe_buttons['name'] ?>" type="checkbox" value="1" <?php if( $show_subscribe_buttons['value'] ) echo 'checked="checked"' ?> />
65
- <label for="<?php echo $show_subscribe_buttons['id'] ?>"><?php _e( 'Show <strong>Subscribe</strong> buttons', AI1EC_PLUGIN_NAME ) ?></label>
66
- <br />
67
- <input id="<?php echo $hide_on_calendar_page['id'] ?>" name="<?php echo $hide_on_calendar_page['name'] ?>" type="checkbox" value="1" <?php if( $hide_on_calendar_page['value'] ) echo 'checked="checked"' ?> />
68
- <label for="<?php echo $hide_on_calendar_page['id'] ?>"><?php _e( 'Hide this widget on calendar page', AI1EC_PLUGIN_NAME ) ?></label>
69
- </p>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/view/admin/all-events.php ADDED
@@ -0,0 +1,151 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Ai1ec_View_Admin_All_Events extends Ai1ec_Base {
4
+
5
+ /**
6
+ * change_columns function
7
+ *
8
+ * Adds Event date/time column to our custom post type
9
+ * and renames Date column to Post Date
10
+ *
11
+ * @param array $columns Existing columns
12
+ *
13
+ * @return array Updated columns array
14
+ */
15
+ public function change_columns( array $columns = array() ) {
16
+ $columns['author'] = __( 'Author', AI1EC_PLUGIN_NAME );
17
+ $columns['date'] = __( 'Post Date', AI1EC_PLUGIN_NAME );
18
+ $columns['ai1ec_event_date'] = __( 'Event date/time', AI1EC_PLUGIN_NAME );
19
+ return $columns;
20
+ }
21
+
22
+ /**
23
+ * orderby function
24
+ *
25
+ * Orders events by event date
26
+ *
27
+ * @param string $orderby Orderby sql
28
+ * @param object $wp_query
29
+ *
30
+ * @return void
31
+ **/
32
+ public function orderby( $orderby, $wp_query ) {
33
+
34
+ $db = $this->_registry->get( 'dbi.dbi' );
35
+ $aco = $this->_registry->get( 'acl.aco' );
36
+
37
+ if( true === $aco->is_all_events_page() ) {
38
+ $wp_query->query = wp_parse_args( $wp_query->query );
39
+ $table_name = $db->get_table_name( 'ai1ec_events' );
40
+ $posts = $db->get_table_name( 'posts' );
41
+ if( isset( $wp_query->query['orderby'] ) && 'ai1ec_event_date' === @$wp_query->query['orderby'] ) {
42
+ $orderby = "(SELECT start FROM {$table_name} WHERE post_id = {$posts}.ID) " . $wp_query->get('order');
43
+ } else if( empty( $wp_query->query['orderby'] ) || $wp_query->query['orderby'] === 'menu_order title' ) {
44
+ $orderby = "(SELECT start FROM {$table_name} WHERE post_id = {$posts}.ID) " . 'desc';
45
+ }
46
+ }
47
+ return $orderby;
48
+ }
49
+
50
+ /**
51
+ * custom_columns function
52
+ *
53
+ * Adds content for custom columns
54
+ *
55
+ * @return void
56
+ **/
57
+ public function custom_columns( $column, $post_id ) {
58
+ if ( 'ai1ec_event_date' === $column ) {
59
+ try {
60
+ $event = $this->_registry->get( 'model.event', $post_id );
61
+ $time = $this->_registry->get( 'view.event.time' );
62
+ echo $time->get_timespan_html( $event );
63
+ } catch( Exception $e ) {
64
+ // event wasn't found, output empty string
65
+ echo '';
66
+ }
67
+ }
68
+ }
69
+
70
+ /**
71
+ * sortable_columns function
72
+ *
73
+ * Enable sorting of columns
74
+ *
75
+ * @return void
76
+ **/
77
+ public function sortable_columns( $columns ) {
78
+ $columns["ai1ec_event_date"] = 'ai1ec_event_date';
79
+ return $columns;
80
+ }
81
+
82
+ /**
83
+ * taxonomy_filter_restrict_manage_posts function
84
+ *
85
+ * Adds filter dropdowns for event categories and event tags
86
+ *
87
+ * @return void
88
+ **/
89
+ function taxonomy_filter_restrict_manage_posts() {
90
+ global $typenow;
91
+
92
+ // =============================================
93
+ // = add the dropdowns only on the events page =
94
+ // =============================================
95
+ if( $typenow === AI1EC_POST_TYPE ) {
96
+ $filters = get_object_taxonomies( $typenow );
97
+ foreach( $filters as $tax_slug ) {
98
+ $tax_obj = get_taxonomy( $tax_slug );
99
+ wp_dropdown_categories( array(
100
+ 'show_option_all' => __( 'Show All ', AI1EC_PLUGIN_NAME ) . $tax_obj->label,
101
+ 'taxonomy' => $tax_slug,
102
+ 'name' => $tax_obj->name,
103
+ 'orderby' => 'name',
104
+ 'selected' => isset( $_GET[$tax_slug] ) ? $_GET[$tax_slug] : '',
105
+ 'hierarchical' => $tax_obj->hierarchical,
106
+ 'show_count' => true,
107
+ 'hide_if_empty' => true
108
+ ));
109
+ }
110
+ }
111
+ }
112
+
113
+ /**
114
+ * taxonomy_filter_post_type_request function
115
+ *
116
+ * Adds filtering of events list by event tags and event categories
117
+ *
118
+ * @return void
119
+ **/
120
+ function taxonomy_filter_post_type_request( $query ) {
121
+ global $pagenow, $typenow;
122
+ if( 'edit.php' === $pagenow ) {
123
+ $filters = get_object_taxonomies( $typenow );
124
+ foreach( $filters as $tax_slug ) {
125
+ $var = &$query->query_vars[$tax_slug];
126
+ if( isset( $var ) ) {
127
+ $term = null;
128
+
129
+ if( is_numeric( $var ) ) {
130
+ $term = get_term_by( 'id', $var, $tax_slug );
131
+ } else {
132
+ $term = get_term_by( 'slug', $var, $tax_slug );
133
+ }
134
+
135
+ if( isset( $term->slug ) ) {
136
+ $var = $term->slug;
137
+ }
138
+ }
139
+ }
140
+ }
141
+ // ===========================
142
+ // = Order by Event date ASC =
143
+ // ===========================
144
+ if( 'ai1ec_event' === $typenow ) {
145
+ if ( ! array_key_exists( 'orderby', $query->query_vars ) ) {
146
+ $query->query_vars['orderby'] = 'ai1ec_event_date';
147
+ $query->query_vars['order'] = 'desc';
148
+ }
149
+ }
150
+ }
151
+ }
app/view/admin/box_advanced_settings.php DELETED
@@ -1,9 +0,0 @@
1
- <?php do_action( 'ai1ec_advanced_settings_before' ); ?>
2
-
3
- <label class="textinput" for="calendar_css_selector"><?php _e( 'Contain calendar in this DOM element:', AI1EC_PLUGIN_NAME ) ?></label>
4
- <input name="calendar_css_selector" id="calendar_css_selector" type="text" size="20" value="<?php echo esc_attr( $calendar_css_selector ) ?>" />
5
- <div class="description"><?php _e( 'Optional. Provide a <a href="http://api.jquery.com/category/selectors/" target="_blank">jQuery selector</a> that evaluates to a single DOM element. Replaces any existing markup found within target. If left empty, calendar is shown in normal page content container.', AI1EC_PLUGIN_NAME ) ?></div>
6
-
7
- <div class="clear"></div>
8
-
9
- <?php do_action( 'ai1ec_advanced_settings_after' ); ?>
 
 
 
 
 
 
 
 
 
app/view/admin/box_event_contact.php DELETED
@@ -1,35 +0,0 @@
1
- <h4 class="ai1ec-section-title"><?php _e( 'Organizer contact info', AI1EC_PLUGIN_NAME ); ?></h4>
2
- <table class="ai1ec-form">
3
- <tbody>
4
- <tr>
5
- <td class="ai1ec-first">
6
- <label for="ai1ec_contact_name">
7
- <?php _e( 'Contact name:', AI1EC_PLUGIN_NAME ); ?>
8
- </label>
9
- </td>
10
- <td>
11
- <input type="text" name="ai1ec_contact_name" id="ai1ec_contact_name" value="<?php echo $contact_name; ?>" />
12
- </td>
13
- </tr>
14
- <tr>
15
- <td>
16
- <label for="ai1ec_contact_phone">
17
- <?php _e( 'Phone:', AI1EC_PLUGIN_NAME ); ?>
18
- </label>
19
- </td>
20
- <td>
21
- <input type="text" name="ai1ec_contact_phone" id="ai1ec_contact_phone" value="<?php echo $contact_phone; ?>" />
22
- </td>
23
- </tr>
24
- <tr>
25
- <td>
26
- <label for="ai1ec_contact_email">
27
- <?php _e( 'E-mail:', AI1EC_PLUGIN_NAME ); ?>
28
- </label>
29
- </td>
30
- <td>
31
- <input type="text" name="ai1ec_contact_email" id="ai1ec_contact_email" value="<?php echo $contact_email; ?>" />
32
- </td>
33
- </tr>
34
- </tbody>
35
- </table>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/view/admin/box_event_cost.php DELETED
@@ -1,15 +0,0 @@
1
- <h4 class="ai1ec-section-title"><?php _e( 'Event cost', AI1EC_PLUGIN_NAME ); ?></h4>
2
- <table class="ai1ec-form">
3
- <tbody>
4
- <tr>
5
- <td class="ai1ec-first">
6
- <label for="ai1ec_cost">
7
- <?php _e( 'Cost', AI1EC_PLUGIN_NAME ); ?>:
8
- </label>
9
- </td>
10
- <td>
11
- <input type="text" name="ai1ec_cost" id="ai1ec_cost" value="<?php echo $cost; ?>" />
12
- </td>
13
- </tr>
14
- </tbody>
15
- </table>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/view/admin/box_event_location.php DELETED
@@ -1,44 +0,0 @@
1
- <h4 class="ai1ec-section-title"><?php _e( 'Event location details', AI1EC_PLUGIN_NAME ); ?></h4>
2
- <div id="ai1ec-inside-wrapper">
3
- <table class="ai1ec-form ai1ec-location-form">
4
- <tbody>
5
- <tr>
6
- <td class="ai1ec-first">
7
- <label for="ai1ec_venue">
8
- <?php _e( 'Venue name:', AI1EC_PLUGIN_NAME ); ?>
9
- </label>
10
- </td>
11
- <td>
12
- <input type="text" name="ai1ec_venue" id="ai1ec_venue" value="<?php echo $venue; ?>" />
13
- </td>
14
- </tr>
15
- <tr>
16
- <td>
17
- <label for="ai1ec_address">
18
- <?php _e( 'Address:', AI1EC_PLUGIN_NAME ); ?>
19
- </label>
20
- </td>
21
- <td>
22
- <input type="text" name="ai1ec_address" id="ai1ec_address" value="<?php echo $address; ?>" />
23
- </td>
24
- </tr>
25
- <tr>
26
- <td>
27
- <label for="ai1ec_google_map">
28
- <?php _e( 'Show Google Map:', AI1EC_PLUGIN_NAME ); ?>
29
- </label>
30
- </td>
31
- <td>
32
- <input type="checkbox" value="1" name="ai1ec_google_map" id="ai1ec_google_map" <?php echo $google_map; ?> />
33
- </td>
34
- </tr>
35
- </tbody>
36
- </table>
37
- </div>
38
- <div class="ai1ec_box_map <?php if( $show_map ) echo 'ai1ec_box_map_visible' ?>">
39
- <div id="ai1ec_map_canvas"></div>
40
- </div>
41
- <input type="hidden" name="ai1ec_city" id="ai1ec_city" value="<?php echo $city; ?>" />
42
- <input type="hidden" name="ai1ec_province" id="ai1ec_province" value="<?php echo $province; ?>" />
43
- <input type="hidden" name="ai1ec_postal_code" id="ai1ec_postal_code" value="<?php echo $postal_code; ?>" />
44
- <input type="hidden" name="ai1ec_country" id="ai1ec_country" value="<?php echo $country; ?>" />
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/view/admin/box_feeds.php DELETED
@@ -1,39 +0,0 @@
1
- <p>
2
- <?php _e(
3
- 'Configure which other calendars your own calendar subscribes to.
4
- You can add any calendar that provides an iCalendar (.ics) feed.
5
- Enter the feed URL(s) below and the events from those feeds will be
6
- imported periodically.',
7
- AI1EC_PLUGIN_NAME ); ?>
8
- </p>
9
-
10
- <?php do_action( 'ai1ec_feeds_before' ); ?>
11
-
12
- <label class="textinput" for="cron_freq">
13
- <?php _e( 'Check for new events', AI1EC_PLUGIN_NAME ) ?>:
14
- </label>
15
- <?php echo $cron_freq ?>
16
- <br class="clear" />
17
-
18
- <div id="ai1ec-feeds-after" class="ai1ec-feed-container">
19
- <h4 class="ai1ec_feed_h4"><?php _e( 'iCalendar/.ics Feed URL:', AI1EC_PLUGIN_NAME ) ?></h4>
20
- <div class="ai1ec-feed-url"><input type="text" name="ai1ec_feed_url" id="ai1ec_feed_url" /></div>
21
- <div class="ai1ec-feed-category">
22
- <label for="ai1ec_feed_category">
23
- <?php _e( 'Event category', AI1EC_PLUGIN_NAME ); ?>:
24
- </label>
25
- <?php echo $event_categories; ?>
26
- </div>
27
- <div class="ai1ec-feed-tags">
28
- <label for="ai1ec_feed_tags">
29
- <?php _e( 'Tag with', AI1EC_PLUGIN_NAME ); ?>:
30
- </label>
31
- <input type="text" name="ai1ec_feed_tags" id="ai1ec_feed_tags" />
32
- </div>
33
- <input type="button" id="ai1ec_add_new_ics" class="button" value="<?php _e( '+ Add new subscription', AI1EC_PLUGIN_NAME ) ?>" />
34
- </div>
35
-
36
- <?php echo $feed_rows; ?>
37
- <br class="clear" />
38
-
39
- <?php do_action( 'ai1ec_feeds_after' ); ?>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/view/admin/box_general_settings.php DELETED
@@ -1,113 +0,0 @@
1
- <?php do_action( 'ai1ec_general_settings_before' ); ?>
2
-
3
- <h2><?php _e( 'Viewing Events', AI1EC_PLUGIN_NAME ) ?></h2>
4
-
5
- <label class="textinput" for="calendar_page_id"><?php _e( 'Calendar page:', AI1EC_PLUGIN_NAME ) ?></label>
6
- <div class="alignleft"><?php echo $calendar_page ?></div>
7
- <br class="clear" />
8
-
9
- <label class="textinput" for="default_calendar_view"><?php _e( 'Default calendar view:', AI1EC_PLUGIN_NAME ) ?></label>
10
- <?php echo $default_calendar_view ?>
11
- <br class="clear" />
12
-
13
- <?php if( $show_timezone ) : ?>
14
- <label class="textinput" for="default_calendar_view"><?php _e( 'Timezone:', AI1EC_PLUGIN_NAME ) ?></label>
15
- <?php echo $timezone_control ?>
16
- <?php endif; ?>
17
- <br class="clear" />
18
-
19
- <label class="textinput" for="week_start_day"><?php _e( 'Week starts on', AI1EC_PLUGIN_NAME ) ?></label>
20
- <?php echo $week_start_day ?>
21
- <br class="clear" />
22
-
23
- <label class="textinput" for="agenda_events_per_page"><?php _e( 'Agenda pages show at most', AI1EC_PLUGIN_NAME ) ?></label>
24
- <input name="agenda_events_per_page" id="agenda_events_per_page" type="text" size="1" value="<?php echo esc_attr( $agenda_events_per_page ) ?>" />&nbsp;<?php _e( 'events', AI1EC_PLUGIN_NAME ) ?>
25
- <br class="clear" />
26
-
27
- <label for="agenda_events_expanded">
28
- <input class="checkbox" name="agenda_events_expanded" id="agenda_events_expanded" type="checkbox" value="1" <?php echo $agenda_events_expanded ?> />
29
- <?php _e( 'Keep all events <strong>expanded</strong> in the agenda view', AI1EC_PLUGIN_NAME ) ?>
30
- </label>
31
- <br class="clear" />
32
-
33
- <label for="show_year_in_agenda_dates">
34
- <input class="checkbox" name="show_year_in_agenda_dates" id="show_year_in_agenda_dates" type="checkbox" value="1" <?php echo $show_year_in_agenda_dates ?> />
35
- <?php _e( '<strong>Show year</strong> in agenda date labels', AI1EC_PLUGIN_NAME ) ?>
36
- </label>
37
- <br class="clear" />
38
-
39
- <label for="show_location_in_title">
40
- <input class="checkbox" name="show_location_in_title" id="show_location_in_title" type="checkbox" value="1" <?php echo $show_location_in_title ?> />
41
- <?php _e( '<strong>Show location in event titles</strong> in calendar views', AI1EC_PLUGIN_NAME ) ?>
42
- </label>
43
- <br class="clear" />
44
-
45
- <label for="exclude_from_search">
46
- <input class="checkbox" name="exclude_from_search" id="exclude_from_search" type="checkbox" value="1" <?php echo $exclude_from_search ?> />
47
- <?php _e( '<strong>Exclude</strong> events from search results', AI1EC_PLUGIN_NAME ) ?>
48
- </label>
49
- <br class="clear" />
50
-
51
- <label for="show_create_event_button">
52
- <input class="checkbox" name="show_create_event_button" id="show_create_event_button" type="checkbox" value="1" <?php echo $show_create_event_button ?> />
53
- <?php _e( 'Show <strong>Post Your Event</strong> button above the calendar to privileged users', AI1EC_PLUGIN_NAME ) ?>
54
- </label>
55
- <br class="clear" />
56
-
57
- <label for="turn_off_subscription_buttons">
58
- <input class="checkbox" name="turn_off_subscription_buttons" id="turn_off_subscription_buttons" type="checkbox" value="1" <?php echo $turn_off_subscription_buttons ?> />
59
- <?php _e( 'Hide <strong>Subscribe</strong>/<strong>Add to Calendar</strong> buttons in calendar and single event views', AI1EC_PLUGIN_NAME ) ?>
60
- </label>
61
- <br class="clear" />
62
-
63
- <label for="hide_maps_until_clicked">
64
- <input class="checkbox" name="hide_maps_until_clicked" id="hide_maps_until_clicked" type="checkbox" value="1" <?php echo $hide_maps_until_clicked ?> />
65
- <?php _e( 'Hide <strong>Google Maps</strong> until clicked', AI1EC_PLUGIN_NAME ) ?>
66
- </label>
67
- <br class="clear" />
68
-
69
- <label for="inject_categories">
70
- <input class="checkbox" name="inject_categories" id="inject_categories" type="checkbox" value="1" <?php echo $inject_categories ?> />
71
- <?php _e( 'Include <strong>event categories</strong> in post category lists', AI1EC_PLUGIN_NAME ) ?>
72
- </label>
73
- <br class="clear" />
74
-
75
- <h2><?php _e( 'Adding/Editing Events', AI1EC_PLUGIN_NAME ) ?></h2>
76
-
77
- <label class="textinput" for="input_date_format"><?php _e( 'Input dates in this format:', AI1EC_PLUGIN_NAME ) ?></label>
78
- <?php echo $input_date_format ?>
79
- <br class="clear" />
80
-
81
- <label for="input_24h_time">
82
- <input class="checkbox" name="input_24h_time" id="input_24h_time" type="checkbox" value="1" <?php echo $input_24h_time ?> />
83
- <?php _e( 'Use <strong>24h time</strong> in time pickers', AI1EC_PLUGIN_NAME ) ?>
84
- </label>
85
- <br class="clear" />
86
-
87
- <label for="disable_autocompletion">
88
- <input class="checkbox" name="disable_autocompletion" id="disable_autocompletion" type="checkbox" value="1" <?php echo $disable_autocompletion ?> />
89
- <?php _e( '<strong>Disable address autocomplete</strong> function', AI1EC_PLUGIN_NAME ) ?>
90
- </label>
91
- <br class="clear" />
92
-
93
- <label for="geo_region_biasing">
94
- <input class="checkbox" name="geo_region_biasing" id="geo_region_biasing" type="checkbox" value="1" <?php echo $geo_region_biasing ?> />
95
- <?php _e( 'Use the configured <strong>region</strong> (WordPress locale) to bias the address autocomplete function', AI1EC_PLUGIN_NAME ) ?>
96
- </label>
97
- <br class="clear" />
98
-
99
- <label for="show_publish_button">
100
- <input class="checkbox" name="show_publish_button" id="show_publish_button" type="checkbox" value="1" <?php echo $show_publish_button ?> />
101
- <?php _e( 'Display <strong>Publish</strong> at bottom of Edit Event form', AI1EC_PLUGIN_NAME ) ?>
102
- </label>
103
- <br class="clear" />
104
-
105
- <h2><?php _e( 'Promoting Events', AI1EC_PLUGIN_NAME ) ?></h2>
106
-
107
- <label for="allow_statistics">
108
- <input class="checkbox" name="allow_statistics" id="allow_statistics" type="checkbox" value="1" <?php echo $allow_statistics ?> />
109
- <?php printf( __( '<strong>Publicize, promote, and share my events</strong> marked as public on the Timely network. (<a href="%s" target="_blank">Learn more »</a>)', AI1EC_PLUGIN_NAME ), 'http://time.ly/event-search-calendar' ); ?>
110
- </label>
111
- <br class="clear" />
112
-
113
- <?php do_action( 'ai1ec_general_settings_after' ); ?>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/view/admin/box_publish_button.php DELETED
@@ -1,5 +0,0 @@
1
- <input type="button"
2
- name="ai1ec_bottom_publish"
3
- id="ai1ec_bottom_publish"
4
- class="button-primary ai1ec_bottom_publish"
5
- value="<?php echo $button_value ?>" />
 
 
 
 
 
app/view/admin/box_repeat.php DELETED
@@ -1,53 +0,0 @@
1
- <ul class="ai1ec_repeat_tabs">
2
- <li><a href="#ai1ec_daily_content" id="ai1ec_daily_tab" class="ai1ec_tab ai1ec_active"><?php _e( 'Daily', AI1EC_PLUGIN_NAME ) ;?></a></li>
3
- <li><a href="#ai1ec_weekly_content" id="ai1ec_weekly_tab" class="ai1ec_tab"><?php _e( 'Weekly', AI1EC_PLUGIN_NAME ) ;?></a></li>
4
- <li><a href="#ai1ec_monthly_content" id="ai1ec_monthly_tab" class="ai1ec_tab"><?php _e( 'Monthly', AI1EC_PLUGIN_NAME ) ;?></a></li>
5
- <li><a href="#ai1ec_yearly_content" id="ai1ec_yearly_tab" class="ai1ec_tab"><?php _e( 'Yearly', AI1EC_PLUGIN_NAME ) ;?></a></li>
6
- </ul>
7
- <div style="clear:both;"></div>
8
- <div id="ai1ec_daily_content" class="ai1ec_tab_content" title="daily">
9
- <?php echo $row_daily ?>
10
- <div id="ai1ec_repeat_tab_append">
11
- <div id="ai1ec_ending_box" class="ai1ec_repeat_centered_content">
12
- <div id="ai1ec_end_holder">
13
- <label for="ai1ec_end">
14
- <?php _e( 'End', AI1EC_PLUGIN_NAME ) ?>:
15
- </label>
16
- <?php echo $end ?>
17
- </div>
18
- <div style="clear:both;"></div>
19
- <div id="ai1ec_count_holder">
20
- <label for="ai1ec_count">
21
- <?php _e( 'Ending after', AI1EC_PLUGIN_NAME ) ?>:
22
- </label>
23
- <?php echo $count; ?>
24
- </div>
25
- <div style="clear:both;"></div>
26
- <div id="ai1ec_until_holder">
27
- <label for="ai1ec_until-date-input">
28
- <?php _e( 'On date', AI1EC_PLUGIN_NAME ) ?>:
29
- </label>
30
- <input type="text" class="ai1ec-date-input" id="ai1ec_until-date-input" />
31
- <input type="hidden" name="ai1ec_until_time" id="ai1ec_until-time" value="<?php echo !is_null( $until ) && $until > 0 ? $until : '' ?>" />
32
- </div>
33
- <div style="clear:both;"></div>
34
- </div>
35
- <div id="ai1ec_apply_button_holder">
36
- <input type="button" name="ai1ec_none_button" value="<?php _e( 'Apply', AI1EC_PLUGIN_NAME ) ?>" class="ai1ec_repeat_apply button button-highlighted" />
37
- <a href="#ai1ec_cancel" class="ai1ec_repeat_cancel"><?php _e( 'Cancel', AI1EC_PLUGIN_NAME ) ?></a>
38
- </div>
39
- <div style="clear:both;"></div>
40
- </div>
41
- <div style="clear:both;"></div>
42
- </div>
43
- <div id="ai1ec_weekly_content" class="ai1ec_tab_content" title="weekly">
44
- <?php echo $row_weekly ?>
45
- </div>
46
- <div id="ai1ec_monthly_content" class="ai1ec_tab_content" title="monthly">
47
- <?php echo $row_monthly ?>
48
- </div>
49
- <div id="ai1ec_yearly_content" class="ai1ec_tab_content" title="yearly">
50
- <?php echo $row_yearly ?>
51
- </div>
52
- <input type="hidden" id="ai1ec_is_box_repeat" value="<?php echo $repeat ?>" />
53
- <div style="clear:both;"></div>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/view/admin/box_support.php DELETED
@@ -1,161 +0,0 @@
1
- <div class="timely">
2
- <h2 class="timely-logo"><a href="http://time.ly/" title="<?php esc_attr_e( 'Timely', AI1EC_PLUGIN_NAME ); ?>" target="_blank"></a></h2>
3
-
4
- <div class="timely-intro">
5
- <h2>
6
- <?php _e( 'Timely’s All-in-One Event Calendar is a<br />revolutionary new way to find and share events.', AI1EC_PLUGIN_NAME ); ?>
7
- </h2>
8
- </div>
9
-
10
- <div class="ai1ec-download row-fluid">
11
- <div class="span12">
12
- <a class="btn btn-large disabled ai1ec-download-btn">
13
- <?php printf(
14
- __( 'You are currently running the %s version %s', AI1EC_PLUGIN_NAME ),
15
- '<div><i class="timely-icon-checkmark"></i> ' .
16
- __( '<strong>Lite</strong> Calendar', AI1EC_PLUGIN_NAME ) .
17
- '</div>',
18
- AI1EC_VERSION );
19
- ?>
20
- </a>
21
- </div>
22
- </div>
23
- <div class="ai1ec-download row-fluid">
24
- <div class="span6">
25
- <div>
26
- <a href="http://support.time.ly/difference-lite-standard-versions/" class="btn btn-large ai1ec-download-btn">
27
- <?php printf(
28
- __( 'Upgrade to the %s for free', AI1EC_PLUGIN_NAME ),
29
- '<div><i class="timely-icon-gift"></i> ' .
30
- __( '<strong>Standard</strong> Calendar', AI1EC_PLUGIN_NAME ) .
31
- '</div>',
32
- AI1EC_VERSION );
33
- ?>
34
- </a>
35
- <ul class="icons">
36
- <li><a title="<?php esc_attr_e( 'Extended Views', AI1EC_PLUGIN_NAME ); ?>"
37
- data-content="<?php esc_attr_e( 'Display events in your choice of layout, including improved Month, Day, Week and Agenda views, as well as the attractive Posterboard view. Lock to specific views or allow viewers to choose. Easily customize the colours and fonts, or write your own custom theme.', AI1EC_PLUGIN_NAME ); ?>">
38
- <i class="timely-icon-checkmark"></i> <?php _e( 'Extended Views', AI1EC_PLUGIN_NAME ); ?>
39
- </a></li>
40
- <li><a title="<?php esc_attr_e( 'Import/Export Events', AI1EC_PLUGIN_NAME ); ?>"
41
- data-content="<?php esc_attr_e( 'Import and sync event feeds from other All-in-One Calendars, or from any other .ics calendar system, including Google Calendar, iCal, Outlook and more.<br /><br />Every event or category feed can be exported to other All-in-One Calendars or to other .ics calendar systems, offering multiple event notification options—even on mobile devices.', AI1EC_PLUGIN_NAME ); ?>">
42
- <i class="timely-icon-checkmark"></i> <?php _e( 'Import/Export Events', AI1EC_PLUGIN_NAME ); ?>
43
- </a></li>
44
- <li><a title="<?php esc_attr_e( 'Facebook Integration', AI1EC_PLUGIN_NAME ); ?>"
45
- data-content="<?php esc_attr_e( 'Connect your Facebook account to import your Facebook events, your friends’ events, and the events of your Pages and Groups, including their associated event photos. Optionally, export individual All-in-One events back to Facebook.', AI1EC_PLUGIN_NAME ); ?>">
46
- <i class="timely-icon-checkmark"></i> <?php _e( 'Facebook Integration', AI1EC_PLUGIN_NAME ); ?>
47
- </a></li>
48
- <li><a title="<?php esc_attr_e( 'Filter by Category and Tag', AI1EC_PLUGIN_NAME ); ?>"
49
- data-content="<?php esc_attr_e( 'Filter your calendar by any combination of category or tag. Assign colors and avatars to your event categories. Subscribe to filtered event feeds or display them on any page in your site; have each filtered view appear alongside any content or advertising you’d like.', AI1EC_PLUGIN_NAME ); ?>">
50
- <i class="timely-icon-checkmark"></i> <?php _e( 'Filter by Category and Tag', AI1EC_PLUGIN_NAME ); ?>
51
- </a></li>
52
- <li><a title="<?php esc_attr_e( 'Recurring Events', AI1EC_PLUGIN_NAME ); ?>"
53
- data-content="<?php esc_attr_e( 'Create recurring events more easily, even in complex patterns. Allow events to repeat on any day of the week, month, or year. Schedule complex recurrence patterns such as “every first and third Monday of the month.”', AI1EC_PLUGIN_NAME ); ?>">
54
- <i class="timely-icon-checkmark"></i> <?php _e( 'Recurring Events', AI1EC_PLUGIN_NAME ); ?>
55
- </a></li>
56
- <li><a title="<?php esc_attr_e( 'Upcoming Events Widgets', AI1EC_PLUGIN_NAME ); ?>"
57
- data-content="<?php esc_attr_e( 'Includes an Upcoming Events widget that can be displayed in your sidebar or footer. Widgets can be filtered to show only events in a certain category, tag or a combination of both.', AI1EC_PLUGIN_NAME ); ?>">
58
- <i class="timely-icon-checkmark"></i> <?php _e( 'Upcoming Events Widgets', AI1EC_PLUGIN_NAME ); ?>
59
- </a></li>
60
- <li><a title="<?php esc_attr_e( 'Locations and Maps', AI1EC_PLUGIN_NAME ); ?>"
61
- data-content="<?php esc_attr_e( 'The Standard Calendar can provide detailed location information for your event and includes the option to embed a Google Map directly into your event details. Additionally, you can specify exact longitude and latitude co-ordinates.', AI1EC_PLUGIN_NAME ); ?>">
62
- <i class="timely-icon-checkmark"></i> <?php _e( 'Locations and Maps', AI1EC_PLUGIN_NAME ); ?>
63
- </a></li>
64
- <li><a title="<?php esc_attr_e( 'Basic Support', AI1EC_PLUGIN_NAME ); ?>"
65
- data-content="<?php esc_attr_e( 'Browse our Developer Guide, find the answers to many previously asked questions on our Support Forums, or review dozens of articles written specifically about common questions.<br /><br />Have a problem that you can’t solve? Our Support Staff can take a quick look at your installation and point you in the right direction. If we discover a bug, we’ll do our best to fix it.', AI1EC_PLUGIN_NAME ); ?>">
66
- <i class="timely-icon-checkmark"></i> <?php _e( 'Basic Support', AI1EC_PLUGIN_NAME ); ?>
67
- </a></li>
68
- </ul>
69
- </div>
70
- </div>
71
- <div class="span6">
72
- <div>
73
- <a href="http://time.ly/timely-all-in-one-calendar-pro"
74
- class="btn btn-large btn-primary ai1ec-download-btn">
75
- <?php printf(
76
- __( 'Upgrade to the %s for only $75', AI1EC_PLUGIN_NAME ),
77
- '<div><i class="timely-icon-shopping-cart"></i> ' .
78
- __( '<strong>Pro</strong> Calendar', AI1EC_PLUGIN_NAME ) .
79
- '</div>' );
80
- ?>
81
- </a>
82
- <ul class="icons">
83
- <li><a title="<?php esc_attr_e( 'All Standard Features', AI1EC_PLUGIN_NAME ); ?>"
84
- data-content="<?php esc_attr_e( 'You get every feature that comes with the Standard Calendar.', AI1EC_PLUGIN_NAME ); ?>">
85
- <i class="timely-icon-checkmark"></i> <?php _e( 'All Standard Features', AI1EC_PLUGIN_NAME ); ?>
86
- </a></li>
87
- <li><a title="<?php esc_attr_e( 'Front-end Event Creation Form', AI1EC_PLUGIN_NAME ); ?>"
88
- data-content="<?php esc_attr_e( 'Allow your users, even anonymous users if you wish, to contribute their own events to your calendar. The form offers security and editorial control of submitted events.', AI1EC_PLUGIN_NAME ); ?>">
89
- <i class="timely-icon-checkmark"></i> <?php _e( 'Front-end Event Creation Form', AI1EC_PLUGIN_NAME ); ?>
90
- </a></li>
91
- <li><a title="<?php esc_attr_e( 'User Feed Submission', AI1EC_PLUGIN_NAME ); ?>"
92
- data-content="<?php esc_attr_e( 'Allow users to submit their own calendar’s iCalendar (.ics) feed through the front-end of your site. You receive a notification of the contribution for review and can easily add it to your calendar’s list of subscribed feeds.', AI1EC_PLUGIN_NAME ); ?>">
93
- <i class="timely-icon-checkmark"></i> <?php _e( 'User Feed Submission', AI1EC_PLUGIN_NAME ); ?>
94
- </a></li>
95
- <li><a title="<?php esc_attr_e( 'Stream View', AI1EC_PLUGIN_NAME ); ?>"
96
- data-content="<?php esc_attr_e( 'A streamlined and mobile-friendly view of your calendar’s upcoming events that includes thumbnails, category avatars and more.', AI1EC_PLUGIN_NAME ); ?>">
97
- <i class="timely-icon-checkmark"></i> <?php _e( 'Stream View', AI1EC_PLUGIN_NAME ); ?>
98
- </a></li>
99
- <li><a title="<?php esc_attr_e( 'Bulk CSV Upload', AI1EC_PLUGIN_NAME ); ?>"
100
- data-content="<?php esc_attr_e( 'Upload a feed of events as a file in either comma-separated values (CSV) or iCalendar (.ics) format.', AI1EC_PLUGIN_NAME ); ?>">
101
- <i class="timely-icon-checkmark"></i> <?php _e( 'Bulk CSV Upload', AI1EC_PLUGIN_NAME ); ?>
102
- </a></li>
103
- <li><a title="<?php esc_attr_e( 'Super Widgets', AI1EC_PLUGIN_NAME ); ?>"
104
- data-content="<?php esc_attr_e( 'Embed your calendar outside of WordPress and distribute it to other websites – even sites hosted on other servers.', AI1EC_PLUGIN_NAME ); ?>">
105
- <i class="timely-icon-checkmark"></i> <?php _e( 'Super Widgets', AI1EC_PLUGIN_NAME ); ?>
106
- </a></li>
107
- <li><a title="<?php esc_attr_e( 'Premium Support', AI1EC_PLUGIN_NAME ); ?>"
108
- data-content="<?php esc_attr_e( 'Get priority support by e-mail and view your active support requests right in WordPress. Examples include:<ul class="icons"><li class="timely-icon-checkmark"> Setting up the calendar</li><li class="timely-icon-checkmark"> Minor customizations</li><li class="timely-icon-checkmark"> Changing the size/positioning of the calendar</li><li class="timely-icon-checkmark"> Resolving plugin or theme conflicts (if possible)</li><li class="timely-icon-checkmark"> Assistance resolving issues covered by documentation</li></ul>', AI1EC_PLUGIN_NAME ); ?>">
109
- <i class="timely-icon-checkmark"></i> <?php _e( 'Premium Support', AI1EC_PLUGIN_NAME ); ?>
110
- </a></li>
111
- <li><a title="<?php esc_attr_e( 'One Year of Free Updates', AI1EC_PLUGIN_NAME ); ?>"
112
- data-content="<?php esc_attr_e( 'Your Pro Calendar license gives you free updates to every new release of the Pro Calendar for one year after your date of purchase.', AI1EC_PLUGIN_NAME ); ?>">
113
- <i class="timely-icon-checkmark"></i> <?php _e( 'One Year of Free Updates', AI1EC_PLUGIN_NAME ); ?>
114
- </a></li>
115
- </ul>
116
- </div>
117
- </div>
118
- </div>
119
-
120
- <div class="ai1ec-news">
121
- <h2>
122
- <?php _e( 'Timely News', AI1EC_PLUGIN_NAME ); ?>
123
- <small>
124
- <a href="http://help.time.ly/" target="_blank"
125
- class="btn btn-primary pull-right ai1ec-get-support">
126
- <i class="timely-icon-dedicated-support"></i> <?php _e( 'Get Support', AI1EC_PLUGIN_NAME ); ?>
127
- <i class="timely-icon-chevron-right"></i>
128
- </a>
129
-
130
- <a href="http://time.ly/blog" target="_blank"><?php _e( 'view all news', AI1EC_PLUGIN_NAME ); ?> <i class="icon-arrow-right"></i></a>
131
- </small>
132
- </h2>
133
- <div>
134
- <?php if( count( $news ) > 0 ) : ?>
135
- <?php foreach( $news as $n ) : ?>
136
- <article>
137
- <header>
138
- <strong><a href="<?php echo $n->get_permalink() ?>" target="_blank"><?php echo $n->get_title() ?></a></strong>
139
- </header>
140
- <div>
141
- <?php echo preg_replace( '/\s+?(\S+)?$/', '', $n->get_description() ); ?>
142
- </div>
143
- </article>
144
- <?php endforeach ?>
145
- <?php else : ?>
146
- <p><em>No news available.</em></p>
147
- <?php endif ?>
148
- </div>
149
- </div>
150
-
151
- <div class="ai1ec-follow-fan">
152
- <div class="ai1ec-facebook-like-top">
153
- <script src="http://connect.facebook.net/en_US/all.js#xfbml=1"></script>
154
- <fb:like href="http://www.facebook.com/timelycal" layout="button_count" show_faces="true" width="110" font="lucida grande"></fb:like>
155
- </div>
156
- <a href="http://twitter.com/_Timely" class="twitter-follow-button"><?php _e( 'Follow @_Timely', AI1EC_PLUGIN_NAME ) ?></a>
157
- <script src="http://platform.twitter.com/widgets.js" type="text/javascript"></script>
158
- </div>
159
-
160
- <br class="clear" />
161
- </div>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/view/admin/box_time_and_date.php DELETED
@@ -1,90 +0,0 @@
1
- <?php wp_nonce_field( 'ai1ec', AI1EC_POST_TYPE ); ?>
2
- <h4 class="ai1ec-section-title"><?php _e( 'Event date and time', AI1EC_PLUGIN_NAME ); ?></h4>
3
- <table class="ai1ec-form">
4
- <tbody>
5
- <tr>
6
- <td class="ai1ec-first">
7
- <label for="ai1ec_all_day_event">
8
- <?php _e( 'All-day event', AI1EC_PLUGIN_NAME ); ?>?
9
- </label>
10
- </td>
11
- <td>
12
- <input type="checkbox" name="ai1ec_all_day_event" id="ai1ec_all_day_event" value="1" <?php echo $all_day_event; ?> />
13
- </td>
14
- </tr>
15
- <tr>
16
- <td>
17
- <label for="ai1ec_start-date-input">
18
- <?php _e( 'Start date / time', AI1EC_PLUGIN_NAME ); ?>:
19
- </label>
20
- </td>
21
- <td>
22
- <input type="text" class="ai1ec-date-input" id="ai1ec_start-date-input" />
23
- <input type="text" class="ai1ec-time-input" id="ai1ec_start-time-input" />
24
- <small><?php echo $timezone ?></small>
25
- <input type="hidden" name="ai1ec_start_time" id="ai1ec_start-time" value="<?php echo $start_timestamp ?>" />
26
- </td>
27
- </tr>
28
- <tr>
29
- <td>
30
- <label for="ai1ec_end-date-input">
31
- <?php _e( 'End date / time', AI1EC_PLUGIN_NAME ) ?>:
32
- </label>
33
- </td>
34
- <td>
35
- <input type="text" class="ai1ec-date-input" id="ai1ec_end-date-input" />
36
- <input type="text" class="ai1ec-time-input" id="ai1ec_end-time-input" />
37
- <small><?php echo $timezone ?></small>
38
- <input type="hidden" name="ai1ec_end_time" id="ai1ec_end-time" value="<?php echo $end_timestamp ?>" />
39
- </td>
40
- </tr>
41
- <tr>
42
- <td>
43
- <input type="checkbox" name="ai1ec_repeat" id="ai1ec_repeat" value="1" <?php echo $repeating_event ? 'checked="checked"' : '' ?>/>
44
- <input type="hidden" name="ai1ec_rrule" id="ai1ec_rrule" value="<?php echo $rrule ?>" />
45
- <label for="ai1ec_repeat" id="ai1ec_repeat_label">
46
- <?php _e( 'Repeat', AI1EC_PLUGIN_NAME ); echo $repeating_event ? ':' : '...' ?>
47
- </label>
48
- </td>
49
- <td>
50
- <div id="ai1ec_repeat_text">
51
- <a href="#ai1ec_repeat_box"><?php echo $rrule_text ?></a>
52
- </div>
53
- </td>
54
- </tr>
55
- <tr>
56
- <td>
57
- <input type="checkbox" name="ai1ec_exclude" id="ai1ec_exclude" value="1" <?php echo $exclude_event ? 'checked="checked"' : '' ?>/>
58
- <input type="hidden" name="ai1ec_exrule" id="ai1ec_exrule" value="<?php echo $exrule ?>" />
59
- <label for="ai1ec_exclude" id="ai1ec_exclude_label">
60
- <?php _e( 'Exclude', AI1EC_PLUGIN_NAME ); echo $exclude_event ? ':' : '...' ?>
61
- </label>
62
- </td>
63
- <td>
64
- <div id="ai1ec_exclude_text">
65
- <a href="#ai1ec_exclude_box"><?php echo $exrule_text ?></a>
66
- </div>
67
- <span class="ai1ec-info-text">(<?php _e( 'Choose a rule for exclusion', AI1EC_PLUGIN_NAME ) ?>)</span>
68
- </td>
69
- </tr>
70
- <tr>
71
- <td>
72
- <label for="ai1ec_exdate_calendar_icon" id="ai1ec_exclude_date_label">
73
- <?php _e( 'Exclude dates', AI1EC_PLUGIN_NAME ) ?>:
74
- </label>
75
- </td>
76
- <td>
77
- <div id="datepicker-widget">
78
- <div id="widgetField">
79
- <span></span>
80
- <a href="#"><?php _e( 'Select date range', AI1EC_PLUGIN_NAME ) ?></a>
81
- </div>
82
- <div id="widgetCalendar"></div>
83
- </div>
84
- <input type="hidden" name="ai1ec_exdate" id="ai1ec_exdate" value="<?php echo $exdate ?>" />
85
- <span class="ai1ec-info-text">(<?php _e( 'Choose specific dates to exclude', AI1EC_PLUGIN_NAME ) ?>)</span>
86
- </td>
87
- </tr>
88
- <div id="ai1ec_repeat_box"></div>
89
- </tbody>
90
- </table>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/view/admin/calendar-feeds.php ADDED
@@ -0,0 +1,102 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * The Calendar Feeds page.
5
+ *
6
+ * @author Time.ly Network Inc.
7
+ * @since 2.0
8
+ *
9
+ * @package AI1EC
10
+ * @subpackage AI1EC.View
11
+ */
12
+ class Ai1ec_View_Calendar_Feeds extends Ai1ec_View_Admin_Abstract {
13
+
14
+ /**
15
+ * Adds page to the menu.
16
+ *
17
+ * @wp_hook admin_menu
18
+ *
19
+ * @return void
20
+ */
21
+ public function add_page() {
22
+ // =======================
23
+ // = Calendar Feeds Page =
24
+ // =======================
25
+ $calendar_feeds = add_submenu_page(
26
+ AI1EC_ADMIN_BASE_URL,
27
+ Ai1ec_I18n::__( 'Calendar Feeds' ),
28
+ Ai1ec_I18n::__( 'Calendar Feeds' ),
29
+ 'manage_ai1ec_feeds',
30
+ AI1EC_PLUGIN_NAME . '-feeds',
31
+ array( $this, 'display_page' )
32
+ );
33
+ $this->_registry->get( 'model.settings' )
34
+ ->set( 'feeds_page', $calendar_feeds );
35
+ }
36
+
37
+ /**
38
+ * Adds metabox to the page.
39
+ *
40
+ * @wp_hook admin_init
41
+ *
42
+ * @return void
43
+ */
44
+ public function add_meta_box() {
45
+ // Add the 'ICS Import Settings' meta box.
46
+ add_meta_box(
47
+ 'ai1ec-feeds',
48
+ Ai1ec_I18n::_x( 'Feed Subscriptions', 'meta box' ),
49
+ array( $this, 'display_meta_box' ),
50
+ $this->_registry->get( 'model.settings' )->get( 'feeds_page' ),
51
+ 'left',
52
+ 'default'
53
+ );
54
+ }
55
+
56
+ /**
57
+ * Display this plugin's feeds page in the admin.
58
+ *
59
+ * @return void
60
+ */
61
+ public function display_page() {
62
+ $settings = $this->_registry->get( 'model.settings' );
63
+ $loader = $this->_registry->get( 'theme.loader' );
64
+ $args = array(
65
+ 'title' => __(
66
+ 'All-in-One Event Calendar: Calendar Feeds',
67
+ AI1EC_PLUGIN_NAME
68
+ ),
69
+ 'settings_page' => $settings->get( 'feeds_page' ),
70
+ 'calendar_settings' => false,
71
+ );
72
+ $file = $loader->get_file( 'settings.php', $args, true );
73
+ $file->render();
74
+ }
75
+
76
+ /**
77
+ * Renders the contents of the Calendar Feeds meta box.
78
+ *
79
+ * @return void
80
+ */
81
+ public function display_meta_box( $object, $box ) {
82
+ // register the calendar feeds page.
83
+ $calendar_feeds = $this->_registry->get( 'controller.calendar-feeds' );
84
+ $feeds = array( $this->_registry->get( 'calendar-feed.ics' ) );
85
+ $feeds = apply_filters( 'ai1ec_calendar_feeds', $feeds );
86
+ foreach ( $feeds as $feed ) {
87
+ $calendar_feeds->add_plugin( $feed );
88
+ }
89
+ $calendar_feeds->handle_feeds_page_post();
90
+ $loader = $this->_registry->get( 'theme.loader' );
91
+ $file = $loader->get_file(
92
+ 'box_feeds.php',
93
+ array( 'calendar_feeds' => $calendar_feeds ),
94
+ true
95
+ );
96
+ $file->render();
97
+ }
98
+
99
+ public function handle_post() {
100
+ }
101
+
102
+ }
app/view/admin/calendar_tasks.php DELETED
@@ -1,82 +0,0 @@
1
- <div class="timely">
2
- <div class="hero-unit">
3
- <h1><?php _e( 'Welcome', AI1EC_PLUGIN_NAME ); ?></h1>
4
- <p><?php _e( 'to the All-in-One Event Calendar by <a href="http://time.ly/" target="_blank">Timely</a>', AI1EC_PLUGIN_NAME ); ?></p>
5
- </div>
6
-
7
- <div class="clearfix">
8
- <div class="row-fluid">
9
- <?php if( $add_allowed ): ?>
10
- <div class="span6">
11
- <p>
12
- <a class="btn btn-primary btn-large" href="<?php echo esc_attr( $add_url ); ?>">
13
- <i class="timely-icon-subscribe-events"></i>&nbsp;&nbsp;<?php _e( 'Post Your Event', AI1EC_PLUGIN_NAME ); ?>
14
- </a>
15
- </p>
16
- <strong><?php _e( 'Add a new event to the calendar.', AI1EC_PLUGIN_NAME ); ?></strong>
17
- </div>
18
- <?php endif; ?>
19
-
20
- <?php if( $edit_allowed ): ?>
21
- <div class="span6">
22
- <p>
23
- <a class="btn btn-primary btn-large" href="<?php echo esc_attr( $edit_url ); ?>">
24
- <i class="timely-icon-pencil"></i>&nbsp;&nbsp;<?php _e( 'Manage Events', AI1EC_PLUGIN_NAME ); ?>
25
- </a>
26
- </p>
27
- <strong><?php _e( 'View and edit all your events.', AI1EC_PLUGIN_NAME ); ?></strong>
28
- </div>
29
- <?php endif; ?>
30
- </div>
31
-
32
- <hr />
33
-
34
- <div class="row-fluid">
35
- <?php if( $categories_allowed ): ?>
36
- <div class="span6">
37
- <p>
38
- <a class="btn" href="<?php echo esc_attr( $categories_url ); ?>">
39
- <i class="timely-icon-filter-tag-category timely-icon-large"></i> <?php _e( 'Manage Event Categories', AI1EC_PLUGIN_NAME ); ?>
40
- </a>
41
- </p>
42
- <p><strong><?php _e( 'Organize and color-code your events.', AI1EC_PLUGIN_NAME ); ?></strong></p>
43
- </div>
44
- <?php endif; ?>
45
-
46
- <?php if( $themes_allowed ): ?>
47
- <div class="span6">
48
- <p>
49
- <a class="btn" href="<?php echo esc_attr( $themes_url ); ?>">
50
- <i class="timely-icon-multiple-views timely-icon-large"></i> <?php _e( 'Choose Your Theme', AI1EC_PLUGIN_NAME ); ?>
51
- </a>
52
- </p>
53
- <p><strong><?php _e( 'Change the look and feel.', AI1EC_PLUGIN_NAME ); ?></strong></p>
54
- </div>
55
- <?php endif; ?>
56
- </div>
57
-
58
- <div class="row-fluid">
59
- <?php if( $feeds_allowed ): ?>
60
- <div class="span6">
61
- <p>
62
- <a class="btn" href="<?php echo esc_attr( $feeds_url ); ?>">
63
- <i class="timely-icon-import-events timely-icon-large"></i> <?php _e( 'Manage Calendar Feeds', AI1EC_PLUGIN_NAME ); ?>
64
- </a>
65
- </p>
66
- <p><strong><?php _e( 'Subscribe to other calendars.', AI1EC_PLUGIN_NAME ); ?></strong></p>
67
- </div>
68
- <?php endif; ?>
69
-
70
- <?php if( $settings_allowed ): ?>
71
- <div class="span6">
72
- <p>
73
- <a class="btn" href="<?php echo esc_attr( $settings_url ); ?>">
74
- <i class="timely-icon-gear timely-icon-large"></i> <?php _e( 'Edit Calendar Settings', AI1EC_PLUGIN_NAME ); ?>
75
- </a>
76
- </p>
77
- <p><strong><?php _e( 'Make this calendar your own.', AI1EC_PLUGIN_NAME ); ?></strong></p>
78
- </div>
79
- <?php endif; ?>
80
- </div>
81
- </div>
82
- </div>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/view/admin/class-ai1ec-agenda-widget.php DELETED
@@ -1,218 +0,0 @@
1
- <?php
2
-
3
- /**
4
- * Ai1ec_Agenda_Widget class
5
- *
6
- * A widget that displays the next X upcoming events (similar to Agenda view).
7
- */
8
- class Ai1ec_Agenda_Widget extends WP_Widget {
9
- /**
10
- * Constructor for widget.
11
- */
12
- function __construct() {
13
- parent::__construct(
14
- 'ai1ec_agenda_widget',
15
- __( 'Upcoming Events', AI1EC_PLUGIN_NAME ),
16
- array(
17
- 'description' => __( 'All-in-One Event Calendar: Lists upcoming events in Agenda view', AI1EC_PLUGIN_NAME ),
18
- 'class' => 'ai1ec-agenda-widget',
19
- )
20
- );
21
- }
22
-
23
- /**
24
- * form function
25
- *
26
- * Renders the widget's configuration form for the Manage Widgets page.
27
- *
28
- * @param array $instance The data array for the widget instance being
29
- * configured.
30
- */
31
- function form( $instance )
32
- {
33
- global $ai1ec_view_helper;
34
-
35
- $default = array(
36
- 'title' => __( 'Upcoming Events', AI1EC_PLUGIN_NAME ),
37
- 'events_per_page' => 10,
38
- 'show_subscribe_buttons' => true,
39
- 'show_calendar_button' => true,
40
- 'hide_on_calendar_page' => true,
41
- 'limit_by_cat' => false,
42
- 'limit_by_tag' => false,
43
- 'limit_by_post' => false,
44
- 'event_cat_ids' => array(),
45
- 'event_tag_ids' => array(),
46
- 'event_post_ids' => array(),
47
- );
48
- $instance = wp_parse_args( (array) $instance, $default );
49
-
50
- // Get available cats, tags, events to allow user to limit widget to certain categories
51
- $events_categories = get_terms( 'events_categories', array( 'orderby' => 'name', "hide_empty" => false ) );
52
- $events_tags = get_terms( 'events_tags', array( 'orderby' => 'name', "hide_empty" => false ) );
53
- $get_events = new WP_Query( array ( 'post_type' => AI1EC_POST_TYPE, 'posts_per_page' => -1 ) );
54
- $events_options = $get_events->posts;
55
-
56
- // Generate unique IDs and NAMEs of all needed form fields
57
- $fields = array(
58
- 'title' => array('value' => $instance['title']),
59
- 'events_per_page' => array('value' => $instance['events_per_page']),
60
- 'show_subscribe_buttons' => array('value' => $instance['show_subscribe_buttons']),
61
- 'show_calendar_button' => array('value' => $instance['show_calendar_button']),
62
- 'hide_on_calendar_page' => array('value' => $instance['hide_on_calendar_page']),
63
- 'limit_by_cat' => array('value' => $instance['limit_by_cat']),
64
- 'limit_by_tag' => array('value' => $instance['limit_by_tag']),
65
- 'limit_by_post' => array('value' => $instance['limit_by_post']),
66
- 'event_cat_ids' => array(
67
- 'value' => (array)$instance['event_cat_ids'],
68
- 'options' => $events_categories
69
- ),
70
- 'event_tag_ids' => array(
71
- 'value' => (array)$instance['event_tag_ids'],
72
- 'options' => $events_tags
73
- ),
74
- 'event_post_ids' => array(
75
- 'value' => (array)$instance['event_post_ids'],
76
- 'options' => $events_options
77
- ),
78
- );
79
- foreach( $fields as $field => $data ) {
80
- $fields[$field]['id'] = $this->get_field_id( $field );
81
- $fields[$field]['name'] = $this->get_field_name( $field );
82
- $fields[$field]['value'] = $data['value'];
83
- if( isset($data['options']) ) {
84
- $fields[$field]['options'] = $data['options'];
85
- }
86
- }
87
-
88
- $ai1ec_view_helper->display_admin( 'agenda-widget-form.php', $fields );
89
- }
90
-
91
- /**
92
- * update function
93
- *
94
- * Called when a user submits the widget configuration form. The data should
95
- * be validated and returned.
96
- *
97
- * @param array $new_instance The new data that was submitted.
98
- * @param array $old_instance The widget's old data.
99
- * @return array The new data to save for this widget instance.
100
- */
101
- function update( $new_instance, $old_instance )
102
- {
103
- // Save existing data as a base to modify with new data
104
- $instance = $old_instance;
105
- $instance['title'] = strip_tags( $new_instance['title'] );
106
- $instance['events_per_page'] = intval( $new_instance['events_per_page'] );
107
- if( $instance['events_per_page'] < 1 ) $instance['events_per_page'] = 1;
108
- $instance['show_subscribe_buttons'] = $new_instance['show_subscribe_buttons'] ? true : false;
109
- $instance['show_calendar_button'] = $new_instance['show_calendar_button'] ? true : false;
110
- $instance['hide_on_calendar_page'] = $new_instance['hide_on_calendar_page'] ? true : false;
111
-
112
- // For limits, set the limit to False if no IDs were selected, or set the respective IDs to empty if "limit by" was unchecked
113
- $instance['limit_by_cat'] = false;
114
- $instance['event_cat_ids'] = array();
115
- if( isset( $new_instance['event_cat_ids'] ) && $new_instance['event_cat_ids'] != false ) {
116
- $instance['limit_by_cat'] = true;
117
- }
118
- if( isset( $new_instance['limit_by_cat'] ) && $new_instance['limit_by_cat'] != false ) {
119
- $instance['limit_by_cat'] = true;
120
- }
121
- if( isset( $new_instance['event_cat_ids'] ) && $instance['limit_by_cat'] === true ) {
122
- $instance['event_cat_ids'] = $new_instance['event_cat_ids'];
123
- }
124
-
125
- $instance['limit_by_tag'] = false;
126
- $instance['event_tag_ids'] = array();
127
- if( isset( $new_instance['event_tag_ids'] ) && $new_instance['event_tag_ids'] != false ) {
128
- $instance['limit_by_tag'] = true;
129
- }
130
- if( isset( $new_instance['limit_by_tag'] ) && $new_instance['limit_by_tag'] != false ) {
131
- $instance['limit_by_tag'] = true;
132
- }
133
- if( isset( $new_instance['event_tag_ids'] ) && $instance['limit_by_tag'] === true ) {
134
- $instance['event_tag_ids'] = $new_instance['event_tag_ids'];
135
- }
136
-
137
- $instance['limit_by_post'] = false;
138
- $instance['event_post_ids'] = array();
139
- if( isset( $new_instance['event_post_ids'] ) && $new_instance['event_post_ids'] != false ) {
140
- $instance['limit_by_post'] = true;
141
- }
142
- if( isset( $new_instance['limit_by_post'] ) && $new_instance['limit_by_post'] != false ) {
143
- $instance['limit_by_post'] = true;
144
- }
145
- if( isset( $new_instance['event_post_ids'] ) && $instance['limit_by_post'] === true ) {
146
- $instance['event_post_ids'] = $new_instance['event_post_ids'];
147
- }
148
-
149
- return $instance;
150
- }
151
-
152
- /**
153
- * widget function
154
- *
155
- * Outputs the given instance of the widget to the front-end.
156
- *
157
- * @param array $args Display arguments passed to the widget
158
- * @param array $instance The settings for this widget instance
159
- */
160
- function widget( $args, $instance )
161
- {
162
- global $ai1ec_view_helper,
163
- $ai1ec_events_helper,
164
- $ai1ec_calendar_helper,
165
- $ai1ec_settings,
166
- $ai1ec_themes_controller;
167
-
168
- if ( $ai1ec_themes_controller->frontend_outdated_themes_notice() ) {
169
- return;
170
- }
171
-
172
- $defaults = array(
173
- 'hide_on_calendar_page' => true,
174
- 'event_cat_ids' => array(),
175
- 'event_tag_ids' => array(),
176
- 'event_post_ids' => array(),
177
- 'events_per_page' => 10,
178
- );
179
- $instance = wp_parse_args( $instance, $defaults );
180
-
181
- if( $instance['hide_on_calendar_page'] &&
182
- is_page( $ai1ec_settings->calendar_page_id ) ) {
183
- return;
184
- }
185
-
186
- // Add params to the subscribe_url for filtering by Limits (category, tag)
187
- $subscribe_filter = '';
188
- $subscribe_filter .= $instance['event_cat_ids'] ? '&ai1ec_cat_ids=' . join( ',', $instance['event_cat_ids'] ) : '';
189
- $subscribe_filter .= $instance['event_tag_ids'] ? '&ai1ec_tag_ids=' . join( ',', $instance['event_tag_ids'] ) : '';
190
- $subscribe_filter .= $instance['event_post_ids'] ? '&ai1ec_post_ids=' . join( ',', $instance['event_post_ids'] ) : '';
191
-
192
- // Get localized time
193
- $timestamp = $ai1ec_events_helper->gmt_to_local( time() );
194
-
195
- // Set $limit to the specified category/tag
196
- $limit = array(
197
- 'cat_ids' => $instance['event_cat_ids'],
198
- 'tag_ids' => $instance['event_tag_ids'],
199
- 'post_ids' => $instance['event_post_ids'],
200
- );
201
-
202
- // Get events, then classify into date array
203
- $event_results = $ai1ec_calendar_helper->get_events_relative_to(
204
- $timestamp, $instance['events_per_page'], 0, $limit );
205
- $dates = $ai1ec_calendar_helper->get_agenda_date_array( $event_results['events'] );
206
-
207
- $args['title'] = $instance['title'];
208
- $args['show_subscribe_buttons'] = $instance['show_subscribe_buttons'];
209
- $args['show_calendar_button'] = $instance['show_calendar_button'];
210
- $args['dates'] = $dates;
211
- $args['show_location_in_title'] = $ai1ec_settings->show_location_in_title;
212
- $args['show_year_in_agenda_dates'] = $ai1ec_settings->show_year_in_agenda_dates;
213
- $args['calendar_url'] = $ai1ec_calendar_helper->get_calendar_url( null, $limit );
214
- $args['subscribe_url'] = AI1EC_EXPORT_URL . $subscribe_filter;
215
-
216
- $ai1ec_view_helper->display_theme( 'agenda-widget.php', $args );
217
- }
218
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/view/admin/css/add_new_event.css DELETED
@@ -1,526 +0,0 @@
1
- /* General form attributes */
2
- #ai1ec_event {
3
- overflow: hidden;
4
- }
5
- .ai1ec-form, .ai1ec-form-nested {
6
- width: 100%;
7
- margin-bottom: 1em;
8
- }
9
- .ai1ec-form td.ai1ec-first, .ai1ec-form-nested td.ai1ec-first {
10
- width: 8.5em;
11
- }
12
- .ai1ec-first-padding {
13
- padding-left: 8.5em;
14
- }
15
- .ai1ec-form label, .ai1ec-form-nested label {
16
- font-size: 9pt;
17
- }
18
- .ai1ec-form td, .ai1ec-form-nested td {
19
- line-height: 1.5em;
20
- }
21
- .ai1ec-section-title {
22
- text-transform: uppercase;
23
- border-bottom: 1px solid #eee;
24
- padding-bottom: 0.4em;
25
- color: #aaa;
26
- clear: both;
27
- }
28
-
29
- /* Recurrence fields */
30
- .ai1ec_hidden {
31
- display: none;
32
- }
33
- .ai1ec_week_days_list, .ai1ec_month_days_list, .ai1ec_yearly_months_list {
34
- margin: 0;
35
- padding: 0;
36
- list-style: none;
37
- }
38
- .ai1ec_week_days_list li, .ai1ec_month_days_list li, .ai1ec_yearly_months_list li {
39
- float: left;
40
- padding: 0.3em 0px;
41
- width: 2.2em;
42
- border: 1px solid #DFDFDF;
43
- border-radius: 0.4em;
44
- -moz-border-radius: 0.4em;
45
- -webkit-border-radius: 0.4em;
46
- margin-right: 0.2em;
47
- background-color: #fff;
48
- text-align: center;
49
- }
50
- .ai1ec_yearly_months_list li {
51
- width: 2.5em !important;
52
- padding: 0.5em 0 !important;
53
- }
54
-
55
- .ai1ec_week_days_list li:hover, .ai1ec_month_days_list li:hover, .ai1ec_yearly_months_list li:hover {
56
- cursor: pointer;
57
- }
58
-
59
- .ai1ec_selected {
60
- background-color: #e2e2e2 !important;
61
- }
62
-
63
- /* Event post fields */
64
- .ai1ec-date-input {
65
- width: 7em;
66
- }
67
- .ai1ec-time-input {
68
- width: 5.5em;
69
- }
70
- #ai1ec_venue, #ai1ec_address, #ai1ec_cost,
71
- #ai1ec_contact_name, #ai1ec_contact_phone, #ai1ec_contact_email {
72
- width: 100%;
73
- max-width: 20em;
74
- }
75
- .ai1ec-form.ai1ec-location-form {
76
- float: left;
77
- width: 33em;
78
- }
79
- #side-info-column .ai1ec-form.ai1ec-location-form {
80
- float: none;
81
- width: 100%;
82
- }
83
-
84
- /* Address autocomplete */
85
- .ac_results img {
86
- float: left;
87
- margin: 0.2em 0.7em 0.2em 0.2em;
88
- }
89
-
90
- /* Google map */
91
- .ai1ec_box_map {
92
- float: right;
93
- margin-bottom: 1em;
94
- margin-top: -11em;
95
- /* These are needed for proper map initialization: */
96
- position: absolute;
97
- visibility: hidden;
98
- border: 1px solid #ddd;
99
- }
100
- .ai1ec_box_map.ai1ec_box_map_visible {
101
- position: static;
102
- visibility: visible;
103
- }
104
- #ai1ec_map_canvas {
105
- width: 264px;
106
- height: 16em;
107
- }
108
- /* Bottom publish button */
109
- .ai1ec_bottom_publish {
110
- min-width: 80px;
111
- text-align: center;
112
- }
113
-
114
- /* CSS for Calendrical */
115
- .calendricalDatePopup, .calendricalTimePopup {
116
- z-index: 2;
117
- }
118
- .calendricalDatePopup {
119
- background: white;
120
- border: solid 1px #999999;
121
- padding: 2px;
122
- text-align: center;
123
- width: 200px; }
124
- .calendricalDatePopup table {
125
- border-collapse: collapse;
126
- width: 200px; }
127
- .calendricalDatePopup table .monthCell {
128
- padding: 2px 0; }
129
- .calendricalDatePopup table .monthCell a {
130
- display: block;
131
- float: left;
132
- line-height: 20px; }
133
- .calendricalDatePopup table .monthCell .prevMonth, .calendricalDatePopup table .monthCell .nextMonth {
134
- width: 24px; }
135
- .calendricalDatePopup table .monthCell .monthName {
136
- width: 150px; }
137
- .calendricalDatePopup table a {
138
- text-decoration: none !important; padding: 0; }
139
- .calendricalDatePopup table th {
140
- text-align: center; }
141
- .calendricalDatePopup table td {
142
- text-align: center;
143
- font-size: 12px;
144
- padding: 0;
145
- font-family: inherit; }
146
- .calendricalDatePopup table td a {
147
- display: block;
148
- color: black;
149
- padding: 2px 3px; }
150
- .calendricalDatePopup table td a:hover {
151
- background: #ccccff;
152
- border: none;
153
- padding: 2px 3px; }
154
- .calendricalDatePopup table td.today a {
155
- background: #f8f8c0; }
156
- .calendricalDatePopup table td.selected a {
157
- background: #ccccff; }
158
- .calendricalDatePopup table td.today_selected a {
159
- background: #f8f8c0;
160
- border: solid 1px #dddd66;
161
- padding: 1px 2px; }
162
- .calendricalDatePopup table td.nonMonth a {
163
- color: #999999; }
164
-
165
- .calendricalTimePopup {
166
- background: white;
167
- border: solid 1px #999999;
168
- width: 110px;
169
- height: 130px;
170
- overflow: auto; }
171
- .calendricalTimePopup ul {
172
- margin: 0 !important;
173
- padding: 0 !important; }
174
- .calendricalTimePopup ul li {
175
- list-style: none !important;
176
- padding: 0 !important;
177
- margin: 0; }
178
- .calendricalTimePopup ul li a, .calendricalTimePopup ul li a:visited {
179
- text-indent: 10px;
180
- padding: 4px;
181
- display: block;
182
- color: black;
183
- text-decoration: none !important; }
184
- .calendricalTimePopup ul li a:hover, .calendricalTimePopup ul li.selected a {
185
- background: #ccccff; }
186
-
187
- .calendricalEndTimePopup {
188
- width: 200px; }
189
-
190
-
191
- /**
192
- * Range input rules (from jQuery Tools)
193
- **/
194
-
195
- /* slider root element */
196
- .ai1ec-slider {
197
- background:#eee;
198
- height:0.4em;
199
- position:relative;
200
- cursor:pointer;
201
- border:1px solid #ccc;
202
- width:8.8em;
203
- margin: 0.7em 0.25em 0 0;
204
- float:left;
205
- clear:right;
206
- border-radius:3px;
207
- -moz-border-radius:3px;
208
- -webkit-border-radius:3px;
209
- }
210
- /* progress bar (enabled with progress: true) */
211
- .ai1ec-progress {
212
- height: 0.5em;
213
- background-color:#C5FF00;
214
- display:none;
215
- }
216
- /* drag handle */
217
- .ai1ec-handle {
218
- background:#fff;
219
- height:1em;
220
- width:1em;
221
- top:-0.5em;
222
- margin-top: 1px;
223
- position:absolute;
224
- z-index: 0;
225
- display:block;
226
- border:1px solid #ccc;
227
- cursor:move;
228
- border-radius: 0.25em;
229
- -moz-border-radius:0.25em;
230
- -webkit-border-radius:0.25em;
231
- box-shadow: 0 2px 5px rgba(0,0,0,0.15);
232
- -moz-box-shadow: 0 2px 5px rgba(0,0,0,0.15);
233
- -webkit-box-shadow: 0 2px 5px rgba(0,0,0,0.15);
234
- }
235
- /* the input field */
236
- .ai1ec-range {
237
- text-align:center;
238
- width:3em;
239
- border: 1px solid #dfdfdf;
240
- background: #fff;
241
- border-radius: 4px;
242
- -moz-border-radius: 4px;
243
- -webkit-border-radius: 4px;
244
- -moz-box-sizing: border-box;
245
- -webkit-box-sizing: border-box;
246
- -ms-box-sizing: border-box;
247
- box-sizing: border-box;
248
- }
249
- /* date select list */
250
- .ai1ec_date_select {
251
- margin: 0;
252
- padding: 0;
253
- list-style: none;
254
- }
255
- .ai1ec_date_select li {
256
- float: left;
257
- width: 20px;
258
- padding: 3px 3px;
259
- -moz-border-radius: 3px;
260
- border-radius: 3px;
261
- border: 1px solid #ccc;
262
- text-align: center;
263
- margin-right: 5px;
264
- background: #f6f8f9; /* Old browsers */
265
- background: -moz-linear-gradient(top, #f6f8f9 0%, #e5ebee 50%, #d7dee3 51%, #f5f7f9 100%); /* FF3.6+ */
266
- background: -webkit-gradient(linear, left top, left bottom, color-stop(0%,#f6f8f9), color-stop(50%,#e5ebee), color-stop(51%,#d7dee3), color-stop(100%,#f5f7f9)); /* Chrome,Safari4+ */
267
- background: -webkit-linear-gradient(top, #f6f8f9 0%,#e5ebee 50%,#d7dee3 51%,#f5f7f9 100%); /* Chrome10+,Safari5.1+ */
268
- background: -o-linear-gradient(top, #f6f8f9 0%,#e5ebee 50%,#d7dee3 51%,#f5f7f9 100%); /* Opera 11.10+ */
269
- background: -ms-linear-gradient(top, #f6f8f9 0%,#e5ebee 50%,#d7dee3 51%,#f5f7f9 100%); /* IE10+ */
270
- background: linear-gradient(top, #f6f8f9 0%,#e5ebee 50%,#d7dee3 51%,#f5f7f9 100%); /* W3C */
271
- filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#f6f8f9', endColorstr='#f5f7f9',GradientType=0 ); /* IE6-9 */
272
- cursor: pointer;
273
- }
274
- .ai1ec_date_select li:hover {
275
- background: #f5f7f9; /* Old browsers */
276
- background: -moz-linear-gradient(top, #f5f7f9 0%, #d7dee3 49%, #e5ebee 50%, #f6f8f9 100%); /* FF3.6+ */
277
- background: -webkit-gradient(linear, left top, left bottom, color-stop(0%,#f5f7f9), color-stop(49%,#d7dee3), color-stop(50%,#e5ebee), color-stop(100%,#f6f8f9)); /* Chrome,Safari4+ */
278
- background: -webkit-linear-gradient(top, #f5f7f9 0%,#d7dee3 49%,#e5ebee 50%,#f6f8f9 100%); /* Chrome10+,Safari5.1+ */
279
- background: -o-linear-gradient(top, #f5f7f9 0%,#d7dee3 49%,#e5ebee 50%,#f6f8f9 100%); /* Opera 11.10+ */
280
- background: -ms-linear-gradient(top, #f5f7f9 0%,#d7dee3 49%,#e5ebee 50%,#f6f8f9 100%); /* IE10+ */
281
- background: linear-gradient(top, #f5f7f9 0%,#d7dee3 49%,#e5ebee 50%,#f6f8f9 100%); /* W3C */
282
- filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#f5f7f9', endColorstr='#f6f8f9',GradientType=0 ); /* IE6-9 */
283
- }
284
- .ai1ec_date_select li.ai1ec_selected {
285
- background: #deefff; /* Old browsers */
286
- background: -moz-linear-gradient(top, #deefff 0%, #98bede 100%); /* FF3.6+ */
287
- background: -webkit-gradient(linear, left top, left bottom, color-stop(0%,#deefff), color-stop(100%,#98bede)); /* Chrome,Safari4+ */
288
- background: -webkit-linear-gradient(top, #deefff 0%,#98bede 100%); /* Chrome10+,Safari5.1+ */
289
- background: -o-linear-gradient(top, #deefff 0%,#98bede 100%); /* Opera 11.10+ */
290
- background: -ms-linear-gradient(top, #deefff 0%,#98bede 100%); /* IE10+ */
291
- background: linear-gradient(top, #deefff 0%,#98bede 100%); /* W3C */
292
- filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#deefff', endColorstr='#98bede',GradientType=0 ); /* IE6-9 */
293
- }
294
- .ai1ec_date_select li.ai1ec_selected:hover {
295
- background: #98bede; /* Old browsers */
296
- background: -moz-linear-gradient(top, #98bede 0%, #deefff 100%); /* FF3.6+ */
297
- background: -webkit-gradient(linear, left top, left bottom, color-stop(0%,#98bede), color-stop(100%,#deefff)); /* Chrome,Safari4+ */
298
- background: -webkit-linear-gradient(top, #98bede 0%,#deefff 100%); /* Chrome10+,Safari5.1+ */
299
- background: -o-linear-gradient(top, #98bede 0%,#deefff 100%); /* Opera 11.10+ */
300
- background: -ms-linear-gradient(top, #98bede 0%,#deefff 100%); /* IE10+ */
301
- background: linear-gradient(top, #98bede 0%,#deefff 100%); /* W3C */
302
- filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#98bede', endColorstr='#deefff',GradientType=0 ); /* IE6-9 */
303
- }
304
- /* week days list */
305
- #ai1ec_weekly_date_select {
306
- margin-left: 25px;
307
- }
308
- /* month days list */
309
- #ai1ec_montly_date_select {
310
- width: 231px;
311
- margin-left: 25px;
312
- }
313
- /* yearly months list */
314
- #ai1ec_yearly_date_select {
315
- width: 208px;
316
- margin-left: 30px;
317
- }
318
- #ai1ec_yearly_date_select li {
319
- padding: 10px 5px;
320
- width: 35px;
321
- }
322
-
323
- #ai1ec_repeat_box {
324
- display: none;
325
- margin-top: 10px;
326
- width: 450px;
327
- }
328
- ul.ai1ec_repeat_tabs {
329
- margin:0px; padding:0px;
330
- margin-bottom: 6px;
331
- margin-left: 15px;
332
- width: 95%;
333
- text-align: left;
334
- }
335
-
336
- ul.ai1ec_repeat_tabs li {
337
- list-style: none;
338
- display:inline;
339
- }
340
- ul.ai1ec_repeat_tabs li a {
341
- background-color:#464c54;
342
- color:#ffebb5;
343
- padding:8px 14px 8px 14px;
344
- text-decoration:none;
345
- font-size:9px;
346
- font-family:Verdana, Arial, Helvetica, sans-serif;
347
- font-weight:bold;
348
- text-transform:uppercase;
349
- border:1px solid #464c54;
350
- -webkit-border-top-left-radius: 5px;
351
- -webkit-border-top-right-radius: 5px;
352
- -moz-border-radius-topleft: 5px;
353
- -moz-border-radius-topright: 5px;
354
- border-top-left-radius: 5px;
355
- border-top-right-radius: 5px;
356
- }
357
- ul.ai1ec_repeat_tabs li a:hover {
358
- background-color:#2f343a;
359
- border-color:#2f343a;
360
- }
361
- ul.ai1ec_repeat_tabs li a.ai1ec_active {
362
- background-color:#ffffff;
363
- color:#282e32;
364
- border:1px solid #464c54;
365
- border-bottom: 1px solid #ffffff;
366
- padding-bottom: 9px;
367
- }
368
- .ai1ec_tab_content {
369
- background-color:#ffffff;
370
- padding:10px;
371
- border:1px solid #464c54;
372
- margin-top: -1px;
373
- -webkit-border-radius: 5px;
374
- -moz-border-radius: 5px;
375
- border-radius: 5px;
376
- cursor: normal !important;
377
- }
378
- #ai1ec_weekly_content, #ai1ec_monthly_content, #ai1ec_yearly_content { display:none; }
379
- .ai1ec_repeat_centered_content {
380
- width: 100%;
381
- text-align: center;
382
- float: left;
383
- border-bottom: 1px solid #EEE;
384
- padding-bottom: 10px;
385
- }
386
- #ai1ec_apply_button_holder {
387
- width: 100%;
388
- text-align: center;
389
- float: left;
390
- }
391
- .ai1ec_tab_content label {
392
- float: left;
393
- width: 61px;
394
- text-align: left;
395
- }
396
- #ai1c_repeat_monthly_byday {
397
- display: none;
398
- float: left;
399
- }
400
- .ai1ec_repeat_monthly_type {
401
- float: left;
402
- clear: both;
403
- margin: 0.4em 0;
404
- }
405
- .ai1ec_repeat_monthly_type label {
406
- float: none;
407
- }
408
- #ai1ec_ending_box, #ai1ec_end_holder, #ai1ec_repeat_text, #ai1ec_exclude_text {
409
- float: left;
410
- }
411
- #ai1ec_repeat_text a, #ai1ec_exclude_text a {
412
- text-decoration: none;
413
- border-bottom: 1px dashed red;
414
- }
415
- #ai1ec_exclude_text {
416
- margin-right: 20px;
417
- }
418
- #ai1ec_ending_box, #ai1ec_apply_button_holder {
419
- margin-top: 10px;
420
- }
421
- .ai1ec_repeat_cancel {
422
- color: red;
423
- text-decoration: none;
424
- border-bottom: 1px solid red;
425
- }
426
- a.ai1ec_repeat_cancel:hover {
427
- color: white;
428
- background-color: red;
429
- }
430
- #ai1ec_count_holder, #ai1ec_until_holder {
431
- display: none;
432
- }
433
- #ai1ec_until_holder input {
434
- float: left;
435
- }
436
- #ai1ec_end_holder {
437
- height: 30px;
438
- }
439
- #menu-posts-ai1ec_event > div.wp-menu-image {
440
- background-image: url( '../img/admin-menu.png' ) !important;
441
- }
442
- div.growlUI h1, div.growlUI h2 {
443
- color: white; padding: 5px 5px 5px 75px; text-align: left
444
- }
445
- /* General AJAX */
446
- .ai1ec-repeat-box-loading {
447
- padding-left: 163px;
448
- width: 31px;
449
- height: 31px;
450
- background: url( ../img/ajax-loader.gif ) no-repeat center right !important;
451
- }
452
- #ai1ec-date-picker-input {
453
- width: 0px;
454
- height: 0px;
455
- }
456
- /* Exclude date style*/
457
- #datepicker-widget {
458
- position: relative;
459
- }
460
- #widgetField {
461
- width: 290px;
462
- height: 26px;
463
- background: url(../img/field.png);
464
- overflow: hidden;
465
- position: relative;
466
- }
467
- #widgetField a {
468
- display: block;
469
- position: absolute;
470
- width: 26px;
471
- height: 26px;
472
- top: 0;
473
- right: 0;
474
- text-decoration: none;
475
- text-indent: -3000px;
476
- }
477
- #widgetField span {
478
- font-size: 12px;
479
- font-weight: bold;
480
- color: #000;
481
- position: absolute;
482
- top: 0;
483
- height: 26px;
484
- line-height: 26px;
485
- left: 5px;
486
- width: 250px;
487
- text-align: center;
488
- cursor: pointer;
489
- }
490
- #widgetCalendar {
491
- position: absolute;
492
- top: 26px;
493
- left: 0;
494
- height: 0px;
495
- overflow: hidden;
496
- width: 588px;
497
- background: #B9B9B9;
498
- z-index: 2;
499
- }
500
- #widgetCalendar .datepicker {
501
- position: absolute;
502
- bottom: 0;
503
- top: auto;
504
- }
505
- #widgetCalendar .datepickerContainer,
506
- #widgetCalendar .datepickerBorderT,
507
- #widgetCalendar .datepickerBorderB,
508
- #widgetCalendar .datepickerBorderL,
509
- #widgetCalendar .datepickerBorderR,
510
- #widgetCalendar .datepickerBorderTL,
511
- #widgetCalendar .datepickerBorderTR,
512
- #widgetCalendar .datepickerBorderBL,
513
- #widgetCalendar .datepickerBorderBR {
514
- background: transparent !important;
515
- }
516
- #widgetCalendar .datepicker a:hover{
517
- color: #b6f063;
518
- }
519
- .ai1ec-info-text {
520
- font-size: 10px;
521
- float: left;
522
- }
523
- /* input coordinates */
524
- #ai1ec-inside-wrapper{
525
- width: 33em;
526
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/view/admin/css/admin.css DELETED
@@ -1,16 +0,0 @@
1
- #icon-edit.icon32-posts-ai1ec_event,
2
- #icon-post.icon32-posts-ai1ec_event {
3
- background: url(../img/logo.png) no-repeat center center;
4
- }
5
- .timely.ai1ec-upgrade-notice .btn {
6
- font-size: 12px;
7
- position: relative;
8
- top: -1px;
9
- }
10
- .timely.ai1ec-upgrade-notice .btn span {
11
- font-size: 14px;
12
- }
13
- .timely.ai1ec-upgrade-notice > span {
14
- display: inline-block;
15
- margin-bottom: 6px;
16
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/view/admin/css/bootstrap.min.css DELETED
@@ -1,9 +0,0 @@
1
- @import url("http://fonts.googleapis.com/css?family=Signika:300");@import url("http://fonts.googleapis.com/css?family=Signika:600");/*!
2
- * Bootstrap v2.0.2
3
- *
4
- * Copyright 2012 Twitter, Inc
5
- * Licensed under the Apache License v2.0
6
- * http://www.apache.org/licenses/LICENSE-2.0
7
- *
8
- * Designed and built with all the love in the world @twitter by @mdo and @fat.
9
- */@font-face{font-family:'Timely Icons';src:url('../font/timely-icons.eot');src:url('../font/timely-icons.eot?#iefix') format('embedded-opentype'),url('../font/timely-icons.svg#Timely-Icons') format('svg'),url('../font/timely-icons.woff') format('woff'),url('../font/timely-icons.ttf') format('truetype');font-weight:normal;font-style:normal}[class^="timely-icon-"]:before,[class*=" timely-icon-"]:before{display:inline-block;font-family:'Timely Icons';font-style:normal;font-weight:normal;speak:none;vertical-align:top}.timely-icon-large:before{font-size:1.25em}.timely .btn .timely-icon-large[class^="timely-icon-"],.timely .btn .timely-icon-large[class*=" timely-icon-"]{line-height:1.1em}.timely li [class^="timely-icon-"],.timely li [class*=" timely-icon-"]{display:inline-block;text-align:center;width:1.25em}.timely li .timely-icon-large[class^="timely-icon-"],.timely li .timely-icon-large[class*=" timely-icon-"]{width:1.875em}.timely li[class^="timely-icon-"],.timely li[class*=" timely-icon-"]{list-style-type:none;margin-left:0}.timely li[class^="timely-icon-"]:before,.timely li[class*=" timely-icon-"]:before{text-align:center;text-indent:-2em}.timely li[class^="timely-icon-"].timely-icon-large:before,.timely li[class*=" timely-icon-"].icon-large:before{text-indent:-1.3333333333333333em}.timely-icon-timely-logomark:before{content:"\21"}.timely-icon-import-events:before{content:"\22"}.timely-icon-export-events:before{content:"\23"}.timely-icon-facebook-sync:before{content:"\24"}.timely-icon-filter-tag-category:before{content:"\25"}.timely-icon-subscribe-events:before{content:"\26"}.timely-icon-recurring-events:before{content:"\27"}.timely-icon-multiple-views:before{content:"\28"}.timely-icon-customizable-views:before{content:"\29"}.timely-icon-upcoming-events-widget:before{content:"\2a"}.timely-icon-locations-maps:before{content:"\2b"}.timely-icon-seo-optimized:before{content:"\2c"}.timely-icon-dedicated-support:before{content:"\2d";font-size:1.2em}.timely-icon-plus-sign:before{content:"\2e"}.timely-icon-minus-sign:before{content:"\2f"}.timely-icon-pencil:before{content:"\3c"}.timely-icon-gear:before{content:"\3e"}.timely-icon-tag:before{content:"\3f"}.timely-icon-forward:before{content:"\3b"}.timely-icon-close:before{content:"\3a"}.timely-icon-heart:before{content:"\3d"}.timely-icon-folder:before{content:"\40"}.timely-icon-grid:before{content:"\41"}.timely-icon-print:before{content:"\38"}.timely-icon-share:before{content:"\39"}.timely-icon-event:before{content:"\44"}.timely-icon-location:before{content:"\45"}.timely-icon-arrow-right:before{content:"\46"}.timely-icon-arrow-up:before{content:"\47"}.timely-icon-arrow-down:before{content:"\48"}.timely-icon-chevron-down:before{content:"\4a"}.timely-icon-chevron-up:before{content:"\4b"}.timely-icon-arrow-left:before{content:"\4c"}.timely-icon-chevron-left:before{content:"\4d";position:relative;top:.1em}.timely-icon-chevron-right:before{content:"\4e";position:relative;top:.1em}.timely-icon-time:before{content:"\4f"}.timely-icon-plus:before{content:"\30"}.timely-icon-minus:before{content:"\31"}.timely-icon-shopping-cart:before{content:"\32"}.timely-icon-gift:before{content:"\33"}.timely-icon-checkmark:before{content:"\34"}.clearfix{*zoom:1}.clearfix:before,.clearfix:after{display:table;content:""}.clearfix:after{clear:both}.hide-text{overflow:hidden;text-indent:100%;white-space:nowrap}.input-block-level{display:block;width:100%;min-height:28px;-webkit-box-sizing:border-box;-moz-box-sizing:border-box;-ms-box-sizing:border-box;box-sizing:border-box}.modal-open .dropdown-menu{z-index:2050}.modal-open .dropdown.open{*z-index:2050}.modal-open .popover{z-index:2060}.modal-open .tooltip{z-index:2070}.modal-backdrop{position:fixed;top:0;right:0;bottom:0;left:0;z-index:1040;background-color:#000}.modal-backdrop.fade{opacity:0}.modal-backdrop,.modal-backdrop.fade.in{opacity:.8;filter:alpha(opacity=80)}.modal{position:fixed;top:50%;left:50%;z-index:1050;overflow:auto;width:560px;margin:-250px 0 0 -280px;background-color:#fff;border:1px solid #999;border:1px solid rgba(0,0,0,0.3);*border:1px solid #999;-webkit-border-radius:6px;-moz-border-radius:6px;border-radius:6px;-webkit-box-shadow:0 3px 7px rgba(0,0,0,0.3);-moz-box-shadow:0 3px 7px rgba(0,0,0,0.3);box-shadow:0 3px 7px rgba(0,0,0,0.3);-webkit-background-clip:padding-box;-moz-background-clip:padding-box;background-clip:padding-box}.modal.fade{-webkit-transition:opacity .3s linear,top .3s ease-out;-moz-transition:opacity .3s linear,top .3s ease-out;-ms-transition:opacity .3s linear,top .3s ease-out;-o-transition:opacity .3s linear,top .3s ease-out;transition:opacity .3s linear,top .3s ease-out;top:-25%}.modal.fade.in{top:50%}.modal-header{padding:9px 15px;border-bottom:1px solid #eee}.modal-header .close{margin-top:2px}.modal-body{overflow-y:auto;max-height:400px;padding:15px}.modal-form{margin-bottom:0}.modal-footer{padding:14px 15px 15px;margin-bottom:0;text-align:right;background-color:#f5f5f5;border-top:1px solid #ddd;-webkit-border-radius:0 0 6px 6px;-moz-border-radius:0 0 6px 6px;border-radius:0 0 6px 6px;-webkit-box-shadow:inset 0 1px 0 #fff;-moz-box-shadow:inset 0 1px 0 #fff;box-shadow:inset 0 1px 0 #fff;*zoom:1}.modal-footer:before,.modal-footer:after{display:table;content:""}.modal-footer:after{clear:both}.modal-footer .btn+.btn{margin-left:5px;margin-bottom:0}.modal-footer .btn-group .btn+.btn{margin-left:-1px}.popover{position:absolute;top:0;left:0;z-index:1010;display:none;padding:5px}.popover.top{margin-top:-5px}.popover.right{margin-left:5px}.popover.bottom{margin-top:5px}.popover.left{margin-left:-5px}.popover.top .arrow{bottom:0;left:50%;margin-left:-5px;border-left:5px solid transparent;border-right:5px solid transparent;border-top:5px solid #000}.popover.right .arrow{top:50%;left:0;margin-top:-5px;border-top:5px solid transparent;border-bottom:5px solid transparent;border-right:5px solid #000}.popover.bottom .arrow{top:0;left:50%;margin-left:-5px;border-left:5px solid transparent;border-right:5px solid transparent;border-bottom:5px solid #000}.popover.left .arrow{top:50%;right:0;margin-top:-5px;border-top:5px solid transparent;border-bottom:5px solid transparent;border-left:5px solid #000}.popover .arrow{position:absolute;width:0;height:0}.popover-inner{padding:3px;width:280px;overflow:hidden;background:#000;background:rgba(0,0,0,0.8);-webkit-border-radius:6px;-moz-border-radius:6px;border-radius:6px;-webkit-box-shadow:0 3px 7px rgba(0,0,0,0.3);-moz-box-shadow:0 3px 7px rgba(0,0,0,0.3);box-shadow:0 3px 7px rgba(0,0,0,0.3)}.popover-title{padding:9px 15px;line-height:1;background-color:#f5f5f5;border-bottom:1px solid #eee;-webkit-border-radius:3px 3px 0 0;-moz-border-radius:3px 3px 0 0;border-radius:3px 3px 0 0}.popover-content{padding:14px;background-color:#fff;-webkit-border-radius:0 0 3px 3px;-moz-border-radius:0 0 3px 3px;border-radius:0 0 3px 3px;-webkit-background-clip:padding-box;-moz-background-clip:padding-box;background-clip:padding-box}.popover-content p,.popover-content ul,.popover-content ol{margin-bottom:0}.fade{-webkit-transition:opacity .15s linear;-moz-transition:opacity .15s linear;-ms-transition:opacity .15s linear;-o-transition:opacity .15s linear;transition:opacity .15s linear;opacity:0}.fade.in{opacity:1}.collapse{-webkit-transition:height .35s ease;-moz-transition:height .35s ease;-ms-transition:height .35s ease;-o-transition:height .35s ease;transition:height .35s ease;position:relative;overflow:hidden;height:0}.collapse.in{height:auto}.popover-title{-webkit-border-radius:4px 4px 0 0;-moz-border-radius:4px 4px 0 0;border-radius:4px 4px 0 0;font-family:Signika,'Helvetica Neue',Helvetica,Arial,sans-serif;font-size:16.25px!important;margin:0!important}.popover-content p{margin:0}.popover-inner{background-color:rgba(0,0,0,0.2);padding:1px}.popover-content{-webkit-border-radius:0 0 4px 4px;-moz-border-radius:0 0 4px 4px;border-radius:0 0 4px 4px}.popover{padding:8px}.popover.top{margin-top:-8px}.popover.right{margin-left:8px}.popover.bottom{margin-top:8px}.popover.left{margin-left:-8px}.popover.top .arrow{bottom:0;left:50%;margin-left:-8px;border-left:8px solid transparent;border-right:8px solid transparent;border-top:8px solid rgba(0,0,0,0.2)}.popover.right .arrow{top:50%;left:0;margin-top:-8px;border-top:8px solid transparent;border-bottom:8px solid transparent;border-right:8px solid rgba(0,0,0,0.2)}.popover.bottom .arrow{top:0;left:50%;margin-left:-8px;border-left:8px solid transparent;border-right:8px solid transparent;border-bottom:8px solid rgba(0,0,0,0.2)}.popover.left .arrow{top:50%;right:0;margin-top:-8px;border-top:8px solid transparent;border-bottom:8px solid transparent;border-left:8px solid rgba(0,0,0,0.2)}.popover ul.icons{text-indent:-0.25em}ul.icons{margin-left:2em}.timely{font-family:Arial,sans-serif;font-size:13px;font-weight:300;line-height:18px;color:#333}.timely article,.timely aside,.timely details,.timely figcaption,.timely figure,.timely footer,.timely header,.timely hgroup,.timely nav,.timely section{display:block}.timely audio,.timely canvas,.timely video{display:inline-block;*display:inline;*zoom:1}.timely audio:not([controls]){display:none}.timely html{font-size:100%;-webkit-text-size-adjust:100%;-ms-text-size-adjust:100%}.timely a:focus{outline:thin dotted #333;outline:5px auto -webkit-focus-ring-color;outline-offset:-2px}.timely a:hover,.timely a:active{outline:0}.timely sub,.timely sup{position:relative;font-size:75%;line-height:0;vertical-align:baseline}.timely sup{top:-0.5em}.timely sub{bottom:-0.25em}.timely img{height:auto;border:0;-ms-interpolation-mode:bicubic;vertical-align:middle}.timely button,.timely input,.timely select,.timely textarea{margin:0;font-size:100%;vertical-align:middle}.timely button,.timely input{*overflow:visible;line-height:normal}.timely button::-moz-focus-inner,.timely input::-moz-focus-inner{padding:0;border:0}.timely button,.timely input[type="button"],.timely input[type="reset"],.timely input[type="submit"]{cursor:pointer;-webkit-appearance:button}.timely input[type="search"]{-webkit-appearance:textfield;-webkit-box-sizing:content-box;-moz-box-sizing:content-box;box-sizing:content-box}.timely input[type="search"]::-webkit-search-decoration,.timely input[type="search"]::-webkit-search-cancel-button{-webkit-appearance:none}.timely textarea{overflow:auto;vertical-align:top}.timely body{margin:0;font-family:Arial,sans-serif;font-size:13px;line-height:18px;color:#333;background-color:#fff}.timely a{color:#6aab2d;text-decoration:none}.timely a:hover{color:#456e1d;text-decoration:underline}.timely .row{margin-left:-20px;*zoom:1}.timely .row:before,.timely .row:after{display:table;content:""}.timely .row:after{clear:both}.timely [class*="span"]{float:left;margin-left:20px}.timely .container,.timely .navbar-fixed-top .container,.timely .navbar-fixed-bottom .container{width:940px}.timely .span12{width:940px}.timely .span11{width:860px}.timely .span10{width:780px}.timely .span9{width:700px}.timely .span8{width:620px}.timely .span7{width:540px}.timely .span6{width:460px}.timely .span5{width:380px}.timely .span4{width:300px}.timely .span3{width:220px}.timely .span2{width:140px}.timely .span1{width:60px}.timely .offset12{margin-left:980px}.timely .offset11{margin-left:900px}.timely .offset10{margin-left:820px}.timely .offset9{margin-left:740px}.timely .offset8{margin-left:660px}.timely .offset7{margin-left:580px}.timely .offset6{margin-left:500px}.timely .offset5{margin-left:420px}.timely .offset4{margin-left:340px}.timely .offset3{margin-left:260px}.timely .offset2{margin-left:180px}.timely .offset1{margin-left:100px}.timely .row-fluid{width:100%;*zoom:1}.timely .row-fluid:before,.timely .row-fluid:after{display:table;content:""}.timely .row-fluid:after{clear:both}.timely .row-fluid>[class*="span"]{float:left;margin-left:2.127659574%}.timely .row-fluid>[class*="span"]:first-child{margin-left:0}.timely .row-fluid>.span12{width:99.99999998999999%}.timely .row-fluid>.span11{width:91.489361693%}.timely .row-fluid>.span10{width:82.97872339599999%}.timely .row-fluid>.span9{width:74.468085099%}.timely .row-fluid>.span8{width:65.95744680199999%}.timely .row-fluid>.span7{width:57.446808505%}.timely .row-fluid>.span6{width:48.93617020799999%}.timely .row-fluid>.span5{width:40.425531911%}.timely .row-fluid>.span4{width:31.914893614%}.timely .row-fluid>.span3{width:23.404255317%}.timely .row-fluid>.span2{width:14.89361702%}.timely .row-fluid>.span1{width:6.382978723%}.timely p{margin:0 0 9px;font-family:Arial,sans-serif;font-size:13px;line-height:18px}.timely p small{font-size:11px;color:#999}.timely .lead{margin-bottom:18px;font-size:20px;font-weight:200;line-height:27px}.timely h1,.timely h2,.timely h3,.timely h4,.timely h5,.timely h6{margin:0;font-family:Signika,'Helvetica Neue',Helvetica,Arial,sans-serif;font-weight:bold;color:#333;text-rendering:optimizelegibility}.timely h1 small,.timely h2 small,.timely h3 small,.timely h4 small,.timely h5 small,.timely h6 small{font-weight:normal;color:#999}.timely h1{font-size:30px;line-height:36px}.timely h1 small{font-size:18px}.timely h2{font-size:24px;line-height:36px}.timely h2 small{font-size:18px}.timely h3{line-height:27px;font-size:18px}.timely h3 small{font-size:14px}.timely h4,.timely h5,.timely h6{line-height:18px}.timely h4{font-size:14px}.timely h4 small{font-size:12px}.timely h5{font-size:12px}.timely h6{font-size:11px;color:#999;text-transform:uppercase}.timely .page-header{padding-bottom:17px;margin:18px 0;border-bottom:1px solid #eee}.timely .page-header h1{line-height:1}.timely ul,.timely ol{padding:0;margin:0 0 9px 25px}.timely ul ul,.timely ul ol,.timely ol ol,.timely ol ul{margin-bottom:0}.timely ul{list-style:disc}.timely ol{list-style:decimal}.timely li{line-height:18px}.timely ul.unstyled,.timely ol.unstyled{margin-left:0;list-style:none}.timely dl{margin-bottom:18px}.timely dt,.timely dd{line-height:18px}.timely dt{font-weight:bold;line-height:17px}.timely dd{margin-left:9px}.timely .dl-horizontal dt{float:left;clear:left;width:120px;text-align:right}.timely .dl-horizontal dd{margin-left:130px}.timely hr{margin:18px 0;border:0;border-top:1px solid #eee;border-bottom:1px solid #fff}.timely strong{font-weight:bold}.timely em{font-style:italic}.timely .muted{color:#999}.timely abbr[title]{border-bottom:1px dotted #ddd;cursor:help}.timely abbr.initialism{font-size:90%;text-transform:uppercase}.timely blockquote{padding:0 0 0 15px;margin:0 0 18px;border-left:5px solid #eee}.timely blockquote p{margin-bottom:0;font-size:16px;font-weight:300;line-height:22.5px}.timely blockquote small{display:block;line-height:18px;color:#999}.timely blockquote small:before{content:'\2014 \00A0'}.timely blockquote.pull-right{float:right;padding-left:0;padding-right:15px;border-left:0;border-right:5px solid #eee}.timely blockquote.pull-right p,.timely blockquote.pull-right small{text-align:right}.timely q:before,.timely q:after,.timely blockquote:before,.timely blockquote:after{content:""}.timely address{display:block;margin-bottom:18px;line-height:18px;font-style:normal}.timely small{font-size:100%}.timely cite{font-style:normal}.timely .close{float:right;font-size:20px;font-weight:bold;line-height:18px;color:#000;text-shadow:0 1px 0 #fff;opacity:.2;filter:alpha(opacity=20)}.timely .close:hover{color:#000;text-decoration:none;cursor:pointer;opacity:.4;filter:alpha(opacity=40)}.timely button.close{padding:0;cursor:pointer;background:transparent;border:0;-webkit-appearance:none}.timely .btn{display:inline-block;*display:inline;*zoom:1;padding:4px 10px 4px;margin-bottom:0;font-size:13px;line-height:18px;color:#333;text-align:center;text-shadow:0 1px 1px rgba(255,255,255,0.75);vertical-align:middle;background-color:#f5f5f5;background-image:-moz-linear-gradient(top,#fff,#e6e6e6);background-image:-ms-linear-gradient(top,#fff,#e6e6e6);background-image:-webkit-gradient(linear,0 0,0 100%,from(#fff),to(#e6e6e6));background-image:-webkit-linear-gradient(top,#fff,#e6e6e6);background-image:-o-linear-gradient(top,#fff,#e6e6e6);background-image:linear-gradient(top,#fff,#e6e6e6);background-repeat:repeat-x;filter:progid:DXImageTransform.Microsoft.gradient(startColorstr='#ffffff',endColorstr='#e6e6e6',GradientType=0);border-color:#e6e6e6 #e6e6e6 #bfbfbf;border-color:rgba(0,0,0,0.1) rgba(0,0,0,0.1) rgba(0,0,0,0.25);filter:progid:DXImageTransform.Microsoft.gradient(enabled=false);border:1px solid #ccc;border-bottom-color:#b3b3b3;-webkit-border-radius:4px;-moz-border-radius:4px;border-radius:4px;-webkit-box-shadow:inset 0 1px 0 rgba(255,255,255,0.2),0 1px 2px rgba(0,0,0,0.05);-moz-box-shadow:inset 0 1px 0 rgba(255,255,255,0.2),0 1px 2px rgba(0,0,0,0.05);box-shadow:inset 0 1px 0 rgba(255,255,255,0.2),0 1px 2px rgba(0,0,0,0.05);cursor:pointer;*margin-left:.3em}.timely .btn:hover,.timely .btn:active,.timely .btn.active,.timely .btn.disabled,.timely .btn[disabled]{background-color:#e6e6e6}.timely .btn:active,.timely .btn.active{background-color:#ccc \9}.timely .btn:first-child{*margin-left:0}.timely .btn:hover{color:#333;text-decoration:none;background-color:#e6e6e6;background-position:0 -15px;-webkit-transition:background-position .1s linear;-moz-transition:background-position .1s linear;-ms-transition:background-position .1s linear;-o-transition:background-position .1s linear;transition:background-position .1s linear}.timely .btn:focus{outline:thin dotted #333;outline:5px auto -webkit-focus-ring-color;outline-offset:-2px}.timely .btn.active,.timely .btn:active{background-image:none;-webkit-box-shadow:inset 0 2px 4px rgba(0,0,0,0.15),0 1px 2px rgba(0,0,0,0.05);-moz-box-shadow:inset 0 2px 4px rgba(0,0,0,0.15),0 1px 2px rgba(0,0,0,0.05);box-shadow:inset 0 2px 4px rgba(0,0,0,0.15),0 1px 2px rgba(0,0,0,0.05);background-color:#e6e6e6;background-color:#d9d9d9 \9;outline:0}.timely .btn.disabled,.timely .btn[disabled]{cursor:default;background-image:none;background-color:#e6e6e6;opacity:.65;filter:alpha(opacity=65);-webkit-box-shadow:none;-moz-box-shadow:none;box-shadow:none}.timely .btn-large{padding:9px 14px;font-size:15px;line-height:normal;-webkit-border-radius:5px;-moz-border-radius:5px;border-radius:5px}.timely .btn-large [class^="icon-"]{margin-top:1px}.timely .btn-small{padding:5px 9px;font-size:11px;line-height:16px}.timely .btn-small [class^="icon-"]{margin-top:-1px}.timely .btn-mini{padding:2px 6px;font-size:11px;line-height:14px}.timely .btn-primary,.timely .btn-primary:hover,.timely .btn-warning,.timely .btn-warning:hover,.timely .btn-danger,.timely .btn-danger:hover,.timely .btn-success,.timely .btn-success:hover,.timely .btn-info,.timely .btn-info:hover,.timely .btn-inverse,.timely .btn-inverse:hover{text-shadow:0 -1px 0 rgba(0,0,0,0.25);color:#fff}.timely .btn-primary.active,.timely .btn-warning.active,.timely .btn-danger.active,.timely .btn-success.active,.timely .btn-info.active,.timely .btn-inverse.active{color:rgba(255,255,255,0.75)}.timely .btn-primary{background-color:#6fb343;background-image:-moz-linear-gradient(top,#84c04b,#51a038);background-image:-ms-linear-gradient(top,#84c04b,#51a038);background-image:-webkit-gradient(linear,0 0,0 100%,from(#84c04b),to(#51a038));background-image:-webkit-linear-gradient(top,#84c04b,#51a038);background-image:-o-linear-gradient(top,#84c04b,#51a038);background-image:linear-gradient(top,#84c04b,#51a038);background-repeat:repeat-x;filter:progid:DXImageTransform.Microsoft.gradient(startColorstr='#84c04b',endColorstr='#51a038',GradientType=0);border-color:#51a038 #51a038 #346724;border-color:rgba(0,0,0,0.1) rgba(0,0,0,0.1) rgba(0,0,0,0.25);filter:progid:DXImageTransform.Microsoft.gradient(enabled=false)}.timely .btn-primary:hover,.timely .btn-primary:active,.timely .btn-primary.active,.timely .btn-primary.disabled,.timely .btn-primary[disabled]{background-color:#51a038}.timely .btn-primary:active,.timely .btn-primary.active{background-color:#3e7a2b \9}.timely .btn-warning{background-color:#faa732;background-image:-moz-linear-gradient(top,#fbb450,#f89406);background-image:-ms-linear-gradient(top,#fbb450,#f89406);background-image:-webkit-gradient(linear,0 0,0 100%,from(#fbb450),to(#f89406));background-image:-webkit-linear-gradient(top,#fbb450,#f89406);background-image:-o-linear-gradient(top,#fbb450,#f89406);background-image:linear-gradient(top,#fbb450,#f89406);background-repeat:repeat-x;filter:progid:DXImageTransform.Microsoft.gradient(startColorstr='#fbb450',endColorstr='#f89406',GradientType=0);border-color:#f89406 #f89406 #ad6704;border-color:rgba(0,0,0,0.1) rgba(0,0,0,0.1) rgba(0,0,0,0.25);filter:progid:DXImageTransform.Microsoft.gradient(enabled=false)}.timely .btn-warning:hover,.timely .btn-warning:active,.timely .btn-warning.active,.timely .btn-warning.disabled,.timely .btn-warning[disabled]{background-color:#f89406}.timely .btn-warning:active,.timely .btn-warning.active{background-color:#c67605 \9}.timely .btn-danger{background-color:#da4f49;background-image:-moz-linear-gradient(top,#ee5f5b,#bd362f);background-image:-ms-linear-gradient(top,#ee5f5b,#bd362f);background-image:-webkit-gradient(linear,0 0,0 100%,from(#ee5f5b),to(#bd362f));background-image:-webkit-linear-gradient(top,#ee5f5b,#bd362f);background-image:-o-linear-gradient(top,#ee5f5b,#bd362f);background-image:linear-gradient(top,#ee5f5b,#bd362f);background-repeat:repeat-x;filter:progid:DXImageTransform.Microsoft.gradient(startColorstr='#ee5f5b',endColorstr='#bd362f',GradientType=0);border-color:#bd362f #bd362f #802420;border-color:rgba(0,0,0,0.1) rgba(0,0,0,0.1) rgba(0,0,0,0.25);filter:progid:DXImageTransform.Microsoft.gradient(enabled=false)}.timely .btn-danger:hover,.timely .btn-danger:active,.timely .btn-danger.active,.timely .btn-danger.disabled,.timely .btn-danger[disabled]{background-color:#bd362f}.timely .btn-danger:active,.timely .btn-danger.active{background-color:#942a25 \9}.timely .btn-success{background-color:#5bb75b;background-image:-moz-linear-gradient(top,#62c462,#51a351);background-image:-ms-linear-gradient(top,#62c462,#51a351);background-image:-webkit-gradient(linear,0 0,0 100%,from(#62c462),to(#51a351));background-image:-webkit-linear-gradient(top,#62c462,#51a351);background-image:-o-linear-gradient(top,#62c462,#51a351);background-image:linear-gradient(top,#62c462,#51a351);background-repeat:repeat-x;filter:progid:DXImageTransform.Microsoft.gradient(startColorstr='#62c462',endColorstr='#51a351',GradientType=0);border-color:#51a351 #51a351 #387038;border-color:rgba(0,0,0,0.1) rgba(0,0,0,0.1) rgba(0,0,0,0.25);filter:progid:DXImageTransform.Microsoft.gradient(enabled=false)}.timely .btn-success:hover,.timely .btn-success:active,.timely .btn-success.active,.timely .btn-success.disabled,.timely .btn-success[disabled]{background-color:#51a351}.timely .btn-success:active,.timely .btn-success.active{background-color:#408140 \9}.timely .btn-info{background-color:#49afcd;background-image:-moz-linear-gradient(top,#5bc0de,#2f96b4);background-image:-ms-linear-gradient(top,#5bc0de,#2f96b4);background-image:-webkit-gradient(linear,0 0,0 100%,from(#5bc0de),to(#2f96b4));background-image:-webkit-linear-gradient(top,#5bc0de,#2f96b4);background-image:-o-linear-gradient(top,#5bc0de,#2f96b4);background-image:linear-gradient(top,#5bc0de,#2f96b4);background-repeat:repeat-x;filter:progid:DXImageTransform.Microsoft.gradient(startColorstr='#5bc0de',endColorstr='#2f96b4',GradientType=0);border-color:#2f96b4 #2f96b4 #1f6377;border-color:rgba(0,0,0,0.1) rgba(0,0,0,0.1) rgba(0,0,0,0.25);filter:progid:DXImageTransform.Microsoft.gradient(enabled=false)}.timely .btn-info:hover,.timely .btn-info:active,.timely .btn-info.active,.timely .btn-info.disabled,.timely .btn-info[disabled]{background-color:#2f96b4}.timely .btn-info:active,.timely .btn-info.active{background-color:#24748c \9}.timely .btn-inverse{background-color:#414141;background-image:-moz-linear-gradient(top,#555,#222);background-image:-ms-linear-gradient(top,#555,#222);background-image:-webkit-gradient(linear,0 0,0 100%,from(#555),to(#222));background-image:-webkit-linear-gradient(top,#555,#222);background-image:-o-linear-gradient(top,#555,#222);background-image:linear-gradient(top,#555,#222);background-repeat:repeat-x;filter:progid:DXImageTransform.Microsoft.gradient(startColorstr='#555555',endColorstr='#222222',GradientType=0);border-color:#222 #222 #000;border-color:rgba(0,0,0,0.1) rgba(0,0,0,0.1) rgba(0,0,0,0.25);filter:progid:DXImageTransform.Microsoft.gradient(enabled=false)}.timely .btn-inverse:hover,.timely .btn-inverse:active,.timely .btn-inverse.active,.timely .btn-inverse.disabled,.timely .btn-inverse[disabled]{background-color:#222}.timely .btn-inverse:active,.timely .btn-inverse.active{background-color:#080808 \9}.timely button.btn,.timely input[type="submit"].btn{*padding-top:2px;*padding-bottom:2px}.timely button.btn::-moz-focus-inner,.timely input[type="submit"].btn::-moz-focus-inner{padding:0;border:0}.timely button.btn.btn-large,.timely input[type="submit"].btn.btn-large{*padding-top:7px;*padding-bottom:7px}.timely button.btn.btn-small,.timely input[type="submit"].btn.btn-small{*padding-top:3px;*padding-bottom:3px}.timely button.btn.btn-mini,.timely input[type="submit"].btn.btn-mini{*padding-top:1px;*padding-bottom:1px}.timely .hero-unit{padding:60px;margin-bottom:30px;background-color:#eee;-webkit-border-radius:6px;-moz-border-radius:6px;border-radius:6px}.timely .hero-unit h1{margin-bottom:0;font-size:60px;line-height:1;color:inherit;letter-spacing:-1px}.timely .hero-unit p{font-size:18px;font-weight:200;line-height:27px;color:inherit}.timely .pull-right{float:right}.timely .pull-left{float:left}.timely .hide{display:none}.timely .show{display:block}.timely .invisible{visibility:hidden}.timely .hero-unit{padding:30px;margin-bottom:15px}.timely .hero-unit h1{color:#333}.timely h4{font-size:16px}.timely hr{margin:14px 0}.timely h2.ai1ec-premium-features{font-size:1.4em!important}.timely h4.ai1ec-premium-features .span4{min-width:145px}.timely h4.ai1ec-premium-features li{color:#6aab2d;font-size:1.2em}.timely h4.ai1ec-premium-features li strong{font-size:.83em;color:#333}.timely a.btn{text-decoration:none}.timely ul.icons{list-style-type:none}.timely a.button-primary{color:#fff}.timely a.button-primary:hover{color:#eaf2fa;text-decoration:none}.timely input[type="text"]{height:28px;line-height:28px}
 
 
 
 
 
 
 
 
 
app/view/admin/css/colorpicker.css DELETED
@@ -1,280 +0,0 @@
1
- #tag-color {
2
- width: 39px;
3
- height: 24px;
4
- background: url( ../img/color-picker.png );
5
- cursor: pointer;
6
- }
7
- #tag-color:hover {
8
- background-position: 0px -24px;
9
- }
10
- #tag-color-background {
11
- position: relative;
12
- top: 3px;
13
- left: 3px;
14
- width: 20px;
15
- height: 18px;
16
- background: transparent;
17
- }
18
- ul.colorpicker-list {
19
- padding: 0.1em;
20
- }
21
- .colorpicker-list li {
22
- float: left;
23
- width: 13px;
24
- height: 13px;
25
- margin: 1px;
26
- cursor: pointer;
27
- border-radius: 2px;
28
- -o-border-radius: 2px;
29
- -moz-border-radius: 2px;
30
- -webkit-border-radius: 2px;
31
- }
32
- .select-more-colors {
33
- width: 100% !important;
34
- line-height: 22px;
35
- height: 22px !important;
36
- border-color: #fff !important;
37
- margin: 2px 1px 2px 1px !important;
38
- text-align: center;
39
- font-family: Tahoma,Verdana,Arial,Helvetica;
40
- font-size: 11px;
41
- /*padding-left: 17px !important;*/
42
- }
43
- li.select-more-colors:hover {
44
- width:103px !important;
45
- border-color: #0A246A !important;
46
- background: #B6BDD2 !important;
47
- margin-right: 2px !important;
48
-
49
-
50
- }
51
- .color-1 {
52
- background: #60a !important;
53
- }
54
- .color-2 {
55
- background: #807 !important;
56
- }
57
- .color-3 {
58
- background: #920 !important;
59
- }
60
- .color-4 {
61
- background: #a60 !important;
62
- }
63
- .color-5 {
64
- background: #990 !important;
65
- }
66
- .color-6 {
67
- background: #080 !important;
68
- }
69
- .color-7 {
70
- background: #077 !important;
71
- }
72
- .color-8 {
73
- background: #00a !important;
74
- }
75
- .color-9 {
76
- background: #000 !important;
77
- }
78
- .color-10 {
79
- background: #444 !important;
80
- }
81
- .color-11 {
82
- background: #85e !important;
83
- }
84
- .color-12 {
85
- background: #d5d !important;
86
- }
87
- .color-13 {
88
- background: #d43 !important;
89
- }
90
- .color-14 {
91
- background: #d90 !important;
92
- }
93
- .color-15 {
94
- background: #bb0 !important;
95
- }
96
- .color-16 {
97
- background: #2b0 !important;
98
- }
99
- .color-17 {
100
- background: #0ba !important;
101
- }
102
- .color-18 {
103
- background: #26d !important;
104
- }
105
- .color-19 {
106
- background: #777 !important;
107
- }
108
- .color-20 {
109
- background: #aaa !important;
110
- }
111
- .color-21 {
112
- width: 13px;
113
- height: 13px;
114
- background: url( ../img/color-picker-default.png );
115
- }
116
- .colorpicker {
117
- width: 356px;
118
- height: 176px;
119
- overflow: hidden;
120
- position: absolute;
121
- background: url(../img/colorpicker_background.png);
122
- font-family: Arial, Helvetica, sans-serif;
123
- display: none;
124
- z-index: 2;
125
- }
126
- .colorpicker_color {
127
- width: 150px;
128
- height: 150px;
129
- left: 14px;
130
- top: 13px;
131
- position: absolute;
132
- background: #f00;
133
- overflow: hidden;
134
- cursor: crosshair;
135
- }
136
- .colorpicker_color div {
137
- position: absolute;
138
- top: 0;
139
- left: 0;
140
- width: 150px;
141
- height: 150px;
142
- background: url(../img/colorpicker_overlay.png);
143
- }
144
- .colorpicker_color div div {
145
- position: absolute;
146
- top: 0;
147
- left: 0;
148
- width: 11px;
149
- height: 11px;
150
- overflow: hidden;
151
- background: url(../img/colorpicker_select.gif);
152
- margin: -5px 0 0 -5px;
153
- }
154
- .colorpicker_hue {
155
- position: absolute;
156
- top: 13px;
157
- left: 171px;
158
- width: 35px;
159
- height: 150px;
160
- cursor: n-resize;
161
- }
162
- .colorpicker_hue div {
163
- position: absolute;
164
- width: 35px;
165
- height: 9px;
166
- overflow: hidden;
167
- background: url(../img/colorpicker_indic.gif) left top;
168
- margin: -4px 0 0 0;
169
- left: 0px;
170
- }
171
- .colorpicker_new_color {
172
- position: absolute;
173
- width: 60px;
174
- height: 30px;
175
- left: 213px;
176
- top: 13px;
177
- background: #f00;
178
- }
179
- .colorpicker_current_color {
180
- position: absolute;
181
- width: 60px;
182
- height: 30px;
183
- left: 283px;
184
- top: 13px;
185
- background: #f00;
186
- }
187
- .colorpicker input {
188
- background-color: transparent !important;
189
- border: 1px solid transparent;
190
- border-color: transparent !important;
191
- border-radius: 0 !important;
192
- box-sizing: content-box !important;
193
- position: absolute;
194
- font-size: 10px;
195
- font-family: Arial, Helvetica, sans-serif;
196
- color: #898989;
197
- top: 4px;
198
- right: 11px;
199
- text-align: right;
200
- margin: 0;
201
- padding: 0;
202
- height: 11px;
203
- }
204
- .colorpicker_hex {
205
- position: absolute;
206
- width: 72px;
207
- height: 22px;
208
- background: url(../img/colorpicker_hex.png) top;
209
- left: 212px;
210
- top: 142px;
211
- }
212
- .colorpicker_hex input {
213
- right: 6px;
214
- }
215
- .colorpicker_field {
216
- height: 22px;
217
- width: 62px;
218
- background-position: top;
219
- position: absolute;
220
- }
221
- .colorpicker_field span {
222
- position: absolute;
223
- width: 12px;
224
- height: 22px;
225
- overflow: hidden;
226
- top: 0;
227
- right: 0;
228
- cursor: n-resize;
229
- }
230
- .colorpicker_rgb_r {
231
- background-image: url(../img/colorpicker_rgb_r.png);
232
- top: 52px;
233
- left: 212px;
234
- }
235
- .colorpicker_rgb_g {
236
- background-image: url(../img/colorpicker_rgb_g.png);
237
- top: 82px;
238
- left: 212px;
239
- }
240
- .colorpicker_rgb_b {
241
- background-image: url(../img/colorpicker_rgb_b.png);
242
- top: 112px;
243
- left: 212px;
244
- }
245
- .colorpicker_hsb_h {
246
- background-image: url(../img/colorpicker_hsb_h.png);
247
- top: 52px;
248
- left: 282px;
249
- }
250
- .colorpicker_hsb_s {
251
- background-image: url(../img/colorpicker_hsb_s.png);
252
- top: 82px;
253
- left: 282px;
254
- }
255
- .colorpicker_hsb_b {
256
- background-image: url(../img/colorpicker_hsb_b.png);
257
- top: 112px;
258
- left: 282px;
259
- }
260
- .colorpicker_submit {
261
- position: absolute;
262
- width: 50px;
263
- height: 22px;
264
- background: url(../img/colorpicker_submit.png) top;
265
- left: 290px;
266
- top: 142px;
267
- overflow: hidden;
268
- }
269
- .colorpicker_focus {
270
- background-position: center;
271
- }
272
- .colorpicker_hex.colorpicker_focus {
273
- background-position: bottom;
274
- }
275
- .colorpicker_submit.colorpicker_focus {
276
- background-position: bottom;
277
- }
278
- .colorpicker_slider {
279
- background-position: bottom;
280
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/view/admin/css/dashboard.css DELETED
@@ -1,28 +0,0 @@
1
- div.ai1ec-calendar-tasks {
2
- padding: 0.25em 0.5em;
3
- position: relative;
4
- }
5
- #ai1ec-calendar-tasks a.ai1ec-big-button {
6
- font-size: 23px !important;
7
- min-width: 275px;
8
- width: 55%;
9
- }
10
- .ai1ec-motif {
11
- background: url(../img/logo.png) no-repeat 90% center;
12
- bottom: 0;
13
- left: 0;
14
- opacity: 0.75;
15
- filter: alpha(opacity=75);
16
- right: 0;
17
- margin: -10px 0;
18
- position: absolute;
19
- top: 0;
20
- }
21
-
22
- #dashboard-widgets > #postbox-container-1 {
23
- width: 65% !important;
24
- }
25
-
26
- #dashboard-widgets > #postbox-container-2 {
27
- width: 35% !important;
28
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/view/admin/css/datepicker.css DELETED
@@ -1,191 +0,0 @@
1
- div.datepicker {
2
- position: relative;
3
- font-family: Arial, Helvetica, sans-serif;
4
- font-size: 12px;
5
- width: 196px;
6
- height: 147px;
7
- position: absolute;
8
- cursor: default;
9
- top: 0;
10
- left: 0;
11
- display: none;
12
- }
13
- .datepickerContainer {
14
- background: #121212;
15
- position: absolute;
16
- top: 10px;
17
- left: 10px;
18
- }
19
- .datepickerBorderT {
20
- position: absolute;
21
- left: 10px;
22
- top: 0;
23
- right: 10px;
24
- height: 10px;
25
- background: url(../img/datepicker_t.png);
26
- }
27
- .datepickerBorderB {
28
- position: absolute;
29
- left: 10px;
30
- bottom: 0;
31
- right: 10px;
32
- height: 10px;
33
- background: url(../img/datepicker_b.png);
34
- }
35
- .datepickerBorderL {
36
- position: absolute;
37
- left: 0;
38
- bottom: 10px;
39
- top: 10px;
40
- width: 10px;
41
- background: url(../img/datepicker_l.png);
42
- }
43
- .datepickerBorderR {
44
- position: absolute;
45
- right: 0;
46
- bottom: 10px;
47
- top: 10px;
48
- width: 10px;
49
- background: url(../img/datepicker_r.png);
50
- }
51
- .datepickerBorderTL {
52
- position: absolute;
53
- top: 0;
54
- left: 0;
55
- width: 10px;
56
- height: 10px;
57
- background: url(../img/datepicker_tl.png);
58
- }
59
- .datepickerBorderTR {
60
- position: absolute;
61
- top: 0;
62
- right: 0;
63
- width: 10px;
64
- height: 10px;
65
- background: url(../img/datepicker_tr.png);
66
- }
67
- .datepickerBorderBL {
68
- position: absolute;
69
- bottom: 0;
70
- left: 0;
71
- width: 10px;
72
- height: 10px;
73
- background: url(../img/datepicker_bl.png);
74
- }
75
- .datepickerBorderBR {
76
- position: absolute;
77
- bottom: 0;
78
- right: 0;
79
- width: 10px;
80
- height: 10px;
81
- background: url(../img/datepicker_br.png);
82
- }
83
- .datepickerHidden {
84
- display: none;
85
- }
86
- div.datepicker table {
87
- border-collapse:collapse;
88
- }
89
- div.datepicker a {
90
- color: #eee;
91
- text-decoration: none;
92
- cursor: default;
93
- outline: none;
94
- }
95
- div.datepicker table td {
96
- text-align: right;
97
- padding: 0;
98
- margin: 0;
99
- }
100
- div.datepicker th {
101
- text-align: center;
102
- color: #999;
103
- font-weight: normal;
104
- }
105
- div.datepicker tbody th {
106
- text-align: left;
107
- }
108
- div.datepicker tbody a {
109
- display: block;
110
- }
111
- .datepickerDays a {
112
- width: 20px;
113
- line-height: 16px;
114
- height: 16px;
115
- padding-right: 2px;
116
- }
117
- .datepickerYears a,
118
- .datepickerMonths a{
119
- width: 44px;
120
- line-height: 36px;
121
- height: 36px;
122
- text-align: center;
123
- }
124
- td.datepickerNotInMonth a {
125
- color: #666;
126
- }
127
- tbody.datepickerDays td.datepickerSelected{
128
- background: #136A9F;
129
- }
130
- tbody.datepickerDays td.datepickerNotInMonth.datepickerSelected {
131
- background: #17384d;
132
- }
133
- tbody.datepickerYears td.datepickerSelected,
134
- tbody.datepickerMonths td.datepickerSelected{
135
- background: #17384d;
136
- }
137
- div.datepicker a:hover,
138
- div.datepicker a:hover {
139
- color: #88c5eb;
140
- }
141
- div.datepicker td.datepickerNotInMonth a:hover {
142
- color: #999;
143
- }
144
- div.datepicker tbody th {
145
- text-align: left;
146
- }
147
- .datepickerSpace div {
148
- width: 20px;
149
- }
150
- .datepickerGoNext a,
151
- .datepickerGoPrev a,
152
- .datepickerMonth a {
153
- text-align: center;
154
- height: 20px;
155
- line-height: 20px;
156
- }
157
- .datepickerGoNext a {
158
- float: right;
159
- width: 20px;
160
- }
161
- .datepickerGoPrev a {
162
- float: left;
163
- width: 20px;
164
- }
165
- table.datepickerViewDays tbody.datepickerMonths,
166
- table.datepickerViewDays tbody.datepickerYears {
167
- display: none;
168
- }
169
- table.datepickerViewMonths tbody.datepickerDays,
170
- table.datepickerViewMonths tbody.datepickerYears,
171
- table.datepickerViewMonths tr.datepickerDoW {
172
- display: none;
173
- }
174
- table.datepickerViewYears tbody.datepickerDays,
175
- table.datepickerViewYears tbody.datepickerMonths,
176
- table.datepickerViewYears tr.datepickerDoW {
177
- display: none;
178
- }
179
- td.datepickerDisabled a,
180
- td.datepickerDisabled.datepickerNotInMonth a{
181
- color: #333;
182
- }
183
- td.datepickerDisabled a:hover {
184
- color: #333;
185
- }
186
- td.datepickerSpecial a {
187
- background: #700;
188
- }
189
- td.datepickerSpecial.datepickerSelected a {
190
- background: #a00;
191
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/view/admin/css/platform.css DELETED
@@ -1,61 +0,0 @@
1
- /**
2
- * @file
3
- * Styles specific to calendar platform mode.
4
- */
5
-
6
- #ai1ec-calendar-tasks {
7
- background: #fff;
8
- }
9
- #ai1ec-calendar-tasks .btn {
10
- -webkit-box-sizing: border-box;
11
- -moz-box-sizing: border-box;
12
- box-sizing: border-box;
13
- width: 85%;
14
- }
15
- #wp-admin-bar-wp-logo > .ab-item .ab-icon {
16
- background-image: url(../img/admin-bar-sprite.png);
17
- }
18
- /* Weird rendering of large icons in WP 3.2. */
19
- .branch-3-2 .icon-large::before {
20
- vertical-align: bottom;
21
- }
22
-
23
- #adminmenu #menu-posts-ai1ec_event.menu-top {
24
- min-height: 47px;
25
- }
26
- #adminmenu #menu-posts-ai1ec_event a.menu-top,
27
- #adminmenu #menu-posts-ai1ec_event .wp-submenu-head {
28
- font-size: 16px;
29
- line-height: 36px;
30
- min-width: 0;
31
- }
32
- #menu-posts-ai1ec_event > div.wp-menu-image {
33
- margin-top: 8px;
34
- }
35
- #adminmenu #menu-posts-ai1ec_event > div.wp-menu-arrow,
36
- #adminmenu #menu-posts-ai1ec_event.wp-not-current-submenu > div.wp-menu-arrow {
37
- height: 46px;
38
- }
39
- #adminmenu #menu-posts-ai1ec_event .wp-menu-arrow div,
40
- #adminmenu #menu-posts-ai1ec_event.wp-not-current-submenu .wp-menu-arrow div {
41
- top: 15px;
42
- -webkit-transform: matrix(-0.6,1.5,0.6,1.5,0,0);
43
- -moz-transform: matrix(-0.6,1.5,0.6,1.5,0,0);
44
- -ms-transform: matrix(-0.6,1.5,0.6,1.5,0,0);
45
- -o-transform: matrix(-0.6,1.5,0.6,1.5,0,0);
46
- transform: matrix(-0.6,1.5,0.6,1.5,0,0);
47
- }
48
- .branch-3-2 #adminmenu #menu-posts-ai1ec_event .wp-menu-arrow div,
49
- .branch-3-2 #adminmenu #menu-posts-ai1ec_event.wp-not-current-submenu .wp-menu-arrow div {
50
- -webkit-background-size: 100% 100%;
51
- -moz-background-size: 100% 100%;
52
- -ms-background-size: 100% 100%;
53
- -o-background-size: 100% 100%;
54
- background-size: 100% 100%;
55
- height: 47px;
56
- -webkit-transform: none;
57
- -moz-transform: none;
58
- -ms-transform: none;
59
- -o-transform: none;
60
- transform: none;
61
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/view/admin/css/settings.css DELETED
@@ -1,203 +0,0 @@
1
- /* Support box */
2
-
3
- #ai1ec-support {
4
- background: #f9f9f9;
5
- min-width: 350px;
6
- }
7
- #ai1ec-support a {
8
- text-decoration: none;
9
- }
10
- #ai1ec-support a:hover {
11
- text-decoration: underline;
12
- }
13
- #ai1ec-support div.inside {
14
- margin: 0;
15
- padding: 6px 12px 8px;
16
- }
17
- #ai1ec-support h2 {
18
- font-size: 19px;
19
- line-height: 28px;
20
- margin: 10px 0;
21
- padding: 0;
22
- }
23
- #ai1ec-support .timely-logo a {
24
- background: url(../img/timely-logo.png) no-repeat center center;
25
- display: block;
26
- height: 140px;
27
- }
28
- #ai1ec-support .timely-intro {
29
- text-align: center;
30
- }
31
- #ai1ec-support .ai1ec-follow-fan {
32
- text-align: center;
33
- }
34
- #ai1ec-support .ai1ec-facebook-like-top {
35
- display: inline-block;
36
- vertical-align: top;
37
- }
38
- #ai1ec-support a.btn,
39
- #ai1ec-support a.btn:hover {
40
- text-decoration: none;
41
- }
42
- #ai1ec-support .ai1ec-download .ai1ec-download-btn {
43
- display: block;
44
- font-size: 13px;
45
- margin-bottom: 10px;
46
- padding: 14px 4px;
47
- }
48
- #ai1ec-support .ai1ec-download .ai1ec-download-btn div {
49
- font-size: 18px;
50
- padding: 4px 0;
51
- }
52
- #ai1ec-support .ai1ec-download > div > div {
53
- background: #fff;
54
- border: 1px solid #ddd;
55
- -webkit-border-radius: 10px;
56
- -moz-border-radius: 10px;
57
- border-radius: 10px;
58
- padding: 8px;
59
- }
60
- #ai1ec-support .ai1ec-download ul {
61
- margin: 0 0 6px 15px;
62
- text-indent: 0;
63
- }
64
- #ai1ec-support .ai1ec-download ul a {
65
- cursor: help;
66
- }
67
- #ai1ec-support .ai1ec-download ul a i {
68
- width: 0.9em;
69
- }
70
- #ai1ec-support .ai1ec-get-support {
71
- display: block;
72
- margin: -3px 0 0;
73
- padding: 4px 13px;
74
- text-align: left;
75
- }
76
- #ai1ec-support .ai1ec-get-support .ai1ec-hover {
77
- display: none;
78
- }
79
- #ai1ec-support .ai1ec-get-support:hover .ai1ec-normal {
80
- display: none;
81
- }
82
- #ai1ec-support .ai1ec-get-support:hover .ai1ec-hover {
83
- display: inline;
84
- }
85
-
86
- #ai1ec-support .ai1ec-news h2 small {
87
- font-family: sans-serif;
88
- font-size: 0.8em;
89
- margin-left: 0.3em;
90
- }
91
- #ai1ec-support .ai1ec-news article {
92
- border-bottom: 1px solid #e0e0e0;
93
- margin-bottom: 7px;
94
- padding-bottom: 5px;
95
- }
96
- #ai1ec-support .ai1ec-news article:first-child {
97
- border-top: 1px solid #e0e0e0;
98
- padding-top: 5px;
99
- }
100
- #ai1ec-support .ai1ec-news article div {
101
- font-size: 0.9em;
102
- overflow: hidden;
103
- text-overflow: ellipsis;
104
- white-space: nowrap;
105
- }
106
-
107
- /* General settings */
108
-
109
- .ai1ec_feed_h4 {
110
- margin-bottom: 5px;
111
- }
112
- .column-1-ai1ec {
113
- float: left;
114
- width: 54%;
115
- }
116
- .column-2-ai1ec {
117
- float: right;
118
- width: 45%;
119
- }
120
- .column-3-ai1ec {
121
- float: left;
122
- width: 100%;
123
- }
124
-
125
- .column-1-ai1ec .inside label {
126
- float: left;
127
- clear: left;
128
- margin: 0.25em 0;
129
- }
130
- .column-1-ai1ec .checkbox {
131
- float: left;
132
- margin: 0.25em 0.5em 0 0;
133
- }
134
- .column-1-ai1ec .inside .description {
135
- clear: left;
136
- font-size: 0.95em;
137
- line-height: 1.5em;
138
- margin: 0.25em 0 0.4em;
139
- }
140
- .column-1-ai1ec .inside label.textinput {
141
- width: 230px;
142
- }
143
- .column-1-ai1ec .inside h2 {
144
- margin-bottom: 0 !important;
145
- margin-top: 10px !important;
146
- }
147
-
148
- /* ICS Feeds */
149
-
150
- #ai1ec_feed_url,
151
- .ai1ec-feed-url {
152
- width: 100%;
153
- }
154
- .ai1ec-feed-category, .ai1ec-feed-tags {
155
- float: left;
156
- overflow: hidden;
157
- line-height: 2em;
158
- }
159
- .ai1ec-feed-category strong, .ai1ec-feed-tags strong {
160
- margin: 0 1em 0 0.2em;
161
- }
162
- #ai1ec_feed_category, #ai1ec_feed_tags {
163
- width: 15em;
164
- }
165
- #ai1ec_feed_category {
166
- margin-right: 0.5em;
167
- }
168
- .ai1ec-feed-container {
169
- background: #eee;
170
- border: 1px solid #ddd;
171
- padding: 0.3em 0.5em;
172
- border-radius: 0.5em;
173
- -moz-border-radius: 0.5em;
174
- -webkit-border-radius: 0.5em;
175
- overflow: hidden;
176
- position: relative;
177
- margin: 1em 0 0;
178
- }
179
- .ai1ec-feed-container .ajax-loading {
180
- clear: left;
181
- display: block;
182
- }
183
- .ai1ec_feed_h4 {
184
- margin: 0.5em 0;
185
- }
186
- #ai1ec_add_new_ics, .ai1ec_delete_ics {
187
- clear: left;
188
- }
189
- #ai1ec_add_new_ics, .ai1ec_delete_ics, .ai1ec_update_ics, .ai1ec_flush_ics {
190
- float: right;
191
- }
192
- #ai1ec_save_settings {
193
- clear: left;
194
- display: block;
195
- }
196
-
197
- .ai1ec-donate {
198
- text-align: center;
199
- }
200
-
201
- p.submit {
202
- padding-top: 0;
203
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/view/admin/donate_button.php DELETED
@@ -1,6 +0,0 @@
1
- <form action="https://www.paypal.com/cgi-bin/webscr" method="post" target="_blank">
2
- <input type="hidden" name="cmd" value="_s-xclick" />
3
- <input type="hidden" name="hosted_button_id" value="9JJMUW48W2ED8" />
4
- <input type="image" src="https://www.paypalobjects.com/en_US/i/btn/btn_donateCC_LG.gif" border="0" name="submit" alt="PayPal - The safer, easier way to pay online!" />
5
- <img alt="" border="0" src="https://www.paypalobjects.com/en_US/i/scr/pixel.gif" width="1" height="1" />
6
- </form>
 
 
 
 
 
 
app/view/admin/event-category.php ADDED
@@ -0,0 +1,250 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * Event category admin view snippets renderer.
5
+ *
6
+ * @author Time.ly Network Inc.
7
+ * @since 2.0
8
+ *
9
+ * @package AI1EC
10
+ * @subpackage AI1EC.View.Admin
11
+ */
12
+ class Ai1ec_View_Admin_EventCategory extends Ai1ec_Base {
13
+
14
+ /**
15
+ * Inserts Color element at index 2 of columns array
16
+ *
17
+ * @param array $columns Array with event_category columns
18
+ *
19
+ * @return array Array with event_category columns where Color is inserted
20
+ * at index 2
21
+ */
22
+ public function manage_event_categories_columns( $columns ) {
23
+ wp_enqueue_media();
24
+ $this->_registry->get( 'css.admin' )
25
+ ->process_enqueue( array(
26
+ array( 'style', 'bootstrap.min.css' )
27
+ ) );
28
+ return array_splice( $columns, 0, 3 ) + // get only first element
29
+ // insert at index 2
30
+ array( 'cat_color' => __( 'Color', AI1EC_PLUGIN_NAME ) ) +
31
+ // insert at index 3
32
+ array( 'cat_image' => __( 'Image', AI1EC_PLUGIN_NAME ) ) +
33
+ // insert rest of elements at the back
34
+ array_splice( $columns, 0 );
35
+ }
36
+
37
+ /**
38
+ * Returns the color or image of the event category.
39
+ *
40
+ * That will be displayed on event category lists page in the backend.
41
+ *
42
+ * @param $not_set
43
+ * @param $column_name
44
+ * @param $term_id
45
+ * @internal param array $columns Array with event_category columns
46
+ *
47
+ * @return array Array with event_category columns where Color is inserted
48
+ * at index 2
49
+ */
50
+ public function manage_events_categories_custom_column(
51
+ $not_set,
52
+ $column_name,
53
+ $term_id
54
+ ) {
55
+ switch ( $column_name ) {
56
+ case 'cat_color':
57
+ return $this->_registry->get( 'view.event.taxonomy' )
58
+ ->get_category_color_square( $term_id );
59
+ case 'cat_image':
60
+ return $this->_registry->get( 'view.event.taxonomy' )
61
+ ->get_category_image_square( $term_id );
62
+ }
63
+ }
64
+
65
+ /**
66
+ * Hook to process event categories creation
67
+ *
68
+ * @param $term_id
69
+ *
70
+ * @return void Method does not return.
71
+ */
72
+ public function created_events_categories( $term_id ) {
73
+ $this->edited_events_categories( $term_id );
74
+ }
75
+
76
+ /**
77
+ * A callback method, triggered when `event_categories' are being edited.
78
+ *
79
+ * @param int $term_id ID of term (category) being edited.
80
+ *
81
+ * @return void Method does not return.
82
+ */
83
+ public function edited_events_categories( $term_id ) {
84
+ if ( isset( $_POST['_inline_edit'] ) ) {
85
+ return;
86
+ }
87
+
88
+ $tag_color_value = '';
89
+ if ( ! empty( $_POST['tag-color-value'] ) ) {
90
+ $tag_color_value = (string)$_POST['tag-color-value'];
91
+ }
92
+ $tag_image_value = '';
93
+ if ( ! empty( $_POST['ai1ec_category_image_url'] ) ) {
94
+ $tag_image_value = (string)$_POST['ai1ec_category_image_url'];
95
+ }
96
+ if ( isset( $_POST['ai1ec_category_image_url_remove'] ) ) {
97
+ $tag_image_value = null;
98
+ }
99
+
100
+ $db = $this->_registry->get( 'dbi.dbi' );
101
+ $table_name = $db->get_table_name( 'ai1ec_event_category_meta' );
102
+ $term = $db->get_row( $db->prepare(
103
+ 'SELECT term_id FROM ' . $table_name .
104
+ ' WHERE term_id = %d',
105
+ $term_id
106
+ ) );
107
+
108
+ if ( null === $term ) { // term does not exist, create it
109
+ $db->insert(
110
+ $table_name,
111
+ array(
112
+ 'term_id' => $term_id,
113
+ 'term_color' => $tag_color_value,
114
+ 'term_image' => $tag_image_value,
115
+ ),
116
+ array(
117
+ '%d',
118
+ '%s',
119
+ '%s',
120
+ )
121
+ );
122
+ } else { // term exist, update it
123
+ $db->update(
124
+ $table_name,
125
+ array(
126
+ 'term_color' => $tag_color_value,
127
+ 'term_image' => $tag_image_value
128
+ ),
129
+ array( 'term_id' => $term_id ),
130
+ array( '%s', '%s' ),
131
+ array( '%d' )
132
+ );
133
+ }
134
+ }
135
+
136
+ /**
137
+ * Edit category form
138
+ *
139
+ * @param $term
140
+ *
141
+ * @return void
142
+ */
143
+ public function events_categories_edit_form_fields( $term ) {
144
+
145
+ $taxonomy = $this->_registry->get( 'model.taxonomy' );
146
+ $color = $taxonomy->get_category_color( $term->term_id );
147
+ $image = $taxonomy->get_category_image( $term->term_id );
148
+
149
+ $style = '';
150
+ $clr = '';
151
+
152
+ if ( null !== $color ) {
153
+ $style = 'style="background-color: ' . $color . '"';
154
+ $clr = $color;
155
+ }
156
+
157
+ $args = array(
158
+ 'style' => $style,
159
+ 'color' => $clr,
160
+ 'label' => Ai1ec_I18n::__( 'Category Color' ),
161
+ 'description' => Ai1ec_I18n::__(
162
+ 'Events in this category will be identified by this color'
163
+ ),
164
+ 'edit' => true,
165
+ );
166
+
167
+ $loader = $this->_registry->get( 'theme.loader' );
168
+ $loader->get_file(
169
+ 'setting/categories-color-picker.twig',
170
+ $args,
171
+ true
172
+ )->render();
173
+
174
+ $style = 'style="display:none"';
175
+
176
+ if ( null !== $image ) {
177
+ $style = '';
178
+ }
179
+
180
+ // Category image
181
+ $args = array(
182
+ 'image_src' => $image,
183
+ 'image_style' => $style,
184
+ 'section_name' => __( 'Category Image', AI1EC_PLUGIN_NAME ),
185
+ 'label' => __( 'Add Image', AI1EC_PLUGIN_NAME ),
186
+ 'remove_label' => __( 'Remove Image', AI1EC_PLUGIN_NAME ),
187
+ 'description' => __(
188
+ 'Assign an optional image to the category. Recommended size: square, minimum 400&times;400 pixels.',
189
+ AI1EC_PLUGIN_NAME
190
+ ),
191
+ 'edit' => true,
192
+ );
193
+
194
+ $loader->get_file(
195
+ 'setting/categories-image.twig',
196
+ $args,
197
+ true
198
+ )->render();
199
+ }
200
+
201
+ /**
202
+ * Add category form
203
+ *
204
+ * @return void
205
+ */
206
+ public function events_categories_add_form_fields() {
207
+
208
+ $loader = $this->_registry->get( 'theme.loader' );
209
+
210
+ // Category color
211
+ $args = array(
212
+ 'color' => '',
213
+ 'style' => '',
214
+ 'label' => __( 'Category Color', AI1EC_PLUGIN_NAME ),
215
+ 'remove_label' => __( 'Remove Image', AI1EC_PLUGIN_NAME ),
216
+ 'description' => __(
217
+ 'Events in this category will be identified by this color',
218
+ AI1EC_PLUGIN_NAME
219
+ ),
220
+ 'edit' => false
221
+ );
222
+
223
+ $file = $loader->get_file(
224
+ 'setting/categories-color-picker.twig',
225
+ $args,
226
+ true
227
+ );
228
+
229
+ $file->render();
230
+
231
+ // Category image
232
+ $args = array(
233
+ 'image_src' => '',
234
+ 'image_style' => 'style="display:none"',
235
+ 'section_name' => __( 'Category Image', AI1EC_PLUGIN_NAME ),
236
+ 'label' => __( 'Add Image', AI1EC_PLUGIN_NAME),
237
+ 'description' => __( 'Assign an optional image to the category. Recommended size: square, minimum 400&times;400 pixels.', AI1EC_PLUGIN_NAME ),
238
+ 'edit' => false,
239
+ );
240
+
241
+ $file = $loader->get_file(
242
+ 'setting/categories-image.twig',
243
+ $args,
244
+ true
245
+ );
246
+
247
+ $file->render();
248
+ }
249
+
250
+ }
app/view/admin/event_categories-color_picker.php DELETED
@@ -1,27 +0,0 @@
1
- <?php if( $edit ) : ?>
2
- <tr class="form-field">
3
- <th scope="row" valign="top">
4
- <label for="tag-color">
5
- <?php _e( 'Category Color', AI1EC_PLUGIN_NAME ) ?>
6
- </label>
7
- </th>
8
- <td>
9
- <div id="tag-color">
10
- <div id="tag-color-background"<?php echo $style ?>></div>
11
- </div>
12
- <input type="hidden" name="tag-color-value" id="tag-color-value" value="<?php echo $color ?>" />
13
- <p class="description"><?php _e( 'Events in this category will be identified by this color', AI1EC_PLUGIN_NAME ) ?>.</p>
14
- </td>
15
- </tr>
16
- <?php else : ?>
17
- <div class="form-field">
18
- <label for="tag-color">
19
- <?php _e( 'Category Color', AI1EC_PLUGIN_NAME ) ?>
20
- </label>
21
- <div id="tag-color">
22
- <div id="tag-color-background"></div>
23
- </div>
24
- <input type="hidden" name="tag-color-value" id="tag-color-value" value="" />
25
- <p><?php _e( 'Events in this category will be identified by this color', AI1EC_PLUGIN_NAME ) ?>.</p>
26
- </div>
27
- <?php endif; ?>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/view/admin/feed_row.php DELETED
@@ -1,25 +0,0 @@
1
- <div class="ai1ec-feed-container">
2
- <h4 class="ai1ec_feed_h4">
3
- <?php _e( 'iCalendar/.ics Feed URL:', AI1EC_PLUGIN_NAME ); ?>
4
- </h4>
5
- <div class="ai1ec-feed-url"><input type="text" class="ai1ec-feed-url" readonly="readonly" value="<?php echo esc_attr( $feed_url ) ?>" /></div>
6
- <input type="hidden" name="feed_id" class="ai1ec_feed_id" value="<?php echo $feed_id;?>" />
7
- <?php if( $event_category ): ?>
8
- <div class="ai1ec-feed-category">
9
- <?php _e( 'Event category:', AI1EC_PLUGIN_NAME ); ?>
10
- <strong><?php echo $event_category; ?></strong>
11
- </div>
12
- <?php endif ?>
13
- <?php if( $tags ): ?>
14
- <div class="ai1ec-feed-tags">
15
- <?php _e( 'Tag with', AI1EC_PLUGIN_NAME ); ?>:
16
- <strong><?php echo $tags; ?></strong>
17
- </div>
18
- <?php endif ?>
19
- <input type="button" class="button ai1ec_delete_ics" value="<?php _e( '× Delete', AI1EC_PLUGIN_NAME ); ?>" />
20
- <input type="button" class="button ai1ec_update_ics" value="<?php _e( 'Update', AI1EC_PLUGIN_NAME ); ?>" />
21
- <?php if( $events ): ?>
22
- <input type="button" class="button ai1ec_flush_ics" value="<?php printf( _n( 'Flush 1 event', 'Flush %s events', $events, AI1EC_PLUGIN_NAME ), $events ) ?>" />
23
- <?php endif ?>
24
- <img src="images/wpspin_light.gif" class="ajax-loading" alt="" />
25
- </div>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/view/admin/get-repeat-box.php ADDED
@@ -0,0 +1,542 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * The get repeat box snippet.
5
+ *
6
+ * @author Time.ly Network Inc.
7
+ * @since 2.0
8
+ *
9
+ * @package AI1EC
10
+ * @subpackage AI1EC.View
11
+ */
12
+ class Ai1ec_View_Admin_Get_repeat_Box extends Ai1ec_Base {
13
+ /**
14
+ * get_repeat_box function
15
+ *
16
+ * @return string
17
+ **/
18
+ public function get_repeat_box() {
19
+ $time_system = $this->_registry->get( 'date.system' );
20
+ $loader = $this->_registry->get( 'theme.loader' );
21
+ $repeat = (int) $_REQUEST["repeat"];
22
+ $repeat = $repeat == 1 ? 1 : 0;
23
+ $post_id = (int) $_REQUEST["post_id"];
24
+ $count = 100;
25
+ $end = NULL;
26
+ $until = $time_system->current_time( true );
27
+
28
+ // try getting the event
29
+ try {
30
+ $event = $this->_registry->get( 'model.event', $post_id );
31
+ $rule = '';
32
+
33
+ if ( $repeat ) {
34
+ $rule = $event->get( 'recurrence_rules' ) ?
35
+ '' :
36
+ $event->get( 'recurrence_rules' );
37
+ } else {
38
+ $rule = $event->get( 'exception_rules' ) ?
39
+ '' :
40
+ $event->get( 'exception_rules' );
41
+ }
42
+
43
+ $rc = new SG_iCal_Recurrence(
44
+ new SG_iCal_Line( 'RRULE:' . $rule )
45
+ );
46
+
47
+ if ( $until = $rc->getUntil() ) {
48
+ $until = ( is_numeric( $until ) )
49
+ ? $until
50
+ : strtotime( $until );
51
+ } elseif ( $count = $rc->getCount() ) {
52
+ $count = ( is_numeric( $count ) ) ? $count : 100;
53
+ }
54
+ } catch( Ai1ec_Event_Not_Found_Exception $e ) { /* event wasn't found, keep defaults */ }
55
+
56
+ $args = array(
57
+ 'row_daily' => $this->row_daily(),
58
+ 'row_weekly' => $this->row_weekly(),
59
+ 'row_monthly' => $this->row_monthly(),
60
+ 'row_yearly' => $this->row_yearly(),
61
+ 'count' => $this->create_count_input(
62
+ 'ai1ec_count',
63
+ $count
64
+ ) . Ai1ec_I18n::__( 'times' ),
65
+ 'end' => $this->create_end_dropdown( $end ),
66
+ 'until' => $until,
67
+ 'repeat' => $repeat,
68
+ );
69
+ $output = array(
70
+ 'error' => false,
71
+ 'message' => $loader->get_file(
72
+ 'box_repeat.php',
73
+ $args,
74
+ true
75
+ )->get_content(),
76
+ 'repeat' => $repeat,
77
+ );
78
+ $json_strategy = $this->_registry->get( 'http.response.render.strategy.json' );
79
+ $json_strategy->render( array( 'data' => $output ) );
80
+ }
81
+
82
+ /**
83
+ * get_weekday_by_id function
84
+ *
85
+ * Returns weekday name in English
86
+ *
87
+ * @param int $day_id Day ID
88
+ *
89
+ * @return string
90
+ **/
91
+ public function get_weekday_by_id( $day_id, $by_value = false ) {
92
+ // do not translate this !!!
93
+ $week_days = array(
94
+ 0 => 'SU',
95
+ 1 => 'MO',
96
+ 2 => 'TU',
97
+ 3 => 'WE',
98
+ 4 => 'TH',
99
+ 5 => 'FR',
100
+ 6 => 'SA',
101
+ );
102
+
103
+ if ( $by_value ) {
104
+ while ( $_name = current( $week_days ) ) {
105
+ if ( $_name == $day_id ) {
106
+ return key( $week_days );
107
+ }
108
+ next( $week_days );
109
+ }
110
+ return false;
111
+ }
112
+ return $week_days[$day_id];
113
+ }
114
+
115
+ /**
116
+ * convert_rrule_to_text method
117
+ *
118
+ * Convert a `recurrence rule' to text to display it on screen
119
+ *
120
+ * @return void
121
+ **/
122
+ public function convert_rrule_to_text() {
123
+ $error = false;
124
+ $message = '';
125
+ // check to see if RRULE is set
126
+ if ( isset( $_REQUEST['rrule'] ) ) {
127
+ // check to see if rrule is empty
128
+ if ( empty( $_REQUEST['rrule'] ) ) {
129
+ $error = true;
130
+ $message = Ai1ec_I18n::__(
131
+ 'Recurrence rule cannot be empty.'
132
+ );
133
+ } else {
134
+ $rrule = $this->_registry->get( 'recurrence.rule' );
135
+ // convert rrule to text
136
+ $message = ucfirst(
137
+ $rrule->rrule_to_text( $_REQUEST['rrule'] )
138
+ );
139
+ }
140
+ } else {
141
+ $error = true;
142
+ $message = Ai1ec_I18n::__(
143
+ 'Recurrence rule was not provided.'
144
+ );
145
+ }
146
+ $output = array(
147
+ 'error' => $error,
148
+ 'message' => get_magic_quotes_gpc()
149
+ ? stripslashes( $message )
150
+ : $message,
151
+ );
152
+
153
+ $json_strategy = $this->_registry->get( 'http.response.render.strategy.json' );
154
+ $json_strategy->render( array( 'data' => $output ) );
155
+ }
156
+
157
+ /**
158
+ * create_end_dropdown function
159
+ *
160
+ * Outputs the dropdown list for the recurrence end option.
161
+ *
162
+ * @param int $selected The index of the selected option, if any
163
+ * @return void
164
+ **/
165
+ protected function create_end_dropdown( $selected = NULL ) {
166
+ ob_start();
167
+
168
+ $options = array(
169
+ 0 => Ai1ec_I18n::__( 'Never' ),
170
+ 1 => Ai1ec_I18n::__( 'After' ),
171
+ 2 => Ai1ec_I18n::__( 'On date' ),
172
+ );
173
+
174
+ ?>
175
+ <select name="ai1ec_end" id="ai1ec_end">
176
+ <?php foreach( $options as $key => $val ): ?>
177
+ <option value="<?php echo $key ?>"
178
+ <?php if( $key === $selected ) echo 'selected="selected"' ?>>
179
+ <?php echo $val ?>
180
+ </option>
181
+ <?php endforeach ?>
182
+ </select>
183
+ <?php
184
+
185
+ $output = ob_get_contents();
186
+ ob_end_clean();
187
+
188
+ return $output;
189
+ }
190
+
191
+ /**
192
+ * row_daily function
193
+ *
194
+ * Returns daily selector
195
+ *
196
+ * @return void
197
+ **/
198
+ protected function row_daily( $visible = false, $selected = 1 ) {
199
+ $loader = $this->_registry->get( 'theme.loader' );
200
+
201
+ $args = array(
202
+ 'visible' => $visible,
203
+ 'count' => $this->create_count_input(
204
+ 'ai1ec_daily_count',
205
+ $selected,
206
+ 365
207
+ ) . Ai1ec_I18n::__( 'day(s)' ),
208
+ );
209
+ return $loader->get_file( 'row_daily.php', $args, true )
210
+ ->get_content();
211
+ }
212
+
213
+ /**
214
+ * Generates and returns "End after X times" input
215
+ *
216
+ * @param Integer|NULL $count Initial value of range input
217
+ *
218
+ * @return String Repeat dropdown
219
+ */
220
+ protected function create_count_input( $name, $count = 100, $max = 365 ) {
221
+ ob_start();
222
+
223
+ if ( ! $count ) {
224
+ $count = 100;
225
+ }
226
+ ?>
227
+ <input type="range" name="<?php echo $name ?>" id="<?php echo $name ?>"
228
+ min="1" max="<?php echo $max ?>"
229
+ <?php if ( $count ) echo 'value="' . $count . '"' ?> />
230
+ <?php
231
+ return ob_get_clean();
232
+ }
233
+
234
+ /**
235
+ * row_weekly function
236
+ *
237
+ * Returns weekly selector
238
+ *
239
+ * @return void
240
+ **/
241
+ protected function row_weekly(
242
+ $visible = false,
243
+ $count = 1,
244
+ array $selected = array()
245
+ ) {
246
+ global $wp_locale;
247
+ $start_of_week = $this->_registry->get( 'model.option' )
248
+ ->get( 'start_of_week', 1 );
249
+ $loader = $this->_registry->get( 'theme.loader' );
250
+
251
+ $options = array();
252
+ // get days from start_of_week until the last day
253
+ for ( $i = $start_of_week; $i <= 6; ++$i ) {
254
+ $options[$this->get_weekday_by_id( $i )] = $wp_locale
255
+ ->weekday_initial[$wp_locale->weekday[$i]];
256
+ }
257
+
258
+ // get days from 0 until start_of_week
259
+ if ( $start_of_week > 0 ) {
260
+ for ( $i = 0; $i < $start_of_week; $i++ ) {
261
+ $options[$this->get_weekday_by_id( $i )] = $wp_locale
262
+ ->weekday_initial[$wp_locale->weekday[$i]];
263
+ }
264
+ }
265
+
266
+ $args = array(
267
+ 'visible' => $visible,
268
+ 'count' => $this->create_count_input(
269
+ 'ai1ec_weekly_count',
270
+ $count,
271
+ 52
272
+ ) . Ai1ec_I18n::__( 'week(s)' ),
273
+ 'week_days' => $this->create_list_element(
274
+ 'ai1ec_weekly_date_select',
275
+ $options,
276
+ $selected
277
+ )
278
+ );
279
+ return $loader->get_file( 'row_weekly.php', $args, true )
280
+ ->get_content();
281
+ }
282
+
283
+ /**
284
+ * Creates a grid of weekday, day, or month selection buttons.
285
+ *
286
+ * @return string
287
+ */
288
+ protected function create_list_element(
289
+ $name,
290
+ array $options = array(),
291
+ array $selected = array()
292
+ ) {
293
+ ob_start();
294
+ ?>
295
+ <div class="ai1ec-btn-group-grid" id="<?php echo $name; ?>">
296
+ <?php foreach ( $options as $key => $val ) : ?>
297
+ <div class="ai1ec-pull-left">
298
+ <a class="ai1ec-btn ai1ec-btn-default ai1ec-btn-block
299
+ <?php echo in_array( $key, $selected ) ? 'ai1ec-active' : ''; ?>">
300
+ <?php echo $val; ?>
301
+ </a>
302
+ <input type="hidden" name="<?php echo $name . '_' . $key; ?>"
303
+ value="<?php echo $key; ?>">
304
+ </div class="ai1ec-pull-left">
305
+ <?php endforeach; ?>
306
+ </div>
307
+ <input type="hidden" name="<?php echo $name; ?>"
308
+ value="<?php echo implode( ',', $selected ) ?>">
309
+ <?php
310
+ return ob_get_clean();
311
+ }
312
+
313
+ /**
314
+ * row_monthly function
315
+ *
316
+ * Returns monthly selector
317
+ *
318
+ * @return void
319
+ **/
320
+ protected function row_monthly(
321
+ $visible = false,
322
+ $count = 1,
323
+ $ai1ec_monthly_each = 0,
324
+ $ai1ec_monthly_on_the = 0,
325
+ $month = array(),
326
+ $first = false,
327
+ $second = false
328
+ ) {
329
+ global $wp_locale;
330
+ $start_of_week = $this->_registry->get( 'model.option' )
331
+ ->get( 'start_of_week', 1 );
332
+ $loader = $this->_registry->get( 'theme.loader' );
333
+
334
+ $options_wd = array();
335
+ // get days from start_of_week until the last day
336
+ for ( $i = $start_of_week; $i <= 6; ++$i ) {
337
+ $options_wd[$this->get_weekday_by_id( $i )] = $wp_locale
338
+ ->weekday[$i];
339
+ }
340
+
341
+ // get days from 0 until start_of_week
342
+ if ( $start_of_week > 0 ) {
343
+ for ( $i = 0; $i < $start_of_week; $i++ ) {
344
+ $options_wd[$this->get_weekday_by_id( $i )] = $wp_locale
345
+ ->weekday[$i];
346
+ }
347
+ }
348
+
349
+ // get options like 1st/2nd/3rd for "day number"
350
+ $options_dn = array( 1 => 1, 2 => 2, 3 => 3, 4 => 4, 5 => 5 );
351
+ foreach ( $options_dn as $_dn ) {
352
+ $options_dn[$_dn] = $this->_registry->get(
353
+ 'date.time',
354
+ strtotime( $_dn . '-01-1998 12:00:00' )
355
+ )->format_i18n( 'jS' );
356
+ }
357
+ $options_dn['-1'] = Ai1ec_I18n::__( 'last' );
358
+
359
+ $args = array(
360
+ 'visible' => $visible,
361
+ 'count' => $this->create_count_input(
362
+ 'ai1ec_monthly_count',
363
+ $count,
364
+ 12
365
+ ) . Ai1ec_I18n::__( 'month(s)' ),
366
+ 'ai1ec_monthly_each' => $ai1ec_monthly_each,
367
+ 'ai1ec_monthly_on_the' => $ai1ec_monthly_on_the,
368
+ 'month' => $this->create_monthly_date_select(
369
+ $month
370
+ ),
371
+ 'on_the_select' => $this->create_on_the_select(
372
+ $first,
373
+ $second
374
+ ),
375
+ 'day_nums' => $this->create_select_element(
376
+ 'ai1ec_monthly_byday_num',
377
+ $options_dn
378
+ ),
379
+ 'week_days' => $this->create_select_element(
380
+ 'ai1ec_monthly_byday_weekday',
381
+ $options_wd
382
+ ),
383
+ );
384
+ return $loader->get_file( 'row_monthly.php', $args, true )
385
+ ->get_content();
386
+ }
387
+
388
+ /**
389
+ * Creates selector for dates in monthly repeat tab.
390
+ *
391
+ * @return void
392
+ */
393
+ protected function create_monthly_date_select( $selected = array() ) {
394
+ $options = array();
395
+ for ( $i = 1; $i <= 31; ++$i ) {
396
+ $options[$i] = $i;
397
+ }
398
+ return $this->create_list_element(
399
+ 'ai1ec_montly_date_select',
400
+ $options,
401
+ $selected
402
+ );
403
+ }
404
+
405
+ /**
406
+ * create_on_the_select function
407
+ *
408
+ *
409
+ *
410
+ * @return string
411
+ **/
412
+ protected function create_on_the_select(
413
+ $f_selected = false,
414
+ $s_selected = false
415
+ ) {
416
+ $ret = '';
417
+
418
+ $first_options = array(
419
+ '0' => Ai1ec_I18n::__( 'first' ),
420
+ '1' => Ai1ec_I18n::__( 'second' ),
421
+ '2' => Ai1ec_I18n::__( 'third' ),
422
+ '3' => Ai1ec_I18n::__( 'fourth' ),
423
+ '4' => '------',
424
+ '5' => Ai1ec_I18n::__( 'last' )
425
+ );
426
+ $ret = $this->create_select_element(
427
+ 'ai1ec_monthly_each_select',
428
+ $first_options,
429
+ $f_selected,
430
+ array( 4 )
431
+ );
432
+
433
+ $second_options = array(
434
+ '0' => Ai1ec_I18n::__( 'Sunday' ),
435
+ '1' => Ai1ec_I18n::__( 'Monday' ),
436
+ '2' => Ai1ec_I18n::__( 'Tuesday' ),
437
+ '3' => Ai1ec_I18n::__( 'Wednesday' ),
438
+ '4' => Ai1ec_I18n::__( 'Thursday' ),
439
+ '5' => Ai1ec_I18n::__( 'Friday' ),
440
+ '6' => Ai1ec_I18n::__( 'Saturday' ),
441
+ '7' => '--------',
442
+ '8' => Ai1ec_I18n::__( 'day' ),
443
+ '9' => Ai1ec_I18n::__( 'weekday' ),
444
+ '10' => Ai1ec_I18n::__( 'weekend day' )
445
+ );
446
+
447
+ return $ret . $this->create_select_element(
448
+ 'ai1ec_monthly_on_the_select',
449
+ $second_options,
450
+ $s_selected,
451
+ array( 7 )
452
+ );
453
+ }
454
+
455
+ /**
456
+ * create_select_element function
457
+ *
458
+ * Render HTML <select> element
459
+ *
460
+ * @param string $name Name of element to be rendered
461
+ * @param array $options Select <option> values as key=>value pairs
462
+ * @param string $selected Key to be marked as selected [optional=false]
463
+ * @param array $disabled_keys List of options to disable [optional=array]
464
+ *
465
+ * @return string Rendered <select> HTML element
466
+ **/
467
+ protected function create_select_element(
468
+ $name,
469
+ array $options = array(),
470
+ $selected = false,
471
+ array $disabled_keys = array()
472
+ ) {
473
+ ob_start();
474
+ ?>
475
+ <select name="<?php echo $name ?>" id="<?php echo $name ?>">
476
+ <?php foreach( $options as $key => $val ): ?>
477
+ <option value="<?php echo $key ?>"
478
+ <?php echo $key === $selected ? 'selected="selected"' : '' ?>
479
+ <?php echo in_array( $key, $disabled_keys ) ? 'disabled' : '' ?>>
480
+ <?php echo $val ?>
481
+ </option>
482
+ <?php endforeach ?>
483
+ </select>
484
+ <?php
485
+ return ob_get_clean();
486
+ }
487
+
488
+ /**
489
+ * row_yearly function
490
+ *
491
+ * Returns yearly selector
492
+ *
493
+ * @return void
494
+ **/
495
+ protected function row_yearly(
496
+ $visible = false,
497
+ $count = 1,
498
+ $year = array(),
499
+ $first = false,
500
+ $second = false
501
+ ) {
502
+ $loader = $this->_registry->get( 'theme.loader' );
503
+
504
+ $args = array(
505
+ 'visible' => $visible,
506
+ 'count' => $this->create_count_input(
507
+ 'ai1ec_yearly_count',
508
+ $count,
509
+ 10
510
+ ) . Ai1ec_I18n::__( 'year(s)' ),
511
+ 'year' => $this->create_yearly_date_select( $year ),
512
+ 'on_the_select' => $this->create_on_the_select(
513
+ $first,
514
+ $second
515
+ ),
516
+ );
517
+ return $loader->get_file( 'row_yearly.php', $args, true )
518
+ ->get_content();
519
+ }
520
+
521
+ /**
522
+ * create_yearly_date_select function
523
+ *
524
+ *
525
+ *
526
+ * @return void
527
+ **/
528
+ protected function create_yearly_date_select( $selected = array() ) {
529
+ global $wp_locale;
530
+ $options = array();
531
+ for ( $i = 1; $i <= 12; ++$i ) {
532
+ $options[$i] = $wp_locale->month_abbrev[
533
+ $wp_locale->month[sprintf( '%02d', $i )]
534
+ ];
535
+ }
536
+ return $this->create_list_element(
537
+ 'ai1ec_yearly_date_select',
538
+ $options,
539
+ $selected
540
+ );
541
+ }
542
+ }
app/view/admin/img/admin-menu.png DELETED
Binary file
app/view/admin/img/ajax-loader.gif DELETED
Binary file
app/view/admin/img/logo.png DELETED
Binary file
app/view/admin/js/add_new_event.js DELETED
@@ -1,982 +0,0 @@
1
- // Global Variables
2
- var ai1ec_geocoder, ai1ec_default_location, ai1ec_myOptions, ai1ec_map, ai1ec_marker, ai1ec_marker_draggable;
3
-
4
- /**
5
- *
6
- * converts commas to dots as in some regions (Europe for example) floating point numbers are defined with a comma instead of a dot
7
- *
8
- */
9
- var ai1ec_convert_commas_to_dots_for_coordinates = function() {
10
- if ( jQuery( '#ai1ec_input_coordinates:checked' ).length > 0 ) {
11
- jQuery( '#ai1ec_table_coordinates input.coordinates' ).each( function() {
12
- this.value = AI1EC_UTILS.convert_comma_to_dot( this.value );
13
- });
14
- }
15
- }
16
- /**
17
- * Shows the error message after the field
18
- *
19
- * @param Object the dom element after which we put the error
20
- * @param the error message
21
- */
22
- var ai1ec_show_error_message_after_element = function( el, error_message ) {
23
- // Create the element to append in case of error
24
- var error = jQuery( '<div />',
25
- {
26
- 'text': error_message,
27
- 'class': 'ai1ec-error'
28
- }
29
- );
30
- // Insert error message
31
- jQuery( el ).after( error );
32
- }
33
-
34
- /**
35
- * Prevent default actions and stop immediate propagation if the publish button
36
- * was clicked and gives focus to the passed element.
37
- *
38
- * @param Object the event object
39
- * @param Object the element to focus
40
- */
41
- var ai1ec_prevent_actions_and_focus_on_errors = function( e, el ) {
42
- // If the validation was triggered by clicking publish
43
- if ( e.target.id === 'publish' ) {
44
- // Prevent other events from firing
45
- e.stopImmediatePropagation();
46
- // Prevent the submit
47
- e.preventDefault();
48
- }
49
- // Focus on the first field that has an error
50
- jQuery( el ).focus();
51
- }
52
-
53
- /**
54
- * Given a location, update the address field with a reformatted version,
55
- * update hidden location fields with address data, and center map on
56
- * new location.
57
- *
58
- * @param object result single result of a Google geocode() call
59
- */
60
- var ai1ec_update_address = function( result ) {
61
- ai1ec_map.setCenter( result.geometry.location );
62
- ai1ec_map.setZoom( 15 );
63
- ai1ec_marker.setPosition( result.geometry.location );
64
- jQuery( '#ai1ec_address' ).val( result.formatted_address );
65
-
66
- var street_number = '',
67
- street_name = '',
68
- city = '',
69
- state = '',
70
- postal_code = 0,
71
- country = 0,
72
- province = '';
73
-
74
- for( var i = 0; i < result.address_components.length; i++ ) {
75
- switch( result.address_components[i].types[0] ) {
76
- case 'street_number':
77
- street_number = result.address_components[i].long_name;
78
- break;
79
- case 'route':
80
- street_name = result.address_components[i].long_name;
81
- break;
82
- case 'locality':
83
- city = result.address_components[i].long_name;
84
- break;
85
- case 'administrative_area_level_1':
86
- province = result.address_components[i].long_name;
87
- break;
88
- case 'postal_code':
89
- postal_code = result.address_components[i].long_name;
90
- break;
91
- case 'country':
92
- country = result.address_components[i].long_name;
93
- break;
94
- }
95
- }
96
- // Combine street number with street address
97
- var address = street_number.length > 0 ? street_number + ' ' : '';
98
- address += street_name.length > 0 ? street_name : '';
99
- // Clean up postal code if necessary
100
- postal_code = postal_code != 0 ? postal_code : '';
101
-
102
- jQuery( '#ai1ec_city' ).val( city );
103
- jQuery( '#ai1ec_province' ).val( province );
104
- jQuery( '#ai1ec_postal_code' ).val( postal_code );
105
- jQuery( '#ai1ec_country' ).val( country );
106
- };
107
-
108
- /**
109
- * Show/hide elements that show selectors for ending until/after events
110
- */
111
- var show_end_fields = function() {
112
- var selected = jQuery( '#ai1ec_end option:selected' ).val();
113
- switch( selected ) {
114
- // Never selected, hide end fields
115
- case '0':
116
- hide_all_end_fields();
117
- break;
118
- // After selected
119
- case '1':
120
- if( jQuery( '#ai1ec_count_holder' ).css( 'display' ) == 'none' ) {
121
- hide_all_end_fields();
122
- jQuery( '#ai1ec_count_holder' ).fadeIn();
123
- }
124
- break;
125
- // On date selected
126
- case '2':
127
- if( jQuery( '#ai1ec_until_holder' ).css( 'display' ) == 'none' ) {
128
- hide_all_end_fields();
129
- jQuery( '#ai1ec_until_holder' ).fadeIn();
130
- }
131
- break;
132
- }
133
- };
134
-
135
- /**
136
- * Show/hide elements that show selectors for repeating events
137
- */
138
- var show_all_repeat_fields = function() {
139
- jQuery( '#ai1ec_end_holder' ).fadeIn();
140
- show_end_fields();
141
- };
142
-
143
- var hide_all_repeat_fields = function() {
144
- hide_all_end_fields();
145
- hide_custom_repeat_elements();
146
- hide_frequency();
147
- jQuery( '#ai1ec_end_holder' ).fadeOut();
148
- };
149
-
150
- var hide_all_end_fields = function() {
151
- jQuery( '#ai1ec_count_holder, #ai1ec_until_holder' ).hide();
152
- };
153
-
154
- var ai1ec_selector = function( selector ) {
155
- jQuery( selector + ' > li' ).live( 'click', function() {
156
- if( jQuery( this ).hasClass( 'ai1ec_selected' ) ) {
157
- jQuery( this ).removeClass( 'ai1ec_selected' );
158
- } else {
159
- jQuery( this ).addClass( 'ai1ec_selected' );
160
- }
161
- var data = new Array();
162
- jQuery( selector + ' > li' ).each( function() {
163
- if( jQuery( this ).hasClass( 'ai1ec_selected' ) ) {
164
- var value = jQuery( this ).children( 'input[type="hidden"]:first' ).val();
165
- data.push( value );
166
- }
167
- });
168
- jQuery( selector ).next().val( data.join() );
169
- });
170
- };
171
-
172
- var ai1ec_repeat_form_success = function( s1, s2, s3, rule, button, response ) {
173
- jQuery( s1 ).val( rule );
174
- jQuery.unblockUI();
175
- var txt = jQuery.trim( jQuery( s2 ).text() );
176
- if( txt.lastIndexOf( ':' ) == -1 ) {
177
- txt = txt.substring( 0, txt.length - 3 );
178
- jQuery( s2 ).text( txt + ':' );
179
- }
180
- jQuery(button).attr( 'disabled', false );
181
- jQuery( s3 ).fadeOut( 'fast', function() {
182
- jQuery( this ).text( response.message );
183
- jQuery( this ).fadeIn( 'fast' );
184
- });
185
- };
186
-
187
- var ai1ec_repeat_form_error = function( s1, s2, response, button ) {
188
- jQuery.growlUI( 'Error', response.message );
189
- jQuery( button ).attr( 'disabled', false );
190
- jQuery( s1 ).val( '' );
191
- var txt = jQuery.trim( jQuery( s2 ).text() );
192
- if( txt.lastIndexOf( '...' ) == -1 ) {
193
- txt = txt.substring( 0, txt.length - 1 );
194
- jQuery( s2 ).text( txt + '...' );
195
- }
196
- };
197
-
198
- var ai1ec_click_on_ics_rule_text = function( s1, s2, s3, data, fn ) {
199
- jQuery( s1 ).live( 'click', function() {
200
- if( ! jQuery( s2 ).is( ':checked' ) ) {
201
- jQuery( s2 ).attr( 'checked', true );
202
- var txt = jQuery.trim( jQuery( s3 ).text() );
203
- txt = txt.substring( 0, txt.length - 3 );
204
- jQuery( s3 ).text( txt + ':' );
205
- }
206
- ai1ec_show_repeat_tabs( data, fn );
207
- return false;
208
- });
209
- };
210
-
211
- var ai1ec_click_on_checkbox = function( s1, s2, s3, data, fn ) {
212
- jQuery( s1 ).click( function() {
213
- if( jQuery(this).is( ':checked' ) ) {
214
- ai1ec_show_repeat_tabs( data, fn );
215
- } else {
216
- jQuery( s2 ).text( '' );
217
- var txt = jQuery.trim( jQuery( s3 ).text() );
218
- txt = txt.substring( 0, txt.length - 1 );
219
- jQuery( s3 ).text( txt + '...' );
220
- }
221
- });
222
- };
223
-
224
- var ai1ec_click_on_modal_cancel = function( s1, s2, s3 ) {
225
- if( jQuery.trim( jQuery( s1 ).text() ) == '' ) {
226
- jQuery( s2 ).attr( 'checked', false );
227
- var txt = jQuery.trim( jQuery( s3 ).text() );
228
- if( txt.lastIndexOf( '...' ) == -1 ) {
229
- txt = txt.substring( 0, txt.length - 1 );
230
- jQuery( s3 ).text( txt + '...' );
231
- }
232
- }
233
- };
234
-
235
- // called after the repeat block is inserted in the DOM
236
- var ai1ec_apply_js_on_repeat_block = function() {
237
- // Initialize count range slider
238
- jQuery( '#ai1ec_count, #ai1ec_daily_count, #ai1ec_weekly_count, #ai1ec_monthly_count, #ai1ec_yearly_count' ).rangeinput( {
239
- css: {
240
- input: 'ai1ec-range',
241
- slider: 'ai1ec-slider',
242
- progress: 'ai1ec-progress',
243
- handle: 'ai1ec-handle'
244
- }
245
- } );
246
- // Initialize inputdate plugin on our "until" date input.
247
- data = {
248
- start_date_input: '#ai1ec_until-date-input',
249
- start_time: '#ai1ec_until-time',
250
- date_format: ai1ec_add_new_event.date_format,
251
- month_names: ai1ec_add_new_event.month_names,
252
- day_names: ai1ec_add_new_event.day_names,
253
- week_start_day: ai1ec_add_new_event.week_start_day,
254
- twentyfour_hour: ai1ec_add_new_event.twentyfour_hour,
255
- now: new Date( ai1ec_add_new_event.now * 1000 )
256
- }
257
- jQuery.inputdate( data );
258
- };
259
-
260
- var ai1ec_show_repeat_tabs = function( data, post_ajax_func ) {
261
- jQuery.blockUI( {
262
- message: '<div class="ai1ec-repeat-box-loading"></div>',
263
- css: {
264
- width: '358px',
265
- border: '0',
266
- background: 'transparent',
267
- cursor: 'normal'
268
- }
269
- });
270
- jQuery.post(
271
- ajaxurl,
272
- data,
273
- function( response ) {
274
- if( response.error ) {
275
- // tell the user there is an error
276
- // TODO: Use other method of notification
277
- alert( response.message );
278
- jQuery.unblockUI();
279
- } else {
280
- // display the form
281
- jQuery.blockUI( {
282
- message: response.message,
283
- css: {
284
- width: '358px',
285
- border: '0',
286
- background: 'transparent',
287
- cursor: 'normal'
288
- }
289
- });
290
- var fn = window[post_ajax_func];
291
- if( typeof fn === 'function' ) {
292
- fn();
293
- }
294
- }
295
- },
296
- 'json'
297
- );
298
- };
299
-
300
- /**
301
- * isUrl checks to see if the passed parameter is a valid url
302
- * and returns true on access and false on failure
303
- *
304
- * @param String s String to validate
305
- *
306
- * @return boolean True if the string is a valid url, false otherwise
307
- */
308
- var isUrl = function( s ) {
309
- var regexp = /(http|https|webcal):\/\/(\w+:{0,1}\w*@)?(\S+)(:[0-9]+)?(\/|\/([\w#!:.?+=&%@!\-\/]))?/
310
- return regexp.test(s);
311
- };
312
-
313
- // ====================
314
- // = jQuery DOM Ready =
315
- // ====================
316
- jQuery( function( $ ){
317
-
318
- // Initialize any popovers required on the page.
319
- // Currently only popovers in the Support box (if present) need to be
320
- // initialized.
321
- $( '#ai1ec-support .ai1ec-download a[title]' ).popover( {
322
- placement: 'left'
323
- } );
324
-
325
- /**
326
- * Click event handler for Dismiss button
327
- * that disables the data notification for admin users
328
- */
329
- $( '.ai1ec-dismiss-notification' ).live( 'click', function() {
330
- var $button = $( this );
331
- var $parent = $( this ).parent().parent();
332
- // disable the update button
333
- $button.attr( 'disabled', true );
334
-
335
- // create the data to send
336
- var data = {
337
- action: 'ai1ec_disable_notification',
338
- note: false
339
- };
340
-
341
- $.post( ajaxurl, data, function( response ) {
342
- if( response.error ) {
343
- // tell the user that there is an error
344
- alert( response.message );
345
- } else {
346
- // hide notification message
347
- $parent.remove();
348
- }
349
- });
350
- });
351
- /**
352
- * Click event handler for Dismiss button
353
- * that disables the data notification for admin users
354
- */
355
- $( '.ai1ec-dismiss-standard-notification' ).live( 'click', function() {
356
- var $button = $( this );
357
- var $parent = $( this ).parent().parent();
358
- // disable the update button
359
- $button.attr( 'disabled', true );
360
-
361
- // create the data to send
362
- var data = {
363
- action: 'ai1ec_disable_standard_notice',
364
- note: false
365
- };
366
-
367
- $.post( ajaxurl, data, function( response ) {
368
- if( response.error ) {
369
- // tell the user that there is an error
370
- alert( response.message );
371
- } else {
372
- // hide notification message
373
- $parent.remove();
374
- }
375
- });
376
- });
377
- /**
378
- * Click event handler for Dismiss button of intro video.
379
- * That disables the intro video notification for admin users.
380
- */
381
- $( '.ai1ec-dismiss-intro-video' ).live( 'click', function() {
382
- var $button = $( this );
383
- var $parent = $( this ).parent().parent();
384
- // disable the update button
385
- $button.attr( 'disabled', true );
386
-
387
- // create the data to send
388
- var data = {
389
- action: 'ai1ec_disable_intro_video',
390
- note: false
391
- };
392
-
393
- $.post( ajaxurl, data, function( response ) {
394
- if( response.error ) {
395
- // tell the user that there is an error
396
- alert( response.message );
397
- } else {
398
- // hide notification message
399
- $parent.remove();
400
- }
401
- });
402
- });
403
-
404
- /**
405
- * Event post creation/edit form
406
- */
407
- if( $('#ai1ec_event' ).length ) {
408
- var now = new Date( ai1ec_add_new_event.now * 1000 );
409
-
410
- /**
411
- * Timespan plugin setup
412
- */
413
-
414
- // Initialize timespan plugin on our date/time inputs.
415
- var data = {
416
- allday: '#ai1ec_all_day_event',
417
- start_date_input: '#ai1ec_start-date-input',
418
- start_time_input: '#ai1ec_start-time-input',
419
- start_time: '#ai1ec_start-time',
420
- end_date_input: '#ai1ec_end-date-input',
421
- end_time_input: '#ai1ec_end-time-input',
422
- end_time: '#ai1ec_end-time',
423
- date_format: ai1ec_add_new_event.date_format,
424
- month_names: ai1ec_add_new_event.month_names,
425
- day_names: ai1ec_add_new_event.day_names,
426
- week_start_day: ai1ec_add_new_event.week_start_day,
427
- twentyfour_hour: ai1ec_add_new_event.twentyfour_hour,
428
- now: now
429
- }
430
- $.timespan( data );
431
-
432
- var exdate = $( "#ai1ec_exdate" ).val();
433
- var dp_date = null;
434
- var _clear_dp = false;
435
- if( exdate.length >= 8 ) {
436
- dp_date = new Array();
437
- var _span_html = '';
438
- $.each( exdate.split( ',' ), function( i, v ) {
439
- _date = v.slice( 0, 8 );
440
- _year = _date.substr( 0, 4 );
441
- _month = _date.substr( 4, 2 );
442
- _day = _date.substr( 6, 2 );
443
- _span_html += _year + '-' + _month + '-' + _day + ',';
444
- _month = _month.charAt(0) == '0' ? ( '0' + ( parseInt( _month.charAt( 1 ) ) - 1 ) )
445
- : ( parseInt( _month ) - 1 )
446
-
447
- dp_date.push( new Date( _year, _month, _day ) );
448
- });
449
- _span_html = _span_html.slice( 0, _span_html.length - 1 );
450
- $( '#widgetField span:first' ).html( _span_html );
451
- } else {
452
- dp_date = new Date( ai1ec_add_new_event.now * 1000 )
453
- _clear_dp = true;
454
- }
455
-
456
- $( '#widgetCalendar' ).DatePicker({
457
- flat: true,
458
- calendars: 3,
459
- mode: 'multiple',
460
- start: 1,
461
- date: dp_date,
462
- onChange: function( formated ) {
463
- $( '#widgetField span' ).get( 0 ).innerHTML = formated;
464
- formated = formated.toString();
465
- if( formated.length >= 8 ) {
466
- // save the date in your hidden field
467
- var exdate = '';
468
- $.each( formated.split( ',' ), function( i, v ) {
469
- exdate += v.replace( /-/g, '' ) + 'T000000Z,';
470
- });
471
- exdate = exdate.slice( 0, exdate.length - 1 );
472
- $( "#ai1ec_exdate" ).val( exdate );
473
- } else {
474
- $( "#ai1ec_exdate" ).val( '' );
475
- }
476
- }
477
- });
478
-
479
- if( _clear_dp ) {
480
- $( '#widgetCalendar' ).DatePickerClear();
481
- }
482
-
483
- var state = false;
484
- $( '#widgetField > a, #widgetField > span, #ai1ec_exclude_date_label' ).bind( 'click', function() {
485
- $('#widgetCalendar').stop().animate( { height: state ? 0 : $( '#widgetCalendar div.datepicker' ).get( 0 ).offsetHeight }, 500 );
486
- state = !state;
487
- return false;
488
- });
489
- $( '#widgetCalendar div.datepicker' ).css( 'position', 'absolute' )
490
-
491
- /**
492
- * Google map setup
493
- */
494
-
495
- // If the user is updating an event, initialize the map to the event
496
- // location, otherwise if the user is creating a new event initialize
497
- // the map to the whole world
498
- var ai1ec_geocoder = new google.maps.Geocoder();
499
- //world = map.setCenter(new GLatLng(9.965, -83.327), 1);
500
- //africa = map.setCenter(new GLatLng(-3, 27), 3);
501
- //europe = map.setCenter(new GLatLng(47, 19), 3);
502
- //asia = map.setCenter(new GLatLng(32, 130), 3);
503
- //south pacific = map.setCenter(new GLatLng(-24, 134), 3);
504
- //north america = map.setCenter(new GLatLng(50, -114), 3);
505
- //latin america = map.setCenter(new GLatLng(-20, -70), 3);
506
- ai1ec_default_location = new google.maps.LatLng( 9.965, -83.327 );
507
- ai1ec_myOptions = {
508
- zoom: 0,
509
- mapTypeId: google.maps.MapTypeId.ROADMAP,
510
- center: ai1ec_default_location
511
- };
512
- ai1ec_map = new google.maps.Map( $( '#ai1ec_map_canvas' ).get(0), ai1ec_myOptions );
513
- ai1ec_marker = new google.maps.Marker({ map: ai1ec_map });
514
-
515
- if( ! ai1ec_add_new_event.disable_autocompletion ) {
516
- // This is the only way to stop the autocomplete from firing when the
517
- // coordinates checkbox is checked. The new jQuery UI autocomplete
518
- // supports the method .autocomplete( "disable" ) but not this version.
519
- $( '#ai1ec_address' )
520
- .bind( "keypress keyup keydown change", function( e ) {
521
- if( $( '#ai1ec_input_coordinates:checked' ).length ) {
522
- e.stopImmediatePropagation();
523
- }
524
- })
525
- // Initialize geo_autocomplete plugin
526
- .geo_autocomplete(
527
- new google.maps.Geocoder,
528
- {
529
- selectFirst: false,
530
- minChars: 3,
531
- cacheLength: 50,
532
- width: 300,
533
- scroll: true,
534
- scrollHeight: 330,
535
- region: ai1ec_add_new_event.region
536
- }
537
- )
538
- .result(
539
- function( _event, _data ) {
540
- if( _data ) {
541
- ai1ec_update_address( _data );
542
- }
543
- }
544
- )
545
- // Each time user changes address field, reformat field and update map.
546
- .change(
547
- function() {
548
- // Position map based on provided address value
549
- if( $( this ).val().length > 0 ) {
550
- var address = $( this ).val();
551
-
552
- ai1ec_geocoder.geocode(
553
- {
554
- 'address': address,
555
- 'region': ai1ec_add_new_event.region
556
- },
557
- function( results, status ) {
558
- if( status == google.maps.GeocoderStatus.OK ) {
559
- ai1ec_update_address( results[0] );
560
- }
561
- }
562
- );
563
- }
564
- }
565
- );
566
- }
567
- // If the coordinates checkbox is not checked
568
- if( $( '#ai1ec_input_coordinates:checked' ).length === 0 ) {
569
- // Hide the table (i hide things in js for progressive enhancement reasons)
570
- $( '#ai1ec_table_coordinates' ).css( { visibility : 'hidden' } );
571
- // Trigger the change event on the address to show the mep
572
- $( '#ai1ec_address' ).change();
573
- } else {
574
- // If the checkbox is checked, show the map using the coordinates
575
- ai1ec_update_map_from_coordinates();
576
- }
577
- // Toggle the visibility of google map on checkbox click
578
- $( '#ai1ec_google_map' ).click( function() {
579
- if( $( this ).is( ':checked' ) ) {
580
- // show the map
581
- $( '.ai1ec_box_map' )
582
- .addClass( 'ai1ec_box_map_visible')
583
- .hide()
584
- .slideDown( 'fast' );
585
- } else {
586
- // hide the map
587
- $( '.ai1ec_box_map' ).slideUp( 'fast' );
588
- }
589
- });
590
-
591
- ai1ec_selector( '#ai1ec_weekly_date_select' );
592
- ai1ec_selector( '#ai1ec_montly_date_select' );
593
- ai1ec_selector( '#ai1ec_yearly_date_select' );
594
-
595
- // ========================
596
- // = End dropdown clicked =
597
- // ========================
598
- $( '#ai1ec_end' ).live( 'change', show_end_fields );
599
-
600
- /**
601
- * Bottom publish button click event handler
602
- */
603
- if( $( '#ai1ec_bottom_publish' ).length > 0 ) {
604
- $( '#ai1ec_bottom_publish' ).click( function() {
605
- $( '#publish' ).trigger( 'click' );
606
- });
607
- }
608
-
609
- $( '.ai1ec_tab' ).live( 'click', function() {
610
- if( ! $( this ).hasClass( 'ai1ec_active' ) ) {
611
- var $active_tab = $( '.ai1ec_repeat_tabs > li > a.ai1ec_active' );
612
- var $active_content = $( $active_tab.attr( 'href' ) );
613
-
614
- var $becoming_active = $( $( this ).attr( 'href' ) );
615
-
616
- $active_tab.removeClass( 'ai1ec_active' );
617
- $active_content.hide();
618
-
619
- $( this ).addClass( 'ai1ec_active' );
620
- $becoming_active.append( $( '#ai1ec_repeat_tab_append' ) );
621
- $( '#ai1ec_ending_box' ).show();
622
- $becoming_active.show();
623
- }
624
- return false;
625
- });
626
-
627
- $( '.ai1ec_repeat_apply' ).live( 'click', function() {
628
- var $button = $( this );
629
- var rule = '';
630
- var $active_tab = $( $( '.ai1ec_active' ).attr( 'href' ) );
631
- var frequency = $active_tab.attr( 'title' );
632
- switch( frequency ) {
633
- case 'daily':
634
- rule += 'FREQ=DAILY;';
635
- var interval = $( '#ai1ec_daily_count' ).val();
636
- if( interval > 1 )
637
- rule += 'INTERVAL=' + interval + ';';
638
- break;
639
- case 'weekly':
640
- rule += 'FREQ=WEEKLY;';
641
- var interval = $( '#ai1ec_weekly_count' ).val();
642
- if( interval > 1 )
643
- rule += 'INTERVAL=' + interval + ';';
644
- var week_days = $( 'input[name="ai1ec_weekly_date_select"]:first' ).val();
645
- var wkst = $( '#ai1ec_weekly_date_select > li:first > input[type="hidden"]:first' ).val();
646
- if( week_days.length > 0 )
647
- rule += 'WKST=' + wkst + ';BYDAY=' + week_days + ';';
648
- break;
649
- case 'monthly':
650
- rule += 'FREQ=MONTHLY;';
651
- var interval = $( '#ai1ec_monthly_count' ).val();
652
- var monthtype = $( 'input[name="ai1ec_monthly_type"]:checked' ).val();
653
- if( interval > 1 )
654
- rule += 'INTERVAL=' + interval + ';';
655
- var month_days = $( 'input[name="ai1ec_montly_date_select"]:first' ).val();
656
- if( month_days.length > 0 && monthtype == 'bymonthday' ) {
657
- rule += 'BYMONTHDAY=' + month_days + ';';
658
- } else if ( monthtype == 'byday' ) {
659
- byday_num = $( '#ai1ec_monthly_byday_num' ).val();
660
- byday_weekday = $( '#ai1ec_monthly_byday_weekday' ).val();
661
- rule += 'BYDAY=' + byday_num + byday_weekday + ';';
662
- }
663
- break;
664
- case 'yearly':
665
- rule += 'FREQ=YEARLY;';
666
- var interval = $( '#ai1ec_yearly_count' ).val();
667
- if( interval > 1 )
668
- rule += 'INTERVAL=' + interval + ';';
669
- var months = $( 'input[name="ai1ec_yearly_date_select"]:first' ).val();
670
- if( months.length > 0 )
671
- rule += 'BYMONTH=' + months + ';';
672
- break;
673
- }
674
-
675
- var ending = $( '#ai1ec_end' ).val();
676
- // After
677
- if( ending == '1' ) {
678
- rule += 'COUNT=' + $( '#ai1ec_count' ).val() + ';';
679
- }
680
- // On Date
681
- if( ending == '2' ) {
682
- var until = parseDate( $( '#ai1ec_until-date-input' ).val(), ai1ec_add_new_event.date_format );
683
- var start = new Date( parseDate( $( '#ai1ec_start-time' ).val(), ai1ec_add_new_event.date_format ) );
684
- // Get UTC Day and UTC Month, and then add leading zeroes if required
685
- var d = until.getUTCDate();
686
- var m = until.getUTCMonth() + 1;
687
- var hh = start.getUTCHours();
688
- var mm = start.getUTCMinutes();
689
- var ss = '00';
690
- // months
691
- m = ( m < 10 ) ? '0' + m : m;
692
- // days
693
- d = ( d < 10 ) ? '0' + d : d;
694
- // hours
695
- hh = ( hh < 10 ) ? '0' + hh : hh;
696
- // minutes
697
- mm = ( mm < 10 ) ? '0' + mm : mm;
698
- // Now, set the UTC friendly date string
699
- until = until.getUTCFullYear() + '' + m + d + 'T235959Z';
700
- rule += 'UNTIL=' + until + ';';
701
- }
702
-
703
- var data = {
704
- action: 'ai1ec_rrule_to_text',
705
- rrule: rule
706
- };
707
- $( this ).attr( 'disabled', true );
708
- $.post(
709
- ajaxurl,
710
- data,
711
- function( response ) {
712
- if( response.error ) {
713
- if( $( '#ai1ec_is_box_repeat' ).val() == '1' ) {
714
- ai1ec_repeat_form_error( '#ai1ec_rrule', '#ai1ec_repeat_label', response, $button );
715
- } else {
716
- ai1ec_repeat_form_error( '#ai1ec_exrule', '#ai1ec_exclude_label', response, $button );
717
- }
718
- } else {
719
- if( $( '#ai1ec_is_box_repeat' ).val() == '1' ) {
720
- ai1ec_repeat_form_success( '#ai1ec_rrule', '#ai1ec_repeat_label', '#ai1ec_repeat_text > a', rule, $button, response );
721
- } else {
722
- ai1ec_repeat_form_success( '#ai1ec_exrule', '#ai1ec_exclude_label', '#ai1ec_exclude_text > a', rule, $button, response );
723
- }
724
- }
725
- },
726
- 'json'
727
- );
728
- });
729
-
730
- // handles click on rrule text
731
- ai1ec_click_on_ics_rule_text(
732
- '#ai1ec_repeat_text > a',
733
- '#ai1ec_repeat',
734
- '#ai1ec_repeat_label',
735
- {
736
- action: 'ai1ec_get_repeat_box',
737
- repeat: 1,
738
- post_id: $( '#post_ID' ).val()
739
- },
740
- 'ai1ec_apply_js_on_repeat_block'
741
- );
742
-
743
- // handles click on exrule text
744
- ai1ec_click_on_ics_rule_text(
745
- '#ai1ec_exclude_text > a',
746
- '#ai1ec_exclude',
747
- '#ai1ec_exclude_label',
748
- {
749
- action: 'ai1ec_get_repeat_box',
750
- repeat: 0,
751
- post_id: $( '#post_ID' ).val()
752
- },
753
- 'ai1ec_apply_js_on_repeat_block'
754
- );
755
-
756
- // handles click on repeat checkbox
757
- ai1ec_click_on_checkbox(
758
- '#ai1ec_repeat',
759
- '#ai1ec_repeat_text > a',
760
- '#ai1ec_repeat_label',
761
- {
762
- action: 'ai1ec_get_repeat_box',
763
- repeat: 1,
764
- post_id: $( '#post_ID' ).val()
765
- },
766
- 'ai1ec_apply_js_on_repeat_block'
767
- );
768
-
769
- // handles click on exclude checkbox
770
- ai1ec_click_on_checkbox(
771
- '#ai1ec_exclude',
772
- '#ai1ec_exclude_text > a',
773
- '#ai1ec_exclude_label',
774
- {
775
- action: 'ai1ec_get_repeat_box',
776
- repeat: 0,
777
- post_id: $( '#post_ID' ).val()
778
- },
779
- 'ai1ec_apply_js_on_repeat_block'
780
- );
781
-
782
- $( 'a.ai1ec_repeat_cancel' ).live( 'click', function() {
783
- if( $( '#ai1ec_is_box_repeat' ).val() == '1' ) {
784
- // handles click on cancel for RRULE
785
- ai1ec_click_on_modal_cancel( '#ai1ec_repeat_text > a', '#ai1ec_repeat', '#ai1ec_repeat_label' );
786
- } else {
787
- // handles click on cancel for EXRULE
788
- ai1ec_click_on_modal_cancel( '#ai1ec_exclude_text > a', '#ai1ec_exclude', '#ai1ec_exclude_label' );
789
- }
790
- $.unblockUI();
791
- return false;
792
- });
793
-
794
- $( '#ai1ec_monthly_type_bymonthday, #ai1ec_monthly_type_byday' ).live( 'change', function() {
795
- $( '#ai1c_repeat_monthly_bymonthday' ).toggle();
796
- $( '#ai1c_repeat_monthly_byday' ).toggle();
797
- })
798
- }
799
-
800
- /**
801
- * ICS feeds
802
- */
803
-
804
- if( $( '#ai1ec_add_new_ics' ).length )
805
- {
806
- /**
807
- * Click event handler for + Add new subscription button
808
- * checks to see if the feed url is valid url
809
- * and makes an ajax call with the feed details
810
- */
811
- $( '#ai1ec_add_new_ics' ).click( function() {
812
- var $button = $( this );
813
- var $url = $( '#ai1ec_feed_url' );
814
- var url = $url.val().replace( 'webcal://', 'http://' );
815
- var invalid = false;
816
- var error_message;
817
-
818
- // restore feed url border colors if it has been changed
819
- $('.ai1ec-feed-url, #ai1ec_feed_url').css( 'border-color', '#DFDFDF' );
820
- $('#ai1ec-feed-error').remove();
821
-
822
- // Check for duplicates
823
- $('.ai1ec-feed-url').each( function() {
824
- if( this.value == url ) {
825
- // This feed's already been added
826
- $(this).css( 'border-color', '#FF0000' );
827
- invalid = true;
828
- error_message = ai1ec_add_new_event.duplicate_feed_message;
829
- }
830
- } );
831
- // Check for valid URL
832
- if( ! isUrl( url ) ) {
833
- invalid = true;
834
- error_message = ai1ec_add_new_event.invalid_url_message;
835
- }
836
-
837
- if( invalid ) {
838
- // color the feed url input field in red and output error message
839
- $url
840
- .css( 'border-color', '#FF0000' )
841
- .focus()
842
- .before( '<div class="error" id="ai1ec-feed-error"><p>' + error_message + '</p></div>' );
843
- } else {
844
- // disable the add button for now
845
- $button.attr( 'disabled', true );
846
- // create the data to send
847
- var data = {
848
- action: 'ai1ec_add_ics',
849
- feed_url: url,
850
- feed_category: $( '#ai1ec_feed_category option:selected' ).val(),
851
- feed_tags: $( '#ai1ec_feed_tags' ).val()
852
- };
853
- // make an ajax call to save the new feed
854
- $.post(
855
- ajaxurl,
856
- data,
857
- function( response ) {
858
- // restore add button
859
- $button.removeAttr( 'disabled' );
860
- if( response.error ) {
861
- // tell the user there is an error
862
- // TODO: Use other method of notification
863
- alert( response.message );
864
- } else {
865
- $url.val( '' );
866
- // Add the feed to the settings screen
867
- $( '#ai1ec-feeds-after' ).after( response.message );
868
- }
869
- },
870
- 'json'
871
- );
872
- }
873
-
874
- });
875
-
876
- /**
877
- * Click event handler for X Delete button
878
- * that deletes the feed by sending the feed_id via ajax
879
- */
880
- $( '.ai1ec_delete_ics' ).live( 'click', function() {
881
- // store clicked button for later use
882
- var $button = $( this );
883
- // disable the delete button
884
- $button.attr( 'disabled', true );
885
- // table row to delete
886
- var $feed_row = $button.closest( '.ai1ec-feed-container' );
887
- // get the selected feed id
888
- var ics_id = $button.siblings( '.ai1ec_feed_id' ).val();
889
- // create the data to send
890
- var data = {
891
- action: 'ai1ec_delete_ics',
892
- ics_id: ics_id
893
- };
894
- // remove the feed from the database
895
- $.post( ajaxurl, data,
896
- function( response ) {
897
- // restore the delete button
898
- $button.removeAttr( 'disabled' );
899
- if( response.error ) {
900
- // tell the user there is an error
901
- alert( response.message );
902
- } else {
903
- // remove the feed from the settings screen
904
- $feed_row.remove();
905
- }
906
- },
907
- 'json'
908
- );
909
- });
910
-
911
- /**
912
- * Click event handler for Flush events button
913
- * that deletes all event posts that came from that feed by sending the feed_id via ajax
914
- */
915
- $( '.ai1ec_flush_ics' ).live( 'click', function() {
916
- // store clicked button for later use
917
- var $button = $( this );
918
- // disable the flush button
919
- $button.attr( 'disabled', true );
920
- // get the selected feed id
921
- var ics_id = $button.siblings( '.ai1ec_feed_id' ).val();
922
- $button.siblings( '.ajax-loading' ).css( 'visibility', 'visible' );
923
- // create the data to send
924
- var data = {
925
- action: 'ai1ec_flush_ics',
926
- ics_id: ics_id
927
- };
928
- // remove the feed from the database
929
- $.post( ajaxurl, data,
930
- function( response ) {
931
- if( response.error ) {
932
- // tell the user there is an error
933
- alert( response.message );
934
- } else {
935
- $button.fadeOut();
936
- }
937
- $button.siblings( '.ajax-loading' ).css( 'visibility', 'hidden' );
938
- },
939
- 'json'
940
- );
941
- });
942
-
943
- /**
944
- * Click event handler for Update events button
945
- * that imports events from that feed by sending the feed_id via ajax
946
- */
947
- $( '.ai1ec_update_ics' ).live( 'click', function() {
948
- // store clicked button for later use
949
- var $button = $( this );
950
- // disable the update button
951
- $button.attr( 'disabled', true );
952
- // get the selected feed id
953
- var ics_id = $button.siblings( '.ai1ec_feed_id' ).val();
954
- $button.siblings( '.ajax-loading' ).css( 'visibility', 'visible' );
955
- // create the data to send
956
- var data = {
957
- action: 'ai1ec_update_ics',
958
- ics_id: ics_id
959
- };
960
- // remove the feed from the database
961
- $.post( ajaxurl, data,
962
- function( response ) {
963
- if( response.error ) {
964
- // tell the user there is an error
965
- alert( response.message );
966
- } else {
967
- $button.siblings( '.ai1ec_flush_ics' ).remove();
968
- // If events were imported, create new flush button
969
- if( response.count )
970
- $button.after(
971
- '<input type="button" class="button ai1ec_flush_ics" value="' +
972
- response.flush_label + '" />' );
973
- }
974
- $button
975
- .attr( 'disabled', false )
976
- .siblings( '.ajax-loading' ).css( 'visibility', 'hidden' );
977
- },
978
- 'json'
979
- );
980
- });
981
- }
982
- });
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/view/admin/js/bootstrap-modal.js DELETED
@@ -1,218 +0,0 @@
1
- /* =========================================================
2
- * bootstrap-modal.js v2.0.3
3
- * http://twitter.github.com/bootstrap/javascript.html#modals
4
- * =========================================================
5
- * Copyright 2012 Twitter, Inc.
6
- *
7
- * Licensed under the Apache License, Version 2.0 (the "License");
8
- * you may not use this file except in compliance with the License.
9
- * You may obtain a copy of the License at
10
- *
11
- * http://www.apache.org/licenses/LICENSE-2.0
12
- *
13
- * Unless required by applicable law or agreed to in writing, software
14
- * distributed under the License is distributed on an "AS IS" BASIS,
15
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16
- * See the License for the specific language governing permissions and
17
- * limitations under the License.
18
- * ========================================================= */
19
-
20
-
21
- !function ($) {
22
-
23
- "use strict"; // jshint ;_;
24
-
25
-
26
- /* MODAL CLASS DEFINITION
27
- * ====================== */
28
-
29
- var Modal = function (content, options) {
30
- this.options = options
31
- this.$element = $(content)
32
- .delegate('[data-dismiss="modal"]', 'click.dismiss.modal', $.proxy(this.hide, this))
33
- }
34
-
35
- Modal.prototype = {
36
-
37
- constructor: Modal
38
-
39
- , toggle: function () {
40
- return this[!this.isShown ? 'show' : 'hide']()
41
- }
42
-
43
- , show: function () {
44
- var that = this
45
- , e = $.Event('show')
46
-
47
- this.$element.trigger(e)
48
-
49
- if (this.isShown || e.isDefaultPrevented()) return
50
-
51
- $('body').addClass('modal-open')
52
-
53
- this.isShown = true
54
-
55
- escape.call(this)
56
- backdrop.call(this, function () {
57
- var transition = $.support.transition && that.$element.hasClass('fade')
58
-
59
- if (!that.$element.parent().length) {
60
- that.$element.appendTo(document.body) //don't move modals dom position
61
- }
62
-
63
- that.$element
64
- .show()
65
-
66
- if (transition) {
67
- that.$element[0].offsetWidth // force reflow
68
- }
69
-
70
- that.$element.addClass('in')
71
-
72
- transition ?
73
- that.$element.one($.support.transition.end, function () { that.$element.trigger('shown') }) :
74
- that.$element.trigger('shown')
75
-
76
- })
77
- }
78
-
79
- , hide: function (e) {
80
- e && e.preventDefault()
81
-
82
- var that = this
83
-
84
- e = $.Event('hide')
85
-
86
- this.$element.trigger(e)
87
-
88
- if (!this.isShown || e.isDefaultPrevented()) return
89
-
90
- this.isShown = false
91
-
92
- $('body').removeClass('modal-open')
93
-
94
- escape.call(this)
95
-
96
- this.$element.removeClass('in')
97
-
98
- $.support.transition && this.$element.hasClass('fade') ?
99
- hideWithTransition.call(this) :
100
- hideModal.call(this)
101
- }
102
-
103
- }
104
-
105
-
106
- /* MODAL PRIVATE METHODS
107
- * ===================== */
108
-
109
- function hideWithTransition() {
110
- var that = this
111
- , timeout = setTimeout(function () {
112
- that.$element.off($.support.transition.end)
113
- hideModal.call(that)
114
- }, 500)
115
-
116
- this.$element.one($.support.transition.end, function () {
117
- clearTimeout(timeout)
118
- hideModal.call(that)
119
- })
120
- }
121
-
122
- function hideModal(that) {
123
- this.$element
124
- .hide()
125
- .trigger('hidden')
126
-
127
- backdrop.call(this)
128
- }
129
-
130
- function backdrop(callback) {
131
- var that = this
132
- , animate = this.$element.hasClass('fade') ? 'fade' : ''
133
-
134
- if (this.isShown && this.options.backdrop) {
135
- var doAnimate = $.support.transition && animate
136
-
137
- this.$backdrop = $('<div class="modal-backdrop ' + animate + '" />')
138
- .appendTo(document.body)
139
-
140
- if (this.options.backdrop != 'static') {
141
- this.$backdrop.click($.proxy(this.hide, this))
142
- }
143
-
144
- if (doAnimate) this.$backdrop[0].offsetWidth // force reflow
145
-
146
- this.$backdrop.addClass('in')
147
-
148
- doAnimate ?
149
- this.$backdrop.one($.support.transition.end, callback) :
150
- callback()
151
-
152
- } else if (!this.isShown && this.$backdrop) {
153
- this.$backdrop.removeClass('in')
154
-
155
- $.support.transition && this.$element.hasClass('fade')?
156
- this.$backdrop.one($.support.transition.end, $.proxy(removeBackdrop, this)) :
157
- removeBackdrop.call(this)
158
-
159
- } else if (callback) {
160
- callback()
161
- }
162
- }
163
-
164
- function removeBackdrop() {
165
- this.$backdrop.remove()
166
- this.$backdrop = null
167
- }
168
-
169
- function escape() {
170
- var that = this
171
- if (this.isShown && this.options.keyboard) {
172
- $(document).on('keyup.dismiss.modal', function ( e ) {
173
- e.which == 27 && that.hide()
174
- })
175
- } else if (!this.isShown) {
176
- $(document).off('keyup.dismiss.modal')
177
- }
178
- }
179
-
180
-
181
- /* MODAL PLUGIN DEFINITION
182
- * ======================= */
183
-
184
- $.fn.modal = function (option) {
185
- return this.each(function () {
186
- var $this = $(this)
187
- , data = $this.data('modal')
188
- , options = $.extend({}, $.fn.modal.defaults, $this.data(), typeof option == 'object' && option)
189
- if (!data) $this.data('modal', (data = new Modal(this, options)))
190
- if (typeof option == 'string') data[option]()
191
- else if (options.show) data.show()
192
- })
193
- }
194
-
195
- $.fn.modal.defaults = {
196
- backdrop: true
197
- , keyboard: true
198
- , show: true
199
- }
200
-
201
- $.fn.modal.Constructor = Modal
202
-
203
-
204
- /* MODAL DATA-API
205
- * ============== */
206
-
207
- $(function () {
208
- $('body').on('click.modal.data-api', '[data-toggle="modal"]', function ( e ) {
209
- var $this = $(this), href
210
- , $target = $($this.attr('data-target') || (href = $this.attr('href')) && href.replace(/.*(?=#[^\s]+$)/, '')) //strip for ie7
211
- , option = $target.data('modal') ? 'toggle' : $.extend({}, $target.data(), $this.data())
212
-
213
- e.preventDefault()
214
- $target.modal(option)
215
- })
216
- })
217
-
218
- }(window.jQuery);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/view/admin/js/bootstrap-popover.js DELETED
@@ -1,95 +0,0 @@
1
- /* ===========================================================
2
- * bootstrap-popover.js v2.0.2
3
- * http://twitter.github.com/bootstrap/javascript.html#popovers
4
- * ===========================================================
5
- * Copyright 2012 Twitter, Inc.
6
- *
7
- * Licensed under the Apache License, Version 2.0 (the "License");
8
- * you may not use this file except in compliance with the License.
9
- * You may obtain a copy of the License at
10
- *
11
- * http://www.apache.org/licenses/LICENSE-2.0
12
- *
13
- * Unless required by applicable law or agreed to in writing, software
14
- * distributed under the License is distributed on an "AS IS" BASIS,
15
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16
- * See the License for the specific language governing permissions and
17
- * limitations under the License.
18
- * =========================================================== */
19
-
20
-
21
- !function( $ ) {
22
-
23
- "use strict"
24
-
25
- var Popover = function ( element, options ) {
26
- this.init('popover', element, options)
27
- }
28
-
29
- /* NOTE: POPOVER EXTENDS BOOTSTRAP-TOOLTIP.js
30
- ========================================== */
31
-
32
- Popover.prototype = $.extend({}, $.fn.tooltip.Constructor.prototype, {
33
-
34
- constructor: Popover
35
-
36
- , setContent: function () {
37
- var $tip = this.tip()
38
- , title = this.getTitle()
39
- , content = this.getContent()
40
-
41
- $tip.find('.popover-title')[ $.type(title) == 'object' ? 'append' : 'html' ](title)
42
- $tip.find('.popover-content > *')[ $.type(content) == 'object' ? 'append' : 'html' ](content)
43
-
44
- $tip.removeClass('fade top bottom left right in')
45
- }
46
-
47
- , hasContent: function () {
48
- return this.getTitle() || this.getContent()
49
- }
50
-
51
- , getContent: function () {
52
- var content
53
- , $e = this.$element
54
- , o = this.options
55
-
56
- content = $e.attr('data-content')
57
- || (typeof o.content == 'function' ? o.content.call($e[0]) : o.content)
58
-
59
- content = content.toString().replace(/(^\s*|\s*$)/, "")
60
-
61
- return content
62
- }
63
-
64
- , tip: function() {
65
- if (!this.$tip) {
66
- this.$tip = $(this.options.template)
67
- }
68
- return this.$tip
69
- }
70
-
71
- })
72
-
73
-
74
- /* POPOVER PLUGIN DEFINITION
75
- * ======================= */
76
-
77
- $.fn.popover = function ( option ) {
78
- return this.each(function () {
79
- var $this = $(this)
80
- , data = $this.data('popover')
81
- , options = typeof option == 'object' && option
82
- if (!data) $this.data('popover', (data = new Popover(this, options)))
83
- if (typeof option == 'string') data[option]()
84
- })
85
- }
86
-
87
- $.fn.popover.Constructor = Popover
88
-
89
- $.fn.popover.defaults = $.extend({} , $.fn.tooltip.defaults, {
90
- placement: 'right'
91
- , content: ''
92
- , template: '<div class="popover"><div class="arrow"></div><div class="popover-inner"><h3 class="popover-title"></h3><div class="popover-content"><p></p></div></div></div>'
93
- })
94
-
95
- }( window.jQuery );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/view/admin/js/bootstrap-tooltip.js DELETED
@@ -1,270 +0,0 @@
1
- /* ===========================================================
2
- * bootstrap-tooltip.js v2.0.2
3
- * http://twitter.github.com/bootstrap/javascript.html#tooltips
4
- * Inspired by the original jQuery.tipsy by Jason Frame
5
- * ===========================================================
6
- * Copyright 2012 Twitter, Inc.
7
- *
8
- * Licensed under the Apache License, Version 2.0 (the "License");
9
- * you may not use this file except in compliance with the License.
10
- * You may obtain a copy of the License at
11
- *
12
- * http://www.apache.org/licenses/LICENSE-2.0
13
- *
14
- * Unless required by applicable law or agreed to in writing, software
15
- * distributed under the License is distributed on an "AS IS" BASIS,
16
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17
- * See the License for the specific language governing permissions and
18
- * limitations under the License.
19
- * ========================================================== */
20
-
21
- !function( $ ) {
22
-
23
- "use strict"
24
-
25
- /* TOOLTIP PUBLIC CLASS DEFINITION
26
- * =============================== */
27
-
28
- var Tooltip = function ( element, options ) {
29
- this.init('tooltip', element, options)
30
- }
31
-
32
- Tooltip.prototype = {
33
-
34
- constructor: Tooltip
35
-
36
- , init: function ( type, element, options ) {
37
- var eventIn
38
- , eventOut
39
-
40
- this.type = type
41
- this.$element = $(element)
42
- this.options = this.getOptions(options)
43
- this.enabled = true
44
-
45
- if (this.options.trigger != 'manual') {
46
- eventIn = this.options.trigger == 'hover' ? 'mouseenter' : 'focus'
47
- eventOut = this.options.trigger == 'hover' ? 'mouseleave' : 'blur'
48
- this.$element.on(eventIn, this.options.selector, $.proxy(this.enter, this))
49
- this.$element.on(eventOut, this.options.selector, $.proxy(this.leave, this))
50
- }
51
-
52
- this.options.selector ?
53
- (this._options = $.extend({}, this.options, { trigger: 'manual', selector: '' })) :
54
- this.fixTitle()
55
- }
56
-
57
- , getOptions: function ( options ) {
58
- options = $.extend({}, $.fn[this.type].defaults, options, this.$element.data())
59
-
60
- if (options.delay && typeof options.delay == 'number') {
61
- options.delay = {
62
- show: options.delay
63
- , hide: options.delay
64
- }
65
- }
66
-
67
- return options
68
- }
69
-
70
- , enter: function ( e ) {
71
- var self = $(e.currentTarget)[this.type](this._options).data(this.type)
72
-
73
- if (!self.options.delay || !self.options.delay.show) {
74
- self.show()
75
- } else {
76
- self.hoverState = 'in'
77
- setTimeout(function() {
78
- if (self.hoverState == 'in') {
79
- self.show()
80
- }
81
- }, self.options.delay.show)
82
- }
83
- }
84
-
85
- , leave: function ( e ) {
86
- var self = $(e.currentTarget)[this.type](this._options).data(this.type)
87
-
88
- if (!self.options.delay || !self.options.delay.hide) {
89
- self.hide()
90
- } else {
91
- self.hoverState = 'out'
92
- setTimeout(function() {
93
- if (self.hoverState == 'out') {
94
- self.hide()
95
- }
96
- }, self.options.delay.hide)
97
- }
98
- }
99
-
100
- , show: function () {
101
- var $tip
102
- , inside
103
- , pos
104
- , actualWidth
105
- , actualHeight
106
- , placement
107
- , tp
108
-
109
- if (this.hasContent() && this.enabled) {
110
- $tip = this.tip()
111
- this.setContent()
112
-
113
- if (this.options.animation) {
114
- $tip.addClass('fade')
115
- }
116
-
117
- placement = typeof this.options.placement == 'function' ?
118
- this.options.placement.call(this, $tip[0], this.$element[0]) :
119
- this.options.placement
120
-
121
- inside = /in/.test(placement)
122
-
123
- $tip
124
- .remove()
125
- .css({ top: 0, left: 0, display: 'block' })
126
- .appendTo(inside ? this.$element : document.body)
127
-
128
- pos = this.getPosition(inside)
129
-
130
- actualWidth = $tip[0].offsetWidth
131
- actualHeight = $tip[0].offsetHeight
132
-
133
- switch (inside ? placement.split(' ')[1] : placement) {
134
- case 'bottom':
135
- tp = {top: pos.top + pos.height, left: pos.left + pos.width / 2 - actualWidth / 2}
136
- break
137
- case 'top':
138
- tp = {top: pos.top - actualHeight, left: pos.left + pos.width / 2 - actualWidth / 2}
139
- break
140
- case 'left':
141
- tp = {top: pos.top + pos.height / 2 - actualHeight / 2, left: pos.left - actualWidth}
142
- break
143
- case 'right':
144
- tp = {top: pos.top + pos.height / 2 - actualHeight / 2, left: pos.left + pos.width}
145
- break
146
- }
147
-
148
- $tip
149
- .css(tp)
150
- .addClass(placement)
151
- .addClass('in')
152
- }
153
- }
154
-
155
- , setContent: function () {
156
- var $tip = this.tip()
157
- $tip.find('.tooltip-inner').html(this.getTitle())
158
- $tip.removeClass('fade in top bottom left right')
159
- }
160
-
161
- , hide: function () {
162
- var that = this
163
- , $tip = this.tip()
164
-
165
- $tip.removeClass('in')
166
-
167
- function removeWithAnimation() {
168
- var timeout = setTimeout(function () {
169
- $tip.off($.support.transition.end).remove()
170
- }, 500)
171
-
172
- $tip.one($.support.transition.end, function () {
173
- clearTimeout(timeout)
174
- $tip.remove()
175
- })
176
- }
177
-
178
- $.support.transition && this.$tip.hasClass('fade') ?
179
- removeWithAnimation() :
180
- $tip.remove()
181
- }
182
-
183
- , fixTitle: function () {
184
- var $e = this.$element
185
- if ($e.attr('title') || typeof($e.attr('data-original-title')) != 'string') {
186
- $e.attr('data-original-title', $e.attr('title') || '').removeAttr('title')
187
- }
188
- }
189
-
190
- , hasContent: function () {
191
- return this.getTitle()
192
- }
193
-
194
- , getPosition: function (inside) {
195
- return $.extend({}, (inside ? {top: 0, left: 0} : this.$element.offset()), {
196
- width: this.$element[0].offsetWidth
197
- , height: this.$element[0].offsetHeight
198
- })
199
- }
200
-
201
- , getTitle: function () {
202
- var title
203
- , $e = this.$element
204
- , o = this.options
205
-
206
- title = $e.attr('data-original-title')
207
- || (typeof o.title == 'function' ? o.title.call($e[0]) : o.title)
208
-
209
- title = (title || '').toString().replace(/(^\s*|\s*$)/, "")
210
-
211
- return title
212
- }
213
-
214
- , tip: function () {
215
- return this.$tip = this.$tip || $(this.options.template)
216
- }
217
-
218
- , validate: function () {
219
- if (!this.$element[0].parentNode) {
220
- this.hide()
221
- this.$element = null
222
- this.options = null
223
- }
224
- }
225
-
226
- , enable: function () {
227
- this.enabled = true
228
- }
229
-
230
- , disable: function () {
231
- this.enabled = false
232
- }
233
-
234
- , toggleEnabled: function () {
235
- this.enabled = !this.enabled
236
- }
237
-
238
- , toggle: function () {
239
- this[this.tip().hasClass('in') ? 'hide' : 'show']()
240
- }
241
-
242
- }
243
-
244
-
245
- /* TOOLTIP PLUGIN DEFINITION
246
- * ========================= */
247
-
248
- $.fn.tooltip = function ( option ) {
249
- return this.each(function () {
250
- var $this = $(this)
251
- , data = $this.data('tooltip')
252
- , options = typeof option == 'object' && option
253
- if (!data) $this.data('tooltip', (data = new Tooltip(this, options)))
254
- if (typeof option == 'string') data[option]()
255
- })
256
- }
257
-
258
- $.fn.tooltip.Constructor = Tooltip
259
-
260
- $.fn.tooltip.defaults = {
261
- animation: true
262
- , delay: 0
263
- , selector: false
264
- , placement: 'top'
265
- , trigger: 'hover'
266
- , title: ''
267
- , template: '<div class="tooltip"><div class="tooltip-arrow"></div><div class="tooltip-inner"></div></div>'
268
- }
269
-
270
- }( window.jQuery );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/view/admin/js/colorpicker.js DELETED
@@ -1,599 +0,0 @@
1
- /**
2
- *
3
- * Color picker
4
- * Author: Stefan Petre www.eyecon.ro
5
- *
6
- * Dual licensed under the MIT and GPL licenses
7
- *
8
- */
9
- (function ($) {
10
- var ColorPicker = function () {
11
- var
12
- ids = {},
13
- inAction,
14
- charMin = 65,
15
- visible,
16
- tpl = '<div class="colorpicker"><div class="colorpicker_color"><div><div></div></div></div><div class="colorpicker_hue"><div></div></div><div class="colorpicker_new_color"></div><div class="colorpicker_current_color"></div><div class="colorpicker_hex"><input type="text" maxlength="6" size="6" /></div><div class="colorpicker_rgb_r colorpicker_field"><input type="text" maxlength="3" size="3" /><span></span></div><div class="colorpicker_rgb_g colorpicker_field"><input type="text" maxlength="3" size="3" /><span></span></div><div class="colorpicker_rgb_b colorpicker_field"><input type="text" maxlength="3" size="3" /><span></span></div><div class="colorpicker_hsb_h colorpicker_field"><input type="text" maxlength="3" size="3" /><span></span></div><div class="colorpicker_hsb_s colorpicker_field"><input type="text" maxlength="3" size="3" /><span></span></div><div class="colorpicker_hsb_b colorpicker_field"><input type="text" maxlength="3" size="3" /><span></span></div><div class="colorpicker_submit"></div></div>',
17
- defaults = {
18
- eventName: 'click',
19
- onShow: function () {},
20
- onBeforeShow: function(){},
21
- onHide: function () {},
22
- onChange: function () {},
23
- onSubmit: function () {},
24
- color: 'ff0000',
25
- livePreview: true,
26
- flat: false
27
- },
28
- fillRGBFields = function (hsb, cal) {
29
- var rgb = HSBToRGB(hsb);
30
- $(cal).data('colorpicker').fields
31
- .eq(1).val(rgb.r).end()
32
- .eq(2).val(rgb.g).end()
33
- .eq(3).val(rgb.b).end();
34
- },
35
- fillHSBFields = function (hsb, cal) {
36
- $(cal).data('colorpicker').fields
37
- .eq(4).val(hsb.h).end()
38
- .eq(5).val(hsb.s).end()
39
- .eq(6).val(hsb.b).end();
40
- },
41
- fillHexFields = function (hsb, cal) {
42
- $(cal).data('colorpicker').fields
43
- .eq(0).val(HSBToHex(hsb)).end();
44
- },
45
- setSelector = function (hsb, cal) {
46
- $(cal).data('colorpicker').selector.css('backgroundColor', '#' + HSBToHex({h: hsb.h, s: 100, b: 100}));
47
- $(cal).data('colorpicker').selectorIndic.css({
48
- left: parseInt(150 * hsb.s/100, 10),
49
- top: parseInt(150 * (100-hsb.b)/100, 10)
50
- });
51
- },
52
- setHue = function (hsb, cal) {
53
- $(cal).data('colorpicker').hue.css('top', parseInt(150 - 150 * hsb.h/360, 10));
54
- },
55
- setCurrentColor = function (hsb, cal) {
56
- $(cal).data('colorpicker').currentColor.css('backgroundColor', '#' + HSBToHex(hsb));
57
- },
58
- setNewColor = function (hsb, cal) {
59
- $(cal).data('colorpicker').newColor.css('backgroundColor', '#' + HSBToHex(hsb));
60
- },
61
- keyDown = function (ev) {
62
- var pressedKey = ev.charCode || ev.keyCode || -1;
63
- if ((pressedKey > charMin && pressedKey <= 90) || pressedKey == 32) {
64
- return false;
65
- }
66
- var cal = $(this).parent().parent();
67
- if (cal.data('colorpicker').livePreview === true) {
68
- change.apply(this);
69
- }
70
- },
71
- change = function (ev) {
72
- var cal = $(this).parent().parent(), col;
73
- if (this.parentNode.className.indexOf('_hex') > 0) {
74
- cal.data('colorpicker').color = col = HexToHSB(fixHex(this.value));
75
- } else if (this.parentNode.className.indexOf('_hsb') > 0) {
76
- cal.data('colorpicker').color = col = fixHSB({
77
- h: parseInt(cal.data('colorpicker').fields.eq(4).val(), 10),
78
- s: parseInt(cal.data('colorpicker').fields.eq(5).val(), 10),
79
- b: parseInt(cal.data('colorpicker').fields.eq(6).val(), 10)
80
- });
81
- } else {
82
- cal.data('colorpicker').color = col = RGBToHSB(fixRGB({
83
- r: parseInt(cal.data('colorpicker').fields.eq(1).val(), 10),
84
- g: parseInt(cal.data('colorpicker').fields.eq(2).val(), 10),
85
- b: parseInt(cal.data('colorpicker').fields.eq(3).val(), 10)
86
- }));
87
- }
88
- if (ev) {
89
- fillRGBFields(col, cal.get(0));
90
- fillHexFields(col, cal.get(0));
91
- fillHSBFields(col, cal.get(0));
92
- }
93
- setSelector(col, cal.get(0));
94
- setHue(col, cal.get(0));
95
- setNewColor(col, cal.get(0));
96
- cal.data('colorpicker').onChange.apply(cal, [col, HSBToHex(col), HSBToRGB(col)]);
97
- },
98
- blur = function (ev) {
99
- var cal = $(this).parent().parent();
100
- cal.data('colorpicker').fields.parent().removeClass('colorpicker_focus');
101
- },
102
- focus = function () {
103
- charMin = this.parentNode.className.indexOf('_hex') > 0 ? 70 : 65;
104
- $(this).parent().parent().data('colorpicker').fields.parent().removeClass('colorpicker_focus');
105
- $(this).parent().addClass('colorpicker_focus');
106
- },
107
- downIncrement = function (ev) {
108
- var field = $(this).parent().find('input').focus();
109
- var current = {
110
- el: $(this).parent().addClass('colorpicker_slider'),
111
- max: this.parentNode.className.indexOf('_hsb_h') > 0 ? 360 : (this.parentNode.className.indexOf('_hsb') > 0 ? 100 : 255),
112
- y: ev.pageY,
113
- field: field,
114
- val: parseInt(field.val(), 10),
115
- preview: $(this).parent().parent().data('colorpicker').livePreview
116
- };
117
- $(document).bind('mouseup', current, upIncrement);
118
- $(document).bind('mousemove', current, moveIncrement);
119
- },
120
- moveIncrement = function (ev) {
121
- ev.data.field.val(Math.max(0, Math.min(ev.data.max, parseInt(ev.data.val + ev.pageY - ev.data.y, 10))));
122
- if (ev.data.preview) {
123
- change.apply(ev.data.field.get(0), [true]);
124
- }
125
- return false;
126
- },
127
- upIncrement = function (ev) {
128
- change.apply(ev.data.field.get(0), [true]);
129
- ev.data.el.removeClass('colorpicker_slider').find('input').focus();
130
- $(document).unbind('mouseup', upIncrement);
131
- $(document).unbind('mousemove', moveIncrement);
132
- return false;
133
- },
134
- downHue = function (ev) {
135
- var current = {
136
- cal: $(this).parent(),
137
- y: $(this).offset().top
138
- };
139
- current.preview = current.cal.data('colorpicker').livePreview;
140
- $(document).bind('mouseup', current, upHue);
141
- $(document).bind('mousemove', current, moveHue);
142
- },
143
- moveHue = function (ev) {
144
- change.apply(
145
- ev.data.cal.data('colorpicker')
146
- .fields
147
- .eq(4)
148
- .val(parseInt(360*(150 - Math.max(0,Math.min(150,(ev.pageY - ev.data.y))))/150, 10))
149
- .get(0),
150
- [ev.data.preview]
151
- );
152
- return false;
153
- },
154
- upHue = function (ev) {
155
- fillRGBFields(ev.data.cal.data('colorpicker').color, ev.data.cal.get(0));
156
- fillHexFields(ev.data.cal.data('colorpicker').color, ev.data.cal.get(0));
157
- $(document).unbind('mouseup', upHue);
158
- $(document).unbind('mousemove', moveHue);
159
- return false;
160
- },
161
- downSelector = function (ev) {
162
- var current = {
163
- cal: $(this).parent(),
164
- pos: $(this).offset()
165
- };
166
- current.preview = current.cal.data('colorpicker').livePreview;
167
- $(document).bind('mouseup', current, upSelector);
168
- $(document).bind('mousemove', current, moveSelector);
169
- },
170
- moveSelector = function (ev) {
171
- change.apply(
172
- ev.data.cal.data('colorpicker')
173
- .fields
174
- .eq(6)
175
- .val(parseInt(100*(150 - Math.max(0,Math.min(150,(ev.pageY - ev.data.pos.top))))/150, 10))
176
- .end()
177
- .eq(5)
178
- .val(parseInt(100*(Math.max(0,Math.min(150,(ev.pageX - ev.data.pos.left))))/150, 10))
179
- .get(0),
180
- [ev.data.preview]
181
- );
182
- return false;
183
- },
184
- upSelector = function (ev) {
185
- fillRGBFields(ev.data.cal.data('colorpicker').color, ev.data.cal.get(0));
186
- fillHexFields(ev.data.cal.data('colorpicker').color, ev.data.cal.get(0));
187
- $(document).unbind('mouseup', upSelector);
188
- $(document).unbind('mousemove', moveSelector);
189
- return false;
190
- },
191
- enterSubmit = function (ev) {
192
- $(this).addClass('colorpicker_focus');
193
- },
194
- leaveSubmit = function (ev) {
195
- $(this).removeClass('colorpicker_focus');
196
- },
197
- clickSubmit = function (ev) {
198
- var cal = $(this).parent();
199
- var col = cal.data('colorpicker').color;
200
- cal.data('colorpicker').origColor = col;
201
- setCurrentColor(col, cal.get(0));
202
- cal.data('colorpicker').onSubmit(col, HSBToHex(col), HSBToRGB(col), cal.data('colorpicker').el);
203
- },
204
- show = function (ev) {
205
- var cal = $('#' + $(this).data('colorpickerId'));
206
- cal.data('colorpicker').onBeforeShow.apply(this, [cal.get(0)]);
207
- var pos = $(this).offset();
208
- var viewPort = getViewport();
209
- var fs_offset = $( '#tag-color' ).offset();
210
- var top = (fs_offset.top) + $( '#tag-color' ).height() ;
211
- var left = (fs_offset.left + 1);
212
- cal.css({left: left + 'px', top: top + 'px'});
213
- if (cal.data('colorpicker').onShow.apply(this, [cal.get(0)]) != false) {
214
- cal.show();
215
- }
216
- $(document).bind('mousedown', {cal: cal}, hide);
217
- return false;
218
- },
219
- hide = function (ev) {
220
- if (!isChildOf(ev.data.cal.get(0), ev.target, ev.data.cal.get(0))) {
221
- if (ev.data.cal.data('colorpicker').onHide.apply(this, [ev.data.cal.get(0)]) != false) {
222
- ev.data.cal.hide();
223
- }
224
- $(document).unbind('mousedown', hide);
225
- }
226
- },
227
- isChildOf = function(parentEl, el, container) {
228
- if (parentEl == el) {
229
- return true;
230
- }
231
- if (parentEl.contains) {
232
- return parentEl.contains(el);
233
- }
234
- if ( parentEl.compareDocumentPosition ) {
235
- return !!(parentEl.compareDocumentPosition(el) & 16);
236
- }
237
- var prEl = el.parentNode;
238
- while(prEl && prEl != container) {
239
- if (prEl == parentEl)
240
- return true;
241
- prEl = prEl.parentNode;
242
- }
243
- return false;
244
- },
245
- getViewport = function () {
246
- var m = document.compatMode == 'CSS1Compat';
247
- return {
248
- l : window.pageXOffset || (m ? document.documentElement.scrollLeft : document.body.scrollLeft),
249
- t : window.pageYOffset || (m ? document.documentElement.scrollTop : document.body.scrollTop),
250
- w : window.innerWidth || (m ? document.documentElement.clientWidth : document.body.clientWidth),
251
- h : window.innerHeight || (m ? document.documentElement.clientHeight : document.body.clientHeight)
252
- };
253
- },
254
- fixHSB = function (hsb) {
255
- return {
256
- h: Math.min(360, Math.max(0, hsb.h)),
257
- s: Math.min(100, Math.max(0, hsb.s)),
258
- b: Math.min(100, Math.max(0, hsb.b))
259
- };
260
- },
261
- fixRGB = function (rgb) {
262
- return {
263
- r: Math.min(255, Math.max(0, rgb.r)),
264
- g: Math.min(255, Math.max(0, rgb.g)),
265
- b: Math.min(255, Math.max(0, rgb.b))
266
- };
267
- },
268
- fixHex = function (hex) {
269
- var len = 6 - hex.length;
270
- if (len > 0) {
271
- var o = [];
272
- for (var i=0; i<len; i++) {
273
- o.push('0');
274
- }
275
- o.push(hex);
276
- hex = o.join('');
277
- }
278
- return hex;
279
- },
280
- HexToRGB = function (hex) {
281
- var hex = parseInt(((hex.indexOf('#') > -1) ? hex.substring(1) : hex), 16);
282
- return {r: hex >> 16, g: (hex & 0x00FF00) >> 8, b: (hex & 0x0000FF)};
283
- },
284
- HexToHSB = function (hex) {
285
- return RGBToHSB(HexToRGB(hex));
286
- },
287
- RGBToHSB = function (rgb) {
288
- var hsb = {
289
- h: 0,
290
- s: 0,
291
- b: 0
292
- };
293
- var min = Math.min(rgb.r, rgb.g, rgb.b);
294
- var max = Math.max(rgb.r, rgb.g, rgb.b);
295
- var delta = max - min;
296
- hsb.b = max;
297
- if (max != 0) {
298
-
299
- }
300
- hsb.s = max != 0 ? 255 * delta / max : 0;
301
- if (hsb.s != 0) {
302
- if (rgb.r == max) {
303
- hsb.h = (rgb.g - rgb.b) / delta;
304
- } else if (rgb.g == max) {
305
- hsb.h = 2 + (rgb.b - rgb.r) / delta;
306
- } else {
307
- hsb.h = 4 + (rgb.r - rgb.g) / delta;
308
- }
309
- } else {
310
- hsb.h = -1;
311
- }
312
- hsb.h *= 60;
313
- if (hsb.h < 0) {
314
- hsb.h += 360;
315
- }
316
- hsb.s *= 100/255;
317
- hsb.b *= 100/255;
318
- return hsb;
319
- },
320
- HSBToRGB = function (hsb) {
321
- var rgb = {};
322
- var h = Math.round(hsb.h);
323
- var s = Math.round(hsb.s*255/100);
324
- var v = Math.round(hsb.b*255/100);
325
- if(s == 0) {
326
- rgb.r = rgb.g = rgb.b = v;
327
- } else {
328
- var t1 = v;
329
- var t2 = (255-s)*v/255;
330
- var t3 = (t1-t2)*(h%60)/60;
331
- if(h==360) h = 0;
332
- if(h<60) {rgb.r=t1; rgb.b=t2; rgb.g=t2+t3}
333
- else if(h<120) {rgb.g=t1; rgb.b=t2; rgb.r=t1-t3}
334
- else if(h<180) {rgb.g=t1; rgb.r=t2; rgb.b=t2+t3}
335
- else if(h<240) {rgb.b=t1; rgb.r=t2; rgb.g=t1-t3}
336
- else if(h<300) {rgb.b=t1; rgb.g=t2; rgb.r=t2+t3}
337
- else if(h<360) {rgb.r=t1; rgb.g=t2; rgb.b=t1-t3}
338
- else {rgb.r=0; rgb.g=0; rgb.b=0}
339
- }
340
- return {r:Math.round(rgb.r), g:Math.round(rgb.g), b:Math.round(rgb.b)};
341
- },
342
- RGBToHex = function (rgb) {
343
- var hex = [
344
- rgb.r.toString(16),
345
- rgb.g.toString(16),
346
- rgb.b.toString(16)
347
- ];
348
- $.each(hex, function (nr, val) {
349
- if (val.length == 1) {
350
- hex[nr] = '0' + val;
351
- }
352
- });
353
- return hex.join('');
354
- },
355
- HSBToHex = function (hsb) {
356
- return RGBToHex(HSBToRGB(hsb));
357
- },
358
- restoreOriginal = function () {
359
- var cal = $(this).parent();
360
- var col = cal.data('colorpicker').origColor;
361
- cal.data('colorpicker').color = col;
362
- fillRGBFields(col, cal.get(0));
363
- fillHexFields(col, cal.get(0));
364
- fillHSBFields(col, cal.get(0));
365
- setSelector(col, cal.get(0));
366
- setHue(col, cal.get(0));
367
- setNewColor(col, cal.get(0));
368
- };
369
- return {
370
- init: function (opt) {
371
- opt = $.extend({}, defaults, opt||{});
372
- if (typeof opt.color == 'string') {
373
- opt.color = HexToHSB(opt.color);
374
- } else if (opt.color.r != undefined && opt.color.g != undefined && opt.color.b != undefined) {
375
- opt.color = RGBToHSB(opt.color);
376
- } else if (opt.color.h != undefined && opt.color.s != undefined && opt.color.b != undefined) {
377
- opt.color = fixHSB(opt.color);
378
- } else {
379
- return this;
380
- }
381
- return this.each(function () {
382
- if (!$(this).data('colorpickerId')) {
383
- var options = $.extend({}, opt);
384
- options.origColor = opt.color;
385
- var id = 'collorpicker_' + parseInt(Math.random() * 1000);
386
- $(this).data('colorpickerId', id);
387
- var cal = $(tpl).attr('id', id);
388
- if (options.flat) {
389
- cal.appendTo(this).show();
390
- } else {
391
- cal.appendTo(document.body);
392
- }
393
- options.fields = cal
394
- .find('input')
395
- .bind('keyup', keyDown)
396
- .bind('change', change)
397
- .bind('blur', blur)
398
- .bind('focus', focus);
399
- cal
400
- .find('span').bind('mousedown', downIncrement).end()
401
- .find('>div.colorpicker_current_color').bind('click', restoreOriginal);
402
- options.selector = cal.find('div.colorpicker_color').bind('mousedown', downSelector);
403
- options.selectorIndic = options.selector.find('div div');
404
- options.el = this;
405
- options.hue = cal.find('div.colorpicker_hue div');
406
- cal.find('div.colorpicker_hue').bind('mousedown', downHue);
407
- options.newColor = cal.find('div.colorpicker_new_color');
408
- options.currentColor = cal.find('div.colorpicker_current_color');
409
- cal.data('colorpicker', options);
410
- cal.find('div.colorpicker_submit')
411
- .bind('mouseenter', enterSubmit)
412
- .bind('mouseleave', leaveSubmit)
413
- .bind('click', clickSubmit);
414
- fillRGBFields(options.color, cal.get(0));
415
- fillHSBFields(options.color, cal.get(0));
416
- fillHexFields(options.color, cal.get(0));
417
- setHue(options.color, cal.get(0));
418
- setSelector(options.color, cal.get(0));
419
- setCurrentColor(options.color, cal.get(0));
420
- setNewColor(options.color, cal.get(0));
421
- if (options.flat) {
422
- cal.css({
423
- position: 'relative',
424
- display: 'block'
425
- });
426
- } else {
427
- $(this).bind(options.eventName, show);
428
- }
429
- }
430
- });
431
- },
432
- showPicker: function() {
433
- return this.each( function () {
434
- if ($(this).data('colorpickerId')) {
435
- show.apply(this);
436
- }
437
- });
438
- },
439
- hidePicker: function() {
440
- return this.each( function () {
441
- if ($(this).data('colorpickerId')) {
442
- $('#' + $(this).data('colorpickerId')).hide();
443
- }
444
- });
445
- },
446
- setColor: function(col) {
447
- if (typeof col == 'string') {
448
- col = HexToHSB(col);
449
- } else if (col.r != undefined && col.g != undefined && col.b != undefined) {
450
- col = RGBToHSB(col);
451
- } else if (col.h != undefined && col.s != undefined && col.b != undefined) {
452
- col = fixHSB(col);
453
- } else {
454
- return this;
455
- }
456
- return this.each(function(){
457
- if ($(this).data('colorpickerId')) {
458
- var cal = $('#' + $(this).data('colorpickerId'));
459
- cal.data('colorpicker').color = col;
460
- cal.data('colorpicker').origColor = col;
461
- fillRGBFields(col, cal.get(0));
462
- fillHSBFields(col, cal.get(0));
463
- fillHexFields(col, cal.get(0));
464
- setHue(col, cal.get(0));
465
- setSelector(col, cal.get(0));
466
- setCurrentColor(col, cal.get(0));
467
- setNewColor(col, cal.get(0));
468
- }
469
- });
470
- }
471
- };
472
- }();
473
- $.fn.extend({
474
- ColorPicker: ColorPicker.init,
475
- ColorPickerHide: ColorPicker.hidePicker,
476
- ColorPickerShow: ColorPicker.showPicker,
477
- ColorPickerSetColor: ColorPicker.setColor
478
- });
479
- })(jQuery)
480
-
481
- jQuery( function( $ ) {
482
- $( '#tag-color' ).click( function() {
483
- var fs_offset = $( '#tag-color' ).offset();
484
- var top = fs_offset.top + $( '#tag-color' ).height() ;
485
- var left = fs_offset.left + 1;
486
- var ul_el = $( '<ul></ul>');
487
- var li_els = $(
488
- '<li style="color: #60a;" class="color-1"></li>' + // 1
489
- '<li style="color: #807;" class="color-2"></li>' + // 2
490
- '<li style="color: #920;" class="color-3"></li>' + // 3
491
- '<li style="color: #a60;" class="color-4"></li>' + // 4
492
- '<li style="color: #990;" class="color-5"></li>' + // 5
493
- '<li style="color: #080;" class="color-6"></li>' + // 6
494
- '<li style="color: #077;" class="color-7"></li>' + // 7
495
- '<li style="color: #00a;" class="color-8"></li>' + // 8
496
- '<li style="color: #000;" class="color-9"></li>' + // 9
497
- '<li style="color: #444;" class="color-10"></li>' + // 10
498
- '<li style="color: #85e;" class="color-11"></li>' + // 11
499
- '<li style="color: #d5d;" class="color-12"></li>' + // 12
500
- '<li style="color: #d43;" class="color-13"></li>' + // 13
501
- '<li style="color: #d90;" class="color-14"></li>' + // 14
502
- '<li style="color: #bb0;" class="color-15"></li>' + // 15
503
- '<li style="color: #2b0;" class="color-16"></li>' + // 16
504
- '<li style="color: #0ba;" class="color-17"></li>' + // 17
505
- '<li style="color: #26d;" class="color-18"></li>' + // 18
506
- '<li style="color: #777;" class="color-19"></li>' + // 19
507
- '<li style="color: #aaa;" class="color-20"></li>' + // 20
508
- '<li style="color: #aab;" class="color-21"></li>' // 21
509
- );
510
- var more_color = $( '<li class="select-more-colors">More colors</li>' );
511
- $( more_color ).ColorPicker({
512
- onSubmit: function( hsb, hex, rgb, el ) {
513
- $( '#tag-color-background' ).css( 'background-color', '#' + hex );
514
- $( '#tag-color-value' ).val( '#' + hex );
515
- $(el).ColorPickerHide();
516
- ul_el.remove();
517
- },
518
- onBeforeShow: function () {
519
- ul_el.hide();
520
- $( document ).unbind( 'mousedown', hide_color_selector );
521
- var color = $( '#tag-color-value' ).val();
522
- color = color.length > 0 ? color : '#ffffff';
523
- $( this ).ColorPickerSetColor( color );
524
- }
525
- });
526
- // Add click event for each font style
527
- li_els.click( function() {
528
- if( rgb2hex( $(this).css( 'color' ) ) != "#aaaabb" ){
529
- $( '#tag-color-background' ).css( 'background-color', $(this).css( 'color' ) );
530
- $( '#tag-color-value' ).val( rgb2hex( $(this).css( 'color' ) ) );
531
- ul_el.remove();
532
- }
533
- else{
534
- $( '#tag-color-background' ).css( 'background-color', "" );
535
- $( '#tag-color-value' ).val( "" );
536
- ul_el.remove();
537
- }
538
- });
539
-
540
- // append li elements to the ul holder
541
- ul_el.append( li_els ).append( more_color );
542
-
543
- // append ul holder to the body
544
- ul_el
545
- .appendTo( 'body' )
546
- .css( {
547
- position: 'absolute',
548
- top: top + 'px',
549
- left: left + 'px',
550
- width: '105px',
551
- height: '70px',
552
- 'z-index': 1,
553
- background: '#fff',
554
- border: '1px solid #ccc'
555
- })
556
- .addClass( 'colorpicker-list' );
557
- $( document ).bind( 'mousedown', {ls: ul_el}, hide_color_selector );
558
- });
559
-
560
- // remove category color click
561
- $( "#tag-color-value-remove" ).click(function(){
562
- $( "#tag-color-background" ).css( "background-color","" );
563
- $( "#tag-color-value" ).val("")
564
- });
565
-
566
- var rgb2hex = function( rgb ) {
567
- rgb = rgb.match( /^rgb\((\d+),\s*(\d+),\s*(\d+)\)$/ );
568
- return "#" + hex( rgb[1] ) + hex( rgb[2] ) + hex( rgb[3] );
569
- };
570
-
571
- var hex = function( x ) {
572
- return ( "0" + parseInt( x ).toString( 16 ) ).slice( -2 );
573
- };
574
-
575
- var hide_color_selector = function( ev ) {
576
- if( ! is_child_of( ev.data.ls.get( 0 ), ev.target, ev.data.ls.get( 0 ) ) ) {
577
- $( ev.data.ls.get(0) ).remove();
578
- $( document ).unbind( 'mousedown', hide_color_selector );
579
- }
580
- };
581
- var is_child_of = function( parentEl, el, container ) {
582
- if( parentEl == el )
583
- return true;
584
-
585
- if( parentEl.contains )
586
- return parentEl.contains( el );
587
-
588
- if( parentEl.compareDocumentPosition )
589
- return !!(parentEl.compareDocumentPosition(el) & 16);
590
-
591
- var prEl = el.parentNode;
592
- while( prEl && prEl != container ) {
593
- if( prEl == parentEl )
594
- return true;
595
- prEl = prEl.parentNode;
596
- }
597
- return false;
598
- };
599
- });
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/view/admin/js/datepicker.js DELETED
@@ -1,891 +0,0 @@
1
- /**
2
- *
3
- * Date picker
4
- * Author: Stefan Petre www.eyecon.ro
5
- *
6
- * Dual licensed under the MIT and GPL licenses
7
- *
8
- */
9
- (function ($) {
10
- var DatePicker = function () {
11
- var ids = {},
12
- views = {
13
- years: 'datepickerViewYears',
14
- moths: 'datepickerViewMonths',
15
- days: 'datepickerViewDays'
16
- },
17
- tpl = {
18
- wrapper: '<div class="datepicker"><div class="datepickerBorderT" /><div class="datepickerBorderB" /><div class="datepickerBorderL" /><div class="datepickerBorderR" /><div class="datepickerBorderTL" /><div class="datepickerBorderTR" /><div class="datepickerBorderBL" /><div class="datepickerBorderBR" /><div class="datepickerContainer"><table cellspacing="0" cellpadding="0"><tbody><tr></tr></tbody></table></div></div>',
19
- head: [
20
- '<td>',
21
- '<table cellspacing="0" cellpadding="0">',
22
- '<thead>',
23
- '<tr>',
24
- '<th class="datepickerGoPrev"><a href="#"><span><%=prev%></span></a></th>',
25
- '<th colspan="6" class="datepickerMonth"><a href="#"><span></span></a></th>',
26
- '<th class="datepickerGoNext"><a href="#"><span><%=next%></span></a></th>',
27
- '</tr>',
28
- '<tr class="datepickerDoW">',
29
- '<th><span><%=week%></span></th>',
30
- '<th><span><%=day1%></span></th>',
31
- '<th><span><%=day2%></span></th>',
32
- '<th><span><%=day3%></span></th>',
33
- '<th><span><%=day4%></span></th>',
34
- '<th><span><%=day5%></span></th>',
35
- '<th><span><%=day6%></span></th>',
36
- '<th><span><%=day7%></span></th>',
37
- '</tr>',
38
- '</thead>',
39
- '</table></td>'
40
- ],
41
- space : '<td class="datepickerSpace"><div></div></td>',
42
- days: [
43
- '<tbody class="datepickerDays">',
44
- '<tr>',
45
- '<th class="datepickerWeek"><a href="#"><span><%=weeks[0].week%></span></a></th>',
46
- '<td class="<%=weeks[0].days[0].classname%>"><a href="#"><span><%=weeks[0].days[0].text%></span></a></td>',
47
- '<td class="<%=weeks[0].days[1].classname%>"><a href="#"><span><%=weeks[0].days[1].text%></span></a></td>',
48
- '<td class="<%=weeks[0].days[2].classname%>"><a href="#"><span><%=weeks[0].days[2].text%></span></a></td>',
49
- '<td class="<%=weeks[0].days[3].classname%>"><a href="#"><span><%=weeks[0].days[3].text%></span></a></td>',
50
- '<td class="<%=weeks[0].days[4].classname%>"><a href="#"><span><%=weeks[0].days[4].text%></span></a></td>',
51
- '<td class="<%=weeks[0].days[5].classname%>"><a href="#"><span><%=weeks[0].days[5].text%></span></a></td>',
52
- '<td class="<%=weeks[0].days[6].classname%>"><a href="#"><span><%=weeks[0].days[6].text%></span></a></td>',
53
- '</tr>',
54
- '<tr>',
55
- '<th class="datepickerWeek"><a href="#"><span><%=weeks[1].week%></span></a></th>',
56
- '<td class="<%=weeks[1].days[0].classname%>"><a href="#"><span><%=weeks[1].days[0].text%></span></a></td>',
57
- '<td class="<%=weeks[1].days[1].classname%>"><a href="#"><span><%=weeks[1].days[1].text%></span></a></td>',
58
- '<td class="<%=weeks[1].days[2].classname%>"><a href="#"><span><%=weeks[1].days[2].text%></span></a></td>',
59
- '<td class="<%=weeks[1].days[3].classname%>"><a href="#"><span><%=weeks[1].days[3].text%></span></a></td>',
60
- '<td class="<%=weeks[1].days[4].classname%>"><a href="#"><span><%=weeks[1].days[4].text%></span></a></td>',
61
- '<td class="<%=weeks[1].days[5].classname%>"><a href="#"><span><%=weeks[1].days[5].text%></span></a></td>',
62
- '<td class="<%=weeks[1].days[6].classname%>"><a href="#"><span><%=weeks[1].days[6].text%></span></a></td>',
63
- '</tr>',
64
- '<tr>',
65
- '<th class="datepickerWeek"><a href="#"><span><%=weeks[2].week%></span></a></th>',
66
- '<td class="<%=weeks[2].days[0].classname%>"><a href="#"><span><%=weeks[2].days[0].text%></span></a></td>',
67
- '<td class="<%=weeks[2].days[1].classname%>"><a href="#"><span><%=weeks[2].days[1].text%></span></a></td>',
68
- '<td class="<%=weeks[2].days[2].classname%>"><a href="#"><span><%=weeks[2].days[2].text%></span></a></td>',
69
- '<td class="<%=weeks[2].days[3].classname%>"><a href="#"><span><%=weeks[2].days[3].text%></span></a></td>',
70
- '<td class="<%=weeks[2].days[4].classname%>"><a href="#"><span><%=weeks[2].days[4].text%></span></a></td>',
71
- '<td class="<%=weeks[2].days[5].classname%>"><a href="#"><span><%=weeks[2].days[5].text%></span></a></td>',
72
- '<td class="<%=weeks[2].days[6].classname%>"><a href="#"><span><%=weeks[2].days[6].text%></span></a></td>',
73
- '</tr>',
74
- '<tr>',
75
- '<th class="datepickerWeek"><a href="#"><span><%=weeks[3].week%></span></a></th>',
76
- '<td class="<%=weeks[3].days[0].classname%>"><a href="#"><span><%=weeks[3].days[0].text%></span></a></td>',
77
- '<td class="<%=weeks[3].days[1].classname%>"><a href="#"><span><%=weeks[3].days[1].text%></span></a></td>',
78
- '<td class="<%=weeks[3].days[2].classname%>"><a href="#"><span><%=weeks[3].days[2].text%></span></a></td>',
79
- '<td class="<%=weeks[3].days[3].classname%>"><a href="#"><span><%=weeks[3].days[3].text%></span></a></td>',
80
- '<td class="<%=weeks[3].days[4].classname%>"><a href="#"><span><%=weeks[3].days[4].text%></span></a></td>',
81
- '<td class="<%=weeks[3].days[5].classname%>"><a href="#"><span><%=weeks[3].days[5].text%></span></a></td>',
82
- '<td class="<%=weeks[3].days[6].classname%>"><a href="#"><span><%=weeks[3].days[6].text%></span></a></td>',
83
- '</tr>',
84
- '<tr>',
85
- '<th class="datepickerWeek"><a href="#"><span><%=weeks[4].week%></span></a></th>',
86
- '<td class="<%=weeks[4].days[0].classname%>"><a href="#"><span><%=weeks[4].days[0].text%></span></a></td>',
87
- '<td class="<%=weeks[4].days[1].classname%>"><a href="#"><span><%=weeks[4].days[1].text%></span></a></td>',
88
- '<td class="<%=weeks[4].days[2].classname%>"><a href="#"><span><%=weeks[4].days[2].text%></span></a></td>',
89
- '<td class="<%=weeks[4].days[3].classname%>"><a href="#"><span><%=weeks[4].days[3].text%></span></a></td>',
90
- '<td class="<%=weeks[4].days[4].classname%>"><a href="#"><span><%=weeks[4].days[4].text%></span></a></td>',
91
- '<td class="<%=weeks[4].days[5].classname%>"><a href="#"><span><%=weeks[4].days[5].text%></span></a></td>',
92
- '<td class="<%=weeks[4].days[6].classname%>"><a href="#"><span><%=weeks[4].days[6].text%></span></a></td>',
93
- '</tr>',
94
- '<tr>',
95
- '<th class="datepickerWeek"><a href="#"><span><%=weeks[5].week%></span></a></th>',
96
- '<td class="<%=weeks[5].days[0].classname%>"><a href="#"><span><%=weeks[5].days[0].text%></span></a></td>',
97
- '<td class="<%=weeks[5].days[1].classname%>"><a href="#"><span><%=weeks[5].days[1].text%></span></a></td>',
98
- '<td class="<%=weeks[5].days[2].classname%>"><a href="#"><span><%=weeks[5].days[2].text%></span></a></td>',
99
- '<td class="<%=weeks[5].days[3].classname%>"><a href="#"><span><%=weeks[5].days[3].text%></span></a></td>',
100
- '<td class="<%=weeks[5].days[4].classname%>"><a href="#"><span><%=weeks[5].days[4].text%></span></a></td>',
101
- '<td class="<%=weeks[5].days[5].classname%>"><a href="#"><span><%=weeks[5].days[5].text%></span></a></td>',
102
- '<td class="<%=weeks[5].days[6].classname%>"><a href="#"><span><%=weeks[5].days[6].text%></span></a></td>',
103
- '</tr>',
104
- '</tbody>'
105
- ],
106
- months: [
107
- '<tbody class="<%=className%>">',
108
- '<tr>',
109
- '<td colspan="2"><a href="#"><span><%=data[0]%></span></a></td>',
110
- '<td colspan="2"><a href="#"><span><%=data[1]%></span></a></td>',
111
- '<td colspan="2"><a href="#"><span><%=data[2]%></span></a></td>',
112
- '<td colspan="2"><a href="#"><span><%=data[3]%></span></a></td>',
113
- '</tr>',
114
- '<tr>',
115
- '<td colspan="2"><a href="#"><span><%=data[4]%></span></a></td>',
116
- '<td colspan="2"><a href="#"><span><%=data[5]%></span></a></td>',
117
- '<td colspan="2"><a href="#"><span><%=data[6]%></span></a></td>',
118
- '<td colspan="2"><a href="#"><span><%=data[7]%></span></a></td>',
119
- '</tr>',
120
- '<tr>',
121
- '<td colspan="2"><a href="#"><span><%=data[8]%></span></a></td>',
122
- '<td colspan="2"><a href="#"><span><%=data[9]%></span></a></td>',
123
- '<td colspan="2"><a href="#"><span><%=data[10]%></span></a></td>',
124
- '<td colspan="2"><a href="#"><span><%=data[11]%></span></a></td>',
125
- '</tr>',
126
- '</tbody>'
127
- ]
128
- },
129
- defaults = {
130
- flat: false,
131
- starts: 1,
132
- prev: '&#9664;',
133
- next: '&#9654;',
134
- lastSel: false,
135
- mode: 'single',
136
- view: 'days',
137
- calendars: 1,
138
- format: 'Y-m-d',
139
- position: 'bottom',
140
- eventName: 'click',
141
- onRender: function(){return {};},
142
- onChange: function(){return true;},
143
- onShow: function(){return true;},
144
- onBeforeShow: function(){return true;},
145
- onHide: function(){return true;},
146
- locale: {
147
- days: ["Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday", "Sunday"],
148
- daysShort: ["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat", "Sun"],
149
- daysMin: ["Su", "Mo", "Tu", "We", "Th", "Fr", "Sa", "Su"],
150
- months: ["January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"],
151
- monthsShort: ["Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"],
152
- weekMin: 'wk'
153
- }
154
- },
155
- fill = function(el) {
156
- var options = $(el).data('datepicker');
157
- var cal = $(el);
158
- var currentCal = Math.floor(options.calendars/2), date, data, dow, month, cnt = 0, week, days, indic, indic2, html, tblCal;
159
- cal.find('td>table tbody').remove();
160
- for (var i = 0; i < options.calendars; i++) {
161
- date = new Date(options.current);
162
- date.addMonths(-currentCal + i);
163
- tblCal = cal.find('table').eq(i+1);
164
- switch (tblCal[0].className) {
165
- case 'datepickerViewDays':
166
- dow = formatDate(date, 'B, Y');
167
- break;
168
- case 'datepickerViewMonths':
169
- dow = date.getFullYear();
170
- break;
171
- case 'datepickerViewYears':
172
- dow = (date.getFullYear()-6) + ' - ' + (date.getFullYear()+5);
173
- break;
174
- }
175
- tblCal.find('thead tr:first th:eq(1) span').text(dow);
176
- dow = date.getFullYear()-6;
177
- data = {
178
- data: [],
179
- className: 'datepickerYears'
180
- }
181
- for ( var j = 0; j < 12; j++) {
182
- data.data.push(dow + j);
183
- }
184
- html = tmpl(tpl.months.join(''), data);
185
- date.setDate(1);
186
- data = {weeks:[], test: 10};
187
- month = date.getMonth();
188
- var dow = (date.getDay() - options.starts) % 7;
189
- date.addDays(-(dow + (dow < 0 ? 7 : 0)));
190
- week = -1;
191
- cnt = 0;
192
- while (cnt < 42) {
193
- indic = parseInt(cnt/7,10);
194
- indic2 = cnt%7;
195
- if (!data.weeks[indic]) {
196
- week = date.getWeekNumber();
197
- data.weeks[indic] = {
198
- week: week,
199
- days: []
200
- };
201
- }
202
- data.weeks[indic].days[indic2] = {
203
- text: date.getDate(),
204
- classname: []
205
- };
206
- if (month != date.getMonth()) {
207
- data.weeks[indic].days[indic2].classname.push('datepickerNotInMonth');
208
- }
209
- if (date.getDay() == 0) {
210
- data.weeks[indic].days[indic2].classname.push('datepickerSunday');
211
- }
212
- if (date.getDay() == 6) {
213
- data.weeks[indic].days[indic2].classname.push('datepickerSaturday');
214
- }
215
- var fromUser = options.onRender(date);
216
- var val = date.valueOf();
217
- if (fromUser.selected || options.date == val || $.inArray(val, options.date) > -1 || (options.mode == 'range' && val >= options.date[0] && val <= options.date[1])) {
218
- data.weeks[indic].days[indic2].classname.push('datepickerSelected');
219
- }
220
- if (fromUser.disabled) {
221
- data.weeks[indic].days[indic2].classname.push('datepickerDisabled');
222
- }
223
- if (fromUser.className) {
224
- data.weeks[indic].days[indic2].classname.push(fromUser.className);
225
- }
226
- data.weeks[indic].days[indic2].classname = data.weeks[indic].days[indic2].classname.join(' ');
227
- cnt++;
228
- date.addDays(1);
229
- }
230
- html = tmpl(tpl.days.join(''), data) + html;
231
- data = {
232
- data: options.locale.monthsShort,
233
- className: 'datepickerMonths'
234
- };
235
- html = tmpl(tpl.months.join(''), data) + html;
236
- tblCal.append(html);
237
- }
238
- },
239
- parseDate = function (date, format) {
240
- if (date.constructor == Date) {
241
- return new Date(date);
242
- }
243
- var parts = date.split(/\W+/);
244
- var against = format.split(/\W+/), d, m, y, h, min, now = new Date();
245
- for (var i = 0; i < parts.length; i++) {
246
- switch (against[i]) {
247
- case 'd':
248
- case 'e':
249
- d = parseInt(parts[i],10);
250
- break;
251
- case 'm':
252
- m = parseInt(parts[i], 10)-1;
253
- break;
254
- case 'Y':
255
- case 'y':
256
- y = parseInt(parts[i], 10);
257
- y += y > 100 ? 0 : (y < 29 ? 2000 : 1900);
258
- break;
259
- case 'H':
260
- case 'I':
261
- case 'k':
262
- case 'l':
263
- h = parseInt(parts[i], 10);
264
- break;
265
- case 'P':
266
- case 'p':
267
- if (/pm/i.test(parts[i]) && h < 12) {
268
- h += 12;
269
- } else if (/am/i.test(parts[i]) && h >= 12) {
270
- h -= 12;
271
- }
272
- break;
273
- case 'M':
274
- min = parseInt(parts[i], 10);
275
- break;
276
- }
277
- }
278
- return new Date(
279
- y === undefined ? now.getFullYear() : y,
280
- m === undefined ? now.getMonth() : m,
281
- d === undefined ? now.getDate() : d,
282
- h === undefined ? now.getHours() : h,
283
- min === undefined ? now.getMinutes() : min,
284
- 0
285
- );
286
- },
287
- formatDate = function(date, format) {
288
- var m = date.getMonth();
289
- var d = date.getDate();
290
- var y = date.getFullYear();
291
- var wn = date.getWeekNumber();
292
- var w = date.getDay();
293
- var s = {};
294
- var hr = date.getHours();
295
- var pm = (hr >= 12);
296
- var ir = (pm) ? (hr - 12) : hr;
297
- var dy = date.getDayOfYear();
298
- if (ir == 0) {
299
- ir = 12;
300
- }
301
- var min = date.getMinutes();
302
- var sec = date.getSeconds();
303
- var parts = format.split(''), part;
304
- for ( var i = 0; i < parts.length; i++ ) {
305
- part = parts[i];
306
- switch (parts[i]) {
307
- case 'a':
308
- part = date.getDayName();
309
- break;
310
- case 'A':
311
- part = date.getDayName(true);
312
- break;
313
- case 'b':
314
- part = date.getMonthName();
315
- break;
316
- case 'B':
317
- part = date.getMonthName(true);
318
- break;
319
- case 'C':
320
- part = 1 + Math.floor(y / 100);
321
- break;
322
- case 'd':
323
- part = (d < 10) ? ("0" + d) : d;
324
- break;
325
- case 'e':
326
- part = d;
327
- break;
328
- case 'H':
329
- part = (hr < 10) ? ("0" + hr) : hr;
330
- break;
331
- case 'I':
332
- part = (ir < 10) ? ("0" + ir) : ir;
333
- break;
334
- case 'j':
335
- part = (dy < 100) ? ((dy < 10) ? ("00" + dy) : ("0" + dy)) : dy;
336
- break;
337
- case 'k':
338
- part = hr;
339
- break;
340
- case 'l':
341
- part = ir;
342
- break;
343
- case 'm':
344
- part = (m < 9) ? ("0" + (1+m)) : (1+m);
345
- break;
346
- case 'M':
347
- part = (min < 10) ? ("0" + min) : min;
348
- break;
349
- case 'p':
350
- case 'P':
351
- part = pm ? "PM" : "AM";
352
- break;
353
- case 's':
354
- part = Math.floor(date.getTime() / 1000);
355
- break;
356
- case 'S':
357
- part = (sec < 10) ? ("0" + sec) : sec;
358
- break;
359
- case 'u':
360
- part = w + 1;
361
- break;
362
- case 'w':
363
- part = w;
364
- break;
365
- case 'y':
366
- part = ('' + y).substr(2, 2);
367
- break;
368
- case 'Y':
369
- part = y;
370
- break;
371
- }
372
- parts[i] = part;
373
- }
374
- return parts.join('');
375
- },
376
- extendDate = function(options) {
377
- if (Date.prototype.tempDate) {
378
- return;
379
- }
380
- Date.prototype.tempDate = null;
381
- Date.prototype.months = options.months;
382
- Date.prototype.monthsShort = options.monthsShort;
383
- Date.prototype.days = options.days;
384
- Date.prototype.daysShort = options.daysShort;
385
- Date.prototype.getMonthName = function(fullName) {
386
- return this[fullName ? 'months' : 'monthsShort'][this.getMonth()];
387
- };
388
- Date.prototype.getDayName = function(fullName) {
389
- return this[fullName ? 'days' : 'daysShort'][this.getDay()];
390
- };
391
- Date.prototype.addDays = function (n) {
392
- this.setDate(this.getDate() + n);
393
- this.tempDate = this.getDate();
394
- };
395
- Date.prototype.addMonths = function (n) {
396
- if (this.tempDate == null) {
397
- this.tempDate = this.getDate();
398
- }
399
- this.setDate(1);
400
- this.setMonth(this.getMonth() + n);
401
- this.setDate(Math.min(this.tempDate, this.getMaxDays()));
402
- };
403
- Date.prototype.addYears = function (n) {
404
- if (this.tempDate == null) {
405
- this.tempDate = this.getDate();
406
- }
407
- this.setDate(1);
408
- this.setFullYear(this.getFullYear() + n);
409
- this.setDate(Math.min(this.tempDate, this.getMaxDays()));
410
- };
411
- Date.prototype.getMaxDays = function() {
412
- var tmpDate = new Date(Date.parse(this)),
413
- d = 28, m;
414
- m = tmpDate.getMonth();
415
- d = 28;
416
- while (tmpDate.getMonth() == m) {
417
- d ++;
418
- tmpDate.setDate(d);
419
- }
420
- return d - 1;
421
- };
422
- Date.prototype.getFirstDay = function() {
423
- var tmpDate = new Date(Date.parse(this));
424
- tmpDate.setDate(1);
425
- return tmpDate.getDay();
426
- };
427
- Date.prototype.getWeekNumber = function() {
428
- var tempDate = new Date(this);
429
- tempDate.setDate(tempDate.getDate() - (tempDate.getDay() + 6) % 7 + 3);
430
- var dms = tempDate.valueOf();
431
- tempDate.setMonth(0);
432
- tempDate.setDate(4);
433
- return Math.round((dms - tempDate.valueOf()) / (604800000)) + 1;
434
- };
435
- Date.prototype.getDayOfYear = function() {
436
- var now = new Date(this.getFullYear(), this.getMonth(), this.getDate(), 0, 0, 0);
437
- var then = new Date(this.getFullYear(), 0, 0, 0, 0, 0);
438
- var time = now - then;
439
- return Math.floor(time / 24*60*60*1000);
440
- };
441
- },
442
- layout = function (el) {
443
- var options = $(el).data('datepicker');
444
- var cal = $('#' + options.id);
445
- if (!options.extraHeight) {
446
- var divs = $(el).find('div');
447
- options.extraHeight = divs.get(0).offsetHeight + divs.get(1).offsetHeight;
448
- options.extraWidth = divs.get(2).offsetWidth + divs.get(3).offsetWidth;
449
- }
450
- var tbl = cal.find('table:first').get(0);
451
- var width = tbl.offsetWidth;
452
- var height = tbl.offsetHeight;
453
- cal.css({
454
- width: width + options.extraWidth + 'px',
455
- height: height + options.extraHeight + 'px'
456
- }).find('div.datepickerContainer').css({
457
- width: width + 'px',
458
- height: height + 'px'
459
- });
460
- },
461
- click = function(ev) {
462
- if ($(ev.target).is('span')) {
463
- ev.target = ev.target.parentNode;
464
- }
465
- var el = $(ev.target);
466
- if (el.is('a')) {
467
- ev.target.blur();
468
- if (el.hasClass('datepickerDisabled')) {
469
- return false;
470
- }
471
- var options = $(this).data('datepicker');
472
- var parentEl = el.parent();
473
- var tblEl = parentEl.parent().parent().parent();
474
- var tblIndex = $('table', this).index(tblEl.get(0)) - 1;
475
- var tmp = new Date(options.current);
476
- var changed = false;
477
- var fillIt = false;
478
- if (parentEl.is('th')) {
479
- if (parentEl.hasClass('datepickerWeek') && options.mode == 'range' && !parentEl.next().hasClass('datepickerDisabled')) {
480
- var val = parseInt(parentEl.next().text(), 10);
481
- tmp.addMonths(tblIndex - Math.floor(options.calendars/2));
482
- if (parentEl.next().hasClass('datepickerNotInMonth')) {
483
- tmp.addMonths(val > 15 ? -1 : 1);
484
- }
485
- tmp.setDate(val);
486
- options.date[0] = (tmp.setHours(0,0,0,0)).valueOf();
487
- tmp.setHours(23,59,59,0);
488
- tmp.addDays(6);
489
- options.date[1] = tmp.valueOf();
490
- fillIt = true;
491
- changed = true;
492
- options.lastSel = false;
493
- } else if (parentEl.hasClass('datepickerMonth')) {
494
- tmp.addMonths(tblIndex - Math.floor(options.calendars/2));
495
- switch (tblEl.get(0).className) {
496
- case 'datepickerViewDays':
497
- tblEl.get(0).className = 'datepickerViewMonths';
498
- el.find('span').text(tmp.getFullYear());
499
- break;
500
- case 'datepickerViewMonths':
501
- tblEl.get(0).className = 'datepickerViewYears';
502
- el.find('span').text((tmp.getFullYear()-6) + ' - ' + (tmp.getFullYear()+5));
503
- break;
504
- case 'datepickerViewYears':
505
- tblEl.get(0).className = 'datepickerViewDays';
506
- el.find('span').text(formatDate(tmp, 'B, Y'));
507
- break;
508
- }
509
- } else if (parentEl.parent().parent().is('thead')) {
510
- switch (tblEl.get(0).className) {
511
- case 'datepickerViewDays':
512
- options.current.addMonths(parentEl.hasClass('datepickerGoPrev') ? -1 : 1);
513
- break;
514
- case 'datepickerViewMonths':
515
- options.current.addYears(parentEl.hasClass('datepickerGoPrev') ? -1 : 1);
516
- break;
517
- case 'datepickerViewYears':
518
- options.current.addYears(parentEl.hasClass('datepickerGoPrev') ? -12 : 12);
519
- break;
520
- }
521
- fillIt = true;
522
- }
523
- } else if (parentEl.is('td') && !parentEl.hasClass('datepickerDisabled')) {
524
- switch (tblEl.get(0).className) {
525
- case 'datepickerViewMonths':
526
- options.current.setMonth(tblEl.find('tbody.datepickerMonths td').index(parentEl));
527
- options.current.setFullYear(parseInt(tblEl.find('thead th.datepickerMonth span').text(), 10));
528
- options.current.addMonths(Math.floor(options.calendars/2) - tblIndex);
529
- tblEl.get(0).className = 'datepickerViewDays';
530
- break;
531
- case 'datepickerViewYears':
532
- options.current.setFullYear(parseInt(el.text(), 10));
533
- tblEl.get(0).className = 'datepickerViewMonths';
534
- break;
535
- default:
536
- var val = parseInt(el.text(), 10);
537
- tmp.addMonths(tblIndex - Math.floor(options.calendars/2));
538
- if (parentEl.hasClass('datepickerNotInMonth')) {
539
- tmp.addMonths(val > 15 ? -1 : 1);
540
- }
541
- tmp.setDate(val);
542
- switch (options.mode) {
543
- case 'multiple':
544
- val = (tmp.setHours(0,0,0,0)).valueOf();
545
- if ($.inArray(val, options.date) > -1) {
546
- $.each(options.date, function(nr, dat){
547
- if (dat == val) {
548
- options.date.splice(nr,1);
549
- return false;
550
- }
551
- });
552
- } else {
553
- options.date.push(val);
554
- }
555
- break;
556
- case 'range':
557
- if (!options.lastSel) {
558
- options.date[0] = (tmp.setHours(0,0,0,0)).valueOf();
559
- }
560
- val = (tmp.setHours(23,59,59,0)).valueOf();
561
- if (val < options.date[0]) {
562
- options.date[1] = options.date[0] + 86399000;
563
- options.date[0] = val - 86399000;
564
- } else {
565
- options.date[1] = val;
566
- }
567
- options.lastSel = !options.lastSel;
568
- break;
569
- default:
570
- options.date = tmp.valueOf();
571
- break;
572
- }
573
- break;
574
- }
575
- fillIt = true;
576
- changed = true;
577
- }
578
- if (fillIt) {
579
- fill(this);
580
- }
581
- if (changed) {
582
- options.onChange.apply(this, prepareDate(options));
583
- }
584
- }
585
- return false;
586
- },
587
- prepareDate = function (options) {
588
- var tmp;
589
- if (options.mode == 'single') {
590
- tmp = new Date(options.date);
591
- return [formatDate(tmp, options.format), tmp, options.el];
592
- } else {
593
- tmp = [[],[], options.el];
594
- $.each(options.date, function(nr, val){
595
- var date = new Date(val);
596
- tmp[0].push(formatDate(date, options.format));
597
- tmp[1].push(date);
598
- });
599
- return tmp;
600
- }
601
- },
602
- getViewport = function () {
603
- var m = document.compatMode == 'CSS1Compat';
604
- return {
605
- l : window.pageXOffset || (m ? document.documentElement.scrollLeft : document.body.scrollLeft),
606
- t : window.pageYOffset || (m ? document.documentElement.scrollTop : document.body.scrollTop),
607
- w : window.innerWidth || (m ? document.documentElement.clientWidth : document.body.clientWidth),
608
- h : window.innerHeight || (m ? document.documentElement.clientHeight : document.body.clientHeight)
609
- };
610
- },
611
- isChildOf = function(parentEl, el, container) {
612
- if (parentEl == el) {
613
- return true;
614
- }
615
- if (parentEl.contains) {
616
- return parentEl.contains(el);
617
- }
618
- if ( parentEl.compareDocumentPosition ) {
619
- return !!(parentEl.compareDocumentPosition(el) & 16);
620
- }
621
- var prEl = el.parentNode;
622
- while(prEl && prEl != container) {
623
- if (prEl == parentEl)
624
- return true;
625
- prEl = prEl.parentNode;
626
- }
627
- return false;
628
- },
629
- show = function (ev) {
630
- var cal = $('#' + $(this).data('datepickerId'));
631
- if (!cal.is(':visible')) {
632
- var calEl = cal.get(0);
633
- fill(calEl);
634
- var options = cal.data('datepicker');
635
- options.onBeforeShow.apply(this, [cal.get(0)]);
636
- var pos = $(this).offset();
637
- var viewPort = getViewport();
638
- var top = pos.top;
639
- var left = pos.left;
640
- var oldDisplay = $.curCSS(calEl, 'display');
641
- cal.css({
642
- visibility: 'hidden',
643
- display: 'block'
644
- });
645
- layout(calEl);
646
- switch (options.position){
647
- case 'top':
648
- top -= calEl.offsetHeight;
649
- break;
650
- case 'left':
651
- left -= calEl.offsetWidth;
652
- break;
653
- case 'right':
654
- left += this.offsetWidth;
655
- break;
656
- case 'bottom':
657
- top += this.offsetHeight;
658
- break;
659
- }
660
- if (top + calEl.offsetHeight > viewPort.t + viewPort.h) {
661
- top = pos.top - calEl.offsetHeight;
662
- }
663
- if (top < viewPort.t) {
664
- top = pos.top + this.offsetHeight + calEl.offsetHeight;
665
- }
666
- if (left + calEl.offsetWidth > viewPort.l + viewPort.w) {
667
- left = pos.left - calEl.offsetWidth;
668
- }
669
- if (left < viewPort.l) {
670
- left = pos.left + this.offsetWidth
671
- }
672
- cal.css({
673
- visibility: 'visible',
674
- display: 'block',
675
- top: top + 'px',
676
- left: left + 'px'
677
- });
678
- if (options.onShow.apply(this, [cal.get(0)]) != false) {
679
- cal.show();
680
- }
681
- $(document).bind('mousedown', {cal: cal, trigger: this}, hide);
682
- }
683
- return false;
684
- },
685
- hide = function (ev) {
686
- if (ev.target != ev.data.trigger && !isChildOf(ev.data.cal.get(0), ev.target, ev.data.cal.get(0))) {
687
- if (ev.data.cal.data('datepicker').onHide.apply(this, [ev.data.cal.get(0)]) != false) {
688
- ev.data.cal.hide();
689
- }
690
- $(document).unbind('mousedown', hide);
691
- }
692
- };
693
- return {
694
- init: function(options){
695
- options = $.extend({}, defaults, options||{});
696
- extendDate(options.locale);
697
- options.calendars = Math.max(1, parseInt(options.calendars,10)||1);
698
- options.mode = /single|multiple|range/.test(options.mode) ? options.mode : 'single';
699
- return this.each(function(){
700
- if (!$(this).data('datepicker')) {
701
- options.el = this;
702
- if (options.date.constructor == String) {
703
- options.date = parseDate(options.date, options.format);
704
- options.date.setHours(0,0,0,0);
705
- }
706
- if (options.mode != 'single') {
707
- if (options.date.constructor != Array) {
708
- options.date = [options.date.valueOf()];
709
- if (options.mode == 'range') {
710
- options.date.push(((new Date(options.date[0])).setHours(23,59,59,0)).valueOf());
711
- }
712
- } else {
713
- for (var i = 0; i < options.date.length; i++) {
714
- options.date[i] = (parseDate(options.date[i], options.format).setHours(0,0,0,0)).valueOf();
715
- }
716
- if (options.mode == 'range') {
717
- options.date[1] = ((new Date(options.date[1])).setHours(23,59,59,0)).valueOf();
718
- }
719
- }
720
- } else {
721
- options.date = options.date.valueOf();
722
- }
723
- if (!options.current) {
724
- options.current = new Date();
725
- } else {
726
- options.current = parseDate(options.current, options.format);
727
- }
728
- options.current.setDate(1);
729
- options.current.setHours(0,0,0,0);
730
- var id = 'datepicker_' + parseInt(Math.random() * 1000), cnt;
731
- options.id = id;
732
- $(this).data('datepickerId', options.id);
733
- var cal = $(tpl.wrapper).attr('id', id).bind('click', click).data('datepicker', options);
734
- if (options.className) {
735
- cal.addClass(options.className);
736
- }
737
- var html = '';
738
- for (var i = 0; i < options.calendars; i++) {
739
- cnt = options.starts;
740
- if (i > 0) {
741
- html += tpl.space;
742
- }
743
- html += tmpl(tpl.head.join(''), {
744
- week: options.locale.weekMin,
745
- prev: options.prev,
746
- next: options.next,
747
- day1: options.locale.daysMin[(cnt++)%7],
748
- day2: options.locale.daysMin[(cnt++)%7],
749
- day3: options.locale.daysMin[(cnt++)%7],
750
- day4: options.locale.daysMin[(cnt++)%7],
751
- day5: options.locale.daysMin[(cnt++)%7],
752
- day6: options.locale.daysMin[(cnt++)%7],
753
- day7: options.locale.daysMin[(cnt++)%7]
754
- });
755
- }
756
- cal
757
- .find('tr:first').append(html)
758
- .find('table').addClass(views[options.view]);
759
- fill(cal.get(0));
760
- if (options.flat) {
761
- cal.appendTo(this).show().css('position', 'relative');
762
- layout(cal.get(0));
763
- } else {
764
- cal.appendTo(document.body);
765
- $(this).bind(options.eventName, show);
766
- }
767
- }
768
- });
769
- },
770
- showPicker: function() {
771
- return this.each( function () {
772
- if ($(this).data('datepickerId')) {
773
- show.apply(this);
774
- }
775
- });
776
- },
777
- hidePicker: function() {
778
- return this.each( function () {
779
- if ($(this).data('datepickerId')) {
780
- $('#' + $(this).data('datepickerId')).hide();
781
- }
782
- });
783
- },
784
- setDate: function(date, shiftTo){
785
- return this.each(function(){
786
- if ($(this).data('datepickerId')) {
787
- var cal = $('#' + $(this).data('datepickerId'));
788
- var options = cal.data('datepicker');
789
- options.date = date;
790
- if (options.date.constructor == String) {
791
- options.date = parseDate(options.date, options.format);
792
- options.date.setHours(0,0,0,0);
793
- }
794
- if (options.mode != 'single') {
795
- if (options.date.constructor != Array) {
796
- options.date = [options.date.valueOf()];
797
- if (options.mode == 'range') {
798
- options.date.push(((new Date(options.date[0])).setHours(23,59,59,0)).valueOf());
799
- }
800
- } else {
801
- for (var i = 0; i < options.date.length; i++) {
802
- options.date[i] = (parseDate(options.date[i], options.format).setHours(0,0,0,0)).valueOf();
803
- }
804
- if (options.mode == 'range') {
805
- options.date[1] = ((new Date(options.date[1])).setHours(23,59,59,0)).valueOf();
806
- }
807
- }
808
- } else {
809
- options.date = options.date.valueOf();
810
- }
811
- if (shiftTo) {
812
- options.current = new Date (options.mode != 'single' ? options.date[0] : options.date);
813
- }
814
- fill(cal.get(0));
815
- }
816
- });
817
- },
818
- getDate: function(formated) {
819
- if (this.size() > 0) {
820
- return prepareDate($('#' + $(this).data('datepickerId')).data('datepicker'))[formated ? 0 : 1];
821
- }
822
- },
823
- clear: function(){
824
- return this.each(function(){
825
- if ($(this).data('datepickerId')) {
826
- var cal = $('#' + $(this).data('datepickerId'));
827
- var options = cal.data('datepicker');
828
- if (options.mode != 'single') {
829
- options.date = [];
830
- fill(cal.get(0));
831
- }
832
- }
833
- });
834
- },
835
- fixLayout: function(){
836
- return this.each(function(){
837
- if ($(this).data('datepickerId')) {
838
- var cal = $('#' + $(this).data('datepickerId'));
839
- var options = cal.data('datepicker');
840
- if (options.flat) {
841
- layout(cal.get(0));
842
- }
843
- }
844
- });
845
- }
846
- };
847
- }();
848
- $.fn.extend({
849
- DatePicker: DatePicker.init,
850
- DatePickerHide: DatePicker.hidePicker,
851
- DatePickerShow: DatePicker.showPicker,
852
- DatePickerSetDate: DatePicker.setDate,
853
- DatePickerGetDate: DatePicker.getDate,
854
- DatePickerClear: DatePicker.clear,
855
- DatePickerLayout: DatePicker.fixLayout
856
- });
857
- })(jQuery);
858
-
859
- (function(){
860
- var cache = {};
861
-
862
- this.tmpl = function tmpl(str, data){
863
- // Figure out if we're getting a template, or if we need to
864
- // load the template - and be sure to cache the result.
865
- var fn = !/\W/.test(str) ?
866
- cache[str] = cache[str] ||
867
- tmpl(document.getElementById(str).innerHTML) :
868
-
869
- // Generate a reusable function that will serve as a template
870
- // generator (and which will be cached).
871
- new Function("obj",
872
- "var p=[],print=function(){p.push.apply(p,arguments);};" +
873
-
874
- // Introduce the data as local variables using with(){}
875
- "with(obj){p.push('" +
876
-
877
- // Convert the template into pure JavaScript
878
- str
879
- .replace(/[\r\t\n]/g, " ")
880
- .split("<%").join("\t")
881
- .replace(/((^|%>)[^\t]*)'/g, "$1\r")
882
- .replace(/\t=(.*?)%>/g, "',$1,'")
883
- .split("\t").join("');")
884
- .split("%>").join("p.push('")
885
- .split("\r").join("\\'")
886
- + "');}return p.join('');");
887
-
888
- // Provide some basic currying to the user
889
- return data ? fn( data ) : fn;
890
- };
891
- })();
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/view/admin/js/element-selector.js DELETED
@@ -1,51 +0,0 @@
1
- /**
2
- * This function will assign a click event on the passed jQuery selector.
3
- * On each click, the function will toggle the CSS class selected_class. Then
4
- * the function will go over each element contained by the DOM selector and look
5
- * for an <input> field with name=hidden_data_el in each element that has the
6
- * selected_class. Of these matching <input>s, their values will be joined by
7
- * "," and the joined value stored in hidden_input (another hidden input field).
8
- *
9
- * If when this function is called, the hidden_input's value is not empty, this
10
- * function will attempt to preselect any elements matching that value.
11
- *
12
- * @param string selector Container that has the <input name=hidden_data_el /> to toggle class
13
- * @param string selected_class Selected element class
14
- * @param string hidden_data_el Name of input element storing selected element's value
15
- * @param string hidden_input jQuery selector for input that stores all selected values
16
- */
17
- function element_selector( selector, selected_class, hidden_data_el, hidden_input )
18
- {
19
- var $ = jQuery;
20
-
21
- // Register click event
22
- $( selector ).click( function() {
23
- var data = new Array();
24
- if( $( this ).hasClass( selected_class ) ) {
25
- // Element deselected, remove class
26
- $( this ).removeClass( selected_class );
27
- } else {
28
- // Element selected, add class
29
- $( this ).addClass( selected_class );
30
- }
31
- $( selector + '.' + selected_class ).each( function() {
32
- var item_val = $( this ).find( 'input[name="' + hidden_data_el + '"]:first' ).val();
33
- data.push( item_val );
34
- } );
35
- $( hidden_input ).val( data.join() );
36
- } );
37
-
38
- // Check if hidden input has a preinitialized value
39
- var initial_val = $( hidden_input ).val();
40
- if( initial_val != undefined && initial_val != '' ) {
41
- var data = initial_val.split( ',' );
42
- // Turn each element of data into a jQuery selector
43
- $( data ).each( function( i, val ) {
44
- data[i] = 'input[name="' + hidden_data_el + '"][value="' + val + '"]';
45
- } );
46
- // Concatenate data into one long jQuery selector
47
- data = data.join();
48
- // Assign the selected_class to all matching elements
49
- $( selector ).has( data ).addClass( selected_class );
50
- }
51
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/view/admin/js/geo_autocomplete.js DELETED
@@ -1,68 +0,0 @@
1
- /*
2
- * jQuery geo_autocomplete plugin 1.0
3
- *
4
- * Copyright (c) 2009 Bob Hitching
5
- *
6
- * Dual licensed under the MIT and GPL licenses:
7
- * http://www.opensource.org/licenses/mit-license.php
8
- * http://www.gnu.org/licenses/gpl.html
9
- *
10
- * Requires jQuery Autocomplete plugin by J�rn Zaefferer - see http://bassistance.de/jquery-plugins/jquery-plugin-autocomplete/
11
- * jquery.autocomplete.js requires a minor modification for geo_autocomplete to work, as shown in /lib/jquery.autocomplete_geomod.js
12
- *
13
- */
14
- ;(function($) {
15
-
16
- $.fn.extend({
17
- geo_autocomplete: function(_geocoder, _options) {
18
- options = $.extend({}, $.Autocompleter.defaults, {
19
- geocoder: _geocoder,
20
- mapwidth: 100,
21
- mapheight: 100,
22
- maptype: 'terrain',
23
- mapkey: 'ABQIAAAAbnvDoAoYOSW2iqoXiGTpYBT2yXp_ZAY8_ufC3CFXhHIE1NvwkxQNumU68AwGqjbSNF9YO8NokKst8w', // localhost
24
- mapsensor: false,
25
- parse: function(_results, _status, _query) {
26
- var _parsed = [];
27
- if (_results && _status && _status == 'OK') {
28
- $.each(_results, function(_key, _result) {
29
- if (_result.geometry && _result.geometry.viewport) {
30
- // place is first matching segment, or first segment
31
- var _place_parts = _result.formatted_address.split(',');
32
- var _place = _place_parts[0];
33
- $.each(_place_parts, function(_key, _part) {
34
- if (_part.toLowerCase().indexOf(_query.toLowerCase()) != -1) {
35
- _place = $.trim(_part);
36
- return false; // break
37
- }
38
- });
39
- _parsed.push({
40
- data: _result,
41
- value: _place,
42
- result: _place
43
- });
44
- }
45
- });
46
- }
47
- return _parsed;
48
- },
49
- formatItem: function(_data, _i, _n, _value) {
50
- var _src = 'http://maps.google.com/maps/api/staticmap?visible=' + _data.geometry.viewport.getSouthWest().toUrlValue() + '|' + _data.geometry.viewport.getNorthEast().toUrlValue() + '&size=' + options.mapwidth + 'x' + options.mapheight + '&maptype=' + options.maptype + '&key=' + options.mapkey + '&sensor=' + (options.mapsensor ? 'true' : 'false');
51
- var _place = _data.formatted_address.replace(/,/gi, ',<br/>');
52
- return '<img src="' + _src + '" width="' + options.mapwidth + '" height="' + options.mapheight + '" /> ' + _place + '<br clear="both"/>';
53
- }
54
- }, _options);
55
-
56
- // if highlight is set to false, replace it with a do-nothing function
57
- options.highlight = options.highlight || function(value) { return value; };
58
-
59
- // if the formatMatch option is not specified, then use formatItem for backwards compatibility
60
- options.formatMatch = options.formatMatch || options.formatItem;
61
-
62
- return this.each(function() {
63
- new $.Autocompleter(this, options);
64
- });
65
- }
66
- });
67
-
68
- })(jQuery);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/view/admin/js/jquery.autocomplete_geomod.js DELETED
@@ -1,825 +0,0 @@
1
- /*
2
- * jQuery Autocomplete plugin 1.1
3
- *
4
- * Copyright (c) 2009 Jörn Zaefferer
5
- *
6
- * Dual licensed under the MIT and GPL licenses:
7
- * http://www.opensource.org/licenses/mit-license.php
8
- * http://www.gnu.org/licenses/gpl.html
9
- *
10
- * Revision: $Id: jquery.autocomplete.js 15 2009-08-22 10:30:27Z joern.zaefferer $
11
- */
12
-
13
- ;(function($) {
14
-
15
- $.fn.extend({
16
- autocomplete: function(urlOrData, options) {
17
- var isUrl = typeof urlOrData == "string";
18
- options = $.extend({}, $.Autocompleter.defaults, {
19
- url: isUrl ? urlOrData : null,
20
- data: isUrl ? null : urlOrData,
21
- delay: isUrl ? $.Autocompleter.defaults.delay : 10,
22
- max: options && !options.scroll ? 10 : 150
23
- }, options);
24
-
25
- // if highlight is set to false, replace it with a do-nothing function
26
- options.highlight = options.highlight || function(value) { return value; };
27
-
28
- // if the formatMatch option is not specified, then use formatItem for backwards compatibility
29
- options.formatMatch = options.formatMatch || options.formatItem;
30
-
31
- return this.each(function() {
32
- new $.Autocompleter(this, options);
33
- });
34
- },
35
- result: function(handler) {
36
- return this.bind("result", handler);
37
- },
38
- search: function(handler) {
39
- return this.trigger("search", [handler]);
40
- },
41
- flushCache: function() {
42
- return this.trigger("flushCache");
43
- },
44
- setOptions: function(options){
45
- return this.trigger("setOptions", [options]);
46
- },
47
- unautocomplete: function() {
48
- return this.trigger("unautocomplete");
49
- }
50
- });
51
-
52
- $.Autocompleter = function(input, options) {
53
-
54
- var KEY = {
55
- UP: 38,
56
- DOWN: 40,
57
- DEL: 46,
58
- TAB: 9,
59
- RETURN: 13,
60
- ESC: 27,
61
- COMMA: 188,
62
- PAGEUP: 33,
63
- PAGEDOWN: 34,
64
- BACKSPACE: 8
65
- };
66
-
67
- // Create $ object for input element
68
- var $input = $(input).attr("autocomplete", "off").addClass(options.inputClass);
69
-
70
- var timeout;
71
- var previousValue = "";
72
- var cache = $.Autocompleter.Cache(options);
73
- var hasFocus = 0;
74
- var lastKeyPressCode;
75
- var config = {
76
- mouseDownOnSelect: false
77
- };
78
- var select = $.Autocompleter.Select(options, input, selectCurrent, config);
79
-
80
- var blockSubmit;
81
-
82
- // prevent form submit in opera when selecting with return key
83
- $.browser.opera && $(input.form).bind("submit.autocomplete", function() {
84
- if (blockSubmit) {
85
- blockSubmit = false;
86
- return false;
87
- }
88
- });
89
-
90
- // only opera doesn't trigger keydown multiple times while pressed, others don't work with keypress at all
91
- $input.bind(($.browser.opera ? "keypress" : "keydown") + ".autocomplete", function(event) {
92
- // a keypress means the input has focus
93
- // avoids issue where input had focus before the autocomplete was applied
94
- hasFocus = 1;
95
- // track last key pressed
96
- lastKeyPressCode = event.keyCode;
97
- switch(event.keyCode) {
98
-
99
- case KEY.UP:
100
- event.preventDefault();
101
- if ( select.visible() ) {
102
- select.prev();
103
- } else {
104
- onChange(0, true);
105
- }
106
- break;
107
-
108
- case KEY.DOWN:
109
- event.preventDefault();
110
- if ( select.visible() ) {
111
- select.next();
112
- } else {
113
- onChange(0, true);
114
- }
115
- break;
116
-
117
- case KEY.PAGEUP:
118
- event.preventDefault();
119
- if ( select.visible() ) {
120
- select.pageUp();
121
- } else {
122
- onChange(0, true);
123
- }
124
- break;
125
-
126
- case KEY.PAGEDOWN:
127
- event.preventDefault();
128
- if ( select.visible() ) {
129
- select.pageDown();
130
- } else {
131
- onChange(0, true);
132
- }
133
- break;
134
-
135
- // matches also semicolon
136
- case options.multiple && $.trim(options.multipleSeparator) == "," && KEY.COMMA:
137
- case KEY.TAB:
138
- case KEY.RETURN:
139
- if( selectCurrent() ) {
140
- // stop default to prevent a form submit, Opera needs special handling
141
- event.preventDefault();
142
- blockSubmit = true;
143
- return false;
144
- }
145
- break;
146
-
147
- case KEY.ESC:
148
- select.hide();
149
- break;
150
-
151
- default:
152
- clearTimeout(timeout);
153
- timeout = setTimeout(onChange, options.delay);
154
- break;
155
- }
156
- }).focus(function(){
157
- // track whether the field has focus, we shouldn't process any
158
- // results if the field no longer has focus
159
- hasFocus++;
160
- }).blur(function() {
161
- hasFocus = 0;
162
- if (!config.mouseDownOnSelect) {
163
- hideResults();
164
- }
165
- }).click(function() {
166
- // show select when clicking in a focused field
167
- if ( hasFocus++ > 1 && !select.visible() ) {
168
- onChange(0, true);
169
- }
170
- }).bind("search", function() {
171
- // TODO why not just specifying both arguments?
172
- var fn = (arguments.length > 1) ? arguments[1] : null;
173
- function findValueCallback(q, data) {
174
- var result;
175
- if( data && data.length ) {
176
- for (var i=0; i < data.length; i++) {
177
- if( data[i].result.toLowerCase() == q.toLowerCase() ) {
178
- result = data[i];
179
- break;
180
- }
181
- }
182
- }
183
- if( typeof fn == "function" ) fn(result);
184
- else $input.trigger("result", result && [result.data, result.value]);
185
- }
186
- $.each(trimWords($input.val()), function(i, value) {
187
- request(value, findValueCallback, findValueCallback);
188
- });
189
- }).bind("flushCache", function() {
190
- cache.flush();
191
- }).bind("setOptions", function() {
192
- $.extend(options, arguments[1]);
193
- // if we've updated the data, repopulate
194
- if ( "data" in arguments[1] )
195
- cache.populate();
196
- }).bind("unautocomplete", function() {
197
- select.unbind();
198
- $input.unbind();
199
- $(input.form).unbind(".autocomplete");
200
- });
201
-
202
-
203
- function selectCurrent() {
204
- var selected = select.selected();
205
- if( !selected )
206
- return false;
207
-
208
- var v = selected.result;
209
- previousValue = v;
210
-
211
- if ( options.multiple ) {
212
- var words = trimWords($input.val());
213
- if ( words.length > 1 ) {
214
- var seperator = options.multipleSeparator.length;
215
- var cursorAt = $(input).selection().start;
216
- var wordAt, progress = 0;
217
- $.each(words, function(i, word) {
218
- progress += word.length;
219
- if (cursorAt <= progress) {
220
- wordAt = i;
221
- return false;
222
- }
223
- progress += seperator;
224
- });
225
- words[wordAt] = v;
226
- // TODO this should set the cursor to the right position, but it gets overriden somewhere
227
- //$.Autocompleter.Selection(input, progress + seperator, progress + seperator);
228
- v = words.join( options.multipleSeparator );
229
- }
230
- v += options.multipleSeparator;
231
- }
232
-
233
- $input.val(v);
234
- hideResultsNow();
235
- $input.trigger("result", [selected.data, selected.value]);
236
- return true;
237
- }
238
-
239
- function onChange(crap, skipPrevCheck) {
240
- if( lastKeyPressCode == KEY.DEL ) {
241
- select.hide();
242
- return;
243
- }
244
-
245
- var currentValue = $input.val();
246
-
247
- if ( !skipPrevCheck && currentValue == previousValue )
248
- return;
249
-
250
- previousValue = currentValue;
251
-
252
- currentValue = lastWord(currentValue);
253
- if ( currentValue.length >= options.minChars) {
254
- $input.addClass(options.loadingClass);
255
- if (!options.matchCase)
256
- currentValue = currentValue.toLowerCase();
257
- request(currentValue, receiveData, hideResultsNow);
258
- } else {
259
- stopLoading();
260
- select.hide();
261
- }
262
- };
263
-
264
- function trimWords(value) {
265
- if (!value)
266
- return [""];
267
- if (!options.multiple)
268
- return [$.trim(value)];
269
- return $.map(value.split(options.multipleSeparator), function(word) {
270
- return $.trim(value).length ? $.trim(word) : null;
271
- });
272
- }
273
-
274
- function lastWord(value) {
275
- if ( !options.multiple )
276
- return value;
277
- var words = trimWords(value);
278
- if (words.length == 1)
279
- return words[0];
280
- var cursorAt = $(input).selection().start;
281
- if (cursorAt == value.length) {
282
- words = trimWords(value)
283
- } else {
284
- words = trimWords(value.replace(value.substring(cursorAt), ""));
285
- }
286
- return words[words.length - 1];
287
- }
288
-
289
- // fills in the input box w/the first match (assumed to be the best match)
290
- // q: the term entered
291
- // sValue: the first matching result
292
- function autoFill(q, sValue){
293
- // autofill in the complete box w/the first match as long as the user hasn't entered in more data
294
- // if the last user key pressed was backspace, don't autofill
295
- if( options.autoFill && (lastWord($input.val()).toLowerCase() == q.toLowerCase()) && lastKeyPressCode != KEY.BACKSPACE ) {
296
- // fill in the value (keep the case the user has typed)
297
- $input.val($input.val() + sValue.substring(lastWord(previousValue).length));
298
- // select the portion of the value not typed by the user (so the next character will erase)
299
- $(input).selection(previousValue.length, previousValue.length + sValue.length);
300
- }
301
- };
302
-
303
- function hideResults() {
304
- clearTimeout(timeout);
305
- timeout = setTimeout(hideResultsNow, 200);
306
- };
307
-
308
- function hideResultsNow() {
309
- var wasVisible = select.visible();
310
- select.hide();
311
- clearTimeout(timeout);
312
- stopLoading();
313
- if (options.mustMatch) {
314
- // call search and run callback
315
- $input.search(
316
- function (result){
317
- // if no value found, clear the input box
318
- if( !result ) {
319
- if (options.multiple) {
320
- var words = trimWords($input.val()).slice(0, -1);
321
- $input.val( words.join(options.multipleSeparator) + (words.length ? options.multipleSeparator : "") );
322
- }
323
- else {
324
- $input.val( "" );
325
- $input.trigger("result", null);
326
- }
327
- }
328
- }
329
- );
330
- }
331
- };
332
-
333
- function receiveData(q, data) {
334
- if ( data && data.length && hasFocus ) {
335
- stopLoading();
336
- select.display(data, q);
337
- autoFill(q, data[0].value);
338
- select.show();
339
- } else {
340
- hideResultsNow();
341
- }
342
- };
343
-
344
- function request(term, success, failure) {
345
- if (!options.matchCase)
346
- term = term.toLowerCase();
347
- var data = cache.load(term);
348
- // recieve the cached data
349
- if (data && data.length) {
350
- success(term, data);
351
-
352
- // start geo_Autocomplete mod
353
- // request handler for google geocoder
354
- } else if (options.geocoder) {
355
- var _query = lastWord(term);
356
- var _opts = { 'address': _query };
357
- if( options.region )
358
- _opts.region = options.region;
359
-
360
- options.geocoder.geocode( _opts, function(_results, _status) {
361
- var parsed = options.parse(_results, _status, _query);
362
- cache.add(term, parsed);
363
- success(term, parsed);
364
- });
365
- // end geo_Autocomplete mod
366
-
367
- // if an AJAX url has been supplied, try loading the data now
368
- } else if( (typeof options.url == "string") && (options.url.length > 0) ){
369
-
370
- var extraParams = {
371
- timestamp: +new Date()
372
- };
373
- $.each(options.extraParams, function(key, param) {
374
- extraParams[key] = typeof param == "function" ? param() : param;
375
- });
376
-
377
- $.ajax({
378
- // try to leverage ajaxQueue plugin to abort previous requests
379
- mode: "abort",
380
- // limit abortion to this input
381
- port: "autocomplete" + input.name,
382
- dataType: options.dataType,
383
- url: options.url,
384
- data: $.extend({
385
- q: lastWord(term),
386
- limit: options.max
387
- }, extraParams),
388
- success: function(data) {
389
- var parsed = options.parse && options.parse(data) || parse(data);
390
- cache.add(term, parsed);
391
- success(term, parsed);
392
- }
393
- });
394
-
395
- } else {
396
- // if we have a failure, we need to empty the list -- this prevents the the [TAB] key from selecting the last successful match
397
- select.emptyList();
398
- failure(term);
399
- }
400
- };
401
-
402
- function parse(data) {
403
- var parsed = [];
404
- var rows = data.split("\n");
405
- for (var i=0; i < rows.length; i++) {
406
- var row = $.trim(rows[i]);
407
- if (row) {
408
- row = row.split("|");
409
- parsed[parsed.length] = {
410
- data: row,
411
- value: row[0],
412
- result: options.formatResult && options.formatResult(row, row[0]) || row[0]
413
- };
414
- }
415
- }
416
- return parsed;
417
- };
418
-
419
- function stopLoading() {
420
- $input.removeClass(options.loadingClass);
421
- };
422
-
423
- };
424
-
425
- $.Autocompleter.defaults = {
426
- inputClass: "ac_input",
427
- resultsClass: "ac_results",
428
- loadingClass: "ac_loading",
429
- minChars: 1,
430
- delay: 400,
431
- matchCase: false,
432
- matchSubset: true,
433
- matchContains: false,
434
- cacheLength: 10,
435
- max: 100,
436
- mustMatch: false,
437
- extraParams: {},
438
- selectFirst: true,
439
- formatItem: function(row) { return row[0]; },
440
- formatMatch: null,
441
- autoFill: false,
442
- width: 0,
443
- multiple: false,
444
- multipleSeparator: ", ",
445
- highlight: function(value, term) {
446
- return value.replace(new RegExp("(?![^&;]+;)(?!<[^<>]*)(" + term.replace(/([\^\$\(\)\[\]\{\}\*\.\+\?\|\\])/gi, "\\$1") + ")(?![^<>]*>)(?![^&;]+;)", "gi"), "<strong>$1</strong>");
447
- },
448
- scroll: true,
449
- scrollHeight: 180
450
- };
451
-
452
- $.Autocompleter.Cache = function(options) {
453
-
454
- var data = {};
455
- var length = 0;
456
-
457
- function matchSubset(s, sub) {
458
- if (!options.matchCase)
459
- s = s.toLowerCase();
460
- var i = s.indexOf(sub);
461
- if (options.matchContains == "word"){
462
- i = s.toLowerCase().search("\\b" + sub.toLowerCase());
463
- }
464
- if (i == -1) return false;
465
- return i == 0 || options.matchContains;
466
- };
467
-
468
- function add(q, value) {
469
- if (length > options.cacheLength){
470
- flush();
471
- }
472
- if (!data[q]){
473
- length++;
474
- }
475
- data[q] = value;
476
- }
477
-
478
- function populate(){
479
- if( !options.data ) return false;
480
- // track the matches
481
- var stMatchSets = {},
482
- nullData = 0;
483
-
484
- // no url was specified, we need to adjust the cache length to make sure it fits the local data store
485
- if( !options.url ) options.cacheLength = 1;
486
-
487
- // track all options for minChars = 0
488
- stMatchSets[""] = [];
489
-
490
- // loop through the array and create a lookup structure
491
- for ( var i = 0, ol = options.data.length; i < ol; i++ ) {
492
- var rawValue = options.data[i];
493
- // if rawValue is a string, make an array otherwise just reference the array
494
- rawValue = (typeof rawValue == "string") ? [rawValue] : rawValue;
495
-
496
- var value = options.formatMatch(rawValue, i+1, options.data.length);
497
- if ( value === false )
498
- continue;
499
-
500
- var firstChar = value.charAt(0).toLowerCase();
501
- // if no lookup array for this character exists, look it up now
502
- if( !stMatchSets[firstChar] )
503
- stMatchSets[firstChar] = [];
504
-
505
- // if the match is a string
506
- var row = {
507
- value: value,
508
- data: rawValue,
509
- result: options.formatResult && options.formatResult(rawValue) || value
510
- };
511
-
512
- // push the current match into the set list
513
- stMatchSets[firstChar].push(row);
514
-
515
- // keep track of minChars zero items
516
- if ( nullData++ < options.max ) {
517
- stMatchSets[""].push(row);
518
- }
519
- };
520
-
521
- // add the data items to the cache
522
- $.each(stMatchSets, function(i, value) {
523
- // increase the cache size
524
- options.cacheLength++;
525
- // add to the cache
526
- add(i, value);
527
- });
528
- }
529
-
530
- // populate any existing data
531
- setTimeout(populate, 25);
532
-
533
- function flush(){
534
- data = {};
535
- length = 0;
536
- }
537
-
538
- return {
539
- flush: flush,
540
- add: add,
541
- populate: populate,
542
- load: function(q) {
543
- if (!options.cacheLength || !length)
544
- return null;
545
- /*
546
- * if dealing w/local data and matchContains than we must make sure
547
- * to loop through all the data collections looking for matches
548
- */
549
- if( !options.url && options.matchContains ){
550
- // track all matches
551
- var csub = [];
552
- // loop through all the data grids for matches
553
- for( var k in data ){
554
- // don't search through the stMatchSets[""] (minChars: 0) cache
555
- // this prevents duplicates
556
- if( k.length > 0 ){
557
- var c = data[k];
558
- $.each(c, function(i, x) {
559
- // if we've got a match, add it to the array
560
- if (matchSubset(x.value, q)) {
561
- csub.push(x);
562
- }
563
- });
564
- }
565
- }
566
- return csub;
567
- } else
568
- // if the exact item exists, use it
569
- if (data[q]){
570
- return data[q];
571
- } else
572
- if (options.matchSubset) {
573
- for (var i = q.length - 1; i >= options.minChars; i--) {
574
- var c = data[q.substr(0, i)];
575
- if (c) {
576
- var csub = [];
577
- $.each(c, function(i, x) {
578
- if (matchSubset(x.value, q)) {
579
- csub[csub.length] = x;
580
- }
581
- });
582
- return csub;
583
- }
584
- }
585
- }
586
- return null;
587
- }
588
- };
589
- };
590
-
591
- $.Autocompleter.Select = function (options, input, select, config) {
592
- var CLASSES = {
593
- ACTIVE: "ac_over"
594
- };
595
-
596
- var listItems,
597
- active = -1,
598
- data,
599
- term = "",
600
- needsInit = true,
601
- element,
602
- list;
603
-
604
- // Create results
605
- function init() {
606
- if (!needsInit)
607
- return;
608
- element = $("<div/>")
609
- .hide()
610
- .addClass(options.resultsClass)
611
- .css("position", "absolute")
612
- .appendTo(document.body);
613
-
614
- list = $("<ul/>").appendTo(element).mouseover( function(event) {
615
- if(target(event).nodeName && target(event).nodeName.toUpperCase() == 'LI') {
616
- active = $("li", list).removeClass(CLASSES.ACTIVE).index(target(event));
617
- $(target(event)).addClass(CLASSES.ACTIVE);
618
- }
619
- }).click(function(event) {
620
- $(target(event)).addClass(CLASSES.ACTIVE);
621
- select();
622
- // TODO provide option to avoid setting focus again after selection? useful for cleanup-on-focus
623
- input.focus();
624
- return false;
625
- }).mousedown(function() {
626
- config.mouseDownOnSelect = true;
627
- }).mouseup(function() {
628
- config.mouseDownOnSelect = false;
629
- });
630
-
631
- if( options.width > 0 )
632
- element.css("width", options.width);
633
-
634
- needsInit = false;
635
- }
636
-
637
- function target(event) {
638
- var element = event.target;
639
- while(element && element.tagName != "LI")
640
- element = element.parentNode;
641
- // more fun with IE, sometimes event.target is empty, just ignore it then
642
- if(!element)
643
- return [];
644
- return element;
645
- }
646
-
647
- function moveSelect(step) {
648
- listItems.slice(active, active + 1).removeClass(CLASSES.ACTIVE);
649
- movePosition(step);
650
- var activeItem = listItems.slice(active, active + 1).addClass(CLASSES.ACTIVE);
651
- if(options.scroll) {
652
- var offset = 0;
653
- listItems.slice(0, active).each(function() {
654
- offset += this.offsetHeight;
655
- });
656
- if((offset + activeItem[0].offsetHeight - list.scrollTop()) > list[0].clientHeight) {
657
- list.scrollTop(offset + activeItem[0].offsetHeight - list.innerHeight());
658
- } else if(offset < list.scrollTop()) {
659
- list.scrollTop(offset);
660
- }
661
- }
662
- };
663
-
664
- function movePosition(step) {
665
- active += step;
666
- if (active < 0) {
667
- active = listItems.size() - 1;
668
- } else if (active >= listItems.size()) {
669
- active = 0;
670
- }
671
- }
672
-
673
- function limitNumberOfItems(available) {
674
- return options.max && options.max < available
675
- ? options.max
676
- : available;
677
- }
678
-
679
- function fillList() {
680
- list.empty();
681
- var max = limitNumberOfItems(data.length);
682
- for (var i=0; i < max; i++) {
683
- if (!data[i])
684
- continue;
685
- var formatted = options.formatItem(data[i].data, i+1, max, data[i].value, term);
686
- if ( formatted === false )
687
- continue;
688
- var li = $("<li/>").html( options.highlight(formatted, term) ).addClass(i%2 == 0 ? "ac_even" : "ac_odd").appendTo(list)[0];
689
- $.data(li, "ac_data", data[i]);
690
- }
691
- listItems = list.find("li");
692
- if ( options.selectFirst ) {
693
- listItems.slice(0, 1).addClass(CLASSES.ACTIVE);
694
- active = 0;
695
- }
696
- // apply bgiframe if available
697
- if ( $.fn.bgiframe )
698
- list.bgiframe();
699
- }
700
-
701
- return {
702
- display: function(d, q) {
703
- init();
704
- data = d;
705
- term = q;
706
- fillList();
707
- },
708
- next: function() {
709
- moveSelect(1);
710
- },
711
- prev: function() {
712
- moveSelect(-1);
713
- },
714
- pageUp: function() {
715
- if (active != 0 && active - 8 < 0) {
716
- moveSelect( -active );
717
- } else {
718
- moveSelect(-8);
719
- }
720
- },
721
- pageDown: function() {
722
- if (active != listItems.size() - 1 && active + 8 > listItems.size()) {
723
- moveSelect( listItems.size() - 1 - active );
724
- } else {
725
- moveSelect(8);
726
- }
727
- },
728
- hide: function() {
729
- element && element.hide();
730
- listItems && listItems.removeClass(CLASSES.ACTIVE);
731
- active = -1;
732
- },
733
- visible : function() {
734
- return element && element.is(":visible");
735
- },
736
- current: function() {
737
- return this.visible() && (listItems.filter("." + CLASSES.ACTIVE)[0] || options.selectFirst && listItems[0]);
738
- },
739
- show: function() {
740
- var offset = $(input).offset();
741
- element.css({
742
- width: typeof options.width == "string" || options.width > 0 ? options.width : $(input).width(),
743
- top: offset.top + input.offsetHeight,
744
- left: offset.left
745
- }).show();
746
- if(options.scroll) {
747
- list.scrollTop(0);
748
- list.css({
749
- maxHeight: options.scrollHeight,
750
- overflow: 'auto'
751
- });
752
-
753
- if($.browser.msie && typeof document.body.style.maxHeight === "undefined") {
754
- var listHeight = 0;
755
- listItems.each(function() {
756
- listHeight += this.offsetHeight;
757
- });
758
- var scrollbarsVisible = listHeight > options.scrollHeight;
759
- list.css('height', scrollbarsVisible ? options.scrollHeight : listHeight );
760
- if (!scrollbarsVisible) {
761
- // IE doesn't recalculate width when scrollbar disappears
762
- listItems.width( list.width() - parseInt(listItems.css("padding-left")) - parseInt(listItems.css("padding-right")) );
763
- }
764
- }
765
-
766
- }
767
- },
768
- selected: function() {
769
- var selected = listItems && listItems.filter("." + CLASSES.ACTIVE).removeClass(CLASSES.ACTIVE);
770
- return selected && selected.length && $.data(selected[0], "ac_data");
771
- },
772
- emptyList: function (){
773
- list && list.empty();
774
- },
775
- unbind: function() {
776
- element && element.remove();
777
- }
778
- };
779
- };
780
-
781
- $.fn.selection = function(start, end) {
782
- if (start !== undefined) {
783
- return this.each(function() {
784
- if( this.createTextRange ){
785
- var selRange = this.createTextRange();
786
- if (end === undefined || start == end) {
787
- selRange.move("character", start);
788
- selRange.select();
789
- } else {
790
- selRange.collapse(true);
791
- selRange.moveStart("character", start);
792
- selRange.moveEnd("character", end);
793
- selRange.select();
794
- }
795
- } else if( this.setSelectionRange ){
796
- this.setSelectionRange(start, end);
797
- } else if( this.selectionStart ){
798
- this.selectionStart = start;
799
- this.selectionEnd = end;
800
- }
801
- });
802
- }
803
- var field = this[0];
804
- if ( field.createTextRange ) {
805
- var range = document.selection.createRange(),
806
- orig = field.value,
807
- teststring = "<->",
808
- textLength = range.text.length;
809
- range.text = teststring;
810
- var caretAt = field.value.indexOf(teststring);
811
- field.value = orig;
812
- this.selection(caretAt, caretAt + textLength);
813
- return {
814
- start: caretAt,
815
- end: caretAt + textLength
816
- }
817
- } else if( field.selectionStart !== undefined ){
818
- return {
819
- start: field.selectionStart,
820
- end: field.selectionEnd
821
- }
822
- }
823
- };
824
-
825
- })(jQuery);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/view/admin/js/jquery.blockUI.js DELETED
@@ -1,496 +0,0 @@
1
- /*!
2
- * jQuery blockUI plugin
3
- * Version 2.39 (23-MAY-2011)
4
- * @requires jQuery v1.2.3 or later
5
- *
6
- * Examples at: http://malsup.com/jquery/block/
7
- * Copyright (c) 2007-2010 M. Alsup
8
- * Dual licensed under the MIT and GPL licenses:
9
- * http://www.opensource.org/licenses/mit-license.php
10
- * http://www.gnu.org/licenses/gpl.html
11
- *
12
- * Thanks to Amir-Hossein Sobhi for some excellent contributions!
13
- */
14
-
15
- ;(function($) {
16
-
17
-
18
- $.fn._fadeIn = $.fn.fadeIn;
19
-
20
- var noOp = function() {};
21
-
22
- // this bit is to ensure we don't call setExpression when we shouldn't (with extra muscle to handle
23
- // retarded userAgent strings on Vista)
24
- var mode = document.documentMode || 0;
25
- var setExpr = $.browser.msie && (($.browser.version < 8 && !mode) || mode < 8);
26
- var ie6 = $.browser.msie && /MSIE 6.0/.test(navigator.userAgent) && !mode;
27
-
28
- // global $ methods for blocking/unblocking the entire page
29
- $.blockUI = function(opts) { install(window, opts); };
30
- $.unblockUI = function(opts) { remove(window, opts); };
31
-
32
- // convenience method for quick growl-like notifications (http://www.google.com/search?q=growl)
33
- $.growlUI = function(title, message, timeout, onClose) {
34
- var $m = $('<div class="growlUI"></div>');
35
- if (title) $m.append('<h1>'+title+'</h1>');
36
- if (message) $m.append('<h2>'+message+'</h2>');
37
- if (timeout == undefined) timeout = 3000;
38
- $.blockUI({
39
- message: $m, fadeIn: 700, fadeOut: 1000, centerY: false,
40
- timeout: timeout, showOverlay: false,
41
- onUnblock: onClose,
42
- css: $.blockUI.defaults.growlCSS
43
- });
44
- };
45
-
46
- // plugin method for blocking element content
47
- $.fn.block = function(opts) {
48
- return this.unblock({ fadeOut: 0 }).each(function() {
49
- if ($.css(this,'position') == 'static')
50
- this.style.position = 'relative';
51
- if ($.browser.msie)
52
- this.style.zoom = 1; // force 'hasLayout'
53
- install(this, opts);
54
- });
55
- };
56
-
57
- // plugin method for unblocking element content
58
- $.fn.unblock = function(opts) {
59
- return this.each(function() {
60
- remove(this, opts);
61
- });
62
- };
63
-
64
- $.blockUI.version = 2.39; // 2nd generation blocking at no extra cost!
65
-
66
- // override these in your code to change the default behavior and style
67
- $.blockUI.defaults = {
68
- // message displayed when blocking (use null for no message)
69
- message: '<h1>Please wait...</h1>',
70
-
71
- title: null, // title string; only used when theme == true
72
- draggable: true, // only used when theme == true (requires jquery-ui.js to be loaded)
73
-
74
- theme: false, // set to true to use with jQuery UI themes
75
-
76
- // styles for the message when blocking; if you wish to disable
77
- // these and use an external stylesheet then do this in your code:
78
- // $.blockUI.defaults.css = {};
79
- css: {
80
- padding: 0,
81
- margin: 0,
82
- width: '30%',
83
- top: '40%',
84
- left: '35%',
85
- textAlign: 'center',
86
- color: '#000',
87
- border: '3px solid #aaa',
88
- backgroundColor:'#fff',
89
- cursor: 'wait'
90
- },
91
-
92
- // minimal style set used when themes are used
93
- themedCSS: {
94
- width: '30%',
95
- top: '40%',
96
- left: '35%'
97
- },
98
-
99
- // styles for the overlay
100
- overlayCSS: {
101
- backgroundColor: '#000',
102
- opacity: 0.6,
103
- cursor: 'wait'
104
- },
105
-
106
- // styles applied when using $.growlUI
107
- growlCSS: {
108
- width: '350px',
109
- top: '10px',
110
- left: '',
111
- right: '10px',
112
- border: 'none',
113
- padding: '5px',
114
- opacity: 0.6,
115
- cursor: 'default',
116
- color: '#fff',
117
- backgroundColor: '#000',
118
- '-webkit-border-radius': '10px',
119
- '-moz-border-radius': '10px',
120
- 'border-radius': '10px'
121
- },
122
-
123
- // IE issues: 'about:blank' fails on HTTPS and javascript:false is s-l-o-w
124
- // (hat tip to Jorge H. N. de Vasconcelos)
125
- iframeSrc: /^https/i.test(window.location.href || '') ? 'javascript:false' : 'about:blank',
126
-
127
- // force usage of iframe in non-IE browsers (handy for blocking applets)
128
- forceIframe: false,
129
-
130
- // z-index for the blocking overlay
131
- baseZ: 1000,
132
-
133
- // set these to true to have the message automatically centered
134
- centerX: true, // <-- only effects element blocking (page block controlled via css above)
135
- centerY: true,
136
-
137
- // allow body element to be stetched in ie6; this makes blocking look better
138
- // on "short" pages. disable if you wish to prevent changes to the body height
139
- allowBodyStretch: true,
140
-
141
- // enable if you want key and mouse events to be disabled for content that is blocked
142
- bindEvents: true,
143
-
144
- // be default blockUI will supress tab navigation from leaving blocking content
145
- // (if bindEvents is true)
146
- constrainTabKey: true,
147
-
148
- // fadeIn time in millis; set to 0 to disable fadeIn on block
149
- fadeIn: 200,
150
-
151
- // fadeOut time in millis; set to 0 to disable fadeOut on unblock
152
- fadeOut: 400,
153
-
154
- // time in millis to wait before auto-unblocking; set to 0 to disable auto-unblock
155
- timeout: 0,
156
-
157
- // disable if you don't want to show the overlay
158
- showOverlay: true,
159
-
160
- // if true, focus will be placed in the first available input field when
161
- // page blocking
162
- focusInput: true,
163
-
164
- // suppresses the use of overlay styles on FF/Linux (due to performance issues with opacity)
165
- applyPlatformOpacityRules: true,
166
-
167
- // callback method invoked when fadeIn has completed and blocking message is visible
168
- onBlock: null,
169
-
170
- // callback method invoked when unblocking has completed; the callback is
171
- // passed the element that has been unblocked (which is the window object for page
172
- // blocks) and the options that were passed to the unblock call:
173
- // onUnblock(element, options)
174
- onUnblock: null,
175
-
176
- // don't ask; if you really must know: http://groups.google.com/group/jquery-en/browse_thread/thread/36640a8730503595/2f6a79a77a78e493#2f6a79a77a78e493
177
- quirksmodeOffsetHack: 4,
178
-
179
- // class name of the message block
180
- blockMsgClass: 'blockMsg'
181
- };
182
-
183
- // private data and functions follow...
184
-
185
- var pageBlock = null;
186
- var pageBlockEls = [];
187
-
188
- function install(el, opts) {
189
- var full = (el == window);
190
- var msg = opts && opts.message !== undefined ? opts.message : undefined;
191
- opts = $.extend({}, $.blockUI.defaults, opts || {});
192
- opts.overlayCSS = $.extend({}, $.blockUI.defaults.overlayCSS, opts.overlayCSS || {});
193
- var css = $.extend({}, $.blockUI.defaults.css, opts.css || {});
194
- var themedCSS = $.extend({}, $.blockUI.defaults.themedCSS, opts.themedCSS || {});
195
- msg = msg === undefined ? opts.message : msg;
196
-
197
- // remove the current block (if there is one)
198
- if (full && pageBlock)
199
- remove(window, {fadeOut:0});
200
-
201
- // if an existing element is being used as the blocking content then we capture
202
- // its current place in the DOM (and current display style) so we can restore
203
- // it when we unblock
204
- if (msg && typeof msg != 'string' && (msg.parentNode || msg.jquery)) {
205
- var node = msg.jquery ? msg[0] : msg;
206
- var data = {};
207
- $(el).data('blockUI.history', data);
208
- data.el = node;
209
- data.parent = node.parentNode;
210
- data.display = node.style.display;
211
- data.position = node.style.position;
212
- if (data.parent)
213
- data.parent.removeChild(node);
214
- }
215
-
216
- $(el).data('blockUI.onUnblock', opts.onUnblock);
217
- var z = opts.baseZ;
218
-
219
- // blockUI uses 3 layers for blocking, for simplicity they are all used on every platform;
220
- // layer1 is the iframe layer which is used to supress bleed through of underlying content
221
- // layer2 is the overlay layer which has opacity and a wait cursor (by default)
222
- // layer3 is the message content that is displayed while blocking
223
-
224
- var lyr1 = ($.browser.msie || opts.forceIframe)
225
- ? $('<iframe class="blockUI" style="z-index:'+ (z++) +';display:none;border:none;margin:0;padding:0;position:absolute;width:100%;height:100%;top:0;left:0" src="'+opts.iframeSrc+'"></iframe>')
226
- : $('<div class="blockUI" style="display:none"></div>');
227
-
228
- var lyr2 = opts.theme
229
- ? $('<div class="blockUI blockOverlay ui-widget-overlay" style="z-index:'+ (z++) +';display:none"></div>')
230
- : $('<div class="blockUI blockOverlay" style="z-index:'+ (z++) +';display:none;border:none;margin:0;padding:0;width:100%;height:100%;top:0;left:0"></div>');
231
-
232
- var lyr3, s;
233
- if (opts.theme && full) {
234
- s = '<div class="blockUI ' + opts.blockMsgClass + ' blockPage ui-dialog ui-widget ui-corner-all" style="z-index:'+(z+10)+';display:none;position:fixed">' +
235
- '<div class="ui-widget-header ui-dialog-titlebar ui-corner-all blockTitle">'+(opts.title || '&nbsp;')+'</div>' +
236
- '<div class="ui-widget-content ui-dialog-content"></div>' +
237
- '</div>';
238
- }
239
- else if (opts.theme) {
240
- s = '<div class="blockUI ' + opts.blockMsgClass + ' blockElement ui-dialog ui-widget ui-corner-all" style="z-index:'+(z+10)+';display:none;position:absolute">' +
241
- '<div class="ui-widget-header ui-dialog-titlebar ui-corner-all blockTitle">'+(opts.title || '&nbsp;')+'</div>' +
242
- '<div class="ui-widget-content ui-dialog-content"></div>' +
243
- '</div>';
244
- }
245
- else if (full) {
246
- s = '<div class="blockUI ' + opts.blockMsgClass + ' blockPage" style="z-index:'+(z+10)+';display:none;position:fixed"></div>';
247
- }
248
- else {
249
- s = '<div class="blockUI ' + opts.blockMsgClass + ' blockElement" style="z-index:'+(z+10)+';display:none;position:absolute"></div>';
250
- }
251
- lyr3 = $(s);
252
-
253
- // if we have a message, style it
254
- if (msg) {
255
- if (opts.theme) {
256
- lyr3.css(themedCSS);
257
- lyr3.addClass('ui-widget-content');
258
- }
259
- else
260
- lyr3.css(css);
261
- }
262
-
263
- // style the overlay
264
- if (!opts.theme && (!opts.applyPlatformOpacityRules || !($.browser.mozilla && /Linux/.test(navigator.platform))))
265
- lyr2.css(opts.overlayCSS);
266
- lyr2.css('position', full ? 'fixed' : 'absolute');
267
-
268
- // make iframe layer transparent in IE
269
- if ($.browser.msie || opts.forceIframe)
270
- lyr1.css('opacity',0.0);
271
-
272
- //$([lyr1[0],lyr2[0],lyr3[0]]).appendTo(full ? 'body' : el);
273
- var layers = [lyr1,lyr2,lyr3], $par = full ? $('body') : $(el);
274
- $.each(layers, function() {
275
- this.appendTo($par);
276
- });
277
-
278
- if (opts.theme && opts.draggable && $.fn.draggable) {
279
- lyr3.draggable({
280
- handle: '.ui-dialog-titlebar',
281
- cancel: 'li'
282
- });
283
- }
284
-
285
- // ie7 must use absolute positioning in quirks mode and to account for activex issues (when scrolling)
286
- var expr = setExpr && (!$.boxModel || $('object,embed', full ? null : el).length > 0);
287
- if (ie6 || expr) {
288
- // give body 100% height
289
- if (full && opts.allowBodyStretch && $.boxModel)
290
- $('html,body').css('height','100%');
291
-
292
- // fix ie6 issue when blocked element has a border width
293
- if ((ie6 || !$.boxModel) && !full) {
294
- var t = sz(el,'borderTopWidth'), l = sz(el,'borderLeftWidth');
295
- var fixT = t ? '(0 - '+t+')' : 0;
296
- var fixL = l ? '(0 - '+l+')' : 0;
297
- }
298
-
299
- // simulate fixed position
300
- $.each([lyr1,lyr2,lyr3], function(i,o) {
301
- var s = o[0].style;
302
- s.position = 'absolute';
303
- if (i < 2) {
304
- full ? s.setExpression('height','Math.max(document.body.scrollHeight, document.body.offsetHeight) - (jQuery.boxModel?0:'+opts.quirksmodeOffsetHack+') + "px"')
305
- : s.setExpression('height','this.parentNode.offsetHeight + "px"');
306
- full ? s.setExpression('width','jQuery.boxModel && document.documentElement.clientWidth || document.body.clientWidth + "px"')
307
- : s.setExpression('width','this.parentNode.offsetWidth + "px"');
308
- if (fixL) s.setExpression('left', fixL);
309
- if (fixT) s.setExpression('top', fixT);
310
- }
311
- else if (opts.centerY) {
312
- if (full) s.setExpression('top','(document.documentElement.clientHeight || document.body.clientHeight) / 2 - (this.offsetHeight / 2) + (blah = document.documentElement.scrollTop ? document.documentElement.scrollTop : document.body.scrollTop) + "px"');
313
- s.marginTop = 0;
314
- }
315
- else if (!opts.centerY && full) {
316
- var top = (opts.css && opts.css.top) ? parseInt(opts.css.top) : 0;
317
- var expression = '((document.documentElement.scrollTop ? document.documentElement.scrollTop : document.body.scrollTop) + '+top+') + "px"';
318
- s.setExpression('top',expression);
319
- }
320
- });
321
- }
322
-
323
- // show the message
324
- if (msg) {
325
- if (opts.theme)
326
- lyr3.find('.ui-widget-content').append(msg);
327
- else
328
- lyr3.append(msg);
329
- if (msg.jquery || msg.nodeType)
330
- $(msg).show();
331
- }
332
-
333
- if (($.browser.msie || opts.forceIframe) && opts.showOverlay)
334
- lyr1.show(); // opacity is zero
335
- if (opts.fadeIn) {
336
- var cb = opts.onBlock ? opts.onBlock : noOp;
337
- var cb1 = (opts.showOverlay && !msg) ? cb : noOp;
338
- var cb2 = msg ? cb : noOp;
339
- if (opts.showOverlay)
340
- lyr2._fadeIn(opts.fadeIn, cb1);
341
- if (msg) {
342
- lyr3._fadeIn(opts.fadeIn, cb2);
343
- }
344
- }
345
- else {
346
- if (opts.showOverlay)
347
- lyr2.show();
348
- if (msg)
349
- lyr3.show();
350
- if (opts.onBlock)
351
- opts.onBlock();
352
- }
353
-
354
- // bind key and mouse events
355
- bind(1, el, opts);
356
-
357
- if (full) {
358
- pageBlock = lyr3[0];
359
- pageBlockEls = $(':input:enabled:visible',pageBlock);
360
- if (opts.focusInput)
361
- setTimeout(focus, 20);
362
- }
363
- else
364
- center(lyr3[0], opts.centerX, opts.centerY);
365
-
366
- if (opts.timeout) {
367
- // auto-unblock
368
- var to = setTimeout(function() {
369
- full ? $.unblockUI(opts) : $(el).unblock(opts);
370
- }, opts.timeout);
371
- $(el).data('blockUI.timeout', to);
372
- }
373
- };
374
-
375
- // remove the block
376
- function remove(el, opts) {
377
- var full = (el == window);
378
- var $el = $(el);
379
- var data = $el.data('blockUI.history');
380
- var to = $el.data('blockUI.timeout');
381
- if (to) {
382
- clearTimeout(to);
383
- $el.removeData('blockUI.timeout');
384
- }
385
- opts = $.extend({}, $.blockUI.defaults, opts || {});
386
- bind(0, el, opts); // unbind events
387
-
388
- if (opts.onUnblock === null) {
389
- opts.onUnblock = $el.data('blockUI.onUnblock');
390
- $el.removeData('blockUI.onUnblock');
391
- }
392
-
393
- var els;
394
- if (full) // crazy selector to handle odd field errors in ie6/7
395
- els = $('body').children().filter('.blockUI').add('body > .blockUI');
396
- else
397
- els = $('.blockUI', el);
398
-
399
- if (full)
400
- pageBlock = pageBlockEls = null;
401
-
402
- if (opts.fadeOut) {
403
- els.fadeOut(opts.fadeOut);
404
- setTimeout(function() { reset(els,data,opts,el); }, opts.fadeOut);
405
- }
406
- else
407
- reset(els, data, opts, el);
408
- };
409
-
410
- // move blocking element back into the DOM where it started
411
- function reset(els,data,opts,el) {
412
- els.each(function(i,o) {
413
- // remove via DOM calls so we don't lose event handlers
414
- if (this.parentNode)
415
- this.parentNode.removeChild(this);
416
- });
417
-
418
- if (data && data.el) {
419
- data.el.style.display = data.display;
420
- data.el.style.position = data.position;
421
- if (data.parent)
422
- data.parent.appendChild(data.el);
423
- $(el).removeData('blockUI.history');
424
- }
425
-
426
- if (typeof opts.onUnblock == 'function')
427
- opts.onUnblock(el,opts);
428
- };
429
-
430
- // bind/unbind the handler
431
- function bind(b, el, opts) {
432
- var full = el == window, $el = $(el);
433
-
434
- // don't bother unbinding if there is nothing to unbind
435
- if (!b && (full && !pageBlock || !full && !$el.data('blockUI.isBlocked')))
436
- return;
437
- if (!full)
438
- $el.data('blockUI.isBlocked', b);
439
-
440
- // don't bind events when overlay is not in use or if bindEvents is false
441
- if (!opts.bindEvents || (b && !opts.showOverlay))
442
- return;
443
-
444
- // bind anchors and inputs for mouse and key events
445
- var events = 'mousedown mouseup keydown keypress';
446
- b ? $(document).bind(events, opts, handler) : $(document).unbind(events, handler);
447
-
448
- // former impl...
449
- // var $e = $('a,:input');
450
- // b ? $e.bind(events, opts, handler) : $e.unbind(events, handler);
451
- };
452
-
453
- // event handler to suppress keyboard/mouse events when blocking
454
- function handler(e) {
455
- // allow tab navigation (conditionally)
456
- if (e.keyCode && e.keyCode == 9) {
457
- if (pageBlock && e.data.constrainTabKey) {
458
- var els = pageBlockEls;
459
- var fwd = !e.shiftKey && e.target === els[els.length-1];
460
- var back = e.shiftKey && e.target === els[0];
461
- if (fwd || back) {
462
- setTimeout(function(){focus(back)},10);
463
- return false;
464
- }
465
- }
466
- }
467
- var opts = e.data;
468
- // allow events within the message content
469
- if ($(e.target).parents('div.' + opts.blockMsgClass).length > 0)
470
- return true;
471
-
472
- // allow events for content that is not being blocked
473
- return $(e.target).parents().children().filter('div.blockUI').length == 0;
474
- };
475
-
476
- function focus(back) {
477
- if (!pageBlockEls)
478
- return;
479
- var e = pageBlockEls[back===true ? pageBlockEls.length-1 : 0];
480
- if (e)
481
- e.focus();
482
- };
483
-
484
- function center(el, x, y) {
485
- var p = el.parentNode, s = el.style;
486
- var l = ((p.offsetWidth - el.offsetWidth)/2) - sz(p,'borderLeftWidth');
487
- var t = ((p.offsetHeight - el.offsetHeight)/2) - sz(p,'borderTopWidth');
488
- if (x) s.left = l > 0 ? (l+'px') : '0';
489
- if (y) s.top = t > 0 ? (t+'px') : '0';
490
- };
491
-
492
- function sz(el, p) {
493
- return parseInt($.css(el,p))||0;
494
- };
495
-
496
- })(jQuery);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/view/admin/js/jquery.calendrical.js DELETED
@@ -1,588 +0,0 @@
1
- calendricalDateFormats = {
2
- us : { //US date format (eg. 12/1/2011)
3
- pattern : /([\d]{1,2})\/([\d]{1,2})\/([\d]{4}|[\d]{2})/,
4
- format : 'm/d/y',
5
- order : 'middleEndian',
6
- zeroPad : false },
7
- iso : { //ISO 8601 (eg. 2011-12-01)
8
- pattern : /([\d]{4}|[\d]{2})-([\d]{1,2})-([\d]{1,2})/,
9
- format : 'y-m-d',
10
- order : 'bigEndian',
11
- zeroPad : true },
12
- dot : { //Little endian with dots (eg. 1.12.2011)
13
- pattern : /([\d]{1,2}).([\d]{1,2}).([\d]{4}|[\d]{2})/,
14
- format : 'd.m.y',
15
- order : 'littleEndian',
16
- zeroPad : false },
17
- def : { //Default (eg. 1/12/2011)
18
- pattern : /([\d]{1,2})\/([\d]{1,2})\/([\d]{4}|[\d]{2})/,
19
- format : 'd/m/y',
20
- order : 'littleEndian',
21
- zeroPad : false }
22
- };
23
-
24
- function formatDate(date, format)
25
- {
26
- if( typeof calendricalDateFormats[format] === 'undefined' )
27
- format = 'def';
28
-
29
- var y = ( date.getUTCFullYear() ).toString();
30
- var m = ( date.getUTCMonth() + 1 ).toString();
31
- var d = ( date.getUTCDate() ).toString();
32
- if( calendricalDateFormats[format].zeroPad ) {
33
- if( m.length == 1 ) m = '0' + m;
34
- if( d.length == 1 ) d = '0' + d;
35
- }
36
- var dt = calendricalDateFormats[format].format;
37
- dt = dt.replace('d', d);
38
- dt = dt.replace('m', m);
39
- dt = dt.replace('y', y);
40
- return dt;
41
- }
42
-
43
- function formatTime(hour, minute, iso)
44
- {
45
- var printMinute = minute;
46
- if( minute < 10 ) printMinute = '0' + minute;
47
-
48
- if( iso ) {
49
- var printHour = hour
50
- if( printHour < 10 ) printHour = '0' + hour;
51
- return printHour + ':' + printMinute;
52
- } else {
53
- var printHour = hour % 12;
54
- if( printHour == 0 ) printHour = 12;
55
- var half = ( hour < 12 ) ? 'am' : 'pm';
56
- return printHour + ':' + printMinute + half;
57
- }
58
- }
59
-
60
- function parseDate(date, format)
61
- {
62
- if( typeof calendricalDateFormats[format] === 'undefined' )
63
- format = 'def';
64
-
65
- var matches = date.match(calendricalDateFormats[format].pattern);
66
- if( !matches || matches.length != 4 ) {
67
- // Return an "invalid date" date instance like the original parseDate
68
- return Date( 'invalid' );
69
- }
70
-
71
- switch( calendricalDateFormats[format].order ) {
72
- case 'bigEndian' :
73
- var d = matches[3]; var m = matches[2]; var y = matches[1];
74
- break;
75
- case 'littleEndian' :
76
- var d = matches[1]; var m = matches[2]; var y = matches[3];
77
- break;
78
- case 'middleEndian' :
79
- var d = matches[2]; var m = matches[1]; var y = matches[3];
80
- break;
81
- default : //Default to little endian
82
- var d = matches[1]; var m = matches[2]; var y = matches[3];
83
- break;
84
- }
85
-
86
- // Add century to a two digit year
87
- if( y.length == 2 ) {
88
- y = new Date().getUTCFullYear().toString().substr(0, 2) + y;
89
- }
90
-
91
- // This is how the original parseDate does it
92
- return new Date( m + '/' + d + '/' + y + ' GMT' );
93
- }
94
-
95
- function parseTime(text)
96
- {
97
- var match = match = /(\d+)\s*[:\-\.,]\s*(\d+)\s*(am|pm)?/i.exec(text);
98
- if( match && match.length >= 3 ) {
99
- var hour = Number(match[1]);
100
- var minute = Number(match[2]);
101
- if( hour == 12 && match[3] ) hour -= 12;
102
- if( match[3] && match[3].toLowerCase() == 'pm' ) hour += 12;
103
- return {
104
- hour: hour,
105
- minute: minute
106
- };
107
- } else {
108
- return null;
109
- }
110
- }
111
-
112
- (function($) {
113
-
114
- function getToday()
115
- {
116
- var date = new Date();
117
- return new Date(date.getFullYear(), date.getMonth(), date.getDate());
118
- }
119
-
120
- function areDatesEqual(date1, date2)
121
- {
122
- if( typeof date1 === 'string' )
123
- date1 = new Date( date1 );
124
-
125
- if( typeof date2 === 'string' )
126
- date2 = new Date(date2);
127
-
128
- if( date1.getUTCDate() === date2.getUTCDate() ) {
129
- if( date1.getUTCMonth() === date2.getUTCMonth() ) {
130
- if( date1.getUTCFullYear() === date2.getUTCFullYear() ) {
131
- return true;
132
- }
133
- }
134
- }
135
- return false;
136
- }
137
-
138
- function daysInMonth(year, month)
139
- {
140
- if (year instanceof Date) return daysInMonth(year.getUTCFullYear(), year.getUTCMonth());
141
- if (month == 1) {
142
- var leapYear = (year % 4 == 0) &&
143
- (!(year % 100 == 0) || (year % 400 == 0));
144
- return leapYear ? 29 : 28;
145
- } else if (month == 3 || month == 5 || month == 8 || month == 10) {
146
- return 30;
147
- } else {
148
- return 31;
149
- }
150
- }
151
-
152
- function dayAfter(date)
153
- {
154
- // + 1 day
155
- return new Date( date.getTime() + (1*24*60*60*1000) );
156
- }
157
-
158
- function dayBefore(date)
159
- {
160
- // - 1 day
161
- return new Date( date.getTime() - (1*24*60*60*1000) );
162
- }
163
-
164
- function monthAfter(year, month)
165
- {
166
- return (month == 11) ?
167
- new Date(year + 1, 0, 1) :
168
- new Date(year, month + 1, 1);
169
- }
170
-
171
- /**
172
- * Generates calendar header, with month name, << and >> controls, and
173
- * initials for days of the week.
174
- */
175
- function renderCalendarHeader(element, year, month, options)
176
- {
177
- var monthNames = options.monthNames.split(',');
178
- //Prepare thead element
179
- var thead = $('<thead />');
180
- var titleRow = $('<tr />').appendTo(thead);
181
-
182
- //Generate << (back a month) link
183
- $('<th />').addClass('monthCell').append(
184
- $('<a href="javascript:;">&laquo;</a>')
185
- .addClass('prevMonth')
186
- .mousedown(function(e) {
187
- renderCalendarPage(element,
188
- month == 0 ? (year - 1) : year,
189
- month == 0 ? 11 : (month - 1), options
190
- );
191
- e.preventDefault();
192
- })
193
- ).appendTo(titleRow);
194
-
195
- //Generate month title
196
- $('<th />').addClass('monthCell').attr('colSpan', 5).append(
197
- $('<a href="javascript:;">' + monthNames[month] + ' ' +
198
- year + '</a>').addClass('monthName')
199
- ).appendTo(titleRow);
200
-
201
- //Generate >> (forward a month) link
202
- $('<th />').addClass('monthCell').append(
203
- $('<a href="javascript:;">&raquo;</a>')
204
- .addClass('nextMonth')
205
- .mousedown(function() {
206
- renderCalendarPage(element,
207
- month == 11 ? (year + 1) : year,
208
- month == 11 ? 0 : (month + 1), options
209
- );
210
- })
211
- ).appendTo(titleRow);
212
-
213
- // Generate weekday initials row. Adjust for week start day
214
- var names = options.dayNames.split(',');
215
- var startDay = parseInt(options.weekStartDay);
216
- var adjustedNames = [];
217
- for( var i = 0, len = names.length; i < len; i++ ) {
218
- adjustedNames[i] = names[(i + startDay) % len];
219
- }
220
- var dayNames = $('<tr />').appendTo(thead);
221
- $.each( adjustedNames, function( k, v ) {
222
- $('<td />').addClass('dayName').append(v).appendTo(dayNames);
223
- });
224
-
225
- return thead;
226
- }
227
-
228
- function renderCalendarPage(element, year, month, options)
229
- {
230
- options = options || {};
231
-
232
- var startDay = parseInt(options.weekStartDay);
233
- var today = options.today ? options.today : getToday();
234
- // Normalize
235
- today.setHours(0);
236
- today.setMinutes(0);
237
-
238
- var date = new Date(year, month, 1);
239
- var endDate = monthAfter(year, month);
240
-
241
- //Adjust dates for current timezone. This is a workaround to get
242
- //date comparison to work properly.
243
- var tzOffset = Math.abs(today.getTimezoneOffset());
244
- if (tzOffset != 0) {
245
- today.setHours(today.getHours() + tzOffset / 60);
246
- today.setMinutes(today.getMinutes() + tzOffset % 60);
247
- date.setHours(date.getHours() + tzOffset / 60);
248
- date.setMinutes(date.getMinutes() + tzOffset % 60);
249
- endDate.setHours(endDate.getHours() + tzOffset / 60);
250
- endDate.setMinutes(endDate.getMinutes() + tzOffset % 60);
251
- }
252
-
253
- //Wind end date forward to last day of week
254
- var ff = endDate.getUTCDay() - startDay;
255
- if (ff < 0) {
256
- ff = Math.abs(ff) - 1;
257
- } else {
258
- ff = 6 - ff;
259
- }
260
- for (var i = 0; i < ff; i++) endDate = dayAfter(endDate);
261
-
262
- var table = $('<table />');
263
- renderCalendarHeader(element, year, month, options).appendTo(table);
264
-
265
- var tbody = $('<tbody />').appendTo(table);
266
- var row = $('<tr />');
267
-
268
- //Rewind date to first day of week
269
- var rewind = date.getUTCDay() - startDay;
270
- if (rewind < 0) rewind = 7 + rewind;
271
- for (var i = 0; i < rewind; i++) date = dayBefore(date);
272
-
273
- while (date <= endDate) {
274
- var td = $('<td />')
275
- .addClass('day')
276
- .append(
277
- $('<a href="javascript:;">' +
278
- date.getUTCDate() + '</a>'
279
- ).click((function() {
280
- var thisDate = date;
281
-
282
- return function() {
283
- if (options && options.selectDate) {
284
- options.selectDate(thisDate);
285
- }
286
- }
287
- }()))
288
- )
289
- .appendTo(row);
290
-
291
- var isToday = areDatesEqual(date, today);
292
- var isSelected = options.selected &&
293
- areDatesEqual(options.selected, date);
294
-
295
- if (isToday) td.addClass('today');
296
- if (isSelected) td.addClass('selected');
297
- if (isToday && isSelected) td.addClass('today_selected');
298
- if (date.getUTCMonth() != month) td.addClass('nonMonth');
299
-
300
- var dow = date.getUTCDay();
301
- if (((dow + 1) % 7) == startDay) {
302
- tbody.append(row);
303
- row = $('<tr />');
304
- }
305
- date = dayAfter(date);
306
- }
307
- if (row.children().length) {
308
- tbody.append(row);
309
- } else {
310
- row.remove();
311
- }
312
-
313
- element.empty().append(table);
314
- }
315
-
316
- function renderTimeSelect(element, options)
317
- {
318
- var selection = options.selection && parseTime(options.selection);
319
- if (selection) {
320
- selection.minute = Math.floor(selection.minute / 15.0) * 15;
321
- }
322
- var startTime = options.startTime &&
323
- (options.startTime.hour * 60 + options.startTime.minute);
324
-
325
- var scrollTo; //Element to scroll the dropdown box to when shown
326
- var ul = $('<ul />');
327
- for (var hour = 0; hour < 24; hour++) {
328
- for (var minute = 0; minute < 60; minute += 15) {
329
- if (startTime && startTime > (hour * 60 + minute)) continue;
330
-
331
- (function() {
332
- var timeText = formatTime(hour, minute, options.isoTime);
333
- var fullText = timeText;
334
- if (startTime != null) {
335
- var duration = (hour * 60 + minute) - startTime;
336
- if (duration < 60) {
337
- fullText += ' (' + duration + ' min)';
338
- } else if (duration == 60) {
339
- fullText += ' (1 hr)';
340
- } else {
341
- fullText += ' (' + Math.floor( duration / 60.0 ) + ' hr ' + ( duration % 60 ) + ' min)';
342
- }
343
- }
344
- var li = $('<li />').append(
345
- $('<a href="javascript:;">' + fullText + '</a>')
346
- .click(function() {
347
- if (options && options.selectTime) {
348
- options.selectTime(timeText);
349
- }
350
- }).mousemove(function() {
351
- $('li.selected', ul).removeClass('selected');
352
- })
353
- ).appendTo(ul);
354
-
355
- //Set to scroll to the default hour, unless already set
356
- if (!scrollTo && hour == options.defaultHour) {
357
- scrollTo = li;
358
- }
359
-
360
- if (selection &&
361
- selection.hour == hour &&
362
- selection.minute == minute)
363
- {
364
- //Highlight selected item
365
- li.addClass('selected');
366
-
367
- //Set to scroll to the selected hour
368
- //
369
- //This is set even if scrollTo is already set, since
370
- //scrolling to selected hour is more important than
371
- //scrolling to default hour
372
- scrollTo = li;
373
- }
374
- })();
375
- }
376
- }
377
- if (scrollTo) {
378
- //Set timeout of zero so code runs immediately after any calling
379
- //functions are finished (this is needed, since box hasn't been
380
- //added to the DOM yet)
381
- setTimeout(function() {
382
- //Scroll the dropdown box so that scrollTo item is in
383
- //the middle
384
- element[0].scrollTop =
385
- scrollTo[0].offsetTop - scrollTo.height() * 2;
386
- }, 0);
387
- }
388
- element.empty().append(ul);
389
- }
390
-
391
- $.fn.calendricalDate = function(options)
392
- {
393
- options = options || {};
394
- options.padding = options.padding || 4;
395
- options.monthNames = options.monthNames ||
396
- 'January,February,March,April,May,June,July,August,September,October,November,December';
397
- options.dayNames = options.dayNames || 'S,M,T,W,T,F,S';
398
- options.weekStartDay = options.weekStartDay || 0;
399
-
400
- return this.each(function() {
401
- var element = $(this);
402
- var div;
403
- var within = false;
404
-
405
- element.bind('focus', function() {
406
- if (div) return;
407
- var offset = element.position();
408
- var padding = element.css('padding-left');
409
- div = $('<div />')
410
- .addClass('calendricalDatePopup')
411
- .mouseenter(function() { within = true; })
412
- .mouseleave(function() { within = false; })
413
- .mousedown(function(e) {
414
- e.preventDefault();
415
- })
416
- .css({
417
- position: 'absolute',
418
- left: offset.left,
419
- top: offset.top + element.height() +
420
- options.padding * 2
421
- });
422
- element.after(div);
423
-
424
- var selected = parseDate(element.val(), options.dateFormat);
425
- if (!selected.getUTCFullYear()) selected = options.today ? options.today : getToday();
426
-
427
- renderCalendarPage(
428
- div,
429
- selected.getUTCFullYear(),
430
- selected.getUTCMonth(), {
431
- today: options.today,
432
- selected: selected,
433
- monthNames: options.monthNames,
434
- dayNames: options.dayNames,
435
- weekStartDay: options.weekStartDay,
436
- selectDate: function(date) {
437
- within = false;
438
- element.val(formatDate(date, options.dateFormat));
439
- div.remove();
440
- div = null;
441
- if (options.endDate) {
442
- var endDate = parseDate(
443
- options.endDate.val(), options.dateFormat
444
- );
445
- if (endDate >= selected) {
446
- options.endDate.val(formatDate(
447
- new Date(
448
- date.getTime() +
449
- endDate.getTime() -
450
- selected.getTime()
451
- ),
452
- options.dateFormat
453
- ));
454
- }
455
- }
456
- }
457
- }
458
- );
459
- }).blur(function() {
460
- if (within){
461
- if (div) element.focus();
462
- return;
463
- }
464
- if (!div) return;
465
- div.remove();
466
- div = null;
467
- });
468
- });
469
- };
470
-
471
- $.fn.calendricalDateRange = function(options)
472
- {
473
- if (this.length >= 2) {
474
- $(this[0]).calendricalDate($.extend({
475
- endDate: $(this[1])
476
- }, options));
477
- $(this[1]).calendricalDate(options);
478
- }
479
- return this;
480
- };
481
-
482
- $.fn.calendricalDateRangeSingle = function(options)
483
- {
484
- if (this.length == 1) {
485
- $(this).calendricalDate(options);
486
- }
487
- return this;
488
- };
489
-
490
- $.fn.calendricalTime = function(options)
491
- {
492
- options = options || {};
493
- options.padding = options.padding || 4;
494
-
495
- return this.each(function() {
496
- var element = $(this);
497
- var div;
498
- var within = false;
499
-
500
- element.bind('focus click', function() {
501
- if (div) return;
502
-
503
- var useStartTime = options.startTime;
504
- if (useStartTime) {
505
- if (options.startDate && options.endDate &&
506
- !areDatesEqual(parseDate(options.startDate.val()),
507
- parseDate(options.endDate.val())))
508
- useStartTime = false;
509
- }
510
-
511
- var offset = element.position();
512
- div = $('<div />')
513
- .addClass('calendricalTimePopup')
514
- .mouseenter(function() { within = true; })
515
- .mouseleave(function() { within = false; })
516
- .mousedown(function(e) {
517
- e.preventDefault();
518
- })
519
- .css({
520
- position: 'absolute',
521
- left: offset.left,
522
- top: offset.top + element.height() +
523
- options.padding * 2
524
- });
525
- if (useStartTime) {
526
- div.addClass('calendricalEndTimePopup');
527
- }
528
-
529
- element.after(div);
530
-
531
- var opts = {
532
- selection: element.val(),
533
- selectTime: function(time) {
534
- within = false;
535
- element.val(time);
536
- div.remove();
537
- div = null;
538
- },
539
- isoTime: options.isoTime || false,
540
- defaultHour: (options.defaultHour != null) ?
541
- options.defaultHour : 8
542
- };
543
-
544
- if (useStartTime) {
545
- opts.startTime = parseTime(options.startTime.val());
546
- }
547
-
548
- renderTimeSelect(div, opts);
549
- }).blur(function() {
550
- if (within){
551
- if (div) element.focus();
552
- return;
553
- }
554
- if (!div) return;
555
- div.remove();
556
- div = null;
557
- });
558
- });
559
- },
560
-
561
- $.fn.calendricalTimeRange = function(options)
562
- {
563
- if (this.length >= 2) {
564
- $(this[0]).calendricalTime(options);
565
- $(this[1]).calendricalTime($.extend({
566
- startTime: $(this[0])
567
- }, options));
568
- }
569
- return this;
570
- };
571
-
572
- $.fn.calendricalDateTimeRange = function(options)
573
- {
574
- if (this.length >= 4) {
575
- $(this[0]).calendricalDate($.extend({
576
- endDate: $(this[2])
577
- }, options));
578
- $(this[1]).calendricalTime(options);
579
- $(this[2]).calendricalDate(options);
580
- $(this[3]).calendricalTime($.extend({
581
- startTime: $(this[1]),
582
- startDate: $(this[0]),
583
- endDate: $(this[2])
584
- }, options));
585
- }
586
- return this;
587
- };
588
- })(jQuery);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/view/admin/js/jquery.inputdate.js DELETED
@@ -1,200 +0,0 @@
1
- (function( $ )
2
- {
3
- /**
4
- * Private functions
5
- */
6
-
7
- // Helper function - reset contents of current field to stored original
8
- // value and alert user.
9
- function reset_invalid( field )
10
- {
11
- field
12
- .addClass( 'error' )
13
- .fadeOut( 'normal', function() {
14
- field
15
- .val( field.data( 'timespan.stored' ) )
16
- .removeClass( 'error' )
17
- .fadeIn( 'fast' );
18
- });
19
- }
20
-
21
- // Stores the value of the HTML element in context to its "stored" jQuery data.
22
- function store_value() {
23
- $(this).data( 'timespan.stored', this.value );
24
- }
25
-
26
- /**
27
- * Value initialization
28
- */
29
- function reset( start_date_input, start_time, twentyfour_hour, date_format, now )
30
- {
31
- // Restore original values of fields when the page was loaded
32
- start_time.val( start_time.data( 'timespan.initial_value' ) );
33
-
34
- // Fill out input field with default date/time based on this original
35
- // value.
36
-
37
- var start = parseInt( start_time.val() );
38
- // If start_time field has a valid integer, use it, else use current time
39
- // rounded to nearest quarter-hour.
40
- if( ! isNaN( parseInt( start ) ) ) {
41
- start = new Date( parseInt( start ) * 1000 );
42
- } else {
43
- start = new Date( now );
44
- }
45
- start_date_input.val( formatDate( start, date_format ) );
46
-
47
- // Trigger function (defined above) to internally store values of each
48
- // input field (used in calculations later).
49
- start_date_input.each( store_value );
50
- }
51
-
52
- /**
53
- * Private constants
54
- */
55
-
56
- var default_options = {
57
- start_date_input: 'date-input',
58
- start_time: 'time',
59
- twentyfour_hour: false,
60
- date_format: 'def',
61
- now: new Date()
62
- };
63
-
64
- /**
65
- * Public methods
66
- */
67
-
68
- var methods = {
69
-
70
- /**
71
- * Initialize settings.
72
- */
73
- init: function( options )
74
- {
75
- var o = $.extend( {}, default_options, options );
76
-
77
- // Shortcut jQuery objects
78
- var start_date_input = $(o.start_date_input);
79
- var start_time = $(o.start_time);
80
-
81
- var date_inputs = start_date_input;
82
- var all_inputs = start_date_input;
83
-
84
- /**
85
- * Event handlers
86
- */
87
-
88
- // Save original (presumably valid) value of every input field upon focus.
89
- all_inputs.bind( 'focus.timespan', store_value );
90
- date_inputs.calendricalDate( {
91
- today: new Date( o.now.getFullYear(), o.now.getMonth(), o.now.getDate() ),
92
- dateFormat: o.date_format, monthNames: o.month_names, dayNames: o.day_names,
93
- weekStartDay: o.week_start_day
94
- } );
95
-
96
- // Validate and update saved value of DATE fields upon blur.
97
- date_inputs
98
- .bind( 'blur.timespan', function() {
99
- // Validate contents of this field.
100
- var date = parseDate( this.value, o.date_format );
101
- if( isNaN( date ) ) {
102
- // This field is invalid.
103
- reset_invalid( $(this) );
104
- } else {
105
- // Value is valid, so store it for later use (below).
106
- $(this).data( 'timespan.stored', this.value );
107
- // Re-format contents of field correctly (in case parsable but not
108
- // perfect).
109
- $(this).val( formatDate( date, o.date_format ) );
110
- }
111
- });
112
-
113
- // When start date/time are modified, update end date/time by shifting the
114
- // appropriate amount.
115
- start_date_input.bind( 'focus.timespan', function() {
116
- // Calculate the time difference between start & end and save it.
117
- var start_date_val = parseDate( start_date_input.val(), o.date_format ).getTime() / 1000;
118
- } )
119
- .bind( 'blur.timespan', function() {
120
- var start_date_val = parseDate( start_date_input.data( 'timespan.stored' ), o.date_format );
121
- // Shift end date/time as appropriate.
122
- } );
123
-
124
- // Validation upon form submission
125
- start_date_input.closest( 'form' )
126
- .bind( 'submit.timespan', function() {
127
- // Update hidden field value with chosen date/time.
128
-
129
- // Convert Date object into UNIX timestamp for form submission
130
- var unix_start_time = parseDate( start_date_input.val(), o.date_format ).getTime() / 1000;
131
- // If parsed incorrectly, entire calculation is invalid.
132
- if( isNaN( unix_start_time ) ) {
133
- unix_start_time = '';
134
- }
135
- // Set start date value to valid unix time, or empty string, depending
136
- // on above validation.
137
- start_time.val( unix_start_time );
138
- } );
139
-
140
- // Store original form value
141
- start_time.data( 'timespan.initial_value', start_time.val() );
142
-
143
- // Initialize input fields
144
- reset( start_date_input,
145
- start_time,
146
- o.twentyfour_hour,
147
- o.date_format,
148
- o.now )
149
-
150
- return this;
151
- },
152
-
153
- /**
154
- * Reset values to defaults.
155
- */
156
- reset: function( options )
157
- {
158
- var o = $.extend( {}, default_options, options );
159
-
160
- reset( $(o.start_date_input),
161
- $(o.start_time),
162
- o.twentyfour_hour,
163
- o.date_format,
164
- o.now );
165
-
166
- return this;
167
- },
168
-
169
- /**
170
- * Destroy registered event handlers.
171
- */
172
- destroy: function( options )
173
- {
174
- options = $.extend( {}, default_options, options );
175
-
176
- $.each( options, function( option_name, value ) {
177
- $(value).unbind( '.timespan' );
178
- } );
179
- $(options.start_date_input).closest('form').unbind( '.timespan' );
180
-
181
- return this;
182
- }
183
- }
184
-
185
- /**
186
- * Main jQuery plugin definition
187
- */
188
-
189
- $.inputdate = function( arg )
190
- {
191
- // Method calling logic
192
- if( methods[arg] ) {
193
- return methods[arg].apply( this, Array.prototype.slice.call( arguments, 1 ));
194
- } else if( typeof arg === 'object' || ! arg ) {
195
- return methods.init.apply( this, arguments );
196
- } else {
197
- $.error( 'Method ' + arg + ' does not exist on jQuery.timespan' );
198
- }
199
- };
200
- })( jQuery );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/view/admin/js/jquery.timespan.js DELETED
@@ -1,374 +0,0 @@
1
- (function( $ )
2
- {
3
- /**
4
- * Private functions
5
- */
6
-
7
- // Helper function - reset contents of current field to stored original
8
- // value and alert user.
9
- function reset_invalid( field )
10
- {
11
- field
12
- .addClass( 'error' )
13
- .fadeOut( 'normal', function() {
14
- field
15
- .val( field.data( 'timespan.stored' ) )
16
- .removeClass( 'error' )
17
- .fadeIn( 'fast' );
18
- });
19
- }
20
-
21
- // Stores the value of the HTML element in context to its "stored" jQuery data.
22
- function store_value() {
23
- $(this).data( 'timespan.stored', this.value );
24
- }
25
-
26
- /**
27
- * Value initialization
28
- */
29
- function reset( start_date_input, start_time_input, start_time,
30
- end_date_input, end_time_input, end_time, allday, twentyfour_hour,
31
- date_format, now )
32
- {
33
- // Restore original values of fields when the page was loaded
34
- start_time.val( start_time.data( 'timespan.initial_value' ) );
35
- end_time.val( end_time.data( 'timespan.initial_value' ) );
36
- allday.get(0).checked = allday.data( 'timespan.initial_value' );
37
-
38
- // Fill out input fields with default date/time based on these original
39
- // values.
40
-
41
- var start = parseInt( start_time.val() );
42
- // If start_time field has a valid integer, use it, else use current time
43
- // rounded to nearest quarter-hour.
44
- if( ! isNaN( parseInt( start ) ) ) {
45
- start = new Date( parseInt( start ) * 1000 );
46
- start_time_input.val( formatTime( start.getUTCHours(), start.getUTCMinutes(), twentyfour_hour ) );
47
- } else {
48
- start = new Date( now );
49
- // Round minutes to nearest quarter-hour.
50
- start_time_input.val(
51
- formatTime( start.getUTCHours(), start.getUTCMinutes() - start.getUTCMinutes() % 15, twentyfour_hour ) );
52
- }
53
- start_date_input.val( formatDate( start, date_format ) );
54
-
55
- var end = parseInt( end_time.val() );
56
- // If end_time field has a valid integer, use it, else use start time plus
57
- // one hour.
58
- if( ! isNaN( parseInt( end ) ) ) {
59
- end = new Date( parseInt( end ) * 1000 );
60
- end_time_input.val( formatTime( end.getUTCHours(), end.getUTCMinutes(), twentyfour_hour ) );
61
- } else {
62
- end = new Date( start.getTime() + 3600000 );
63
- // Round minutes to nearest quarter-hour.
64
- end_time_input.val(
65
- formatTime( end.getUTCHours(), end.getUTCMinutes() - end.getUTCMinutes() % 15, twentyfour_hour ) );
66
- }
67
- // If all-day is checked, end date one day *before* last day of the span,
68
- // provided we were given an iCalendar-spec all-day timespan.
69
- if( allday.get(0).checked )
70
- end.setUTCDate( end.getUTCDate() - 1 );
71
- end_date_input.val( formatDate( end, date_format ) );
72
-
73
- // Trigger function (defined above) to internally store values of each
74
- // input field (used in calculations later).
75
- start_date_input.each( store_value );
76
- start_time_input.each( store_value );
77
- end_date_input.each( store_value );
78
- end_time_input.each( store_value );
79
-
80
- // Set up visibility of controls and Calendrical activation based on
81
- // original "checked" status of "All day" box.
82
- allday.trigger( 'change.timespan' );
83
- }
84
-
85
- /**
86
- * Private constants
87
- */
88
-
89
- var default_options = {
90
- allday: '#allday',
91
- start_date_input: '#start-date-input',
92
- start_time_input: '#start-time-input',
93
- start_time: '#start-time',
94
- end_date_input: '#end-date-input',
95
- end_time_input: '#end-time-input',
96
- end_time: '#end-time',
97
- twentyfour_hour: false,
98
- date_format: 'def',
99
- now: new Date(),
100
- };
101
-
102
- /**
103
- * Public methods
104
- */
105
-
106
- var methods = {
107
-
108
- /**
109
- * Initialize settings.
110
- */
111
- init: function( options )
112
- {
113
- var o = $.extend( {}, default_options, options );
114
-
115
- // Shortcut jQuery objects
116
- var allday = $(o.allday);
117
- var start_date_input = $(o.start_date_input);
118
- var start_time_input = $(o.start_time_input);
119
- var start_time = $(o.start_time);
120
- var end_date_input = $(o.end_date_input);
121
- var end_time_input = $(o.end_time_input);
122
- var end_time = $(o.end_time);
123
-
124
- var date_inputs = start_date_input.add( o.end_date_input );
125
- var time_inputs = start_time_input.add( o.end_time_input );
126
- var all_inputs = start_date_input.add( o.start_time_input )
127
- .add( o.end_date_input ).add( o.end_time_input );
128
-
129
- /**
130
- * Event handlers
131
- */
132
-
133
- // Save original (presumably valid) value of every input field upon focus.
134
- all_inputs.bind( 'focus.timespan', store_value );
135
-
136
- // When "All day" is toggled, show/hide time.
137
- var today = new Date( o.now.getFullYear(), o.now.getMonth(), o.now.getDate() );
138
- allday
139
- .bind( 'change.timespan', function() {
140
- if( this.checked ) {
141
- time_inputs.fadeOut();
142
- date_inputs.calendricalDateRange( {
143
- today: today, dateFormat: o.date_format, monthNames: o.month_names,
144
- dayNames: o.day_names, weekStartDay: o.week_start_day
145
- } );
146
- } else {
147
- time_inputs.fadeIn();
148
- all_inputs.calendricalDateTimeRange( {
149
- today: today, dateFormat: o.date_format, isoTime: o.twentyfour_hour,
150
- monthNames: o.month_names, dayNames: o.day_names, weekStartDay: o.week_start_day
151
- } );
152
- }
153
- } )
154
- .get().checked = false;
155
-
156
- // Validate and update saved value of DATE fields upon blur.
157
- date_inputs
158
- .bind( 'blur.timespan', function() {
159
- // Validate contents of this field.
160
- var date = parseDate( this.value, o.date_format );
161
- if( isNaN( date ) ) {
162
- // This field is invalid.
163
- reset_invalid( $(this) );
164
- } else {
165
- // Value is valid, so store it for later use (below).
166
- $(this).data( 'timespan.stored', this.value );
167
- // Re-format contents of field correctly (in case parsable but not
168
- // perfect).
169
- $(this).val( formatDate( date, o.date_format ) );
170
- }
171
- });
172
-
173
- // Validate and update saved value of TIME fields upon blur.
174
- time_inputs
175
- .bind( 'blur.timespan', function() {
176
- // Validate contents of this field.
177
- var time = parseTime( this.value );
178
- if( ! time ) {
179
- // This field is invalid.
180
- reset_invalid( $(this) );
181
- } else {
182
- // Value is valid, so store it for later use (below).
183
- $(this).data( 'timespan.stored', this.value );
184
- // Re-format contents of field correctly (in case parsable but not
185
- // perfect).
186
- $(this).val( formatTime( time.hour, time.minute, o.twentyfour_hour ) );
187
- }
188
- });
189
-
190
- // Gets the time difference between start and end dates
191
- function get_startend_time_difference() {
192
- var start_date_val = parseDate( start_date_input.val(), o.date_format ).getTime() / 1000;
193
- var start_time_val = parseTime( start_time_input.val() );
194
- start_date_val += start_time_val.hour * 3600 + start_time_val.minute * 60;
195
- var end_date_val = parseDate( end_date_input.val(), o.date_format ).getTime() / 1000;
196
- var end_time_val = parseTime( end_time_input.val() );
197
- end_date_val += end_time_val.hour * 3600 + end_time_val.minute * 60;
198
-
199
- return end_date_val - start_date_val;
200
- }
201
-
202
- function shift_jqts_enddate() {
203
- var start_date_val = parseDate( start_date_input.data( 'timespan.stored' ), o.date_format );
204
- var start_time_val = parseTime( start_time_input.data( 'timespan.stored' ) );
205
- var end_time_val = start_date_val.getTime() / 1000
206
- + start_time_val.hour * 3600 + start_time_val.minute * 60
207
- + start_date_input.data( 'time_diff' );
208
- end_time_val = new Date( end_time_val * 1000 );
209
- end_date_input.val( formatDate( end_time_val, o.date_format ) );
210
- end_time_input.val( formatTime( end_time_val.getUTCHours(), end_time_val.getUTCMinutes(), o.twentyfour_hour ) );
211
-
212
- return true;
213
- }
214
-
215
- // When start date/time are modified, update end date/time by shifting the
216
- // appropriate amount.
217
- start_date_input.add( o.start_time_input )
218
- .bind( 'focus.timespan', function() {
219
- // Calculate the time difference between start & end and save it.
220
- start_date_input.data( 'time_diff', get_startend_time_difference() );
221
- } )
222
- .bind( 'blur.timespan', function() {
223
- // If End date is earlier than StartDate, reset it to 15 mins after startDate
224
- if ( start_date_input.data( 'time_diff' ) < 0 ) {
225
- start_date_input.data( 'time_diff', 15 * 60 );
226
- }
227
- // Shift end date/time as appropriate.
228
- var shift_jqts = shift_jqts_enddate();
229
- } );
230
-
231
- // When end date/time is modified, check if it is earlier than start date/time and shift it if needed
232
- end_date_input.add( o.start_time_input )
233
- .bind( 'blur.timespan', function() {
234
- // If End date is earlier than StartDate, reset it to 15 mins after startDate
235
- if ( get_startend_time_difference() < 0 ) {
236
- start_date_input.data( 'time_diff', 15 * 60 );
237
- // Shift end date/time as appropriate.
238
- var shift_jqts = shift_jqts_enddate();
239
- }
240
- } );
241
-
242
- // Validation upon form submission
243
- start_date_input.closest( 'form' )
244
- .bind( 'submit.timespan', function() {
245
- // Update hidden field values with chosen date/time.
246
- //
247
- // 1. Start date/time
248
-
249
- // Convert Date object into UNIX timestamp for form submission
250
- var unix_start_time = parseDate( start_date_input.val(), o.date_format ).getTime() / 1000;
251
- // If parsed correctly, proceed to add the time.
252
- if( ! isNaN( unix_start_time ) ) {
253
- // Add time quantity to date, unless "All day" is checked.
254
- if( ! allday.get(0).checked ) {
255
- var time = parseTime( start_time_input.val() );
256
- // If parsed correctly, proceed add its value.
257
- if( time ) {
258
- unix_start_time += time.hour * 3600 + time.minute * 60;
259
- } else {
260
- // Else entire calculation is invalid.
261
- unix_start_time = '';
262
- }
263
- }
264
- } else {
265
- // Else entire calculation is invalid.
266
- unix_start_time = '';
267
- }
268
- // Set start date value to valid unix time, or empty string, depending
269
- // on above validation.
270
- start_time.val( unix_start_time );
271
-
272
- // 2. End date/time
273
-
274
- // Convert Date object into UNIX timestamp for form submission
275
- var unix_end_time = parseDate( end_date_input.val(), o.date_format ).getTime() / 1000;
276
- // If parsed correctly, proceed to add the time.
277
- if( ! isNaN( unix_end_time ) ) {
278
- // If "All day" is checked, store an end date that is one day
279
- // *after* the start date (following iCalendar spec).
280
- if( allday.get(0).checked ) {
281
- unix_end_time += 24 * 60 * 60;
282
- // Else add time quantity to date.
283
- } else {
284
- var time = parseTime( end_time_input.val() );
285
- // If parsed correctly, proceed add its value.
286
- if( time ) {
287
- unix_end_time += time.hour * 3600 + time.minute * 60;
288
- } else {
289
- // Else entire calculation is invalid.
290
- unix_end_time = '';
291
- }
292
- }
293
- } else {
294
- // Else entire calculation is invalid.
295
- unix_end_time = '';
296
- }
297
- // Set end date value to valid unix time, or empty string, depending
298
- // on above validation.
299
- end_time.val( unix_end_time );
300
- } );
301
-
302
- // Store original form values
303
- start_time.data( 'timespan.initial_value', start_time.val() );
304
- end_time.data( 'timespan.initial_value', end_time.val() );
305
- allday.data( 'timespan.initial_value', allday.get(0).checked );
306
-
307
- // Initialize input fields
308
- reset( start_date_input,
309
- start_time_input,
310
- start_time,
311
- end_date_input,
312
- end_time_input,
313
- end_time,
314
- allday,
315
- o.twentyfour_hour,
316
- o.date_format,
317
- o.now )
318
-
319
- return this;
320
- },
321
-
322
- /**
323
- * Reset values to defaults.
324
- */
325
- reset: function( options )
326
- {
327
- var o = $.extend( {}, default_options, options );
328
-
329
- reset( $(o.start_date_input),
330
- $(o.start_time_input),
331
- $(o.start_time),
332
- $(o.end_date_input),
333
- $(o.end_time_input),
334
- $(o.end_time),
335
- $(o.allday),
336
- o.twentyfour_hour,
337
- o.date_format,
338
- o.now );
339
-
340
- return this;
341
- },
342
-
343
- /**
344
- * Destroy registered event handlers.
345
- */
346
- destroy: function( options )
347
- {
348
- options = $.extend( {}, default_options, options );
349
-
350
- $.each( options, function( option_name, value ) {
351
- $(value).unbind( '.timespan' );
352
- } );
353
- $(options.start_date_input).closest('form').unbind( '.timespan' );
354
-
355
- return this;
356
- }
357
- }
358
-
359
- /**
360
- * Main jQuery plugin definition
361
- */
362
-
363
- $.timespan = function( arg )
364
- {
365
- // Method calling logic
366
- if( methods[arg] ) {
367
- return methods[arg].apply( this, Array.prototype.slice.call( arguments, 1 ));
368
- } else if( typeof arg === 'object' || ! arg ) {
369
- return methods.init.apply( this, arguments );
370
- } else {
371
- $.error( 'Method ' + arg + ' does not exist on jQuery.timespan' );
372
- }
373
- };
374
- })( jQuery );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/view/admin/js/jquery.tools.min.js DELETED
@@ -1,47 +0,0 @@
1
- /*!
2
- * jQuery Tools v1.2.6 - The missing UI library for the Web
3
- *
4
- * dateinput/dateinput.js
5
- * overlay/overlay.js
6
- * overlay/overlay.apple.js
7
- * rangeinput/rangeinput.js
8
- * scrollable/scrollable.js
9
- * scrollable/scrollable.autoscroll.js
10
- * scrollable/scrollable.navigator.js
11
- * toolbox/toolbox.expose.js
12
- * toolbox/toolbox.flashembed.js
13
- * toolbox/toolbox.history.js
14
- * toolbox/toolbox.mousewheel.js
15
- * tooltip/tooltip.js
16
- * tooltip/tooltip.dynamic.js
17
- * tooltip/tooltip.slide.js
18
- * validator/validator.js
19
- *
20
- * NO COPYRIGHTS OR LICENSES. DO WHAT YOU LIKE.
21
- *
22
- * http://flowplayer.org/tools/
23
- *
24
- * jquery.event.wheel.js - rev 1
25
- * Copyright (c) 2008, Three Dub Media (http://threedubmedia.com)
26
- * Liscensed under the MIT License (MIT-LICENSE.txt)
27
- * http://www.opensource.org/licenses/mit-license.php
28
- * Created: 2008-07-01 | Updated: 2008-07-14
29
- *
30
- * -----
31
- *
32
- */
33
- (function(a,b){a.tools=a.tools||{version:"v1.2.6"};var c=[],d,e=[75,76,38,39,74,72,40,37],f={};d=a.tools.dateinput={conf:{format:"mm/dd/yy",selectors:!1,yearRange:[-5,5],lang:"en",offset:[0,0],speed:0,firstDay:0,min:b,max:b,trigger:0,toggle:0,editable:0,css:{prefix:"cal",input:"date",root:0,head:0,title:0,prev:0,next:0,month:0,year:0,days:0,body:0,weeks:0,today:0,current:0,week:0,off:0,sunday:0,focus:0,disabled:0,trigger:0}},localize:function(b,c){a.each(c,function(a,b){c[a]=b.split(",")}),f[b]=c}},d.localize("en",{months:"January,February,March,April,May,June,July,August,September,October,November,December",shortMonths:"Jan,Feb,Mar,Apr,May,Jun,Jul,Aug,Sep,Oct,Nov,Dec",days:"Sunday,Monday,Tuesday,Wednesday,Thursday,Friday,Saturday",shortDays:"Sun,Mon,Tue,Wed,Thu,Fri,Sat"});function g(a,b){return(new Date(a,b+1,0)).getDate()}function h(a,b){a=""+a,b=b||2;while(a.length<b)a="0"+a;return a}var i=/d{1,4}|m{1,4}|yy(?:yy)?|"[^"]*"|'[^']*'/g,j=a("<a/>");function k(a,b,c){var d=a.getDate(),e=a.getDay(),g=a.getMonth(),k=a.getFullYear(),l={d:d,dd:h(d),ddd:f[c].shortDays[e],dddd:f[c].days[e],m:g+1,mm:h(g+1),mmm:f[c].shortMonths[g],mmmm:f[c].months[g],yy:String(k).slice(2),yyyy:k},m=b.replace(i,function(a){return a in l?l[a]:a.slice(1,a.length-1)});return j.html(m).html()}function l(a){return parseInt(a,10)}function m(a,b){return a.getFullYear()===b.getFullYear()&&a.getMonth()==b.getMonth()&&a.getDate()==b.getDate()}function n(a){if(a!==b){if(a.constructor==Date)return a;if(typeof a=="string"){var c=a.split("-");if(c.length==3)return new Date(l(c[0]),l(c[1])-1,l(c[2]));if(!/^-?\d+$/.test(a))return;a=l(a)}var d=new Date;d.setDate(d.getDate()+a);return d}}function o(d,h){var i=this,j=new Date,o=j.getFullYear(),p=h.css,q=f[h.lang],r=a("#"+p.root),s=r.find("#"+p.title),t,u,v,w,x,y,z=d.attr("data-value")||h.value||d.val(),A=d.attr("min")||h.min,B=d.attr("max")||h.max,C,D;A===0&&(A="0"),z=n(z)||j,A=n(A||new Date(o+h.yearRange[0],1,1)),B=n(B||new Date(o+h.yearRange[1]+1,1,-1));if(!q)throw"Dateinput: invalid language: "+h.lang;if(d.attr("type")=="date"){var D=d.clone(),E=D.wrap("<div/>").parent().html(),F=a(E.replace(/type/i,"type=text data-orig-type"));h.value&&F.val(h.value),d.replaceWith(F),d=F}d.addClass(p.input);var G=d.add(i);if(!r.length){r=a("<div><div><a/><div/><a/></div><div><div/><div/></div></div>").hide().css({position:"absolute"}).attr("id",p.root),r.children().eq(0).attr("id",p.head).end().eq(1).attr("id",p.body).children().eq(0).attr("id",p.days).end().eq(1).attr("id",p.weeks).end().end().end().find("a").eq(0).attr("id",p.prev).end().eq(1).attr("id",p.next),s=r.find("#"+p.head).find("div").attr("id",p.title);if(h.selectors){var H=a("<select/>").attr("id",p.month),I=a("<select/>").attr("id",p.year);s.html(H.add(I))}var J=r.find("#"+p.days);for(var K=0;K<7;K++)J.append(a("<span/>").text(q.shortDays[(K+h.firstDay)%7]));a("body").append(r)}h.trigger&&(t=a("<a/>").attr("href","#").addClass(p.trigger).click(function(a){h.toggle?i.toggle():i.show();return a.preventDefault()}).insertAfter(d));var L=r.find("#"+p.weeks);I=r.find("#"+p.year),H=r.find("#"+p.month);function M(b,c,e){z=b,w=b.getFullYear(),x=b.getMonth(),y=b.getDate(),e=e||a.Event("api"),e.type="beforeChange",G.trigger(e,[b]);e.isDefaultPrevented()||(d.val(k(b,c.format,c.lang)),e.type="change",G.trigger(e),d.data("date",b),i.hide(e))}function N(b){b.type="onShow",G.trigger(b),a(document).bind("keydown.d",function(b){if(b.ctrlKey)return!0;var c=b.keyCode;if(c==8){d.val("");return i.hide(b)}if(c==27||c==9)return i.hide(b);if(a(e).index(c)>=0){if(!C){i.show(b);return b.preventDefault()}var f=a("#"+p.weeks+" a"),g=a("."+p.focus),h=f.index(g);g.removeClass(p.focus);if(c==74||c==40)h+=7;else if(c==75||c==38)h-=7;else if(c==76||c==39)h+=1;else if(c==72||c==37)h-=1;h>41?(i.addMonth(),g=a("#"+p.weeks+" a:eq("+(h-42)+")")):h<0?(i.addMonth(-1),g=a("#"+p.weeks+" a:eq("+(h+42)+")")):g=f.eq(h),g.addClass(p.focus);return b.preventDefault()}if(c==34)return i.addMonth();if(c==33)return i.addMonth(-1);if(c==36)return i.today();c==13&&(a(b.target).is("select")||a("."+p.focus).click());return a([16,17,18,9]).index(c)>=0}),a(document).bind("click.d",function(b){var c=b.target;!a(c).parents("#"+p.root).length&&c!=d[0]&&(!t||c!=t[0])&&i.hide(b)})}a.extend(i,{show:function(b){if(!(d.attr("readonly")||d.attr("disabled")||C)){b=b||a.Event(),b.type="onBeforeShow",G.trigger(b);if(b.isDefaultPrevented())return;a.each(c,function(){this.hide()}),C=!0,H.unbind("change").change(function(){i.setValue(I.val(),a(this).val())}),I.unbind("change").change(function(){i.setValue(a(this).val(),H.val())}),u=r.find("#"+p.prev).unbind("click").click(function(a){u.hasClass(p.disabled)||i.addMonth(-1);return!1}),v=r.find("#"+p.next).unbind("click").click(function(a){v.hasClass(p.disabled)||i.addMonth();return!1}),i.setValue(z);var e=d.offset();/iPad/i.test(navigator.userAgent)&&(e.top-=a(window).scrollTop()),r.css({top:e.top+d.outerHeight({margins:!0})+h.offset[0],left:e.left+h.offset[1]}),h.speed?r.show(h.speed,function(){N(b)}):(r.show(),N(b));return i}},setValue:function(c,d,e){var f=l(d)>=-1?new Date(l(c),l(d),l(e==b||isNaN(e)?1:e)):c||z;f<A?f=A:f>B&&(f=B),typeof c=="string"&&(f=n(c)),c=f.getFullYear(),d=f.getMonth(),e=f.getDate(),d==-1?(d=11,c--):d==12&&(d=0,c++);if(!C){M(f,h);return i}x=d,w=c,y=e;var k=new Date(c,d,1-h.firstDay),o=k.getDay(),r=g(c,d),t=g(c,d-1),D;if(h.selectors){H.empty(),a.each(q.months,function(b,d){A<new Date(c,b+1,1)&&B>new Date(c,b,0)&&H.append(a("<option/>").html(d).attr("value",b))}),I.empty();var E=j.getFullYear();for(var F=E+h.yearRange[0];F<E+h.yearRange[1];F++)A<new Date(F+1,0,1)&&B>new Date(F,0,0)&&I.append(a("<option/>").text(F));H.val(d),I.val(c)}else s.html(q.months[d]+" "+c);L.empty(),u.add(v).removeClass(p.disabled);for(var G=o?0:-7,J,K;G<(o?42:35);G++)J=a("<a/>"),G%7===0&&(D=a("<div/>").addClass(p.week),L.append(D)),G<o?(J.addClass(p.off),K=t-o+G+1,f=new Date(c,d-1,K)):G<o+r?(K=G-o+1,f=new Date(c,d,K),m(z,f)?J.attr("id",p.current).addClass(p.focus):m(j,f)&&J.attr("id",p.today)):(J.addClass(p.off),K=G-r-o+1,f=new Date(c,d+1,K)),A&&f<A&&J.add(u).addClass(p.disabled),B&&f>B&&J.add(v).addClass(p.disabled),J.attr("href","#"+K).text(K).data("date",f),D.append(J);L.find("a").click(function(b){var c=a(this);c.hasClass(p.disabled)||(a("#"+p.current).removeAttr("id"),c.attr("id",p.current),M(c.data("date"),h,b));return!1}),p.sunday&&L.find(p.week).each(function(){var b=h.firstDay?7-h.firstDay:0;a(this).children().slice(b,b+1).addClass(p.sunday)});return i},setMin:function(a,b){A=n(a),b&&z<A&&i.setValue(A);return i},setMax:function(a,b){B=n(a),b&&z>B&&i.setValue(B);return i},today:function(){return i.setValue(j)},addDay:function(a){return this.setValue(w,x,y+(a||1))},addMonth:function(a){var b=x+(a||1),c=g(w,b),d=y<=c?y:c;return this.setValue(w,b,d)},addYear:function(a){return this.setValue(w+(a||1),x,y)},destroy:function(){d.add(document).unbind("click.d").unbind("keydown.d"),r.add(t).remove(),d.removeData("dateinput").removeClass(p.input),D&&d.replaceWith(D)},hide:function(b){if(C){b=a.Event(),b.type="onHide",G.trigger(b),a(document).unbind("click.d").unbind("keydown.d");if(b.isDefaultPrevented())return;r.hide(),C=!1}return i},toggle:function(){return i.isOpen()?i.hide():i.show()},getConf:function(){return h},getInput:function(){return d},getCalendar:function(){return r},getValue:function(a){return a?k(z,a,h.lang):z},isOpen:function(){return C}}),a.each(["onBeforeShow","onShow","change","onHide"],function(b,c){a.isFunction(h[c])&&a(i).bind(c,h[c]),i[c]=function(b){b&&a(i).bind(c,b);return i}}),h.editable||d.bind("focus.d click.d",i.show).keydown(function(b){var c=b.keyCode;if(!C&&a(e).index(c)>=0){i.show(b);return b.preventDefault()}return b.shiftKey||b.ctrlKey||b.altKey||c==9?!0:b.preventDefault()}),n(d.val())&&M(z,h)}a.expr[":"].date=function(b){var c=b.getAttribute("type");return c&&c=="date"||a(b).data("dateinput")},a.fn.dateinput=function(b){if(this.data("dateinput"))return this;b=a.extend(!0,{},d.conf,b),a.each(b.css,function(a,c){!c&&a!="prefix"&&(b.css[a]=(b.css.prefix||"")+(c||a))});var e;this.each(function(){var d=new o(a(this),b);c.push(d);var f=d.getInput().data("dateinput",d);e=e?e.add(f):f});return e?e:this}})(jQuery);
34
- (function(a){a.tools=a.tools||{version:"v1.2.6"},a.tools.overlay={addEffect:function(a,b,d){c[a]=[b,d]},conf:{close:null,closeOnClick:!0,closeOnEsc:!0,closeSpeed:"fast",effect:"default",fixed:!a.browser.msie||a.browser.version>6,left:"center",load:!1,mask:null,oneInstance:!0,speed:"normal",target:null,top:"10%"}};var b=[],c={};a.tools.overlay.addEffect("default",function(b,c){var d=this.getConf(),e=a(window);d.fixed||(b.top+=e.scrollTop(),b.left+=e.scrollLeft()),b.position=d.fixed?"fixed":"absolute",this.getOverlay().css(b).fadeIn(d.speed,c)},function(a){this.getOverlay().fadeOut(this.getConf().closeSpeed,a)});function d(d,e){var f=this,g=d.add(f),h=a(window),i,j,k,l=a.tools.expose&&(e.mask||e.expose),m=Math.random().toString().slice(10);l&&(typeof l=="string"&&(l={color:l}),l.closeOnClick=l.closeOnEsc=!1);var n=e.target||d.attr("rel");j=n?a(n):null||d;if(!j.length)throw"Could not find Overlay: "+n;d&&d.index(j)==-1&&d.click(function(a){f.load(a);return a.preventDefault()}),a.extend(f,{load:function(d){if(f.isOpened())return f;var i=c[e.effect];if(!i)throw"Overlay: cannot find effect : \""+e.effect+"\"";e.oneInstance&&a.each(b,function(){this.close(d)}),d=d||a.Event(),d.type="onBeforeLoad",g.trigger(d);if(d.isDefaultPrevented())return f;k=!0,l&&a(j).expose(l);var n=e.top,o=e.left,p=j.outerWidth({margin:!0}),q=j.outerHeight({margin:!0});typeof n=="string"&&(n=n=="center"?Math.max((h.height()-q)/2,0):parseInt(n,10)/100*h.height()),o=="center"&&(o=Math.max((h.width()-p)/2,0)),i[0].call(f,{top:n,left:o},function(){k&&(d.type="onLoad",g.trigger(d))}),l&&e.closeOnClick&&a.mask.getMask().one("click",f.close),e.closeOnClick&&a(document).bind("click."+m,function(b){a(b.target).parents(j).length||f.close(b)}),e.closeOnEsc&&a(document).bind("keydown."+m,function(a){a.keyCode==27&&f.close(a)});return f},close:function(b){if(!f.isOpened())return f;b=b||a.Event(),b.type="onBeforeClose",g.trigger(b);if(!b.isDefaultPrevented()){k=!1,c[e.effect][1].call(f,function(){b.type="onClose",g.trigger(b)}),a(document).unbind("click."+m).unbind("keydown."+m),l&&a.mask.close();return f}},getOverlay:function(){return j},getTrigger:function(){return d},getClosers:function(){return i},isOpened:function(){return k},getConf:function(){return e}}),a.each("onBeforeLoad,onStart,onLoad,onBeforeClose,onClose".split(","),function(b,c){a.isFunction(e[c])&&a(f).bind(c,e[c]),f[c]=function(b){b&&a(f).bind(c,b);return f}}),i=j.find(e.close||".close"),!i.length&&!e.close&&(i=a("<a class=\"close\"></a>"),j.prepend(i)),i.click(function(a){f.close(a)}),e.load&&f.load()}a.fn.overlay=function(c){var e=this.data("overlay");if(e)return e;a.isFunction(c)&&(c={onBeforeLoad:c}),c=a.extend(!0,{},a.tools.overlay.conf,c),this.each(function(){e=new d(a(this),c),b.push(e),a(this).data("overlay",e)});return c.api?e:this}})(jQuery);
35
- (function(a){var b=a.tools.overlay,c=a(window);a.extend(b.conf,{start:{top:null,left:null},fadeInSpeed:"fast",zIndex:9999});function d(a){var b=a.offset();return{top:b.top+a.height()/2,left:b.left+a.width()/2}}var e=function(b,e){var f=this.getOverlay(),g=this.getConf(),h=this.getTrigger(),i=this,j=f.outerWidth({margin:!0}),k=f.data("img"),l=g.fixed?"fixed":"absolute";if(!k){var m=f.css("backgroundImage");if(!m)throw"background-image CSS property not set for overlay";m=m.slice(m.indexOf("(")+1,m.indexOf(")")).replace(/\"/g,""),f.css("backgroundImage","none"),k=a("<img src=\""+m+"\"/>"),k.css({border:0,display:"none"}).width(j),a("body").append(k),f.data("img",k)}var n=g.start.top||Math.round(c.height()/2),o=g.start.left||Math.round(c.width()/2);if(h){var p=d(h);n=p.top,o=p.left}g.fixed?(n-=c.scrollTop(),o-=c.scrollLeft()):(b.top+=c.scrollTop(),b.left+=c.scrollLeft()),k.css({position:"absolute",top:n,left:o,width:0,zIndex:g.zIndex}).show(),b.position=l,f.css(b),k.animate({top:f.css("top"),left:f.css("left"),width:j},g.speed,function(){f.css("zIndex",g.zIndex+1).fadeIn(g.fadeInSpeed,function(){i.isOpened()&&!a(this).index(f)?e.call():f.hide()})}).css("position",l)},f=function(b){var e=this.getOverlay().hide(),f=this.getConf(),g=this.getTrigger(),h=e.data("img"),i={top:f.start.top,left:f.start.left,width:0};g&&a.extend(i,d(g)),f.fixed&&h.css({position:"absolute"}).animate({top:"+="+c.scrollTop(),left:"+="+c.scrollLeft()},0),h.animate(i,f.closeSpeed,b)};b.addEffect("apple",e,f)})(jQuery);
36
- (function(a){a.tools=a.tools||{version:"v1.2.6"};var b;b=a.tools.rangeinput={conf:{min:0,max:100,step:"any",steps:0,value:0,precision:undefined,vertical:0,keyboard:!0,progress:!1,speed:100,css:{input:"range",slider:"slider",progress:"progress",handle:"handle"}}};var c,d;a.fn.drag=function(b){document.ondragstart=function(){return!1},b=a.extend({x:!0,y:!0,drag:!0},b),c=c||a(document).bind("mousedown mouseup",function(e){var f=a(e.target);if(e.type=="mousedown"&&f.data("drag")){var g=f.position(),h=e.pageX-g.left,i=e.pageY-g.top,j=!0;c.bind("mousemove.drag",function(a){var c=a.pageX-h,e=a.pageY-i,g={};b.x&&(g.left=c),b.y&&(g.top=e),j&&(f.trigger("dragStart"),j=!1),b.drag&&f.css(g),f.trigger("drag",[e,c]),d=f}),e.preventDefault()}else try{d&&d.trigger("dragEnd")}finally{c.unbind("mousemove.drag"),d=null}});return this.data("drag",!0)};function e(a,b){var c=Math.pow(10,b);return Math.round(a*c)/c}function f(a,b){var c=parseInt(a.css(b),10);if(c)return c;var d=a[0].currentStyle;return d&&d.width&&parseInt(d.width,10)}function g(a){var b=a.data("events");return b&&b.onSlide}function h(b,c){var d=this,h=c.css,i=a("<div><div/><a href='#'/></div>").data("rangeinput",d),j,k,l,m,n;b.before(i);var o=i.addClass(h.slider).find("a").addClass(h.handle),p=i.find("div").addClass(h.progress);a.each("min,max,step,value".split(","),function(a,d){var e=b.attr(d);parseFloat(e)&&(c[d]=parseFloat(e,10))});var q=c.max-c.min,r=c.step=="any"?0:c.step,s=c.precision;if(s===undefined)try{s=r.toString().split(".")[1].length}catch(t){s=0}if(b.attr("type")=="range"){var u=b.clone().wrap("<div/>").parent().html(),v=a(u.replace(/type/i,"type=text data-orig-type"));v.val(c.value),b.replaceWith(v),b=v}b.addClass(h.input);var w=a(d).add(b),x=!0;function y(a,f,g,h){g===undefined?g=f/m*q:h&&(g-=c.min),r&&(g=Math.round(g/r)*r);if(f===undefined||r)f=g*m/q;if(isNaN(g))return d;f=Math.max(0,Math.min(f,m)),g=f/m*q;if(h||!j)g+=c.min;j&&(h?f=m-f:g=c.max-g),g=e(g,s);var i=a.type=="click";if(x&&k!==undefined&&!i){a.type="onSlide",w.trigger(a,[g,f]);if(a.isDefaultPrevented())return d}var l=i?c.speed:0,t=i?function(){a.type="change",w.trigger(a,[g])}:null;j?(o.animate({top:f},l,t),c.progress&&p.animate({height:m-f+o.height()/2},l)):(o.animate({left:f},l,t),c.progress&&p.animate({width:f+o.width()/2},l)),k=g,n=f,b.val(g);return d}a.extend(d,{getValue:function(){return k},setValue:function(b,c){z();return y(c||a.Event("api"),undefined,b,!0)},getConf:function(){return c},getProgress:function(){return p},getHandle:function(){return o},getInput:function(){return b},step:function(b,e){e=e||a.Event();var f=c.step=="any"?1:c.step;d.setValue(k+f*(b||1),e)},stepUp:function(a){return d.step(a||1)},stepDown:function(a){return d.step(-a||-1)}}),a.each("onSlide,change".split(","),function(b,e){a.isFunction(c[e])&&a(d).bind(e,c[e]),d[e]=function(b){b&&a(d).bind(e,b);return d}}),o.drag({drag:!1}).bind("dragStart",function(){z(),x=g(a(d))||g(b)}).bind("drag",function(a,c,d){if(b.is(":disabled"))return!1;y(a,j?c:d)}).bind("dragEnd",function(a){a.isDefaultPrevented()||(a.type="change",w.trigger(a,[k]))}).click(function(a){return a.preventDefault()}),i.click(function(a){if(b.is(":disabled")||a.target==o[0])return a.preventDefault();z();var c=j?o.height()/2:o.width()/2;y(a,j?m-l-c+a.pageY:a.pageX-l-c)}),c.keyboard&&b.keydown(function(c){if(!b.attr("readonly")){var e=c.keyCode,f=a([75,76,38,33,39]).index(e)!=-1,g=a([74,72,40,34,37]).index(e)!=-1;if((f||g)&&!(c.shiftKey||c.altKey||c.ctrlKey)){f?d.step(e==33?10:1,c):g&&d.step(e==34?-10:-1,c);return c.preventDefault()}}}),b.blur(function(b){var c=a(this).val();c!==k&&d.setValue(c,b)}),a.extend(b[0],{stepUp:d.stepUp,stepDown:d.stepDown});function z(){j=c.vertical||f(i,"height")>f(i,"width"),j?(m=f(i,"height")-f(o,"height"),l=i.offset().top+m):(m=f(i,"width")-f(o,"width"),l=i.offset().left)}function A(){z(),d.setValue(c.value!==undefined?c.value:c.min)}A(),m||a(window).load(A)}a.expr[":"].range=function(b){var c=b.getAttribute("type");return c&&c=="range"||a(b).filter("input").data("rangeinput")},a.fn.rangeinput=function(c){if(this.data("rangeinput"))return this;c=a.extend(!0,{},b.conf,c);var d;this.each(function(){var b=new h(a(this),a.extend(!0,{},c)),e=b.getInput().data("rangeinput",b);d=d?d.add(e):e});return d?d:this}})(jQuery);
37
- (function(a){a.tools=a.tools||{version:"v1.2.6"},a.tools.scrollable={conf:{activeClass:"active",circular:!1,clonedClass:"cloned",disabledClass:"disabled",easing:"swing",initialIndex:0,item:"> *",items:".items",keyboard:!0,mousewheel:!1,next:".next",prev:".prev",size:1,speed:400,vertical:!1,touch:!0,wheelSpeed:0}};function b(a,b){var c=parseInt(a.css(b),10);if(c)return c;var d=a[0].currentStyle;return d&&d.width&&parseInt(d.width,10)}function c(b,c){var d=a(c);return d.length<2?d:b.parent().find(c)}var d;function e(b,e){var f=this,g=b.add(f),h=b.children(),i=0,j=e.vertical;d||(d=f),h.length>1&&(h=a(e.items,b)),e.size>1&&(e.circular=!1),a.extend(f,{getConf:function(){return e},getIndex:function(){return i},getSize:function(){return f.getItems().size()},getNaviButtons:function(){return n.add(o)},getRoot:function(){return b},getItemWrap:function(){return h},getItems:function(){return h.find(e.item).not("."+e.clonedClass)},move:function(a,b){return f.seekTo(i+a,b)},next:function(a){return f.move(e.size,a)},prev:function(a){return f.move(-e.size,a)},begin:function(a){return f.seekTo(0,a)},end:function(a){return f.seekTo(f.getSize()-1,a)},focus:function(){d=f;return f},addItem:function(b){b=a(b),e.circular?(h.children().last().before(b),h.children().first().replaceWith(b.clone().addClass(e.clonedClass))):(h.append(b),o.removeClass("disabled")),g.trigger("onAddItem",[b]);return f},seekTo:function(b,c,k){b.jquery||(b*=1);if(e.circular&&b===0&&i==-1&&c!==0)return f;if(!e.circular&&b<0||b>f.getSize()||b<-1)return f;var l=b;b.jquery?b=f.getItems().index(b):l=f.getItems().eq(b);var m=a.Event("onBeforeSeek");if(!k){g.trigger(m,[b,c]);if(m.isDefaultPrevented()||!l.length)return f}var n=j?{top:-l.position().top}:{left:-l.position().left};i=b,d=f,c===undefined&&(c=e.speed),h.animate(n,c,e.easing,k||function(){g.trigger("onSeek",[b])});return f}}),a.each(["onBeforeSeek","onSeek","onAddItem"],function(b,c){a.isFunction(e[c])&&a(f).bind(c,e[c]),f[c]=function(b){b&&a(f).bind(c,b);return f}});if(e.circular){var k=f.getItems().slice(-1).clone().prependTo(h),l=f.getItems().eq(1).clone().appendTo(h);k.add(l).addClass(e.clonedClass),f.onBeforeSeek(function(a,b,c){if(!a.isDefaultPrevented()){if(b==-1){f.seekTo(k,c,function(){f.end(0)});return a.preventDefault()}b==f.getSize()&&f.seekTo(l,c,function(){f.begin(0)})}});var m=b.parents().add(b).filter(function(){if(a(this).css("display")==="none")return!0});m.length?(m.show(),f.seekTo(0,0,function(){}),m.hide()):f.seekTo(0,0,function(){})}var n=c(b,e.prev).click(function(a){a.stopPropagation(),f.prev()}),o=c(b,e.next).click(function(a){a.stopPropagation(),f.next()});e.circular||(f.onBeforeSeek(function(a,b){setTimeout(function(){a.isDefaultPrevented()||(n.toggleClass(e.disabledClass,b<=0),o.toggleClass(e.disabledClass,b>=f.getSize()-1))},1)}),e.initialIndex||n.addClass(e.disabledClass)),f.getSize()<2&&n.add(o).addClass(e.disabledClass),e.mousewheel&&a.fn.mousewheel&&b.mousewheel(function(a,b){if(e.mousewheel){f.move(b<0?1:-1,e.wheelSpeed||50);return!1}});if(e.touch){var p={};h[0].ontouchstart=function(a){var b=a.touches[0];p.x=b.clientX,p.y=b.clientY},h[0].ontouchmove=function(a){if(a.touches.length==1&&!h.is(":animated")){var b=a.touches[0],c=p.x-b.clientX,d=p.y-b.clientY;f[j&&d>0||!j&&c>0?"next":"prev"](),a.preventDefault()}}}e.keyboard&&a(document).bind("keydown.scrollable",function(b){if(!(!e.keyboard||b.altKey||b.ctrlKey||b.metaKey||a(b.target).is(":input"))){if(e.keyboard!="static"&&d!=f)return;var c=b.keyCode;if(j&&(c==38||c==40)){f.move(c==38?-1:1);return b.preventDefault()}if(!j&&(c==37||c==39)){f.move(c==37?-1:1);return b.preventDefault()}}}),e.initialIndex&&f.seekTo(e.initialIndex,0,function(){})}a.fn.scrollable=function(b){var c=this.data("scrollable");if(c)return c;b=a.extend({},a.tools.scrollable.conf,b),this.each(function(){c=new e(a(this),b),a(this).data("scrollable",c)});return b.api?c:this}})(jQuery);
38
- (function(a){var b=a.tools.scrollable;b.autoscroll={conf:{autoplay:!0,interval:3e3,autopause:!0}},a.fn.autoscroll=function(c){typeof c=="number"&&(c={interval:c});var d=a.extend({},b.autoscroll.conf,c),e;this.each(function(){var b=a(this).data("scrollable"),c=b.getRoot(),f,g=!1;function h(){f=setTimeout(function(){b.next()},d.interval)}b&&(e=b),b.play=function(){f||(g=!1,c.bind("onSeek",h),h())},b.pause=function(){f=clearTimeout(f),c.unbind("onSeek",h)},b.resume=function(){g||b.play()},b.stop=function(){g=!0,b.pause()},d.autopause&&c.add(b.getNaviButtons()).hover(b.pause,b.resume),d.autoplay&&b.play()});return d.api?e:this}})(jQuery);
39
- (function(a){var b=a.tools.scrollable;b.navigator={conf:{navi:".navi",naviItem:null,activeClass:"active",indexed:!1,idPrefix:null,history:!1}};function c(b,c){var d=a(c);return d.length<2?d:b.parent().find(c)}a.fn.navigator=function(d){typeof d=="string"&&(d={navi:d}),d=a.extend({},b.navigator.conf,d);var e;this.each(function(){var b=a(this).data("scrollable"),f=d.navi.jquery?d.navi:c(b.getRoot(),d.navi),g=b.getNaviButtons(),h=d.activeClass,i=d.history&&history.pushState,j=b.getConf().size;b&&(e=b),b.getNaviButtons=function(){return g.add(f)},i&&(history.pushState({i:0}),a(window).bind("popstate",function(a){var c=a.originalEvent.state;c&&b.seekTo(c.i)}));function k(a,c,d){b.seekTo(c),d.preventDefault(),i&&history.pushState({i:c})}function l(){return f.find(d.naviItem||"> *")}function m(b){var c=a("<"+(d.naviItem||"a")+"/>").click(function(c){k(a(this),b,c)});b===0&&c.addClass(h),d.indexed&&c.text(b+1),d.idPrefix&&c.attr("id",d.idPrefix+b);return c.appendTo(f)}l().length?l().each(function(b){a(this).click(function(c){k(a(this),b,c)})}):a.each(b.getItems(),function(a){a%j==0&&m(a)}),b.onBeforeSeek(function(a,b){setTimeout(function(){if(!a.isDefaultPrevented()){var c=b/j,d=l().eq(c);d.length&&l().removeClass(h).eq(c).addClass(h)}},1)}),b.onAddItem(function(a,c){var d=b.getItems().index(c);d%j==0&&m(d)})});return d.api?e:this}})(jQuery);
40
- (function(a){a.tools=a.tools||{version:"v1.2.6"};var b;b=a.tools.expose={conf:{maskId:"exposeMask",loadSpeed:"slow",closeSpeed:"fast",closeOnClick:!0,closeOnEsc:!0,zIndex:9998,opacity:.8,startOpacity:0,color:"#fff",onLoad:null,onClose:null}};function c(){if(a.browser.msie){var b=a(document).height(),c=a(window).height();return[window.innerWidth||document.documentElement.clientWidth||document.body.clientWidth,b-c<20?c:b]}return[a(document).width(),a(document).height()]}function d(b){if(b)return b.call(a.mask)}var e,f,g,h,i;a.mask={load:function(j,k){if(g)return this;typeof j=="string"&&(j={color:j}),j=j||h,h=j=a.extend(a.extend({},b.conf),j),e=a("#"+j.maskId),e.length||(e=a("<div/>").attr("id",j.maskId),a("body").append(e));var l=c();e.css({position:"absolute",top:0,left:0,width:l[0],height:l[1],display:"none",opacity:j.startOpacity,zIndex:j.zIndex}),j.color&&e.css("backgroundColor",j.color);if(d(j.onBeforeLoad)===!1)return this;j.closeOnEsc&&a(document).bind("keydown.mask",function(b){b.keyCode==27&&a.mask.close(b)}),j.closeOnClick&&e.bind("click.mask",function(b){a.mask.close(b)}),a(window).bind("resize.mask",function(){a.mask.fit()}),k&&k.length&&(i=k.eq(0).css("zIndex"),a.each(k,function(){var b=a(this);/relative|absolute|fixed/i.test(b.css("position"))||b.css("position","relative")}),f=k.css({zIndex:Math.max(j.zIndex+1,i=="auto"?0:i)})),e.css({display:"block"}).fadeTo(j.loadSpeed,j.opacity,function(){a.mask.fit(),d(j.onLoad),g="full"}),g=!0;return this},close:function(){if(g){if(d(h.onBeforeClose)===!1)return this;e.fadeOut(h.closeSpeed,function(){d(h.onClose),f&&f.css({zIndex:i}),g=!1}),a(document).unbind("keydown.mask"),e.unbind("click.mask"),a(window).unbind("resize.mask")}return this},fit:function(){if(g){var a=c();e.css({width:a[0],height:a[1]})}},getMask:function(){return e},isLoaded:function(a){return a?g=="full":g},getConf:function(){return h},getExposed:function(){return f}},a.fn.mask=function(b){a.mask.load(b);return this},a.fn.expose=function(b){a.mask.load(b,this);return this}})(jQuery);
41
- (function(){var a=document.all,b="http://www.adobe.com/go/getflashplayer",c=typeof jQuery=="function",d=/(\d+)[^\d]+(\d+)[^\d]*(\d*)/,e={width:"100%",height:"100%",id:"_"+(""+Math.random()).slice(9),allowfullscreen:!0,allowscriptaccess:"always",quality:"high",version:[3,0],onFail:null,expressInstall:null,w3c:!1,cachebusting:!1};window.attachEvent&&window.attachEvent("onbeforeunload",function(){__flash_unloadHandler=function(){},__flash_savedUnloadHandler=function(){}});function f(a,b){if(b)for(var c in b)b.hasOwnProperty(c)&&(a[c]=b[c]);return a}function g(a,b){var c=[];for(var d in a)a.hasOwnProperty(d)&&(c[d]=b(a[d]));return c}window.flashembed=function(a,b,c){typeof a=="string"&&(a=document.getElementById(a.replace("#","")));if(a){typeof b=="string"&&(b={src:b});return new j(a,f(f({},e),b),c)}};var h=f(window.flashembed,{conf:e,getVersion:function(){var a,b;try{b=navigator.plugins["Shockwave Flash"].description.slice(16)}catch(c){try{a=new ActiveXObject("ShockwaveFlash.ShockwaveFlash.7"),b=a&&a.GetVariable("$version")}catch(e){try{a=new ActiveXObject("ShockwaveFlash.ShockwaveFlash.6"),b=a&&a.GetVariable("$version")}catch(f){}}}b=d.exec(b);return b?[b[1],b[3]]:[0,0]},asString:function(a){if(a===null||a===undefined)return null;var b=typeof a;b=="object"&&a.push&&(b="array");switch(b){case"string":a=a.replace(new RegExp("([\"\\\\])","g"),"\\$1"),a=a.replace(/^\s?(\d+\.?\d*)%/,"$1pct");return"\""+a+"\"";case"array":return"["+g(a,function(a){return h.asString(a)}).join(",")+"]";case"function":return"\"function()\"";case"object":var c=[];for(var d in a)a.hasOwnProperty(d)&&c.push("\""+d+"\":"+h.asString(a[d]));return"{"+c.join(",")+"}"}return String(a).replace(/\s/g," ").replace(/\'/g,"\"")},getHTML:function(b,c){b=f({},b);var d="<object width=\""+b.width+"\" height=\""+b.height+"\" id=\""+b.id+"\" name=\""+b.id+"\"";b.cachebusting&&(b.src+=(b.src.indexOf("?")!=-1?"&":"?")+Math.random()),b.w3c||!a?d+=" data=\""+b.src+"\" type=\"application/x-shockwave-flash\"":d+=" classid=\"clsid:D27CDB6E-AE6D-11cf-96B8-444553540000\"",d+=">";if(b.w3c||a)d+="<param name=\"movie\" value=\""+b.src+"\" />";b.width=b.height=b.id=b.w3c=b.src=null,b.onFail=b.version=b.expressInstall=null;for(var e in b)b[e]&&(d+="<param name=\""+e+"\" value=\""+b[e]+"\" />");var g="";if(c){for(var i in c)if(c[i]){var j=c[i];g+=i+"="+encodeURIComponent(/function|object/.test(typeof j)?h.asString(j):j)+"&"}g=g.slice(0,-1),d+="<param name=\"flashvars\" value='"+g+"' />"}d+="</object>";return d},isSupported:function(a){return i[0]>a[0]||i[0]==a[0]&&i[1]>=a[1]}}),i=h.getVersion();function j(c,d,e){if(h.isSupported(d.version))c.innerHTML=h.getHTML(d,e);else if(d.expressInstall&&h.isSupported([6,65]))c.innerHTML=h.getHTML(f(d,{src:d.expressInstall}),{MMredirectURL:location.href,MMplayerType:"PlugIn",MMdoctitle:document.title});else{c.innerHTML.replace(/\s/g,"")||(c.innerHTML="<h2>Flash version "+d.version+" or greater is required</h2><h3>"+(i[0]>0?"Your version is "+i:"You have no flash plugin installed")+"</h3>"+(c.tagName=="A"?"<p>Click here to download latest version</p>":"<p>Download latest version from <a href='"+b+"'>here</a></p>"),c.tagName=="A"&&(c.onclick=function(){location.href=b}));if(d.onFail){var g=d.onFail.call(this);typeof g=="string"&&(c.innerHTML=g)}}a&&(window[d.id]=document.getElementById(d.id)),f(this,{getRoot:function(){return c},getOptions:function(){return d},getConf:function(){return e},getApi:function(){return c.firstChild}})}c&&(jQuery.tools=jQuery.tools||{version:"v1.2.6"},jQuery.tools.flashembed={conf:e},jQuery.fn.flashembed=function(a,b){return this.each(function(){jQuery(this).data("flashembed",flashembed(this,a,b))})})})();
42
- (function(a){var b,c,d,e;a.tools=a.tools||{version:"v1.2.6"},a.tools.history={init:function(g){e||(a.browser.msie&&a.browser.version<"8"?c||(c=a("<iframe/>").attr("src","javascript:false;").hide().get(0),a("body").prepend(c),setInterval(function(){var d=c.contentWindow.document,e=d.location.hash;b!==e&&a(window).trigger("hash",e)},100),f(location.hash||"#")):setInterval(function(){var c=location.hash;c!==b&&a(window).trigger("hash",c)},100),d=d?d.add(g):g,g.click(function(b){var d=a(this).attr("href");c&&f(d);if(d.slice(0,1)!="#"){location.href="#"+d;return b.preventDefault()}}),e=!0)}};function f(a){if(a){var b=c.contentWindow.document;b.open().close(),b.location.hash=a}}a(window).bind("hash",function(c,e){e?d.filter(function(){var b=a(this).attr("href");return b==e||b==e.replace("#","")}).trigger("history",[e]):d.eq(0).trigger("history",[e]),b=e}),a.fn.history=function(b){a.tools.history.init(this);return this.bind("history",b)}})(jQuery);
43
- (function(a){a.fn.mousewheel=function(a){return this[a?"bind":"trigger"]("wheel",a)},a.event.special.wheel={setup:function(){a.event.add(this,b,c,{})},teardown:function(){a.event.remove(this,b,c)}};var b=a.browser.mozilla?"DOMMouseScroll"+(a.browser.version<"1.9"?" mousemove":""):"mousewheel";function c(b){switch(b.type){case"mousemove":return a.extend(b.data,{clientX:b.clientX,clientY:b.clientY,pageX:b.pageX,pageY:b.pageY});case"DOMMouseScroll":a.extend(b,b.data),b.delta=-b.detail/3;break;case"mousewheel":b.delta=b.wheelDelta/120}b.type="wheel";return a.event.handle.call(this,b,b.delta)}})(jQuery);
44
- (function(a){a.tools=a.tools||{version:"v1.2.6"},a.tools.tooltip={conf:{effect:"toggle",fadeOutSpeed:"fast",predelay:0,delay:30,opacity:1,tip:0,fadeIE:!1,position:["top","center"],offset:[0,0],relative:!1,cancelDefault:!0,events:{def:"mouseenter,mouseleave",input:"focus,blur",widget:"focus mouseenter,blur mouseleave",tooltip:"mouseenter,mouseleave"},layout:"<div/>",tipClass:"tooltip"},addEffect:function(a,c,d){b[a]=[c,d]}};var b={toggle:[function(a){var b=this.getConf(),c=this.getTip(),d=b.opacity;d<1&&c.css({opacity:d}),c.show(),a.call()},function(a){this.getTip().hide(),a.call()}],fade:[function(b){var c=this.getConf();!a.browser.msie||c.fadeIE?this.getTip().fadeTo(c.fadeInSpeed,c.opacity,b):(this.getTip().show(),b())},function(b){var c=this.getConf();!a.browser.msie||c.fadeIE?this.getTip().fadeOut(c.fadeOutSpeed,b):(this.getTip().hide(),b())}]};function c(b,c,d){var e=d.relative?b.position().top:b.offset().top,f=d.relative?b.position().left:b.offset().left,g=d.position[0];e-=c.outerHeight()-d.offset[0],f+=b.outerWidth()+d.offset[1],/iPad/i.test(navigator.userAgent)&&(e-=a(window).scrollTop());var h=c.outerHeight()+b.outerHeight();g=="center"&&(e+=h/2),g=="bottom"&&(e+=h),g=d.position[1];var i=c.outerWidth()+b.outerWidth();g=="center"&&(f-=i/2),g=="left"&&(f-=i);return{top:e,left:f}}function d(d,e){var f=this,g=d.add(f),h,i=0,j=0,k=d.attr("title"),l=d.attr("data-tooltip"),m=b[e.effect],n,o=d.is(":input"),p=o&&d.is(":checkbox, :radio, select, :button, :submit"),q=d.attr("type"),r=e.events[q]||e.events[o?p?"widget":"input":"def"];if(!m)throw"Nonexistent effect \""+e.effect+"\"";r=r.split(/,\s*/);if(r.length!=2)throw"Tooltip: bad events configuration for "+q;d.bind(r[0],function(a){clearTimeout(i),e.predelay?j=setTimeout(function(){f.show(a)},e.predelay):f.show(a)}).bind(r[1],function(a){clearTimeout(j),e.delay?i=setTimeout(function(){f.hide(a)},e.delay):f.hide(a)}),k&&e.cancelDefault&&(d.removeAttr("title"),d.data("title",k)),a.extend(f,{show:function(b){if(!h){l?h=a(l):e.tip?h=a(e.tip).eq(0):k?h=a(e.layout).addClass(e.tipClass).appendTo(document.body).hide().append(k):(h=d.next(),h.length||(h=d.parent().next()));if(!h.length)throw"Cannot find tooltip for "+d}if(f.isShown())return f;h.stop(!0,!0);var o=c(d,h,e);e.tip&&h.html(d.data("title")),b=a.Event(),b.type="onBeforeShow",g.trigger(b,[o]);if(b.isDefaultPrevented())return f;o=c(d,h,e),h.css({position:"absolute",top:o.top,left:o.left}),n=!0,m[0].call(f,function(){b.type="onShow",n="full",g.trigger(b)});var p=e.events.tooltip.split(/,\s*/);h.data("__set")||(h.unbind(p[0]).bind(p[0],function(){clearTimeout(i),clearTimeout(j)}),p[1]&&!d.is("input:not(:checkbox, :radio), textarea")&&h.unbind(p[1]).bind(p[1],function(a){a.relatedTarget!=d[0]&&d.trigger(r[1].split(" ")[0])}),e.tip||h.data("__set",!0));return f},hide:function(c){if(!h||!f.isShown())return f;c=a.Event(),c.type="onBeforeHide",g.trigger(c);if(!c.isDefaultPrevented()){n=!1,b[e.effect][1].call(f,function(){c.type="onHide",g.trigger(c)});return f}},isShown:function(a){return a?n=="full":n},getConf:function(){return e},getTip:function(){return h},getTrigger:function(){return d}}),a.each("onHide,onBeforeShow,onShow,onBeforeHide".split(","),function(b,c){a.isFunction(e[c])&&a(f).bind(c,e[c]),f[c]=function(b){b&&a(f).bind(c,b);return f}})}a.fn.tooltip=function(b){var c=this.data("tooltip");if(c)return c;b=a.extend(!0,{},a.tools.tooltip.conf,b),typeof b.position=="string"&&(b.position=b.position.split(/,?\s/)),this.each(function(){c=new d(a(this),b),a(this).data("tooltip",c)});return b.api?c:this}})(jQuery);
45
- (function(a){var b=a.tools.tooltip;b.dynamic={conf:{classNames:"top right bottom left"}};function c(b){var c=a(window),d=c.width()+c.scrollLeft(),e=c.height()+c.scrollTop();return[b.offset().top<=c.scrollTop(),d<=b.offset().left+b.width(),e<=b.offset().top+b.height(),c.scrollLeft()>=b.offset().left]}function d(a){var b=a.length;while(b--)if(a[b])return!1;return!0}a.fn.dynamic=function(e){typeof e=="number"&&(e={speed:e}),e=a.extend({},b.dynamic.conf,e);var f=a.extend(!0,{},e),g=e.classNames.split(/\s/),h;this.each(function(){var b=a(this).tooltip().onBeforeShow(function(b,e){var i=this.getTip(),j=this.getConf();h||(h=[j.position[0],j.position[1],j.offset[0],j.offset[1],a.extend({},j)]),a.extend(j,h[4]),j.position=[h[0],h[1]],j.offset=[h[2],h[3]],i.css({visibility:"hidden",position:"absolute",top:e.top,left:e.left}).show();var k=a.extend(!0,{},f),l=c(i);if(!d(l)){l[2]&&(a.extend(j,k.top),j.position[0]="top",i.addClass(g[0])),l[3]&&(a.extend(j,k.right),j.position[1]="right",i.addClass(g[1])),l[0]&&(a.extend(j,k.bottom),j.position[0]="bottom",i.addClass(g[2])),l[1]&&(a.extend(j,k.left),j.position[1]="left",i.addClass(g[3]));if(l[0]||l[2])j.offset[0]*=-1;if(l[1]||l[3])j.offset[1]*=-1}i.css({visibility:"visible"}).hide()});b.onBeforeShow(function(){var a=this.getConf(),b=this.getTip();setTimeout(function(){a.position=[h[0],h[1]],a.offset=[h[2],h[3]]},0)}),b.onHide(function(){var a=this.getTip();a.removeClass(e.classNames)}),ret=b});return e.api?ret:this}})(jQuery);
46
- (function(a){var b=a.tools.tooltip;a.extend(b.conf,{direction:"up",bounce:!1,slideOffset:10,slideInSpeed:200,slideOutSpeed:200,slideFade:!a.browser.msie});var c={up:["-","top"],down:["+","top"],left:["-","left"],right:["+","left"]};b.addEffect("slide",function(a){var b=this.getConf(),d=this.getTip(),e=b.slideFade?{opacity:b.opacity}:{},f=c[b.direction]||c.up;e[f[1]]=f[0]+"="+b.slideOffset,b.slideFade&&d.css({opacity:0}),d.show().animate(e,b.slideInSpeed,a)},function(b){var d=this.getConf(),e=d.slideOffset,f=d.slideFade?{opacity:0}:{},g=c[d.direction]||c.up,h=""+g[0];d.bounce&&(h=h=="+"?"-":"+"),f[g[1]]=h+"="+e,this.getTip().animate(f,d.slideOutSpeed,function(){a(this).hide(),b.call()})})})(jQuery);
47
- (function(a){a.tools=a.tools||{version:"v1.2.6"};var b=/\[type=([a-z]+)\]/,c=/^-?[0-9]*(\.[0-9]+)?$/,d=a.tools.dateinput,e=/^([a-z0-9_\.\-\+]+)@([\da-z\.\-]+)\.([a-z\.]{2,6})$/i,f=/^(https?:\/\/)?[\da-z\.\-]+\.[a-z\.]{2,6}[#&+_\?\/\w \.\-=]*$/i,g;g=a.tools.validator={conf:{grouped:!1,effect:"default",errorClass:"invalid",inputEvent:null,errorInputEvent:"keyup",formEvent:"submit",lang:"en",message:"<div/>",messageAttr:"data-message",messageClass:"error",offset:[0,0],position:"center right",singleError:!1,speed:"normal"},messages:{"*":{en:"Please correct this value"}},localize:function(b,c){a.each(c,function(a,c){g.messages[a]=g.messages[a]||{},g.messages[a][b]=c})},localizeFn:function(b,c){g.messages[b]=g.messages[b]||{},a.extend(g.messages[b],c)},fn:function(c,d,e){a.isFunction(d)?e=d:(typeof d=="string"&&(d={en:d}),this.messages[c.key||c]=d);var f=b.exec(c);f&&(c=i(f[1])),j.push([c,e])},addEffect:function(a,b,c){k[a]=[b,c]}};function h(b,c,d){var e=b.offset().top,f=b.offset().left,g=d.position.split(/,?\s+/),h=g[0],i=g[1];e-=c.outerHeight()-d.offset[0],f+=b.outerWidth()+d.offset[1],/iPad/i.test(navigator.userAgent)&&(e-=a(window).scrollTop());var j=c.outerHeight()+b.outerHeight();h=="center"&&(e+=j/2),h=="bottom"&&(e+=j);var k=b.outerWidth();i=="center"&&(f-=(k+c.outerWidth())/2),i=="left"&&(f-=k);return{top:e,left:f}}function i(a){function b(){return this.getAttribute("type")==a}b.key="[type="+a+"]";return b}var j=[],k={"default":[function(b){var c=this.getConf();a.each(b,function(b,d){var e=d.input;e.addClass(c.errorClass);var f=e.data("msg.el");f||(f=a(c.message).addClass(c.messageClass).appendTo(document.body),e.data("msg.el",f)),f.css({visibility:"hidden"}).find("p").remove(),a.each(d.messages,function(b,c){a("<p/>").html(c).appendTo(f)}),f.outerWidth()==f.parent().width()&&f.add(f.find("p")).css({display:"inline"});var g=h(e,f,c);f.css({visibility:"visible",position:"absolute",top:g.top,left:g.left}).fadeIn(c.speed)})},function(b){var c=this.getConf();b.removeClass(c.errorClass).each(function(){var b=a(this).data("msg.el");b&&b.css({visibility:"hidden"})})}]};a.each("email,url,number".split(","),function(b,c){a.expr[":"][c]=function(a){return a.getAttribute("type")===c}}),a.fn.oninvalid=function(a){return this[a?"bind":"trigger"]("OI",a)},g.fn(":email","Please enter a valid email address",function(a,b){return!b||e.test(b)}),g.fn(":url","Please enter a valid URL",function(a,b){return!b||f.test(b)}),g.fn(":number","Please enter a numeric value.",function(a,b){return c.test(b)}),g.fn("[max]","Please enter a value no larger than $1",function(a,b){if(b===""||d&&a.is(":date"))return!0;var c=a.attr("max");return parseFloat(b)<=parseFloat(c)?!0:[c]}),g.fn("[min]","Please enter a value of at least $1",function(a,b){if(b===""||d&&a.is(":date"))return!0;var c=a.attr("min");return parseFloat(b)>=parseFloat(c)?!0:[c]}),g.fn("[required]","Please complete this mandatory field.",function(a,b){if(a.is(":checkbox"))return a.is(":checked");return b}),g.fn("[pattern]",function(a){var b=new RegExp("^"+a.attr("pattern")+"$");return b.test(a.val())});function l(b,c,e){var f=this,i=c.add(f);b=b.not(":button, :image, :reset, :submit"),c.attr("novalidate","novalidate");function l(b,c,d){if(e.grouped||!b.length){var f;if(d===!1||a.isArray(d)){f=g.messages[c.key||c]||g.messages["*"],f=f[e.lang]||g.messages["*"].en;var h=f.match(/\$\d/g);h&&a.isArray(d)&&a.each(h,function(a){f=f.replace(this,d[a])})}else f=d[e.lang]||d;b.push(f)}}a.extend(f,{getConf:function(){return e},getForm:function(){return c},getInputs:function(){return b},reflow:function(){b.each(function(){var b=a(this),c=b.data("msg.el");if(c){var d=h(b,c,e);c.css({top:d.top,left:d.left})}});return f},invalidate:function(c,d){if(!d){var g=[];a.each(c,function(a,c){var d=b.filter("[name='"+a+"']");d.length&&(d.trigger("OI",[c]),g.push({input:d,messages:[c]}))}),c=g,d=a.Event()}d.type="onFail",i.trigger(d,[c]),d.isDefaultPrevented()||k[e.effect][0].call(f,c,d);return f},reset:function(c){c=c||b,c.removeClass(e.errorClass).each(function(){var b=a(this).data("msg.el");b&&(b.remove(),a(this).data("msg.el",null))}).unbind(e.errorInputEvent||"");return f},destroy:function(){c.unbind(e.formEvent+".V").unbind("reset.V"),b.unbind(e.inputEvent+".V").unbind("change.V");return f.reset()},checkValidity:function(c,g){c=c||b,c=c.not(":disabled");if(!c.length)return!0;g=g||a.Event(),g.type="onBeforeValidate",i.trigger(g,[c]);if(g.isDefaultPrevented())return g.result;var h=[];c.not(":radio:not(:checked)").each(function(){var b=[],c=a(this).data("messages",b),k=d&&c.is(":date")?"onHide.v":e.errorInputEvent+".v";c.unbind(k),a.each(j,function(){var a=this,d=a[0];if(c.filter(d).length){var h=a[1].call(f,c,c.val());if(h!==!0){g.type="onBeforeFail",i.trigger(g,[c,d]);if(g.isDefaultPrevented())return!1;var j=c.attr(e.messageAttr);if(j){b=[j];return!1}l(b,d,h)}}}),b.length&&(h.push({input:c,messages:b}),c.trigger("OI",[b]),e.errorInputEvent&&c.bind(k,function(a){f.checkValidity(c,a)}));if(e.singleError&&h.length)return!1});var m=k[e.effect];if(!m)throw"Validator: cannot find effect \""+e.effect+"\"";if(h.length){f.invalidate(h,g);return!1}m[1].call(f,c,g),g.type="onSuccess",i.trigger(g,[c]),c.unbind(e.errorInputEvent+".v");return!0}}),a.each("onBeforeValidate,onBeforeFail,onFail,onSuccess".split(","),function(b,c){a.isFunction(e[c])&&a(f).bind(c,e[c]),f[c]=function(b){b&&a(f).bind(c,b);return f}}),e.formEvent&&c.bind(e.formEvent+".V",function(a){if(!f.checkValidity(null,a))return a.preventDefault();a.target=c,a.type=e.formEvent}),c.bind("reset.V",function(){f.reset()}),b[0]&&b[0].validity&&b.each(function(){this.oninvalid=function(){return!1}}),c[0]&&(c[0].checkValidity=f.checkValidity),e.inputEvent&&b.bind(e.inputEvent+".V",function(b){f.checkValidity(a(this),b)}),b.filter(":checkbox, select").filter("[required]").bind("change.V",function(b){var c=a(this);(this.checked||c.is("select")&&a(this).val())&&k[e.effect][1].call(f,c,b)});var m=b.filter(":radio").change(function(a){f.checkValidity(m,a)});a(window).resize(function(){f.reflow()})}a.fn.validator=function(b){var c=this.data("validator");c&&(c.destroy(),this.removeData("validator")),b=a.extend(!0,{},g.conf,b);if(this.is("form"))return this.each(function(){var d=a(this);c=new l(d.find(":input"),d,b),d.data("validator",c)});c=new l(this,this.eq(0).closest("form"),b);return this.data("validator",c)}})(jQuery);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/view/admin/js/platform-all.js DELETED
@@ -1,11 +0,0 @@
1
- jQuery( function( $ ) {
2
- // Disable the "Front page" option in WP General Settings.
3
- if( $( 'body.options-reading-php' ).length ) {
4
- function disable_front_page_option() {
5
- $( '#page_on_front' ).attr( 'disabled', 'disabled' );
6
- }
7
- disable_front_page_option();
8
- $( '#front-static-pages input:radio' ).change(disable_front_page_option);
9
- $( '#page_on_front' ).after( '<span class="description">' + ai1ec_platform_all.page_on_front_description + '</span>' );
10
- }
11
- });
 
 
 
 
 
 
 
 
 
 
 
app/view/admin/js/platform.js DELETED
@@ -1,15 +0,0 @@
1
- jQuery( function( $ ) {
2
- // If in strict mode, hide all administrative functions other than event, user
3
- // and media management.
4
- if ( ai1ec_platform.strict_mode ) {
5
- $( '#dashboard-widgets .postbox' )
6
- .not( '#ai1ec-calendar-tasks, #dashboard_right_now' )
7
- .remove();
8
- $( '#adminmenu > li' )
9
- .not( '.wp-menu-separator, #menu-dashboard, #menu-posts-ai1ec_event, #menu-media, #menu-appearance, #menu-users, #menu-settings' )
10
- .remove();
11
- $( '#menu-appearance > .wp-submenu li, #menu-settings > .wp-submenu li' )
12
- .not( ':has(a[href*="all-in-one-event-calendar"])' )
13
- .remove();
14
- }
15
- });
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/view/admin/js/settings.js DELETED
@@ -1,4 +0,0 @@
1
- jQuery( function( $ ) {
2
- $( '.if-js-closed' ).removeClass( 'if-js-closed' ).addClass( 'closed' );
3
- postboxes.add_postbox_toggles( ai1ec_settings.page );
4
- });
 
 
 
 
app/view/admin/js/widget.js DELETED
@@ -1,6 +0,0 @@
1
- jQuery( function( $ ) {
2
- // Show/hide the multiselect containers when user clicks on "limit by" widget options
3
- $( '.ai1ec-limit-by-cat, .ai1ec-limit-by-tag, .ai1ec-limit-by-event' ).live( 'click', function() {
4
- $( this ).parent().next( '.ai1ec-limit-by-options-container' ).toggle();
5
- } );
6
- } );
 
 
 
 
 
 
app/view/admin/less/bootstrap.less DELETED
@@ -1,355 +0,0 @@
1
- /*!
2
- * Bootstrap v2.0.2
3
- *
4
- * Copyright 2012 Twitter, Inc
5
- * Licensed under the Apache License v2.0
6
- * http://www.apache.org/licenses/LICENSE-2.0
7
- *
8
- * Designed and built with all the love in the world @twitter by @mdo and @fat.
9
- */
10
-
11
- // Fonts
12
- @import url("http://fonts.googleapis.com/css?family=Signika:300");
13
- @import url("http://fonts.googleapis.com/css?family=Signika:600");
14
-
15
- /* Timely Icons font - loading */
16
-
17
- @font-face {
18
- font-family: 'Timely Icons';
19
- src:url('../font/timely-icons.eot');
20
- src:url('../font/timely-icons.eot?#iefix') format('embedded-opentype'),
21
- url('../font/timely-icons.svg#Timely-Icons') format('svg'),
22
- url('../font/timely-icons.woff') format('woff'),
23
- url('../font/timely-icons.ttf') format('truetype');
24
- font-weight: normal;
25
- font-style: normal;
26
- }
27
-
28
- [class^="timely-icon-"]:before, [class*=" timely-icon-"]:before {
29
- display: inline-block;
30
- font-family: 'Timely Icons';
31
- font-style: normal;
32
- font-weight: normal;
33
- speak: none;
34
- vertical-align: top;
35
- }
36
- .timely-icon-large:before {
37
- font-size: 1.25em;
38
- }
39
-
40
- /* Timely Icons font - Bootstrap-related accommodations */
41
-
42
- .timely .btn .timely-icon-large[class^="timely-icon-"],
43
- .timely .btn .timely-icon-large[class*=" timely-icon-"] {
44
- line-height: 1.1em;
45
- }
46
- .timely li [class^="timely-icon-"],
47
- .timely li [class*=" timely-icon-"] {
48
- display: inline-block;
49
- text-align: center;
50
- width: 1.25em;
51
- }
52
- .timely li .timely-icon-large[class^="timely-icon-"],
53
- .timely li .timely-icon-large[class*=" timely-icon-"] {
54
- width: 1.875em;
55
- }
56
- .timely li[class^="timely-icon-"],
57
- .timely li[class*=" timely-icon-"] {
58
- list-style-type: none;
59
- margin-left: 0;
60
- }
61
- .timely li[class^="timely-icon-"]:before,
62
- .timely li[class*=" timely-icon-"]:before {
63
- text-align: center;
64
- text-indent: -2em;
65
- }
66
- .timely li[class^="timely-icon-"].timely-icon-large:before,
67
- .timely li[class*=" timely-icon-"].icon-large:before {
68
- text-indent: -1.3333333333333333em;
69
- }
70
-
71
- /* Timely Icons font - shortcut classes */
72
-
73
- .timely-icon-timely-logomark:before {
74
- content: "\21";
75
- }
76
- .timely-icon-import-events:before {
77
- content: "\22";
78
- }
79
- .timely-icon-export-events:before {
80
- content: "\23";
81
- }
82
- .timely-icon-facebook-sync:before {
83
- content: "\24";
84
- }
85
- .timely-icon-filter-tag-category:before {
86
- content: "\25";
87
- }
88
- .timely-icon-subscribe-events:before {
89
- content: "\26";
90
- }
91
- .timely-icon-recurring-events:before {
92
- content: "\27";
93
- }
94
- .timely-icon-multiple-views:before {
95
- content: "\28";
96
- }
97
- .timely-icon-customizable-views:before {
98
- content: "\29";
99
- }
100
- .timely-icon-upcoming-events-widget:before {
101
- content: "\2a";
102
- }
103
- .timely-icon-locations-maps:before {
104
- content: "\2b";
105
- }
106
- .timely-icon-seo-optimized:before {
107
- content: "\2c";
108
- }
109
- .timely-icon-dedicated-support:before {
110
- content: "\2d";
111
- font-size: 1.2em;
112
- }
113
- .timely-icon-plus-sign:before {
114
- content: "\2e";
115
- }
116
- .timely-icon-minus-sign:before {
117
- content: "\2f";
118
- }
119
- .timely-icon-pencil:before {
120
- content: "\3c";
121
- }
122
- .timely-icon-gear:before {
123
- content: "\3e";
124
- }
125
- .timely-icon-tag:before {
126
- content: "\3f";
127
- }
128
- .timely-icon-forward:before {
129
- content: "\3b";
130
- }
131
- .timely-icon-close:before {
132
- content: "\3a";
133
- }
134
- .timely-icon-heart:before {
135
- content: "\3d";
136
- }
137
- .timely-icon-folder:before {
138
- content: "\40";
139
- }
140
- .timely-icon-grid:before {
141
- content: "\41";
142
- }
143
- .timely-icon-print:before {
144
- content: "\38";
145
- }
146
- .timely-icon-share:before {
147
- content: "\39";
148
- }
149
- .timely-icon-event:before {
150
- content: "\44";
151
- }
152
- .timely-icon-location:before {
153
- content: "\45";
154
- }
155
- .timely-icon-arrow-right:before {
156
- content: "\46";
157
- }
158
- .timely-icon-arrow-up:before {
159
- content: "\47";
160
- }
161
- .timely-icon-arrow-down:before {
162
- content: "\48";
163
- }
164
- .timely-icon-chevron-down:before {
165
- content: "\4a";
166
- }
167
- .timely-icon-chevron-up:before {
168
- content: "\4b";
169
- }
170
- .timely-icon-arrow-left:before {
171
- content: "\4c";
172
- }
173
- .timely-icon-chevron-left:before {
174
- content: "\4d";
175
- position: relative;
176
- top: 0.1em;
177
- }
178
- .timely-icon-chevron-right:before {
179
- content: "\4e";
180
- position: relative;
181
- top: 0.1em;
182
- }
183
- .timely-icon-time:before {
184
- content: "\4f";
185
- }
186
- .timely-icon-plus:before {
187
- content: "\30";
188
- }
189
- .timely-icon-minus:before {
190
- content: "\31";
191
- }
192
- .timely-icon-shopping-cart:before {
193
- content: "\32";
194
- }
195
- .timely-icon-gift:before {
196
- content: "\33";
197
- }
198
- .timely-icon-checkmark:before {
199
- content: "\34";
200
- }
201
-
202
- // Core variables and mixins
203
- @import "variables.less"; // Modify this for custom colors, font-sizes, etc
204
- @import "mixins.less";
205
-
206
- // Modals & popovers must stay outside of .timely as they are root-level
207
- // elements.
208
- @import "modals.less";
209
- @import "popovers.less";
210
- @import "component-animations.less";
211
-
212
- // ==========================
213
- // = Unnamespaced overrides =
214
- // ==========================
215
- // Popovers
216
- .popover-title {
217
- .border-radius( 4px 4px 0 0 );
218
- font-family: @headingsFontFamily;
219
- font-size: @baseFontSize * 1.25 !important;
220
- margin: 0 !important;
221
- }
222
- .popover-content p {
223
- margin: 0;
224
- }
225
- .popover-inner {
226
- background-color: @dropdownBorder;
227
- padding: 1px;
228
- }
229
- .popover-content {
230
- .border-radius( 0 0 4px 4px );
231
- }
232
- .popover {
233
- padding: 8px;
234
- &.top { margin-top: -8px; }
235
- &.right { margin-left: 8px; }
236
- &.bottom { margin-top: 8px; }
237
- &.left { margin-left: -8px; }
238
- &.top .arrow { #popoverArrow > .top( 8px, @dropdownBorder ); }
239
- &.right .arrow { #popoverArrow > .right( 8px, @dropdownBorder ); }
240
- &.bottom .arrow { #popoverArrow > .bottom( 8px, @dropdownBorder ); }
241
- &.left .arrow { #popoverArrow > .left( 8px, @dropdownBorder ); }
242
- ul.icons {
243
- text-indent: -0.25em;
244
- }
245
- }
246
- ul.icons {
247
- margin-left: 2em;
248
- }
249
-
250
- .timely {
251
- // CSS Reset
252
- @import "reset.less";
253
-
254
- // Grid system and page structure
255
- @import "scaffolding.less";
256
- @import "grid.less";
257
- //@import "layouts.less";
258
-
259
- // Base CSS
260
- @import "type.less";
261
- //@import "code.less";
262
- //@import "forms.less";
263
- //@import "tables.less";
264
-
265
- // Components: common
266
- //@import "sprites.less";
267
- //@import "dropdowns.less";
268
- //@import "wells.less";
269
- @import "close.less";
270
-
271
- // Components: Buttons & Alerts
272
- @import "buttons.less";
273
- //@import "button-groups.less";
274
- //@import "alerts.less"; // Note: alerts share common CSS with buttons and thus have styles in buttons.less
275
-
276
- // Components: Nav
277
- //@import "navs.less";
278
- //@import "navbar.less";
279
- //@import "breadcrumbs.less";
280
- //@import "pagination.less";
281
- //@import "pager.less";
282
-
283
- // Components: Popovers
284
- //@import "tooltip.less";
285
-
286
- // Components: Misc
287
- //@import "thumbnails.less";
288
- //@import "labels.less";
289
- //@import "badges.less";
290
- //@import "progress-bars.less";
291
- //@import "accordion.less";
292
- //@import "carousel.less";
293
- @import "hero-unit.less";
294
-
295
- // Utility classes
296
- @import "utilities.less"; // Has to be last to override when necessary
297
-
298
- // Adjustments.
299
- font-family: @baseFontFamily;
300
- font-size: @baseFontSize;
301
- font-weight: 300;
302
- line-height: @baseLineHeight;
303
- color: @textColor;
304
-
305
- .hero-unit {
306
- padding: 30px;
307
- margin-bottom: 15px;
308
- }
309
- .hero-unit h1 {
310
- color: @headingsColor;
311
- }
312
- h4 {
313
- font-size: 16px;
314
- }
315
- hr {
316
- margin: 14px 0;
317
- }
318
- h2.ai1ec-premium-features {
319
- font-size: 1.4em !important;
320
- }
321
- h4.ai1ec-premium-features {
322
- .span4 {
323
- min-width: 145px;
324
- }
325
- li {
326
- color: @linkColor;
327
- font-size: 1.2em;
328
- strong {
329
- font-size: 0.83em;
330
- color: @textColor;
331
- }
332
- }
333
- }
334
- a.btn {
335
- text-decoration: none;
336
- }
337
-
338
- // Icons
339
- ul.icons {
340
- list-style-type: none;
341
- }
342
-
343
- // Restore WP styles.
344
- a.button-primary {
345
- color: #fff;
346
- &:hover {
347
- color: #EAF2FA;
348
- text-decoration: none;
349
- }
350
- }
351
- input[type="text"] {
352
- height: 28px;
353
- line-height: 28px;
354
- }
355
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/view/admin/less/build-css.sh DELETED
@@ -1,10 +0,0 @@
1
- #!/bin/bash
2
-
3
- LESSC="lessc --yui-compress --include-path=."
4
-
5
- if which -s lessc; then
6
- $LESSC bootstrap.less > ../css/bootstrap.min.css
7
- else
8
- echo 'Error: lessc not found. Install Node.js then: npm install -g less';
9
- exit 1;
10
- fi
 
 
 
 
 
 
 
 
 
 
app/view/admin/less/button-groups.less DELETED
@@ -1,172 +0,0 @@
1
- // BUTTON GROUPS
2
- // -------------
3
-
4
-
5
- // Make the div behave like a button
6
- .btn-group {
7
- position: relative;
8
- .clearfix(); // clears the floated buttons
9
- .ie7-restore-left-whitespace();
10
- }
11
-
12
- // Space out series of button groups
13
- .btn-group + .btn-group {
14
- margin-left: 5px;
15
- }
16
-
17
- // Optional: Group multiple button groups together for a toolbar
18
- .btn-toolbar {
19
- margin-top: @baseLineHeight / 2;
20
- margin-bottom: @baseLineHeight / 2;
21
- .btn-group {
22
- display: inline-block;
23
- .ie7-inline-block();
24
- }
25
- }
26
-
27
- // Float them, remove border radius, then re-add to first and last elements
28
- .btn-group .btn {
29
- position: relative;
30
- float: left;
31
- margin-left: -1px;
32
- .border-radius(0);
33
- }
34
- // Set corners individual because sometimes a single button can be in a .btn-group and we need :first-child and :last-child to both match
35
- .btn-group .btn:first-child {
36
- margin-left: 0;
37
- -webkit-border-top-left-radius: 4px;
38
- -moz-border-radius-topleft: 4px;
39
- border-top-left-radius: 4px;
40
- -webkit-border-bottom-left-radius: 4px;
41
- -moz-border-radius-bottomleft: 4px;
42
- border-bottom-left-radius: 4px;
43
- }
44
- .btn-group .btn:last-child,
45
- .btn-group .dropdown-toggle {
46
- -webkit-border-top-right-radius: 4px;
47
- -moz-border-radius-topright: 4px;
48
- border-top-right-radius: 4px;
49
- -webkit-border-bottom-right-radius: 4px;
50
- -moz-border-radius-bottomright: 4px;
51
- border-bottom-right-radius: 4px;
52
- }
53
- // Reset corners for large buttons
54
- .btn-group .btn.large:first-child {
55
- margin-left: 0;
56
- -webkit-border-top-left-radius: 6px;
57
- -moz-border-radius-topleft: 6px;
58
- border-top-left-radius: 6px;
59
- -webkit-border-bottom-left-radius: 6px;
60
- -moz-border-radius-bottomleft: 6px;
61
- border-bottom-left-radius: 6px;
62
- }
63
- .btn-group .btn.large:last-child,
64
- .btn-group .large.dropdown-toggle {
65
- -webkit-border-top-right-radius: 6px;
66
- -moz-border-radius-topright: 6px;
67
- border-top-right-radius: 6px;
68
- -webkit-border-bottom-right-radius: 6px;
69
- -moz-border-radius-bottomright: 6px;
70
- border-bottom-right-radius: 6px;
71
- }
72
-
73
- // On hover/focus/active, bring the proper btn to front
74
- .btn-group .btn:hover,
75
- .btn-group .btn:focus,
76
- .btn-group .btn:active,
77
- .btn-group .btn.active {
78
- z-index: 2;
79
- }
80
-
81
- // On active and open, don't show outline
82
- .btn-group .dropdown-toggle:active,
83
- .btn-group.open .dropdown-toggle {
84
- outline: 0;
85
- }
86
-
87
-
88
-
89
- // Split button dropdowns
90
- // ----------------------
91
-
92
- // Give the line between buttons some depth
93
- .btn-group .dropdown-toggle {
94
- padding-left: 8px;
95
- padding-right: 8px;
96
- @shadow: inset 1px 0 0 rgba(255,255,255,.125), inset 0 1px 0 rgba(255,255,255,.2), 0 1px 2px rgba(0,0,0,.05);
97
- .box-shadow(@shadow);
98
- *padding-top: 3px;
99
- *padding-bottom: 3px;
100
- }
101
- .btn-group .btn-mini.dropdown-toggle {
102
- padding-left: 5px;
103
- padding-right: 5px;
104
- *padding-top: 1px;
105
- *padding-bottom: 1px;
106
- }
107
- .btn-group .btn-small.dropdown-toggle {
108
- *padding-top: 4px;
109
- *padding-bottom: 4px;
110
- }
111
- .btn-group .btn-large.dropdown-toggle {
112
- padding-left: 12px;
113
- padding-right: 12px;
114
- }
115
-
116
- .btn-group.open {
117
- // IE7's z-index only goes to the nearest positioned ancestor, which would
118
- // make the menu appear below buttons that appeared later on the page
119
- *z-index: @zindexDropdown;
120
-
121
- // Reposition menu on open and round all corners
122
- .dropdown-menu {
123
- display: block;
124
- margin-top: 1px;
125
- .border-radius(5px);
126
- }
127
-
128
- .dropdown-toggle {
129
- background-image: none;
130
- @shadow: inset 0 1px 6px rgba(0,0,0,.15), 0 1px 2px rgba(0,0,0,.05);
131
- .box-shadow(@shadow);
132
- }
133
- }
134
-
135
- // Reposition the caret
136
- .btn .caret {
137
- margin-top: 7px;
138
- margin-left: 0;
139
- }
140
- .btn:hover .caret,
141
- .open.btn-group .caret {
142
- .opacity(100);
143
- }
144
- // Carets in other button sizes
145
- .btn-mini .caret {
146
- margin-top: 5px;
147
- }
148
- .btn-small .caret {
149
- margin-top: 6px;
150
- }
151
- .btn-large .caret {
152
- margin-top: 6px;
153
- border-left: 5px solid transparent;
154
- border-right: 5px solid transparent;
155
- border-top: 5px solid @black;
156
- }
157
-
158
-
159
- // Account for other colors
160
- .btn-primary,
161
- .btn-warning,
162
- .btn-danger,
163
- .btn-info,
164
- .btn-success,
165
- .btn-inverse {
166
- .caret {
167
- border-top-color: @white;
168
- border-bottom-color: @white;
169
- .opacity(75);
170
- }
171
- }
172
-
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/view/admin/less/buttons.less DELETED
@@ -1,187 +0,0 @@
1
- // BUTTON STYLES
2
- // -------------
3
-
4
-
5
- // Base styles
6
- // --------------------------------------------------
7
-
8
- // Core
9
- .btn {
10
- display: inline-block;
11
- .ie7-inline-block();
12
- padding: 4px 10px 4px;
13
- margin-bottom: 0; // For input.btn
14
- font-size: @baseFontSize;
15
- line-height: @baseLineHeight;
16
- color: @grayDark;
17
- text-align: center;
18
- text-shadow: 0 1px 1px rgba(255,255,255,.75);
19
- vertical-align: middle;
20
- .buttonBackground(@btnBackground, @btnBackgroundHighlight);
21
- border: 1px solid @btnBorder;
22
- border-bottom-color: darken(@btnBorder, 10%);
23
- .border-radius(4px);
24
- @shadow: inset 0 1px 0 rgba(255,255,255,.2), 0 1px 2px rgba(0,0,0,.05);
25
- .box-shadow(@shadow);
26
- cursor: pointer;
27
-
28
- // Give IE7 some love
29
- .ie7-restore-left-whitespace();
30
- }
31
-
32
- // Hover state
33
- .btn:hover {
34
- color: @grayDark;
35
- text-decoration: none;
36
- background-color: darken(@white, 10%);
37
- background-position: 0 -15px;
38
-
39
- // transition is only when going to hover, otherwise the background
40
- // behind the gradient (there for IE<=9 fallback) gets mismatched
41
- .transition(background-position .1s linear);
42
- }
43
-
44
- // Focus state for keyboard and accessibility
45
- .btn:focus {
46
- .tab-focus();
47
- }
48
-
49
- // Active state
50
- .btn.active,
51
- .btn:active {
52
- background-image: none;
53
- @shadow: inset 0 2px 4px rgba(0,0,0,.15), 0 1px 2px rgba(0,0,0,.05);
54
- .box-shadow(@shadow);
55
- background-color: darken(@white, 10%);
56
- background-color: darken(@white, 15%) e("\9");
57
- outline: 0;
58
- }
59
-
60
- // Disabled state
61
- .btn.disabled,
62
- .btn[disabled] {
63
- cursor: default;
64
- background-image: none;
65
- background-color: darken(@white, 10%);
66
- .opacity(65);
67
- .box-shadow(none);
68
- }
69
-
70
-
71
- // Button Sizes
72
- // --------------------------------------------------
73
-
74
- // Large
75
- .btn-large {
76
- padding: 9px 14px;
77
- font-size: @baseFontSize + 2px;
78
- line-height: normal;
79
- .border-radius(5px);
80
- }
81
- .btn-large [class^="icon-"] {
82
- margin-top: 1px;
83
- }
84
-
85
- // Small
86
- .btn-small {
87
- padding: 5px 9px;
88
- font-size: @baseFontSize - 2px;
89
- line-height: @baseLineHeight - 2px;
90
- }
91
- .btn-small [class^="icon-"] {
92
- margin-top: -1px;
93
- }
94
-
95
- // Mini
96
- .btn-mini {
97
- padding: 2px 6px;
98
- font-size: @baseFontSize - 2px;
99
- line-height: @baseLineHeight - 4px;
100
- }
101
-
102
-
103
- // Alternate buttons
104
- // --------------------------------------------------
105
-
106
- // Set text color
107
- // -------------------------
108
- .btn-primary,
109
- .btn-primary:hover,
110
- .btn-warning,
111
- .btn-warning:hover,
112
- .btn-danger,
113
- .btn-danger:hover,
114
- .btn-success,
115
- .btn-success:hover,
116
- .btn-info,
117
- .btn-info:hover,
118
- .btn-inverse,
119
- .btn-inverse:hover {
120
- text-shadow: 0 -1px 0 rgba(0,0,0,.25);
121
- color: @white;
122
- }
123
- // Provide *some* extra contrast for those who can get it
124
- .btn-primary.active,
125
- .btn-warning.active,
126
- .btn-danger.active,
127
- .btn-success.active,
128
- .btn-info.active,
129
- .btn-inverse.active {
130
- color: rgba(255,255,255,.75);
131
- }
132
-
133
- // Set the backgrounds
134
- // -------------------------
135
- .btn-primary {
136
- .buttonBackground(@btnPrimaryBackground, @btnPrimaryBackgroundHighlight);
137
- }
138
- // Warning appears are orange
139
- .btn-warning {
140
- .buttonBackground(@btnWarningBackground, @btnWarningBackgroundHighlight);
141
- }
142
- // Danger and error appear as red
143
- .btn-danger {
144
- .buttonBackground(@btnDangerBackground, @btnDangerBackgroundHighlight);
145
- }
146
- // Success appears as green
147
- .btn-success {
148
- .buttonBackground(@btnSuccessBackground, @btnSuccessBackgroundHighlight);
149
- }
150
- // Info appears as a neutral blue
151
- .btn-info {
152
- .buttonBackground(@btnInfoBackground, @btnInfoBackgroundHighlight);
153
- }
154
- // Inverse appears as dark gray
155
- .btn-inverse {
156
- .buttonBackground(@btnInverseBackground, @btnInverseBackgroundHighlight);
157
- }
158
-
159
-
160
- // Cross-browser Jank
161
- // --------------------------------------------------
162
-
163
- button.btn,
164
- input[type="submit"].btn {
165
-
166
- // Firefox 3.6 only I believe
167
- &::-moz-focus-inner {
168
- padding: 0;
169
- border: 0;
170
- }
171
-
172
- // IE7 has some default padding on button controls
173
- *padding-top: 2px;
174
- *padding-bottom: 2px;
175
- &.btn-large {
176
- *padding-top: 7px;
177
- *padding-bottom: 7px;
178
- }
179
- &.btn-small {
180
- *padding-top: 3px;
181
- *padding-bottom: 3px;
182
- }
183
- &.btn-mini {
184
- *padding-top: 1px;
185
- *padding-bottom: 1px;
186
- }
187
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/view/admin/less/close.less DELETED
@@ -1,29 +0,0 @@
1
- // CLOSE ICONS
2
- // -----------
3
-
4
- .close {
5
- float: right;
6
- font-size: 20px;
7
- font-weight: bold;
8
- line-height: @baseLineHeight;
9
- color: @black;
10
- text-shadow: 0 1px 0 rgba(255,255,255,1);
11
- .opacity(20);
12
- &:hover {
13
- color: @black;
14
- text-decoration: none;
15
- cursor: pointer;
16
- .opacity(40);
17
- }
18
- }
19
-
20
- // Additional properties for button version
21
- // iOS requires the button element instead of an anchor tag.
22
- // If you want the anchor version, it requires `href="#"`.
23
- button.close {
24
- padding: 0;
25
- cursor: pointer;
26
- background: transparent;
27
- border: 0;
28
- -webkit-appearance: none;
29
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/view/admin/less/component-animations.less DELETED
@@ -1,20 +0,0 @@
1
- // COMPONENT ANIMATIONS
2
- // --------------------
3
-
4
- .fade {
5
- .transition(opacity .15s linear);
6
- opacity: 0;
7
- &.in {
8
- opacity: 1;
9
- }
10
- }
11
-
12
- .collapse {
13
- .transition(height .35s ease);
14
- position:relative;
15
- overflow:hidden;
16
- height: 0;
17
- &.in {
18
- height: auto;
19
- }
20
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/view/admin/less/dropdowns.less DELETED
@@ -1,148 +0,0 @@
1
- // DROPDOWN MENUS
2
- // --------------
3
-
4
- // Use the .menu class on any <li> element within the topbar or ul.tabs and you'll get some superfancy dropdowns
5
- .dropdown {
6
- position: relative;
7
- }
8
- .dropdown-toggle {
9
- // The caret makes the toggle a bit too tall in IE7
10
- *margin-bottom: -3px;
11
- }
12
- .dropdown-toggle:active,
13
- .open .dropdown-toggle {
14
- outline: 0;
15
- }
16
-
17
- // Dropdown arrow/caret
18
- // --------------------
19
- .caret {
20
- display: inline-block;
21
- width: 0;
22
- height: 0;
23
- vertical-align: top;
24
- border-left: 4px solid transparent;
25
- border-right: 4px solid transparent;
26
- border-top: 4px solid @black;
27
- .opacity(30);
28
- content: "";
29
- }
30
-
31
- // Place the caret
32
- .dropdown .caret {
33
- margin-top: 8px;
34
- margin-left: 2px;
35
- }
36
- .dropdown:hover .caret,
37
- .open.dropdown .caret {
38
- .opacity(100);
39
- }
40
-
41
- // The dropdown menu (ul)
42
- // ----------------------
43
- .dropdown-menu {
44
- position: absolute;
45
- top: 100%;
46
- left: 0;
47
- z-index: @zindexDropdown;
48
- float: left;
49
- display: none; // none by default, but block on "open" of the menu
50
- min-width: 160px;
51
- padding: 4px 0;
52
- margin: 0; // override default ul
53
- list-style: none;
54
- background-color: @dropdownBackground;
55
- border-color: #ccc;
56
- border-color: rgba(0,0,0,.2);
57
- border-style: solid;
58
- border-width: 1px;
59
- .border-radius(0 0 5px 5px);
60
- .box-shadow(0 5px 10px rgba(0,0,0,.2));
61
- -webkit-background-clip: padding-box;
62
- -moz-background-clip: padding;
63
- background-clip: padding-box;
64
- *border-right-width: 2px;
65
- *border-bottom-width: 2px;
66
-
67
- // Aligns the dropdown menu to right
68
- &.pull-right {
69
- right: 0;
70
- left: auto;
71
- }
72
-
73
- // Dividers (basically an hr) within the dropdown
74
- .divider {
75
- .nav-divider();
76
- }
77
-
78
- // Links within the dropdown menu
79
- a {
80
- display: block;
81
- padding: 3px 15px;
82
- clear: both;
83
- font-weight: normal;
84
- line-height: @baseLineHeight;
85
- color: @dropdownLinkColor;
86
- white-space: nowrap;
87
- }
88
- }
89
-
90
- // Hover state
91
- // -----------
92
- .dropdown-menu li > a:hover,
93
- .dropdown-menu .active > a,
94
- .dropdown-menu .active > a:hover {
95
- color: @dropdownLinkColorHover;
96
- text-decoration: none;
97
- background-color: @dropdownLinkBackgroundHover;
98
- }
99
-
100
- // Open state for the dropdown
101
- // ---------------------------
102
- .dropdown.open {
103
- // IE7's z-index only goes to the nearest positioned ancestor, which would
104
- // make the menu appear below buttons that appeared later on the page
105
- *z-index: @zindexDropdown;
106
-
107
- .dropdown-toggle {
108
- color: @white;
109
- background: #ccc;
110
- background: rgba(0,0,0,.3);
111
- }
112
- .dropdown-menu {
113
- display: block;
114
- }
115
- }
116
-
117
- // Right aligned dropdowns
118
- .pull-right .dropdown-menu {
119
- left: auto;
120
- right: 0;
121
- }
122
-
123
- // Allow for dropdowns to go bottom up (aka, dropup-menu)
124
- // ------------------------------------------------------
125
- // Just add .dropup after the standard .dropdown class and you're set, bro.
126
- // TODO: abstract this so that the navbar fixed styles are not placed here?
127
- .dropup,
128
- .navbar-fixed-bottom .dropdown {
129
- // Reverse the caret
130
- .caret {
131
- border-top: 0;
132
- border-bottom: 4px solid @black;
133
- content: "\2191";
134
- }
135
- // Different positioning for bottom up menu
136
- .dropdown-menu {
137
- top: auto;
138
- bottom: 100%;
139
- margin-bottom: 1px;
140
- }
141
- }
142
-
143
- // Typeahead
144
- // ---------
145
- .typeahead {
146
- margin-top: 2px; // give it some space to breathe
147
- .border-radius(4px);
148
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/view/admin/less/grid.less DELETED
@@ -1,5 +0,0 @@
1
- // Fixed (940px)
2
- #grid > .core(@gridColumnWidth, @gridGutterWidth);
3
-
4
- // Fluid (940px)
5
- #grid > .fluid(@fluidGridColumnWidth, @fluidGridGutterWidth);
 
 
 
 
 
app/view/admin/less/hero-unit.less DELETED
@@ -1,22 +0,0 @@
1
- // HERO UNIT
2
- // ---------
3
-
4
- .hero-unit {
5
- padding: 60px;
6
- margin-bottom: 30px;
7
- background-color: @heroUnitBackground;
8
- .border-radius(6px);
9
- h1 {
10
- margin-bottom: 0;
11
- font-size: 60px;
12
- line-height: 1;
13
- color: @heroUnitHeadingColor;
14
- letter-spacing: -1px;
15
- }
16
- p {
17
- font-size: 18px;
18
- font-weight: 200;
19
- line-height: @baseLineHeight * 1.5;
20
- color: @heroUnitLeadColor;
21
- }
22
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/view/admin/less/mixins.less DELETED
@@ -1,614 +0,0 @@
1
- // Mixins.less
2
- // Snippets of reusable CSS to develop faster and keep code readable
3
- // -----------------------------------------------------------------
4
-
5
-
6
- // UTILITY MIXINS
7
- // --------------------------------------------------
8
-
9
- // Clearfix
10
- // --------
11
- // For clearing floats like a boss h5bp.com/q
12
- .clearfix {
13
- *zoom: 1;
14
- &:before,
15
- &:after {
16
- display: table;
17
- content: "";
18
- }
19
- &:after {
20
- clear: both;
21
- }
22
- }
23
-
24
- // Webkit-style focus
25
- // ------------------
26
- .tab-focus() {
27
- // Default
28
- outline: thin dotted #333;
29
- // Webkit
30
- outline: 5px auto -webkit-focus-ring-color;
31
- outline-offset: -2px;
32
- }
33
-
34
- // Center-align a block level element
35
- // ----------------------------------
36
- .center-block() {
37
- display: block;
38
- margin-left: auto;
39
- margin-right: auto;
40
- }
41
-
42
- // IE7 inline-block
43
- // ----------------
44
- .ie7-inline-block() {
45
- *display: inline; /* IE7 inline-block hack */
46
- *zoom: 1;
47
- }
48
-
49
- // IE7 likes to collapse whitespace on either side of the inline-block elements.
50
- // Ems because we're attempting to match the width of a space character. Left
51
- // version is for form buttons, which typically come after other elements, and
52
- // right version is for icons, which come before. Applying both is ok, but it will
53
- // mean that space between those elements will be .6em (~2 space characters) in IE7,
54
- // instead of the 1 space in other browsers.
55
- .ie7-restore-left-whitespace() {
56
- *margin-left: .3em;
57
-
58
- &:first-child {
59
- *margin-left: 0;
60
- }
61
- }
62
-
63
- .ie7-restore-right-whitespace() {
64
- *margin-right: .3em;
65
-
66
- &:last-child {
67
- *margin-left: 0;
68
- }
69
- }
70
-
71
- // Sizing shortcuts
72
- // -------------------------
73
- .size(@height: 5px, @width: 5px) {
74
- width: @width;
75
- height: @height;
76
- }
77
- .square(@size: 5px) {
78
- .size(@size, @size);
79
- }
80
-
81
- // Placeholder text
82
- // -------------------------
83
- .placeholder(@color: @placeholderText) {
84
- :-moz-placeholder {
85
- color: @color;
86
- }
87
- ::-webkit-input-placeholder {
88
- color: @color;
89
- }
90
- }
91
-
92
- // Text overflow
93
- // -------------------------
94
- // Requires inline-block or block for proper styling
95
- .text-overflow() {
96
- overflow: hidden;
97
- text-overflow: ellipsis;
98
- white-space: nowrap;
99
- }
100
-
101
- // New image replacement
102
- // -------------------------
103
- // Source: http://www.zeldman.com/2012/03/01/replacing-the-9999px-hack-new-image-replacement/
104
- .hide-text {
105
- overflow: hidden;
106
- text-indent: 100%;
107
- white-space: nowrap;
108
- }
109
-
110
-
111
- // FONTS
112
- // --------------------------------------------------
113
-
114
- #font {
115
- #family {
116
- .serif() {
117
- font-family: Georgia, "Times New Roman", Times, serif;
118
- }
119
- .sans-serif() {
120
- font-family: "Helvetica Neue", Helvetica, Arial, sans-serif;
121
- }
122
- .monospace() {
123
- font-family: Menlo, Monaco, "Courier New", monospace;
124
- }
125
- }
126
- .shorthand(@size: @baseFontSize, @weight: normal, @lineHeight: @baseLineHeight) {
127
- font-size: @size;
128
- font-weight: @weight;
129
- line-height: @lineHeight;
130
- }
131
- .serif(@size: @baseFontSize, @weight: normal, @lineHeight: @baseLineHeight) {
132
- #font > #family > .serif;
133
- #font > .shorthand(@size, @weight, @lineHeight);
134
- }
135
- .sans-serif(@size: @baseFontSize, @weight: normal, @lineHeight: @baseLineHeight) {
136
- #font > #family > .sans-serif;
137
- #font > .shorthand(@size, @weight, @lineHeight);
138
- }
139
- .monospace(@size: @baseFontSize, @weight: normal, @lineHeight: @baseLineHeight) {
140
- #font > #family > .monospace;
141
- #font > .shorthand(@size, @weight, @lineHeight);
142
- }
143
- }
144
-
145
-
146
- // FORMS
147
- // --------------------------------------------------
148
-
149
- // Block level inputs
150
- .input-block-level {
151
- display: block;
152
- width: 100%;
153
- min-height: 28px; /* Make inputs at least the height of their button counterpart */
154
- /* Makes inputs behave like true block-level elements */
155
- .box-sizing(border-box);
156
- }
157
-
158
-
159
- // Mixin for form field states
160
- .formFieldState(@textColor: #555, @borderColor: #ccc, @backgroundColor: #f5f5f5) {
161
- // Set the text color
162
- > label,
163
- .help-block,
164
- .help-inline {
165
- color: @textColor;
166
- }
167
- // Style inputs accordingly
168
- input,
169
- select,
170
- textarea {
171
- color: @textColor;
172
- border-color: @borderColor;
173
- &:focus {
174
- border-color: darken(@borderColor, 10%);
175
- .box-shadow(0 0 6px lighten(@borderColor, 20%));
176
- }
177
- }
178
- // Give a small background color for input-prepend/-append
179
- .input-prepend .add-on,
180
- .input-append .add-on {
181
- color: @textColor;
182
- background-color: @backgroundColor;
183
- border-color: @textColor;
184
- }
185
- }
186
-
187
-
188
-
189
- // CSS3 PROPERTIES
190
- // --------------------------------------------------
191
-
192
- // Border Radius
193
- .border-radius(@radius: 5px) {
194
- -webkit-border-radius: @radius;
195
- -moz-border-radius: @radius;
196
- border-radius: @radius;
197
- }
198
-
199
- // Drop shadows
200
- .box-shadow(@shadow: 0 1px 3px rgba(0,0,0,.25)) {
201
- -webkit-box-shadow: @shadow;
202
- -moz-box-shadow: @shadow;
203
- box-shadow: @shadow;
204
- }
205
-
206
- // Transitions
207
- .transition(@transition) {
208
- -webkit-transition: @transition;
209
- -moz-transition: @transition;
210
- -ms-transition: @transition;
211
- -o-transition: @transition;
212
- transition: @transition;
213
- }
214
-
215
- // Transformations
216
- .rotate(@degrees) {
217
- -webkit-transform: rotate(@degrees);
218
- -moz-transform: rotate(@degrees);
219
- -ms-transform: rotate(@degrees);
220
- -o-transform: rotate(@degrees);
221
- transform: rotate(@degrees);
222
- }
223
- .scale(@ratio) {
224
- -webkit-transform: scale(@ratio);
225
- -moz-transform: scale(@ratio);
226
- -ms-transform: scale(@ratio);
227
- -o-transform: scale(@ratio);
228
- transform: scale(@ratio);
229
- }
230
- .translate(@x: 0, @y: 0) {
231
- -webkit-transform: translate(@x, @y);
232
- -moz-transform: translate(@x, @y);
233
- -ms-transform: translate(@x, @y);
234
- -o-transform: translate(@x, @y);
235
- transform: translate(@x, @y);
236
- }
237
- .skew(@x: 0, @y: 0) {
238
- -webkit-transform: skew(@x, @y);
239
- -moz-transform: skew(@x, @y);
240
- -ms-transform: skew(@x, @y);
241
- -o-transform: skew(@x, @y);
242
- transform: skew(@x, @y);
243
- }
244
- .translate3d(@x: 0, @y: 0, @z: 0) {
245
- -webkit-transform: translate(@x, @y, @z);
246
- -moz-transform: translate(@x, @y, @z);
247
- -ms-transform: translate(@x, @y, @z);
248
- -o-transform: translate(@x, @y, @z);
249
- transform: translate(@x, @y, @z);
250
- }
251
-
252
- // Background clipping
253
- // Heads up: FF 3.6 and under need "padding" instead of "padding-box"
254
- .background-clip(@clip) {
255
- -webkit-background-clip: @clip;
256
- -moz-background-clip: @clip;
257
- background-clip: @clip;
258
- }
259
-
260
- // Background sizing
261
- .background-size(@size){
262
- -webkit-background-size: @size;
263
- -moz-background-size: @size;
264
- -o-background-size: @size;
265
- background-size: @size;
266
- }
267
-
268
-
269
- // Box sizing
270
- .box-sizing(@boxmodel) {
271
- -webkit-box-sizing: @boxmodel;
272
- -moz-box-sizing: @boxmodel;
273
- -ms-box-sizing: @boxmodel;
274
- box-sizing: @boxmodel;
275
- }
276
-
277
- // User select
278
- // For selecting text on the page
279
- .user-select(@select) {
280
- -webkit-user-select: @select;
281
- -moz-user-select: @select;
282
- -o-user-select: @select;
283
- user-select: @select;
284
- }
285
-
286
- // Resize anything
287
- .resizable(@direction: both) {
288
- resize: @direction; // Options: horizontal, vertical, both
289
- overflow: auto; // Safari fix
290
- }
291
-
292
- // CSS3 Content Columns
293
- .content-columns(@columnCount, @columnGap: @gridColumnGutter) {
294
- -webkit-column-count: @columnCount;
295
- -moz-column-count: @columnCount;
296
- column-count: @columnCount;
297
- -webkit-column-gap: @columnGap;
298
- -moz-column-gap: @columnGap;
299
- column-gap: @columnGap;
300
- }
301
-
302
- // Opacity
303
- .opacity(@opacity: 100) {
304
- opacity: @opacity / 100;
305
- filter: ~"alpha(opacity=@{opacity})";
306
- }
307
-
308
-
309
-
310
- // BACKGROUNDS
311
- // --------------------------------------------------
312
-
313
- // Add an alphatransparency value to any background or border color (via Elyse Holladay)
314
- #translucent {
315
- .background(@color: @white, @alpha: 1) {
316
- background-color: hsla(hue(@color), saturation(@color), lightness(@color), @alpha);
317
- }
318
- .border(@color: @white, @alpha: 1) {
319
- border-color: hsla(hue(@color), saturation(@color), lightness(@color), @alpha);
320
- .background-clip(padding-box);
321
- }
322
- }
323
-
324
- // Gradient Bar Colors for buttons and alerts
325
- .gradientBar(@primaryColor, @secondaryColor) {
326
- #gradient > .vertical(@primaryColor, @secondaryColor);
327
- border-color: @secondaryColor @secondaryColor darken(@secondaryColor, 15%);
328
- border-color: rgba(0,0,0,.1) rgba(0,0,0,.1) fadein(rgba(0,0,0,.1), 15%);
329
- }
330
-
331
- // Gradients
332
- #gradient {
333
- .horizontal(@startColor: #555, @endColor: #333) {
334
- background-color: @endColor;
335
- background-image: -moz-linear-gradient(left, @startColor, @endColor); // FF 3.6+
336
- background-image: -ms-linear-gradient(left, @startColor, @endColor); // IE10
337
- background-image: -webkit-gradient(linear, 0 0, 100% 0, from(@startColor), to(@endColor)); // Safari 4+, Chrome 2+
338
- background-image: -webkit-linear-gradient(left, @startColor, @endColor); // Safari 5.1+, Chrome 10+
339
- background-image: -o-linear-gradient(left, @startColor, @endColor); // Opera 11.10
340
- background-image: linear-gradient(left, @startColor, @endColor); // Le standard
341
- background-repeat: repeat-x;
342
- filter: e(%("progid:DXImageTransform.Microsoft.gradient(startColorstr='%d', endColorstr='%d', GradientType=1)",@startColor,@endColor)); // IE9 and down
343
- }
344
- .vertical(@startColor: #555, @endColor: #333) {
345
- background-color: mix(@startColor, @endColor, 60%);
346
- background-image: -moz-linear-gradient(top, @startColor, @endColor); // FF 3.6+
347
- background-image: -ms-linear-gradient(top, @startColor, @endColor); // IE10
348
- background-image: -webkit-gradient(linear, 0 0, 0 100%, from(@startColor), to(@endColor)); // Safari 4+, Chrome 2+
349
- background-image: -webkit-linear-gradient(top, @startColor, @endColor); // Safari 5.1+, Chrome 10+
350
- background-image: -o-linear-gradient(top, @startColor, @endColor); // Opera 11.10
351
- background-image: linear-gradient(top, @startColor, @endColor); // The standard
352
- background-repeat: repeat-x;
353
- filter: e(%("progid:DXImageTransform.Microsoft.gradient(startColorstr='%d', endColorstr='%d', GradientType=0)",@startColor,@endColor)); // IE9 and down
354
- }
355
- .directional(@startColor: #555, @endColor: #333, @deg: 45deg) {
356
- background-color: @endColor;
357
- background-repeat: repeat-x;
358
- background-image: -moz-linear-gradient(@deg, @startColor, @endColor); // FF 3.6+
359
- background-image: -ms-linear-gradient(@deg, @startColor, @endColor); // IE10
360
- background-image: -webkit-linear-gradient(@deg, @startColor, @endColor); // Safari 5.1+, Chrome 10+
361
- background-image: -o-linear-gradient(@deg, @startColor, @endColor); // Opera 11.10
362
- background-image: linear-gradient(@deg, @startColor, @endColor); // The standard
363
- }
364
- .vertical-three-colors(@startColor: #00b3ee, @midColor: #7a43b6, @colorStop: 50%, @endColor: #c3325f) {
365
- background-color: mix(@midColor, @endColor, 80%);
366
- background-image: -webkit-gradient(linear, 0 0, 0 100%, from(@startColor), color-stop(@colorStop, @midColor), to(@endColor));
367
- background-image: -webkit-linear-gradient(@startColor, @midColor @colorStop, @endColor);
368
- background-image: -moz-linear-gradient(top, @startColor, @midColor @colorStop, @endColor);
369
- background-image: -ms-linear-gradient(@startColor, @midColor @colorStop, @endColor);
370
- background-image: -o-linear-gradient(@startColor, @midColor @colorStop, @endColor);
371
- background-image: linear-gradient(@startColor, @midColor @colorStop, @endColor);
372
- background-repeat: no-repeat;
373
- filter: e(%("progid:DXImageTransform.Microsoft.gradient(startColorstr='%d', endColorstr='%d', GradientType=0)",@startColor,@endColor)); // IE9 and down, gets no color-stop at all for proper fallback
374
- }
375
- .radial(@innerColor: #555, @outerColor: #333) {
376
- background-color: @outerColor;
377
- background-image: -webkit-gradient(radial, center center, 0, center center, 460, from(@innerColor), to(@outerColor));
378
- background-image: -webkit-radial-gradient(circle, @innerColor, @outerColor);
379
- background-image: -moz-radial-gradient(circle, @innerColor, @outerColor);
380
- background-image: -ms-radial-gradient(circle, @innerColor, @outerColor);
381
- background-image: -o-radial-gradient(circle, @innerColor, @outerColor);
382
- background-repeat: no-repeat;
383
- }
384
- .striped(@color, @angle: -45deg) {
385
- background-color: @color;
386
- background-image: -webkit-gradient(linear, 0 100%, 100% 0, color-stop(.25, rgba(255,255,255,.15)), color-stop(.25, transparent), color-stop(.5, transparent), color-stop(.5, rgba(255,255,255,.15)), color-stop(.75, rgba(255,255,255,.15)), color-stop(.75, transparent), to(transparent));
387
- background-image: -webkit-linear-gradient(@angle, rgba(255,255,255,.15) 25%, transparent 25%, transparent 50%, rgba(255,255,255,.15) 50%, rgba(255,255,255,.15) 75%, transparent 75%, transparent);
388
- background-image: -moz-linear-gradient(@angle, rgba(255,255,255,.15) 25%, transparent 25%, transparent 50%, rgba(255,255,255,.15) 50%, rgba(255,255,255,.15) 75%, transparent 75%, transparent);
389
- background-image: -ms-linear-gradient(@angle, rgba(255,255,255,.15) 25%, transparent 25%, transparent 50%, rgba(255,255,255,.15) 50%, rgba(255,255,255,.15) 75%, transparent 75%, transparent);
390
- background-image: -o-linear-gradient(@angle, rgba(255,255,255,.15) 25%, transparent 25%, transparent 50%, rgba(255,255,255,.15) 50%, rgba(255,255,255,.15) 75%, transparent 75%, transparent);
391
- background-image: linear-gradient(@angle, rgba(255,255,255,.15) 25%, transparent 25%, transparent 50%, rgba(255,255,255,.15) 50%, rgba(255,255,255,.15) 75%, transparent 75%, transparent);
392
- }
393
- }
394
- // Reset filters for IE
395
- .reset-filter() {
396
- filter: progid:DXImageTransform.Microsoft.gradient(enabled = false);
397
- }
398
-
399
-
400
-
401
- // COMPONENT MIXINS
402
- // --------------------------------------------------
403
-
404
- // Horizontal dividers
405
- // -------------------------
406
- // Dividers (basically an hr) within dropdowns and nav lists
407
- .nav-divider() {
408
- height: 1px;
409
- margin: ((@baseLineHeight / 2) - 1) 1px; // 8px 1px
410
- overflow: hidden;
411
- background-color: #e5e5e5;
412
- border-bottom: 1px solid @white;
413
-
414
- // IE7 needs a set width since we gave a height. Restricting just
415
- // to IE7 to keep the 1px left/right space in other browsers.
416
- // It is unclear where IE is getting the extra space that we need
417
- // to negative-margin away, but so it goes.
418
- *width: 100%;
419
- *margin: -5px 0 5px;
420
- }
421
-
422
- // Button backgrounds
423
- // ------------------
424
- .buttonBackground(@startColor, @endColor) {
425
- // gradientBar will set the background to a pleasing blend of these, to support IE<=9
426
- .gradientBar(@startColor, @endColor);
427
- .reset-filter();
428
-
429
- // in these cases the gradient won't cover the background, so we override
430
- &:hover, &:active, &.active, &.disabled, &[disabled] {
431
- background-color: @endColor;
432
- }
433
-
434
- // IE 7 + 8 can't handle box-shadow to show active, so we darken a bit ourselves
435
- &:active,
436
- &.active {
437
- background-color: darken(@endColor, 10%) e("\9");
438
- }
439
- }
440
-
441
- // Navbar vertical align
442
- // -------------------------
443
- // Vertically center elements in the navbar.
444
- // Example: an element has a height of 30px, so write out `.navbarVerticalAlign(30px);` to calculate the appropriate top margin.
445
- .navbarVerticalAlign(@elementHeight) {
446
- margin-top: (@navbarHeight - @elementHeight) / 2;
447
- }
448
-
449
- // Popover arrows
450
- // -------------------------
451
- // For tipsies and popovers
452
- #popoverArrow {
453
- .top(@arrowWidth: 5px, @color: @black) {
454
- bottom: 0;
455
- left: 50%;
456
- margin-left: -@arrowWidth;
457
- border-left: @arrowWidth solid transparent;
458
- border-right: @arrowWidth solid transparent;
459
- border-top: @arrowWidth solid @color;
460
- }
461
- .left(@arrowWidth: 5px, @color: @black) {
462
- top: 50%;
463
- right: 0;
464
- margin-top: -@arrowWidth;
465
- border-top: @arrowWidth solid transparent;
466
- border-bottom: @arrowWidth solid transparent;
467
- border-left: @arrowWidth solid @color;
468
- }
469
- .bottom(@arrowWidth: 5px, @color: @black) {
470
- top: 0;
471
- left: 50%;
472
- margin-left: -@arrowWidth;
473
- border-left: @arrowWidth solid transparent;
474
- border-right: @arrowWidth solid transparent;
475
- border-bottom: @arrowWidth solid @color;
476
- }
477
- .right(@arrowWidth: 5px, @color: @black) {
478
- top: 50%;
479
- left: 0;
480
- margin-top: -@arrowWidth;
481
- border-top: @arrowWidth solid transparent;
482
- border-bottom: @arrowWidth solid transparent;
483
- border-right: @arrowWidth solid @color;
484
- }
485
- }
486
-
487
- // Grid System
488
- // -----------
489
-
490
- // Centered container element
491
- .container-fixed() {
492
- margin-left: auto;
493
- margin-right: auto;
494
- .clearfix();
495
- }
496
-
497
- // Table colum