From e597399954affc43e8cf6473555855b8abc5500c Mon Sep 17 00:00:00 2001 From: Dennis Reilard Date: Thu, 10 Aug 2023 08:41:43 +0200 Subject: [PATCH] 1.8.0 Ilch-Core und PHP-Version Anpassung FontAwesome 6 Code Verbesserungen Captcha Anpassung --- LICENSE | 674 ++++++++++++++++++++++++++ config/config.php | 133 +++-- controllers/Index.php | 58 ++- controllers/admin/Index.php | 69 +-- controllers/admin/Settings.php | 13 +- libs/SearchiTunes.php | 386 ++++++++++----- mappers/HoererCharts.php | 247 +++++----- mappers/HoererChartsList.php | 87 ++-- mappers/HoererChartsSuggestion.php | 129 +---- mappers/HoererChartsUserVotes.php | 151 +++--- models/HoererCharts.php | 135 ++++-- models/HoererChartsList.php | 77 ++- models/HoererChartsUserVotes.php | 81 +++- translations/de.php | 3 +- translations/en.php | 1 + views/admin/index/index.php | 343 +++++++------ views/admin/index/reset.php | 79 +-- views/admin/index/searchiTunes.php | 6 +- views/admin/index/treat.php | 51 +- views/admin/settings/index.php | 32 +- views/admin/settings/votedatetime.php | 15 +- views/index/index.php | 238 ++++----- views/index/treat.php | 55 ++- 23 files changed, 1981 insertions(+), 1082 deletions(-) create mode 100644 LICENSE diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..f288702 --- /dev/null +++ b/LICENSE @@ -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 +. diff --git a/config/config.php b/config/config.php index f3081fe..88b7af9 100644 --- a/config/config.php +++ b/config/config.php @@ -1,4 +1,5 @@ db()); - $databaseConfig->set('radio_hoerercharts_Guest_Allow', '0'); - $databaseConfig->set('radio_hoerercharts_Start_Datetime', ''); - $databaseConfig->set('radio_hoerercharts_End_Datetime', ''); - $databaseConfig->set('radio_hoerercharts_Program_Name', 'Hörercharts'); - $databaseConfig->set('radio_hoerercharts_showstars', '1'); - $databaseConfig->set('radio_hoerercharts_Star1', '1'); - $databaseConfig->set('radio_hoerercharts_Star2', '2'); - $databaseConfig->set('radio_hoerercharts_Star3', '3'); - $databaseConfig->set('radio_hoerercharts_Star4', '4'); - $databaseConfig->set('radio_hoerercharts_Star5', '5'); - $databaseConfig->set('radio_hoerercharts_all_sec_vote', '86400'); // 24h - $databaseConfig->set('radio_hoerercharts_allow_suggestion', '1'); - $databaseConfig->set('radio_hoerercharts_Program_sec_duration', '7200'); // 2h - $databaseConfig->set('radio_hoerercharts_votetext_de', '[size=120][b]So funktioniert es:[/b][/size] + $databaseConfig->set('radio_hoerercharts_Guest_Allow', '0') + ->set('radio_hoerercharts_Start_Datetime', '') + ->set('radio_hoerercharts_End_Datetime', '') + ->set('radio_hoerercharts_Program_Name', 'Hörercharts') + ->set('radio_hoerercharts_showstars', '1') + ->set('radio_hoerercharts_Star1', '1') + ->set('radio_hoerercharts_Star2', '2') + ->set('radio_hoerercharts_Star3', '3') + ->set('radio_hoerercharts_Star4', '4') + ->set('radio_hoerercharts_Star5', '5') + ->set('radio_hoerercharts_all_sec_vote', '86400') // 24h + ->set('radio_hoerercharts_allow_suggestion', '1') + ->set('radio_hoerercharts_Program_sec_duration', '7200') // 2h + ->set('radio_hoerercharts_votetext_de', '[size=120][b]So funktioniert es:[/b][/size] --user-- darf für seinen Lieblingstitel stimmen und an einem Bestimmten Tag (siehe: Sendeplan) wird es die Sendung "--name--" geben. In dieser Sendung wird von unten (z.B. Platz 20) bis auf Platz 1 gespielt. -Danach werden die Stimmen von Ihnen wieder gelöscht und die Chartliste aktualisiert, d.h. es werden möglicherweise neue Interpreten hinzugefügt oder ältere Titel werden ausgeblendet usw.'); - $databaseConfig->set('radio_hoerercharts_votetext_en', '[b][size=120]So It Works:[/size][/b] +Danach werden die Stimmen von Ihnen wieder gelöscht und die Chartliste aktualisiert, d.h. es werden möglicherweise neue Interpreten hinzugefügt oder ältere Titel werden ausgeblendet usw.') + ->set('radio_hoerercharts_votetext_en', '[b][size=120]So It Works:[/size][/b] --user-- can vote for their favorite song and on a specific day (see: Broadcasting schedule) there will be the show "--name--". This show plays from the bottom (e.g. 20th place) to the first place. -After that, the votes will be deleted again and updates the chart list, i.e. new artists may be added or older titles are hidden, etc.'); - $databaseConfig->set('radio_hoerercharts_show_artwork', '0'); - $databaseConfig->set('radio_hoerercharts_active_list', '1'); +After that, the votes will be deleted again and updates the chart list, i.e. new artists may be added or older titles are hidden, etc.') + ->set('radio_hoerercharts_show_artwork', '0') + ->set('radio_hoerercharts_active_list', '1'); $this->db()->queryMulti($this->getInstallSql()); } public function uninstall() { - $this->db()->queryMulti("DELETE FROM `[prefix]_config` WHERE `key` = 'radio_hoerercharts_Guest_Allow'"); - $this->db()->queryMulti("DELETE FROM `[prefix]_config` WHERE `key` = 'radio_hoerercharts_Start_Datetime'"); - $this->db()->queryMulti("DELETE FROM `[prefix]_config` WHERE `key` = 'radio_hoerercharts_End_Datetime'"); - $this->db()->queryMulti("DELETE FROM `[prefix]_config` WHERE `key` = 'radio_hoerercharts_Program_Name'"); - $this->db()->queryMulti("DELETE FROM `[prefix]_config` WHERE `key` = 'radio_hoerercharts_showstars'"); - $this->db()->queryMulti("DELETE FROM `[prefix]_config` WHERE `key` = 'radio_hoerercharts_Star1'"); - $this->db()->queryMulti("DELETE FROM `[prefix]_config` WHERE `key` = 'radio_hoerercharts_Star2'"); - $this->db()->queryMulti("DELETE FROM `[prefix]_config` WHERE `key` = 'radio_hoerercharts_Star3'"); - $this->db()->queryMulti("DELETE FROM `[prefix]_config` WHERE `key` = 'radio_hoerercharts_Star4'"); - $this->db()->queryMulti("DELETE FROM `[prefix]_config` WHERE `key` = 'radio_hoerercharts_Star5'"); - $this->db()->queryMulti("DELETE FROM `[prefix]_config` WHERE `key` = 'radio_hoerercharts_all_sec_vote'"); - $this->db()->queryMulti("DELETE FROM `[prefix]_config` WHERE `key` = 'radio_hoerercharts_allow_suggestion'"); - $this->db()->queryMulti("DELETE FROM `[prefix]_config` WHERE `key` = 'radio_hoerercharts_Program_sec_duration'"); - $this->db()->queryMulti("DELETE FROM `[prefix]_config` WHERE `key` = 'radio_hoerercharts_votetext_de'"); - $this->db()->queryMulti("DELETE FROM `[prefix]_config` WHERE `key` = 'radio_hoerercharts_votetext_en'"); - $this->db()->queryMulti("DELETE FROM `[prefix]_config` WHERE `key` = 'radio_hoerercharts_show_artwork'"); - $this->db()->queryMulti("DELETE FROM `[prefix]_config` WHERE `key` = 'radio_hoerercharts_active_list'"); + $databaseConfig = new \Ilch\Config\Database($this->db()); + $databaseConfig->delete('radio_hoerercharts_Guest_Allow') + ->delete('radio_hoerercharts_Start_Datetime') + ->delete('radio_hoerercharts_End_Datetime') + ->delete('radio_hoerercharts_Program_Name') + ->delete('radio_hoerercharts_showstars') + ->delete('radio_hoerercharts_Star1') + ->delete('radio_hoerercharts_Star2') + ->delete('radio_hoerercharts_Star3') + ->delete('radio_hoerercharts_Star4') + ->delete('radio_hoerercharts_Star5') + ->delete('radio_hoerercharts_all_sec_vote') + ->delete('radio_hoerercharts_allow_suggestion') + ->delete('radio_hoerercharts_Program_sec_duration') + ->delete('radio_hoerercharts_votetext_de') + ->delete('radio_hoerercharts_votetext_en') + ->delete('radio_hoerercharts_show_artwork') + ->delete('radio_hoerercharts_active_list'); - $this->db()->queryMulti(' DROP TABLE IF EXISTS `[prefix]_radio_hoerercharts`; - DROP TABLE IF EXISTS `[prefix]_radio_hoerercharts_uservotes`; - DROP TABLE IF EXISTS `[prefix]_radio_hoerercharts_suggestion`; - DROP TABLE IF EXISTS `[prefix]_radio_hoerercharts_list`;'); + + $this->db()->drop('radio_hoerercharts', true); + $this->db()->drop('radio_hoerercharts_uservotes', true); + $this->db()->drop('radio_hoerercharts_suggestion', true); + $this->db()->drop('radio_hoerercharts_list', true); } - public function getInstallSql() + public function getInstallSql(): string { return 'CREATE TABLE IF NOT EXISTS `[prefix]_radio_hoerercharts` ( `id` INT(11) NOT NULL AUTO_INCREMENT, @@ -127,7 +130,7 @@ public function getInstallSql() ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci AUTO_INCREMENT=1;'; } - public function getUpdate($installedVersion) + public function getUpdate(string $installedVersion): string { switch ($installedVersion) { // Erste version erstellt Vorlage: https://www.ilch.de/downloads-show-1562.html @@ -140,6 +143,7 @@ public function getUpdate($installedVersion) Zurücksetzen mit Sicherheitsabfrage Englische übersetzung überarbeitet */ + // no break case "1.0.1": // update zu 1.1.0 /* @@ -150,6 +154,7 @@ public function getUpdate($installedVersion) $this->db()->query('ALTER TABLE `[prefix]_radio_hoerercharts_uservotes` ADD COLUMN `session_id` VARCHAR(255) NOT NULL DEFAULT \'\' AFTER `user_id`;'); $databaseConfig = new \Ilch\Config\Database($this->db()); $databaseConfig->set('radio_hoerercharts_Guest_Allow', '0'); + // no break case "1.1.0": // update zu 1.2.0 /* @@ -167,9 +172,10 @@ public function getUpdate($installedVersion) 'icon_small' => 'fa-solid fa-list-ol' ]; $this->db()->update('modules') - ->values($fields) - ->where(['key' => 'radiohoerercharts']) - ->execute(); + ->values($fields) + ->where(['key' => 'radiohoerercharts']) + ->execute(); + // no break case "1.2.0": // update zu 1.3.0 /* @@ -182,7 +188,7 @@ public function getUpdate($installedVersion) $this->db()->query('ALTER TABLE `[prefix]_radio_hoerercharts` ADD COLUMN `datecreate` DATETIME NOT NULL AFTER `votes`;'); $date = new \Ilch\Date(); $datecreate = new \Ilch\Date($date->format("Y-m-d H:i:s", true)); - $this->db()->query('UPDATE `[prefix]_radio_hoerercharts` SET `datecreate` = "'.$datecreate.'"'); + $this->db()->query('UPDATE `[prefix]_radio_hoerercharts` SET `datecreate` = "' . $datecreate . '"'); $this->db()->query('ALTER TABLE `[prefix]_radio_hoerercharts` ADD COLUMN `user_id` INT(11) NOT NULL AFTER `datecreate`;'); $this->db()->query('CREATE TABLE IF NOT EXISTS `[prefix]_radio_hoerercharts_suggestion` ( `id` INT(11) NOT NULL AUTO_INCREMENT, @@ -195,12 +201,14 @@ public function getUpdate($installedVersion) $databaseConfig = new \Ilch\Config\Database($this->db()); $databaseConfig->set('radio_hoerercharts_all_sec_vote', '86400'); // 24h $databaseConfig->set('radio_hoerercharts_allow_suggestion', '1'); + // no break case "1.3.0": // update zu 1.3.1 /* fix indentation bugfix of redirect in Frontent */ + // no break case "1.3.1": // update zu 1.3.2 /* @@ -208,6 +216,7 @@ public function getUpdate($installedVersion) */ $this->db()->query('ALTER TABLE `[prefix]_radio_hoerercharts_suggestion` CHANGE `datecreate` `datecreate` DATETIME NOT NULL;'); $this->db()->query('ALTER TABLE `[prefix]_radio_hoerercharts` CHANGE `datecreate` `datecreate` DATETIME NOT NULL;'); + // no break case "1.3.2": // update zu 1.4.0 /* @@ -215,22 +224,26 @@ public function getUpdate($installedVersion) shows the users / guests who submitted the entry small fixes */ + // no break case "1.4.0": // update zu 1.4.1 /* bugfix of SQL-Statement is_voted */ + // no break case "1.4.1": // update zu 1.4.2 /* bugfix of SQL-Statement is_voted Some Beauty fixes */ + // no break case "1.4.2": // update zu 1.4.3 /* Some Beauty fixes */ + // no break case "1.4.3": // update zu 1.4.4 /* @@ -239,12 +252,14 @@ public function getUpdate($installedVersion) */ $date = new \Ilch\Date(); $datecreate = new \Ilch\Date($date->format("Y-m-d H:i:s", true)); - $this->db()->query('UPDATE `[prefix]_radio_hoerercharts` SET `datecreate` = "'.$datecreate.'" WHERE `datecreate` = "0000-00-00 00:00:00"'); + $this->db()->query('UPDATE `[prefix]_radio_hoerercharts` SET `datecreate` = "' . $datecreate . '" WHERE `datecreate` = "0000-00-00 00:00:00"'); + // no break case "1.4.4": // update zu 1.5.0 /* Admin View Sort #2 ( https://github.com/hhunderter/radiohoerercharts/issues/2 ) */ + // no break case "1.5.0": // update zu 1.5.1 /* @@ -253,6 +268,7 @@ public function getUpdate($installedVersion) */ $databaseConfig = new \Ilch\Config\Database($this->db()); $databaseConfig->set('radio_hoerercharts_Program_sec_duration', '7200'); //2h + // no break case "1.5.1": // update zu 1.5.2 /* @@ -271,6 +287,7 @@ public function getUpdate($installedVersion) --user-- can vote for their favorite song and on a specific day (see: Broadcasting schedule) there will be the show "--name--". This show plays from the bottom (e.g. 20th place) to the first place. After that, the votes will be deleted again and updates the chart list, i.e. new artists may be added or older titles are hidden, etc.'); + // no break case "1.5.2": // update zu 1.6.0 /* @@ -285,7 +302,7 @@ public function getUpdate($installedVersion) `list` tinyint(1) NOT NULL, PRIMARY KEY (`id`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci AUTO_INCREMENT=1;'); - + $hoererchartsMapper = new HoererChartsMapper(); $hoererchartslistMapper = new HoererChartsListMapper(); $chartsentries = $hoererchartsMapper->getEntriesby(['setfree' => 1]) ?? []; @@ -296,12 +313,14 @@ public function getUpdate($installedVersion) $databaseConfig = new \Ilch\Config\Database($this->db()); $databaseConfig->set('radio_hoerercharts_show_artwork', '0'); $databaseConfig->set('radio_hoerercharts_active_list', '1'); + // no break case "1.6.0": // update zu 1.6.1 /* translations update */ - + + // no break case "1.6.1": // update zu 1.7.0 /* @@ -320,10 +339,22 @@ public function getUpdate($installedVersion) ->values($fields) ->where(['key' => 'radiohoerercharts']) ->execute(); + // no break case "1.7.0": - // Update icons for fontawesome 6 + // update zu 1.7.1 + /* + * Ilch-Core und PHP-Version Anpassung + * FontAwesome 6 + * Code Verbesserungen + * Captcha Anpassung + */ $this->db()->query("UPDATE `[prefix]_modules` SET `icon_small` = '" . $this->config['icon_small'] . "' WHERE `key` = '" . $this->config['key'] . "';"); - + // no break + case "1.7.1": + // update zu 1.?.? + /* + */ + // no break } return 'Update function executed.'; } diff --git a/controllers/Index.php b/controllers/Index.php index 8d4975f..a2ffac8 100644 --- a/controllers/Index.php +++ b/controllers/Index.php @@ -1,4 +1,5 @@ getConfig()->get('radio_hoerercharts_Program_Name'); $hoererchartsconfig = [ 'guestallow' => $this->getConfig()->get('radio_hoerercharts_Guest_Allow'), 'allowsuggestion' => $this->getConfig()->get('radio_hoerercharts_allow_suggestion'), - 'Program_Name' => ($radio_hoerercharts_Program_Name ? $radio_hoerercharts_Program_Name : $this->getTranslator()->trans('hoerercharts')), + 'Program_Name' => ($radio_hoerercharts_Program_Name ?: $this->getTranslator()->trans('hoerercharts')), 'show_artwork' => $this->getConfig()->get('radio_hoerercharts_show_artwork'), 'show_registered_by' => $this->getConfig()->get('radio_hoerercharts_show_registered_by'),]; @@ -51,16 +52,16 @@ public function indexAction() $this->getView()->set('config', $hoererchartsconfig); $this->getView()->set('userMapper', $userMapper); - $this->getView()->set('votedatetime', ((!$start_datetime && !$end_datetime)?'':$this->getTranslator()->trans('votedatetime').(($start_datetime && $end_datetime)?call_user_func_array([$this->getTranslator(), 'trans'], ['fromto', $start_datetime->format($this->getTranslator()->trans('datetimeformat')),$end_datetime->format($this->getTranslator()->trans('datetimeformat'))]):(($start_datetime)?$this->getTranslator()->trans('from').' '.$start_datetime->format($this->getTranslator()->trans('datetimeformat')):$this->getTranslator()->trans('to').' '.$end_datetime->format($this->getTranslator()->trans('datetimeformat'))))."

")); - $vote_allowed = $hoererchartsMapper->vote_allowed($start_datetime, $end_datetime); + $this->getView()->set('votedatetime', ((!$start_datetime && !$end_datetime) ? '' : $this->getTranslator()->trans('votedatetime') . (($start_datetime && $end_datetime) ? call_user_func_array([$this->getTranslator(), 'trans'], ['fromto', $start_datetime->format($this->getTranslator()->trans('datetimeformat')), $end_datetime->format($this->getTranslator()->trans('datetimeformat'))]) : (($start_datetime) ? $this->getTranslator()->trans('from') . ' ' . $start_datetime->format($this->getTranslator()->trans('datetimeformat')) : $this->getTranslator()->trans('to') . ' ' . $end_datetime->format($this->getTranslator()->trans('datetimeformat')))) . "

")); + $vote_allowed = $hoererchartsMapper->voteAllowed($start_datetime, $end_datetime); $this->getView()->set('vote_allowed', $vote_allowed); - $show_sortedlist = $hoererchartsMapper->is_showsortedlist($end_datetime); + $show_sortedlist = $hoererchartsMapper->isShowSortedList($end_datetime); $this->getView()->set('show_sortedlist', $show_sortedlist); if ($hoererchartsMapper->checkDB() && $hoererchartssuggestionMapper->checkDB() && $hoererchartsuservotesMapper->checkDB()) { - if ($hoererchartsuservotesMapper->is_voted($this->getUser()) || !$vote_allowed) { + if ($hoererchartsuservotesMapper->isVoted($this->getUser()) || !$vote_allowed) { $this->getView()->set('voted', true); - + if ($show_sortedlist) { $this->getView()->set('entries', $hoererchartsMapper->getEntryByList(['l.list' => $this->getConfig()->get('radio_hoerercharts_active_list')], ['h.votes' => 'DESC','h.id' => 'DESC'])); } else { @@ -84,11 +85,11 @@ public function indexAction() $model->setId($voteId); } if ($this->getUser()) { - $model->setUser_Id($this->getUser()->getId()); + $model->setUserId($this->getUser()->getId()); } $model->setSessionId(session_id()); $model->setIp($hoererchartsuservotesMapper->getIp()); - $model->setLast_Activity($datenow); + $model->setLastActivity($datenow); $hoererchartsuservotesMapper->save($model); $hoererchartsuservotesMapper->setIsVotedCookie(session_id()); @@ -108,12 +109,12 @@ public function indexAction() $this->getView()->set('entries', $hoererchartsMapper->getEntryByList(['l.list' => $this->getConfig()->get('radio_hoerercharts_active_list')])); } - $this->getView()->set('gettext', (!empty($this->getRequest()->getParam('copy'))?$hoererchartsMapper->gettext():'')); + $this->getView()->set('gettext', (!empty($this->getRequest()->getParam('copy')) ? $hoererchartsMapper->gettext() : '')); } else { $this->addMessage('dbfail'); } } - + public function treatAction() { if ($this->getConfig()->get('radio_hoerercharts_allow_suggestion') && ((!$this->getUser() && $this->getConfig()->get('radio_hoerercharts_Guest_Allow')) || $this->getUser())) { @@ -122,7 +123,7 @@ public function treatAction() $radio_hoerercharts_Program_Name = $this->getConfig()->get('radio_hoerercharts_Program_Name'); - $Program_Name = ($radio_hoerercharts_Program_Name ? $radio_hoerercharts_Program_Name : $this->getTranslator()->trans('hoerercharts')); + $Program_Name = ($radio_hoerercharts_Program_Name ?: $this->getTranslator()->trans('hoerercharts')); if ($hoererchartssuggestionMapper->checkDB()) { $this->getLayout()->getTitle() @@ -131,13 +132,36 @@ public function treatAction() ->add($Program_Name, ['action' => 'index']) ->add($this->getTranslator()->trans('add'), ['action' => 'treat']); + if ($captchaNeeded) { + if (in_array((int)$this->getConfig()->get('captcha'), [2, 3])) { + $googlecaptcha = new \Captcha\GoogleCaptcha($this->getConfig()->get('captcha_apikey'), null, (int)$this->getConfig()->get('captcha')); + $this->getView()->set('googlecaptcha', $googlecaptcha); + } else { + $defaultcaptcha = new \Captcha\DefaultCaptcha(); + $this->getView()->set('defaultcaptcha', $defaultcaptcha); + } + } $this->getView()->set('captchaNeeded', $captchaNeeded); if ($this->getRequest()->isPost()) { - $validation = Validation::create($this->getRequest()->getPost(), array_merge([ + Validation::setCustomFieldAliases([ + 'grecaptcha' => 'token', + ]); + + $validationRules = [ 'interpret' => 'required', 'songtitel' => 'required' - ], ($captchaNeeded?['captcha' => 'captcha']:[]))); + ]; + + if ($captchaNeeded) { + if (in_array((int)$this->getConfig()->get('captcha'), [2, 3])) { + $validationRules['token'] = 'required|grecaptcha:save'; + } else { + $validationRules['captcha'] = 'required|captcha'; + } + } + + $validation = Validation::create($this->getRequest()->getPost(), $validationRules); if ($validation->isValid()) { $hoererchartsModel = new HoererChartsModel(); @@ -145,7 +169,7 @@ public function treatAction() $datenow = new \Ilch\Date($date->format("Y-m-d H:i:s", true)); if ($this->getUser()) { - $hoererchartsModel->setUser_Id($this->getUser()->getId()); + $hoererchartsModel->setUserId($this->getUser()->getId()); } $hoererchartsModel->setInterpret($this->getRequest()->getPost('interpret')) @@ -153,7 +177,9 @@ public function treatAction() ->setVotes(0) ->setDateCreate($datenow); - $hoererchartssuggestionMapper->save($hoererchartsModel); + $id = $hoererchartssuggestionMapper->save($hoererchartsModel); + + $this->addMessage($id); $this->redirect() ->withMessage('saveSuccess') diff --git a/controllers/admin/Index.php b/controllers/admin/Index.php index db296e0..e2539ee 100644 --- a/controllers/admin/Index.php +++ b/controllers/admin/Index.php @@ -1,4 +1,5 @@ getView()->set('allowsuggestion', $this->getConfig()->get('radio_hoerercharts_allow_suggestion')); $this->getView()->set('suggestion', $this->getRequest()->getParam('suggestion')); - + $activelist = $this->getConfig()->get('radio_hoerercharts_active_list'); $this->getView()->set('activelist', $activelist); $this->getView()->set('list', $this->getRequest()->getParam('list')); - + $this->getView()->set('filterlist', $this->getRequest()->getParam('filterlist')); - + + $listentries = []; if ($this->getRequest()->getParam('list')) { $listentries = $hoererchartslistMapper->getEntryByList($this->getRequest()->getParam('list')) ?? []; } - $this->getView()->set('votedatetime', ((!$start_datetime && !$end_datetime)?$this->getTranslator()->trans('noentriesadmin'):(($start_datetime && $end_datetime)?call_user_func_array([$this->getTranslator(), 'trans'], ['fromto', $start_datetime->format($this->getTranslator()->trans('datetimeformat')),$end_datetime->format($this->getTranslator()->trans('datetimeformat'))]):(($start_datetime)?$this->getTranslator()->trans('from').' '.$start_datetime->format($this->getTranslator()->trans('datetimeformat')):$this->getTranslator()->trans('to').' '.$end_datetime->format($this->getTranslator()->trans('datetimeformat'))))."

")); + $this->getView()->set('votedatetime', ((!$start_datetime && !$end_datetime) ? $this->getTranslator()->trans('noentriesadmin') : (($start_datetime && $end_datetime) ? call_user_func_array([$this->getTranslator(), 'trans'], ['fromto', $start_datetime->format($this->getTranslator()->trans('datetimeformat')), $end_datetime->format($this->getTranslator()->trans('datetimeformat'))]) : (($start_datetime) ? $this->getTranslator()->trans('from') . ' ' . $start_datetime->format($this->getTranslator()->trans('datetimeformat')) : $this->getTranslator()->trans('to') . ' ' . $end_datetime->format($this->getTranslator()->trans('datetimeformat')))) . "

")); if ($hoererchartsMapper->checkDB() && $hoererchartssuggestionMapper->checkDB() && $hoererchartsuservotesMapper->checkDB()) { if ($this->getRequest()->getPost('check_entries')) { if ($this->getRequest()->getPost('action') == 'delete') { @@ -136,7 +136,7 @@ public function indexAction() unset($sortItems[$keylist]); } } - foreach($sortItems as $key => $hid) { + foreach ($sortItems as $hid) { $id = $hoererchartslistMapper->addEntryToList($hid, $this->getRequest()->getParam('list')); $hoererchartslistModel = new HoererChartsListModel(); $hoererchartslistModel->setId($id) @@ -145,7 +145,7 @@ public function indexAction() $listentries[] = $hoererchartslistModel; } $this->addMessage('updateSuccess'); - + $this->redirect(['action' => 'index', 'list' => $this->getRequest()->getParam('list')]); } @@ -155,7 +155,7 @@ public function indexAction() } $column = $this->getRequest()->getParam('column') && in_array($this->getRequest()->getParam('column'), $columns) ? $this->getRequest()->getParam('column') : $columns[0]; $sort_order = $this->getRequest()->getParam('order') && strtolower($this->getRequest()->getParam('order')) == 'asc' ? 'ASC' : 'DESC'; - + if ($column === 'votes') { $suggestionentries = $hoererchartssuggestionMapper->getEntriesby([], [$columns[0] => $sort_order]); } else { @@ -166,9 +166,8 @@ public function indexAction() $this->getView()->set('listentries', $listentries); $chartsentries = $hoererchartsMapper->getEntriesby(['setfree' => 1]) ?? []; } else { - $chartsentries = $hoererchartsMapper->getEntriesby([], [$column => $sort_order]); if ($this->getRequest()->getParam('filterlist')) { - $chartsentries = $hoererchartsMapper->getEntryByList(['l.list' => $this->getRequest()->getParam('filterlist')], ['h.'.$column => $sort_order]); + $chartsentries = $hoererchartsMapper->getEntryByList(['l.list' => $this->getRequest()->getParam('filterlist')], ['h.' . $column => $sort_order]); } else { $chartsentries = $hoererchartsMapper->getEntriesby([], [$column => $sort_order]); } @@ -180,7 +179,7 @@ public function indexAction() $this->getView()->set('entries', $chartsentries); } - $this->getView()->set('badgeSuggestion', $suggestionentries?count($suggestionentries):0) + $this->getView()->set('badgeSuggestion', $suggestionentries ? count($suggestionentries) : 0) ->set('sort_column', $column) ->set('sort_order', $sort_order); } else { @@ -192,7 +191,7 @@ public function updateAction() { $hoererchartsMapper = new HoererChartsMapper(); if ($hoererchartsMapper->checkDB() && $this->getRequest()->isSecure()) { - $hoererchartsMapper->update_setfree($this->getRequest()->getParam('id'), $this->getRequest()->getParam('status_man')); + $hoererchartsMapper->updateSetFree($this->getRequest()->getParam('id'), $this->getRequest()->getParam('status_man')); $this->addMessage('saveSuccess'); } @@ -217,43 +216,45 @@ public function treatAction() if ($this->getRequest()->getParam('suggestion')) { $hoererchartsModel = $hoererchartssuggestionMapper->getEntryById($this->getRequest()->getParam('id')); - $this->getView()->set('entrie', $hoererchartsModel); } else { $hoererchartsModel = $hoererchartsMapper->getEntryById($this->getRequest()->getParam('id')); - $this->getView()->set('entrie', $hoererchartsModel); + } + if (!$hoererchartsModel) { + $this->redirect(['action' => 'index']); } } else { $this->getLayout()->getAdminHmenu() ->add($this->getTranslator()->trans('add'), ['action' => 'treat']); } + $this->getView()->set('entry', $hoererchartsModel); if ($this->getRequest()->isPost()) { $validation = Validation::create($this->getRequest()->getPost(), array_merge([ 'interpret' => 'required', 'songtitel' => 'required' - ], (($this->getRequest()->getParam('suggestion'))?[]:['setfree' => 'required|numeric|min:0|max:1']))); + ], (($this->getRequest()->getParam('suggestion')) ? [] : ['setfree' => 'required|numeric|min:0|max:1']))); if ($validation->isValid()) { $date = new \Ilch\Date(); $datenow = new \Ilch\Date($date->format("Y-m-d H:i:s", true)); - - if ($this->getRequest()->getParam('id')) { - $hoererchartsModel->setId($this->getRequest()->getParam('id')); - } else { + + if (!$hoererchartsModel->getId()) { if ($this->getUser()) { - $hoererchartsModel->setUser_Id($this->getUser()->getId()); + $hoererchartsModel->setUserId($this->getUser()->getId()); } $hoererchartsModel->setDateCreate($datenow); } if (!$this->getRequest()->getParam('suggestion')) { $hoererchartsModel->setSetFree($this->getRequest()->getPost('setfree')); - if ($this->getConfig()->get('radio_hoerercharts_show_artwork')) $hoererchartsModel->setArtworkUrl($this->getRequest()->getPost('artworkUrl')); + if ($this->getConfig()->get('radio_hoerercharts_show_artwork')) { + $hoererchartsModel->setArtworkUrl($this->getRequest()->getPost('artworkUrl') ?? ''); + } } if ($hoererchartsModel->getId() && ($hoererchartsModel->getInterpret() != $this->getRequest()->getPost('interpret') || $hoererchartsModel->getSongTitel() != $this->getRequest()->getPost('songtitel'))) { $hoererchartsModel->setVotes(0); } - + $hoererchartsModel->setInterpret($this->getRequest()->getPost('interpret')) ->setSongTitel($this->getRequest()->getPost('songtitel')); @@ -265,26 +266,26 @@ public function treatAction() $this->redirect() ->withMessage('saveSuccess') - ->to(array_merge(['action' => 'index'], (($this->getRequest()->getParam('suggestion'))?['suggestion' => 'true']:[]))); + ->to(array_merge(['action' => 'index'], (($this->getRequest()->getParam('suggestion')) ? ['suggestion' => 'true'] : []))); } $this->addMessage($validation->getErrorBag()->getErrorMessages(), 'danger', true); $this->redirect() ->withInput() ->withErrors($validation->getErrorBag()) - ->to(array_merge(['action' => 'treat', 'id' => $this->getRequest()->getParam('id')], (($this->getRequest()->getParam('suggestion'))?['suggestion' => 'true']:[]))); + ->to(array_merge(['action' => 'treat', 'id' => $this->getRequest()->getParam('id')], (($this->getRequest()->getParam('suggestion')) ? ['suggestion' => 'true'] : []))); } } else { - $this->redirect(array_merge(['action' => 'index'], (($this->getRequest()->getParam('suggestion'))?['suggestion' => 'true']:[]))); + $this->redirect(array_merge(['action' => 'index'], (($this->getRequest()->getParam('suggestion')) ? ['suggestion' => 'true'] : []))); } $this->getView()->set('show_artwork', $this->getConfig()->get('radio_hoerercharts_show_artwork')); } - + public function searchiTunesAction() { $this->getLayout()->setFile('modules/admin/layouts/ajax'); if ($this->getRequest()->isSecure()) { - $searchitunes = new SearchiTunes; + $searchitunes = new SearchiTunes(); $searchitunes->setTerm($this->getRequest()->getParam('term')) ->setCountry('DE') ->setMedia('music') @@ -295,7 +296,9 @@ public function searchiTunesAction() ->setExplicit(false) ->search(); - $this->getView()->set('entrie', ['URL' => $searchitunes->getResult('artworkUrl100', 1)]); + $this->getView()->set('entry', ['URL' => $searchitunes->getResult('artworkUrl100', 1)]); + } else { + $this->getView()->set('entry', []); } } @@ -314,7 +317,7 @@ public function delAction() $this->addMessage('deleteSuccess'); } } - $this->redirect(array_merge(['action' => 'index'], (($this->getRequest()->getParam('suggestion'))?['suggestion' => 'true']:[]))); + $this->redirect(array_merge(['action' => 'index'], (($this->getRequest()->getParam('suggestion')) ? ['suggestion' => 'true'] : []))); } public function allowsuggestionAction() @@ -326,7 +329,7 @@ public function allowsuggestionAction() ->withMessage('updateSuccess') ->to(['action' => 'index', 'suggestion' => 'true']); } - + public function activelistAction() { $this->getConfig()->set('radio_hoerercharts_active_list', $this->getRequest()->getParam('list')); @@ -335,7 +338,7 @@ public function activelistAction() ->withMessage('updateSuccess') ->to(['action' => 'index', 'list' => $this->getRequest()->getParam('list')]); } - + public function suggestionenableAction() { $hoererchartsMapper = new HoererChartsMapper(); @@ -373,6 +376,6 @@ public function resetAction() } } - $this->getView()->set('entries', $hoererchartsuservotesMapper->getEntries([]) ?? []); + $this->getView()->set('entries', $hoererchartsuservotesMapper->getEntries() ?? []); } } diff --git a/controllers/admin/Settings.php b/controllers/admin/Settings.php index 446aeb3..66dc5ac 100644 --- a/controllers/admin/Settings.php +++ b/controllers/admin/Settings.php @@ -1,4 +1,5 @@ getConfig()->get('radio_hoerercharts_Program_Name'); - $Program_Name = ($radio_hoerercharts_Program_Name ? $radio_hoerercharts_Program_Name : $this->getTranslator()->trans('hoerercharts')); + $Program_Name = ($radio_hoerercharts_Program_Name ?: $this->getTranslator()->trans('hoerercharts')); $this->getView()->set('Program_Name', $Program_Name); @@ -100,14 +101,14 @@ public function indexAction() $this->redirect() ->withMessage('saveSuccess') - ->to(array_merge(['action' => 'index'], ($this->getRequest()->getParam('settings_language')?['settings_language' => 'true']:[]))); + ->to(array_merge(['action' => 'index'], ($this->getRequest()->getParam('settings_language') ? ['settings_language' => 'true'] : []))); } $this->addMessage($validation->getErrorBag()->getErrorMessages(), 'danger', true); $this->redirect() ->withInput() ->withErrors($validation->getErrorBag()) - ->to(array_merge(['action' => 'index'], ($this->getRequest()->getParam('settings_language')?['settings_language' => 'true']:[]))); + ->to(array_merge(['action' => 'index'], ($this->getRequest()->getParam('settings_language') ? ['settings_language' => 'true'] : []))); } if (!$this->getRequest()->getParam('settings_language')) { @@ -130,7 +131,7 @@ public function indexAction() $language = new \Ilch\Translator('de_DE'); } - $language->load(APPLICATION_PATH.'/modules/radiohoerercharts/translations'); + $language->load(APPLICATION_PATH . '/modules/radiohoerercharts/translations'); $language_votetext = $language->trans('votetext'); if ($this->getTranslator()->shortenLocale($this->getTranslator()->getLocale()) == 'de') { @@ -206,8 +207,8 @@ public function votedatetimeAction() $end_datetime = new \Ilch\Date($this->getConfig()->get('radio_hoerercharts_End_Datetime')); } - $this->getView()->set('start_datetime', (($start_datetime)?$start_datetime->format($this->getTranslator()->trans('datetimeformat')):'')) - ->set('end_datetime', (($end_datetime)?$end_datetime->format($this->getTranslator()->trans('datetimeformat')):'')); + $this->getView()->set('start_datetime', (($start_datetime) ? $start_datetime->format($this->getTranslator()->trans('datetimeformat')) : '')) + ->set('end_datetime', (($end_datetime) ? $end_datetime->format($this->getTranslator()->trans('datetimeformat')) : '')); } } } diff --git a/libs/SearchiTunes.php b/libs/SearchiTunes.php index a2af476..f4e4018 100644 --- a/libs/SearchiTunes.php +++ b/libs/SearchiTunes.php @@ -2,10 +2,16 @@ namespace Modules\RadioHoererCharts\Libs; -class SearchiTunes { - - const REQUEST_SEARCH = 1; - const REQUEST_LOOKUP = 2; +class SearchiTunes +{ + /** + * @var int + */ + public const REQUEST_SEARCH = 1; + /** + * @var int + */ + public const REQUEST_LOOKUP = 2; /** * The API url @@ -13,51 +19,90 @@ class SearchiTunes { * @var string */ protected $apiUrl = 'https://itunes.apple.com/'; - - protected $parameters = null; - protected $debug = 0; + + /** + * @var array + */ + protected $parameters = []; + + /** + * @var bool + */ + protected $debug = false; + /** + * @var mixed + */ protected $result = null; + /** + * @var string + */ protected $url = ''; - - - protected $term = null; - protected $country = null; // US + + /** + * @var string + */ + protected $term = ''; + /** + * @var string + */ + protected $country = ''; // US + /** + * @var string|null + */ protected $media = null; // https://developer.apple.com/library/archive/documentation/AudioVideo/Conceptual/iTuneSearchAPI/Searching.html#//apple_ref/doc/uid/TP40017632-CH5-SW3 - protected $entity = null; - protected $attribute = null; - protected $limit = null; // 1 to 200 - protected $lang = null; // en_us - protected $explicit = null; // Yes, No - - protected $lookup = 'id'; // id, amgArtistId, amgAlbumId, upc, amgVideoId, isbn - protected $sort = 'recent'; + /** + * @var string + */ + protected $entity = ''; + /** + * @var string + */ + protected $attribute = ''; + /** + * @var int + */ + protected $limit = 0; // 1 to 200 + /** + * @var string + */ + protected $lang = ''; // en_us + /** + * @var bool + */ + protected $explicit = false; // Yes, No + /** + * @var string|null + */ + protected $lookup = 'id'; // id, amgArtistId, amgAlbumId, upc, amgVideoId, isbn /** * SearchiTunes constructor. * - * @param $term string|null Wargaming Application API Key - * @param $country string|null Wargaming Application API Secret - * @param $media string|null Wargaming Application API Secret - * @param $entity string|null OAuth Token - * @param $attribute string|null OAuth Token Secret - * @param $limit int|null The callback Url - * @param $lang string|null The callback Url - * @param $explicit bool|null The callback Url - */ - public function __construct($term = null, $entity = null) - { - if ($term) $this->setTerm($term); - if ($entity) $this->setTerm($entity); + * @param string|null $term + * @param string|null $entity + */ + public function __construct(?string $term = null, ?string $entity = null) + { + if ($term) { + $this->setTerm($term); + } + if ($entity) { + $this->setEntity($entity); + } return $this; } /** * max 20 calls per minute + * @param string|null $term + * @return false|SearchiTunes */ - public function search($term = null) + public function search(?string $term = null) { - if ($term) $this->setTerm($term); + if ($term) { + $this->setTerm($term); + } if ($this->getTerm()) { $this->makeRequest(self::REQUEST_SEARCH); @@ -66,13 +111,17 @@ public function search($term = null) return false; } } - + /** * max 20 calls per minute + * @param string|null $term + * @return false|SearchiTunes */ - public function lookup($term = null) + public function lookup(?string $term = null) { - if ($term) $this->setTerm($term); + if ($term) { + $this->setTerm($term); + } if ($this->getTerm()) { $this->makeRequest(self::REQUEST_LOOKUP); @@ -85,13 +134,11 @@ public function lookup($term = null) /** * Makes the actual request * - * @param $type - * - * @throws Exception + * @param int $type * * @return void */ - protected function makeRequest($type) + protected function makeRequest(int $type) { $this->makeParameters($type); $this->makeUrl($type); @@ -122,82 +169,107 @@ protected function makeRequest($type) /** * @return string */ - public function getApiUrl() + public function getApiUrl(): string { return $this->apiUrl; } /** * @param string $apiUrl + * @return SearchiTunes */ - public function setApiUrl(string $apiUrl) + public function setApiUrl(string $apiUrl): SearchiTunes { - $this->apiUrl = (string) $apiUrl; + $this->apiUrl = $apiUrl; return $this; } - + /** * @return string */ - public function getUrl() + public function getUrl(): string { return $this->url; } /** - * @param string $apiUrl + * @param string $url + * @return SearchiTunes */ - public function setUrl(string $url) + public function setUrl(string $url): SearchiTunes { - $this->url = (string) $url; + $this->url = $url; return $this; } - + /** - * @param string $apiUrl + * @param int $type + * @return SearchiTunes */ - public function makeUrl($type) + public function makeUrl(int $type): SearchiTunes { $this->setUrl(''); if ($this->getParameters()) { - switch($type) { + switch ($type) { case self::REQUEST_SEARCH: - $this->setUrl($this->getApiUrl().'search?'.http_build_query($this->getParameters())); + $this->setUrl($this->getApiUrl() . 'search?' . http_build_query($this->getParameters())); break; case self::REQUEST_LOOKUP: - $this->setUrl($this->getApiUrl().'lookup?'.http_build_query($this->getParameters())); + $this->setUrl($this->getApiUrl() . 'lookup?' . http_build_query($this->getParameters())); break; } } - + return $this; } - + /** * Obtains the needed tokens + * @param int $type + * @return SearchiTunes */ - public function makeParameters($type) + public function makeParameters(int $type): SearchiTunes { $this->setParameters(null); - - switch($type) { + + switch ($type) { case self::REQUEST_SEARCH: if ($this->getTerm() && $this->getCountry()) { - if ($this->getTerm()) $this->setParameter('term', $this->getTerm()); - if ($this->getCountry()) $this->setParameter('country', $this->getCountry()); - if ($this->getMedia()) $this->setParameter('media', $this->getMedia()); - if ($this->getEntity()) $this->setParameter('entity', $this->getEntity()); - if ($this->getAttribute()) $this->setParameter('attribute', $this->getAttribute()); - if ($this->getLimit()) $this->setParameter('limit', $this->getLimit()); - if ($this->getLang()) $this->setParameter('lang', $this->getLang()); - if ($this->getExplicit()) $this->setParameter('explicit', ($this->getExplicit()?'Yes':'No')); + if ($this->getTerm()) { + $this->setParameter('term', $this->getTerm()); + } + if ($this->getCountry()) { + $this->setParameter('country', $this->getCountry()); + } + if ($this->getMedia()) { + $this->setParameter('media', $this->getMedia()); + } + if ($this->getEntity()) { + $this->setParameter('entity', $this->getEntity()); + } + if ($this->getAttribute()) { + $this->setParameter('attribute', $this->getAttribute()); + } + if ($this->getLimit()) { + $this->setParameter('limit', $this->getLimit()); + } + if ($this->getLang()) { + $this->setParameter('lang', $this->getLang()); + } + $this->setParameter('explicit', ($this->getExplicit() ? 'Yes' : 'No')); } break; case self::REQUEST_LOOKUP: if ($this->getLookup() && $this->getTerm()) { - if ($this->getTerm()) $this->setParameter($this->getLookup(), $this->getTerm()); - if ($this->getEntity()) $this->setParameter('entity', $this->getEntity()); - if ($this->getLimit()) $this->setParameter('limit', $this->getLimit()); + if ($this->getTerm()) { + $this->setParameter($this->getLookup(), $this->getTerm()); + } + if ($this->getEntity()) { + $this->setParameter('entity', $this->getEntity()); + } + if ($this->getLimit()) { + $this->setParameter('limit', $this->getLimit()); + } } break; } @@ -207,38 +279,49 @@ public function makeParameters($type) /** * @return array */ - public function getParameters() + public function getParameters(): array { return $this->parameters; } /** - * @param array $parameters + * @param array|null $parameters + * @return SearchiTunes */ - public function setParameters($parameters) + public function setParameters(?array $parameters): SearchiTunes { + if (!$parameters) { + $parameters = []; + } $this->parameters = $parameters; + + return $this; } - public function setParameter($key, $value) + /** + * @param $key + * @param $value + * @return SearchiTunes + */ + public function setParameter($key, $value): SearchiTunes { $this->parameters[$key] = $value; return $this; } - + /** * @return bool */ - public function hasParameters() + public function hasParameters(): bool { - return !empty($this->getParameters()); + return count($this->getParameters()) > 0; } /** * @return bool */ - public function isDebug() + public function isDebug(): bool { return $this->debug; } @@ -266,16 +349,18 @@ public function setResults($result) { $this->result = $result; } - + /** + * @param string|null $key + * @param int|null $id * @return mixed */ - public function getResult($key = null, $id = null) + public function getResult(?string $key = null, ?int $id = null) { if (!$key && !$id) { return $this->getResults(); } - + $keys = [ 'wrapperType', 'collectionType', 'artistId', @@ -297,16 +382,16 @@ public function getResult($key = null, $id = null) 'releaseDate', 'primaryGenreName', ]; - + if ($key && !in_array($key, $keys)) { return false; } - - if ($id && isset($this->result[$id-1])){ + + if ($id && isset($this->result[$id - 1])) { if ($key) { - return $this->result[$id-1][$key] ?? ''; + return $this->result[$id - 1][$key] ?? ''; } else { - return $this->result[$id-1]; + return $this->result[$id - 1]; } } elseif (!$id) { $result = []; @@ -318,40 +403,56 @@ public function getResult($key = null, $id = null) return null; } } - - - - - - public function getTerm() + /** + * @return string + */ + public function getTerm(): string { return $this->term; } - public function setTerm(string $term) + /** + * @param string $term + * @return SearchiTunes + */ + public function setTerm(string $term): SearchiTunes { - $this->term = (string) $term; + $this->term = $term; return $this; } - - public function getCountry() + + /** + * @return string + */ + public function getCountry(): string { return $this->country; } - public function setCountry(string $country) + /** + * @param string $country + * @return SearchiTunes + */ + public function setCountry(string $country): SearchiTunes { - $this->country = (string) $country; + $this->country = $country; return $this; } - - public function getMedia() + + /** + * @return null|string + */ + public function getMedia(): ?string { return $this->media; } - public function setMedia(string $media) + /** + * @param string|null $media + * @return SearchiTunes + */ + public function setMedia(?string $media): SearchiTunes { $keys = [ 'movie', 'podcast', @@ -365,21 +466,26 @@ public function setMedia(string $media) 'all', ]; if ($media && in_array($media, $keys)) { - $this->media = (string) $media; + $this->media = $media; } else { $this->media = null; } return $this; } - - public function getEntity() + + public function getEntity(): string { if ($this->getMedia()) { return $this->entity; } + return ''; } - public function setEntity(string $entity) + /** + * @param string $entity + * @return SearchiTunes + */ + public function setEntity(string $entity): SearchiTunes { $keys = [ 'movie' => [ 'movieArtist', 'movie', @@ -424,21 +530,22 @@ public function setEntity(string $entity) ], ]; if ($this->getMedia() && $entity && isset($keys[$this->getMedia()]) && in_array($entity, $keys[$this->getMedia()])) { - $this->entity = (string) $entity; + $this->entity = $entity; } else { $this->entity = ''; } return $this; } - - public function getAttribute() + + public function getAttribute(): string { if ($this->getMedia()) { return $this->attribute; } + return ''; } - public function setAttribute(string $attribute) + public function setAttribute(string $attribute): SearchiTunes { $keys = [ 'movie' => [ 'actorTerm', 'genreIndex', @@ -526,53 +633,77 @@ public function setAttribute(string $attribute) ], ]; if ($this->getMedia() && $attribute && isset($keys[$this->getMedia()]) && in_array($attribute, $keys[$this->getMedia()])) { - $this->attribute = (string) $attribute; + $this->attribute = $attribute; } else { $this->attribute = ''; } return $this; } - - - public function getLimit() + + + /** + * @return int + */ + public function getLimit(): int { return $this->limit; } - public function setLimit(int $limit) + public function setLimit(int $limit): SearchiTunes { - $this->limit = (int) $limit; + $this->limit = $limit; return $this; } - - public function getLang() + + /** + * @return string + */ + public function getLang(): string { return $this->lang; } - public function setLang(string $lang) + /** + * @param string $lang + * @return SearchiTunes + */ + public function setLang(string $lang): SearchiTunes { - $this->lang = (string) $lang; + $this->lang = $lang; return $this; } - - public function getExplicit() + + /** + * @return bool + */ + public function getExplicit(): bool { return $this->explicit; } - public function setExplicit(bool $explicit) + /** + * @param bool $explicit + * @return SearchiTunes + */ + public function setExplicit(bool $explicit): SearchiTunes { $this->explicit = $explicit; return $this; } - - public function getLookup() + + /** + * @return null|string + */ + public function getLookup(): ?string { return $this->lookup; } - public function setLookup(string $lookup) + /** + * @param string $lookup + * @return SearchiTunes + */ + public function setLookup(string $lookup): SearchiTunes { $keys = [ 'id', 'amgArtistId', @@ -582,11 +713,10 @@ public function setLookup(string $lookup) 'isbn', ]; if ($lookup && in_array($lookup, $keys)) { - $this->lookup = (string) $lookup; + $this->lookup = $lookup; } else { $this->lookup = null; } return $this; } - } diff --git a/mappers/HoererCharts.php b/mappers/HoererCharts.php index 02beaf0..94b2ec3 100644 --- a/mappers/HoererCharts.php +++ b/mappers/HoererCharts.php @@ -1,4 +1,5 @@ db()->ifTableExists('[prefix]_radio_hoerercharts'); + return $this->db()->ifTableExists($this->tablename); } /** @@ -26,13 +37,13 @@ public function checkDB() * * @param array $where * @param array $orderBy - * @param \Ilch\Pagination|null $pagination - * @return array|null + * @param Pagination|null $pagination + * @return EntriesModel[]|null */ - public function getEntriesBy($where = [], $orderBy = ['id' => 'DESC'], $pagination = null) + public function getEntriesBy(array $where = [], array $orderBy = ['id' => 'DESC'], ?Pagination $pagination = null): ?array { $select = $this->db()->select('*') - ->from('radio_hoerercharts') + ->from($this->tablename) ->where($where) ->order($orderBy); @@ -45,35 +56,29 @@ public function getEntriesBy($where = [], $orderBy = ['id' => 'DESC'], $paginati $result = $select->execute(); } - $entryArray = $result->fetchRows(); - if (empty($entryArray)) { + $entriesArray = $result->fetchRows(); + if (empty($entriesArray)) { return null; } - $entrys = []; + $entries = []; - foreach ($entryArray as $entries) { + foreach ($entriesArray as $entry) { $entryModel = new EntriesModel(); - $entryModel->setId($entries['id']) - ->setSetFree($entries['setfree']) - ->setInterpret($entries['interpret']) - ->setSongTitel($entries['songtitel']) - ->setVotes($entries['votes']) - ->setDateCreate($entries['datecreate']) - ->setUser_Id($entries['user_id']) - ->setArtworkUrl($entries['artworkUrl']); - $entrys[] = $entryModel; + $entryModel->setByArray($entry); + + $entries[] = $entryModel; } - return $entrys; + return $entries; } /** * Gets the Entries. * * @param array $where - * @param \Ilch\Pagination|null $pagination - * @return array|null + * @param Pagination|null $pagination + * @return EntriesModel[]|null */ - public function getEntries($where = [], $pagination = null) + public function getEntries(array $where = [], ?Pagination $pagination = null): ?array { return $this->getEntriesBy($where, ['setfree' => 'DESC', 'id' => 'DESC'], $pagination); } @@ -84,31 +89,31 @@ public function getEntries($where = [], $pagination = null) * @param int $id * @return null|EntriesModel */ - public function getEntryById(int $id) + public function getEntryById(int $id): ?EntriesModel { - $entrys = $this->getEntriesBy(['id' => (int)$id], []); + $entries = $this->getEntriesBy(['id' => $id], []); - if (!empty($entrys)) { - return reset($entrys); + if (!empty($entries)) { + return reset($entries); } - + return null; } - + /** * Gets the entry by given ID. * * @param array $where - * @param array $orderBy_ - * @param \Ilch\Pagination|null $pagination - * @return null|array + * @param array $orderBy + * @param Pagination|null $pagination + * @return null|EntriesModel[] */ - public function getEntryByList($where = [], $orderBy = ['h.id' => 'DESC'], $pagination = null) + public function getEntryByList(array $where = [], array $orderBy = ['h.id' => 'DESC'], ?Pagination $pagination = null): ?array { $select = $this->db()->select() ->fields(['h.id', 'h.setfree', 'h.interpret', 'h.songtitel', 'h.votes', 'h.datecreate', 'h.user_id', 'h.artworkUrl']) - ->from(['h' => 'radio_hoerercharts']) - ->join(['l' => 'radio_hoerercharts_list'], 'h.id = l.hid', 'LEFT', ['l.list']) + ->from(['h' => $this->tablename]) + ->join(['l' => $this->tablenameList], 'h.id = l.hid', 'LEFT', ['l.list']) ->where($where) ->order($orderBy); @@ -121,89 +126,77 @@ public function getEntryByList($where = [], $orderBy = ['h.id' => 'DESC'], $pagi $result = $select->execute(); } - $entryArray = $result->fetchRows(); - if (empty($entryArray)) { + $entriesArray = $result->fetchRows(); + if (empty($entriesArray)) { return null; } - $entrys = []; + $entries = []; - foreach ($entryArray as $entries) { + foreach ($entriesArray as $entryArray) { $entryModel = new EntriesModel(); - $entryModel->setId($entries['id']) - ->setSetFree($entries['setfree']) - ->setInterpret($entries['interpret']) - ->setSongTitel($entries['songtitel']) - ->setVotes($entries['votes']) - ->setDateCreate($entries['datecreate']) - ->setUser_Id($entries['user_id']) - ->setArtworkUrl($entries['artworkUrl']); - $entrys[] = $entryModel; + $entryModel->setByArray($entryArray); + + $entries[] = $entryModel; } - return $entrys; + return $entries; } /** * Inserts or updates entry. * * @param EntriesModel $model - * @return boolean|integer + * @return int */ - public function save(EntriesModel $model) + public function save(EntriesModel $model): int { - $fields = [ - 'setfree' => $model->getSetFree(), - 'interpret' => $model->getInterpret(), - 'songtitel' => $model->getSongTitel(), - 'votes' => $model->getVotes(), - 'datecreate' => $model->getDateCreate(), - 'user_id' => $model->getUser_Id(), - 'artworkUrl' => $model->getArtworkUrl(), - ]; + $fields = $model->getArray(false); + if (str_ends_with($this->tablename, 'suggestion')) { + unset($fields['setfree'], $fields['votes'], $fields['artworkUrl']); + } if ($model->getId()) { - $result = $this->db()->update('radio_hoerercharts') + $this->db()->update($this->tablename) ->values($fields) ->where(['id' => $model->getId()]) ->execute(); + $result = $model->getId(); } else { - $result = $this->db()->insert('radio_hoerercharts') + $result = $this->db()->insert($this->tablename) ->values($fields) ->execute(); } return $result; } - + /** * Updates Entrie setfree with given id. * * @param int $id - * @param int $setfree_man - * @return boolean + * @param int $setFreeMan + * @return bool */ - public function update_setfree(int $id, int $setfree_man) + public function updateSetFree(int $id, int $setFreeMan): bool { - if ($setfree_man != -1) { - $setfree_now = (int)$setfree_man; + if ($setFreeMan != -1) { + $setFreeNow = $setFreeMan; } else { - $setfree = (int) $this->db()->select('setfree') - ->from('radio_hoerercharts') - ->where(['id' => (int)$id]) + $setFree = (int) $this->db()->select('setfree') + ->from($this->tablename) + ->where(['id' => $id]) ->execute() ->fetchCell(); - if ($setfree == 1) { - $setfree_now = 0; + if ($setFree == 1) { + $setFreeNow = 0; } else { - $setfree_now = 1; + $setFreeNow = 1; } } - $result = $this->db()->update('radio_hoerercharts') - ->values(['setfree' => $setfree_now]) - ->where(['id' => (int)$id]) + return $this->db()->update($this->tablename) + ->values(['setfree' => $setFreeNow]) + ->where(['id' => $id]) ->execute(); - - return $result; } /** @@ -211,28 +204,26 @@ public function update_setfree(int $id, int $setfree_man) * * @param int $id * @param int $votes_man - * @return boolean + * @return bool */ - public function update(int $id, int $votes_man) + public function update(int $id, int $votes_man): bool { if ($votes_man != -1) { - $votes_now = (int)$votes_man; + $votes_now = $votes_man; } else { $votes = (int) $this->db()->select('votes') - ->from('radio_hoerercharts') - ->where(['id' => (int)$id]) + ->from($this->tablename) + ->where(['id' => $id]) ->execute() ->fetchCell(); $votes_now = $votes + 1; } - $result = $this->db()->update('radio_hoerercharts') + return $this->db()->update($this->tablename) ->values(['votes' => $votes_now]) - ->where(['id' => (int)$id]) + ->where(['id' => $id]) ->execute(); - - return $result; } /** @@ -240,34 +231,34 @@ public function update(int $id, int $votes_man) * * @return String */ - public function gettext() + public function gettext(): string { - $configClass = '\\Modules\\'.ucfirst('RadioHoererCharts').'\\Config\\Config'; + $configClass = '\\Modules\\' . ucfirst('RadioHoererCharts') . '\\Config\\Config'; $config = new $configClass(); - return " -> © by Dennis Reilard alias hhunderter (Version: ".$config->config['version'].")"; + return " -> © by Dennis Reilard alias hhunderter (Version: " . $config->config['version'] . ")"; } /** * Deletes the entry. * * @param integer $id - * @return boolean + * @return bool */ - public function delete(int $id) + public function delete(int $id): bool { - return $this->db()->delete('radio_hoerercharts') - ->where(['id' => (int)$id]) + return $this->db()->delete($this->tablename) + ->where(['id' => $id]) ->execute(); } /** * Reset the Vote counts. * - * @return boolean + * @return bool */ - public function reset() + public function reset(): bool { - return $this->db()->update('radio_hoerercharts') + return $this->db()->update($this->tablename) ->values(['votes' => 0]) ->execute(); } @@ -298,11 +289,17 @@ public function getStars(int $votes = 0, bool $showstars = false) $starcount = 1; } elseif ($votes < $config->get('radio_hoerercharts_Star1')) { $starcount = 0; + } else { + $starcount = 0; } $stars = ''; - for ($i = 1; $i <= $starcount; $i++) $stars .= ''; - for ($i = 1; $i <= 5-$starcount; $i++) $stars .= ''; + for ($i = 1; $i <= $starcount; $i++) { + $stars .= ''; + } + for ($i = 1; $i <= 5 - $starcount; $i++) { + $stars .= ''; + } } else { $stars = $votes; } @@ -312,50 +309,50 @@ public function getStars(int $votes = 0, bool $showstars = false) /** * Checks if voting is allowed. * - * @param null|\Ilch\Date $start_datetime - * @param null|\Ilch\Date $end_datetime - * @return boolean + * @param Date|null $startDatetime + * @param Date|null $endDatetime + * @return bool */ - public function vote_allowed($start_datetime = null, $end_datetime = null) + public function voteAllowed(?Date $startDatetime = null, ?Date $endDatetime = null): bool { - $date = new \Ilch\Date(); - $datenow = new \Ilch\Date($date->format("Y-m-d H:i:s", true)); + $date = new Date(); + $datenow = new Date($date->format("Y-m-d H:i:s", true)); - if (!$start_datetime && !$end_datetime) { + if (!$startDatetime && !$endDatetime) { return true; } else { - if ($start_datetime) { - if (!$end_datetime) { - return ($datenow->getTimestamp() >= $start_datetime->getTimestamp()); + if ($startDatetime) { + if (!$endDatetime) { + return ($datenow->getTimestamp() >= $startDatetime->getTimestamp()); } } - if ($end_datetime) { - if (!$start_datetime) { - return ($datenow->getTimestamp() <= $end_datetime->getTimestamp()); + if ($endDatetime) { + if (!$startDatetime) { + return ($datenow->getTimestamp() <= $endDatetime->getTimestamp()); } } - return ($datenow->getTimestamp() >= $start_datetime->getTimestamp() && $datenow->getTimestamp() <= $end_datetime->getTimestamp()); + return ($datenow->getTimestamp() >= $startDatetime->getTimestamp() && $datenow->getTimestamp() <= $endDatetime->getTimestamp()); } } /** * Checks if Time to show the Final list. * - * @param null|\Ilch\Date $end_datetime - * @return boolean + * @param Date|null $end_datetime + * @return bool */ - public function is_showsortedlist($end_datetime = null) + public function isShowSortedList(?Date $end_datetime = null): bool { $config = \Ilch\Registry::get('config'); $program_secduration = $config->get('radio_hoerercharts_Program_sec_duration'); - $date = new \Ilch\Date(); - $datenow = new \Ilch\Date($date->format("Y-m-d H:i:s", true)); + $date = new Date(); + $datenow = new Date($date->format("Y-m-d H:i:s", true)); if (!$end_datetime) { return true; } else { - return ($datenow->getTimestamp() >= ($end_datetime->getTimestamp()+$program_secduration)); + return ($datenow->getTimestamp() >= ($end_datetime->getTimestamp() + $program_secduration)); } } @@ -364,7 +361,7 @@ public function is_showsortedlist($end_datetime = null) * * @return String */ - public function getvotetext() + public function getVoteText(): string { $config = \Ilch\Registry::get('config'); $translator = \Ilch\Registry::get('translator'); @@ -375,7 +372,7 @@ public function getvotetext() } $radio_hoerercharts_Program_Name = $config->get('radio_hoerercharts_Program_Name'); - $Program_Name = ($radio_hoerercharts_Program_Name ? $radio_hoerercharts_Program_Name : $translator->trans('hoerercharts')); - return str_replace(['--user--', '--name--'], [((!$config->get('guestallow'))?$translator->trans('votetextuser'):$translator->trans('votetextguest')), $Program_Name], $votetext); + $Program_Name = ($radio_hoerercharts_Program_Name ?: $translator->trans('hoerercharts')); + return str_replace(['--user--', '--name--'], [((!$config->get('guestallow')) ? $translator->trans('votetextuser') : $translator->trans('votetextguest')), $Program_Name], $votetext); } } diff --git a/mappers/HoererChartsList.php b/mappers/HoererChartsList.php index 330b66c..055ecec 100644 --- a/mappers/HoererChartsList.php +++ b/mappers/HoererChartsList.php @@ -1,4 +1,5 @@ db()->ifTableExists('[prefix]_radio_hoerercharts_list'); + return $this->db()->ifTableExists($this->tablename); } /** @@ -28,12 +33,12 @@ public function checkDB() * @param array $where * @param array $orderBy * @param \Ilch\Pagination|null $pagination - * @return array|null + * @return EntriesModel[]|null */ - public function getEntriesBy($where = [], $orderBy = ['id' => 'DESC'], $pagination = null) + public function getEntriesBy(array $where = [], array $orderBy = ['id' => 'DESC'], ?\Ilch\Pagination $pagination = null): ?array { $select = $this->db()->select('*') - ->from('radio_hoerercharts_list') + ->from($this->tablename) ->where($where) ->order($orderBy); @@ -46,30 +51,29 @@ public function getEntriesBy($where = [], $orderBy = ['id' => 'DESC'], $paginati $result = $select->execute(); } - $entryArray = $result->fetchRows(); - if (empty($entryArray)) { + $entriesArray = $result->fetchRows(); + if (empty($entriesArray)) { return null; } - $entrys = []; - + $entries = []; + $entriesMapper = new EntriesMapper(); - foreach ($entryArray as $entries) { - $entriesmapperModel = $entriesMapper->getEntryById($entries['hid']); - if ($entriesmapperModel && $entriesmapperModel->getSetFree() === 1) { + foreach ($entriesArray as $entryArray) { + $hoererChartsModel = $entriesMapper->getEntryById($entryArray['hid']); + if ($hoererChartsModel && $hoererChartsModel->getSetFree()) { $entryModel = new EntriesModel(); - $entryModel->setId($entries['id']) - ->setHId($entries['hid']) - ->setEntry($entriesMapper->getEntryById($entries['hid'])) - ->setList($entries['list']); - $entrys[] = $entryModel; + $entryModel->setByArray($entryArray) + ->setEntry($hoererChartsModel); + + $entries[] = $entryModel; } else { - $this->db()->delete('radio_hoerercharts_list') - ->where(['id' => $entries['id']]) - ->execute(); + $this->db()->delete($this->tablename) + ->where(['id' => $entryArray['id']]) + ->execute(); } } - return $entrys; + return $entries; } /** @@ -77,41 +81,42 @@ public function getEntriesBy($where = [], $orderBy = ['id' => 'DESC'], $paginati * * @param array $where * @param \Ilch\Pagination|null $pagination - * @return array|null + * @return EntriesModel[]|null */ - public function getEntries($where = [], $pagination = null) + public function getEntries(array $where = [], ?\Ilch\Pagination $pagination = null): ?array { return $this->getEntriesBy($where, ['list' => 'DESC', 'id' => 'DESC'], $pagination); } - + /** * Gets the entry by given List ID. * * @param int $id - * @return null|EntriesModel + * @return EntriesModel[]|null */ - public function getEntryByList(int $id) + public function getEntryByList(int $id): ?array { - $entrys = $this->getEntriesBy(['list' => (int) $id], []); + $entries = $this->getEntriesBy(['list' => $id], []); - if (!empty($entrys)) { - return $entrys; + if (!empty($entries)) { + return $entries; } - + return null; } /** * Add H ID to a List. * - * @param int $hId + * @param int $hID * @param int $listId + * @return bool|int */ public function addEntryToList(int $hID, int $listId) { - if (!$this->getEntriesBy(['hid' => (int) $hID, 'list' => (int) $listId])) { - return $this->db()->insert('radio_hoerercharts_list') - ->values(['hid' => (int) $hID, 'list' => (int) $listId]) + if (!$this->getEntriesBy(['hid' => $hID, 'list' => $listId])) { + return $this->db()->insert($this->tablename) + ->values(['hid' => $hID, 'list' => $listId]) ->execute(); } return false; @@ -120,17 +125,17 @@ public function addEntryToList(int $hID, int $listId) /** * Delete H ID to a List. * - * @param int $hId + * @param int $hID * @param int $listId + * @return bool|int */ public function deleteEntryToList(int $hID, int $listId) { - if ($this->getEntriesBy(['hid' => (int) $hID, 'list' => (int) $listId])) { - return $this->db()->delete('radio_hoerercharts_list') - ->where(['hid' => (int) $hID, 'list' => (int) $listId]) + if ($this->getEntriesBy(['hid' => $hID, 'list' => $listId])) { + return $this->db()->delete($this->tablename) + ->where(['hid' => $hID, 'list' => $listId]) ->execute(); } return false; } - } diff --git a/mappers/HoererChartsSuggestion.php b/mappers/HoererChartsSuggestion.php index c064305..6683616 100644 --- a/mappers/HoererChartsSuggestion.php +++ b/mappers/HoererChartsSuggestion.php @@ -1,4 +1,5 @@ db()->ifTableExists('[prefix]_radio_hoerercharts_suggestion'); - } - - /** - * Gets the Entries by param. - * - * @param array $where - * @param array $orderBy - * @param \Ilch\Pagination|null $pagination - * @return array|null - */ - public function getEntriesBy($where = [], $orderBy = ['id' => 'DESC'], $pagination = null) - { - $select = $this->db()->select('*') - ->from('radio_hoerercharts_suggestion') - ->where($where) - ->order($orderBy); - - if ($pagination !== null) { - $select->limit($pagination->getLimit()) - ->useFoundRows(); - $result = $select->execute(); - $pagination->setRows($result->getFoundRows()); - } else { - $result = $select->execute(); - } - - $entryArray = $result->fetchRows(); - if (empty($entryArray)) { - return null; - } - $entrys = []; - - foreach ($entryArray as $entries) { - $entryModel = new EntriesModel(); - $entryModel->setId($entries['id']); - $entryModel->setInterpret($entries['interpret']); - $entryModel->setSongTitel($entries['songtitel']); - $entryModel->setDateCreate($entries['datecreate']); - $entryModel->setUser_Id($entries['user_id']); - $entrys[] = $entryModel; - } - return $entrys; - } - - /** - * Gets the Entries. - * - * @param array $where - * @param \Ilch\Pagination|null $pagination - * @return array|null - */ - public function getEntries($where = [], $pagination = null) - { - return $this->getEntriesBy($where, ['id' => 'DESC'], $pagination); - } - - /** - * Gets the entry by given ID. - * - * @param int $id - * @return null|EntriesModel - */ - public function getEntryById(int $id) - { - $entrys = $this->getEntriesBy(['id' => (int)$id], []); - - if (!empty($entrys)) { - return reset($entrys); - } - - return null; - } - - /** - * Inserts or updates entry. - * - * @param EntriesModel $model - * @return boolean|integer - */ - public function save(EntriesModel $model) - { - $fields = [ - 'interpret' => $model->getInterpret(), - 'songtitel' => $model->getSongTitel(), - 'datecreate' => $model->getDateCreate(), - 'user_id' => $model->getUser_Id() - - ]; - - if ($model->getId()) { - $result = $this->db()->update('radio_hoerercharts_suggestion') - ->values($fields) - ->where(['id' => $model->getId()]) - ->execute(); - } else { - $result = $this->db()->insert('radio_hoerercharts_suggestion') - ->values($fields) - ->execute(); - } - - return $result; - } - - /** - * Deletes the entry. - * - * @param integer $id - * @return boolean + * @var string */ - public function delete(int $id) - { - return $this->db()->delete('radio_hoerercharts_suggestion') - ->where(['id' => $id]) - ->execute(); - } + public $tablename = 'radio_hoerercharts_suggestion'; } diff --git a/mappers/HoererChartsUserVotes.php b/mappers/HoererChartsUserVotes.php index ecf2106..b48ec00 100644 --- a/mappers/HoererChartsUserVotes.php +++ b/mappers/HoererChartsUserVotes.php @@ -1,4 +1,5 @@ db()->ifTableExists('[prefix]_radio_hoerercharts_uservotes'); + return $this->db()->ifTableExists($this->tablename); } /** @@ -27,12 +32,12 @@ public function checkDB() * @param array $where * @param array $orderBy * @param \Ilch\Pagination|null $pagination - * @return array|null + * @return EntriesModel[]|null */ - public function getEntriesBy($where = [], $orderBy = ['id' => 'DESC'], $pagination = null) + public function getEntriesBy(array $where = [], array $orderBy = ['id' => 'DESC'], ?\Ilch\Pagination $pagination = null): ?array { $select = $this->db()->select('*') - ->from('radio_hoerercharts_uservotes') + ->from($this->tablename) ->where($where) ->order($orderBy); @@ -45,23 +50,20 @@ public function getEntriesBy($where = [], $orderBy = ['id' => 'DESC'], $paginati $result = $select->execute(); } - $entryArray = $result->fetchRows(); - if (empty($entryArray)) { + $entriesArray = $result->fetchRows(); + if (empty($entriesArray)) { return null; } - $entrys = []; + $entries = []; - foreach ($entryArray as $entries) { + foreach ($entriesArray as $entryArray) { $entryModel = new EntriesModel(); - $entryModel->setId($entries['id']); - $entryModel->setUser_Id($entries['user_id']); - $entryModel->setSessionId($entries['session_id']); - $entryModel->setIp($entries['ip_address']); - $entryModel->setLast_Activity($entries['last_activity']); - $entrys[] = $entryModel; + $entryModel->setByArray($entryArray); + + $entries[] = $entryModel; } - return $entrys; + return $entries; } /** @@ -69,9 +71,9 @@ public function getEntriesBy($where = [], $orderBy = ['id' => 'DESC'], $paginati * * @param array $where * @param \Ilch\Pagination|null $pagination - * @return array|null + * @return EntriesModel[]|null */ - public function getEntries($where = [], $pagination = null) + public function getEntries(array $where = [], ?\Ilch\Pagination $pagination = null): ?array { return $this->getEntriesBy($where, ['id' => 'DESC'], $pagination); } @@ -82,14 +84,14 @@ public function getEntries($where = [], $pagination = null) * @param int $id * @return null|EntriesModel */ - public function getEntryById(int $id) + public function getEntryById(int $id): ?EntriesModel { - $entrys = $this->getEntriesBy(['id' => (int)$id], []); + $entries = $this->getEntriesBy(['id' => $id], []); - if (!empty($entrys)) { - return reset($entrys); + if (!empty($entries)) { + return reset($entries); } - + return null; } @@ -97,24 +99,20 @@ public function getEntryById(int $id) * Inserts or updates entry. * * @param EntriesModel $model - * @return boolean|integer + * @return int */ - public function save(EntriesModel $model) + public function save(EntriesModel $model): int { - $fields = [ - 'user_id' => $model->getUser_Id(), - 'session_id' => $model->getSessionId(), - 'last_activity' => $model->getLast_Activity(), - 'ip_address' => $model->getIp(), - ]; + $fields = $model->getArray(false); if ($model->getId()) { - $result = $this->db()->update('radio_hoerercharts_uservotes') + $this->db()->update($this->tablename) ->values($fields) ->where(['id' => $model->getId()]) ->execute(); + $result = $model->getId(); } else { - $result = $this->db()->insert('radio_hoerercharts_uservotes') + $result = $this->db()->insert($this->tablename) ->values($fields) ->execute(); } @@ -125,21 +123,22 @@ public function save(EntriesModel $model) * Inserts or updates entry by User. * * @param EntriesModel $model - * @return bool|integer + * @return int */ - public function save_user(EntriesModel $model) + public function saveUser(EntriesModel $model): int { $fields = [ 'id' => $model->getId() ]; - if ($model->getUser_Id()) { - $result = $this->db()->update('radio_hoerercharts_uservotes') + if ($model->getUserId()) { + $this->db()->update($this->tablename) ->values($fields) - ->where(['user_id' => $model->getUser_Id()]) + ->where(['user_id' => $model->getUserId()]) ->execute(); + $result = $model->getId(); } else { - $result = $this->db()->insert('radio_hoerercharts_uservotes') + $result = $this->db()->insert($this->tablename) ->values($fields) ->execute(); } @@ -150,11 +149,11 @@ public function save_user(EntriesModel $model) * Deletes the entry. * * @param integer $id - * @return boolean + * @return bool */ - public function delete(int $id) + public function delete(int $id): bool { - return $this->db()->delete('radio_hoerercharts_uservotes') + return $this->db()->delete($this->tablename) ->where(['id' => $id]) ->execute(); } @@ -163,11 +162,11 @@ public function delete(int $id) * Delete user vote with specific user_id. * * @param integer $user_id - * @return boolean + * @return bool */ - public function delete_user(int $user_id) + public function deleteUser(int $user_id): bool { - return $this->db()->delete('radio_hoerercharts_uservotes') + return $this->db()->delete($this->tablename) ->where(['user_id' => $user_id]) ->execute(); } @@ -176,11 +175,11 @@ public function delete_user(int $user_id) * Delete user vote with specific session_id. * * @param string $session_id - * @return boolean + * @return bool */ - public function delete_session(string $session_id) + public function deleteSession(string $session_id): bool { - return $this->db()->delete('radio_hoerercharts_uservotes') + return $this->db()->delete($this->tablename) ->where(['session_id' => $session_id]) ->execute(); } @@ -189,25 +188,25 @@ public function delete_session(string $session_id) * Delete user vote with specific ip_address. * * @param string|null $ip_address - * @return boolean + * @return bool */ - public function delete_ip(string $ip_address) + public function deleteIp(?string $ip_address): bool { if (!$ip_address) { $ip_address = $this->getIp(); } - - return $this->db()->delete('radio_hoerercharts_uservotes') + + return $this->db()->delete($this->tablename) ->where(['ip_address' => $ip_address]) ->execute(); } - + /** * get thi ip_address * * @return string */ - public function getIp() + public function getIp(): string { if (isset($_SERVER['HTTP_X_FORWARDED_FOR']) && preg_match("/^[0-9a-zA-Z\/.:]{7,}$/", $_SERVER['HTTP_X_FORWARDED_FOR'])) { $ip_address = $_SERVER['HTTP_X_FORWARDED_FOR']; @@ -216,17 +215,17 @@ public function getIp() } else { $ip_address = '128.0.0.1'; } - + return $ip_address; } /** * Gets the entry by given ID. * - * @param \Modules\User\Models\User $User - * @return integer + * @param \Modules\User\Models\User|null $User + * @return int */ - public function getEntryByUserSessionIp($User = null) + public function getEntryByUserSessionIp(?\Modules\User\Models\User $User = null): int { $ip = $this->getIp(); @@ -244,20 +243,20 @@ public function getEntryByUserSessionIp($User = null) } $voteId = (int) $this->db()->select('id') - ->from('radio_hoerercharts_uservotes') + ->from($this->tablename) ->Where(['session_id' => $oldsession]) ->execute() ->fetchCell(); if (!$voteId && $User_Id > 0) { $voteId = (int) $this->db()->select('id') - ->from('radio_hoerercharts_uservotes') + ->from($this->tablename) ->Where(['user_id >' => 0, 'user_id' => $User_Id]) ->execute() ->fetchCell(); } if (!$voteId && $User_Id === 0) { $voteId = (int) $this->db()->select('id') - ->from('radio_hoerercharts_uservotes') + ->from($this->tablename) ->Where(['ip_address' => $ip]) ->execute() ->fetchCell(); @@ -271,7 +270,7 @@ public function getEntryByUserSessionIp($User = null) * * @param String $sessionid */ - public function setIsVotedCookie(String $sessionid) + public function setIsVotedCookie(string $sessionid) { setcookieIlch('RadioHoererCharts_is_voted', $sessionid, strtotime('+1 days')); } @@ -279,10 +278,10 @@ public function setIsVotedCookie(String $sessionid) /** * Check if user has already voted or if guests can vote. * - * @param \Modules\User\Models\User $User - * @return boolean + * @param \Modules\User\Models\User|null $User + * @return bool */ - public function is_voted($User = null) + public function isVoted(?\Modules\User\Models\User $User = null): bool { $config = \Ilch\Registry::get('config'); @@ -300,24 +299,24 @@ public function is_voted($User = null) $returnvalue = true; $entryModel = $this->getEntryById($voteId); - if (!empty($entryModel->getLast_Activity())) { - $dateentry = new \Ilch\Date($entryModel->getLast_Activity()); + if (!empty($entryModel->getLastActivity())) { + $dateentry = new \Ilch\Date($entryModel->getLastActivity()); } else { $dateentry = clone $datenow; } if ($config->get('radio_hoerercharts_all_sec_vote') > 0) { $dateentryclone = clone $dateentry; - $dateentryclone->modify('+'.$config->get('radio_hoerercharts_all_sec_vote').' seconds'); + $dateentryclone->modify('+' . $config->get('radio_hoerercharts_all_sec_vote') . ' seconds'); if ($dateentryclone->getTimestamp() < $datenow->getTimestamp()) { $returnvalue = false; } } - $entryModel->setLast_Activity($dateentry); + $entryModel->setLastActivity($dateentry); if ($User_Id) { - $entryModel->setUser_Id($User_Id); + $entryModel->setUserId($User_Id); } $entryModel->setSessionId(session_id()); $this->save($entryModel); @@ -330,12 +329,12 @@ public function is_voted($User = null) /** * Reset the Vote counts. * - * @return boolean + * @return bool * @throws \Ilch\Database\Exception */ - public function reset() + public function reset(): bool { - $this->db()->truncate('[prefix]_radio_hoerercharts_uservotes'); - return $this->db()->queryMulti('ALTER TABLE `[prefix]_radio_hoerercharts_uservotes` auto_increment = 1;'); + $this->db()->truncate($this->tablename); + return $this->db()->queryMulti('ALTER TABLE `[prefix]_' . $this->tablename . '` auto_increment = 1;'); } } diff --git a/models/HoererCharts.php b/models/HoererCharts.php index 941d540..8632b31 100644 --- a/models/HoererCharts.php +++ b/models/HoererCharts.php @@ -1,4 +1,5 @@ setId($entries['id']); + } + if (isset($entries['setfree'])) { + $this->setSetFree($entries['setfree']); + } + if (isset($entries['interpret'])) { + $this->setInterpret($entries['interpret']); + } + if (isset($entries['songtitel'])) { + $this->setSongTitel($entries['songtitel']); + } + if (isset($entries['votes'])) { + $this->setVotes($entries['votes']); + } + if (isset($entries['datecreate'])) { + $this->setDateCreate($entries['datecreate']); + } + if (isset($entries['user_id'])) { + $this->setUserId($entries['user_id']); + } + if (isset($entries['artworkUrl'])) { + $this->setArtworkUrl($entries['artworkUrl']); + } + return $this; + } /** * Gets the Id. * * @return int */ - public function getId() + public function getId(): int { return $this->id; } @@ -80,31 +113,31 @@ public function getId() * @param int $id * @return $this */ - public function setId(int $id) + public function setId(int $id): HoererCharts { - $this->id = (int) $id; + $this->id = $id; return $this; } - + /** * Gets the setfree. * - * @return int + * @return bool */ - public function getSetFree() + public function getSetFree(): bool { return $this->setfree; } /** * Sets the setfree. * - * @param int $setfree + * @param bool $setfree * @return $this */ - public function setSetFree(int $setfree) + public function setSetFree(bool $setfree): HoererCharts { - $this->setfree = (int) $setfree; + $this->setfree = $setfree; return $this; } @@ -114,7 +147,7 @@ public function setSetFree(int $setfree) * * @return string */ - public function getInterpret() + public function getInterpret(): string { return $this->interpret; } @@ -124,9 +157,9 @@ public function getInterpret() * @param String $interpret * @return $this */ - public function setInterpret(String $interpret) + public function setInterpret(string $interpret): HoererCharts { - $this->interpret = (string) $interpret; + $this->interpret = $interpret; return $this; } @@ -136,7 +169,7 @@ public function setInterpret(String $interpret) * * @return string */ - public function getSongTitel() + public function getSongTitel(): string { return $this->songtitel; } @@ -146,9 +179,9 @@ public function getSongTitel() * @param String $songtitel * @return $this */ - public function setSongTitel(string $songtitel) + public function setSongTitel(string $songtitel): HoererCharts { - $this->songtitel = (string) $songtitel; + $this->songtitel = $songtitel; return $this; } @@ -158,7 +191,7 @@ public function setSongTitel(string $songtitel) * * @return int */ - public function getVotes() + public function getVotes(): int { return $this->votes; } @@ -168,9 +201,9 @@ public function getVotes() * @param int $votes * @return $this */ - public function setVotes(int $votes) + public function setVotes(int $votes): HoererCharts { - $this->votes = (int) $votes; + $this->votes = $votes; return $this; } @@ -180,7 +213,7 @@ public function setVotes(int $votes) * * @return String */ - public function getDateCreate() + public function getDateCreate(): string { return $this->datecreate; } @@ -190,19 +223,19 @@ public function getDateCreate() * @param String $datecreate * @return $this */ - public function setDateCreate(String $datecreate) + public function setDateCreate(string $datecreate): HoererCharts { - $this->datecreate = (string) $datecreate; + $this->datecreate = $datecreate; return $this; } - + /** * Gets the user_id. * * @return int */ - public function getUser_Id() + public function getUserId(): int { return $this->user_id; } @@ -212,19 +245,19 @@ public function getUser_Id() * @param int $user_id * @return $this */ - public function setUser_Id(int $user_id) + public function setUserId(int $user_id): HoererCharts { - $this->user_id = (int) $user_id; + $this->user_id = $user_id; return $this; } - + /** * Gets the artworkUrl. * * @return string */ - public function getArtworkUrl() + public function getArtworkUrl(): string { return $this->artworkUrl; } @@ -234,10 +267,32 @@ public function getArtworkUrl() * @param string $artworkUrl * @return $this */ - public function setArtworkUrl(string $artworkUrl) + public function setArtworkUrl(string $artworkUrl): HoererCharts { - $this->artworkUrl = (string) $artworkUrl; + $this->artworkUrl = $artworkUrl; return $this; } + + /** + * Gets the Array of Model. + * + * @param bool $withId + * @return array + */ + public function getArray(bool $withId = true): array + { + return array_merge( + ($withId ? ['id' => $this->getId()] : []), + [ + 'setfree' => $this->getSetFree(), + 'interpret' => $this->getInterpret(), + 'songtitel' => $this->getSongTitel(), + 'votes' => $this->getVotes(), + 'datecreate' => $this->getDateCreate(), + 'user_id' => $this->getUserId(), + 'artworkUrl' => $this->getArtworkUrl(), + ] + ); + } } diff --git a/models/HoererChartsList.php b/models/HoererChartsList.php index b5428a0..8bc9abb 100644 --- a/models/HoererChartsList.php +++ b/models/HoererChartsList.php @@ -1,4 +1,5 @@ setId($entries['id']); + } + if (isset($entries['hid'])) { + $this->setHId($entries['hid']); + } + if (isset($entries['list'])) { + $this->setList($entries['list']); + } + return $this; + } /** * Gets the Id. * * @return int */ - public function getId() + public function getId(): int { return $this->id; } @@ -54,31 +72,32 @@ public function getId() * @param int $id * @return $this */ - public function setId(int $id) + public function setId(int $id): HoererChartsList { - $this->id = (int) $id; + $this->id = $id; return $this; } - + /** * Gets the hid. * * @return int */ - public function getHId() + public function getHId(): int { return $this->hid; } + /** * Sets the setfree. * - * @param int $setfree + * @param int $hid * @return $this */ - public function setHId(int $hid) + public function setHId(int $hid): HoererChartsList { - $this->hid = (int) $hid; + $this->hid = $hid; return $this; } @@ -88,8 +107,11 @@ public function setHId(int $hid) * * @return EntriesModel */ - public function getEntry() + public function getEntry(): EntriesModel { + if (!$this->entry) { + $this->entry = new EntriesModel(); + } return $this->entry; } /** @@ -98,7 +120,7 @@ public function getEntry() * @param EntriesModel $entry * @return $this */ - public function setEntry(EntriesModel $entry) + public function setEntry(EntriesModel $entry): HoererChartsList { $this->entry = $entry; @@ -110,21 +132,38 @@ public function setEntry(EntriesModel $entry) * * @return int */ - public function getList() + public function getList(): int { return $this->list; } + /** * Sets the List. * * @param int $list * @return $this */ - public function setList(string $list) + public function setList(int $list): HoererChartsList { - $this->list = (int) $list; + $this->list = $list; return $this; } + /** + * Gets the Array of Model. + * + * @param bool $withId + * @return array + */ + public function getArray(bool $withId = true): array + { + return array_merge( + ($withId ? ['id' => $this->getId()] : []), + [ + 'hid' => $this->getHId(), + 'list' => $this->getList(), + ] + ); + } } diff --git a/models/HoererChartsUserVotes.php b/models/HoererChartsUserVotes.php index 44609bb..39ca21f 100644 --- a/models/HoererChartsUserVotes.php +++ b/models/HoererChartsUserVotes.php @@ -1,4 +1,5 @@ setId($entries['id']); + } + if (isset($entries['user_id'])) { + $this->setUserId($entries['user_id']); + } + if (isset($entries['session_id'])) { + $this->setSessionId($entries['session_id']); + } + if (isset($entries['last_activity'])) { + $this->setLastActivity($entries['last_activity']); + } + return $this; + } /** * Gets the Id. * * @return int */ - public function getId() + public function getId(): int { return $this->id; } @@ -58,9 +80,9 @@ public function getId() * @param int $id * @return $this */ - public function setId(int $id) + public function setId(int $id): HoererChartsUserVotes { - $this->id = (int) $id; + $this->id = $id; return $this; } @@ -70,7 +92,7 @@ public function setId(int $id) * * @return int */ - public function getUser_Id() + public function getUserId(): int { return $this->user_id; } @@ -80,9 +102,9 @@ public function getUser_Id() * @param int $user_id * @return $this */ - public function setUser_Id(int $user_id) + public function setUserId(int $user_id): HoererChartsUserVotes { - $this->user_id = (int) $user_id; + $this->user_id = $user_id; return $this; } @@ -94,7 +116,7 @@ public function setUser_Id(int $user_id) * * @return string */ - public function getSessionId() + public function getSessionId(): string { return $this->sessionId; } @@ -104,9 +126,9 @@ public function getSessionId() * * @param string $sessionId */ - public function setSessionId(String $sessionId) + public function setSessionId(string $sessionId) { - $this->sessionId = (string) $sessionId; + $this->sessionId = $sessionId; } /** @@ -114,7 +136,7 @@ public function setSessionId(String $sessionId) * * @return string */ - public function getIp() + public function getIp(): string { return $this->ip; } @@ -124,9 +146,9 @@ public function getIp() * @param string $ip * @return $this */ - public function setIp(String $ip) + public function setIp(string $ip): HoererChartsUserVotes { - $this->ip = (string) $ip; + $this->ip = $ip; return $this; } @@ -136,7 +158,7 @@ public function setIp(String $ip) * * @return string */ - public function getLast_Activity() + public function getLastActivity(): string { return $this->last_activity; } @@ -146,10 +168,29 @@ public function getLast_Activity() * @param string $last_activity * @return $this */ - public function setLast_Activity(String $last_activity) + public function setLastActivity(string $last_activity): HoererChartsUserVotes { - $this->last_activity = (string) $last_activity; + $this->last_activity = $last_activity; return $this; } + + /** + * Gets the Array of Model. + * + * @param bool $withId + * @return array + */ + public function getArray(bool $withId = true): array + { + return array_merge( + ($withId ? ['id' => $this->getId()] : []), + [ + 'user_id' => $this->getUserId(), + 'session_id' => $this->getSessionId(), + 'last_activity' => $this->getLastActivity(), + 'ip_address' => $this->getIp(), + ] + ); + } } diff --git a/translations/de.php b/translations/de.php index 906e428..ba34f6a 100644 --- a/translations/de.php +++ b/translations/de.php @@ -1,4 +1,5 @@ 'Deutsch', 'english' => 'Englisch', - 'language_footer' => 'Platzhalter: --user-- -> Gäste:"%s", User:"%s" ; --name-- -> "%s"', + 'language_footer' => 'Platzhalter:
--user-- ->
Gäste:"%s"
User:"%s"
--name-- -> "%s"', 'registered_by' => 'Eingetragen von', 'suggestionenable' => 'Vorschlag aktivieren', diff --git a/translations/en.php b/translations/en.php index 52337f7..f9332c9 100644 --- a/translations/en.php +++ b/translations/en.php @@ -1,4 +1,5 @@ get('hoererchartsMapper'); + +/** @var Modules\RadioHoererCharts\Mappers\HoererChartsList $hoererchartslistMapper */ +$hoererchartslistMapper = $this->get('hoererchartslistMapper'); + +/** @var string $sort_order */ +$sort_order = $this->get('sort_order'); + +/** @var string $sort_column */ +$sort_column = $this->get('sort_column'); + +/** @var bool $suggestion */ +$suggestion = $this->get('suggestion'); + +/** @var bool $allowsuggestion */ +$allowsuggestion = $this->get('allowsuggestion'); + +/** @var bool $badgeSuggestion */ +$badgeSuggestion = $this->get('badgeSuggestion'); + +/** @var int $list */ +$list = $this->get('list'); + +/** @var int $activelist */ +$activelist = $this->get('activelist'); + +/** @var int $filterlist */ +$filterlist = $this->get('filterlist'); + +/** @var string $votedatetime */ +$votedatetime = $this->get('votedatetime'); + +/** @var Modules\RadioHoererCharts\Models\HoererCharts[] $entries */ +$entries = $this->get('entries'); + +/** @var Modules\RadioHoererCharts\Models\HoererChartsList[] $listentries */ +$listentries = $this->get('listentries'); + + +?>

getTrans('manage') ?>

-get('suggestion') && !$this->get('list')) { - ?> +
- getTrans('votedatetime') ?>get('votedatetime') ?> + getTrans('votedatetime') ?>
-get('list')) { - ?> +
- get('allowsuggestion'))?'checked="checked"':'' ?> /> + /> - get('allowsuggestion'))?'checked="checked"':'' ?> /> + />
- +
- +
-get('list')) { -?> + - -
+ + getTokenField() ?>
-get('list')) { - ?> +
@@ -99,21 +136,20 @@
    - get('listentries') as $entry) { - $listentries[] = $entry->getHId(); - ?> + $listentrie = []; ?> + getHId(); ?>
  1. getEntry()->getInterpret() ?> - getEntry()->getSongTitel() ?>
  2. - +
    - get('entries') as $entry) { ?> - getId(), $listentries)) { ?> + + getId(), $listentrie)) { ?>
  1. getInterpret() ?> - getSongTitel() ?>
  2. @@ -125,14 +161,10 @@
- getListBar(['save' => 'save']); ?> + getListBar(['save' => 'save']); ?> getSaveBar() ?> - -get('entries')) { - ?> + +
@@ -140,190 +172,180 @@ + + + + - get('suggestion')) { - ?>+ - $this->get('sort_order') == 'ASC' ? 'desc' : 'asc']; - if ($this->get('suggestion')) { - $urladd['suggestion'] = 'true'; - } - if ($this->get('filterlist')) { - $urladd['filterlist'] = $this->get('filterlist'); - } - ?> + $sort_order == 'ASC' ? 'desc' : 'asc']; + if ($suggestion) { + $urladd['suggestion'] = 'true'; + } + if ($filterlist) { + $urladd['filterlist'] = $filterlist; + } + ?> + + - get('suggestion')) { - ?> + - + - get('entries') as $entry) { - ?> + - - + + + + - get('suggestion')) { - ?> + + + - +
getCheckAllCheckbox('check_entries') ?> getTrans('list') ?> getTrans('interpret') ?> - + getTrans('songtitel') ?> - + getTrans('vote') ?> - + getTrans('datecreate') ?> - + getTrans('user') ?> - +
getDeleteCheckbox('check_entries', $entry->getId()) ?>getDeleteIcon(array_merge(['action' => 'del', 'id' => $entry->getId()], (($this->get('suggestion'))?['suggestion' => 'true']:[]))) ?>getEditIcon(array_merge(['action' => 'treat', 'id' => $entry->getId()], (($this->get('suggestion'))?['suggestion' => 'true']:[]))) ?>getDeleteIcon(array_merge(['action' => 'del', 'id' => $entry->getId()], (($suggestion) ? ['suggestion' => 'true'] : []))) ?>getEditIcon(array_merge(['action' => 'treat', 'id' => $entry->getId()], (($suggestion) ? ['suggestion' => 'true'] : []))) ?> - get('suggestion')) { - ?> + - + - + - + - get('hoererchartslistMapper')->getEntriesBy(['hid' => $entry->getId()], ['list' => 'ASC']) ?? []; - $liste = []; - foreach ($lists as $listsModel) { - $liste[] = $listsModel->getList(); - } - echo implode(', ', $liste); - ?> + getEntriesBy(['hid' => $entry->getId()], ['list' => 'ASC']) ?? []; + $liste = []; + foreach ($lists as $listsModel) { + $liste[] = $listsModel->getList(); + } + echo implode(', ', $liste); + ?> escape($entry->getInterpret()) ?> escape($entry->getSongTitel()) ?>getVotes() ?> (get('hoererchartsMapper')->getStars($entry->getVotes(), true) ?>)getVotes() ?> (getStars($entry->getVotes(), true) ?>) getDateCreate()); - echo $datenow->format($this->getTrans('datetimeformat')); ?> + echo $datenow->format($this->getTrans('datetimeformat')); + ?> getUser_Id(); - $user = $userMapper->getUserById($user_id); - if ($user) { - echo $this->escape($user->getName()); - } else { - echo $this->getTrans('guest'); - } ?> + $userMapper = new \Modules\User\Mappers\User(); + + $user = $userMapper->getUserById($entry->getUserId()); + if ($user) { + echo $this->escape($user->getName()); + } else { + echo $this->getTrans('guest'); + } + ?>
- getListBar(array_merge((($this->get('suggestion'))?['setfree' => 'suggestionenable']:[]), ['delete' => 'delete'])); ?> - + getListBar(array_merge((($suggestion) ? ['setfree' => 'suggestionenable'] : []), ['delete' => 'delete'])); ?> +
- getTrans('noentriesadmin') ?> + getTrans('noentriesadmin') ?>
- - + +
-get('suggestion') && !$this->get('list')) { - ?> -getDialog('radiohoererchartsModal', $this->getTrans('settings'), ''); ?> + + getDialog('radiohoererchartsModal', $this->getTrans('settings'), ''); ?> -get('list')) { - ?> + - + - + diff --git a/views/admin/index/reset.php b/views/admin/index/reset.php index beb3bac..3f65649 100644 --- a/views/admin/index/reset.php +++ b/views/admin/index/reset.php @@ -1,44 +1,51 @@ +get('entries'); +?>

getTrans('reset') ?>

- - - - - - +
+ + + + + + + + + + + + - - + + - - get('entries') as $entry) { - ?> - - - - - - - -
getTrans('user') ?>getTrans('datecreate') ?>
getTrans('user') ?>getTrans('datecreate') ?> + getUserId(); + $user = $userMapper->getUserById($user_id); + if ($user) { + echo $this->escape($user->getName()); + } else { + echo $this->getTrans('guest'); + } + ?> + + getLastActivity()); + echo $datenow->format($this->getTrans('datetimeformat')); + ?> +
- getUser_Id(); - $user = $userMapper->getUserById($user_id); - if ($user) { - echo $this->escape($user->getName()); - } else { - echo $this->getTrans('guest'); - } ?> - - getLast_Activity()); - echo $datenow->format($this->getTrans('datetimeformat')); ?> -
-
+ + + + diff --git a/views/admin/index/searchiTunes.php b/views/admin/index/searchiTunes.php index 5c3a769..92ab2ca 100644 --- a/views/admin/index/searchiTunes.php +++ b/views/admin/index/searchiTunes.php @@ -1 +1,5 @@ -get('entrie')); ?> +get('entry')); diff --git a/views/admin/index/treat.php b/views/admin/index/treat.php index 8b419da..2b06162 100644 --- a/views/admin/index/treat.php +++ b/views/admin/index/treat.php @@ -1,5 +1,14 @@ -get('entrie'); ?> -

getTrans('edit') : $this->getTrans('add') ?>

+get('show_artwork'); + +/** @var Modules\RadioHoererCharts\Models\HoererCharts $entry */ +$entry = $this->get('entry'); +?> +

getTrans('edit') : $this->getTrans('add') ?>

getTokenField() ?>
@@ -8,8 +17,8 @@
getDateCreate()); + if ($entry != '') { + $datenow = new \Ilch\Date($entry->getDateCreate()); echo $datenow->format($this->getTrans('datetimeformat')); } else { echo $this->getTrans('new'); @@ -17,24 +26,22 @@ ?>
- getRequest()->getParam('suggestion')) { - ?> + getRequest()->getParam('suggestion')) { ?>
getTrans('setfree') ?>
- originalInput('setfree', ($entrie?$entrie->getSetFree():true)))?'checked="checked"':'' ?> /> + originalInput('setfree', ($entry->getSetFree()))) ? 'checked="checked"' : '' ?> /> - originalInput('setfree', ($entrie?$entrie->getSetFree():true)))?'checked="checked"':'' ?> /> + originalInput('setfree', ($entry->getSetFree()))) ? 'checked="checked"' : '' ?> />
- +
@@ -56,11 +63,10 @@ type="text" id="songtitel" name="songtitel" - value="escape($this->originalInput('songtitel', ($entrie?$entrie->getSongTitel():''))) ?>" /> + value="escape($this->originalInput('songtitel', ($entry->getSongTitel()))) ?>" />
- getRequest()->getParam('suggestion') && $this->get('show_artwork')) { - ?> + getRequest()->getParam('suggestion') && $show_artwork) { ?>
- - getSaveBar('updateButton') : $this->getSaveBar('addButton') ?> + + getId()) ? $this->getSaveBar('updateButton') : $this->getSaveBar('addButton') ?>
-getRequest()->getParam('suggestion') && $this->get('show_artwork')) { -?> +getRequest()->getParam('suggestion') && $show_artwork) { ?> - + diff --git a/views/admin/settings/index.php b/views/admin/settings/index.php index a943eaf..57f7864 100644 --- a/views/admin/settings/index.php +++ b/views/admin/settings/index.php @@ -1,18 +1,17 @@

getTrans('menuSettings') ?>

-
+ getTokenField() ?> - get('settings_language')) { - ?> + get('settings_language')) { ?>

getTrans('Program_Name') ?>

- originalInput('guestallow', $this->get('guestallow')))?'checked="checked"':'' ?> /> + originalInput('guestallow', $this->get('guestallow'))) ? 'checked="checked"' : '' ?> /> - originalInput('guestallow', $this->get('guestallow')))?'checked="checked"':'' ?> /> + originalInput('guestallow', $this->get('guestallow'))) ? 'checked="checked"' : '' ?> />
@@ -81,9 +80,9 @@ class="form-control"
- originalInput('show_artwork', $this->get('show_artwork')))?'checked="checked"':'' ?> /> + originalInput('show_artwork', $this->get('show_artwork'))) ? 'checked="checked"' : '' ?> /> - originalInput('show_artwork', $this->get('show_artwork')))?'checked="checked"':'' ?> /> + originalInput('show_artwork', $this->get('show_artwork'))) ? 'checked="checked"' : '' ?> />
@@ -97,9 +96,9 @@ class="form-control"
- originalInput('show_registered_by', $this->get('show_registered_by')))?'checked="checked"':'' ?> /> + originalInput('show_registered_by', $this->get('show_registered_by'))) ? 'checked="checked"' : '' ?> /> - originalInput('show_registered_by', $this->get('show_registered_by')))?'checked="checked"':'' ?> /> + originalInput('show_registered_by', $this->get('show_registered_by'))) ? 'checked="checked"' : '' ?> />
@@ -113,9 +112,9 @@ class="form-control"
- originalInput('showstars', $this->get('showstars')))?'checked="checked"':'' ?> /> + originalInput('showstars', $this->get('showstars'))) ? 'checked="checked"' : '' ?> /> - originalInput('showstars', $this->get('showstars')))?'checked="checked"':'' ?> /> + originalInput('showstars', $this->get('showstars'))) ? 'checked="checked"' : '' ?> />
@@ -196,9 +195,7 @@ class="form-control" required />
- +
@@ -218,7 +215,6 @@ class="form-control"

getTrans('language_footer', $this->getTrans('votetextguest'), $this->getTrans('votetextuser'), $this->get('Program_Name')) ?>

- + getSaveBar() ?> diff --git a/views/admin/settings/votedatetime.php b/views/admin/settings/votedatetime.php index 085318a..446d110 100644 --- a/views/admin/settings/votedatetime.php +++ b/views/admin/settings/votedatetime.php @@ -1,4 +1,7 @@ escape($this->originalInput('start_datetime', $this->get('start_datetime'))); $end_datetime = $this->escape($this->originalInput('end_datetime', $this->get('end_datetime'))); ?> @@ -42,25 +45,25 @@ class="form-control" getSaveBar('edit') ?> -getTranslator()->getLocale(), 0, 2) != 'en'): ?> - +getTranslator()->getLocale(), 0, 2) != 'en') : ?> + \ No newline at end of file + diff --git a/views/index/treat.php b/views/index/treat.php index a51177b..6f46400 100644 --- a/views/index/treat.php +++ b/views/index/treat.php @@ -1,5 +1,18 @@ +get('captchaNeeded'); + +/** @var \Captcha\DefaultCaptcha $defaultcaptcha */ +$defaultcaptcha = $this->get('defaultcaptcha'); + +/** @var \Captcha\GoogleCaptcha $googlecaptcha */ +$googlecaptcha = $this->get('googlecaptcha'); +?>

getTrans('add') ?>

-
+ getTokenField() ?>
@@ -22,11 +35,10 @@ type="text" id="songtitel" name="songtitel" - value="escape($this->originalInput('songtitel', '')) ?>" /> + value="escape($this->originalInput('songtitel')) ?>" />
- get('captchaNeeded')) { - ?> +
+ + getCaptcha($this) ?> +
-
- - - - - - +
+ setForm('rhcForm')->getCaptcha($this, 'addButton'); + } else { + echo $this->getSaveBar('addButton'); + } + } else { + echo $this->getSaveBar('addButton'); + } + ?>
- + getSaveBar('addButton') ?>