From 96d893fd58a65833301de042258bedaa273d21e3 Mon Sep 17 00:00:00 2001 From: Will Bradley Date: Tue, 18 Feb 2014 19:11:50 -0700 Subject: [PATCH] Initial Commit --- GNU-GPL.txt | 674 +++++++ classes/admin.php | 124 ++ classes/ft-ps-client.php | 827 +++++++++ classes/help.php | 250 +++ classes/import-export.php | 803 +++++++++ classes/locations.php | 749 ++++++++ classes/maps.php | 279 +++ classes/options-general.php | 755 ++++++++ classes/parsecsv.lib.php | 695 ++++++++ classes/shortcodes.php | 254 +++ classes/simplemap.php | 2369 +++++++++++++++++++++++++ classes/templates.php | 151 ++ classes/widgets.php | 256 +++ classes/xml-search.php | 198 +++ inc/images/black-dot.png | Bin 0 -> 401 bytes inc/images/blue-dot.png | Bin 0 -> 913 bytes inc/images/blue-grad.png | Bin 0 -> 128 bytes inc/images/button-red-grad-active.png | Bin 0 -> 128 bytes inc/images/button-red-grad.png | Bin 0 -> 128 bytes inc/images/green-dot.png | Bin 0 -> 886 bytes inc/images/icon.png | Bin 0 -> 659 bytes inc/images/loading.gif | Bin 0 -> 2456 bytes inc/images/map-type-hybrid.jpg | Bin 0 -> 6465 bytes inc/images/map-type-normal.jpg | Bin 0 -> 6765 bytes inc/images/map-type-satellite.jpg | Bin 0 -> 4622 bytes inc/images/map-type-terrain.jpg | Bin 0 -> 4778 bytes inc/images/pink-dot.png | Bin 0 -> 917 bytes inc/images/purple-dot.png | Bin 0 -> 909 bytes inc/images/red-dot.png | Bin 0 -> 893 bytes inc/images/star.png | Bin 0 -> 608 bytes inc/images/teal-dot.png | Bin 0 -> 927 bytes inc/images/white-dot.png | Bin 0 -> 553 bytes inc/images/yellow-dot.png | Bin 0 -> 956 bytes inc/styles/admin.css | 179 ++ inc/styles/dark.css | 214 +++ inc/styles/light.css | 217 +++ lang/SimpleMap-de_DE.mo | Bin 0 -> 4349 bytes lang/SimpleMap-de_DE.po | 934 ++++++++++ lang/SimpleMap-en_US.mo | Bin 0 -> 530 bytes lang/SimpleMap-es_ES.mo | Bin 0 -> 6623 bytes lang/SimpleMap-es_ES.po | 927 ++++++++++ lang/SimpleMap-nl_NL.mo | Bin 0 -> 4367 bytes lang/SimpleMap-nl_NL.po | 947 ++++++++++ lang/SimpleMap-pt_BR.mo | Bin 0 -> 4480 bytes lang/SimpleMap-pt_BR.po | 946 ++++++++++ lang/SimpleMap.mo | Bin 0 -> 530 bytes lang/SimpleMap.pot | 862 +++++++++ readme.txt | 418 +++++ screenshot-1.png | Bin 0 -> 181479 bytes screenshot-2.png | Bin 0 -> 128281 bytes screenshot-3.png | Bin 0 -> 46174 bytes screenshot-4.png | Bin 0 -> 216438 bytes screenshot-5.png | Bin 0 -> 104690 bytes simplemap.php | 153 ++ 54 files changed, 14181 insertions(+) create mode 100644 GNU-GPL.txt create mode 100644 classes/admin.php create mode 100644 classes/ft-ps-client.php create mode 100644 classes/help.php create mode 100644 classes/import-export.php create mode 100644 classes/locations.php create mode 100644 classes/maps.php create mode 100644 classes/options-general.php create mode 100644 classes/parsecsv.lib.php create mode 100644 classes/shortcodes.php create mode 100644 classes/simplemap.php create mode 100644 classes/templates.php create mode 100644 classes/widgets.php create mode 100644 classes/xml-search.php create mode 100644 inc/images/black-dot.png create mode 100644 inc/images/blue-dot.png create mode 100644 inc/images/blue-grad.png create mode 100644 inc/images/button-red-grad-active.png create mode 100644 inc/images/button-red-grad.png create mode 100644 inc/images/green-dot.png create mode 100644 inc/images/icon.png create mode 100644 inc/images/loading.gif create mode 100644 inc/images/map-type-hybrid.jpg create mode 100644 inc/images/map-type-normal.jpg create mode 100644 inc/images/map-type-satellite.jpg create mode 100644 inc/images/map-type-terrain.jpg create mode 100644 inc/images/pink-dot.png create mode 100644 inc/images/purple-dot.png create mode 100644 inc/images/red-dot.png create mode 100644 inc/images/star.png create mode 100644 inc/images/teal-dot.png create mode 100644 inc/images/white-dot.png create mode 100644 inc/images/yellow-dot.png create mode 100644 inc/styles/admin.css create mode 100644 inc/styles/dark.css create mode 100644 inc/styles/light.css create mode 100644 lang/SimpleMap-de_DE.mo create mode 100644 lang/SimpleMap-de_DE.po create mode 100644 lang/SimpleMap-en_US.mo create mode 100644 lang/SimpleMap-es_ES.mo create mode 100644 lang/SimpleMap-es_ES.po create mode 100644 lang/SimpleMap-nl_NL.mo create mode 100644 lang/SimpleMap-nl_NL.po create mode 100644 lang/SimpleMap-pt_BR.mo create mode 100644 lang/SimpleMap-pt_BR.po create mode 100644 lang/SimpleMap.mo create mode 100644 lang/SimpleMap.pot create mode 100644 readme.txt create mode 100644 screenshot-1.png create mode 100644 screenshot-2.png create mode 100644 screenshot-3.png create mode 100644 screenshot-4.png create mode 100644 screenshot-5.png create mode 100644 simplemap.php diff --git a/GNU-GPL.txt b/GNU-GPL.txt new file mode 100644 index 0000000..20d40b6 --- /dev/null +++ b/GNU-GPL.txt @@ -0,0 +1,674 @@ + GNU GENERAL PUBLIC LICENSE + Version 3, 29 June 2007 + + Copyright (C) 2007 Free Software Foundation, Inc. + Everyone is permitted to copy and distribute verbatim copies + of this license document, but changing it is not allowed. + + Preamble + + The GNU General Public License is a free, copyleft license for +software and other kinds of works. + + The licenses for most software and other practical works are designed +to take away your freedom to share and change the works. By contrast, +the GNU General Public License is intended to guarantee your freedom to +share and change all versions of a program--to make sure it remains free +software for all its users. We, the Free Software Foundation, use the +GNU General Public License for most of our software; it applies also to +any other work released this way by its authors. You can apply it to +your programs, too. + + When we speak of free software, we are referring to freedom, not +price. Our General Public Licenses are designed to make sure that you +have the freedom to distribute copies of free software (and charge for +them if you wish), that you receive source code or can get it if you +want it, that you can change the software or use pieces of it in new +free programs, and that you know you can do these things. + + To protect your rights, we need to prevent others from denying you +these rights or asking you to surrender the rights. Therefore, you have +certain responsibilities if you distribute copies of the software, or if +you modify it: responsibilities to respect the freedom of others. + + For example, if you distribute copies of such a program, whether +gratis or for a fee, you must pass on to the recipients the same +freedoms that you received. You must make sure that they, too, receive +or can get the source code. And you must show them these terms so they +know their rights. + + Developers that use the GNU GPL protect your rights with two steps: +(1) assert copyright on the software, and (2) offer you this License +giving you legal permission to copy, distribute and/or modify it. + + For the developers' and authors' protection, the GPL clearly explains +that there is no warranty for this free software. For both users' and +authors' sake, the GPL requires that modified versions be marked as +changed, so that their problems will not be attributed erroneously to +authors of previous versions. + + Some devices are designed to deny users access to install or run +modified versions of the software inside them, although the manufacturer +can do so. This is fundamentally incompatible with the aim of +protecting users' freedom to change the software. The systematic +pattern of such abuse occurs in the area of products for individuals to +use, which is precisely where it is most unacceptable. Therefore, we +have designed this version of the GPL to prohibit the practice for those +products. If such problems arise substantially in other domains, we +stand ready to extend this provision to those domains in future versions +of the GPL, as needed to protect the freedom of users. + + Finally, every program is threatened constantly by software patents. +States should not allow patents to restrict development and use of +software on general-purpose computers, but in those that do, we wish to +avoid the special danger that patents applied to a free program could +make it effectively proprietary. To prevent this, the GPL assures that +patents cannot be used to render the program non-free. + + The precise terms and conditions for copying, distribution and +modification follow. + + TERMS AND CONDITIONS + + 0. Definitions. + + "This License" refers to version 3 of the GNU General Public License. + + "Copyright" also means copyright-like laws that apply to other kinds of +works, such as semiconductor masks. + + "The Program" refers to any copyrightable work licensed under this +License. Each licensee is addressed as "you". "Licensees" and +"recipients" may be individuals or organizations. + + To "modify" a work means to copy from or adapt all or part of the work +in a fashion requiring copyright permission, other than the making of an +exact copy. The resulting work is called a "modified version" of the +earlier work or a work "based on" the earlier work. + + A "covered work" means either the unmodified Program or a work based +on the Program. + + To "propagate" a work means to do anything with it that, without +permission, would make you directly or secondarily liable for +infringement under applicable copyright law, except executing it on a +computer or modifying a private copy. Propagation includes copying, +distribution (with or without modification), making available to the +public, and in some countries other activities as well. + + To "convey" a work means any kind of propagation that enables other +parties to make or receive copies. Mere interaction with a user through +a computer network, with no transfer of a copy, is not conveying. + + An interactive user interface displays "Appropriate Legal Notices" +to the extent that it includes a convenient and prominently visible +feature that (1) displays an appropriate copyright notice, and (2) +tells the user that there is no warranty for the work (except to the +extent that warranties are provided), that licensees may convey the +work under this License, and how to view a copy of this License. If +the interface presents a list of user commands or options, such as a +menu, a prominent item in the list meets this criterion. + + 1. Source Code. + + The "source code" for a work means the preferred form of the work +for making modifications to it. "Object code" means any non-source +form of a work. + + A "Standard Interface" means an interface that either is an official +standard defined by a recognized standards body, or, in the case of +interfaces specified for a particular programming language, one that +is widely used among developers working in that language. + + The "System Libraries" of an executable work include anything, other +than the work as a whole, that (a) is included in the normal form of +packaging a Major Component, but which is not part of that Major +Component, and (b) serves only to enable use of the work with that +Major Component, or to implement a Standard Interface for which an +implementation is available to the public in source code form. A +"Major Component", in this context, means a major essential component +(kernel, window system, and so on) of the specific operating system +(if any) on which the executable work runs, or a compiler used to +produce the work, or an object code interpreter used to run it. + + The "Corresponding Source" for a work in object code form means all +the source code needed to generate, install, and (for an executable +work) run the object code and to modify the work, including scripts to +control those activities. However, it does not include the work's +System Libraries, or general-purpose tools or generally available free +programs which are used unmodified in performing those activities but +which are not part of the work. For example, Corresponding Source +includes interface definition files associated with source files for +the work, and the source code for shared libraries and dynamically +linked subprograms that the work is specifically designed to require, +such as by intimate data communication or control flow between those +subprograms and other parts of the work. + + The Corresponding Source need not include anything that users +can regenerate automatically from other parts of the Corresponding +Source. + + The Corresponding Source for a work in source code form is that +same work. + + 2. Basic Permissions. + + All rights granted under this License are granted for the term of +copyright on the Program, and are irrevocable provided the stated +conditions are met. This License explicitly affirms your unlimited +permission to run the unmodified Program. The output from running a +covered work is covered by this License only if the output, given its +content, constitutes a covered work. This License acknowledges your +rights of fair use or other equivalent, as provided by copyright law. + + You may make, run and propagate covered works that you do not +convey, without conditions so long as your license otherwise remains +in force. You may convey covered works to others for the sole purpose +of having them make modifications exclusively for you, or provide you +with facilities for running those works, provided that you comply with +the terms of this License in conveying all material for which you do +not control copyright. Those thus making or running the covered works +for you must do so exclusively on your behalf, under your direction +and control, on terms that prohibit them from making any copies of +your copyrighted material outside their relationship with you. + + Conveying under any other circumstances is permitted solely under +the conditions stated below. Sublicensing is not allowed; section 10 +makes it unnecessary. + + 3. Protecting Users' Legal Rights From Anti-Circumvention Law. + + No covered work shall be deemed part of an effective technological +measure under any applicable law fulfilling obligations under article +11 of the WIPO copyright treaty adopted on 20 December 1996, or +similar laws prohibiting or restricting circumvention of such +measures. + + When you convey a covered work, you waive any legal power to forbid +circumvention of technological measures to the extent such circumvention +is effected by exercising rights under this License with respect to +the covered work, and you disclaim any intention to limit operation or +modification of the work as a means of enforcing, against the work's +users, your or third parties' legal rights to forbid circumvention of +technological measures. + + 4. Conveying Verbatim Copies. + + You may convey verbatim copies of the Program's source code as you +receive it, in any medium, provided that you conspicuously and +appropriately publish on each copy an appropriate copyright notice; +keep intact all notices stating that this License and any +non-permissive terms added in accord with section 7 apply to the code; +keep intact all notices of the absence of any warranty; and give all +recipients a copy of this License along with the Program. + + You may charge any price or no price for each copy that you convey, +and you may offer support or warranty protection for a fee. + + 5. Conveying Modified Source Versions. + + You may convey a work based on the Program, or the modifications to +produce it from the Program, in the form of source code under the +terms of section 4, provided that you also meet all of these conditions: + + a) The work must carry prominent notices stating that you modified + it, and giving a relevant date. + + b) The work must carry prominent notices stating that it is + released under this License and any conditions added under section + 7. This requirement modifies the requirement in section 4 to + "keep intact all notices". + + c) You must license the entire work, as a whole, under this + License to anyone who comes into possession of a copy. This + License will therefore apply, along with any applicable section 7 + additional terms, to the whole of the work, and all its parts, + regardless of how they are packaged. This License gives no + permission to license the work in any other way, but it does not + invalidate such permission if you have separately received it. + + d) If the work has interactive user interfaces, each must display + Appropriate Legal Notices; however, if the Program has interactive + interfaces that do not display Appropriate Legal Notices, your + work need not make them do so. + + A compilation of a covered work with other separate and independent +works, which are not by their nature extensions of the covered work, +and which are not combined with it such as to form a larger program, +in or on a volume of a storage or distribution medium, is called an +"aggregate" if the compilation and its resulting copyright are not +used to limit the access or legal rights of the compilation's users +beyond what the individual works permit. Inclusion of a covered work +in an aggregate does not cause this License to apply to the other +parts of the aggregate. + + 6. Conveying Non-Source Forms. + + You may convey a covered work in object code form under the terms +of sections 4 and 5, provided that you also convey the +machine-readable Corresponding Source under the terms of this License, +in one of these ways: + + a) Convey the object code in, or embodied in, a physical product + (including a physical distribution medium), accompanied by the + Corresponding Source fixed on a durable physical medium + customarily used for software interchange. + + b) Convey the object code in, or embodied in, a physical product + (including a physical distribution medium), accompanied by a + written offer, valid for at least three years and valid for as + long as you offer spare parts or customer support for that product + model, to give anyone who possesses the object code either (1) a + copy of the Corresponding Source for all the software in the + product that is covered by this License, on a durable physical + medium customarily used for software interchange, for a price no + more than your reasonable cost of physically performing this + conveying of source, or (2) access to copy the + Corresponding Source from a network server at no charge. + + c) Convey individual copies of the object code with a copy of the + written offer to provide the Corresponding Source. This + alternative is allowed only occasionally and noncommercially, and + only if you received the object code with such an offer, in accord + with subsection 6b. + + d) Convey the object code by offering access from a designated + place (gratis or for a charge), and offer equivalent access to the + Corresponding Source in the same way through the same place at no + further charge. You need not require recipients to copy the + Corresponding Source along with the object code. If the place to + copy the object code is a network server, the Corresponding Source + may be on a different server (operated by you or a third party) + that supports equivalent copying facilities, provided you maintain + clear directions next to the object code saying where to find the + Corresponding Source. Regardless of what server hosts the + Corresponding Source, you remain obligated to ensure that it is + available for as long as needed to satisfy these requirements. + + e) Convey the object code using peer-to-peer transmission, provided + you inform other peers where the object code and Corresponding + Source of the work are being offered to the general public at no + charge under subsection 6d. + + A separable portion of the object code, whose source code is excluded +from the Corresponding Source as a System Library, need not be +included in conveying the object code work. + + A "User Product" is either (1) a "consumer product", which means any +tangible personal property which is normally used for personal, family, +or household purposes, or (2) anything designed or sold for incorporation +into a dwelling. In determining whether a product is a consumer product, +doubtful cases shall be resolved in favor of coverage. For a particular +product received by a particular user, "normally used" refers to a +typical or common use of that class of product, regardless of the status +of the particular user or of the way in which the particular user +actually uses, or expects or is expected to use, the product. A product +is a consumer product regardless of whether the product has substantial +commercial, industrial or non-consumer uses, unless such uses represent +the only significant mode of use of the product. + + "Installation Information" for a User Product means any methods, +procedures, authorization keys, or other information required to install +and execute modified versions of a covered work in that User Product from +a modified version of its Corresponding Source. The information must +suffice to ensure that the continued functioning of the modified object +code is in no case prevented or interfered with solely because +modification has been made. + + If you convey an object code work under this section in, or with, or +specifically for use in, a User Product, and the conveying occurs as +part of a transaction in which the right of possession and use of the +User Product is transferred to the recipient in perpetuity or for a +fixed term (regardless of how the transaction is characterized), the +Corresponding Source conveyed under this section must be accompanied +by the Installation Information. But this requirement does not apply +if neither you nor any third party retains the ability to install +modified object code on the User Product (for example, the work has +been installed in ROM). + + The requirement to provide Installation Information does not include a +requirement to continue to provide support service, warranty, or updates +for a work that has been modified or installed by the recipient, or for +the User Product in which it has been modified or installed. Access to a +network may be denied when the modification itself materially and +adversely affects the operation of the network or violates the rules and +protocols for communication across the network. + + Corresponding Source conveyed, and Installation Information provided, +in accord with this section must be in a format that is publicly +documented (and with an implementation available to the public in +source code form), and must require no special password or key for +unpacking, reading or copying. + + 7. Additional Terms. + + "Additional permissions" are terms that supplement the terms of this +License by making exceptions from one or more of its conditions. +Additional permissions that are applicable to the entire Program shall +be treated as though they were included in this License, to the extent +that they are valid under applicable law. If additional permissions +apply only to part of the Program, that part may be used separately +under those permissions, but the entire Program remains governed by +this License without regard to the additional permissions. + + When you convey a copy of a covered work, you may at your option +remove any additional permissions from that copy, or from any part of +it. (Additional permissions may be written to require their own +removal in certain cases when you modify the work.) You may place +additional permissions on material, added by you to a covered work, +for which you have or can give appropriate copyright permission. + + Notwithstanding any other provision of this License, for material you +add to a covered work, you may (if authorized by the copyright holders of +that material) supplement the terms of this License with terms: + + a) Disclaiming warranty or limiting liability differently from the + terms of sections 15 and 16 of this License; or + + b) Requiring preservation of specified reasonable legal notices or + author attributions in that material or in the Appropriate Legal + Notices displayed by works containing it; or + + c) Prohibiting misrepresentation of the origin of that material, or + requiring that modified versions of such material be marked in + reasonable ways as different from the original version; or + + d) Limiting the use for publicity purposes of names of licensors or + authors of the material; or + + e) Declining to grant rights under trademark law for use of some + trade names, trademarks, or service marks; or + + f) Requiring indemnification of licensors and authors of that + material by anyone who conveys the material (or modified versions of + it) with contractual assumptions of liability to the recipient, for + any liability that these contractual assumptions directly impose on + those licensors and authors. + + All other non-permissive additional terms are considered "further +restrictions" within the meaning of section 10. If the Program as you +received it, or any part of it, contains a notice stating that it is +governed by this License along with a term that is a further +restriction, you may remove that term. If a license document contains +a further restriction but permits relicensing or conveying under this +License, you may add to a covered work material governed by the terms +of that license document, provided that the further restriction does +not survive such relicensing or conveying. + + If you add terms to a covered work in accord with this section, you +must place, in the relevant source files, a statement of the +additional terms that apply to those files, or a notice indicating +where to find the applicable terms. + + Additional terms, permissive or non-permissive, may be stated in the +form of a separately written license, or stated as exceptions; +the above requirements apply either way. + + 8. Termination. + + You may not propagate or modify a covered work except as expressly +provided under this License. Any attempt otherwise to propagate or +modify it is void, and will automatically terminate your rights under +this License (including any patent licenses granted under the third +paragraph of section 11). + + However, if you cease all violation of this License, then your +license from a particular copyright holder is reinstated (a) +provisionally, unless and until the copyright holder explicitly and +finally terminates your license, and (b) permanently, if the copyright +holder fails to notify you of the violation by some reasonable means +prior to 60 days after the cessation. + + Moreover, your license from a particular copyright holder is +reinstated permanently if the copyright holder notifies you of the +violation by some reasonable means, this is the first time you have +received notice of violation of this License (for any work) from that +copyright holder, and you cure the violation prior to 30 days after +your receipt of the notice. + + Termination of your rights under this section does not terminate the +licenses of parties who have received copies or rights from you under +this License. If your rights have been terminated and not permanently +reinstated, you do not qualify to receive new licenses for the same +material under section 10. + + 9. Acceptance Not Required for Having Copies. + + You are not required to accept this License in order to receive or +run a copy of the Program. Ancillary propagation of a covered work +occurring solely as a consequence of using peer-to-peer transmission +to receive a copy likewise does not require acceptance. However, +nothing other than this License grants you permission to propagate or +modify any covered work. These actions infringe copyright if you do +not accept this License. Therefore, by modifying or propagating a +covered work, you indicate your acceptance of this License to do so. + + 10. Automatic Licensing of Downstream Recipients. + + Each time you convey a covered work, the recipient automatically +receives a license from the original licensors, to run, modify and +propagate that work, subject to this License. You are not responsible +for enforcing compliance by third parties with this License. + + An "entity transaction" is a transaction transferring control of an +organization, or substantially all assets of one, or subdividing an +organization, or merging organizations. If propagation of a covered +work results from an entity transaction, each party to that +transaction who receives a copy of the work also receives whatever +licenses to the work the party's predecessor in interest had or could +give under the previous paragraph, plus a right to possession of the +Corresponding Source of the work from the predecessor in interest, if +the predecessor has it or can get it with reasonable efforts. + + You may not impose any further restrictions on the exercise of the +rights granted or affirmed under this License. For example, you may +not impose a license fee, royalty, or other charge for exercise of +rights granted under this License, and you may not initiate litigation +(including a cross-claim or counterclaim in a lawsuit) alleging that +any patent claim is infringed by making, using, selling, offering for +sale, or importing the Program or any portion of it. + + 11. Patents. + + A "contributor" is a copyright holder who authorizes use under this +License of the Program or a work on which the Program is based. The +work thus licensed is called the contributor's "contributor version". + + A contributor's "essential patent claims" are all patent claims +owned or controlled by the contributor, whether already acquired or +hereafter acquired, that would be infringed by some manner, permitted +by this License, of making, using, or selling its contributor version, +but do not include claims that would be infringed only as a +consequence of further modification of the contributor version. For +purposes of this definition, "control" includes the right to grant +patent sublicenses in a manner consistent with the requirements of +this License. + + Each contributor grants you a non-exclusive, worldwide, royalty-free +patent license under the contributor's essential patent claims, to +make, use, sell, offer for sale, import and otherwise run, modify and +propagate the contents of its contributor version. + + In the following three paragraphs, a "patent license" is any express +agreement or commitment, however denominated, not to enforce a patent +(such as an express permission to practice a patent or covenant not to +sue for patent infringement). To "grant" such a patent license to a +party means to make such an agreement or commitment not to enforce a +patent against the party. + + If you convey a covered work, knowingly relying on a patent license, +and the Corresponding Source of the work is not available for anyone +to copy, free of charge and under the terms of this License, through a +publicly available network server or other readily accessible means, +then you must either (1) cause the Corresponding Source to be so +available, or (2) arrange to deprive yourself of the benefit of the +patent license for this particular work, or (3) arrange, in a manner +consistent with the requirements of this License, to extend the patent +license to downstream recipients. "Knowingly relying" means you have +actual knowledge that, but for the patent license, your conveying the +covered work in a country, or your recipient's use of the covered work +in a country, would infringe one or more identifiable patents in that +country that you have reason to believe are valid. + + If, pursuant to or in connection with a single transaction or +arrangement, you convey, or propagate by procuring conveyance of, a +covered work, and grant a patent license to some of the parties +receiving the covered work authorizing them to use, propagate, modify +or convey a specific copy of the covered work, then the patent license +you grant is automatically extended to all recipients of the covered +work and works based on it. + + A patent license is "discriminatory" if it does not include within +the scope of its coverage, prohibits the exercise of, or is +conditioned on the non-exercise of one or more of the rights that are +specifically granted under this License. You may not convey a covered +work if you are a party to an arrangement with a third party that is +in the business of distributing software, under which you make payment +to the third party based on the extent of your activity of conveying +the work, and under which the third party grants, to any of the +parties who would receive the covered work from you, a discriminatory +patent license (a) in connection with copies of the covered work +conveyed by you (or copies made from those copies), or (b) primarily +for and in connection with specific products or compilations that +contain the covered work, unless you entered into that arrangement, +or that patent license was granted, prior to 28 March 2007. + + Nothing in this License shall be construed as excluding or limiting +any implied license or other defenses to infringement that may +otherwise be available to you under applicable patent law. + + 12. No Surrender of Others' Freedom. + + If conditions are imposed on you (whether by court order, agreement or +otherwise) that contradict the conditions of this License, they do not +excuse you from the conditions of this License. If you cannot convey a +covered work so as to satisfy simultaneously your obligations under this +License and any other pertinent obligations, then as a consequence you may +not convey it at all. For example, if you agree to terms that obligate you +to collect a royalty for further conveying from those to whom you convey +the Program, the only way you could satisfy both those terms and this +License would be to refrain entirely from conveying the Program. + + 13. Use with the GNU Affero General Public License. + + Notwithstanding any other provision of this License, you have +permission to link or combine any covered work with a work licensed +under version 3 of the GNU Affero General Public License into a single +combined work, and to convey the resulting work. The terms of this +License will continue to apply to the part which is the covered work, +but the special requirements of the GNU Affero General Public License, +section 13, concerning interaction through a network will apply to the +combination as such. + + 14. Revised Versions of this License. + + The Free Software Foundation may publish revised and/or new versions of +the GNU General Public License from time to time. Such new versions will +be similar in spirit to the present version, but may differ in detail to +address new problems or concerns. + + Each version is given a distinguishing version number. If the +Program specifies that a certain numbered version of the GNU General +Public License "or any later version" applies to it, you have the +option of following the terms and conditions either of that numbered +version or of any later version published by the Free Software +Foundation. If the Program does not specify a version number of the +GNU General Public License, you may choose any version ever published +by the Free Software Foundation. + + If the Program specifies that a proxy can decide which future +versions of the GNU General Public License can be used, that proxy's +public statement of acceptance of a version permanently authorizes you +to choose that version for the Program. + + Later license versions may give you additional or different +permissions. However, no additional obligations are imposed on any +author or copyright holder as a result of your choosing to follow a +later version. + + 15. Disclaimer of Warranty. + + THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY +APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT +HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY +OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, +THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM +IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF +ALL NECESSARY SERVICING, REPAIR OR CORRECTION. + + 16. Limitation of Liability. + + IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING +WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS +THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY +GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE +USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF +DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD +PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), +EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF +SUCH DAMAGES. + + 17. Interpretation of Sections 15 and 16. + + If the disclaimer of warranty and limitation of liability provided +above cannot be given local legal effect according to their terms, +reviewing courts shall apply local law that most closely approximates +an absolute waiver of all civil liability in connection with the +Program, unless a warranty or assumption of liability accompanies a +copy of the Program in return for a fee. + + END OF TERMS AND CONDITIONS + + How to Apply These Terms to Your New Programs + + If you develop a new program, and you want it to be of the greatest +possible use to the public, the best way to achieve this is to make it +free software which everyone can redistribute and change under these terms. + + To do so, attach the following notices to the program. It is safest +to attach them to the start of each source file to most effectively +state the exclusion of warranty; and each file should have at least +the "copyright" line and a pointer to where the full notice is found. + + + Copyright (C) + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . + +Also add information on how to contact you by electronic and paper mail. + + If the program does terminal interaction, make it output a short +notice like this when it starts in an interactive mode: + + Copyright (C) + This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'. + This is free software, and you are welcome to redistribute it + under certain conditions; type `show c' for details. + +The hypothetical commands `show w' and `show c' should show the appropriate +parts of the General Public License. Of course, your program's commands +might be different; for a GUI interface, you would use an "about box". + + You should also get your employer (if you work as a programmer) or school, +if any, to sign a "copyright disclaimer" for the program, if necessary. +For more information on this, and how to apply and follow the GNU GPL, see +. + + The GNU General Public License does not permit incorporating your program +into proprietary programs. If your program is a subroutine library, you +may consider it more useful to permit linking proprietary applications with +the library. If this is what you want to do, use the GNU Lesser General +Public License instead of this License. But first, please read +. \ No newline at end of file diff --git a/classes/admin.php b/classes/admin.php new file mode 100644 index 0000000..1027ec1 --- /dev/null +++ b/classes/admin.php @@ -0,0 +1,124 @@ +get_options(); + + // loop through menu and find the one I need to disable + foreach( $menu as $key => $value ) { + if ( in_array( 'edit.php?post_type=sm-location' , $value ) ) { + unset( $menu[$key] ); + } + } + add_menu_page(__('SimpleMap Options', 'SimpleMap'), 'SimpleMap', apply_filters( 'sm-admin-permissions-sm-options', 'publish_posts' ), 'simplemap', array( &$sm_options, 'print_page' ), SIMPLEMAP_URL.'/inc/images/icon.png' ); + add_submenu_page( 'simplemap', __('SimpleMap: General Options', 'SimpleMap'), __( 'General Options', 'SimpleMap'), apply_filters( 'sm-admin-permissions-sm-options', 'manage_options' ), 'simplemap', array( &$sm_options, 'print_page' ) ); + add_submenu_page( 'simplemap', __('SimpleMap: Add Location', 'SimpleMap'), __( 'Add Location', 'SimpleMap' ), apply_filters( 'sm-admin-permissions-sm-add-locations', 'publish_posts' ), 'post-new.php?post_type=sm-location' ); + add_submenu_page( 'simplemap', __('SimpleMap: Edit Locations', 'SimpleMap'), __( 'Edit Locations', 'SimpleMap' ), apply_filters( 'sm-admin-permissions-sm-edit-locations', 'publish_posts' ), 'edit.php?post_type=sm-location' ); + + foreach ( $options['taxonomies'] as $taxonomy => $tax_info ) { + add_submenu_page( 'simplemap', __('SimpleMap: Location ' . $tax_info['plural'], 'SimpleMap'), __( 'Location ' . $tax_info['plural'], 'SimpleMap' ), 'publish_posts', 'edit-tags.php?taxonomy=' . $taxonomy . '&post_type=sm-location' ); + } + + add_submenu_page( 'simplemap', __('SimpleMap: Import / Export CSV', 'SimpleMap'), __('Import / Export CSV', 'SimpleMap'), 'publish_posts', 'simplemap-import-export', array( &$sm_import_export, 'print_page' ) ); + add_submenu_page( 'simplemap', __('SimpleMap: Premium Support', 'SimpleMap'), __('Premium Support', 'SimpleMap'), 'publish_posts', 'simplemap-help', array( &$sm_help, 'print_page' ) ); + } + + // Print admin scripts + function load_admin_scripts(){ + global $current_screen; + + #### GENERAL OPTIONS PAGE #### + if ( 'toplevel_page_simplemap' == $current_screen->id ) : + ?> + + checked[SIMPLEMAP_FILE] ) ) { + return; // <--- Remove to enable + $options = get_option( 'SimpleMap_options' ); + if ( empty( $options ) ) { + $options = array( 'auto_locate' => 'html5' ); + update_option( 'SimpleMap_options', $options ); + } + } + } +} +?> diff --git a/classes/ft-ps-client.php b/classes/ft-ps-client.php new file mode 100644 index 0000000..074f9dc --- /dev/null +++ b/classes/ft-ps-client.php @@ -0,0 +1,827 @@ +server_url = isset( $config['server_url'] ) ? $config['server_url'] : false; + $this->product_id = isset( $config['product_id'] ) ? $config['product_id'] : false; + $this->plugin_support_page_ids = isset( $config['plugin_support_page_ids'] ) ? $config['plugin_support_page_ids'] : false; + $this->plugin_basename = isset( $config['plugin_basename'] ) ? $config['plugin_basename'] : false; + $this->plugin_slug = isset( $config['plugin_slug'] ) ? $config['plugin_slug'] : false; + $this->learn_more_link = isset( $config['learn_more_link'] ) ? $config['learn_more_link'] : false; + $this->confirming_request = isset( $_GET['ft-ps-confirm-request'] ) ? $_GET['ft-ps-confirm-request'] : false; + $this->receiving_sso = isset( $_POST['ft-ps-receiving-sso'] ) ? $_POST['ft-ps-receiving-sso'] : false; + $this->site_url = site_url(); + + // Register actions + add_action( 'admin_head', array( &$this, 'init' ) ); + add_action( 'init', array( &$this, 'check_premium_upgrades' ) ); + + } + + // Checks for premium upgrades + function check_premium_upgrades() { + // Build key + $exp_option_key = '_ftpssu_' . md5( 'ftpssue-' . $this->product_id . '-' . sanitize_title_with_dashes( $this->site_url ) . '-' . sanitize_title_with_dashes( $this->server_url ) ); + + // Check server for auto update? + if ( $expires = get_option( $exp_option_key ) ) { + + if ( $expires > strtotime( 'now' ) ) + $ft_ps_client_auto_update = new FT_Premium_Support_PluginUpdate_Checker( $this->server_url . '?ft-pss-upgrade-request=1&ft-pss-upgrade-request-product-id=' . $this->product_id . '&ft-pss-upgrade-request-site=' . $this->site_url . '&exp=' . $expires, $this->plugin_basename, $this->plugin_slug, 1 ); + else + delete_option( 'external_updates-' . $this->plugin_slug ); + + } + + } + + // Inits the client if we're on the support page or receiving a request from the server + function init() { + + global $current_screen; + + // Return false if we don't have initial config settings and this isn't a request from the host server + if ( ( ! $this->server_url || ! $this->product_id || ! isset( $this->plugin_support_page_ids ) ) && ( ! $this->confirming_request || ! $this->receiving_sso ) ) + return; + + // Fire in the hole! + if ( $this->receiving_sso ) + $this->receive_sso(); + elseif ( $this->confirming_request ) + $this->confirm_request(); + elseif ( in_array( $current_screen->id, $this->plugin_support_page_ids ) ) + $this->init_premium_support(); + + } + + // This function inits premium support process + function init_premium_support() { + + global $current_user; + wp_get_current_user(); + + // Check for premium support, sso, and paypal button transients + $status_key = md5( 'ft_premium_support_' . $this->product_id . '_' . sanitize_title_with_dashes( $this->site_url ) . '_' . sanitize_title_with_dashes( $this->server_url ) ) ; + $sso_key = md5( 'ft_premium_sso_' . $current_user->ID . '_' . $this->product_id . '_' . sanitize_title_with_dashes( $this->site_url ) . '_' . sanitize_title_with_dashes( $this->server_url ) ); + $paypal_button_key = md5( 'ft_premium_signup_' . $this->product_id . '_' . sanitize_title_with_dashes( $this->site_url ) . '_' . sanitize_title_with_dashes( $this->server_url ) ); + $exp_option_key = '_ftpssu_' . md5( 'ftpssue-' . $this->product_id . '-' . sanitize_title_with_dashes( $this->site_url ) . '-' . sanitize_title_with_dashes( $this->server_url ) ); + + // If we haven't set the status in the last 24 hours, or we haven't set a SSO for the current user in the last 3 hours, do it now. + if ( false === ( $ps_status = get_transient( $status_key ) ) || false === ( $sso_status = get_transient( $sso_key ) ) ) { + + $body['ft-ps-status-request'] = true; + $body['site'] = urlencode( $this->site_url ); + $body['user'] = $current_user->ID; + $body['product'] = $this->product_id; + $body['email'] = urlencode( $current_user->user_email ); + $body['nicename'] = urlencode( $current_user->user_nicename ); + + // Ping server for response + if ( $request = wp_remote_post( $this->server_url, array( 'body' => $body, 'timeout' => 20 ) ) ) { + + if ( isset( $request['response']['code'] ) && 200 == $request['response']['code'] ) { + + // Response found a server, lets see if it hit a script we recognize + $response = json_decode( $request['body'] ); + + // Set the paypal button + if ( ! empty( $response->paypal_button->args ) && ! empty( $response->paypal_button->base) ) + $this->paypal_button = add_query_arg( get_object_vars( $response->paypal_button->args ), $response->paypal_button->base ); + + // Set the expired flag + $this->support_expired = isset( $response->support_expired ) ? $response->support_expired : false; + + // Do we have a premium status? + if ( isset( $response->support_status ) && $response->support_status ) { + + // We have a premium support license for this domain / product combination. Set the transient and property + set_transient( $status_key, $response->support_status, 60*60*24 ); + //set_transient( $status_key, $response->support_status, 60 ); + $this->ps_status = $response->support_status; + + // Did we get a user sso back as well? Set the property if we did + if ( isset( $response->user_sso ) && '' != $response->user_sso ) { + set_transient( $sso_key, $response->user_sso, 60*60*2.9 ); + //set_transient( $sso_key, $response->user_sso, 60 ); + $this->sso_status = $response->user_sso; + } + + // Set an auto update option with expiration date + if ( isset( $response->support_status->exp_date ) && ! empty( $response->support_status->exp_date ) ) { + update_option( $exp_option_key, $response->support_status->exp_date ); + + // Check server for auto update? + if ( $this->ps_status ) { + delete_option( 'external_updates-' . $this->plugin_slug ); + $ft_ps_client_auto_update = new FT_Premium_Support_PluginUpdate_Checker( $this->server_url . '?ft-pss-premium-request=1&ft-pss-upgrade-request-product-id=' . $this->product_id . '&ft-pss-upgrade-request-site=' . $this->site_url . '&exp=' . $response->support_status->exp_date, SIMPLEMAP_PATH, $this->plugin_slug, 1 ); + } + + } + + } else { + + // No premium support so lets delete the keys + delete_option( 'external_updates-' . $this->plugin_slug ); + delete_option( $exp_option_key ); + } + } + } + } else { + + // Transients exist, therefore permission exists, set properties + $this->ps_status = $ps_status; + $this->sso_status = $sso_status; + + } + + // Check server for auto update? + if ( $this->ps_status ) + $ft_ps_client_auto_update = new FT_Premium_Support_PluginUpdate_Checker( $this->server_url . '?ft-pss-upgrade-request=1&ft-pss-upgrade-request-product-id=' . $this->product_id . '&ft-pss-upgrade-request-site=' . $this->site_url, $this->plugin_basename, 'simplemap', 1 ); + + // Maybe Nag Renewal + $this->maybe_trigger_renewal_nag(); + + } + + function maybe_trigger_renewal_nag() { + // Has support expired? + if ( ! empty( $this->support_expired ) && ! is_object( $this->support_expired ) ) { + add_action( 'admin_notices', array( $this, 'support_expired' ) ); + return; + } + + if ( ! empty( $this->ps_status->exp_date ) ) { + $onemonthout = $this->ps_status->exp_date - 2628000; + // If we are within a month of expiration date + if ( $onemonthout <= strtotime( 'now' ) ) { + add_action( 'admin_notices', array( $this, 'renew_soon' ) ); + } + } + + } + + function support_expired() { + $link = ( $this->paypal_button ) ? esc_url( $this->paypal_button ) : 'http://simplemap-plugin.com'; + echo "
" . sprintf( __( "Your license for SimpleMap has expired!
You need to renew your license now for continued support and upgrades: Renew my license now." ), $link ) . "
"; + } + + function renew_soon() { + $link = ( $this->paypal_button ) ? esc_url( $this->paypal_button ) : 'http://simplemap-plugin.com'; + echo "
" . sprintf( __( "SimpleMap is expiring soon!
You will need to renew your license for continued support and upgrades: Renew my license now." ), $link ) . "
"; + } + + } + +} + +if ( !class_exists( 'FT_Premium_Support_PluginUpdate_Checker' ) ) : + +/** + * A custom plugin update checker. + * + * @author Janis Elsts + * @copyright 2010 + * @version 1.0 + * @access public + */ +class FT_Premium_Support_PluginUpdate_Checker { + + var $metadataUrl = ''; //The URL of the plugin's metadata file. + var $pluginFile = ''; //Plugin filename relative to the plugins directory. + var $slug = ''; //Plugin slug. + var $checkPeriod = 12; //How often to check for updates (in hours). + var $optionName = ''; //Where to store the update info. + + /** + * Class constructor. + * + * @param string $metadataUrl The URL of the plugin's metadata file. + * @param string $pluginFile Fully qualified path to the main plugin file. + * @param string $slug The plugin's 'slug'. If not specified, the filename part of $pluginFile sans '.php' will be used as the slug. + * @param integer $checkPeriod How often to check for updates (in hours). Defaults to checking every 12 hours. Set to 0 to disable automatic update checks. + * @param string $optionName Where to store book-keeping info about update checks. Defaults to 'external_updates-$slug'. + * @return void + */ + function __construct( $metadataUrl, $pluginFile, $slug = '', $checkPeriod = 12, $optionName = '' ){ + + $this->metadataUrl = $metadataUrl; + $this->pluginFile = $pluginFile; + $this->checkPeriod = $checkPeriod; + $this->slug = $slug; + + //If no slug is specified, use the name of the main plugin file as the slug. + //For example, 'my-cool-plugin/cool-plugin.php' becomes 'cool-plugin'. + if ( empty( $this->slug ) ){ + $this->slug = basename( $this->pluginFile, '.php' ); + } + + if ( empty( $this->optionName ) ) { + $this->optionName = 'external_updates-' . $this->slug; + } + + if ( '' == $optionName ) + $this->optionName = 'external_updates-' . $this->slug; + else + $this->optionName = $optionName; + + $this->installHooks(); + } + + /** + * Install the hooks required to run periodic update checks and inject update info + * into WP data structures. + * + * @return void + */ + function installHooks(){ + + //Override requests for plugin information + add_filter( 'plugins_api', array( &$this, 'injectInfo' ), 10, 3 ); + + //Insert our update info into the update array maintained by WP + add_filter( 'site_transient_update_plugins', array( &$this,'injectUpdate' )); //WP 3.0+ + add_filter( 'transient_update_plugins', array( &$this,'injectUpdate' ) ); //WP 2.8+ + + //Set up the periodic update checks + $cronHook = 'check_plugin_updates-' . $this->slug; + + if ( $this->checkPeriod > 0 ) { + + //Trigger the check via Cron + add_filter( 'cron_schedules', array( &$this, '_addCustomSchedule' ) ); + + if ( ! wp_next_scheduled( $cronHook ) && ! defined( 'WP_INSTALLING' ) ) { + + $scheduleName = 'every' . $this->checkPeriod . 'hours'; + wp_schedule_event( time(), $scheduleName, $cronHook ); + + } + add_action( $cronHook, array( &$this, 'checkForUpdates' ) ); + + //In case Cron is disabled or unreliable, we also manually trigger + //the periodic checks while the user is browsing the Dashboard. + add_action( 'admin_init', array( &$this, 'maybeCheckForUpdates' ) ); + + } else { + //Periodic checks are disabled. + wp_clear_scheduled_hook( $cronHook ); + } + } + + /** + * Add our custom schedule to the array of Cron schedules used by WP. + * + * @param array $schedules + * @return array + */ + function _addCustomSchedule( $schedules ) { + + if ( $this->checkPeriod && ( $this->checkPeriod > 0 ) ) { + $scheduleName = 'every' . $this->checkPeriod . 'hours'; + $schedules[$scheduleName] = array( + 'interval' => $this->checkPeriod * 3600, + 'display' => sprintf( 'Every %d hours', $this->checkPeriod ), + ); + } + + return $schedules; + } + + /** + * Retrieve plugin info from the configured API endpoint. + * + * @uses wp_remote_get() + * + * @param array $queryArgs Additional query arguments to append to the request. Optional. + * @return PluginInfo + */ + function requestInfo( $queryArgs = array() ) { + //Query args to append to the URL. Plugins can add their own by using a filter callback (see addQueryArgFilter()). + $queryArgs['installed_version'] = $this->getInstalledVersion(); + $queryArgs = apply_filters( 'puc_request_info_query_args-' . $this->slug, $queryArgs ); + + //Various options for the wp_remote_get() call. Plugins can filter these, too. + $options = array( + 'timeout' => 10, //seconds + 'headers' => array( + 'Accept' => 'application/json' + ), + ); + + $options = apply_filters( 'puc_request_info_options-' . $this->slug, $options ); + + //The plugin info should be at 'http://your-api.com/url/here/$slug/info.json' + $url = $this->metadataUrl; + if ( ! empty( $queryArgs ) ){ + $url = add_query_arg( $queryArgs, $url ); + } + + $result = wp_remote_get( + $url, + $options + ); + + //Try to parse the response + $ft_premium_support_plugin_info = null; + if ( !is_wp_error( $result ) && isset( $result['response']['code'] ) && ( $result['response']['code'] == 200 ) && !empty( $result['body'] ) ){ + $ft_premium_support_plugin_info = FT_Premium_Support_PluginInfo::fromJson( $result['body'] ); + } + + $ft_premium_support_plugin_info = apply_filters( 'puc_request_info_result-' . $this->slug, $ft_premium_support_plugin_info, $result ); + + return $ft_premium_support_plugin_info; + } + + /** + * Retrieve the latest update (if any) from the configured API endpoint. + * + * @uses PluginUpdateChecker::requestInfo() + * + * @return PluginUpdate An instance of PluginUpdate, or NULL when no updates are available. + */ + function requestUpdate() { + //For the sake of simplicity, this function just calls requestInfo() + //and transforms the result accordingly. + $ft_premium_support_plugin_info = $this->requestInfo( array( 'checking_for_updates' => '1' ) ); + + if ( $ft_premium_support_plugin_info == null ) + return null; + + return FT_Premium_Support_PluginUpdate::fromPluginInfo( $ft_premium_support_plugin_info ); + } + + /** + * Get the currently installed version of the plugin. + * + * @return string Version number. + */ + function getInstalledVersion() { + + if ( ! function_exists( 'get_plugins' ) ) + require_once( ABSPATH . 'wp-admin/includes/plugin.php' ); + + $allPlugins = get_plugins(); + + if ( array_key_exists( $this->pluginFile, $allPlugins ) && array_key_exists( 'Version', $allPlugins[$this->pluginFile] ) ) + return $allPlugins[$this->pluginFile]['Version']; + else + return ''; //This should never happen. + + } + + /** + * Check for plugin updates. + * The results are stored in the DB option specified in $optionName. + * + * @return void + */ + function checkForUpdates(){ + $state = get_option( $this->optionName ); + + if ( empty($state) ){ + $state = new StdClass; + $state->lastCheck = 0; + $state->checkedVersion = ''; + $state->update = null; + } + + $state->lastCheck = time(); + $state->checkedVersion = $this->getInstalledVersion(); + update_option( $this->optionName, $state ); //Save before checking in case something goes wrong + + $state->update = $this->requestUpdate(); + update_option( $this->optionName, $state ); + } + + /** + * Check for updates only if the configured check interval has already elapsed. + * + * @return void + */ + function maybeCheckForUpdates(){ + + if ( empty( $this->checkPeriod ) ) + return; + + $state = get_option( $this->optionName ); + + $shouldCheck = + empty( $state ) || + ! isset( $state->lastCheck ) || + ( ( time() - $state->lastCheck ) >= $this->checkPeriod*3600 ); + + if ( $shouldCheck ){ + $this->checkForUpdates(); + } + } + + /** + * Intercept plugins_api() calls that request information about our plugin and + * use the configured API endpoint to satisfy them. + * + * @see plugins_api() + * + * @param mixed $result + * @param string $action + * @param array|object $args + * @return mixed + */ + function injectInfo( $result, $action = null, $args = null ) { + + $relevant = ( $action == 'plugin_information') && isset( $args->slug ) && ( $args->slug == $this->slug ); + + if ( !$relevant ){ + return $result; + } + + $ft_premium_support_plugin_info = $this->requestInfo(); + + if ( $ft_premium_support_plugin_info ) + return $ft_premium_support_plugin_info->toWpFormat(); + + return $result; + } + + /** + * Insert the latest update (if any) into the update list maintained by WP. + * + * @param array $updates Update list. + * @return array Modified update list. + */ + function injectUpdate( $updates ){ + + $state = get_option( $this->optionName ); + + //Is there an update to insert? + if ( ! empty( $state ) && isset( $state->update ) && ! empty( $state->update ) ) { + + //Only insert updates that are actually newer than the currently installed version. + if ( version_compare( $state->update->version, $this->getInstalledVersion(), '>' ) ) + $updates->response[$this->pluginFile] = $state->update->toWpFormat(); + + } + + return $updates; + } + + /** + * Register a callback for filtering query arguments. + * + * The callback function should take one argument - an associative array of query arguments. + * It should return a modified array of query arguments. + * + * @uses add_filter() This method is a convenience wrapper for add_filter(). + * + * @param callback $callback + * @return void + */ + function addQueryArgFilter( $callback ) { + add_filter( 'puc_request_info_query_args-' . $this->slug, $callback ); + } + + /** + * Register a callback for filtering arguments passed to wp_remote_get(). + * + * The callback function should take one argument - an associative array of arguments - + * and return a modified array or arguments. See the WP documentation on wp_remote_get() + * for details on what arguments are available and how they work. + * + * @uses add_filter() This method is a convenience wrapper for add_filter(). + * + * @param callback $callback + * @return void + */ + function addHttpRequestArgFilter($callback) { + add_filter( 'puc_request_info_options-' . $this->slug, $callback ); + } + + /** + * Register a callback for filtering the plugin info retrieved from the external API. + * + * The callback function should take two arguments. If the plugin info was retrieved + * successfully, the first argument passed will be an instance of PluginInfo. Otherwise, + * it will be NULL. The second argument will be the corresponding return value of + * wp_remote_get (see WP docs for details). + * + * The callback function should return a new or modified instance of PluginInfo or NULL. + * + * @uses add_filter() This method is a convenience wrapper for add_filter(). + * + * @param callback $callback + * @return void + */ + function addResultFilter( $callback ) { + add_filter( 'puc_request_info_result-' . $this->slug, $callback, 10, 2 ); + } +} + +endif; + +if ( ! class_exists( 'FT_Premium_Support_PluginInfo' ) ) : + +/** + * A container class for holding and transforming various plugin metadata. + * + * @author Janis Elsts + * @copyright 2010 + * @version 1.0 + * @access public + */ +class FT_Premium_Support_PluginInfo { + + //Most fields map directly to the contents of the plugin's info.json file. + //See the relevant docs for a description of their meaning. + var $name; + var $slug; + var $version; + var $homepage; + var $sections; + var $download_url; + + var $author; + var $author_homepage; + + var $requires; + var $tested; + var $upgrade_notice; + + var $rating; + var $num_ratings; + var $downloaded; + var $last_updated; + + var $id = 0; //The native WP.org API returns numeric plugin IDs, but they're not used for anything. + + /** + * Create a new instance of PluginInfo from JSON-encoded plugin info + * returned by an external update API. + * + * @param string $json Valid JSON string representing plugin info. + * @return PluginInfo New instance of PluginInfo, or NULL on error. + */ + function fromJson( $json ){ + $apiResponse = json_decode( $json ); + if ( empty( $apiResponse ) || !is_object( $apiResponse ) ) + return null; + + //Very, very basic validation. + $valid = isset( $apiResponse->name ) && ! empty( $apiResponse->name ) && isset( $apiResponse->version ) && ! empty( $apiResponse->version ); + if ( ! $valid ) + return null; + + $info = new FT_Premium_Support_PluginInfo(); + foreach( get_object_vars( $apiResponse ) as $key => $value ) { + $info->$key = $value; + } + + return $info; + } + + /** + * Transform plugin info into the format used by the native WordPress.org API + * + * @return object + */ + function toWpFormat(){ + $info = new StdClass; + + //The custom update API is built so that many fields have the same name and format + //as those returned by the native WordPress.org API. These can be assigned directly. + $sameFormat = array( + 'name', 'slug', 'version', 'requires', 'tested', 'rating', 'upgrade_notice', + 'num_ratings', 'downloaded', 'homepage', 'last_updated', + ); + + foreach( $sameFormat as $field ){ + if ( isset( $this->$field ) ) + $info->$field = $this->$field; + } + + //Other fields need to be renamed and/or transformed. + $info->download_link = $this->download_url; + + if ( ! empty( $this->author_homepage ) ) + $info->author = sprintf( '%s', $this->author_homepage, $this->author ); + else + $info->author = $this->author; + + if ( is_object( $this->sections ) ){ + $info->sections = get_object_vars( $this->sections ); + } elseif ( is_array( $this->sections ) ) { + $info->sections = $this->sections; + } else { + $info->sections = array( 'description' => '' ); + } + + return $info; + } +} + +endif; + +if ( ! class_exists( 'FT_Premium_Support_PluginUpdate' ) ): + +/** + * A simple container class for holding information about an available update. + * + * @author Janis Elsts + * @copyright 2010 + * @version 1.0 + * @access public + */ +class FT_Premium_Support_PluginUpdate { + + var $id = 0; + var $slug; + var $version; + var $homepage; + var $download_url; + var $upgrade_notice; + + /** + * Create a new instance of PluginUpdate from its JSON-encoded representation. + * + * @param string $json + * @return PluginUpdate + */ + function fromJson( $json ){ + //Since update-related information is simply a subset of the full plugin info, + //we can parse the update JSON as if it was a plugin info string, then copy over + //the parts that we care about. + $ft_premium_support_plugin_info = FT_Premium_Support_PluginInfo::fromJson( $json ); + if ( $ft_premium_support_plugin_info != null ) + return FT_Premium_Support_PluginUpdate::fromPluginInfo( $ft_premium_support_plugin_info ); + else + return null; + + } + + /** + * Create a new instance of PluginUpdate based on an instance of PluginInfo. + * Basically, this just copies a subset of fields from one object to another. + * + * @param PluginInfo $info + * @return PluginUpdate + */ + function fromPluginInfo( $info ){ + + $update = new FT_Premium_Support_PluginUpdate(); + $copyFields = array( 'id', 'slug', 'version', 'homepage', 'download_url', 'upgrade_notice' ); + foreach( $copyFields as $field ) { + $update->$field = $info->$field; + } + + return $update; + + } + + /** + * Transform the update into the format used by WordPress native plugin API. + * + * @return object + */ + function toWpFormat(){ + + $update = new StdClass; + + $update->id = $this->id; + $update->slug = $this->slug; + $update->new_version = $this->version; + $update->url = $this->homepage; + $update->package = $this->download_url; + + if ( ! empty( $this->upgrade_notice ) ) + $update->upgrade_notice = $this->upgrade_notice; + + return $update; + + } + +} + +endif; + +/** + * Checks for premium support + */ +function url_has_ftps_for_item( &$ps_object ) { + + if ( is_object( $ps_object ) && $ps_object->ps_status ) + return true; + + return false; + +} + +/** + * Return paypal button + */ +function get_ftps_paypal_button( &$ps_object ) { + + if ( is_object( $ps_object ) && isset( $ps_object->paypal_button ) ) + return $ps_object->paypal_button; + + return false; +} + +/** + * Return learn more link + */ +function get_ftps_learn_more_link( &$ps_object ) { + + if ( is_object( $ps_object ) && isset( $ps_object->learn_more_link ) ) + return $ps_object->learn_more_link; + + return false; +} + +/** + * Return SSO key + */ +function get_ftps_sso_key( &$ps_object ) { + + if ( is_object( $ps_object ) && isset( $ps_object->sso_status ) ) + return $ps_object->sso_status; + + return false; +} + +/** + * Return this site URL that has premium support + */ +function get_ftps_site( &$ps_object ) { + + if ( is_object( $ps_object ) && isset( $ps_object->ps_status->site ) ) + return $ps_object->ps_status->site; + + return false; +} + +/** + * Return purchase date + */ +function get_ftps_purchase_date( &$ps_object ) { + + if ( is_object( $ps_object ) && isset( $ps_object->ps_status->purchase_date ) ) + return $ps_object->ps_status->purchase_date; + + return false; +} + +/** + * Return expiration date + */ +function get_ftps_exp_date( &$ps_object ) { + + if ( is_object( $ps_object ) && isset( $ps_object->ps_status->exp_date ) ) + return $ps_object->ps_status->exp_date; + + return false; +} + +/** + * Return email of person who purchased premium support + */ +function get_ftps_email( &$ps_object ) { + + if ( is_object( $ps_object ) && isset( $ps_object->ps_status->email ) ) + return $ps_object->ps_status->email; + + return false; +} + +/** + * Return name of person who purchased premium support + */ +function get_ftps_name( &$ps_object ) { + + if ( is_object( $ps_object ) && isset( $ps_object->ps_status->name ) ) + return $ps_object->ps_status->name; + + return false; +} + +?> diff --git a/classes/help.php b/classes/help.php new file mode 100644 index 0000000..90c4818 --- /dev/null +++ b/classes/help.php @@ -0,0 +1,250 @@ +get_options(); + + extract( $options ); + + ?> +
+ + show_toolbar( $sm_page_title ); + ?> + +

| | |

+ +
+ +
+ +
+ +
+ + +
+ +

+ +
+ +
+ + + + + +
+
+ +
+ +
+
+ + + + +
+ +

+ +
+ +
+ + + + + + + + + + + + + + + + + + + + +
[simplemap]
[simplemap categories=2,5,14 tags=3,6,15]
[simplemap show_categories_filter=false show_tags_filter=false]
[simplemap hide_map=true]
[simplemap hide_list=true]
[simplemap default_lat='34.1346702' default_lng='-118.4389877']
[simplemap categories=2,5,14 show_tags_filter=false]
', '' ); ?>
+
+ +
+ +
+
+ + + + +
+ +

+ +
+ +
+ + + + + + + + + + + + + + + + + +
+ ', ''); ?>
+ ', '' ); ?>
+ ', '', '', '' ); ?>

+ + +
+
+ +
+ +
+
+ + + + +
+ +

+ +
+ +
+ + + + + + +
+
+
+
+ +
+ +
+
+ +
+ +
+
+ + + + +
+ +
+ +
+ +
+ + + + + +
+ +

+ +
+ + + +

+

+ +

+

+ +

+ +
    +
  • +
  • +
  • +
  • +
+ +
    +
  • +
  • +
+ + +

%s was purchased on %s by %s (%s). It will remain valid for this URL until %s.", get_ftps_site( $simplemap_ps ), date( "F d, Y", get_ftps_purchase_date( $simplemap_ps ) ), get_ftps_name( $simplemap_ps ), get_ftps_email( $simplemap_ps ), date( "F d, Y", get_ftps_exp_date( $simplemap_ps ) ) ); ?>

+

|

+ + + + + +
+
+ + + +
+
+ +
+ +
+
+
+
+ diff --git a/classes/import-export.php b/classes/import-export.php new file mode 100644 index 0000000..6c854b7 --- /dev/null +++ b/classes/import-export.php @@ -0,0 +1,803 @@ + 'publish', 'post_type' => 'sm-location', 'posts_per_page' => -1 ) ); + // Include CSV library + require_once( SIMPLEMAP_PATH . '/classes/parsecsv.lib.php' ); + $taxonomies = get_object_taxonomies( 'sm-location' ); + + foreach ( $locations as $key => $location ) { + $location_data = array( + 'name' => esc_attr( $location->post_title ), + 'address' => esc_attr( get_post_meta( $location->ID, 'location_address', true ) ), + 'address2' => esc_attr( get_post_meta( $location->ID, 'location_address2', true ) ), + 'city' => esc_attr( get_post_meta( $location->ID, 'location_city', true ) ), + 'state' => esc_attr( get_post_meta( $location->ID, 'location_state', true ) ), + 'zip' => esc_attr( get_post_meta( $location->ID, 'location_zip', true ) ), + 'country' => esc_attr( get_post_meta( $location->ID, 'location_country', true ) ), + 'phone' => esc_attr( get_post_meta( $location->ID, 'location_phone', true ) ), + 'email' => esc_attr( get_post_meta( $location->ID, 'location_email', true ) ), + 'fax' => esc_attr( get_post_meta( $location->ID, 'location_fax', true ) ), + 'url' => esc_attr( get_post_meta( $location->ID, 'location_url', true ) ), + 'description' => esc_attr( $location->post_content ), + 'special' => esc_attr( get_post_meta( $location->ID, 'location_special', true ) ), + 'lat' => esc_attr( get_post_meta( $location->ID, 'location_lat', true ) ), + 'lng' => esc_attr( get_post_meta( $location->ID, 'location_lng', true ) ), + 'dateUpdated' => esc_attr( $location->post_modified ) + ); + + foreach ( $taxonomies as $tax ) { + $term_value = ''; + if ( $terms = wp_get_object_terms( $location->ID, $tax, array( 'fields' => 'names' ) ) ) { + $term_value = implode( ',', $terms ); + } + $location_data["tax_$tax"] = esc_attr( $term_value ); + } + + $content[] = $location_data; + } + + if ( ! empty( $content ) ) { + $csv = new smParseCSV(); + $csv->output( true, 'simplemap.csv', $content, array_keys( reset( $content ) ) ); + die(); + } + } + } + + // Exports a LEGACY SimpleMap CSV file to WordPress + function export_legacy_csv() { + global $simple_map, $sm_locations,$wpdb; + + if ( isset( $_GET['sm-action'] ) && 'export-legacy-csv' == $_GET['sm-action'] ) { + + // Include CSV library + include_once( SIMPLEMAP_PATH . '/classes/parsecsv.lib.php' ); + + // Grab Categories + if ( $categories = $wpdb->get_results( "SELECT * FROM `" . $wpdb->prefix . "simple_map_cats`" ) ) { + foreach ( $categories as $key => $value ) { + $cats[$value->id] = $value; + } + } + // Grab locations + if ( $locations = $wpdb->get_results( "SELECT * FROM `" . $wpdb->prefix . "simple_map`" ) ) { + + foreach( $locations as $key => $location ) { + + $catnames = ''; + + // Do Cats + if ( isset( $location->category ) && 0 != $location->category ) { + if ( isset( $cats[$location->category] ) ) + $catnames = $cats[$location->category]->name; + } + $content[] = array( + 'name' => esc_attr( $location->name ), + 'address' => esc_attr( $location->address ), + 'address2' => esc_attr( $location->address2 ), + 'city' => esc_attr( $location->city ), + 'state' => esc_attr( $location->state ), + 'zip' => esc_attr( $location->zip ), + 'country' => esc_attr( $location->country ), + 'phone' => esc_attr( $location->phone ), + 'fax' => esc_attr( $location->fax ), + 'url' => esc_attr( $location->url ), + 'description' => esc_attr( $location->description ), + 'category' => esc_attr( $catnames ), + 'tags' => esc_attr( $location->tags ), + 'special' => esc_attr( $location->special ), + 'lat' => esc_attr( $location->lat ), + 'lng' => esc_attr( $location->lng ), + 'dateUpdated' => esc_attr( $location->dateUpdated ) + ); + + } + + $csv = new smParseCSV(); + $csv->output (true, 'simplemap.csv', $content, array('name','address','address2','city','state','zip','country','phone','fax','url','description','category','tags','special','lat','lng','dateUpdated' ) ); + die(); + + } else { + $csv = new smParseCSV(); + $csv->output (true, 'simplemap.csv', array( array( 'You have no locations in your legacy database' ) ) ); + die(); + } + } + + } + + // Deletes legacy tables + function delete_legacy_tables() { + global $wpdb, $simple_map; + + if ( isset( $_GET['sm-action'] ) && 'delete-legacy-simplemap' == $_GET['sm-action'] ) { + + // Confirm we have both permisssion to do this and we have intent to do this. + if ( current_user_can( 'manage_options' ) && check_admin_referer( 'delete-legacy-simplemap' ) ) { + + $drop_sm = 'DROP TABLE `' . $wpdb->prefix. 'simple_map`;'; + $drop_cats = 'DROP TABLE `' . $wpdb->prefix . 'simple_map_cats`;'; + + $wpdb->query( $drop_sm ); + $wpdb->query( $drop_cats ); + + if ( $simple_map->legacy_tables_exist() ) { + wp_redirect( admin_url( 'admin.php?page=simplemap-import-export&sm-msg=3' ) ); + die(); + } else { + wp_redirect( admin_url( 'admin.php?page=simplemap-import-export&sm-msg=2' ) ); + die(); + } + } + + } + + } + + // All location data + function get_location_data_types( $init = array() ) { + static $types = null; + + if ( empty( $types ) ) { + $types = array( + 'name' => __( 'Name', 'SimpleMap' ), + 'address' => __( 'Address', 'SimpleMap' ), + 'address2' => __( 'Address 2', 'SimpleMap' ), + 'city' => __( 'City', 'SimpleMap' ), + 'state' => __( 'State', 'SimpleMap' ), + 'zip' => __( 'Zip', 'SimpleMap' ), + 'country' => __( 'Country', 'SimpleMap' ), + 'phone' => __( 'Phone', 'SimpleMap' ), + 'fax' => __( 'Fax', 'SimpleMap' ), + 'email' => __( 'Email', 'SimpleMap' ), + 'url' => __( 'URL', 'SimpleMap' ), + 'description' => __( 'Description', 'SimpleMap' ), + 'special' => __( 'Special', 'SimpleMap' ), + 'lat' => __( 'Lat', 'SimpleMap' ), + 'lng' => __( 'Lng', 'SimpleMap' ), + ); + + $legacy_types = array( + 'category' => __( 'Legacy Taxonomy: Categories', 'SimpleMap' ), + 'tags' => __( 'Legacy Taxonomy: Tags', 'SimpleMap' ), + 'days' => __( 'Legacy Taxonomy: Days', 'SimpleMap' ), + 'times' => __( 'Legacy Taxonomy: Times', 'SimpleMap' ), + ); + + foreach ( get_object_taxonomies( 'sm-location', 'objects' ) as $taxonomy => $tax_info ) { + $types['tax_' . $taxonomy] = __( 'Taxonomy: ' . $tax_info->label, 'SimpleMap' ); + } + + foreach ( $init as $key => $value ) { + if ( substr( $key, 0, 4 ) === 'tax_' ) { + $types[$key] = __( 'Taxonomy: ' . ucwords( substr( $key, strpos( $key, '-' ) + 1 ) ), 'SimpleMap' ); + } elseif ( isset( $legacy_types[$key] ) ) { + $types[$key] = $legacy_types[$key]; + } + } + + $types = apply_filters( 'sm-data-types', $types ); + } + + return $types; + } + + // Imports a CSV file to WordPress + function import_csv() { + global $simple_map, $sm_locations, $wpdb, $current_user, $blog_id; + + // Define Importing Constant + define( 'WP_IMPORTING', true ); + + if ( isset( $_POST['sm-action'] ) && 'import-csv' == $_POST['sm-action'] && isset( $_POST['step'] ) && 2 == $_POST['step'] ) { + ?> +
+ + show_toolbar( $sm_page_title ); + ?> + +
+ +
+ +
+ +
+ +
+ +

+ +
+ + auto( $file_location ); + + if ( isset( $csv->data ) ) { + echo '
    '; + + /* We're going to do some pre-processing to prevent WP's wp_get_unique_slug from pinging the database + * a ridiculous amount of times in the event that this file is importing several thousand locations with + * same name (like a franchise). + */ + $post_names = array(); + + $taxes = $simple_map->get_taxonomy_settings(); + foreach ( $taxes as $taxonomy => $tax_info ) { + $taxes[$taxonomy] = $tax_info['field']; + } + + $types = $this->get_location_data_types( current( $csv->data ) ); + $columns = array(); + foreach ( $types as $key => $value ) { + $taxonomy = null; + + // If custom taxonomies don't exist, register them temporarily in the event that we need to import them. + if ( substr( $key, 0, 7 ) === 'tax_sm-' ) { + $taxonomy = substr( $key, 4 ); + $taxes[$taxonomy] = $key; + } + // Allow legacy taxonomy column names + elseif ( array_search( $key, $taxes ) ) { + $taxonomy = $key; + } + + if ( isset( $taxonomy ) ) { + $sm_locations->register_location_taxonomy( $taxonomy, $simple_map->get_taxonomy_settings( $taxonomy ) ); + } + + $columns[$key] = str_replace( 'col_', '', array_search( $key, $_POST ) ); + } + + $active_taxes = get_object_taxonomies( 'sm-location' ); + $taxes = array_intersect_key( $taxes, array_flip( $active_taxes ) ); + + foreach ( $csv->data as $row => $location ) { + // Give me 20 seconds for each location. That should be more than enough time. + set_time_limit ( 20 ); + + // Convert assoc to int array since I can't trust the headings from the user + $location = array_values( $location ); + + // Use the information the user gave me via select boxes to map columns to correct attributes + foreach ( $columns as $key => $column ) { + if ( isset( $location[$column] ) ) { + $to_insert[$key] = trim( $location[$column] ); + } + else { + $to_insert[$key] = ''; + } + } + + // Combine legacy taxonomy fields into new taxonomy fields. + $legacy_taxes = $simple_map->get_taxonomy_settings(); + foreach ( $legacy_taxes as $taxonomy => $legacy_taxonomy ) { + $old_key = $legacy_taxonomy['field']; + $key = 'tax_' . $taxonomy; + if ( isset( $to_insert[$old_key] ) ) { + $to_insert += array( $key => '' ); + $to_insert[$key] = implode( ',', array_filter( array( $to_insert[$key], $to_insert[$old_key] ) ) ); + unset( $to_insert[$old_key] ); + } + } + + // Prep and insert + if ( isset( $to_insert ) ) { + $options = $simple_map->get_options(); + $geocoded = ''; + + // Maybe geo encode + if ( ( empty( $to_insert['lat'] ) || empty( $to_insert['lng'] ) ) ) { + if ( $geo = $simple_map->geocode_location( $to_insert['address'], $to_insert['city'], $to_insert['state'], $to_insert['zip'], $to_insert['country'], '' ) ) { + $geocoded = __( 'geocoded and ', 'SimpleMap' ); + + if ( isset( $geo['lat'] ) ) { + $to_insert['lat'] = $geo['lat']; + } + + if ( isset( $geo['lng'] ) ) { + $to_insert['lng'] = $geo['lng']; + } + } + } + + // Prevent dup names before getting to wp_unique_slug function + $clean_name = sanitize_title( $to_insert['name'] ); + + // Start by check to see if this post's name has been used before + if ( isset( $post_names[$clean_name] ) ) { + + // Set the int to the value of the post_name key (this is set the first time we import a post with this title). + $post_names_int = $post_names[$clean_name]; + + // Just to be safe, lets make sure the incremented name doesn't exist. Loop till we find one available. + while( isset( $post_names[$clean_name . '-' . $post_names_int] ) ) { + $post_names_int++; + } + + // Set the new unique slug + $unique_title = $clean_name . '-' . $post_names_int; + + // Add the post_name to the post attributes array we're about to insert + $vars['post_name'] = $unique_title; + + // Update the original slug for this title with the new int + $post_names[$clean_name] = $post_names[$unique_title] = $post_names_int; + } else { + // If we made it here, its the first time we're inserting a post with this title (this import anyway). + // Add it to the post attributes array we're about to send to wp_insert_post + $vars['post_name'] = $clean_name; + + // Log this title as used in the post_names array with an int of 1 + $post_names[$clean_name] = 1; + } + + // Prep for WordPress function + wp_get_current_user(); + $vars['post_title'] = $to_insert['name']; + $vars['post_author'] = $current_user->ID; + $vars['post_type'] = 'sm-location'; + $vars['post_status'] = 'publish'; + $vars['post_content'] = $to_insert['description']; + + // Insert into WordPress post table + if ( $id = wp_insert_post( $vars ) ) { + update_post_meta( $id, 'location_address', $to_insert['address'] ); + update_post_meta( $id, 'location_address2', $to_insert['address2'] ); + update_post_meta( $id, 'location_city', $to_insert['city'] ); + update_post_meta( $id, 'location_state', $to_insert['state'] ); + update_post_meta( $id, 'location_zip', $to_insert['zip'] ); + update_post_meta( $id, 'location_country', $to_insert['country'] ); + update_post_meta( $id, 'location_phone', $to_insert['phone'] ); + update_post_meta( $id, 'location_fax', $to_insert['fax'] ); + update_post_meta( $id, 'location_email', $to_insert['email'] ); + update_post_meta( $id, 'location_url', $to_insert['url'] ); + update_post_meta( $id, 'location_special', $to_insert['special'] ); + update_post_meta( $id, 'location_lat', $to_insert['lat'] ); + update_post_meta( $id, 'location_lng', $to_insert['lng'] ); + + foreach ( $taxes as $taxonomy => $tax_field ) { + if ( isset( $to_insert[$tax_field] ) ) { + // Place comma separated values into array + $terms = explode( ',', $to_insert[$tax_field] ); + + // Loop through array. If term does not exist, create it. + // Then associate the term with the location. + foreach ( (array) $terms as $key => $name ) { + $name = trim( $name ); + + // Skip it if we have bad data + if ( empty( $name ) ) { + continue; + } + + // Grab or create and grab the category ID + if ( $term_obj = get_term_by( 'name', $name, $taxonomy ) ) { + $term_id = $term_obj->term_id; + } else { + $term_array = wp_insert_term( $name, $taxonomy ); + if ( is_wp_error( $term_array ) ) { + continue; + } + $term_id = $term_array['term_id']; + } + + // This is just a failsafe. It also gives us access to vars the WP API created rather than from the CSV + if ( ! is_wp_error( $term_id ) && $term = get_term( (int) $term_id, $taxonomy ) ) { + if ( ! is_wp_error( $term ) ) { + // Associate (last var appends term to rather than replaces existing terms) + wp_set_object_terms( $id, $term->name, $taxonomy, true ); + unset( $term ); + } + } + } + } + } + + echo "
  1. " . sprintf( esc_attr( $to_insert['name'] ) . __( ' was successfully %simported', 'SimpleMap' ), $geocoded ) . "
  2. "; + } else { + echo "
  3. " . esc_attr( $to_insert['name'] ) . __( ' failed to import properly', 'SimpleMap' ) . "
  4. "; + } + + unset( $to_insert ); + unset( $geocoded ); + } + } + + echo ""; + echo "

    " . sprintf( __( 'View them here', 'SimpleMap' ), admin_url( 'edit.php?post_type=sm-location' ) ) . "

    "; + } + + // Import is finished, delete csv and redirect to edit locaitons page + if ( file_exists( $file_location ) ) { + unlink( $file_location ); + } + } + ?> +
+
+
+
+
+ get_options(); + + /* + if ( !isset( $options['api_key'] ) ) + $options['api_key'] = ''; + */ + + extract( $options ); + + ?> +
+ + show_toolbar( $sm_page_title ); + ?> + +
+ +
+ +
+ +
+ +
+ +

+ +
+ +

', '' );?>

+ + +
+ + +

|

+ + + get_location_data_types( current($csv->data) ); + foreach( $csv->titles as $col => $title ) { + echo ""; + } + ?> + + + data ); + if ( $row_count < 50 ) { + foreach( $csv->data as $csv_row => $csv_row_data ) { + ?> $tdv ) { + ?>data[$numb] as $td => $tdv ) { + ?> +
" . $this->column_select( $col, $title ) . "
+ writable by WordPress: %s', 'http://codex.wordpress.org/Changing_File_Permissions#Permission_Scheme_for_WordPress', '' . WP_PLUGIN_DIR . '' ), 'SimpleMap' ); + } + ?> + +
+ +
+ +
+ +
+ +
+ +
+ "; + + $select .= ""; + + + foreach( $this->get_location_data_types() as $type => $label ) { + $select .= ""; + } + + $select .= ""; + + return $select; + } + + // Prints the options page + function print_page() { + if ( isset( $_POST['sm-action'] ) && 'import-csv' == $_POST['sm-action'] ) { + $step = isset( $_POST['step'] ) ? absint( $_POST['step'] ) : 1; + + // Check for uploaded file with no errors. + if ( ( 1 == $step && isset( $_FILES['simplemap-csv-upload'] ) && ! $_FILES['simplemap-csv-upload']['error'] > 0 ) || 2 == $step ) { + + switch( $step ) { + case 2: + $this->import_csv(); + break; + case 1: + default : + $this->do_csv_preview(); + } + } + } else { + global $simple_map; + $options = $simple_map->get_options(); + + /* + if ( !isset( $options['api_key'] ) ) + $options['api_key'] = ''; + */ + + extract( $options ); + + + ?> +
+ + show_toolbar( $sm_page_title ); + + // Messages + if ( isset( $_GET['sm-msg'] ) && '2' == $_GET['sm-msg'] ) + echo '

'.__('Legacy SimpleMap settings deleted.', 'SimpleMap').'

'; + + if ( isset( $_GET['sm-msg'] ) && '3' == $_GET['sm-msg'] ) + echo '

'.__('Legacy SimpleMap NOT settings deleted.', 'SimpleMap').'

'; + ?> + +
+ +
+ +
+ +
+ +
+ +

+ +
+ +

+ +

+ +

+ +

+ +

+ +

+ +
    +
  • +
  • +
+ +

', ''); ?>

+ +

+ +
+ + + +

+
+ + " . __( sprintf( 'Please make the following directory writable by WordPress: %s', 'http://codex.wordpress.org/Changing_File_Permissions#Permission_Scheme_for_WordPress', '' . WP_PLUGIN_DIR . '' ), 'SimpleMap' ); + ?> + +

+ + + API key if you need your locaitons geocoded.", 'SimpleMap' ), admin_url( "admin.php?page=simplemap" ) ); ?> + +
+ +

+
+ +
+
+ + + +
+ +

+ +
+ +
+ + + + +
+
+ +
+
+ + + +
+
+ +
+ +
+ + + + + +
+ +

+ +
+ + + +

+

+ +

+

+ +

+ +
    +
  • +
  • +
  • +
  • +
+ +
    +
  • +
  • +
+ + +

%s was purchased on %s by %s (%s). It will remain valid for this URL until %s.", get_ftps_site( $simplemap_ps ), date( "F d, Y", get_ftps_purchase_date( $simplemap_ps ) ), get_ftps_name( $simplemap_ps ), get_ftps_email( $simplemap_ps ), date( "F d, Y", get_ftps_exp_date( $simplemap_ps ) ) ); ?>

+

|

+ + + + + +
+
+ + legacy_tables_exist() ) : ?> + +
+ +

+ +
+

+ +
    +
  • '>
  • + +
  • +
+
+
+ + + + + +
+ +
+ +
+
+
+
+ diff --git a/classes/locations.php b/classes/locations.php new file mode 100644 index 0000000..c41a933 --- /dev/null +++ b/classes/locations.php @@ -0,0 +1,749 @@ +get_options(); + if ( !empty( $options['enable_permalinks'] ) ) { + $args += array( + 'publicly_queryable' => true, + 'exclude_from_search' => false, + 'rewrite' => array( 'slug' => $options['permalink_slug'] ), + ); + } + + $args += array( + 'public' => true, + 'publicly_queryable' => false, + 'exclude_from_search' => true, + 'show_ui' => true, + 'capability_type' => 'post', + 'hierarchical' => false, + 'rewrite' => false, + 'query_var' => 'sm-location', + 'register_meta_box_cb' => array( &$this, 'location_meta_cb' ), + 'supports' => array(), + 'labels' => array( + 'name' => 'Locations', + 'singular_name' => 'Location', + 'add_new_item' => 'Add New Location', + 'edit_item' => 'Edit Location', + 'new_item' => 'New Location', + 'view_item' => 'View Locations', + 'search_items' => 'Search Locations', + 'not_found' => 'No Locations found', + 'not_found_in_trash' => 'No Locations found in trash', + ) + ); + + // Register it + register_post_type( 'sm-location', $args ); + } + + // Register custom taxonomies for locations + function register_location_taxonomies() { + global $simple_map; + $options = $simple_map->get_options(); + + foreach ( $options['taxonomies'] as $taxonomy => $tax_info ) { + $this->register_location_taxonomy( $taxonomy, $tax_info ); + } + } + + // Register custom taxonomy for locations + function register_location_taxonomy( $taxonomy, $tax_info ) { + if ( taxonomy_exists( $taxonomy ) ) { + return; + } + + $tax_info += array( + 'singular' => $taxonomy, + 'plural' => $taxonomy, + 'hierarchical' => false, + ); + + $args = array( + 'labels' => array( + 'name' => 'Location ' . $tax_info['plural'], + 'singular_name' => 'Location ' . $tax_info['singular'], + 'search_items' => 'Search ' . $tax_info['plural'], + 'popular_items' => 'Popular ' . $tax_info['plural'], + 'all_items' => 'All ' . $tax_info['plural'], + 'parent_item' => 'Parent ' . $tax_info['singular'], + 'parent_item_colon' => 'Parent ' . $tax_info['singular'] . ':', + 'edit_item' => 'Edit ' . $tax_info['singular'], + 'update_item' => 'Update ' . $tax_info['singular'], + 'add_new_item' => 'Add New ' . $tax_info['singular'], + 'new_item_name' => 'New ' . $tax_info['singular'] . ' Name', + 'separate_items_with_commas' => 'Separate ' . strtolower( $tax_info['plural'] ) . ' with commas', + 'add_or_remove_items' => 'Add or remove ' . strtolower( $tax_info['plural'] ), + 'choose_from_most_used' => 'Choose from the most used ' . strtolower( $tax_info['plural'] ), + ), + 'hierarchical' => $tax_info['hierarchical'], + 'rewrite' => false, + 'show_tagcloud' => false + ); + + register_taxonomy( $taxonomy, 'sm-location', $args ); + } + + // Add call back for meta box + function location_meta_cb(){ + add_meta_box( 'sm-location-premium-support', __( 'Premium Support', 'SimpleMap' ), array( &$this, 'premium_support' ), 'sm-location', 'side', 'high' ); + add_meta_box( 'sm-geo-location', __( 'Geographic Location', 'SimpleMap' ), array( &$this, 'geo_location' ), 'sm-location', 'normal' ); + add_meta_box( 'sm-additional-information', __( 'Additional Information', 'SimpleMap' ), array( &$this, 'additional_information' ), 'sm-location', 'normal' ); + add_meta_box( 'sm-location-drag-drop', __( 'Drag and Drop Location', 'SimpleMap' ), array( &$this, 'location_drag_drop' ), 'sm-location', 'side' ); + } + + // Add premium support box + function premium_support() { + + global $simplemap_ps, $current_user; + + wp_get_current_user(); + $status_key = md5( 'ft_premium_support_' . $simplemap_ps->product_id . '_' . sanitize_title_with_dashes( $simplemap_ps->site_url ) . '_' . sanitize_title_with_dashes( $simplemap_ps->server_url ) ) ; + $sso_key = md5( 'ft_premium_sso_' . $current_user->ID . '_' . $simplemap_ps->product_id . '_' . sanitize_title_with_dashes( $simplemap_ps->site_url ) . '_' . sanitize_title_with_dashes( $simplemap_ps->server_url ) ); + + // Set status from transient if not set via global + if ( '' == $simplemap_ps->ps_status && '' != get_transient( $status_key ) ) + $simplemap_ps->ps_status = get_transient( $status_key ); + + // Set sso key from transient if not set via global + if ( '' == $simplemap_ps->sso_status && '' != get_transient( $sso_key ) ) + $simplemap_ps->sso_status = get_transient( $sso_key ); + + + //echo "
";print_r( $simplemap_ps );echo "
"; + if ( ! url_has_ftps_for_item( $simplemap_ps ) ) : + + ?> +

+ +

+ +
    +
  • +
  • +
  • +
  • +
+ +
    +
  • +
  • +
+ + +

+
    +
  • +
  • + + + get_options(); + + // Location data + $location_address = get_post_meta( $post->ID, 'location_address', true ) ? get_post_meta( $post->ID, 'location_address', true ) : ''; + $location_address2 = get_post_meta( $post->ID, 'location_address2', true ) ? get_post_meta( $post->ID, 'location_address2', true ) : ''; + $location_city = get_post_meta( $post->ID, 'location_city', true ) ? get_post_meta( $post->ID, 'location_city', true ) : ''; + $location_state = get_post_meta( $post->ID, 'location_state', true ) ? get_post_meta( $post->ID, 'location_state', true ) : $options['default_state']; + $location_zip = get_post_meta( $post->ID, 'location_zip', true ) ? get_post_meta( $post->ID, 'location_zip', true ) : ''; + $location_country = get_post_meta( $post->ID, 'location_country', true ) ? get_post_meta( $post->ID, 'location_country', true ) : $options['default_country']; + $location_lat = get_post_meta( $post->ID, 'location_lat', true ) ? get_post_meta( $post->ID, 'location_lat', true ) : ''; + $location_lng = get_post_meta( $post->ID, 'location_lng', true ) ? get_post_meta( $post->ID, 'location_lng', true ) : ''; + + ?> +

    + + + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +

    +
    + +
    +
    +
    +
    + get_options(); + + $location_phone = get_post_meta( $post->ID, 'location_phone', true ) ? get_post_meta( $post->ID, 'location_phone', true ) : ''; + $location_fax = get_post_meta( $post->ID, 'location_fax', true ) ? get_post_meta( $post->ID, 'location_fax', true ) : ''; + $location_url = get_post_meta( $post->ID, 'location_url', true ) ? get_post_meta( $post->ID, 'location_url', true ) : ''; + $location_email = get_post_meta( $post->ID, 'location_email', true ) ? get_post_meta( $post->ID, 'location_email', true ) : ''; + $location_special = get_post_meta( $post->ID, 'location_special', true ) ? get_post_meta( $post->ID, 'location_special', true ) : ''; + ?> +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    +
    +
    http://', 'SimpleMap'); ?>
    />
    + +
    + +
    + + get_options(); + + // Location data + $location_address = get_post_meta( $post->ID, 'location_address', true ) ? get_post_meta( $post->ID, 'location_address', true ) : ''; + $location_address2 = get_post_meta( $post->ID, 'location_address2', true ) ? get_post_meta( $post->ID, 'location_address2', true ) : ''; + $location_city = get_post_meta( $post->ID, 'location_city', true ) ? get_post_meta( $post->ID, 'location_city', true ) : ''; + $location_state = get_post_meta( $post->ID, 'location_state', true ) ? get_post_meta( $post->ID, 'location_state', true ) : $options['default_state']; + $location_zip = get_post_meta( $post->ID, 'location_zip', true ) ? get_post_meta( $post->ID, 'location_zip', true ) : ''; + $location_country = get_post_meta( $post->ID, 'location_country', true ) ? get_post_meta( $post->ID, 'location_country', true ) : $options['default_country']; + $location_lat = get_post_meta( $post->ID, 'location_lat', true ) ? get_post_meta( $post->ID, 'location_lat', true ) : ''; + $location_lng = get_post_meta( $post->ID, 'location_lng', true ) ? get_post_meta( $post->ID, 'location_lng', true ) : ''; + + ?> +

    Drag the marker to fine tune your location's placement on the map

    +
    + id ) + return; + + wp_enqueue_script( 'sm-drag-drop-location-js', site_url() . '/?sm-drag-drop-location-js=' . $post->ID, array( 'jquery' ) ); + + } + + // Javascript for add / edit location page + function location_add_edit_js() { + global $current_screen, $simple_map; + + $options = $simple_map->get_options(); + + if ( !isset( $_GET['sm-drag-drop-location-js'] ) ) + return; + + $postid = (int) $_GET['sm-drag-drop-location-js']; + + $drag_drop_lat = get_post_meta( $postid, 'location_lat', true ) ? get_post_meta( $postid, 'location_lat', true ) : '40.730885'; + $drag_drop_lng = get_post_meta( $postid, 'location_lng', true ) ? get_post_meta( $postid, 'location_lng', true ) : '-73.997383'; + $drag_drop_zoom = ( $drag_drop_lat == '40.730885' ) ? 2 : 17; + + header( "Content-type: application/x-javascript" ); + + /* + if ( '' == $options['api_key'] ) { + die( "alert( '" . esc_js( __( "You will need to enter your API key in general options before your addresses will be coded properly.", 'SimpleMap' ) ) . "');" ); + } + */ + ?> + var map; + var geocoder; + var address; + var marker; + var place; + + function location_add_edit_js_init() { + var latlng = new google.maps.LatLng( , ); + var myOptions = { + zoom: , + center: latlng, + mapTypeId: google.maps.MapTypeId.ROADMAP + }; + map = new google.maps.Map( document.getElementById( "dragdrop_map_canvas" ), myOptions ); + + marker = new google.maps.Marker({ + position: latlng, + map: map, + draggable: true, + animation: google.maps.Animation.DROP + }); + + google.maps.event.addListener( map, 'click', dragDropGetAddress ); + google.maps.event.addListener( marker, 'dragend', dragDropGetAddressTest ); + + geocoder = new google.maps.Geocoder(); + + + jQuery( '#js-geo-encode-msg' ).removeClass( 'hidden' ); + + // Do geocode + var geo_address = ''; + geocoder.geocode( { 'address': geo_address }, function( results, status ) { + if ( status == google.maps.GeocoderStatus.OK ) { + var latlng = results[0].geometry.location; + jQuery( "#location_lat" ).attr( 'value', latlng.lat() ); + jQuery( "#location_lng" ).attr( 'value', latlng.lng() ); + + var smdata = { + action: 'ajax_save_lat_lng', + sm_id: , + sm_lat: latlng.lat(), + sm_lng: latlng.lng() + }; + + jQuery.post( ajaxurl, smdata, function( response ) { + jQuery( '#sm_js_update_lat_lng_result' ).html( response ); + }); + + // Set drag/drop map to new location + map.setCenter( latlng ); + map.setZoom( ); + marker = new google.maps.Marker({ + map: map, + position: latlng, + draggable: true, + animation: google.maps.Animation.DROP + }); + + jQuery( '#js-geo-encode-msg' ).removeClass( 'hidden' ); + } + else { + alert("Geocode was not successful for the following reason: " + status); + } + }); + + + } + + function dragDropGetAddressTest() { + var latlng = marker.getPosition(); + geocoder.geocode( { 'latLng': latlng }, dragDropShowAddress ); + } + + function dragDropGetAddress( event ) { + if ( event.latlng != null ) { + geocoder.geocode( { 'latLng': event.latlng }, dragDropShowAddress ); + } + } + + function dragDropShowAddress( results, status ) { + marker.setMap(null); + if ( status != google.maps.GeocoderStatus.OK ) { + alert("Geocoder failed due to: " + status); + map.addOverlay(marker); + } else { + var latlng = results[0].geometry.location; + marker = new google.maps.Marker({ + map: map, + position: latlng, + draggable: true, + animation: google.maps.Animation.DROP + }); + + dragDropUpdateFormFields( latlng ); + place = results[0]; + + google.maps.event.addListener( marker, 'dragend', dragDropGetAddressTest ); + } + } + + jQuery(document).ready(function(){ + location_add_edit_js_init(); + }); + + function dragDropUpdateFormFields( latlng ) { + jQuery( "#location_lat" ).attr( 'value', latlng.lat() ); + jQuery( "#location_lng" ).attr( 'value', latlng.lng() ); + jQuery( "#latlng_dontforget" ).hide(); + jQuery( "#latlng_updated" ).fadeIn(); + } + + function dragDropUpdateAddress() { + var newAddress = {}; + for ( var i = 0; i < place.address_components.length; i++ ) { + var component = place.address_components[i]; + newAddress[component.types[0]] = component.short_name; + } + + var newStreet = ''; + var newCity = ''; + var newState = ''; + var newZip = ''; + var newCountry = ''; + + if ( newAddress.street_number ) { + newStreet += newAddress.street_number; + } + if ( newAddress.route ) { + if ( newStreet != '' ) { + newStreet += ' '; + } + newStreet += newAddress.route; + } + + if ( newAddress.locality ) { + newCity += newAddress.locality; + } + + if ( newAddress.administrative_area_level_1 ) { + newState += newAddress.administrative_area_level_1; + } + + if ( newAddress.postal_code ) { + newZip += newAddress.postal_code; + } + + if ( newAddress.country ) { + newCountry += newAddress.country; + } + + /* + if ( place.AddressDetails.Country.AdministrativeArea != null && place.AddressDetails.Country.AdministrativeArea.SubAdministrativeArea != null && place.AddressDetails.Country.AdministrativeArea.SubAdministrativeArea.Locality != null && place.AddressDetails.Country.AdministrativeArea.SubAdministrativeArea.Locality.Thoroughfare != null ) + newStreet = place.AddressDetails.Country.AdministrativeArea.SubAdministrativeArea.Locality.Thoroughfare.ThoroughfareName; + else if ( place.AddressDetails.Country.AdministrativeArea != null && place.AddressDetails.Country.AdministrativeArea.Locality != null && place.AddressDetails.Country.AdministrativeArea.Locality.Thoroughfare != null ) + newStreet = place.AddressDetails.Country.AdministrativeArea.Locality.Thoroughfare.ThoroughfareName; + + if ( place.AddressDetails.Country.AdministrativeArea != null && place.AddressDetails.Country.AdministrativeArea.SubAdministrativeArea != null && place.AddressDetails.Country.AdministrativeArea.SubAdministrativeArea.Locality != null && place.AddressDetails.Country.AdministrativeArea.SubAdministrativeArea.Locality.LocalityName != null ) + newCity = place.AddressDetails.Country.AdministrativeArea.SubAdministrativeArea.Locality.LocalityName; + else if ( place.AddressDetails.Country.AdministrativeArea != null && place.AddressDetails.Country.AdministrativeArea.Locality != null && place.AddressDetails.Country.AdministrativeArea.Locality.LocalityName != null ) + newCity = place.AddressDetails.Country.AdministrativeArea.Locality.LocalityName; + + if ( place.AddressDetails.Country.AdministrativeArea != null && place.AddressDetails.Country.AdministrativeArea.AdministrativeAreaName != null ) + newState = place.AddressDetails.Country.AdministrativeArea.AdministrativeAreaName; + + if ( place.AddressDetails.Country.AdministrativeArea != null && place.AddressDetails.Country.AdministrativeArea.SubAdministrativeArea != null && place.AddressDetails.Country.AdministrativeArea.SubAdministrativeArea.Locality != null && place.AddressDetails.Country.AdministrativeArea.SubAdministrativeArea.Locality.PostalCode != null && place.AddressDetails.Country.AdministrativeArea.SubAdministrativeArea.Locality.PostalCode.PostalCodeNumber != null ) + newZip = place.AddressDetails.Country.AdministrativeArea.SubAdministrativeArea.Locality.PostalCode.PostalCodeNumber; + if ( place.AddressDetails.Country.AdministrativeArea != null && place.AddressDetails.Country.AdministrativeArea.Locality != null && place.AddressDetails.Country.AdministrativeArea.Locality.PostalCode != null && place.AddressDetails.Country.AdministrativeArea.Locality.PostalCode.PostalCodeNumber != null ) + newZip = place.AddressDetails.Country.AdministrativeArea.Locality.PostalCode.PostalCodeNumber; + + if ( place.AddressDetails.Country != null && place.AddressDetails.Country.CountryNameCode != null ) + newCountry = place.AddressDetails.Country.CountryNameCode; + + oldStreet = jQuery("#location_address").attr( 'value' ); + oldCity = jQuery("#location_address").attr( 'value' ); + oldState = jQuery("#location_address").attr( 'value' ); + oldZip = jQuery("#location_address").attr( 'value' ); + oldCountry = jQuery("#location_address").attr( 'value' ); + */ + + jQuery("#location_address").attr( 'value', newStreet ); + jQuery("#location_city").attr( 'value', newCity ); + jQuery("#location_state").attr( 'value', newState ); + jQuery("#location_zip").attr( 'value', newZip ); + jQuery("#location_country").val( newCountry ); + } + id || 'sm-location' != $current_screen->post_type ) + return; + + $options = $simple_map->get_options(); + $post_object = get_post( $post ); + + //$api_key = ( isset( $options['api_key'] ) && !empty( $options['api_key'] ) ) ? $options['api_key'] : ''; + + // Grab old data + $location_address = get_post_meta( $post, 'location_address', true ) ? get_post_meta( $post, 'location_address', true ) : ' '; + $location_address2 = get_post_meta( $post, 'location_address2', true ) ? get_post_meta( $post, 'location_address2', true ) : ' '; + $location_city = get_post_meta( $post, 'location_city', true ) ? get_post_meta( $post, 'location_city', true ) : ' '; + $location_state = get_post_meta( $post, 'location_state', true ) ? get_post_meta( $post, 'location_state', true ) : $options['default_state']; + $location_zip = get_post_meta( $post, 'location_zip', true ) ? get_post_meta( $post, 'location_zip', true ) : ' '; + $location_country = get_post_meta( $post, 'location_country', true ) ? get_post_meta( $post, 'location_country', true ) : $options['default_country']; + $location_lat = get_post_meta( $post, 'location_lat', true ) ? get_post_meta( $post, 'location_lat', true ) : ' '; + $location_lng = get_post_meta( $post, 'location_lng', true ) ? get_post_meta( $post, 'location_lng', true ) : ' '; + $location_phone = get_post_meta( $post, 'location_phone', true ) ? get_post_meta( $post, 'location_phone', true ) : ' '; + $location_fax = get_post_meta( $post, 'location_fax', true ) ? get_post_meta( $post, 'location_fax', true ) : ' '; + $location_url = get_post_meta( $post, 'location_url', true ) ? get_post_meta( $post, 'location_url', true ) : ' '; + $location_email = get_post_meta( $post, 'location_email', true ) ? get_post_meta( $post, 'location_email', true ) : ' '; + $location_special = get_post_meta( $post, 'location_special', true ) ? get_post_meta( $post, 'location_special', true ) : ' '; + // If adding new field that has a default (like state and country above), you must modify the update section below accordingly! + + // Grab new data + $new_address = isset( $_POST['location_address'] ) ? $_POST['location_address'] : ''; + $new_address2 = isset( $_POST['location_address2'] ) ? $_POST['location_address2'] : ''; + $new_city = isset( $_POST['location_city'] ) ? $_POST['location_city'] : ''; + $new_state = isset( $_POST['location_state'] ) ? $_POST['location_state'] : ''; + $new_zip = isset( $_POST['location_zip'] ) ? $_POST['location_zip'] : ''; + $new_country = isset( $_POST['location_country'] ) ? $_POST['location_country'] : ''; + $new_lat = isset( $_POST['location_lat'] ) ? $_POST['location_lat'] : ''; + $new_lng = isset( $_POST['location_lng'] ) ? $_POST['location_lng'] : ''; + $new_phone = isset( $_POST['location_phone'] ) ? $_POST['location_phone'] : ''; + $new_fax = isset( $_POST['location_fax'] ) ? $_POST['location_fax'] : ''; + $new_url = isset( $_POST['location_url'] ) ? $_POST['location_url'] : ''; + $new_email = isset( $_POST['location_email'] ) ? $_POST['location_email'] : ''; + $new_special = isset( $_POST['location_special'] ) ? $_POST['location_special'] : ''; + + // Update + if ( $location_address != $new_address ) update_post_meta( $post, 'location_address', $new_address ); + if ( $location_address2 != $new_address2 ) update_post_meta( $post, 'location_address2', $new_address2 ); + if ( $location_city != $new_city ) update_post_meta( $post, 'location_city', $new_city ); + if ( $location_state != $new_state || ( $new_state == $options['default_state'] && ! get_post_meta( $post, 'location_state', true ) ) ) update_post_meta( $post, 'location_state', $new_state ); + if ( $location_zip != $new_zip ) update_post_meta( $post, 'location_zip', $new_zip ); + if ( $location_country != $new_country || ( $new_country == $options['default_country'] && ! get_post_meta( $post, 'location_country', true ) ) ) update_post_meta( $post, 'location_country', $new_country ); + if ( $location_lat != $new_lat ) update_post_meta( $post, 'location_lat', $new_lat ); + if ( $location_lng != $new_lng ) update_post_meta( $post, 'location_lng', $new_lng ); + if ( $location_phone != $new_phone ) update_post_meta( $post, 'location_phone', $new_phone ); + if ( $location_fax != $new_fax ) update_post_meta( $post, 'location_fax', $new_fax ); + if ( $location_url != $new_url ) update_post_meta( $post, 'location_url', $new_url ); + if ( $location_email != $new_email ) update_post_meta( $post, 'location_email', $new_email ); + if ( $location_special != $new_special ) update_post_meta( $post, 'location_special', $new_special ); + + + // Lets not geocode on auto-draft + if ( 'auto-draft' == $post_object->post_status ) + return; + + /* + * Geocode here under the following conditions + * If address, city, state, or zip have changed + * If lat or lng is empty + */ + $updated_address = get_post_meta( $post, 'location_address', true ); + $updated_city = get_post_meta( $post, 'location_city', true ); + $updated_state = get_post_meta( $post, 'location_state', true ); + $updated_zip = get_post_meta( $post, 'location_zip', true ); + $updated_country = get_post_meta( $post, 'location_country', true ); + $updated_lat = get_post_meta( $post, 'location_lat', true ); + $updated_lng = get_post_meta( $post, 'location_lng', true ); + + if ( $location_address != $updated_address || $location_city != $updated_city || $location_state != $updated_state || $location_zip != $updated_zip || $location_country != $updated_country || '' == $updated_lat || '' == $updated_lng ) { + $geocode_result = $simple_map->geocode_location( $updated_address, $updated_city, $updated_state, $updated_zip, $updated_country, '' ); + + if ( $geocode_result && isset( $geocode_result['status'] ) && $geocode_result['status'] == 'OK' ) { + if ( isset( $geocode_result['lat'] ) && isset( $geocode_result['lng'] ) ) { + update_post_meta( $post, 'location_lat', $geocode_result['lat'] ); + update_post_meta( $post, 'location_lng', $geocode_result['lng'] ); + } + } else if ( $geocode_result && isset( $geocode_result['status'] ) ) { + // Parse response + switch( $geocode_result['status'] ) { + case 620 : + case 'OVER_QUERY_LIMIT' : + update_post_meta( $post, 'sm-needs-js-geocode', 'true' ); + } + } + } + } + + // Filter the main query run at top of edit.php + function limit_edit_query( $query ) { + global $current_screen, $wpdb; + + if ( is_object( $current_screen ) && 'edit-sm-location' == $current_screen->id ) { + + $sql = 'SELECT ID FROM `' . $wpdb->posts . '` WHERE post_type = "sm-location" AND post_status = "publish" LIMIT 10000'; + if ( 10000 == count( $wpdb->get_results( $sql ) ) ) { + $query->query_vars['posts_per_page'] = $query->query_vars['posts_per_archive_page'] = 1000; + add_action( 'in_admin_footer', array( &$this, 'print_excessive_locations_message' ) ); + } + + } + + return $query; + } + + // Prints the excessive locations message + function print_excessive_locations_message() { + ?> +

    Warning: You have more than 10,000 locations in your database. We have limited the list here to 1,000. You may use the search field to access locations beyond the first 1,000.', 'SimpleMap' ); ?>

    + id ) + $args['include'] = 'This always returns an empty record set.'; + + return $args; + } + + // Related to limit_wp_dropdown_pages. Now fill in what I erased above with fake data + function modify_empty_wp_dropdown_pages( $output ) { + global $current_screen; + + if ( is_object( $current_screen ) && 'edit-sm-location' == $current_screen->id ) + $output = ""; + + return $output; + } + + // Flushes location cached data + function flush_cache_data( $id=0 ) { + + if ( 'sm-location' == get_post_type( $id ) || 'force' == $id ) + delete_transient( 'simplemap-queries-cache' ); + + + } + + } +} +?> diff --git a/classes/maps.php b/classes/maps.php new file mode 100644 index 0000000..20c937c --- /dev/null +++ b/classes/maps.php @@ -0,0 +1,279 @@ +set_map_atts(); + + // Prints the iframe + if ( isset( $_GET['sm_map_iframe'] ) ) { + add_action( 'template_redirect', array( &$this, 'add_iframe_locations' ), 2 ); + add_action( 'template_redirect', array( &$this, 'generate_iframe' ) ); + } + } + + /** + * This loads all the attributes for the map itself + * + * 'map_width' + * 'map_height' + * 'default_lat' + * 'default_lng' + * 'zoom_level' + * 'default_radius' + * 'map_type' + * 'special_text' + * 'default_state' + * 'default_country' + * 'default_language' + * 'default_domain' + * 'map_stylesheet' + * 'units' + * 'autoload' + * 'lock_default_location' + * 'results_limit' + * 'address_format' + * 'powered_by' + * 'enable_permalinks' + * 'permalink_slug' + * 'display_search' + * 'map_pages' + * 'adsense_for_maps' + * 'adsense_pub_id' + * 'adsense_channel_id' + * 'adsense_max_ads' + * + * @since 2.4 + */ + function set_map_atts( $atts=array() ) { + + global $simple_map; + $locations = ! empty ( $_GET['location_ids'] ) ? explode( ',', $_GET['location_ids'] ) : array(); + + // Do atts for iframes + if ( isset( $_GET['sm_map_iframe'] ) ) { + // Set atts from GET vars + if ( ! empty( $_GET['map_width'] ) ) + $atts['map_width'] = $_GET['map_width']; + if ( ! empty( $_GET['map_height'] ) ) + $atts['map_height'] = $_GET['map_height']; + if ( ! empty( $_GET['pan_control'] ) ) + $atts['panControl'] = $_GET['pan_control']; + if ( ! empty( $_GET['zoom_control'] ) ) + $atts['zoomControl'] = $_GET['zoom_control']; + if ( ! empty( $_GET['scale_control'] ) ) + $atts['scaleControl'] = $_GET['scale_control']; + if ( ! empty( $_GET['street_view_control'] ) ) + $atts['streetViewControl'] = $_GET['street_view_control']; + if ( ! empty( $_GET['map_type_control'] ) ) + $atts['mapTypeControl'] = $_GET['map_type_control']; + if ( ! empty( $_GET['map_type'] ) ) + $atts['mapType'] = $_GET['map_type']; + if ( empty( $_GET['default_lat'] ) ) + $atts['default_lat'] = get_post_meta( $locations[0], 'location_lat', true ); + if ( empty( $_GET['default_lng'] ) ) + $atts['default_lng'] = get_post_meta( $locations[0], 'location_lng', true ); + if ( empty( $_GET['zoom_level'] ) ) + $atts['zoom_level'] = 15; + } + + // Default Options + $defaults = $simple_map->get_options(); + + // Overwrite defaults with any vars passed in + $merged_atts = wp_parse_args( $atts, $defaults ); + + // Kick back to property + $this->map_atts = $merged_atts; + + } + + /** + * Adds a location to the map + * + * @since 2.4 + */ + function add_location( $location ) { + + // $location can be a post object or a post ID. If its an object, grab the id + if ( is_object( $location ) ) + $location = $location->ID; + + // Build array of important post data + if ( $location_data = get_metadata( 'post', $location ) ) { + $location_array = array( + 'id' => $location, + 'lat' => ! empty( $location_data['location_lat'][0] ) ? $location_data['location_lat'][0] : false, + 'lng' => ! empty( $location_data['location_lng'][0] ) ? $location_data['location_lng'][0] : false + ); + + if ( $location_array['lat'] && $location_array['lng'] ) + $this->locations[$location] = $location_array; + } + + } + + /** + * A wrapper for add_location for use when loading an iframe + * + * @since 2.4 + */ + function add_iframe_locations() { + + // Add locations from GET string in iframe embed + $locations = ! empty ( $_GET['location_ids'] ) ? explode( ',', $_GET['location_ids'] ) : array(); + foreach( $locations as $location ) { + $this->add_location( $location ); + } + + } + + /** + * Returns the map code + * + * @since 2.4 + */ + function get_map() { + + } + + /** + * Returns the link for the iframe embed + * + * @since 2.4 + */ + function get_iframe_embed() { + + $atts = $this->map_atts; + $locations = array_keys( $this->locations ); + + $iframe = ''; + + return $iframe; + + } + + /** + * Generates the actual iframe + * + * @since 1.0 + */ + function generate_iframe() { + + if ( ! empty( $_GET['sm_map_iframe'] ) ) { + global $simple_map; + $this->set_map_atts(); + $atts = $this->map_atts; + + wp_enqueue_script('jquery'); + ?> + + + + + + + + + + +
    + + + + 'sm-location', 'posts_per_page' => 200 ) ) ) { + // Delete posts (and therby postmeta as well). Second arg bypasses trash + foreach ( $locations as $key => $location ) { + set_time_limit( 20 ); + wp_delete_post( $location->ID, true ); + } + } + + $options = $simple_map->get_options(); + $taxonomies = $options['taxonomies']; + + $original_taxonomies = array_keys( $simple_map->get_taxonomy_settings() ); + + if ( is_array( $original_taxonomies ) ) { + foreach ( $original_taxonomies as $taxonomy ) { + $taxonomies[$taxonomy] = true; + if ( ! taxonomy_exists( $taxonomy ) ) { + $sm_locations->register_location_taxonomy( $taxonomy, array() ); + } + } + } + + // Delete taxonomy terms + $args = array( 'hide_empty' => 0 ); + if ( $terms = get_terms( array_keys( $taxonomies ), $args ) ) { + foreach ( $terms as $key => $term ) { + wp_delete_term( $term->term_id, $term->taxonomy ); + } + } + + // Delete Options + if ( get_option( 'SimpleMap_options' ) && empty( $_GET['locations-only'] ) ) { + delete_option( 'SimpleMap_options' ); + } + + do_action( 'sm-delete-all-data' ); + + wp_safe_redirect( admin_url( 'admin.php?page=simplemap' ) ); + } + } + + $options = $simple_map->get_options(); + + // Update Options if form was submitted or if WordPress options doesn't exist yet. + if ( isset( $_POST['sm_general_options_submitted'] ) ) { + check_admin_referer( 'sm-general-options' ); + + $new_options = $options; + + // Validate POST Options + //$new_options['api_key'] = ( ! empty( $_POST['api_key'] ) ) ? $_POST['api_key'] : ''; + $new_options['map_width'] = ( ! empty( $_POST['map_width'] ) ) ? $_POST['map_width'] : $options['map_width']; + $new_options['map_height'] = ( ! empty( $_POST['map_height'] ) ) ? $_POST['map_height'] : $options['map_height']; + $new_options['default_lat'] = ( ! empty( $_POST['default_lat'] ) ) ? $_POST['default_lat'] : $options['default_lat'] ; + $new_options['default_lng'] = ( ! empty( $_POST['default_lng'] ) ) ? $_POST['default_lng'] : $options['default_lng'] ; + $new_options['zoom_level'] = ( isset( $_POST['zoom_level'] ) ) ? absint( $_POST['zoom_level'] ) : $options['zoom_level'] ; + $new_options['default_radius'] = ( ! empty( $_POST['default_radius'] ) ) ? absint( $_POST['default_radius'] ) : $options['default_radius'] ; + $new_options['map_type'] = ( ! empty( $_POST['map_type'] ) ) ? $_POST['map_type'] : $options['map_type']; + $new_options['special_text'] = ( isset( $_POST['special_text'] ) ) ? $_POST['special_text'] : $options['special_text']; + $new_options['default_state'] = ( ! empty( $_POST['default_state'] ) ) ? $_POST['default_state'] : $options['default_state']; + $new_options['default_country'] = ( ! empty( $_POST['default_country'] ) ) ? esc_attr( $_POST['default_country'] ) : $options['default_country']; + $new_options['default_language'] = ( ! empty( $_POST['default_language'] ) ) ? esc_attr( $_POST['default_language'] ) : $options['default_language']; + $new_options['default_domain'] = ( ! empty( $_POST['default_domain'] ) ) ? $_POST['default_domain'] : $options['default_domain']; + $new_options['address_format'] = ( ! empty( $_POST['address_format'] ) ) ? $_POST['address_format'] : $options['address_format']; + $new_options['map_stylesheet'] = ( ! empty( $_POST['map_stylesheet'] ) ) ? $_POST['map_stylesheet'] : $options['map_stylesheet']; + $new_options['units'] = ( ! empty( $_POST['units'] ) ) ? $_POST['units'] : $options['units']; + $new_options['results_limit'] = ( isset( $_POST['results_limit'] ) ) ? absint( $_POST['results_limit'] ) : $options['results_limit']; + $new_options['autoload'] = ( ! empty( $_POST['autoload'] ) ) ? $_POST['autoload'] : $options['autoload']; + $new_options['map_pages'] = ( isset( $_POST['map_pages'] ) ) ? $_POST['map_pages'] : $options['map_pages']; + $new_options['lock_default_location'] = ( ! empty( $_POST['lock_default_location'] ) ) ? true : $options['lock_default_location']; + $new_options['powered_by'] = ( isset( $_POST['powered_by'] ) && 'on' == $_POST['powered_by'] ) ? 1 : 0; + $new_options['enable_permalinks'] = ( isset( $_POST['enable_permalinks'] ) && 'on' == $_POST['enable_permalinks'] ) ? 1 : 0; + $new_options['permalink_slug'] = ( ! empty( $_POST['permalink_slug'] ) ) ? $_POST['permalink_slug'] : $options['permalink_slug']; + $new_options['adsense_for_maps'] = ( isset( $_POST['adsense_for_maps'] ) && 'on' == $_POST['adsense_for_maps'] ) ? 1 : 0; + $new_options['adsense_pub_id'] = ( isset( $_POST['adsense_pub_id'] ) ) ? $_POST['adsense_pub_id'] : $options['adsense_pub_id']; + $new_options['adsense_channel_id'] = ( isset( $_POST['adsense_channel_id'] ) ) ? $_POST['adsense_channel_id'] : $options['adsense_channel_id']; + $new_options['adsense_max_ads'] = ( isset( $_POST['adsense_max_ads'] ) ) ? absint( $_POST['adsense_max_ads'] ) : $options['adsense_max_ads']; + $new_options['display_search'] = ( ! empty( $_POST['display_search'] ) ) ? $_POST['display_search'] : $options['display_search']; + $new_options['auto_locate'] = ( isset( $_POST['auto_locate'] ) ) ? $_POST['auto_locate'] : $options['auto_locate']; + + foreach ( $new_options['taxonomies'] as $taxonomy => $tax_info ) { + if ( isset( $_POST['taxonomies'][$taxonomy]['active'] ) ) { + $new_tax_options = $_POST['taxonomies'][$taxonomy]; + unset($new_tax_options['active']); + //echo 'UPDATE(' . $taxonomy . ' - ' . json_encode( array_diff_assoc( array_filter( $new_tax_options ), $tax_info ) ) . ')' . PHP_EOL; + $new_options['taxonomies'][$taxonomy] = array_filter( $new_tax_options ) + $tax_info; + unset($_POST['taxonomies'][$taxonomy]); + } + else { + //echo 'DISABLE(' . $taxonomy . ')' . PHP_EOL; + unset($new_options['taxonomies'][$taxonomy]); + } + } + + if ( isset( $_POST['taxonomies'] ) ) { + foreach ( $_POST['taxonomies'] as $taxonomy => $tax_info ) { + if ( isset( $tax_info['active'] ) ) { + //echo 'ENABLE(' . $taxonomy . ')' . PHP_EOL; + $new_options['taxonomies'][$taxonomy] = $simple_map->get_taxonomy_settings( $taxonomy ); + } + } + } + + $new_options = apply_filters( 'sm-new-general-options', $new_options, $options ); + + if ( $new_options !== $options && update_option( 'SimpleMap_options', $new_options ) ) { + if ( $new_options['enable_permalinks'] !== $options['enable_permalinks'] || $new_options['permalink_slug'] !== $options['permalink_slug'] ) { + update_option( 'sm-rewrite-rules', true ); + } + + do_action( 'sm-general-options-updated' ); + wp_redirect( admin_url( 'admin.php?page=simplemap&sm-msg=1' ) ); + die(); + } + } + + } + + // Prints the options page + function print_page(){ + global $simple_map, $wpdb; + $options = $simple_map->get_options(); + + extract( $options ); + + // Set Autoload Vars + $count = $wpdb->get_col( "SELECT COUNT(ID) FROM `" . $wpdb->posts . "` WHERE post_type = 'sm-location' AND post_status = 'publish'" ); + + if ( $count >= 250 ) { + $disabled_autoload = false; // let it happen. we're limiting to 500 in the query + $disabledmsg = sprintf( __( 'You have to many locations to auto-load them all. Only the closest %d will be displayed if auto-load all is selected.', 'SimpleMap' ), '250' ); + } else { + $disabled_autoload = false; + $disabledmsg = ''; + } + + // Extract styles + $themes1 = $themes2 = array(); + + if ( file_exists( SIMPLEMAP_PATH . '/inc/styles' ) ) + $themes1 = $this->read_styles( SIMPLEMAP_PATH . '/inc/styles' ); + + if ( file_exists( WP_PLUGIN_DIR . '/simplemap-styles' ) ) + $themes2 = $this->read_styles( WP_PLUGIN_DIR . '/simplemap-styles' ); + + $themes1 = apply_filters( 'sm-general-options-themes1', $themes1 ); + $themes2 = apply_filters( 'sm-general-options-themes1', $themes2 ); + ?> +
    + + show_toolbar( $sm_page_title ); + + // Messages + if ( isset( $_GET['sm-msg'] ) && '1' == $_GET['sm-msg'] ) + echo '

    '.__('SimpleMap settings saved.', 'SimpleMap').'

    '; + + ?> + +
    + +
    + + + + + + +
    + + + +
    + +
    + + + +
    + +

    + +
    +

    + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    + +
    + +
    + +
    + + + + + + + + +
    + +
    + +

    +

    +

    +
    + +
    +
    + + + +
    + +

    + +
    +

    ', ' ' ); ?>

    + +
    + + + + + + */ ?> + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    +
    + get_api_link() . '">', ''); ?> +
    + +
    + + + +

    + type="text" name="default_address" id="default_address" size="30" value="" />  onclick="codeAddress();return false;" href="#"> +
    +

    +
    + +
    + +
    +
    + +
    + +
    + ', '', '
    ', '', '', '
    ', '', '' ) ); ?>
    + ' . $disabledmsg . ''; } ?> + + +
    +
    + +
    + +
    +
    + +
    + +
    + +

    +

    +

    +
    + +
    +
    + + +
    + +

    + +
    +

    ', ' ' ); ?>

    + +
    + + + + + + + + + + + + + + + + + + + + + + +
    + +
    +
    + get_taxonomy_settings(); + $taxonomies += $standard_taxonomies; + foreach ( $taxonomies as $taxonomy => $tax_info ) { + $safe = str_replace( '-', '_', $taxonomy ); + $label = isset( $tax_info['description'] ) ? $tax_info['description'] : str_replace( 'sm-', '', $taxonomy ); + $active = !empty( $options['taxonomies'][$taxonomy] ); + echo ''; + echo '
    '; + if ( $active && !isset( $standard_taxonomies[$taxonomy] ) ) { + echo '
    '; + echo ''; + echo '
    '; + echo ''; + echo '
    '; + echo '
    '; + } + } + ?> +
    + +
    +
    +
    +
    +
    + +
    + +
    + +

    +

    +

    + +
    + +
    +
    + + + + +
    +
    + +
    + +
    + + + + + + +
    + +

    + +
    + + + +

    +

    + +

    +

    + +

    + +
      +
    • +
    • +
    • +
    • +
    + +
      +
    • +
    • +
    + + +

    %s was purchased on %s by %s (%s). It will remain valid for this URL until %s.", get_ftps_site( $simplemap_ps ), date( "F d, Y", get_ftps_purchase_date( $simplemap_ps ) ), get_ftps_name( $simplemap_ps ), get_ftps_email( $simplemap_ps ), date( "F d, Y", get_ftps_exp_date( $simplemap_ps ) ) ); ?>

    +

    |

    + + + + + +
    +
    + + + + +
    + +

    + +
    +

    [simplemap]' ); ?>

    + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    + +
    + +
    + 100%', '500px' ); ?> +
    +
    + +
    + +
    + +
    + +
    + +
    + +
    + +
    +
    +
    + ', '' ); ?>
    +
    + /*
    Theme Name: THEME_NAME_HERE
    */
    +
    + +
    + + +    +
    +
    + + + +
    +
    + +

    +    +

    +
    + +
    +
    + +
    + +

    + +
    +

    +

    +

    +
    +
    + + + +
    +
    + + + +
    +
    + +

    Donate via PayPal

    + +
    +
    +
    +
    + diff --git a/classes/parsecsv.lib.php b/classes/parsecsv.lib.php new file mode 100644 index 0000000..dc74e4d --- /dev/null +++ b/classes/parsecsv.lib.php @@ -0,0 +1,695 @@ +data); + ---------------- + # tab delimited, and encoding conversion + $csv = new parseCSV(); + $csv->encoding('UTF-16', 'UTF-8'); + $csv->delimiter = "\t"; + $csv->parse('data.tsv'); + print_r($csv->data); + ---------------- + # auto-detect delimiter character + $csv = new parseCSV(); + $csv->auto('data.csv'); + print_r($csv->data); + ---------------- + # modify data in a csv file + $csv = new parseCSV(); + $csv->sort_by = 'id'; + $csv->parse('data.csv'); + # "4" is the value of the "id" column of the CSV row + $csv->data[4] = array('firstname' => 'John', 'lastname' => 'Doe', 'email' => 'john@doe.com'); + $csv->save(); + ---------------- + # add row/entry to end of CSV file + # - only recommended when you know the extact sctructure of the file + $csv = new parseCSV(); + $csv->save('data.csv', array('1986', 'Home', 'Nowhere', ''), true); + ---------------- + # convert 2D array to csv data and send headers + # to browser to treat output as a file and download it + $csv = new parseCSV(); + $csv->output (true, 'movies.csv', $array); + ---------------- + + +*/ + + + /** + * Configuration + * - set these options with $object->var_name = 'value'; + */ + + # use first line/entry as field names + var $heading = true; + + # override field names + var $fields = array(); + + # sort entries by this field + var $sort_by = null; + var $sort_reverse = false; + + # delimiter (comma) and enclosure (double quote) + var $delimiter = ','; + var $enclosure = '"'; + + # basic SQL-like conditions for row matching + var $conditions = null; + + # number of rows to ignore from beginning of data + var $offset = null; + + # limits the number of returned rows to specified amount + var $limit = null; + + # number of rows to analyze when attempting to auto-detect delimiter + var $auto_depth = 15; + + # characters to ignore when attempting to auto-detect delimiter + var $auto_non_chars = "a-zA-Z0-9\n\r"; + + # preferred delimiter characters, only used when all filtering method + # returns multiple possible delimiters (happens very rarely) + var $auto_preferred = ",;\t.:|"; + + # character encoding options + var $convert_encoding = false; + var $input_encoding = 'ISO-8859-1'; + var $output_encoding = 'ISO-8859-1'; + + # used by unparse(), save(), and output() functions + var $linefeed = "\r\n"; + + # only used by output() function + var $output_delimiter = ','; + var $output_filename = 'data.csv'; + + + /** + * Internal variables + */ + + # current file + var $file; + + # loaded file contents + var $file_data; + + # array of field values in data parsed + var $titles = array(); + + # two dimentional array of CSV data + var $data = array(); + + + /** + * Constructor + * @param input CSV file or string + * @return nothing + */ + function smParseCSV ($input = null, $offset = null, $limit = null, $conditions = null) { + if ( $offset !== null ) $this->offset = $offset; + if ( $limit !== null ) $this->limit = $limit; + if ( count($conditions) > 0 ) $this->conditions = $conditions; + if ( !empty($input) ) $this->parse($input); + } + + + // ============================================== + // ----- [ Main Functions ] --------------------- + // ============================================== + + /** + * Parse CSV file or string + * @param input CSV file or string + * @return nothing + */ + function parse ($input = null, $offset = null, $limit = null, $conditions = null) { + if ( !empty($input) ) { + if ( $offset !== null ) $this->offset = $offset; + if ( $limit !== null ) $this->limit = $limit; + if ( count($conditions) > 0 ) $this->conditions = $conditions; + if ( is_readable($input) ) { + $this->data = $this->parse_file($input); + } else { + $this->file_data = &$input; + $this->data = $this->parse_string(); + } + if ( $this->data === false ) return false; + } + return true; + } + + /** + * Save changes, or new file and/or data + * @param file file to save to + * @param data 2D array with data + * @param append append current data to end of target CSV if exists + * @param fields field names + * @return true or false + */ + function save ($file = null, $data = array(), $append = false, $fields = array()) { + if ( empty($file) ) $file = &$this->file; + $mode = ( $append ) ? 'at' : 'wt' ; + $is_php = ( preg_match('/\.php$/i', $file) ) ? true : false ; + return $this->_wfile($file, $this->unparse($data, $fields, $append, $is_php), $mode); + } + + /** + * Generate CSV based string for output + * @param output if true, prints headers and strings to browser + * @param filename filename sent to browser in headers if output is true + * @param data 2D array with data + * @param fields field names + * @param delimiter delimiter used to separate data + * @return CSV data using delimiter of choice, or default + */ + function output ($output = true, $filename = null, $data = array(), $fields = array(), $delimiter = null) { + if ( empty($filename) ) $filename = $this->output_filename; + if ( $delimiter === null ) $delimiter = $this->output_delimiter; + $data = $this->unparse($data, $fields, null, null, $delimiter); + if ( $output ) { + header('Content-type: application/csv'); + header('Content-Disposition: inline; filename="'.$filename.'"'); + echo $data; + } + return $data; + } + + /** + * Convert character encoding + * @param input input character encoding, uses default if left blank + * @param output output character encoding, uses default if left blank + * @return nothing + */ + function encoding ($input = null, $output = null) { + $this->convert_encoding = true; + if ( $input !== null ) $this->input_encoding = $input; + if ( $output !== null ) $this->output_encoding = $output; + } + + /** + * Auto-Detect Delimiter: Find delimiter by analyzing a specific number of + * rows to determine most probable delimiter character + * @param file local CSV file + * @param parse true/false parse file directly + * @param search_depth number of rows to analyze + * @param preferred preferred delimiter characters + * @param enclosure enclosure character, default is double quote ("). + * @return delimiter character + */ + function auto ($file = null, $parse = true, $search_depth = null, $preferred = null, $enclosure = null) { + + if ( $file === null ) $file = $this->file; + if ( empty($search_depth) ) $search_depth = $this->auto_depth; + if ( $enclosure === null ) $enclosure = $this->enclosure; + + if ( $preferred === null ) $preferred = $this->auto_preferred; + + if ( empty($this->file_data) ) { + if ( $this->_check_data($file) ) { + $data = &$this->file_data; + } else return false; + } else { + $data = &$this->file_data; + } + + $chars = array(); + $strlen = strlen($data); + $enclosed = false; + $n = 1; + $to_end = true; + + // walk specific depth finding posssible delimiter characters + for ( $i=0; $i < $strlen; $i++ ) { + $ch = $data{$i}; + $nch = ( isset($data{$i+1}) ) ? $data{$i+1} : false ; + $pch = ( isset($data{$i-1}) ) ? $data{$i-1} : false ; + + // open and closing quotes + if ( $ch == $enclosure && (!$enclosed || $nch != $enclosure) ) { + $enclosed = ( $enclosed ) ? false : true ; + + // inline quotes + } elseif ( $ch == $enclosure && $enclosed ) { + $i++; + + // end of row + } elseif ( ($ch == "\n" && $pch != "\r" || $ch == "\r") && !$enclosed ) { + if ( $n >= $search_depth ) { + $strlen = 0; + $to_end = false; + } else { + $n++; + } + + // count character + } elseif (!$enclosed) { + if ( !preg_match('/['.preg_quote($this->auto_non_chars, '/').']/i', $ch) ) { + if ( !isset($chars[$ch][$n]) ) { + $chars[$ch][$n] = 1; + } else { + $chars[$ch][$n]++; + } + } + } + } + + // filtering + $depth = ( $to_end ) ? $n-1 : $n ; + $filtered = array(); + foreach( $chars as $char => $value ) { + if ( $match = $this->_check_count($char, $value, $depth, $preferred) ) { + $filtered[$match] = $char; + } + } + + // capture most probable delimiter + ksort($filtered); + $delimiter = reset($filtered); + $this->delimiter = $delimiter; + + // parse data + if ( $parse ) $this->data = $this->parse_string(); + + return $delimiter; + + } + + + // ============================================== + // ----- [ Core Functions ] --------------------- + // ============================================== + + /** + * Read file to string and call parse_string() + * @param file local CSV file + * @return 2D array with CSV data, or false on failure + */ + function parse_file ($file = null) { + if ( $file === null ) $file = $this->file; + if ( empty($this->file_data) ) $this->load_data($file); + return ( !empty($this->file_data) ) ? $this->parse_string() : false ; + } + + /** + * Parse CSV strings to arrays + * @param data CSV string + * @return 2D array with CSV data, or false on failure + */ + function parse_string ($data = null) { + if ( empty($data) ) { + if ( $this->_check_data() ) { + $data = &$this->file_data; + } else return false; + } + + $rows = array(); + $row = array(); + $row_count = 0; + $current = ''; + $head = ( !empty($this->fields) ) ? $this->fields : array() ; + $col = 0; + $enclosed = false; + $was_enclosed = false; + $strlen = strlen($data); + + // walk through each character + for ( $i=0; $i < $strlen; $i++ ) { + $ch = $data{$i}; + $nch = ( isset($data{$i+1}) ) ? $data{$i+1} : false ; + $pch = ( isset($data{$i-1}) ) ? $data{$i-1} : false ; + + // open and closing quotes + if ( $ch == $this->enclosure && (!$enclosed || $nch != $this->enclosure) ) { + $enclosed = ( $enclosed ) ? false : true ; + if ( $enclosed ) $was_enclosed = true; + + // inline quotes + } elseif ( $ch == $this->enclosure && $enclosed ) { + $current .= $ch; + $i++; + + // end of field/row + } elseif ( ($ch == $this->delimiter || ($ch == "\n" && $pch != "\r") || $ch == "\r") && !$enclosed ) { + if ( !$was_enclosed ) $current = trim($current); + $key = ( !empty($head[$col]) ) ? $head[$col] : $col ; + $row[$key] = $current; + $current = ''; + $col++; + + // end of row + if ( $ch == "\n" || $ch == "\r" ) { + if ( $this->_validate_offset($row_count) && $this->_validate_row_conditions($row, $this->conditions) ) { + if ( $this->heading && empty($head) ) { + $head = $row; + } elseif ( empty($this->fields) || (!empty($this->fields) && (($this->heading && $row_count > 0) || !$this->heading)) ) { + if ( !empty($this->sort_by) && !empty($row[$this->sort_by]) ) { + if ( isset($rows[$row[$this->sort_by]]) ) { + $rows[$row[$this->sort_by].'_0'] = &$rows[$row[$this->sort_by]]; + unset($rows[$row[$this->sort_by]]); + for ( $sn=1; isset($rows[$row[$this->sort_by].'_'.$sn]); $sn++ ) {} + $rows[$row[$this->sort_by].'_'.$sn] = $row; + } else $rows[$row[$this->sort_by]] = $row; + } else $rows[] = $row; + } + } + $row = array(); + $col = 0; + $row_count++; + if ( $this->sort_by === null && $this->limit !== null && count($rows) == $this->limit ) { + $i = $strlen; + } + } + + // append character to current field + } else { + $current .= $ch; + } + } + $this->titles = $head; + if ( !empty($this->sort_by) ) { + ( $this->sort_reverse ) ? krsort($rows) : ksort($rows) ; + if ( $this->offset !== null || $this->limit !== null ) { + $rows = array_slice($rows, ($this->offset === null ? 0 : $this->offset) , $this->limit, true); + } + } + return $rows; + } + + /** + * Create CSV data from array + * @param data 2D array with data + * @param fields field names + * @param append if true, field names will not be output + * @param is_php if a php die() call should be put on the first + * line of the file, this is later ignored when read. + * @param delimiter field delimiter to use + * @return CSV data (text string) + */ + function unparse ( $data = array(), $fields = array(), $append = false , $is_php = false, $delimiter = null) { + if ( !is_array($data) || empty($data) ) $data = &$this->data; + if ( !is_array($fields) || empty($fields) ) $fields = &$this->titles; + if ( $delimiter === null ) $delimiter = $this->delimiter; + + $string = ( $is_php ) ? "".$this->linefeed : '' ; + $entry = array(); + + // create heading + if ( $this->heading && !$append ) { + foreach( $fields as $key => $value ) { + $entry[] = $this->_enclose_value($value); + } + $string .= implode($delimiter, $entry).$this->linefeed; + $entry = array(); + } + + // create data + foreach( $data as $key => $row ) { + foreach( $row as $field => $value ) { + $entry[] = $this->_enclose_value($value); + } + $string .= implode($delimiter, $entry).$this->linefeed; + $entry = array(); + } + + return $string; + } + + /** + * Load local file or string + * @param input local CSV file + * @return true or false + */ + function load_data ($input = null) { + $data = null; + $file = null; + if ( $input === null ) { + $file = $this->file; + } elseif ( file_exists($input) ) { + $file = $input; + } else { + $data = $input; + } + if ( !empty($data) || $data = $this->_rfile($file) ) { + if ( $this->file != $file ) $this->file = $file; + if ( preg_match('/\.php$/i', $file) && preg_match('/<\?.*?\?>(.*)/ims', $data, $strip) ) { + $data = ltrim($strip[1]); + } + if ( $this->convert_encoding ) $data = iconv($this->input_encoding, $this->output_encoding, $data); + if ( substr($data, -1) != "\n" ) $data .= "\n"; + $this->file_data = &$data; + return true; + } + return false; + } + + + // ============================================== + // ----- [ Internal Functions ] ----------------- + // ============================================== + + /** + * Validate a row against specified conditions + * @param row array with values from a row + * @param conditions specified conditions that the row must match + * @return true of false + */ + function _validate_row_conditions ($row = array(), $conditions = null) { + if ( !empty($row) ) { + if ( !empty($conditions) ) { + $conditions = (strpos($conditions, ' OR ') !== false) ? explode(' OR ', $conditions) : array($conditions) ; + $or = ''; + foreach( $conditions as $key => $value ) { + if ( strpos($value, ' AND ') !== false ) { + $value = explode(' AND ', $value); + $and = ''; + foreach( $value as $k => $v ) { + $and .= $this->_validate_row_condition($row, $v); + } + $or .= (strpos($and, '0') !== false) ? '0' : '1' ; + } else { + $or .= $this->_validate_row_condition($row, $value); + } + } + return (strpos($or, '1') !== false) ? true : false ; + } + return true; + } + return false; + } + + /** + * Validate a row against a single condition + * @param row array with values from a row + * @param condition specified condition that the row must match + * @return true of false + */ + function _validate_row_condition ($row, $condition) { + $operators = array( + '=', 'equals', 'is', + '!=', 'is not', + '<', 'is less than', + '>', 'is greater than', + '<=', 'is less than or equals', + '>=', 'is greater than or equals', + 'contains', + 'does not contain', + ); + $operators_regex = array(); + foreach( $operators as $value ) { + $operators_regex[] = preg_quote($value, '/'); + } + $operators_regex = implode('|', $operators_regex); + if ( preg_match('/^(.+) ('.$operators_regex.') (.+)$/i', trim($condition), $capture) ) { + $field = $capture[1]; + $op = $capture[2]; + $value = $capture[3]; + if ( preg_match('/^([\'\"]{1})(.*)([\'\"]{1})$/i', $value, $capture) ) { + if ( $capture[1] == $capture[3] ) { + $value = $capture[2]; + $value = str_replace("\\n", "\n", $value); + $value = str_replace("\\r", "\r", $value); + $value = str_replace("\\t", "\t", $value); + $value = stripslashes($value); + } + } + if ( array_key_exists($field, $row) ) { + if ( ($op == '=' || $op == 'equals' || $op == 'is') && $row[$field] == $value ) { + return '1'; + } elseif ( ($op == '!=' || $op == 'is not') && $row[$field] != $value ) { + return '1'; + } elseif ( ($op == '<' || $op == 'is less than' ) && $row[$field] < $value ) { + return '1'; + } elseif ( ($op == '>' || $op == 'is greater than') && $row[$field] > $value ) { + return '1'; + } elseif ( ($op == '<=' || $op == 'is less than or equals' ) && $row[$field] <= $value ) { + return '1'; + } elseif ( ($op == '>=' || $op == 'is greater than or equals') && $row[$field] >= $value ) { + return '1'; + } elseif ( $op == 'contains' && preg_match('/'.preg_quote($value, '/').'/i', $row[$field]) ) { + return '1'; + } elseif ( $op == 'does not contain' && !preg_match('/'.preg_quote($value, '/').'/i', $row[$field]) ) { + return '1'; + } else { + return '0'; + } + } + } + return '1'; + } + + /** + * Validates if the row is within the offset or not if sorting is disabled + * @param current_row the current row number being processed + * @return true of false + */ + function _validate_offset ($current_row) { + if ( $this->sort_by === null && $this->offset !== null && $current_row < $this->offset ) return false; + return true; + } + + /** + * Enclose values if needed + * - only used by unparse() + * @param value string to process + * @return Processed value + */ + function _enclose_value ($value = null) { + if ( $value !== null && $value != '' ) { + $delimiter = preg_quote($this->delimiter, '/'); + $enclosure = preg_quote($this->enclosure, '/'); + if ( preg_match("/".$delimiter."|".$enclosure."|\n|\r/i", $value) || ($value{0} == ' ' || substr($value, -1) == ' ') ) { + $value = str_replace($this->enclosure, $this->enclosure.$this->enclosure, $value); + $value = $this->enclosure.$value.$this->enclosure; + } + } + return $value; + } + + /** + * Check file data + * @param file local filename + * @return true or false + */ + function _check_data ($file = null) { + if ( empty($this->file_data) ) { + if ( $file === null ) $file = $this->file; + return $this->load_data($file); + } + return true; + } + + + /** + * Check if passed info might be delimiter + * - only used by find_delimiter() + * @return special string used for delimiter selection, or false + */ + function _check_count ($char, $array, $depth, $preferred) { + if ( $depth == count($array) ) { + $first = null; + $equal = null; + $almost = false; + foreach( $array as $key => $value ) { + if ( $first == null ) { + $first = $value; + } elseif ( $value == $first && $equal !== false) { + $equal = true; + } elseif ( $value == $first+1 && $equal !== false ) { + $equal = true; + $almost = true; + } else { + $equal = false; + } + } + if ( $equal ) { + $match = ( $almost ) ? 2 : 1 ; + $pref = strpos($preferred, $char); + $pref = ( $pref !== false ) ? str_pad($pref, 3, '0', STR_PAD_LEFT) : '999' ; + return $pref.$match.'.'.(99999 - str_pad($first, 5, '0', STR_PAD_LEFT)); + } else return false; + } + } + + /** + * Read local file + * @param file local filename + * @return Data from file, or false on failure + */ + function _rfile ($file = null) { + if ( is_readable($file) ) { + if ( !($fh = fopen($file, 'r')) ) return false; + $data = fread($fh, filesize($file)); + fclose($fh); + return $data; + } + return false; + } + + /** + * Write to local file + * @param file local filename + * @param string data to write to file + * @param mode fopen() mode + * @param lock flock() mode + * @return true or false + */ + function _wfile ($file, $string = '', $mode = 'wb', $lock = 2) { + if ( $fp = fopen($file, $mode) ) { + flock($fp, $lock); + $re = fwrite($fp, $string); + $re2 = fclose($fp); + if ( $re != false && $re2 != false ) return true; + } + return false; + } + +} + +?> diff --git a/classes/shortcodes.php b/classes/shortcodes.php new file mode 100644 index 0000000..e5df40b --- /dev/null +++ b/classes/shortcodes.php @@ -0,0 +1,254 @@ +shortcode_tags = $this->get_shortcode_tags(); + + // Register shortcodes with WordPress + add_action( 'init', array( &$this, 'register_shortcodes' ) ); + + } + + /** + * This method loops through all my location shortcodes and registers them. + * + * All shortcode tags actually use the same callback method + * + * @since 2.4 + */ + function register_shortcodes() { + + // Register + add_shortcode( 'sm-location', array( &$this, 'do_shortcode' ) ); + + } + + /** + * Builds the array of tags used for location shortcodes + * + * @since 2.4 + */ + function get_shortcode_tags() { + + $shortcode_tags = array( + 'address', + 'city', + 'state', + 'zip', + 'country', + 'phone', + 'fax', + 'email', + 'url' + ); + + return apply_filters( 'sm-location-shortcode-tag-array', $shortcode_tags ); + } + + /** + * Responsible for returning a location address + * + * @since 2.4 + */ + function do_shortcode( $args ) { + + global $post, $simple_map; + $options = $simple_map->get_options(); + + // Default args for map itself, not for locations on map + $map_defaults = array( + 'data' => '', + 'before' => '', + 'after' => '', + 'map_width' => '75px', + 'map_height' => '75px', + 'default_lat' => get_post_meta( $post->ID, 'location_lat', true ), + 'default_lng' => get_post_meta( $post->ID, 'location_lng', true ), + 'panControl' => false, + 'zoomContorl' => false, + 'scaleControl' => false, + 'streetViewControl' => false, + 'mapTypeContorl' => false, + 'mapTypeId' => 'google.maps.MapTypeId.ROADMAP', + 'format' => 'csv', + ); + + $atts = shortcode_atts( $map_defaults, $args ); + + // If the requested data is description, return the post content + if ( 'description' == $atts['data'] ) + return $post->post_content; + + // If we're looking for the full address, compose that from the options + if ( 'full-address' == $atts['data'] ) { + $postmeta = get_metadata( 'post', $post->ID ); + $address_format = $options['address_format']; + + switch ( $address_format ) { + case 'town province postalcode' : + $full_address = $postmeta['location_address'][0] . ' ' . $postmeta['location_address2'][0] . ' ' .$postmeta['location_city'][0] . $postmeta['location_state'][0] . ' ' . $postmeta['location_zip'][0]; + break; + + case 'town-province postalcode' : + $full_address = $postmeta['location_address'][0] . ' ' . $postmeta['location_address2'][0] . ' ' .$postmeta['location_city'][0] . '-' . $postmeta['location_state'][0] . ' ' . $postmeta['location_zip'][0]; + break; + + case 'postalcode town-province' : + $full_address = $postmeta['location_address'][0] . ' ' . $postmeta['location_address2'][0] . ' ' .$postmeta['location_zip'][0] . ' ' . $postmeta['location_city'][0] . '-' . $postmeta['location_state'][0]; + break; + + case 'postalcode town, province' : + $full_address = $postmeta['location_address'][0] . ' ' . $postmeta['location_address2'][0] . ' ' .$postmeta['location_zip'][0] . ' ' . $postmeta['location_city'][0] . ', ' . $postmeta['location_state'][0]; + break; + + case 'postalcode town' : + $full_address = $postmeta['location_address'][0] . ' ' . $postmeta['location_address2'][0] . ' ' .$postmeta['location_zip'][0] . ' ' . $postmeta['location_city'][0]; + break; + + case 'town postalcode' : + $full_address = $postmeta['location_address'][0] . ' ' . $postmeta['location_address2'][0] . ' ' .$postmeta['location_city'][0] . ' ' . $postmeta['location_zip'][0]; + break; + + case 'town, province postalcode' : + default : + $full_address = $postmeta['location_address'][0] . ' ' . $postmeta['location_address2'][0] . ' ' .$postmeta['location_city'][0] . ', ' . $postmeta['location_state'][0] . ' ' . $postmeta['location_zip'][0]; + break; + + } + + return $full_address; + } + + // if the requested data is 'directions' return the link to google maps + if ( 'directions' == $atts['data'] ) + return $this->get_directions_link( $post->ID ); + + // if the requested data is a map, return the map + if ( 'iframe-map' == $atts['data'] ) { + + // Args we need to make the map itself - not the locations on the map + $r = array( + 'map_width' => $atts['map_width'], + 'map_height' => $atts['map_height'], + 'panControl' => $atts['pan_control'], + 'default_lat' => $atts['default_lat'], + 'default_lng' => $atts['default_lng'], + 'zoomControl' => $atts['zoom_control'], + 'scaleControl' => $atts['scale_control'], + 'streetViewControl' => $atts['street_view_control'], + 'mapTypeControl' => $atts['map_type_control'], + 'mapType' => $atts['map_type'] + ); + + // Determine location IDs + $location_ids = empty( $args['location_ids'] ) ? array( $post->ID ) : explode( ',', $args['location_ids'] ); + + // Init the object and return the iframe source + $map = new SM_Map_Factory(); + $map->set_map_atts( $r ); + + // Add Locations + foreach( $location_ids as $location_id ) { + $map->add_location( $location_id ); + } + + return $map->get_iframe_embed(); + + } + + // If the requested data is a taxonomy + $sm_taxes = $simple_map->get_sm_taxonomies( 'array', '', true, 'objects' ) ? $simple_map->get_sm_taxonomies( 'array', '', true, 'objects' ) : array(); + + foreach( $sm_taxes as $taxonomy ) { + if ( $taxonomy->name == $atts['data'] ) { + // Forward compatible format types + $tax_format = ( in_array( $atts['format'], array( 'csv' ) ) ) ? $atts['format'] : 'csv'; + if ( $terms = wp_get_object_terms( $post->ID, $taxonomy->query_var ) ) { + foreach( $terms as $termk => $termv ) { + $term_names[] = $termv->name; + } + + } else { + $term_names = array(); + } + + // Forward compatible format types + switch( $tax_format ) { + case 'csv': + default: + return ! empty( $term_names ) ? $args['before'] . implode( ', ', $term_names ) . $args['after'] : '' ; + break; + } + } + } + + // Look for postmeta with location_ prepended to it + if ( $value = get_post_meta( absint( $post->ID ), 'location_' . $atts['data'], true ) ) + return str_replace( '%self%', $value, $atts['before'] . $value . $atts['after'] ); + + // Look for postmeta of another type + if ( $value = get_post_meta( absint( $post->ID ), $atts['data'], true ) ) + return str_replace( '%self%', $value, $atts['before'] . $value . $atts['after'] ); + + return false; + } + + /** + * Returns a directions link + * + * @since 2.4 + */ + function get_directions_link( $post ) { + global $simple_map; + + $options = $simple_map->get_options(); + $address = $directions_url = ''; + + if ( $pm = get_metadata( 'post', $post ) ) { + + $address .= empty( $pm['location_address'][0] ) ? '' : $pm['location_address'][0]; + $address .= empty( $pm['location_city'][0] ) ? '' : ' '.$pm['location_city'][0]; + $address .= empty( $pm['location_state'][0] ) ? '' : ' '.$pm['location_state'][0]; + $address .= empty( $pm['location_zip'][0] ) ? '' : ' '.$pm['location_zip'][0]; + $address .= empty( $pm['location_country'][0] ) ? '' : ' '.$pm['location_country'][0]; + + $directions_url = 'http://google' . $options['default_domain'] . '/maps?saddr=&daddr=' . urlencode( $address ); + + } + + return $directions_url; + + } + + } + +} diff --git a/classes/simplemap.php b/classes/simplemap.php new file mode 100644 index 0000000..c49818b --- /dev/null +++ b/classes/simplemap.php @@ -0,0 +1,2369 @@ +plugin_domain, 'wp-content/plugins/' . $plugin_dir . '/lang', $plugin_dir . '/lang' ); + + $this->plugin_url = SIMPLEMAP_URL; + + // Add shortcode handler + add_shortcode( 'simplemap', array( &$this, 'display_map' ) ); + + // Enqueue frontend scripts & styles into + add_action( 'template_redirect', array( &$this, 'enqueue_frontend_scripts_styles' ) ); + + // Enqueue backend scripts + add_action( 'init', array( &$this, 'enqueue_backend_scripts_styles' ) ); + + // Add hook for master js file + add_action( 'template_redirect', array( &$this, 'google_map_js_script' ) ); + + // Add hook for general options js file + add_action( 'init', array( &$this, 'general_options_js_script' ) ); + + // Query vars + add_filter( 'query_vars', array( &$this, 'register_query_vars' ) ); + + // Backwards compat for core sm taxonomies + add_filter( 'sm_category-text', array( &$this, 'backwards_compat_categories_text' ) ); + add_filter( 'sm_tag-text', array( &$this, 'backwards_compat_tags_text' ) ); + add_filter( 'sm_day-text', array( &$this, 'backwards_compat_days_text' ) ); + add_filter( 'sm_time-text', array( &$this, 'backwards_compat_times_text' ) ); + + } + + // This function generates the code to display the map + function display_map( $atts ) { + + $options = $this->get_options(); + + $atts = $this->parse_shortcode_atts( $atts ); + + extract( $atts ); + + $to_display = ''; + + $to_display .= $this->location_search_form( $atts ); + + if ( $powered_by ) + $to_display .= '
    ' . sprintf( __( 'Powered by %s SimpleMap', 'SimpleMap' ), '' ) . '
    '; + + // Hide map? + $hidemap = ( $hide_map ) ? "display:none; " : ''; + + // Hide list? + $hidelist = $hide_list ? "display:none; " : ''; + + // Map Width and height + $map_width = ( '' == $map_width ) ? $options['map_width'] : $map_width; + $map_height = ( '' == $map_height ) ? $options['map_height'] : $map_height; + + // Updating Div + $sm_updating_img_src = apply_filters( 'sm_updating_img_src', SIMPLEMAP_URL . '/inc/images/loading.gif' ); + $sm_updating_div_size = apply_filters( 'sm_updating_img_size', 'height:' . $map_height . ';width:' . $map_width . ';' ); + $to_display .= '
    ' . __( 'Loading new locations', 'SimpleMap' ) . '
    '; + + $to_display .= '
    '; + $to_display .= '
    '; + $to_display .= ''; + + return apply_filters( 'sm-display-map', $to_display, $atts ); + } + + // This function returns the location search form + function location_search_form( $atts ) { + global $post; + + // Grab default SimpleMap options + $options = $this->get_options(); + + // Merge default simplemap options with default shortcode options and provided shortcode options + $atts = $this->parse_shortcode_atts( $atts ); + + // Create individual vars for each att + extract( $atts ); + + // Array of the names for all taxonomies registered with sm-location post type + $sm_tax_names = get_object_taxonomies( 'sm-location' ); + + // Array of field names for this form (with label syntax stripped + $form_field_names = $this->get_form_field_names_from_shortcode_atts( $search_fields ); + + // Form onsubmit, action, and method values + $on_submit = apply_filters( 'sm-location-search-onsubmit', ' onsubmit="searchLocations( 1 ); return false; "', $post->ID ); + $action = apply_filters( 'sm-locaiton-search-action', get_permalink(), $post->ID ); + $method = apply_filters( 'sm-location-search-method', 'post', $post->ID ); + + // Form Field Values + $address_value = get_query_var( 'location_search_address' ); + $city_value = isset( $_REQUEST['location_search_city'] ) ? $_REQUEST['location_search_city'] : ''; + $state_value = isset( $_REQUEST['location_search_state'] ) ? $_REQUEST['location_search_state'] : ''; + $zip_value = get_query_var( 'location_search_zip' ); + $country_value = get_query_var( 'location_search_country' ); + $radius_value = isset( $_REQUEST['location_search_distance'] ) ? $_REQUEST['location_search_distance'] : $radius; + $limit_value = isset( $_REQUEST['location_search_limit'] ) ? $_REQUEST['location_search_limit'] : $limit; + $is_sm_search = isset( $_REQUEST['location_is_search_results'] ) ? 1 : 0; + + // Normal Field inputs + $ffi['street'] = array( 'label' => apply_filters( 'sm-search-label-street', __( 'Street: ', 'SimpleMap' ), $post ), 'input' => '' ); + $ffi['city'] = array( 'label' => apply_filters( 'sm-search-label-city', __( 'City: ', 'SimpleMap' ), $post ), 'input' => '' ); + $ffi['state'] = array( 'label' => apply_filters( 'sm-search-label-state', __( 'State: ', 'SimpleMap' ), $post ), 'input' => '' ); + $ffi['zip'] = array( 'label' => apply_filters( 'sm-search-label-zip', __( 'Zip: ', 'SimpleMap' ), $post ), 'input' => '' ); + $ffi['country'] = array( 'label' => apply_filters( 'sm-search-label-country', __( 'Country: ', 'SimpleMap' ), $post ), 'input' => '' ); + $ffi['empty'] = array( 'label' => '', 'input' => '' ); + $ffi['submit'] = array( 'label' => '', 'input' => '' ); + $ffi['distance'] = $this->add_distance_field( $radius_value, $units ); + + $hidden_fields = array(); + + // Visible Taxonomy Field Inputs + foreach ( $sm_tax_names as $tax_name ) { + if ( in_array( $tax_name, $form_field_names ) && $this->show_taxonomy_filter( $atts, $tax_name ) ) + $ffi[$tax_name] = $this->add_taxonomy_fields( $atts, $tax_name ); + else + $hidden_fields[] = ''; + } + + // More Taxonomy Fields + foreach ( $sm_tax_names as $tax_name ) { + $hidden_fields[] = ''; + } + + // Hide search? + $hidesearch = $hide_search ? " style='display:none;' " : ''; + + $location_search = ''; // close map_search div + + return apply_filters( 'sm_location_search_form', $location_search, $atts ); + } + + // Separates form field names from label syntax attached to them when submitted via shortcode + function get_form_field_names_from_shortcode_atts( $fields ) { + + // String to array + $fields = explode( '||', $fields); + + foreach( $fields as $key => $field ) { + + switch( substr( $field, 0, 8 ) ) { + + case 'labelbr_' : + $field_names[] = substr( $field, 8 ); + break; + case 'labelsp_' : + $field_names[] = substr( $field, 8 ); + break; + case 'labeltd_' : + $field_names[] = substr( $field, 8 ); + break; + default : + $field_names[] = $field; + } + + } + + return (array) $field_names; + + } + + // Determines if we're supposed to show this taxonomy's filter options in the form + function show_taxonomy_filter( $atts, $tax_name ) { + + // Convert tax_name to PHP safe equiv + $php_tax_name = str_replace( '-', '_', $tax_name ); + + // Convert Given Taxonomy's 'show filter' into a generic one + $key = 'show_' . $php_tax_name . '_filter'; + $show_taxes_filter = $atts[$key]; + + if ( false != $show_taxes_filter && 'false' != $show_taxes_filter ) + return true; + + return false; + + } + + // Adds Distance field to form + function add_distance_field( $radius_value, $units ) { + global $post; + + // Distance + $distance_input = ''; + + return array( 'label' => apply_filters( 'sm-search-label-distance', __( 'Select a distance: ', 'SimpleMap' ), $post ), 'input' => $distance_input ); + + } + + // Adds taxonomy fields to search form + function add_taxonomy_fields( $atts, $taxonomy ) { + global $post; + + // Get taxonomy object or return empty; + if ( ! $tax_object = get_taxonomy( $taxonomy ) ) + return ''; + + $options = $this->get_options(); + + $atts = $this->parse_shortcode_atts( $atts ); + + extract( $atts ); + + $php_taxonomy = str_replace( '-', '_', $taxonomy ); + + // Convert Specific Taxonomy var names and var values to Generic var names and var values + $taxonomies = $atts[$php_taxonomy]; + $tax_hidden_name = 'avail_' . $php_taxonomy; + $show_taxes_filter = $atts['show_' . $php_taxonomy . '_filter']; + $tax_field_name = $php_taxonomy; + + // This originates at the comma separated list of taxonomy ids in the shortcode. ie: sm_category='1,3,5' + $taxes_avail = $atts[$tax_hidden_name]; + + // Place available taxes in array + $taxes_avail = explode( ',', $taxes_avail ); + $taxes_array = array(); + + // Loop through all cats and create array of available cats + if ( $all_taxes = get_terms( $taxonomy ) ) { + + foreach ( $all_taxes as $key => $value ){ + if ( '' == $taxes_avail[0] || in_array( $value->term_id, $taxes_avail ) ) { + $taxes_array[] = $value->term_id; + } + } + + } + + $taxes_avail = $taxes_array; + + // Show taxes filters if allowed + $tax_search = ''; + $tax_label = apply_filters( $php_taxonomy . '-text', __( $tax_object->labels->singular_name . ': ' ), 'SimpleMap' ); + + $taxes_array = apply_filters( 'sm-search-from-taxonomies', $taxes_array, $taxonomy ); + + if ( 'checkboxes' == $taxonomy_field_type ) { + // Print checkbox for each available cat + foreach( $taxes_array as $key => $taxid ) { + if( $term = get_term_by( 'id', $taxid, $taxonomy ) ) { + $tax_checked = isset( $_REQUEST['location_search_' . $tax_field_name . '_' . esc_attr( $term->term_id ) . 'field'] ) ? ' checked="checked" ' : ''; + $tax_search .= ' '; + } + } + } elseif( 'select' == $taxonomy_field_type ) { + // Print selectbox if that's what we're doing + $tax_select = ""; + + if ( ! empty( $taxid ) ) + $tax_search .= $tax_select; + } + + return array( 'label' => $tax_label, 'input' => $tax_search ); + } + + // This function enqueues all the javascript and stylesheets + function enqueue_frontend_scripts_styles() { + global $post; + $options = $this->get_options(); + + // Rewrite rules if we've changed the location permalink slug + if ( get_option( 'sm-rewrite-rules' ) ) { + global $wp_rewrite; + $wp_rewrite->flush_rules(); + delete_option( 'sm-rewrite-rules' ); + } + + // Frontend only + if ( ! is_admin() && is_object( $post ) || apply_filters( 'sm-force-frontend-js', '__return_false' ) ) { + // Bail if we're not showing on all pages and this isn't a map page + if ( ! in_array( $post->ID, explode( ',', $options['map_pages'] ) ) && ! in_array( 0, explode( ',', $options['map_pages'] ) ) ) + return false; + + // Check for use of custom stylesheet and load styles + if ( strstr( $options['map_stylesheet'], 'simplemap-styles' ) ) + $style_url = plugins_url() . '/' . $options['map_stylesheet']; + else + $style_url = SIMPLEMAP_URL . '/' . $options['map_stylesheet']; + + // Load styles + wp_enqueue_style( 'simplemap-map-style', $style_url ); + + // Scripts + wp_enqueue_script( 'simplemap-master-js', get_home_url() . '?simplemap-master-js=1&smpid=' . $post->ID, array( 'jquery' ) ); + + // Google API v3 does not need a key + $url_params = array( + 'sensor' => 'false', + 'v' => '3', + 'language' => $options['default_language'], + 'region' => $options['default_country'], + ); + if ( $options['adsense_for_maps'] ) { + $url_params['libraries'] = 'adsense'; + } + wp_enqueue_script( 'simplemap-google-api', SIMPLEMAP_MAPS_JS_API . http_build_query( $url_params, '', '&' ) ); + } + } + + // This function enqueues all the javascript and stylesheets + function enqueue_backend_scripts_styles() { + // Admin only + if ( is_admin() ) { + $options = $this->get_options(); + wp_enqueue_style( 'simplemap-admin', SIMPLEMAP_URL . '/inc/styles/admin.css' ); + + // SimpleMap General options + if ( isset( $_GET['page'] ) && 'simplemap' == $_GET['page'] ) + wp_enqueue_script( 'simplemap-general-options-js', get_home_url() . '/?simplemap-general-options-js', array( 'jquery' ) ); + + // Google API v3 does not need a key + $url_params = array( + 'v' => '3', + 'sensor' => 'false', + 'language' => $options['default_language'], + 'region' => $options['default_country'], + ); + wp_enqueue_script( 'simplemap-google-api', SIMPLEMAP_MAPS_JS_API . http_build_query( $url_params, '', '&' ) ); + } + } + + // JS Script for general options page + function general_options_js_script() { + if ( ! isset( $_GET['simplemap-general-options-js'] ) ) + return; + + header( 'Status: 200 OK', false, 200 ); + header( 'Content-type: application/x-javascript' ); + do_action( 'sm-master-js-headers' ); + + $options = $this->get_options(); + + do_action( 'sm-general-options-js' ); + ?> + function codeAddress() { + // if this is modified, modify mirror function in master-js php function + var d_address = document.getElementById("default_address").value; + + geocoder = new google.maps.Geocoder(); + geocoder.geocode( { 'address': d_address }, function( results, status ) { + if ( status == google.maps.GeocoderStatus.OK ) { + var latlng = results[0].geometry.location; + document.getElementById("default_lat").value = latlng.lat(); + document.getElementById("default_lng").value = latlng.lng(); + } else { + alert("Geocode was not successful for the following reason: " + status); + } + }); + } + get_options(); + + ?> + var default_lat = ; + var default_lng = ; + var default_radius = ; + var zoom_level = ''; + var map_width = ''; + var map_height = ''; + var special_text = ''; + var units = ''; + var limit = ''; + var plugin_url = ''; + var visit_website_text = ''; + var get_directions_text = ''; + var location_tab_text = ''; + var description_tab_text = ''; + var phone_text = ''; + var fax_text = ''; + var email_text = ''; + + var taxonomy_text = {}; + get_sm_taxonomies( 'array', '', true, 'object' ) ) { + foreach( $taxonomies as $taxonomy ) { + ?> + taxonomy_text.name; ?> = 'name . '-text', __( $taxonomy->labels->name, 'SimpleMap' ) ); ?>'; + + var noresults_text = ''; + var default_domain = ''; + var address_format = ''; + var siteurl = ''; + var map; + var geocoder; + var autoload = ''; + var auto_locate = ''; + var markersArray = []; + var infowindowsArray = []; + + function clearInfoWindows() { + if (infowindowsArray) { + for (var i=0;i + jQuery( "#simplemap" ).html( "

    General Settings before your maps will work.', 'SimpleMap' ), admin_url( 'admin.php?page=simplemap' ) ); ?>

    " ); + + + if ( lat == 0 ) { + lat = ''; + } + + if ( lng == 0 ) { + lng = ''; + } + + var latlng = new google.maps.LatLng( lat, lng ); + var myOptions = { + zoom: parseInt(zoom_level), + center: latlng, + mapTypeId: google.maps.MapTypeId[map_type] + }; + map = new google.maps.Map( document.getElementById( "simplemap" ), myOptions ); + + // Adsense for Google Maps + + + // Adsense ID. If no shortcode, check for options. If not options, use blank string. + if ( aspid == 0 ) + aspid = ''; + + // Channel ID. If no shortcode, check for options. If not options, use blank string. + if ( ascid == 0 ) + ascid = ''; + + // Max ads per map. If no shortcode, check for options. If no options, use 2. + if ( asma == 0 ) + asma = ''; + + var publisher_id = aspid; + + var adUnitDiv = document.createElement('div'); + var adUnitOptions = { + channelNumber: ascid, + format: google.maps.adsense.AdFormat.HALF_BANNER, + position: google.maps.ControlPosition.TOP, + map: map, + visible: true, + publisherId: publisher_id + }; + adUnit = new google.maps.adsense.AdUnit(adUnitDiv, adUnitOptions); + + } + + function codeAddress() { + // if this is modified, modify mirror function in general-options-js php function + var d_address = document.getElementById("default_address").value; + + geocoder = new google.maps.Geocoder(); + geocoder.geocode( { 'address': d_address }, function( results, status ) { + if ( status == google.maps.GeocoderStatus.OK ) { + var latlng = results[0].geometry.location; + document.getElementById("default_lat").value = latlng.lat(); + document.getElementById("default_lng").value = latlng.lng(); + } else { + alert("Geocode was not successful for the following reason: " + status); + } + }); + } + + function codeNewAddress() { + if (document.getElementById("store_lat").value != '' && document.getElementById("store_lng").value != '') { + document.new_location_form.submit(); + } + else { + var address = ''; + var street = document.getElementById("store_address").value; + var city = document.getElementById("store_city").value; + var state = document.getElementById("store_state").value; + var country = document.getElementById("store_country").value; + + if (street) { address += street + ', '; } + if (city) { address += city + ', '; } + if (state) { address += state + ', '; } + address += country; + + geocoder = new google.maps.Geocoder(); + geocoder.geocode( { 'address': address }, function( results, status ) { + if ( status == google.maps.GeocoderStatus.OK ) { + var latlng = results[0].geometry.location; + document.getElementById("store_lat").value = latlng.lat(); + document.getElementById("store_lng").value = latlng.lng(); + document.new_location_form.submit(); + } else { + alert("Geocode was not successful for the following reason: " + status); + } + }); + } + } + + function codeChangedAddress() { + var address = ''; + var street = document.getElementById("store_address").value; + var city = document.getElementById("store_city").value; + var state = document.getElementById("store_state").value; + var country = document.getElementById("store_country").value; + + if (street) { address += street + ', '; } + if (city) { address += city + ', '; } + if (state) { address += state + ', '; } + address += country; + + geocoder = new google.maps.Geocoder(); + geocoder.geocode( { 'address': address }, function( results, status ) { + if ( status == google.maps.GeocoderStatus.OK ) { + var latlng = results[0].geometry.location; + document.getElementById("store_lat").value = latlng.lat(); + document.getElementById("store_lng").value = latlng.lng(); + } else { + alert("Geocode was not successful for the following reason: " + status); + } + }); + } + + function searchLocations( is_search ) { + // Init searchData + var searchData = {}; + searchData.taxes = {}; + + // Set defaults for search form fields + searchData.address = ''; + searchData.city = ''; + searchData.state = ''; + searchData.zip = ''; + searchData.country = ''; + + if ( null != document.getElementById('location_search_address_field') ) { + searchData.address = document.getElementById('location_search_address_field').value; + } + + if ( null != document.getElementById('location_search_city_field') ) { + searchData.city = document.getElementById('location_search_city_field').value; + } + + if ( null != document.getElementById('location_search_country_field') ) { + searchData.country = document.getElementById('location_search_country_field').value;; + } + + if ( null != document.getElementById('location_search_state_field') ) { + searchData.state = document.getElementById('location_search_state_field').value; + } + + if ( null != document.getElementById('location_search_zip_field') ) { + searchData.zip = document.getElementById('location_search_zip_field').value; + } + + if ( null != document.getElementById('location_search_distance_field') ) { + searchData.radius = document.getElementById('location_search_distance_field').value; + } + + searchData.lat = document.getElementById('location_search_default_lat').value; + searchData.lng = document.getElementById('location_search_default_lng').value; + searchData.limit = document.getElementById('location_search_limit').value; + searchData.searching = document.getElementById('location_is_search_results').value; + + // Do SimpleMap Taxonomies + + + // Do taxnonomy for checkboxes + searchData.taxes. = ''; + var checks_found = false; + jQuery( 'input[rel=location_search__field]' ).each( function() { + checks_found = true; + if ( jQuery( this ).attr( 'checked' ) && jQuery( this ).attr( 'value' ) != null ) { + += jQuery( this ).attr( 'value' ) + ','; + } + }); + + // Do taxnonomy for select box if checks weren't found + if ( false == checks_found ) { + jQuery( 'option[rel=location_search__select_val]' ).each( function() { + if ( jQuery( this ).attr( 'selected' ) && jQuery( this ).attr( 'value' ) != null ) { + += jQuery( this ).attr( 'value' ) + ','; + } + }); + } + + + + var query = ''; + var start = 0; + + if ( searchData.address && searchData.address != '' ) { + query += searchData.address + ', '; + } + + if ( searchData.city && searchData.city != '' ) { + query += searchData.city + ', '; + } + + if ( searchData.state && searchData.state != '' ) { + query += searchData.state + ', '; + } + + if ( searchData.zip && searchData.zip != '' ) { + query += searchData.zip + ', '; + } + + if ( searchData.country && searchData.country != '' ) { + query += searchData.country + ', '; + } + + // Query + if ( query != null ) { + query = query.slice(0, -2); + } + + if ( searchData.limit == '' || searchData.limit == null ) { + searchData.limit = 0; + } + + if ( searchData.radius == '' || searchData.radius == null ) { + searchData.radius = 0; + } + + // Taxonomies + + + if ( != null ) { + var _ = .slice(0, -1); + } else { + var _ = ''; + } + + // Append available taxes logic if no taxes are selected but limited taxes were passed through shortcode as available + if ( '' != document.getElementById('avail_').value && '' == _ ) { + _ = 'OR,' + document.getElementById('avail_').value; + } + + searchData.taxes. = _; + + + + // Load default location if query is empty + if ( query == '' || query == null ) { + + if ( searchData.lat != 0 && searchData.lng != 0 ) + query = searchData.lat + ', ' + searchData.lng; + else + query = ', '; + + } + + // Searching + if ( 1 == searchData.searching || 1 == is_search ) { + is_search = 1; + searchData.source = 'search'; + } else { + is_search = 0; + searchData.source = 'initial_load'; + } + + geocoder.geocode( { 'address': query }, function( results, status ) { + if ( status == google.maps.GeocoderStatus.OK ) { + searchData.center = results[0].geometry.location; + if ( 'none' != autoload || is_search ) { + if ( 'all' == autoload && is_search != 1 ) { + searchData.radius = 0; + searchData.limit = 0; + } + + if (! searchData.center) { + searchData.center = new GLatLng( 44.9799654, -93.2638361 ); + } + searchData.query_type = 'all'; + searchData.mapLock = 'unlock'; + searchData.homeAddress = query; + + searchLocationsNear(searchData); + } + } + }); + } + + function searchLocationsNear(searchData) { + // Radius + if ( searchData.radius != null && searchData.radius != '' ) { + searchData.radius = parseInt( searchData.radius ); + + if ( units == 'km' ) { + searchData.radius = parseInt( searchData.radius ) / 1.609344; + } + } else if ( autoload == 'all' ) { + searchData.radius = 0; + } else { + if ( units == 'mi' ) { + searchData.radius = parseInt( default_radius ); + } else if ( units == 'km' ) { + searchData.radius = parseInt( default_radius ) / 1.609344; + } + } + + // Build search URL + get_sm_taxonomies( 'array', '', true ) ) { + $js_tax_string = ''; + foreach( $taxonomies as $taxonomy ) { + $js_tax_string .= "'&$taxonomy=' + searchData.taxes.$taxonomy + "; + } + } + ?> + + var searchUrl = siteurl + '/?sm-xml-search=1&lat=' + searchData.center.lat() + '&lng=' + searchData.center.lng() + '&radius=' + searchData.radius + '&namequery=' + searchData.homeAddress + '&query_type=' + searchData.query_type + '&limit=' + searchData.limit + '&address=' + searchData.address + '&city=' + searchData.city + '&state=' + searchData.state + '&zip=' + searchData.zip + '&pid='; + + + // Display Updating Message and hide search results + if ( jQuery( "#simplemap" ).is(":visible") ) { + jQuery( "#simplemap" ).hide(); + jQuery( "#simplemap-updating" ).show(); + } + + jQuery( "#results" ).html( '' ); + + jQuery.get( searchUrl, {}, function(data) { + + // Hide Updating Message + if ( jQuery( "#simplemap-updating" ).is(":visible") ) { + jQuery( "#simplemap-updating" ).hide(); + jQuery( "#simplemap" ).show(); + } + + + clearOverlays(); + + var results = document.getElementById('results'); + results.innerHTML = ''; + + var markers = jQuery( eval( data ) ); + if (markers.length == 0) { + results.innerHTML = '

    ' + noresults_text + '

    '; + map.setCenter( searchData.center ); + return; + } + + var bounds = new google.maps.LatLngBounds(); + markers.each( function () { + var locationData = this; + locationData.distance = parseFloat(locationData.distance); + locationData.point = new google.maps.LatLng(parseFloat(locationData.lat), parseFloat(locationData.lng)); + locationData.homeAddress = searchData.homeAddress; + + var marker = createMarker(locationData); + var sidebarEntry = createSidebarEntry(marker, locationData, searchData); + results.appendChild(sidebarEntry); + bounds.extend(locationData.point); + }); + + // Make centeral marker on search + if ( 'search' == searchData.source && ) { + var searchMarkerOptions = {}; + searchMarkerOptions.map = map; + searchMarkerOptions.position = searchData.center; + + searchMarkerOptions.icon = new google.maps.MarkerImage( + '', + new google.maps.Size(20, 32), + new google.maps.Point(0,0), + new google.maps.Point(0,32) + ); + + var searchMarkerTitle = ''; + if ( '' != searchData.address ) { + searchMarkerTitle += searchData.address + ' '; + } + if ( '' != searchData.city ) { + searchMarkerTitle += searchData.city + ' '; + } + if ( '' != searchData.state ) { + searchMarkerTitle += searchData.state + ' '; + } + if ( '' != searchData.zip ) { + searchMarkerTitle += searchData.zip + ' '; + } + + var searchMarker = new google.maps.Marker( searchMarkerOptions ); + searchMarker.title = searchMarkerTitle; + markersArray.push(searchMarker); + bounds.extend(searchMarkerOptions.position); + } + + // If the search button was clicked, limit to a 15px zoom + if ( 'search' == searchData.source ) { + map.fitBounds( bounds ); + if ( map.getZoom() > 15 ) { + map.setZoom( 15 ); + } + } else { + // If initial load of map, zoom to default settings + map.setZoom(parseInt(zoom_level)); + } + + // Paranoia - fix container sizing bug -- pdb + google.maps.event.addListener(map, "idle", function(){ + google.maps.event.trigger(map, 'resize'); + }); + }); + } + + function stringFilter(s) { + filteredValues = "emnpxt%"; // Characters stripped out + var i; + var returnString = ""; + for (i = 0; i < s.length; i++) { // Search through string and append to unfiltered values to returnString. + var c = s.charAt(i); + if (filteredValues.indexOf(c) == -1) returnString += c; + } + return returnString; + } + + function createMarker( locationData ) { + + // Init tax heights + locationData.taxonomyheights = []; + + // Allow plugin users to define Maker Options (including custom images) + var markerOptions = {}; + if ( 'function' == typeof window.simplemapCustomMarkers ) { + markerOptions = simplemapCustomMarkers( locationData ); + } + + // Allow developers to turn of description in bubble. (Return true to hide) + + locationData.description = ''; + + + markerOptions.map = map; + markerOptions.position = locationData.point; + var marker = new google.maps.Marker( markerOptions ); + marker.title = locationData.name; + markersArray.push(marker); + + var mapwidth; + var mapheight; + var maxbubblewidth; + var maxbubbleheight; + + mapwidth = document.getElementById("simplemap"); + if ( typeof mapwidth != 'undefined' ) { + mapwidth = mapwidth.offsetWidth; + } else { + if ( typeof map_width != 'undefined' ) { + mapwidth = Number(stringFilter(map_width)); + } else { + mapwidth = 400; + } + } + + mapheight = document.getElementById("simplemap"); + if ( typeof mapheight != 'undefined' ) { + mapheight = mapheight.offsetHeight; + } else { + if ( typeof map_height != 'undefined' ) { + mapheight = Number(stringFilter(map_height)); + } else { + mapheight = 200; + } + } + maxbubblewidth = Math.round(mapwidth / 1.5); + maxbubbleheight = Math.round(mapheight / 2.2); + + var fontsize = 12; + var lineheight = 12; + + if (locationData.taxes.sm_category && locationData.taxes.sm_category != '' ) { + var titleheight = 3 + Math.floor((locationData.name.length + locationData.taxes.sm_category.length) * fontsize / (maxbubblewidth * 1.5)); + } else { + var titleheight = 3 + Math.floor((locationData.name.length) * fontsize / (maxbubblewidth * 1.5)); + } + + var addressheight = 2; + if (locationData.address2 != '') { + addressheight += 1; + } + if (locationData.phone != '' || locationData.fax != '') { + addressheight += 1; + if (locationData.phone != '') { + addressheight += 1; + } + if (locationData.fax != '') { + addressheight += 1; + } + } + + for (jstax in locationData.taxes) { + if ( locationData.taxes[jstax] !== '' ) { + locationData.taxonomyheights[jstax] = 3 + Math.floor((locationData.taxes[jstax][length]) * fontsize / (maxbubblewidth * 1.5)); + } + } + var linksheight = 2; + + var totalheight = titleheight + addressheight; + for (jstax in locationData.taxes) { + if ( 'sm_category' != jstax ) { + totalheight += locationData.taxonomyheights[jstax]; + } + } + totalheight = (totalheight + 1) * fontsize; + + if (totalheight > maxbubbleheight) { + totalheight = maxbubbleheight; + } + + if ( isNaN( totalheight ) || totalheight > maxbubbleheight ) { + totalheight = maxbubbleheight; + } + + var html = '
    '; + html += '

    '; + + if ( '' != locationData.permalink ) { + html += ''; + } + html += locationData.name; + + if ( '' != locationData.permalink ) { + html += ''; + } + + if (locationData.taxes.sm_category && locationData.taxes.sm_category != null && locationData.taxes.sm_category != '' ) { + html += '
    ' + locationData.taxes.sm_category + ''; + } + + html += '

    '; + + html += '

    ' + locationData.address; + if (locationData.address2 != '') { + html += '
    ' + locationData.address2; + } + + // Address Data + if (address_format == 'town, province postalcode') { + html += '
    ' + locationData.city + ', ' + locationData.state + ' ' + locationData.zip + '

    '; + } else if (address_format == 'town province postalcode') { + html += '
    ' + locationData.city + ' ' + locationData.state + ' ' + locationData.zip + '

    '; + } else if (address_format == 'town-province postalcode') { + html += '
    ' + locationData.city + '-' + locationData.state + ' ' + locationData.zip + '

    '; + } else if (address_format == 'postalcode town-province') { + html += '
    ' + locationData.zip + ' ' + locationData.city + '-' + locationData.state + '

    '; + } else if (address_format == 'postalcode town, province') { + html += '
    ' + locationData.zip + ' ' + locationData.city + ', ' + locationData.state + '

    '; + } else if (address_format == 'postalcode town') { + html += '
    ' + locationData.zip + ' ' + locationData.city + '

    '; + } else if (address_format == 'town postalcode') { + html += '
    ' + locationData.city + ' ' + locationData.zip + '

    '; + } + + // Phone and Fax Data + if (locationData.phone != null && locationData.phone != '') { + html += '

    ' + phone_text + ': ' + locationData.phone + ''; + if (locationData.email != null && locationData.email != '') { + html += '
    ' + email_text + ': ' + locationData.email + ''; + } + if (locationData.fax != null && locationData.fax != '') { + html += '
    ' + fax_text + ': ' + locationData.fax + ''; + } + html += '

    '; + } else if (locationData.fax != null && locationData.fax != '') { + html += '

    ' + fax_text + ': ' + locationData.fax + '

    '; + } + + html += '

    '; + + for (jstax in locationData.taxes) { + if ( 'sm_category' == jstax ) { + continue; + } + if ( locationData.taxes[jstax] != null && locationData.taxes[jstax] != '' ) { + html += taxonomy_text[jstax] + ': ' + locationData.taxes[jstax] + '
    '; + } + } + html += '

    '; + + var dir_address = locationData.point.toUrlValue(10); + var dir_address2 = ''; + if (locationData.address) { dir_address2 += locationData.address; } + if (locationData.city) { if ( '' != dir_address2 ) { dir_address2 += ' '; } dir_address2 += locationData.city; }; + if (locationData.state) { if ( '' != dir_address2 ) { dir_address2 += ' '; } dir_address2 += locationData.state; }; + if (locationData.zip) { if ( '' != dir_address2 ) { dir_address2 += ' '; } dir_address2 += locationData.zip; }; + if (locationData.country) { if ( '' != dir_address2 ) { dir_address2 += ' '; } dir_address2 += locationData.country; }; + + if ( '' != dir_address2 ) { dir_address = locationData.point.toUrlValue(10) + '(' + escape( dir_address2 ) + ')'; }; + + html += ' '; + + if (locationData.description != '' && locationData.description != null) { + var numlines = Math.ceil(locationData.description.length / 40); + var newlines = locationData.description.split('
    ').length - 1; + var totalheight2 = 0; + + if ( locationData.description.indexOf(' maxbubbleheight) { + totalheight2 = maxbubbleheight; + } + + //marker.openInfoWindowTabsHtml([new GInfoWindowTab(location_tab_text, html), new GInfoWindowTab(description_tab_text, html2)], {maxWidth: maxbubblewidth}); + // tabs aren't possible with the Google Maps api v3 + html += '

    ' + locationData.description + '

    '; + } + + html += '
    '; + + google.maps.event.addListener(marker, 'click', function() { + clearInfoWindows(); + var infowidth = 0; + if ( maxbubblewidth <= 100 ) { + infowidth = document.getElementById("simplemap"); + if ( typeof infowidth != 'undefined' ) { + infowidth = infowidth.offsetWidth; + } else { + infowidth = 400; + } + infowidth = infowidth * (maxbubblewidth / 100.0); + } + if ( infowidth < maxbubblewidth ) infowidth = maxbubblewidth; + infowidth = parseInt(infowidth) + 'px'; + var infowindow = new google.maps.InfoWindow({ + maxWidth: infowidth, + content: html + }); + infowindow.open(map, marker); + infowindowsArray.push(infowindow); + window.location = '#map_top'; + }); + + return marker; + } + + function createSidebarEntry(marker, locationData, searchData) { + var div = document.createElement('div'); + + // Beginning of result + var html = '
    '; + + // Flagged special + if (locationData.special == 1 && special_text != '') { + html += '
    ' + special_text + '
    '; + } + + // Name & distance + html += '
    '; + html += '

    '; + if (locationData.permalink != null && locationData.permalink != '') { + html += ''; + } + html += locationData.name; + if (locationData.permalink != null && locationData.permalink != '') { + html += ''; + } + + if (locationData.distance.toFixed(1) != 'NaN') { + if (units == 'mi') { + html+= ' ' + locationData.distance.toFixed(1) + ' miles'; + } + else if (units == 'km') { + html+= ' ' + (locationData.distance * 1.609344).toFixed(1) + ' km'; + } + } + html += '

    '; + + // Address + html += '
    ' + locationData.address; + if (locationData.address2 != '') { + html += '
    ' + locationData.address2; + } + + if (address_format == 'town, province postalcode') { + html += '
    ' + locationData.city + ', ' + locationData.state + ' ' + locationData.zip + '
    '; + } + else if (address_format == 'town province postalcode') { + html += '
    ' + locationData.city + ' ' + locationData.state + ' ' + locationData.zip + '
    '; + } + else if (address_format == 'town-province postalcode') { + html += '
    ' + locationData.city + '-' + locationData.state + ' ' + locationData.zip + '
'; + } + else if (address_format == 'postalcode town-province') { + html += '
' + locationData.zip + ' ' + locationData.city + '-' + locationData.state + '
'; + } + else if (address_format == 'postalcode town, province') { + html += '
' + locationData.zip + ' ' + locationData.city + ', ' + locationData.state + '
'; + } + else if (address_format == 'postalcode town') { + html += '
' + locationData.zip + ' ' + locationData.city + '
'; + } + else if (address_format == 'town postalcode') { + html += '
' + locationData.city + ' ' + locationData.zip + ''; + } + + // Phone, email, and fax numbers + html += '
'; + if (locationData.phone != null && locationData.phone != '') { + html += phone_text + ': ' + locationData.phone; + } + if (locationData.email != null && locationData.email != '') { + html += '
' + email_text + ': ' + locationData.email + '
'; + } + if (locationData.fax != null && locationData.fax != '') { + html += '
' + fax_text + ': ' + locationData.fax + '
'; + } + html += '
'; + + // Links section + html += ''; + html += '
'; + + + html += '
'; + html += locationData.description; + html += '
'; + html += '
'; + + + // Taxonomy lists + for (jstax in locationData.taxes) { + if ( locationData.taxes[jstax] != null && locationData.taxes[jstax] != '' ) { + html += '
' + taxonomy_text[jstax] + ': ' + locationData.taxes[jstax] + '
'; + } + } + + // End of result + html += ''; + + div.innerHTML = html; + div.style.cursor = 'pointer'; + div.style.margin = 0; + google.maps.event.addDomListener(div, 'click', function() { + google.maps.event.trigger(marker, 'click'); + }); + return div; + } + get_options(); + // Create URL encoded comma separated list of address elements that != '' + $to_geocode = urlencode( implode( ', ', array_filter( compact( 'address', 'city', 'state', 'zip', 'country' ) ) ) ); + + // Base URL + $base_url = SIMPLEMAP_MAPS_WS_API . 'geocode/json?sensor=false®ion=' . substr( $options['default_domain'], strrpos( $options['default_domain'], '.' ) + 1 ); + + // Add query + $request_url = $base_url . "&address=" . $to_geocode; + + $response = wp_remote_get( $request_url ); + + // TODO: Handle this situation better + if ( ! is_wp_error( $response ) ) { + $body = json_decode( $response['body'] ); + $status = $body->status; + + if ( $status == 'OK' ) { + // Successful geocode + //echo "
";print_r( $body );die();
+					$location = $body->results[0]->geometry->location;
+
+					// Format: Longitude, Latitude, Altitude
+					$lat = $location->lat;
+					$lng = $location->lng;
+				}
+
+				return compact( 'body', 'status', 'lat', 'lng' );
+			} else {
+				return false;
+			}
+		}
+
+		// Returns list of SimpleMap Taxonomies
+		function get_sm_taxonomies( $format='array', $prefix='', $php_safe=false, $output='names' ) {
+
+			$taxes = array();
+
+			if ( $taxes = get_object_taxonomies( 'sm-location', $output ) ) {
+
+				foreach( $taxes as $key => $tax ) {
+
+					// Convert to PHP safe and add prefix
+					if ( $php_safe && 'names' == $output )
+						$taxes[$key] = str_replace( '-', '_', $prefix.$tax );
+					elseif ( $php_safe )
+						$taxes[$key]->name = str_replace( '-', '_', $prefix.$tax->name );
+
+				}
+
+			}
+
+			// Convert to string if needed
+			if ( 'string' == $format )
+				$taxes = implode( ', ', $taxes );
+
+			return $taxes;
+
+		}
+
+		function get_taxonomy_settings( $taxonomy = null ) {
+			$standard_taxonomies = array(
+				'sm-category' => array( 'singular' => 'Category', 'plural' => 'Categories', 'hierarchical' => true, 'field' => 'category' ),
+				'sm-tag' => array( 'singular' => 'Tag', 'plural' => 'Tags', 'field' => 'tags' ),
+				'sm-day' => array( 'singular' => 'Day', 'plural' => 'Days', 'field' => 'days', 'description' => 'day of week' ),
+				'sm-time' => array( 'singular' => 'Time', 'plural' => 'Times', 'field' => 'times', 'description' => 'time of day' ),
+			);
+
+			if ( empty( $taxonomy ) ) {
+				return $standard_taxonomies;
+			}
+
+			if ( isset( $standard_taxonomies[$taxonomy] ) ) {
+				return $standard_taxonomies[$taxonomy];
+			}
+			else {
+				$singular = ucwords( substr( $taxonomy, strpos( $taxonomy, '-' ) + 1 ) );
+				return array( 'singular' => $singular, 'plural' => $singular . 's' );
+			}
+		}
+
+		// This function returns the default SimpleMap options		
+		function get_options() {
+			$options = array();
+			$saved = get_option( 'SimpleMap_options' );
+
+			if ( !empty( $saved ) ) {
+				$options = $saved;
+			}
+
+			static $default = null;
+			if ( empty( $default ) ) {
+				$default = array(
+					'map_width' => '100%',
+					'map_height' => '350px',
+					'default_lat' => '44.968684',
+					'default_lng' => '-93.215561',
+					'zoom_level' => '10',
+					'default_radius' => '10',
+					'map_type' => 'ROADMAP',
+					'special_text' => '',
+					'default_state' => '',
+					'default_country' => 'US',
+					'default_language' => 'en',
+					'default_domain' => '.com',
+					'map_stylesheet' => 'inc/styles/light.css',
+					'units' => 'mi',
+					'autoload' => 'all',
+					'lock_default_location' => false,
+					'results_limit' => '20',
+					'address_format' => 'town, province postalcode',
+					'powered_by' => 0,
+					'enable_permalinks' => 0,
+					'permalink_slug' => 'location',
+					'display_search' => 'show',
+					'map_pages' => '0',
+					'adsense_for_maps' => 0,
+					'adsense_pub_id' => '',
+					'adsense_channel_id' => '',
+					'adsense_max_ads' => 2,
+					//'api_key' => '',
+					'auto_locate' => '',
+					'taxonomies' => array(
+						'sm-category' => $this->get_taxonomy_settings( 'sm-category' ),
+						'sm-tag' => $this->get_taxonomy_settings( 'sm-tag' ),
+					),
+				);
+
+				$valid_map_type_map = array(
+					'ROADMAP' => 'ROADMAP',
+					'SATELLITE' => 'SATELLITE',
+					'HYBRID' => 'HYBRID',
+					'TERRAIN' => 'TERRAIN',
+					'G_NORMAL_MAP' => 'ROADMAP',
+					'G_SATELLITE_MAP' => 'SATELLITE',
+					'G_HYBRID_MAP' => 'HYBRID',
+					'G_PHYSICAL_MAP' => 'TERRAIN',
+				);
+
+				if ( empty( $valid_map_type_map[$options['map_type']] ) ) {
+					$options['map_type'] = $default['map_type'];
+				}
+				else {
+					$options['map_type'] = $valid_map_type_map[$options['map_type']];
+				}
+			}
+
+			$options += $default;
+
+			if ( isset( $options['days_taxonomy'] ) ) {
+				if ( ! empty( $options['days_taxonomy'] ) ) {
+					$options['taxonomies']['sm-day'] = $this->get_taxonomy_settings( 'sm-day' );
+				}
+				unset( $options['days_taxonomy'] );
+			}
+
+			if ( isset( $options['time_taxonomy'] ) ) {
+				if ( ! empty( $options['time_taxonomy'] ) ) {
+					$options['taxonomies']['sm-time'] = $this->get_taxonomy_settings( 'sm-time' );
+				}
+				unset( $options['time_taxonomy'] );
+			}
+
+			if ( $saved != $options ) {
+				update_option( 'SimpleMap_options', $options );
+			}
+			return $options;
+		}
+		
+		// Google Domains
+		function get_domain_options() {
+			$domains_list = array(
+				'United States' => '.com',
+				'Austria' => '.at',
+				'Australia' => '.com.au',
+				'Bosnia and Herzegovina' => '.com.ba',
+				'Belgium' => '.be',
+				'Brazil' => '.com.br',
+				'Canada' => '.ca',
+				'Switzerland' => '.ch',
+				'Czech Republic' => '.cz',
+				'Germany' => '.de',
+				'Denmark' => '.dk',
+				'Spain' => '.es',
+				'Finland' => '.fi',
+				'France' => '.fr',
+				'Italy' => '.it',
+				'Japan' => '.jp',
+				'Netherlands' => '.nl',
+				'Norway' => '.no',
+				'New Zealand' => '.co.nz',
+				'Poland' => '.pl',
+				'Russia' => '.ru',
+				'Sweden' => '.se',
+				'Taiwan' => '.tw',
+				'United Kingdom' => '.co.uk',
+				'South Africa' => '.co.za'
+			);
+			
+			return apply_filters( 'sm-domain-list', $domains_list );
+		}
+
+		// Region list from http://code.google.com/apis/adwords/docs/appendix/provincecodes.html
+		// Used for Maps v3 localization: http://code.google.com/apis/maps/documentation/javascript/basics.html#Localization
+		function get_region_options() {
+			$region_list = array(
+				'US' => 'United States',
+				'AR' => 'Argentina',
+				'AU' => 'Australia',
+				'AT' => 'Austria',
+				'BE' => 'Belgium',
+				'BR' => 'Brazil',
+				'CA' => 'Canada',
+				'CL' => 'Chile',
+				'CN' => 'China',
+				'CO' => 'Colombia',
+				'HR' => 'Croatia',
+				'CZ' => 'Czech Republic',
+				'DK' => 'Denmark',
+				'EG' => 'Egypt',
+				'FI' => 'Finland',
+				'FR' => 'France',
+				'DE' => 'Germany',
+				'HU' => 'Hungary',
+				'IN' => 'India',
+				'IE' => 'Ireland',
+				'IL' => 'Israel',
+				'IT' => 'Italy',
+				'JP' => 'Japan',
+				'MY' => 'Malaysia',
+				'MX' => 'Mexico',
+				'MA' => 'Morocco',
+				'NL' => 'Netherlands',
+				'NZ' => 'New Zealand',
+				'NG' => 'Nigeria',
+				'NO' => 'Norway',
+				'PL' => 'Poland',
+				'PT' => 'Portugal',
+				'RU' => 'Russian Federation',
+				'SA' => 'Saudi Arabia',
+				'ZA' => 'South Africa',
+				'KR' => 'South Korea',
+				'ES' => 'Spain',
+				'SE' => 'Sweden',
+				'CH' => 'Switzerland',
+				'TH' => 'Thailand',
+				'TR' => 'Turkey',
+				'UA' => 'Ukraine',
+				'GB' => 'United Kingdom',
+			);
+
+			return apply_filters( 'sm-region-list', $region_list );
+		}
+
+		// Country list
+		function get_country_options() {
+			$country_list = array(
+				'US' => 'United States',
+				'AF' => 'Afghanistan',
+				'AL' => 'Albania',
+				'DZ' => 'Algeria',
+				'AS' => 'American Samoa',
+				'AD' => 'Andorra',
+				'AO' => 'Angola',
+				'AI' => 'Anguilla',
+				'AQ' => 'Antarctica',
+				'AG' => 'Antigua and Barbuda',
+				'AR' => 'Argentina',
+				'AM' => 'Armenia',
+				'AW' => 'Aruba',
+				'AU' => 'Australia',
+				'AT' => 'Austria',
+				'AZ' => 'Azerbaijan',
+				'BS' => 'Bahamas',
+				'BH' => 'Bahrain',
+				'BD' => 'Bangladesh',
+				'BB' => 'Barbados',
+				'BY' => 'Belarus',
+				'BE' => 'Belgium',
+				'BZ' => 'Belize',
+				'BJ' => 'Benin',
+				'BM' => 'Bermuda',
+				'BT' => 'Bhutan',
+				'BO' => 'Bolivia',
+				'BA' => 'Bosnia and Herzegowina',
+				'BW' => 'Botswana',
+				'BV' => 'Bouvet Island',
+				'BR' => 'Brazil',
+				'IO' => 'British Indian Ocean Territory',
+				'BN' => 'Brunei Darussalam',
+				'BG' => 'Bulgaria',
+				'BF' => 'Burkina Faso',
+				'BI' => 'Burundi',
+				'KH' => 'Cambodia',
+				'CM' => 'Cameroon',
+				'CA' => 'Canada',
+				'CV' => 'Cape Verde',
+				'KY' => 'Cayman Islands',
+				'CF' => 'Central African Republic',
+				'TD' => 'Chad',
+				'CL' => 'Chile',
+				'CN' => 'China',
+				'CX' => 'Christmas Island',
+				'CC' => 'Cocos (Keeling) Islands',
+				'CO' => 'Colombia',
+				'KM' => 'Comoros',
+				'CG' => 'Congo',
+				'CD' => 'Congo, The Democratic Republic of the',
+				'CK' => 'Cook Islands',
+				'CR' => 'Costa Rica',
+				'CI' => 'Cote D\'Ivoire',
+				'HR' => 'Croatia (Local Name: Hrvatska)',
+				'CU' => 'Cuba',
+				'CY' => 'Cyprus',
+				'CZ' => 'Czech Republic',
+				'DK' => 'Denmark',
+				'DJ' => 'Djibouti',
+				'DM' => 'Dominica',
+				'DO' => 'Dominican Republic',
+				'TP' => 'East Timor',
+				'EC' => 'Ecuador',
+				'EG' => 'Egypt',
+				'SV' => 'El Salvador',
+				'GQ' => 'Equatorial Guinea',
+				'ER' => 'Eritrea',
+				'EE' => 'Estonia',
+				'ET' => 'Ethiopia',
+				'FK' => 'Falkland Islands (Malvinas)',
+				'FO' => 'Faroe Islands',
+				'FJ' => 'Fiji',
+				'FI' => 'Finland',
+				'FR' => 'France',
+				'FX' => 'France, Metropolitan',
+				'GF' => 'French Guiana',
+				'PF' => 'French Polynesia',
+				'TF' => 'French Southern Territories',
+				'GA' => 'Gabon',
+				'GM' => 'Gambia',
+				'GE' => 'Georgia',
+				'DE' => 'Germany',
+				'GH' => 'Ghana',
+				'GI' => 'Gibraltar',
+				'GR' => 'Greece',
+				'GL' => 'Greenland',
+				'GD' => 'Grenada',
+				'GP' => 'Guadeloupe',
+				'GU' => 'Guam',
+				'GT' => 'Guatemala',
+				'GN' => 'Guinea',
+				'GW' => 'Guinea-Bissau',
+				'GY' => 'Guyana',
+				'HT' => 'Haiti',
+				'HM' => 'Heard and Mc Donald Islands',
+				'VA' => 'Holy See (Vatican City State)',
+				'HN' => 'Honduras',
+				'HK' => 'Hong Kong',
+				'HU' => 'Hungary',
+				'IS' => 'Iceland',
+				'IN' => 'India',
+				'ID' => 'Indonesia',
+				'IR' => 'Iran (Islamic Republic of)',
+				'IQ' => 'Iraq',
+				'IE' => 'Ireland',
+				'IL' => 'Israel',
+				'IT' => 'Italy',
+				'JM' => 'Jamaica',
+				'JP' => 'Japan',
+				'JO' => 'Jordan',
+				'KZ' => 'Kazakhstan',
+				'KE' => 'Kenya',
+				'KI' => 'Kiribati',
+				'KP' => 'Korea, Democratic People\'s Republic of',
+				'KR' => 'Korea, Republic of',
+				'KW' => 'Kuwait',
+				'KG' => 'Kyrgyzstan',
+				'LA' => 'Lao People\'s Democratic Republic',
+				'LV' => 'Latvia',
+				'LB' => 'Lebanon',
+				'LS' => 'Lesotho',
+				'LR' => 'Liberia',
+				'LY' => 'Libyan Arab Jamahiriya',
+				'LI' => 'Liechtenstein',
+				'LT' => 'Lithuania',
+				'LU' => 'Luxembourg',
+				'MO' => 'Macau',
+				'MK' => 'Macedonia, Former Yugoslav Republic of',
+				'MG' => 'Madagascar',
+				'MW' => 'Malawi',
+				'MY' => 'Malaysia',
+				'MV' => 'Maldives',
+				'ML' => 'Mali',
+				'MT' => 'Malta',
+				'MH' => 'Marshall Islands',
+				'MQ' => 'Martinique',
+				'MR' => 'Mauritania',
+				'MU' => 'Mauritius',
+				'YT' => 'Mayotte',
+				'MX' => 'Mexico',
+				'FM' => 'Micronesia, Federated States of',
+				'MD' => 'Moldova, Republic of',
+				'MC' => 'Monaco',
+				'MN' => 'Mongolia',
+				'MS' => 'Montserrat',
+				'MA' => 'Morocco',
+				'MZ' => 'Mozambique',
+				'MM' => 'Myanmar',
+				'NA' => 'Namibia',
+				'NR' => 'Nauru',
+				'NP' => 'Nepal',
+				'NL' => 'Netherlands',
+				'AN' => 'Netherlands Antilles',
+				'NC' => 'New Caledonia',
+				'NZ' => 'New Zealand',
+				'NI' => 'Nicaragua',
+				'NE' => 'Niger',
+				'NG' => 'Nigeria',
+				'NU' => 'Niue',
+				'NF' => 'Norfolk Island',
+				'MP' => 'Northern Mariana Islands',
+				'NO' => 'Norway',
+				'OM' => 'Oman',
+				'PK' => 'Pakistan',
+				'PW' => 'Palau',
+				'PA' => 'Panama',
+				'PG' => 'Papua New Guinea',
+				'PY' => 'Paraguay',
+				'PE' => 'Peru',
+				'PH' => 'Philippines',
+				'PN' => 'Pitcairn',
+				'PL' => 'Poland',
+				'PT' => 'Portugal',
+				'PR' => 'Puerto Rico',
+				'QA' => 'Qatar',
+				'RE' => 'Reunion',
+				'RO' => 'Romania',
+				'RU' => 'Russian Federation',
+				'RW' => 'Rwanda',
+				'KN' => 'Saint Kitts and Nevis',
+				'LC' => 'Saint Lucia',
+				'VC' => 'Saint Vincent and The Grenadines',
+				'WS' => 'Samoa',
+				'SM' => 'San Marino',
+				'ST' => 'Sao Tome And Principe',
+				'SA' => 'Saudi Arabia',
+				'SN' => 'Senegal',
+				'SC' => 'Seychelles',
+				'SL' => 'Sierra Leone',
+				'SG' => 'Singapore',
+				'SK' => 'Slovakia (Slovak Republic)',
+				'SI' => 'Slovenia',
+				'SB' => 'Solomon Islands',
+				'SO' => 'Somalia',
+				'ZA' => 'South Africa',
+				'GS' => 'South Georgia, South Sandwich Islands',
+				'ES' => 'Spain',
+				'LK' => 'Sri Lanka',
+				'SH' => 'St. Helena',
+				'PM' => 'St. Pierre and Miquelon',
+				'SD' => 'Sudan',
+				'SR' => 'Suriname',
+				'SJ' => 'Svalbard and Jan Mayen Islands',
+				'SZ' => 'Swaziland',
+				'SE' => 'Sweden',
+				'CH' => 'Switzerland',
+				'SY' => 'Syrian Arab Republic',
+				'TW' => 'Taiwan',
+				'TJ' => 'Tajikistan',
+				'TZ' => 'Tanzania, United Republic of',
+				'TH' => 'Thailand',
+				'TG' => 'Togo',
+				'TK' => 'Tokelau',
+				'TO' => 'Tonga',
+				'TT' => 'Trinidad and Tobago',
+				'TN' => 'Tunisia',
+				'TR' => 'Turkey',
+				'TM' => 'Turkmenistan',
+				'TC' => 'Turks and Caicos Islands',
+				'TV' => 'Tuvalu',
+				'UG' => 'Uganda',
+				'UA' => 'Ukraine',
+				'AE' => 'United Arab Emirates',
+				'GB' => 'United Kingdom',
+				'UM' => 'United States Minor Outlying Islands',
+				'UY' => 'Uruguay',
+				'UZ' => 'Uzbekistan',
+				'VU' => 'Vanuatu',
+				'VE' => 'Venezuela',
+				'VN' => 'Vietnam',
+				'VG' => 'Virgin Islands (British)',
+				'VI' => 'Virgin Islands (U.S.)',
+				'WF' => 'Wallis and Futuna Islands',
+				'EH' => 'Western Sahara',
+				'YE' => 'Yemen',
+				'YU' => 'Yugoslavia',
+				'ZM' => 'Zambia',
+				'ZW' => 'Zimbabwe'
+			);
+
+			return apply_filters( 'sm-country-list', $country_list );
+		}
+
+		// Region list from http://code.google.com/apis/maps/faq.html#languagesupport
+		// Used for Maps v3 localization: http://code.google.com/apis/maps/documentation/javascript/basics.html#Localization
+		function get_language_options() {
+			$language_list = array(
+				'ar' => 'Arabic',
+				'eu' => 'Basque',
+				'bg' => 'Bulgarian',
+				'bn' => 'Bengali',
+				'ca' => 'Catalan',
+				'cs' => 'Czech',
+				'da' => 'Danish',
+				'de' => 'German',
+				'el' => 'Greek',
+				'en' => 'English',
+				'en-AU' => 'English (Australian)',
+				'en-GB' => 'English (Great Britain)',
+				'es' => 'Spanish',
+				'eu' => 'Basque',
+				'fa' => 'Farsi',
+				'fi' => 'Finnish',
+				'fil' => 'Filipino',
+				'fr' => 'French',
+				'gl' => 'Galician',
+				'gu' => 'Gujarati',
+				'hi' => 'Hindi',
+				'hr' => 'Croatian',
+				'hu' => 'Hungarian',
+				'id' => 'Indonesian',
+				'it' => 'Italian',
+				'iw' => 'Hebrew',
+				'ja' => 'Japanese',
+				'kn' => 'Kannada',
+				'ko' => 'Korean',
+				'lt' => 'Lithuanian',
+				'lv' => 'Latvian',
+				'ml' => 'Malayalam',
+				'mr' => 'Marathi',
+				'nl' => 'Dutch',
+				'no' => 'Norwegian',
+				'pl' => 'Polish',
+				'pt' => 'Portuguese',
+				'pt-BR' => 'Portuguese (Brazil)',
+				'pt-PT' => 'Portuguese (Portugal)',
+				'ro' => 'Romanian',
+				'ru' => 'Russian',
+				'sk' => 'Slovak',
+				'sl' => 'Slovenian',
+				'sr' => 'Serbian',
+				'sv' => 'Swedish',
+				'tl' => 'Tagalog',
+				'ta' => 'Tamil',
+				'te' => 'Telugu',
+				'th' => 'Thai',
+				'tr' => 'Turkish',
+				'uk' => 'Ukrainian',
+				'vi' => 'Vietnamese',
+				'zh-CN' => 'Chinese (Simplified)',
+				'zh-TW' => 'Chinese (Traditional)',
+			);
+
+			return apply_filters( 'sm-language-list', $language_list );
+		}
+
+		function get_auto_locate_options() {
+			$auto_locate_list = array(
+				'' => 'No Automatic Location',
+				'ip' => 'Use IP Address',
+				'html5' => 'Use HTML5',
+			);
+
+			return apply_filters( 'sm-auto-locte-list', $auto_locate_list );
+		}
+
+		// Echo the toolbar
+		function show_toolbar( $title = '' ) {
+			global $simple_map;
+			$options = $simple_map->get_options();
+			if ( '' == $title )
+				$title = 'SimpleMap';
+			?>
+			
+				
+					
+					
+					
+					
+				
+			
+

+
+ + + + +
+ + + + +
+
+ +

' . __( 'You must enter an API key for your domain.', 'SimpleMap' ).' ' . __( 'Enter a key on the General Options page.', 'SimpleMap' ) . '

'; + */ + } + + // Return the available search_radii + function get_search_radii(){ + $search_radii = array( 1, 5, 10, 25, 50, 100, 500, 1000 ); + return apply_filters( 'sm-search-radii', $search_radii ); + } + + // What link are we using for google's API + function get_api_link() { + $lo = str_replace('_', '-', get_locale()); + $l = substr($lo, 0, 2); + switch($l) { + case 'es': + case 'de': + case 'ja': + case 'ko': + case 'ru': + $api_link = "http://code.google.com/intl/$l/apis/maps/signup.html"; + break; + case 'pt': + case 'zh': + $api_link = "http://code.google.com/intl/$lo/apis/maps/signup.html"; + break; + case 'en': + default: + $api_link = "http://code.google.com/apis/maps/signup.html"; + break; + } + return $api_link; + } + + // Returns true if legacy tables exist in the DB + function legacy_tables_exist() { + global $wpdb; + + $sql = "SHOW TABLES LIKE '" . $wpdb->prefix . "simple_map'"; + if ( $tables = $wpdb->get_results( $sql ) ) { + return true; + } + + return false; + } + + // Search form / widget query vars + function register_query_vars( $vars ) { + + $vars[] = 'location_search_address'; + $vars[] = 'location_search_city'; + $vars[] = 'location_search_state'; + $vars[] = 'location_search_zip'; + $vars[] = 'location_search_distance'; + $vars[] = 'location_search_limit'; + $vars[] = 'location_is_search_results'; + + return $vars; + } + + /** + * Parses the shortcode attributes with the default options and returns array + * + * @since 2.3 + */ + function parse_shortcode_atts( $shortcode_atts ) { + $options = $this->get_options(); + $default_atts = $this->get_default_shortcode_atts(); + $atts = shortcode_atts( $default_atts, $shortcode_atts ); + + // If deprecated shortcodes were used, replace with current ones + if ( isset( $atts['show_categories_filter'] ) ) + $atts['show_sm_category_filter'] = $atts['show_categories_filter']; + if ( isset( $atts['show_tags_filter'] ) ) + $atts['show_sm_tag_filter'] = $atts['show_tags_filter']; + if ( isset( $atts['show_days_filter'] ) ) + $atts['show_sm_day_filter'] = $atts['show_days_filter']; + if ( isset( $atts['show_times_filter'] ) ) + $atts['show_sm_time_filter'] = $atts['show_times_filter']; + if ( isset( $atts['categories'] ) ) + $atts['sm_category'] = $atts['categories']; + if ( isset( $atts['tags'] ) ) + $atts['sm_tag'] = $atts['tags']; + if ( isset( $atts['days'] ) ) + $atts['sm_day'] = $atts['days']; + if ( isset( $atts['times'] ) ) + $atts['sm_time'] = $atts['times']; + + // Determine if we need to hide the search form or not + if ( '' == $atts['hide_search'] ) { + // Use default value + if ( 'show' == $options['display_search'] ) + $atts['hide_search'] = 0; + else + $atts['hide_search'] = 1; + } + + // Set categories and tags to available equivelants + $atts['avail_sm_category'] = $atts['sm_category']; + $atts['avail_sm_tag'] = $atts['sm_tag']; + $atts['avail_sm_day'] = $atts['sm_day']; + $atts['avail_sm_time'] = $atts['sm_time']; + + // Default lat / lng from shortcode? + if ( ! $atts['default_lat'] ) + $atts['default_lat'] = $options['default_lat']; + if ( ! $atts['default_lng'] ) + $atts['default_lng'] = $options['default_lng']; + + // Doing powered by? + if ( '' == $atts['powered_by'] ) { + + // Use default value + $atts['powered_by'] = $options['powered_by']; + + } else { + + // Use shortcode + if ( 0 == $atts['powered_by'] ) + $atts['powered_by'] = 0; + else + $atts['powered_by'] = 1; + + } + + // Default units or shortcode units? + if ( 'km' != $atts['units'] && 'mi' != $atts['units'] ) + $atts['units'] = $options['units']; + + // Default radius or shortcode radius? + if ( '' != $atts['radius'] && in_array( $atts['radius'], $this->get_search_radii() ) ) + $atts['radius'] = absint( $atts['radius'] ); + else + $atts['radius'] = $options['default_radius']; + + //Make sure we have limit + if ( '' == $atts['limit'] ) + $atts['limit'] = $options['results_limit']; + + // Clean search_field_cols + if ( 0 === absint( $atts['search_form_cols'] ) ) + $atts['search_form_cols'] = $default_atts['search_form_cols']; + + // Which type of map are we using? + if ( '' == $atts['map_type'] ) + $atts['map_type'] = $options['map_type']; + + // Height of the map? + if ( '' == $atts['map_height'] ) + $atts['map_height'] = $options['map_height']; + + // Width of the map? + if ( '' == $atts['map_width'] ) + $atts['map_width'] = $options['map_width']; + + // Which zoom level are we using? + if ( '' == $atts['zoom_level'] ) + $atts['zoom_level'] = $options['zoom_level']; + + // Which autoload option are we using? + if ( '' == $atts['autoload'] ) + $atts['autoload'] = $options['autoload']; + + // Return final array + return $atts; + } + + /** + * Returns default shortcode attributes + * + * @since 2.3 + */ + function get_default_shortcode_atts() { + $options = $this->get_options(); + + $tax_atts = array(); + $tax_search_fields = array(); + foreach ( $options['taxonomies'] as $taxonomy => $taxonomy_info ) { + $tax_search_fields[] = "||labeltd_$taxonomy||empty"; + + $safe_tax = str_replace('-', '_', $taxonomy); + $tax_atts[$safe_tax] = ''; + $tax_atts['show_' . $safe_tax . '_filter'] = 1; + + // The following are deprecated. Don't use them. + $tax_atts[strtolower($taxonomy_info['plural'])] = null; + $tax_atts['show_' . strtolower($taxonomy_info['plural']) . '_filter'] = null; + } + + $atts = $tax_atts + array( + 'search_title' => __( 'Find Locations Near:', 'SimpleMap' ), + 'search_form_type' => 'table', + 'search_form_cols' => 3, + 'search_fields' => 'labelbr_street||labelbr_city||labelbr_state||labelbr_zip||empty||empty||labeltd_distance||empty' . implode('', $tax_search_fields) . '||submit||empty||empty', + 'taxonomy_field_type' => 'checkboxes', + 'hide_search' => '', + 'hide_map' => 0, + 'hide_list' => 0, + 'default_lat' => 0, + 'default_lng' => 0, + 'adsense_publisher_id' => 0, + 'adsense_channel_id' => 0, + 'adsense_max_ads' => 0, + 'map_width' => '', + 'map_height' => '', + 'units' => '', + 'radius' => '', + 'limit' => '', + 'autoload' => '', + 'zoom_level' => '', + 'map_type' => '', + 'powered_by' => '', + 'sm_day' => '', + 'sm_time' => '' + ); + + return apply_filters( 'sm-default-shortcode-atts', $atts ); + } + + // This function filters category text labels + function backwards_compat_categories_text( $text ) { + return __( 'Categories', 'SimpleMap' ); + } + + // This function filters category text labels + function backwards_compat_tags_text( $text ) { + return __( 'Tags', 'SimpleMap' ); + } + + // This function filters category text labels + function backwards_compat_days_text( $text ) { + return __( 'Days', 'SimpleMap' ); + } + + // This function filters category text labels + function backwards_compat_times_text( $text ) { + return __( 'Times', 'SimpleMap' ); + } + + } +} diff --git a/classes/templates.php b/classes/templates.php new file mode 100644 index 0000000..fc7348c --- /dev/null +++ b/classes/templates.php @@ -0,0 +1,151 @@ +template_type = $this->set_template_type(); + + // Set the specific template for this view + $this->set_active_template(); + + // Add the filter + add_filter( 'the_content', array( &$this, 'apply_template' ), 1 ); + + } + + /** + * Parses wp_query to determine the template type we are going to use + * As of 2.4, the only opiton is single-location + * + * @since 2.4 + */ + function set_template_type() { + + global $post; + + // Exit if we're not on a single disply of the location post type + if ( 'sm-location' != $post->post_type || ! is_single() ) + return false; + + return 'single-location'; + } + + /** + * Sets the template we will use for the current view based on a cascading set of rules + * If this is a single location view, do the following: + *
    + *
  • Check for specific template via post-meta + *
  • Check for default template
  • + *
+ * + * @since 2.4 + */ + function set_active_template() { + + global $post; + + // Switch based on template type + switch ( $this->template_type ) { + case 'single-location' : + default : + // Grab the ID for the specific template for this post if it is present + $template_id = ( get_post_meta( $post->ID, 'sm-location-template', false ) ) ? get_post_meta( $post->ID, 'sm-location-template', false ) : 0; + break; + } + + $this->template_id = $template_id; + $this->template_structure = $this->get_template_structure(); + } + + /** + * Returns the actual template structure we're going to use for this object + * + * @since 2.4 + */ + function get_template_structure() { + + // Grab the post that contains the template strucutre or the hard_coded structure + if ( 0 != $this->template_id ) { + // get post obejct via ID + // return post_content + } else { + $return = "
"; + $return .= "
[sm-location data='iframe-map' map_width='100px' map_height='100px']
"; + $return .= "
[sm-location data='full-address']"; + $return .= "
Get Directions"; + $return .= "
    [sm-location data='phone' before='
  • ' after='
  • '] [sm-location data='email' before='
  • ' after='
  • '] [sm-location data='sm_category' format='csv' before='
  • Categories: ' after='
  • '] [sm-location data='sm_tag' format='csv' before='
  • Tags: ' after='
  • ']
"; + $return .= "
"; + $return .= "
"; + $return .= "
"; + $return .= "[sm-location data='description']"; + return apply_filters( 'sm-single-location-default-template', $return ); + + } + + return $return; + } + + /** + * This method applies the template to the content + * + * @since 2.4 + */ + function apply_template( $content ) { + + // Return content untouched if not location data + if ( ! $this->template_type || ! $this->template_structure ) + return $content; + + // Return if not in the loop + if ( ! in_the_loop() ) + return $content; + + // Save the location 'description' + $location_description = $content; + + // Send it through the shortcode parser + $content = do_shortcode( $this->template_structure ); + + return $content; + + } + + } + +} diff --git a/classes/widgets.php b/classes/widgets.php new file mode 100644 index 0000000..fd3dcbd --- /dev/null +++ b/classes/widgets.php @@ -0,0 +1,256 @@ + 'sm_search_widget', 'description' => __( "Adds a customizable search widget to your site" ) ); + $this->WP_Widget('sm_search_widget', __('SimpleMap Search'), $widget_ops); + } + + function widget( $args, $instance ) { + global $simple_map, $wp_rewrite; + + extract( $args ); + + $options = $simple_map->get_options(); + + $title = apply_filters( 'widget_title', empty( $instance['title'] ) ? '' : $instance['title'] ); + + // Search Form Options + $show_address = $instance['show_address'] ? 1 : 0; + $show_city = $instance['show_city'] ? 1 : 0; + $show_state = $instance['show_state'] ? 1 : 0; + $show_zip = $instance['show_zip'] ? 1 : 0; + $show_distance = $instance['show_distance'] ? 1 : 0; + + $default_lat = $instance['default_lat'] ? $instance['default_lat'] : 0; + $default_lng = $instance['default_lng'] ? $instance['default_lng'] : 0; + $simplemap_page = $instance['simplemap_page'] ? $instance['simplemap_page'] : 2; + + // Set taxonomies to available equivalents + $show = array(); + $terms = array(); + foreach ( $options['taxonomies'] as $taxonomy => $tax_info ) { + $key = strtolower( $tax_info['plural'] ); + $show[$taxonomy] = $instance['show_' . $key] ? 1 : 0; + $terms[$taxonomy] = $instance[$key] ? $instance[$key] : ''; + } + + $available = $terms; + + echo $before_widget; + if ( $title ) + echo '' . $before_title . $title . $after_title . ''; + + // Form Field Values + $address_value = isset( $_REQUEST['location_search_address'] ) ? $_REQUEST['location_search_address'] : ''; + $city_value = isset( $_REQUEST['location_search_city'] ) ? $_REQUEST['location_search_city'] : ''; + $state_value = isset( $_REQUEST['location_search_state'] ) ? $_REQUEST['location_search_state'] : ''; + $zip_value = isset( $_REQUEST['location_search_zip'] ) ? $_REQUEST['location_search_zip'] : ''; + $radius_value = isset( $_REQUEST['location_search_distance'] ) ? $_REQUEST['location_search_distance'] : $options['default_radius']; + $limit_value = isset( $_REQUEST['location_search_limit'] ) ? $_REQUEST['location_search_limit'] : $options['results_limit']; + + // Set action based on permalink structure + if ( ! $wp_rewrite->permalink_structure ) { + $method = 'get'; + $action = site_url(); + } else { + $method = 'post'; + $action = get_permalink( absint( $simplemap_page ) ); + } + + $location_search = ''; // close map_search div + + echo $location_search; + + echo $after_widget; + } + + // Save settings in backend + function update( $new_instance, $old_instance ) { + $instance = $old_instance; + + $instance['title'] = strip_tags( $new_instance['title'] ); + $instance['show_address'] = $new_instance['show_address'] ? 1 : 0; + $instance['show_city'] = $new_instance['show_city'] ? 1 : 0; + $instance['show_state'] = $new_instance['show_state'] ? 1 : 0; + $instance['show_zip'] = $new_instance['show_zip'] ? 1 : 0; + $instance['show_distance'] = $new_instance['show_distance'] ? 1 : 0; + $instance['default_lat'] = $new_instance['default_lat'] ? $new_instance['default_lat'] : 0; + $instance['default_lng'] = $new_instance['default_lng'] ? $new_instance['default_lng'] : 0; + $instance['simplemap_page'] = $new_instance['simplemap_page'] ? $new_instance['simplemap_page'] : 2; + + global $simple_map; + $options = $simple_map->get_options(); + foreach ( $options['taxonomies'] as $taxonomy => $tax_info ) { + $key = strtolower( $tax_info['plural'] ); + $instance['show_' . $key] = $new_instance['show_' . $key] ? 1 : 0; + $instance[$key] = $new_instance[$key] ? $new_instance[$key] : ''; + } + + return $instance; + } + + function form( $instance ) { + //Defaults + $instance = wp_parse_args( (array) $instance, array( 'title' => '' ) ); + + $title = esc_attr( $instance['title'] ); + $show_address = isset( $instance['show_address'] ) ? (bool) $instance['show_address'] : false; + $show_city = isset( $instance['show_city'] ) ? (bool) $instance['show_city'] : false; + $show_state = isset( $instance['show_state'] ) ? (bool) $instance['show_state'] : false; + $show_zip = isset( $instance['show_zip'] ) ? (bool) $instance['show_zip'] : false; + $show_distance = isset( $instance['show_distance'] ) ? (bool) $instance['show_distance'] : false; + $default_lat = isset( $instance['default_lat'] ) ? esc_attr( $instance['default_lat'] ) : 0; + $default_lng = isset( $instance['default_lng'] ) ? esc_attr( $instance['default_lng'] ) : 0; + $simplemap_page = isset( $instance['simplemap_page'] ) ? esc_attr( $instance['simplemap_page'] ) : ''; + ?> + +

+

+ +

/> +
+ + /> +
+ + /> +
+ + /> +
+ + /> +
+ + get_options(); + foreach ( $options['taxonomies'] as $taxonomy => $tax_info ) { + $key = strtolower( $tax_info['plural'] ); + $show_field = 'show_' . $key; + $show = isset( $instance[$show_field] ) ? (bool) $instance[$show_field] : false; + ?> + /> +
+ + +

+

+ +

+ +

+

+ */ + ?> +

+

+ + diff --git a/classes/xml-search.php b/classes/xml-search.php new file mode 100644 index 0000000..4221e18 --- /dev/null +++ b/classes/xml-search.php @@ -0,0 +1,198 @@ + false, + 'lng' => false, + 'radius' => false, + 'namequery' => false, + 'query_type' => 'distance', + 'address' => false, + 'city' => false, + 'state' => false, + 'zip' => false, + 'onlyzip' => false, + 'country' => false, + 'limit' => false, + 'pid' => 0, + ); + $input = array_filter( array_intersect_key( $_GET, $defaults ) ) + $defaults; + + $smtaxes = array(); + if ( $taxonomies = get_object_taxonomies( 'sm-location' ) ) { + foreach ( $taxonomies as $key => $tax ) { + $phpsafe = str_replace( '-', '_', $tax ); + $_GET += array( $phpsafe => '' ); + $smtaxes[$tax] = $_GET[$phpsafe]; + } + } + + // Define my empty strings + $distance_select = $distance_having = $distance_order = ''; + + // We're going to do a hard limit to 5000 for now. + if ( !$input['limit'] || $input['limit'] > 250 ) + $limit = "LIMIT 250"; + else + $limit = 'LIMIT ' . absint( $input['limit'] ); + + $limit = apply_filters( 'sm-xml-search-limit', $limit ); + + // Locations within specific distance or just get them all? + $distance_select = $wpdb->prepare( "( 3959 * ACOS( COS( RADIANS(%s) ) * COS( RADIANS( lat_tbl.meta_value ) ) * COS( RADIANS( lng_tbl.meta_value ) - RADIANS(%s) ) + SIN( RADIANS(%s) ) * SIN( RADIANS( lat_tbl.meta_value ) ) ) ) AS distance", $input['lat'], $input['lng'], $input['lat'] ) . ', '; + $distance_order = 'distance, '; + + if ( $input['radius'] ) { + $input['radius'] = ( $input['radius'] < 1 ) ? 1 : $input['radius']; + $distance_having = $wpdb->prepare( "HAVING distance < %d", $input['radius'] ); + } + + $i = 1; + $taxonomy_join = ''; + foreach ( array_filter( $smtaxes ) as $taxonomy => $tax_value ) { + $term_ids = explode( ',', $tax_value ); + if ( $term_ids[0] == 'OR' ) { + unset( $term_ids[0] ); + if ( empty( $term_ids ) ) { + continue; + } + $search_values = array( "IN (" . vsprintf( '%d' . str_repeat( ',%d', count( $term_ids ) - 1 ), $term_ids ) . ")" ); + } else { + $search_values = array(); + foreach ( $term_ids as $term_id ) { + $search_values[] = sprintf( '= %d', $term_id ); + } + } + foreach ( $search_values as $search_value ) { + $taxonomy_join .= " + INNER JOIN + $wpdb->term_relationships AS term_rel_$i ON posts.ID = term_rel_$i.object_id + INNER JOIN + $wpdb->term_taxonomy AS tax_$i ON + term_rel_$i.term_taxonomy_id = tax_$i.term_taxonomy_id + AND tax_$i.taxonomy = '$taxonomy' + AND tax_$i.term_id $search_value + "; + $i++; + } + } + + $sql = "SELECT + lat_tbl.meta_value AS lat, + lng_tbl.meta_value AS lng, + $distance_select + posts.ID, + posts.post_content, + posts.post_title + FROM + $wpdb->posts AS posts + INNER JOIN + $wpdb->postmeta lat_tbl ON lat_tbl.post_id = posts.ID AND lat_tbl.meta_key = 'location_lat' + INNER JOIN + $wpdb->postmeta lng_tbl ON lng_tbl.post_id = posts.ID AND lng_tbl.meta_key = 'location_lng' + $taxonomy_join + WHERE + posts.post_type = 'sm-location' + AND posts.post_status = 'publish' + GROUP BY + posts.ID + $distance_having + ORDER BY " . apply_filters( 'sm-location-sort-order', $distance_order . ' posts.post_name ASC', $input ) . " " . $limit; + + $sql = apply_filters( 'sm-xml-search-locations-sql', $sql ); + + // TODO: Consider using this to generate the marker node attributes in print_xml(). + $location_field_map = array( + 'location_address' => 'address', + 'location_address2' => 'address2', + 'location_city' => 'city', + 'location_state' => 'state', + 'location_zip' => 'zip', + 'location_country' => 'country', + 'location_phone' => 'phone', + 'location_fax' => 'fax', + 'location_email' => 'email', + 'location_url' => 'url', + 'location_special' => 'special', + ); + + $options = $simple_map->get_options(); + $show_permalink = !empty( $options['enable_permalinks'] ); + + if ( $locations = $wpdb->get_results( $sql ) ) { + // Start looping through all locations i found in the radius + foreach ( $locations as $key => $value ) { + // Add postmeta data to location + $custom_fields = get_post_custom( $value->ID ); + foreach ( $location_field_map as $key => $field ) { + if ( isset( $custom_fields[$key][0] ) ) { + $value->$field = $custom_fields[$key][0]; + } + else { + $value->$field = ''; + } + } + + $value->postid = $value->ID; + $value->name = apply_filters( 'the_title', $value->post_title ); + + $the_content = trim( $value->post_content ); + if ( !empty( $the_content ) ) { + $the_content = apply_filters( 'the_content', $the_content ); + } + $value->description = $the_content; + + $value->permalink = ''; + if ( $show_permalink ) { + $value->permalink = get_permalink( $value->ID ); + $value->permalink = apply_filters( 'the_permalink', $value->permalink ); + } + + // List all terms for all taxonomies for this post + $value->taxes = array(); + foreach ( $smtaxes as $taxonomy => $tax_value ) { + $phpsafe_tax = str_replace( '-', '_', $taxonomy ); + $local_tax_names = ''; + + // Get all taxes for this post + if ( $local_taxes = wp_get_object_terms( $value->ID, $taxonomy, array( 'fields' => 'names' ) ) ) { + $local_tax_names = implode( ', ', $local_taxes ); + } + + $value->taxes[$phpsafe_tax] = $local_tax_names; + } + } + } else { + // Print empty XML + $locations = array(); + } + + $locations = apply_filters( 'sm-xml-search-locations', $locations ); + $this->print_json( $locations, $smtaxes ); + } + } + + // Prints the JSON output + function print_json( $dataset, $smtaxes ) { + header( 'Status: 200 OK', false, 200 ); + header( 'Content-type: application/json' ); + do_action( 'sm-xml-search-headers' ); + + do_action( 'sm-print-json', $dataset, $smtaxes ); + + echo json_encode( $dataset ); + die(); + } + } +} diff --git a/inc/images/black-dot.png b/inc/images/black-dot.png new file mode 100644 index 0000000000000000000000000000000000000000..9031b926963ade5d12aee14538e49204529a217d GIT binary patch literal 401 zcmV;C0dD?@P)YU6oX_v64h&BsYNln5zul&Ny=*B&!CbYYSP9R!_U?#W@W$`^u} z4(miHA=YdVFwM9AF)6O8{ZT;C&`MT@{dkg*v^b&ofCB|R4k$^-lVm6^z^)#K{D(!U zOVh8S-={(5XTV)w)V+23k{139Z%O1l1$ zJ20j1pHlmDGSSQB0WJ{zV%Oi1maJcqb6lesr-fMa!2|(wv@OyPOGH?jBy|icdJ9}}Dd(~RBOcOIjUGJnRmMLbLWm-m>8fKCgqVPiMl4f9K zg(=$AE@Tltc#EKniXNn(2N5d5GN+kicv&}H-GSlo?V0blGjskk9OuBq)6H(`i~|uZqGwj=FJ0{eh#i`~G#6s; z^ga&b440l$hEw{>FMVfV%s=eDka!4UUo8!q>lClvR{(PFfL{Hb(N&yS+Ttr$D8SVH z1)_(X2a!_`y`FssULk;cVf_w{Z3{ms_yJ*l$k0m zpI{9f3rRSN^+Lo7dq%xx0iie@5e1z7T)P>?H{p4EWZ7Snns4qNCGk#)W!JV$>nt?B zm4zlqut+C?)_;>A#H7*8cFc$t(`Oq5)tENlCIvVnToSBD`E@{zely*Cqn$TWy4s#V zY~oLS#SMoa!@lV>!x;ZtcfK>+;joJrx?^bA4K4lu?H~Pa?)V@LIcAo!=o-=-K6^^8 zGlHcLztr%;@d-v4@9hVw)Z;ZvE=SK7lWq#{fS0P&yanab8J8!>-E|+#J!5N~+O}A3 z0F`U%`aDx^6gp)qQ>sBMZrsZ)$5>!^w{p(RN=+}l47`V7#Mt?9&9Y#+^0w_L7r?Tm z-i7sJuRMK0bD$)bTdo?9oL~itgFqDK45(g|kGk?V}U1i&PnV|k*Y<~v|!$uHK)NSEhF%6~hT#^iqiH~m-EtYG+Lc*EFu}T~ n#$}i`vm}{ds`P?`OU3>LQZZ$CN4L}e00000NkvXXu0mjfhg7Vr literal 0 HcmV?d00001 diff --git a/inc/images/blue-grad.png b/inc/images/blue-grad.png new file mode 100644 index 0000000000000000000000000000000000000000..a570cb4e78bbf2f147df6f4b085776d9dcd4f145 GIT binary patch literal 128 zcmeAS@N?(olHy`uVBq!ia0vp^tUxT!!2~21I85*dQtqBEjv*C{OD7!UY+&GFo_sk_ z=0M|}dcOT;{nL`_kGDEJeqHxv=jEbQZ429}A1}DyKW;Q%r)}Sp#a{y=)&57nW!}B# d(C7U5;#x(F6J{5^`UfPS+N{-$O|K<1pvG=LmbXEC@;a&bE5*P3MmtQnLeQ78sncG}zL=JRMKv>|2>K8aB@wky zp%;oGBBw~y7eDk5^r4{sg$N?VGEe8+V(MDDxdVrX=XuWk-E+=!&S5NwlnryydF?7& zl11=HlH?UdaZ)RZUfhrFIH0U3I~&chP^5H-D@-zra|x2TWG>wbc^xrOc$}A4lT83! zg7nLnsd-y8z}waZ<(}Y=pcjjoElO}cX3*)=K$lPSYv;5UT+bL-TUCH|OZbz%prDF# zTn`$+?kiF9hi=qvgmuiQ{o3hM%ja}oeJu(w1+Z(7?_UF|8D}L3`cd^4L?5k&1S;Kk zO(#Ij^)2M#a_tRf_rtao3v*c*S}35^O7{3rkd&>ScTO>mm7n44m~3c#$mGjVL9&OK z!~HK9X!Ro4PI2|jR3cn375upf^r~r!K{mdk!6eBm?Sthoy-ZEsU1AvXJ&Q{f)GGq$ zbUMG%K4_?TjvOz+Ci2}eL1E<4Y8dT<=8}5hynw0!ztOERg*>*mlQBB zXVj^vXJ7h@7TwQ~4DnwIhPaRmm+b5w4zNbQ?ejA0nwGL(WqUD+3l$^$hT+mZ^)TB1 zbc}H=L7Uxvc}p8LJND{-fpp$5Dd&ki>sfaUyrkoex&RC9lZa1fvE@2l-P!joxW~FD- zuu2b?C>k~28@vn*W(^egE2>x|f(87cppOS!zdA;EDI!?1RsDu$eDZefdlsqS;C!Mt zY5}3IBZlD=y-nSKHTFDWn8g`;kznbyapMug^14-r36|5Y9N5VAH^Sv&!39-DkN^Mx M07*qoM6N<$f}xkD_W%F@ literal 0 HcmV?d00001 diff --git a/inc/images/icon.png b/inc/images/icon.png new file mode 100644 index 0000000000000000000000000000000000000000..b502b495313c59e8e022f519f77e30480362ae81 GIT binary patch literal 659 zcmV;E0&M+>P)3B^Yb;dJuE;F9XKDU|9-s6m&Xu*$farXCd)>;JrDY3P6)EXXE++?z>4-GA) zTUuiOdRUQ9-}*jaw{p+=lwZ5g`8$L8S&p=| z-kcH|FU0EW;^0K%*gBMunw`b=!UBHI%s?$g5seIS7=iQPGQMnX zVmg(=4^2X7@CuF!<$#an2sNF+M-naI#;ZZ}yd6hkYyjPF9-*nP5nf3T_zaDL6t2@-#Tbdkb#J=l&{J=h78%1M|tE{YILpHIYn0~NyjK}^Q z9GmUT^x#0j{P%ZQTi=A|F|!NH4^-h{U2cM2sDma898*WF*VG8k3HNZgE5ejBFvM*X zSLe7I{zSwMb0JF3Q`Bt*i$~EtK%X{r#nD8?{MWkJDBMostUDEdfhNl z_Qx~526Q#o`{R~Qs2nV~Gqtr^Pr_&LbmSw>_Kf3eh8?T2YZW3%#Yt7sP^F;QTqRjT tZ{jiDFJ>{nvW3O<9i($gjkR=k@(&iu=%*smmO%gj002ovPDHLkV1hm~HEI9= literal 0 HcmV?d00001 diff --git a/inc/images/loading.gif b/inc/images/loading.gif new file mode 100644 index 0000000000000000000000000000000000000000..78a943cab0b34baad18bf59ae1478c0491044962 GIT binary patch literal 2456 zcmYk8d0f)j8peMh$dXf_R=B2hRdUcUYsRIzh+1e)nV}}pgk_3rnpSQz0cx6>nK}yQ zf-5R+jplBVX@YB3F1h5Axsgjb_-Wb($w#-~r8BoYbm-O!Y5I%Y{eX>Mj~xmO=A z1CmZ@u0fzkU=x7*vh2&Y07POdvf?)yi972hG;ExUdj`Fz)JuHd7uOx&JsMcL7`iAC zaD7QQp26y_@k1o}O9xEGKTy6Nh zdvQa;V6wu(Bd$kA-H48fy%~2a{&qrQ(jUnwY))YHoSlDipP~cXW1jKk0e;?0Iir|Gl+_GeU<<+NL5lf_hA@ZL6<5l&w3Pz+GU+a zx|`h+gE90N7T(Qiy`>>Bk5;w%Ggp*|Jy}E*{h8OEft~jdB@0qZdg>o>&_&E zA=Rua3wm-$iMnTW^#lyS##D|?VG@{mfE<}^!T>YMtT)*lBrwI{;Ikmy>mmo16T%&V z+mE*wgjYkJ9^Q(#=d-H)a=;kD${ZPje8)=Xo+>>KfFXo*Uv61MgWEH(@30|ZQs@mk z-o*`i+ufaM?1?Q|*Kv8Sro7`lj;j~hXNg$7Ihg%dKi?Dt!4n#c;G_Be+s@vvHy;F; zVO!j~hM)_>>Mkn1_p|mbaq0U*mei6OWIN;)uQkS<{4|AFO>yP$~Gne$L{S@-i`w-=RX1B}ftFv@tgC$wTDG=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NweillWV*62hSa~FD+4ZZv=gRNLr&}(SG F^ly&*NsRyi literal 0 HcmV?d00001 diff --git a/inc/images/map-type-hybrid.jpg b/inc/images/map-type-hybrid.jpg new file mode 100644 index 0000000000000000000000000000000000000000..8410311ea89a8eb6270b502d52f1b7ffd060f4f5 GIT binary patch literal 6465 zcma)AcQo8v*Pf=g8G{f+uOS${_tBz_-V#RdB@q!s3(-44L}!!;qC^*U5JB|bdly`U z#OL1kzTdy!x6k^mbI$Lqb=I@aIeYJCKeyAj%K)f4QVj_Jf&c)Uy9T(O11JJ;ArJ@- z1Q!PfmjL(fBf`hU#U~;rBqSmvB!&|IV^CsJGAJ1-F&s`o0f*Dk($dl~{IC7J2@nqt zkA#?n8VaSpPYI*E|G$g>-@$Ds0EYiJC@>HP0KtG@81S|mKnDPTf&UobUxVP_feu(XyUOyO?FEG(DuRStaG$Pb{Fcy!=!# zK2oB+>hi3TN9igGig*7&W5%y^oJzAeiDk2esw}Ar(*Xa$|6lNTJqQc|0&xBT4}#v!V;=;s_S@j`vevmht2W;0nu*BdM1a`# zj0y?L(19vC1es52H>9QMKs(vWGBHPH)dOQW;kmd+>En8+OqNRLn{f5jcNvR?D@|$z zg+)B=y@ip+UzNFeCqbDVTNQ+P0qHX(M}gl|A3y!S;DG;z)5~ibo?XtZpZZKGLQPU3 z*k7Sjm~(;Youi#hz@)b1MGlv7q423a!T!N((iXHGOj9|zRc^;gN5&`}mRo2?i9hFS zyu(yDxjbtxeG{89j91jQ# zgunqfFmeh?CKg;~RskwDgrJbHyn^DtHw`2P&b`jHO&D~*ax@i>C6uHS_&8KmKZTWR zL_Yud=@)kay8AeUYR;qJBSiaE;l?>r#N-y|hk>s|#`R)yVKzPp`p9bOykgya2Sa^= z?kbTIwW5-K=6R6-ZH5PvI8m2&c3_)N%B{+cJf*`{0{k2-MAa^_o`P`Rrj0gV=+Oo< znl(+ZoQg_4ri{n)ps{Tg<)T4V@$G~fnL1lGBQ8^L-&;;*z)H#+`H?@GChGz3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D`FRBOOQaT};f*uy3I zDVDI_tPGqa`%SvDD$`uwau-JiVXi7!sUcauOrizh5Q7#LXzjua`ii>mR5hdHzUvCG z&15aRAJ&_r)i|T+PNfA)41yukN`6tkYA&hNY0Fa`5?m1O z(0rv(*u$BNr}X2!RseEoAhxJC1OnFxAD5x2Rf^;B;W2g5;a^oT`s?&cD@s9)a)!ES z`!&pZ(2v%AHrWAZ zxer&;TPcs2N@K98GKYBXV$KA@Fo|G=1tYs4{fBPm%aYaQW^FMgeR2Rr?D*=d+|KMd z2YRTbCQxCQRMxgse4g`Mj<3|)>(VqxQ^bK}>{u14uH_B%?|ej;@USaO@-tTvH29~Z z-A?@dFt;KpW#ou100Ti}@V&j)c@w|OaPoM&?>>;;WhpuQ(;nbqXU_In^Vo&gh0*FQ hU^aSjaYf@$dZbR|`+m*3e}kUWc-wi0`PA*q{{R;tyz~G7 literal 0 HcmV?d00001 diff --git a/inc/images/map-type-normal.jpg b/inc/images/map-type-normal.jpg new file mode 100644 index 0000000000000000000000000000000000000000..4323109a0122e77e23f85e7722b4aca3d22c7e95 GIT binary patch literal 6765 zcma)=RZtvEw5CKP6+Pq?k<6w|K2+1 z`L3?6>Z-l^+xwxbdUwChzpevtmE;uV00@Wxfc3utcwGX>0FXf-5E2L(2?-eu`QOAq zMMg%&z(hyKKu5>K#r(g*#l*(J#lglTARr_pAfO;8C#RtLU;PI`KtVyl!o(uQ#U&*p z!XqO4-{Al6;}AtD11Q2qtQZ~=%2 zKp-Lr_^))7|11cIKoA~20O=h8HzAFbCJ`+Uvb2SJ7%{I_VgVgJUs7$irH5x>UDw9N zzwKlQ|BwAY(F!k|ym(y%U;_Wy@ql;$3Bcc|sARWX)Z)k%OUD|O45R_E zw&9SpHXTu7zr_Jr>MM*wksw`t%PseJqw|$|zpU-*Z`=xrZJ3#f83}^XlS&`$MCDAh zsXZCKYCfI3fbpoEWY^(qh}lKuOF@WoCQ_Odel?aF!GLBK{!wRL`e=IKK|C3CC&GlqZ$@v}5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{_G5Ypf!HZtr$(iPyf9Jj;*hwtw=e4d|sr)0$5XG3n;C zCzGo`RlPmyF5s!D{Uk=+=yoR1W>DIn($g@je#Xhgeh&O~{yMhH{dTKvik;y_dD{dE z3UYIl^BpkeNUrGYX;$!vE^LKuKZTH|MgS01vpsJG*6wZMU(f9*#1w{;_xEhJFI!4@vSRC_t|7Yd*|?pDY_+DTHa3hrH2jMzkj9U(&1Xx z_|11=GeXASi+-nIq2Zu3oh;3IdqrC;2I&kx6?-b8;jv%P7iUa#65H6y;S)fGmn^KD zLXpl2-}#HAP9NX!!}$oOW;<6IE zSQMA>@{CXimN`k*oPzyD?Oy?oJQ`TkMus)W|tN3`TDWn~+6 z%2Wded7*o5e`IS8+T$X)69o>c=9(T^2q)Vv{`Amu6VdCcIEImkZGYncR~{8?)~H9Z zAosV8t5mqZk)kYjE;lk1eb%MP2izwC%(%) ziKYA;=E?(67t;SA$#ID!%+198?73bEJo6kr8|xR$nIi!`xIUh1R4z|rq$-_b1yfc1cHGB1~duQbE(rl$V^T3SzMN9p< z7$=zui34jia>UC&treXgRqIzrE3JMTgT6e9w5hCy_%NvPj$KCA1fStIz?{mk39 z_9UoYF#VW&Z#6b`QvS@?d%DxLU;A3b8CFytA>Xto=Z4pOHJch^e@qEUKjok9V_zP literal 0 HcmV?d00001 diff --git a/inc/images/map-type-satellite.jpg b/inc/images/map-type-satellite.jpg new file mode 100644 index 0000000000000000000000000000000000000000..c19078b83411d2174eebcfe204ad32cb7da5707e GIT binary patch literal 4622 zcma)AbyO7n-<=Jb1(u~tx34p)=;B>hG7qfsGKnR6G37~`o z1cW4nmj@X!At5mtIVmX_DJeM>`5#b`Q&3V-QjjAMG&BeV3o|n_%a#A|`z0VEA|e<$ zjDd=Zfr%DQ%kFCb6?LNEv*x|jio z|Gxb-;o8sP@whu&rCY+zgD+x^qKl)Z9!=1SocM}c6yl3+9B4-=tyz|Z-!6J_ zjFP;Sb@C=VrAvP2-blW5D$ICfBi99wZYhv?&?@}!?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MuPy*F(~MYz`*QUKpuXkM$FZzAM@E)4 zaMqxspBNSwtws6x8`~N<3}4QDgHMbR8uvT^roU%X!8U<6(5oLOY) zS>clg`Dxr)+bnnZ+E60@Vj5RtU`hJNxJw3mRX+cBCm#==lOy5nS_+yrtFY!2K1_mR#Rk-n`{6Yr5Wv6cX z;Wd@2O64z56&*K?=v2nSW{-Jw(09c0hf;NRgB)M<9P6+lV`xgg#6NHyURl7#3wR$- zz=TG^`%N}cZBNB(<~}xzb!+on1|o)b5OEFVO8p!p(<2!tI|kCt5{Y&pb^jO&*g@vy zXOqe|Xy9uKJ$vAS6Cqdqw<}%G0@G9AyVWR`j|jC=b{0MnuI^1i zhKM@9&8?y~YtfO~&dO)bxVYVgsil@o& zWI9+)QMVk`i^52A@yw4q1SsV#51I9OWR}SazsVaym?GAw?S_h= znglkaMYOK~6_@3j5wF`hGV*e656a)Wx?Iu}jBD+?4U}_VJt9fvL&jrOHQV|>z5n4H zTl}~%8=>4{!Jc=1pV0KI=y_B6r!8C07>}ctGs%;r?SSo>;g>mFo#O?+PH$|gL2vpF zj5rUioVGi6e(A&t0^vc!uUp+a3y)6XdQ2DeD83Q`3(nWtk4~856)IZvGB@HbfICKz zmy2yhJIn6aPwh^}_>((?xE-wfX5qX`M}JU9r^1=S^RKl>EQV?;mq`_SovZV=F916i zw+o;Qi`*4`YDXzGhB}iCZ{a;tJML(bwb4N|KXQ3UpuPZx4_yWR%oVaIJ-~E05 N^0af|?~8pg_dlRE!b1Q6 literal 0 HcmV?d00001 diff --git a/inc/images/pink-dot.png b/inc/images/pink-dot.png new file mode 100644 index 0000000000000000000000000000000000000000..dbc1ac3b7c6786e87d1ca7f89aa9b18cdf64b073 GIT binary patch literal 917 zcmV;G18V${{aW5L;}% zOh(Hq*=)9x#bR}{Su7{6FIgoyaW~Y>p_D&X6JIBh3Z%mv4tG&2Oon_}0aPd|nOQH= z1DDJD6D5cmtyVc?n}VuURaxl8LbfCuCd_ZZUFZRK$=vEF^1!={NjMpm3wUl3e`50q zYD#Lc;sJ2#x|oZe;yIWhF#GD5E$}e=M<5md-(sp_h2L^ibcYT7hYWn&B)AZPpLaIw+pUhXQ4o(lusug;EWPjVeqwjGJGB zn}lHZA4YOGdE^7|*j#X^YEvkkPN=z-zJ($4$hKdTB>!dlDqDA+4d=~#(eSDo?74T26O-ZeQ8vXIaG%Q?K zQumVYYcYxQt=e{!xj} zOi^AX;)!AU*cX^7+E_lHZEld!3OE&grhUui_$hNLM7dWvksEz_W4O4+<_Y0E;q2Rt z_q+V+wis>_3D;#FUkw+%BHq$$8m=bP=TO@*jZpX4DqT~vI5(&pA)G6kerg)sxh+_W zrcH-(0StRNcljQW(=sTQmy}Z5wLU}t4gn`@2191L>KK+1YHA+$SyUiq-k07+6z)0q z6%${Jp2fPTK&@O+p^xB4!Yqbp5U0Y4NK0kFux3r$9-7VnIb<9G2`vFfe2tO{#!$dh zS5#Gi^Y<2Q`|hA%a)IJG>G3gPu^*{m4I5`KpF@LO5H}Ju47=zpQVpoF{-9yUrIyPC rb~qxVJ!n{QT#1FiY%zKHTb=z2MaFWkR=&oL00000NkvXXu0mjfy|}XZ literal 0 HcmV?d00001 diff --git a/inc/images/purple-dot.png b/inc/images/purple-dot.png new file mode 100644 index 0000000000000000000000000000000000000000..a569c4c852d0949e1e6019971081433a645e9351 GIT binary patch literal 909 zcmV;819JR{P)jBy)@^{K67R~GjrzR=!7~Nns;Y(ybGx*lBp?@Su|eL2TO$>yx?U> z6CH0v6bRXkz(9QPEhr9Fn zvd%2Akq(w+oidqhn3c(#xNb<`tHUmX121k%qyr= zGhT!Tpi1-9eQ`V;U=(4a)*Zv<*{9!Yq}PBFK#|&6u?yso7EK8HRjqvnOBPp}-d=-rO0@^X?d8@Jx3|#bFtF#ix6st!p94Ci%!&h*n z`wpUmYIx7|0|?7Qeo%irdS$IQ@d@q^d%bEgdv&idbATp*WO^cstyVpqOiU=MWtV!*#rlL z4KPt8?>fc{W2wi}jB0Hn$zbMF>zH!skr9(`qd9o#$gfGoZ!@mY@ITjtmwctl%=}UtmO32 zXU5C+{pE8%0YJ+}L9%eO`_Sgt6TBHVD)_*#ABv_etDi+fPFl>)@ zDFAxb0vW278s?~WOSf=>ut6U&WOr9>!&1VWT6gFcWXy3alE2tRGkhWkpg`;g18bRM zj%(Sf_QW901S1$?7@q~Pq{4A*SgCgE3@=muY|?)KjXVTju{VP8$1s847l>Ve^IDlS zecCUWj*EI3u1E)ogui9{HEf)da#jfvcmBEGFzlkev>GtS9{LT76Dk@hEQY_-?Kdn_ jY$>2Ht5A3Ku(N*w)}%UOO-J&U00000NkvXXu0mjfLP)Vq literal 0 HcmV?d00001 diff --git a/inc/images/red-dot.png b/inc/images/red-dot.png new file mode 100644 index 0000000000000000000000000000000000000000..3735dc02652d570037d3cb92694848e018e02af6 GIT binary patch literal 893 zcmV-@1A_dCP)P_YtW zp$H2SjZuR}7h*!fn)nH_@RPVOAsS-{IOTfZfE7xGes1#e^5(rcbMAfT++mm`amS(L zbW4&y$gs7r7wDMGQt}&o5Z2(Ce zbYE|-gI8WRWw`pI zbs)+RYxrY-KJc6whGcswQ!bF+Ql2+95?L+yH0V)mpbEs8={i{rtE~cMcag!IZ+GDB z7)4L`G6f)n#0On(VTkWh*&xm^1smzZMKUnTXd@V1Cj+~JAE7uDY$#&Qj#-!8O2MK` z*h)GvU(oBTGO8J^bs6EIlJGsuq+8Wce9LeAzO-+X7XMR$mx_0F%&im|I;$sSEX)%F zEK&8_374kWhWbR$K8%YN=@TI@Z!xOLDLLS;VDCE}fExWd=l9q*S?Za`c^HehG=ZK= zb{UC9ryj=hzaO~Oilkq2MzMK+)%yf#@t?A+#n)>SlTMTq{&5EyIL;2|5xhO8nSDR+({`r?Htu#FLAd~?yt@b0P{8l5sWRaFeZr;g%?hlT<6h7nUr5Lt zlWkz*oDk7I2RO^~tiiC0-k@$kjZJ0^)-HbS8K|$i*V4;nLjRYG@TT6{v zDOjixG>PnHv)SxN_I=Ha^N0ya$mYQB&f#3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NUes~Otgl76t^S_oU|#%2T{Xtie9E} zK#kpr8pfBn4-rhcIjb#d*y6oK+X%+*DyW*x_c!WLG@(|rx$6J`002ovPDHLkV1i1& B#>W5v literal 0 HcmV?d00001 diff --git a/inc/images/white-dot.png b/inc/images/white-dot.png new file mode 100644 index 0000000000000000000000000000000000000000..87f808d6e7a32000240aa5f72f0242cd510f74f8 GIT binary patch literal 553 zcmV+^0@nSBP)xwL@XQ>3PKj8b|_Xeh#90&BiS+p1dED> z)(#aM93(g#q7*U+g5V%UA^rmrJo#D))!KK5#Bj~8`#js-i|6~jdmfQyZuB{0=Auzl z&s5R8GkNA#zqBWHV$e0Vhj2*ZFihy*;Jf*;7BqKRZN(|$q0wkOK9WFfC$IWYW>!&X zyslRjjph*sscQ|ic1ryzps6;|f4a#sYG-*uL_};i-T~E1<6xEDeo0Rltox2@txp&% zoEQ7{QM_g^7l$YguJ4W`SUFKoCw;vf!h{Lq>^W8yMXgNxShT^SK9)qSh{Zh?3#!hBjL}JflU04;(D8sKrM8vg?AE}N%Sd+#0RXWxf z*ZqX5<=Q%G3aGz%$2a`^jACsM)VLUAXIob3;=KqJAN!6;VySH{H~J30Pc-{!QbfLe zIM88#^Ji6a2`Yq0U6IbQU)Lw1NptY4yT1#|o-^3M!^33yrgY2dzHlYaCN4&8^@w!O z@du;SSimexuOu%F;1T2WVo#Pm6#89afcbIhoyeCtB0qDH0A{@%!Tc;iv0j9*-UKrH rp~8F_$l`Yuqf3Eo=8|ISdh63&3lAHTxofJf00000NkvXXu0mjff@AvA literal 0 HcmV?d00001 diff --git a/inc/images/yellow-dot.png b/inc/images/yellow-dot.png new file mode 100644 index 0000000000000000000000000000000000000000..b52fdc3d6872c06f90f210f036d125bf6676c26a GIT binary patch literal 956 zcmV;t14I0YP) zYe0Q=50Ih@bFyT-_AMD|C~{j4Le<_;+S*f zIt3#rb8>QO#;rEWiE5TJf=WZCU)-6KYMNS%Rh5Kkq&{vvH0?a8QHdbmq=2HmK~R8m zltv6RhchLW^6!@xhv?=79W4&oj?>R9y)V3enhKUN1Hf3Wby!Ao;LSif7_()7_a+Y( z2JNv4I$Ir?j}x>s!~l%r$Kyt@j2K|@%NFaH!a?@Q`Sq4qz!bpAiimwPKwTXPt8n_& z)~EycW@0~@oM%i!^Wa8X9P!X{^IBYj6{e2x=*h;=V0>ZFzXQISz-*L5kW$$9>|QcW z)gDtNaGagt)sr;Li*eB)7B-#(LoYIb%XNmzlF&3NQYEU02otdfv%TuSn*=-X6(wRm zJCn7o9O|MxAy6qiL882D$da*1o&C!MK-08!koEuGT! zpO3ne@L=l_U(*QBAEXlTTF#zQ$Fn+%U+vY79 zoRJgd;p~N}MR{d{bJdZ68vXX5D=~CNNnO39OU7xUu2yUFWoIY-N_`AT`tOV9qx3e5 zy{RsG6Djtt8*AsxAKCA_lf)MJx#{LGx9#5*cw8dp!SMS`0BkukK-iLg3~vD?BLI^@ z*05l6{Pb4O2@Y5`VA{<5r#%uLHct?VTs{sCq%U7ox5aSRk#Ju={#*RStIz1In=1{+ zOT!DOrC4NysN0a`Z}pCNRa2z~vB+iUNzXdol3*8VG$|+-z_8ie{YIc%<_^2_m4~RM zT4#GaS190qz>wLl+TWW@G&RxLzD7pbV~K0M>xshQs~MYL7%(#TKFVG@P#Cn{OXA9g z7#r;g8#7jx*$q2it&zI%>F*D_62Zrt4`s!n@suNm0)BU-C+9HD{%;>V1)Og zwG#06bswZ0HT