commit 9d707d180073f84328935371edc05d20b22bc33b Author: Llewellyn van der Merwe Date: Wed Jul 26 11:09:42 2023 +0200 aVersion 2 diff --git a/.octojpack b/.octojpack new file mode 100644 index 0000000..9b64be0 --- /dev/null +++ b/.octojpack @@ -0,0 +1,69 @@ +{ + "global": { + "packager": "Vast Development Method", + "packager_url": "https://dev.vdm.io/", + "url": "git.vdm.dev", + "api": "https://git.vdm.dev/api/v1" + }, + "package": { + "name": "PKG_GETBIBLE", + "code_name": "getbible", + "package_name": "pkg_getbible", + "min_joomla_version": "3.8", + "max_joomla_version": "3.10", + "copyright": "Copyright (C) 2015 Llewellyn van der Merwe. All rights reserved.", + "copyright_year": "2015", + "license": "GNU General Public License version 2; see LICENSE", + "license_file": "LICENSE", + "author": "Llewellyn van der Merwe", + "author_email": "joomla@vdm.io", + "author_url": "https://io.vdm.dev/", + "description": "The Get Bible for Joomla.", + "version_id": "com_getbible", + "update_servers": "https://git.vdm.dev/getBible/joomla-component/raw/branch/master/update_server.xml" + }, + "repository": { + "owner": "getBible", + "repo": "joomla-pkg" + }, + "files": [ + { + "owner": "getBible", + "repo": "joomla-component", + "id": "com_getbible", + "type": "component", + "mode": "master" + }, + { + "owner": "getBible", + "repo": "daily-light-module", + "id": "mod_dailylight", + "type": "module", + "client": "site", + "mode": "master" + }, + { + "owner": "getBible", + "repo": "daily-scripture-module", + "id": "mod_dailyscripture", + "type": "module", + "client": "site", + "mode": "master" + } + ], + "languages": [ + { + "tag": "en-GB", + "ini": "sys.ini", + "key": "PKG_GETBIBLE", + "value": "GetBible Package" + }, + { + "tag": "en-GB", + "ini": "ini", + "key": "PKG_GETBIBLE", + "value": "GetBible Package" + } + ] +} + diff --git a/CHANGELOG.md b/CHANGELOG.md new file mode 100644 index 0000000..9614ab3 --- /dev/null +++ b/CHANGELOG.md @@ -0,0 +1,11 @@ +# v2.0.1 + +- New System Architecture as to how Scripture is added +- New Application Page (Bible Page) +- New Linker (anonymous users) system +- SEO for each chapter of the Bible +- New Easy Sharing System +- New Tagging system +- New Notes system +- New Search system +- Integration with OpenAI \ No newline at end of file diff --git a/LICENSE.txt b/LICENSE.txt new file mode 100644 index 0000000..df50810 --- /dev/null +++ b/LICENSE.txt @@ -0,0 +1,340 @@ +GNU GENERAL PUBLIC LICENSE + Version 2, June 1991 + + Copyright (C) 1989, 1991 Free Software Foundation, Inc. + 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + Everyone is permitted to copy and distribute verbatim copies + of this license document, but changing it is not allowed. + + Preamble + + The licenses for most software are designed to take away your +freedom to share and change it. By contrast, the GNU General Public +License is intended to guarantee your freedom to share and change free +software--to make sure the software is free for all its users. This +General Public License applies to most of the Free Software +Foundation's software and to any other program whose authors commit to +using it. (Some other Free Software Foundation software is covered by +the GNU Library General Public License instead.) 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 +this service 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 make restrictions that forbid +anyone to deny you these rights or to ask you to surrender the rights. +These restrictions translate to certain responsibilities for you if you +distribute copies of the software, or if you modify it. + + For example, if you distribute copies of such a program, whether +gratis or for a fee, you must give the recipients all the rights that +you have. 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. + + We protect your rights with two steps: (1) copyright the software, and +(2) offer you this license which gives you legal permission to copy, +distribute and/or modify the software. + + Also, for each author's protection and ours, we want to make certain +that everyone understands that there is no warranty for this free +software. If the software is modified by someone else and passed on, we +want its recipients to know that what they have is not the original, so +that any problems introduced by others will not reflect on the original +authors' reputations. + + Finally, any free program is threatened constantly by software +patents. We wish to avoid the danger that redistributors of a free +program will individually obtain patent licenses, in effect making the +program proprietary. To prevent this, we have made it clear that any +patent must be licensed for everyone's free use or not licensed at all. + + The precise terms and conditions for copying, distribution and +modification follow. + + GNU GENERAL PUBLIC LICENSE + TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION + + 0. This License applies to any program or other work which contains +a notice placed by the copyright holder saying it may be distributed +under the terms of this General Public License. The "Program", below, +refers to any such program or work, and a "work based on the Program" +means either the Program or any derivative work under copyright law: +that is to say, a work containing the Program or a portion of it, +either verbatim or with modifications and/or translated into another +language. (Hereinafter, translation is included without limitation in +the term "modification".) Each licensee is addressed as "you". + +Activities other than copying, distribution and modification are not +covered by this License; they are outside its scope. The act of +running the Program is not restricted, and the output from the Program +is covered only if its contents constitute a work based on the +Program (independent of having been made by running the Program). +Whether that is true depends on what the Program does. + + 1. You may copy and distribute 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 and disclaimer of warranty; keep intact all the +notices that refer to this License and to the absence of any warranty; +and give any other recipients of the Program a copy of this License +along with the Program. + +You may charge a fee for the physical act of transferring a copy, and +you may at your option offer warranty protection in exchange for a fee. + + 2. You may modify your copy or copies of the Program or any portion +of it, thus forming a work based on the Program, and copy and +distribute such modifications or work under the terms of Section 1 +above, provided that you also meet all of these conditions: + + a) You must cause the modified files to carry prominent notices + stating that you changed the files and the date of any change. + + b) You must cause any work that you distribute or publish, that in + whole or in part contains or is derived from the Program or any + part thereof, to be licensed as a whole at no charge to all third + parties under the terms of this License. + + c) If the modified program normally reads commands interactively + when run, you must cause it, when started running for such + interactive use in the most ordinary way, to print or display an + announcement including an appropriate copyright notice and a + notice that there is no warranty (or else, saying that you provide + a warranty) and that users may redistribute the program under + these conditions, and telling the user how to view a copy of this + License. (Exception: if the Program itself is interactive but + does not normally print such an announcement, your work based on + the Program is not required to print an announcement.) + +These requirements apply to the modified work as a whole. If +identifiable sections of that work are not derived from the Program, +and can be reasonably considered independent and separate works in +themselves, then this License, and its terms, do not apply to those +sections when you distribute them as separate works. But when you +distribute the same sections as part of a whole which is a work based +on the Program, the distribution of the whole must be on the terms of +this License, whose permissions for other licensees extend to the +entire whole, and thus to each and every part regardless of who wrote it. + +Thus, it is not the intent of this section to claim rights or contest +your rights to work written entirely by you; rather, the intent is to +exercise the right to control the distribution of derivative or +collective works based on the Program. + +In addition, mere aggregation of another work not based on the Program +with the Program (or with a work based on the Program) on a volume of +a storage or distribution medium does not bring the other work under +the scope of this License. + + 3. You may copy and distribute the Program (or a work based on it, +under Section 2) in object code or executable form under the terms of +Sections 1 and 2 above provided that you also do one of the following: + + a) Accompany it with the complete corresponding machine-readable + source code, which must be distributed under the terms of Sections + 1 and 2 above on a medium customarily used for software interchange; or, + + b) Accompany it with a written offer, valid for at least three + years, to give any third party, for a charge no more than your + cost of physically performing source distribution, a complete + machine-readable copy of the corresponding source code, to be + distributed under the terms of Sections 1 and 2 above on a medium + customarily used for software interchange; or, + + c) Accompany it with the information you received as to the offer + to distribute corresponding source code. (This alternative is + allowed only for noncommercial distribution and only if you + received the program in object code or executable form with such + an offer, in accord with Subsection b above.) + +The source code for a work means the preferred form of the work for +making modifications to it. For an executable work, complete source +code means all the source code for all modules it contains, plus any +associated interface definition files, plus the scripts used to +control compilation and installation of the executable. However, as a +special exception, the source code distributed need not include +anything that is normally distributed (in either source or binary +form) with the major components (compiler, kernel, and so on) of the +operating system on which the executable runs, unless that component +itself accompanies the executable. + +If distribution of executable or object code is made by offering +access to copy from a designated place, then offering equivalent +access to copy the source code from the same place counts as +distribution of the source code, even though third parties are not +compelled to copy the source along with the object code. + + 4. You may not copy, modify, sublicense, or distribute the Program +except as expressly provided under this License. Any attempt +otherwise to copy, modify, sublicense or distribute the Program is +void, and will automatically terminate your rights under this License. +However, parties who have received copies, or rights, from you under +this License will not have their licenses terminated so long as such +parties remain in full compliance. + + 5. You are not required to accept this License, since you have not +signed it. However, nothing else grants you permission to modify or +distribute the Program or its derivative works. These actions are +prohibited by law if you do not accept this License. Therefore, by +modifying or distributing the Program (or any work based on the +Program), you indicate your acceptance of this License to do so, and +all its terms and conditions for copying, distributing or modifying +the Program or works based on it. + + 6. Each time you redistribute the Program (or any work based on the +Program), the recipient automatically receives a license from the +original licensor to copy, distribute or modify the Program subject to +these terms and conditions. You may not impose any further +restrictions on the recipients' exercise of the rights granted herein. +You are not responsible for enforcing compliance by third parties to +this License. + + 7. If, as a consequence of a court judgment or allegation of patent +infringement or for any other reason (not limited to patent issues), +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 +distribute so as to satisfy simultaneously your obligations under this +License and any other pertinent obligations, then as a consequence you +may not distribute the Program at all. For example, if a patent +license would not permit royalty-free redistribution of the Program by +all those who receive copies directly or indirectly through you, then +the only way you could satisfy both it and this License would be to +refrain entirely from distribution of the Program. + +If any portion of this section is held invalid or unenforceable under +any particular circumstance, the balance of the section is intended to +apply and the section as a whole is intended to apply in other +circumstances. + +It is not the purpose of this section to induce you to infringe any +patents or other property right claims or to contest validity of any +such claims; this section has the sole purpose of protecting the +integrity of the free software distribution system, which is +implemented by public license practices. Many people have made +generous contributions to the wide range of software distributed +through that system in reliance on consistent application of that +system; it is up to the author/donor to decide if he or she is willing +to distribute software through any other system and a licensee cannot +impose that choice. + +This section is intended to make thoroughly clear what is believed to +be a consequence of the rest of this License. + + 8. If the distribution and/or use of the Program is restricted in +certain countries either by patents or by copyrighted interfaces, the +original copyright holder who places the Program under this License +may add an explicit geographical distribution limitation excluding +those countries, so that distribution is permitted only in or among +countries not thus excluded. In such case, this License incorporates +the limitation as if written in the body of this License. + + 9. The Free Software Foundation may publish revised and/or new versions +of the 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 a version number of this License which applies to it and "any +later version", you have the option of following the terms and conditions +either of that version or of any later version published by the Free +Software Foundation. If the Program does not specify a version number of +this License, you may choose any version ever published by the Free Software +Foundation. + + 10. If you wish to incorporate parts of the Program into other free +programs whose distribution conditions are different, write to the author +to ask for permission. For software which is copyrighted by the Free +Software Foundation, write to the Free Software Foundation; we sometimes +make exceptions for this. Our decision will be guided by the two goals +of preserving the free status of all derivatives of our free software and +of promoting the sharing and reuse of software generally. + + NO WARRANTY + + 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, 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. + + 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING +WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR +REDISTRIBUTE 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. + + 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 +convey 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 2 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, write to the Free Software + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + + +Also add information on how to contact you by electronic and paper mail. + +If the program is interactive, make it output a short notice like this +when it starts in an interactive mode: + + Gnomovision version 69, Copyright (C) year name of author + Gnomovision 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, the commands you use may +be called something other than `show w' and `show c'; they could even be +mouse-clicks or menu items--whatever suits your program. + +You should also get your employer (if you work as a programmer) or your +school, if any, to sign a "copyright disclaimer" for the program, if +necessary. Here is a sample; alter the names: + + Yoyodyne, Inc., hereby disclaims all copyright interest in the program + `Gnomovision' (which makes passes at compilers) written by James Hacker. + + , 1 April 1989 + Ty Coon, President of Vice + +This 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 Library General +Public License instead of this License. diff --git a/README.md b/README.md new file mode 100644 index 0000000..e26ed39 --- /dev/null +++ b/README.md @@ -0,0 +1,60 @@ +# Get Bible (2.0.1) + + ![Get Bible image](https://git.vdm.dev/getBible/joomla-component/raw/branch/master/admin/assets/images/vdm-component.jpg "GetBible") + +Welcome to the next level of scripture engagement - The Bible for Joomla! Our purpose is to bring the Word of God to every person, in their native language, entirely free. This isn't just a typical extension; it's a groundbreaking tool developed to span language divides and deliver a rich, customizable Bible study experience to users worldwide. + +With an impressive array of 80 translations, our Joomla extension allows people from all corners of the globe to read, comprehend, and meditate on the Holy Scriptures in their preferred language. Moreover, we offer the unique opportunity for individuals to host the Bible on their own website, further extending the reach of the Word. + +We've integrated robust features such as note-taking, tagging, and a search function, to enhance your interaction with the Scriptures. This allows users to immerse themselves in the text, crafting a personal journey through the Bible that can be revisited in future sessions. Furthermore, our innovative linker system assigns each visitor a unique identifier (GUID) - no login required. This means you can create notes, select favorite verses, and even share sessions, while maintaining control over your personalized content. + +A distinctive feature of our application is the integration with OpenAI. This advanced capability allows website owners to create custom prompts to interact with OpenAI using text from any translation. This function allows you to ask questions, gain clarity, and deepen your understanding of the Scriptures in an engaging and user-friendly manner. + +In essence, The Bible for Joomla is designed to transform how the Word of God is shared, studied, and comprehended. Its comprehensive features, combined with a user-friendly interface, make it an essential tool for individuals, churches, and website owners alike. Join us on this journey of faith as we make the wisdom and guidance of the Scriptures accessible to all, one verse, one language, and one website at a time. + +# Build Details + ++ *Company*: [Vast Development Method](https://getbible.net) ++ *Author*: [Llewellyn van der Merwe](mailto:joomla@vdm.io) ++ *Name*: [Get Bible](https://getbible.net) ++ *First Build*: 3rd December, 2015 ++ *Last Build*: 26th July, 2023 ++ *Version*: 2.0.1 ++ *Copyright*: Copyright (C) 2015. All Rights Reserved ++ *License*: GNU/GPL Version 2 or later - http://www.gnu.org/licenses/gpl-2.0.html + +## Build Time + +**530 Hours** or **66 Eight Hour Days** (actual time the author saved - +due to [Automated Component Builder](https://www.joomlacomponentbuilder.com)) + +> (if creating a folder and file took **5 seconds** and writing one line of code took **10 seconds**, +> never making one mistake or taking any coffee break.) + ++ *Line count*: **189808** ++ *File count*: **1660** ++ *Folder count*: **161** + +**349 Hours** or **44 Eight Hour Days** (the actual time the author spent) + +> (with the following break down: +> **debugging @132hours** = codingtime / 4; +> **planning @76hours** = codingtime / 7; +> **mapping @53hours** = codingtime / 10; +> **office @88hours** = codingtime / 6;) + +**879 Hours** or **110 Eight Hour Days** +(a total of the realistic time frame for this project) + +> (if creating a folder and file took **5 seconds** and writing one line of code took **10 seconds**, +> with the normal everyday realities at the office, that includes the component planning, mapping & debugging.) + +Project duration: **22 weeks** or **4.6 months** + +> This **component** was build with a Joomla [Automated Component Builder](https://www.joomlacomponentbuilder.com). +> Developed by [Llewellyn van der Merwe](mailto:joomla@vdm.io) + +## Donations + +If you want to support this project, please consider donating: +* Open Collective: [Joomla-Component-Builder](https://opencollective.com/Joomla-Component-Builder) \ No newline at end of file diff --git a/admin/README.txt b/admin/README.txt new file mode 100644 index 0000000..e26ed39 --- /dev/null +++ b/admin/README.txt @@ -0,0 +1,60 @@ +# Get Bible (2.0.1) + + ![Get Bible image](https://git.vdm.dev/getBible/joomla-component/raw/branch/master/admin/assets/images/vdm-component.jpg "GetBible") + +Welcome to the next level of scripture engagement - The Bible for Joomla! Our purpose is to bring the Word of God to every person, in their native language, entirely free. This isn't just a typical extension; it's a groundbreaking tool developed to span language divides and deliver a rich, customizable Bible study experience to users worldwide. + +With an impressive array of 80 translations, our Joomla extension allows people from all corners of the globe to read, comprehend, and meditate on the Holy Scriptures in their preferred language. Moreover, we offer the unique opportunity for individuals to host the Bible on their own website, further extending the reach of the Word. + +We've integrated robust features such as note-taking, tagging, and a search function, to enhance your interaction with the Scriptures. This allows users to immerse themselves in the text, crafting a personal journey through the Bible that can be revisited in future sessions. Furthermore, our innovative linker system assigns each visitor a unique identifier (GUID) - no login required. This means you can create notes, select favorite verses, and even share sessions, while maintaining control over your personalized content. + +A distinctive feature of our application is the integration with OpenAI. This advanced capability allows website owners to create custom prompts to interact with OpenAI using text from any translation. This function allows you to ask questions, gain clarity, and deepen your understanding of the Scriptures in an engaging and user-friendly manner. + +In essence, The Bible for Joomla is designed to transform how the Word of God is shared, studied, and comprehended. Its comprehensive features, combined with a user-friendly interface, make it an essential tool for individuals, churches, and website owners alike. Join us on this journey of faith as we make the wisdom and guidance of the Scriptures accessible to all, one verse, one language, and one website at a time. + +# Build Details + ++ *Company*: [Vast Development Method](https://getbible.net) ++ *Author*: [Llewellyn van der Merwe](mailto:joomla@vdm.io) ++ *Name*: [Get Bible](https://getbible.net) ++ *First Build*: 3rd December, 2015 ++ *Last Build*: 26th July, 2023 ++ *Version*: 2.0.1 ++ *Copyright*: Copyright (C) 2015. All Rights Reserved ++ *License*: GNU/GPL Version 2 or later - http://www.gnu.org/licenses/gpl-2.0.html + +## Build Time + +**530 Hours** or **66 Eight Hour Days** (actual time the author saved - +due to [Automated Component Builder](https://www.joomlacomponentbuilder.com)) + +> (if creating a folder and file took **5 seconds** and writing one line of code took **10 seconds**, +> never making one mistake or taking any coffee break.) + ++ *Line count*: **189808** ++ *File count*: **1660** ++ *Folder count*: **161** + +**349 Hours** or **44 Eight Hour Days** (the actual time the author spent) + +> (with the following break down: +> **debugging @132hours** = codingtime / 4; +> **planning @76hours** = codingtime / 7; +> **mapping @53hours** = codingtime / 10; +> **office @88hours** = codingtime / 6;) + +**879 Hours** or **110 Eight Hour Days** +(a total of the realistic time frame for this project) + +> (if creating a folder and file took **5 seconds** and writing one line of code took **10 seconds**, +> with the normal everyday realities at the office, that includes the component planning, mapping & debugging.) + +Project duration: **22 weeks** or **4.6 months** + +> This **component** was build with a Joomla [Automated Component Builder](https://www.joomlacomponentbuilder.com). +> Developed by [Llewellyn van der Merwe](mailto:joomla@vdm.io) + +## Donations + +If you want to support this project, please consider donating: +* Open Collective: [Joomla-Component-Builder](https://opencollective.com/Joomla-Component-Builder) \ No newline at end of file diff --git a/admin/access.xml b/admin/access.xml new file mode 100644 index 0000000..f722b7d --- /dev/null +++ b/admin/access.xml @@ -0,0 +1,505 @@ + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+
+ + + + + + + + + + +
+
+ + + + + + + + + + + + + + + + +
+
+ + + + + + + + + + + + + + + + + +
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+
+ + + + + + + + + + + + + + + + +
+
+ + + + + + + + + + + + + + +
+
+ + + + + + + + + + + + + + +
+
+ + + + + + + + + + + + + + + + + + + + + + + + + +
+
+ + + + + + + + + + + + +
+
+ + + + + + + + + + + + + +
+
+ + + + + + + + + + + + + + +
+
\ No newline at end of file diff --git a/admin/assets/css/admin.css b/admin/assets/css/admin.css new file mode 100644 index 0000000..c9c3e5e --- /dev/null +++ b/admin/assets/css/admin.css @@ -0,0 +1,21 @@ +/*----------------------------------------------------------------------------------| io.vdm.dev |----/ + Vast Development Method +/-------------------------------------------------------------------------------------------------------/ + + @package getBible.net + + @created 3rd December, 2015 + @author Llewellyn van der Merwe + @git Get Bible + @github Get Bible + @support Get Bible + @copyright Copyright (C) 2015. All Rights Reserved + @license GNU/GPL Version 2 or later - http://www.gnu.org/licenses/gpl-2.0.html + +/------------------------------------------------------------------------------------------------------*/ + +/* CSS Document */ +.no-click { + pointer-events: none; +} + diff --git a/admin/assets/css/book.css b/admin/assets/css/book.css new file mode 100644 index 0000000..488f773 --- /dev/null +++ b/admin/assets/css/book.css @@ -0,0 +1,19 @@ +/*----------------------------------------------------------------------------------| io.vdm.dev |----/ + Vast Development Method +/-------------------------------------------------------------------------------------------------------/ + + @package getBible.net + + @created 3rd December, 2015 + @author Llewellyn van der Merwe + @git Get Bible + @github Get Bible + @support Get Bible + @copyright Copyright (C) 2015. All Rights Reserved + @license GNU/GPL Version 2 or later - http://www.gnu.org/licenses/gpl-2.0.html + +/------------------------------------------------------------------------------------------------------*/ + +/* CSS Document */ + + diff --git a/admin/assets/css/books.css b/admin/assets/css/books.css new file mode 100644 index 0000000..488f773 --- /dev/null +++ b/admin/assets/css/books.css @@ -0,0 +1,19 @@ +/*----------------------------------------------------------------------------------| io.vdm.dev |----/ + Vast Development Method +/-------------------------------------------------------------------------------------------------------/ + + @package getBible.net + + @created 3rd December, 2015 + @author Llewellyn van der Merwe + @git Get Bible + @github Get Bible + @support Get Bible + @copyright Copyright (C) 2015. All Rights Reserved + @license GNU/GPL Version 2 or later - http://www.gnu.org/licenses/gpl-2.0.html + +/------------------------------------------------------------------------------------------------------*/ + +/* CSS Document */ + + diff --git a/admin/assets/css/chapter.css b/admin/assets/css/chapter.css new file mode 100644 index 0000000..488f773 --- /dev/null +++ b/admin/assets/css/chapter.css @@ -0,0 +1,19 @@ +/*----------------------------------------------------------------------------------| io.vdm.dev |----/ + Vast Development Method +/-------------------------------------------------------------------------------------------------------/ + + @package getBible.net + + @created 3rd December, 2015 + @author Llewellyn van der Merwe + @git Get Bible + @github Get Bible + @support Get Bible + @copyright Copyright (C) 2015. All Rights Reserved + @license GNU/GPL Version 2 or later - http://www.gnu.org/licenses/gpl-2.0.html + +/------------------------------------------------------------------------------------------------------*/ + +/* CSS Document */ + + diff --git a/admin/assets/css/chapters.css b/admin/assets/css/chapters.css new file mode 100644 index 0000000..488f773 --- /dev/null +++ b/admin/assets/css/chapters.css @@ -0,0 +1,19 @@ +/*----------------------------------------------------------------------------------| io.vdm.dev |----/ + Vast Development Method +/-------------------------------------------------------------------------------------------------------/ + + @package getBible.net + + @created 3rd December, 2015 + @author Llewellyn van der Merwe + @git Get Bible + @github Get Bible + @support Get Bible + @copyright Copyright (C) 2015. All Rights Reserved + @license GNU/GPL Version 2 or later - http://www.gnu.org/licenses/gpl-2.0.html + +/------------------------------------------------------------------------------------------------------*/ + +/* CSS Document */ + + diff --git a/admin/assets/css/dashboard.css b/admin/assets/css/dashboard.css new file mode 100644 index 0000000..10742d8 --- /dev/null +++ b/admin/assets/css/dashboard.css @@ -0,0 +1,169 @@ +/*----------------------------------------------------------------------------------| io.vdm.dev |----/ + Vast Development Method +/-------------------------------------------------------------------------------------------------------/ + + @package getBible.net + + @created 3rd December, 2015 + @author Llewellyn van der Merwe + @git Get Bible + @github Get Bible + @support Get Bible + @copyright Copyright (C) 2015. All Rights Reserved + @license GNU/GPL Version 2 or later - http://www.gnu.org/licenses/gpl-2.0.html + +/------------------------------------------------------------------------------------------------------*/ + +/* CSS Document */ + +.dashboard-container { + margin-left: 10px; + margin-top: 10px; + width: 100%; +} +.dashboard-container [class*="span"] { + display: block; + float: none; + margin-left: 0; + width: auto; +} +.dashboard-container:before, .dashboard-container:after { + content: ""; + display: table; +} +.dashboard-container:after { + clear: both; +} +.dashboard-container [class*="span"] { + box-sizing: border-box; + display: block; + float: left; + min-height: 145px; + min-width: 96px; + width: 100%; +} +.dashboard-container [class*="span"]:first-child { + margin-left: 0; +} +.dashboard-wraper { + background: none repeat scroll 0 0 hsl(0, 0%, 93%); + border-radius: 5px; + float: left; + margin: 1%; + padding: 3px; + width: 17%; + min-height: 194px; + min-width: 96px; +} +.dashboard-content a { + background: linear-gradient(to bottom, hsl(0, 0%, 100%) 0%, hsl(0, 0%, 96%) 47%, hsl(0, 0%, 93%) 100%) repeat scroll 0 0 hsla(0, 0%, 0%, 0); + border: 1px solid hsl(0, 0%, 85%); + border-radius: 4px; + box-shadow: 0 0 3px hsla(0, 0%, 0%, 0.1) inset; + color: hsl(0, 0%, 20%); + display: block; + min-height: 89px; + padding: 10px; + text-align: center; + text-decoration: none; +} +.dashboard-content a:hover { + background: linear-gradient(to bottom, hsl(0, 0%, 90%) 0%, hsl(0, 0%, 100%) 100%) repeat scroll 0 0 hsla(0, 0%, 0%, 0); + color: hsl(200, 100%, 30%); + text-decoration: none; +} +.dashboard-title { + display: block; + padding-top: 5px; +} +.dashboard-info { + background: linear-gradient(to bottom, hsl(0, 0%, 100%) 0%, hsl(0, 0%, 96%) 47%, hsl(0, 0%, 93%) 100%) repeat scroll 0 0 hsla(0, 0%, 0%, 0); + border: 1px solid hsl(0, 0%, 85%); + border-radius: 4px; + box-shadow: 0 0 3px hsla(0, 0%, 0%, 0.1) inset; + color: hsl(0, 0%, 20%); + display: block; + font-size: 12px; + padding: 10px; + text-align: center; +} +.dashboard-info span { + display: block; + text-align: center; +} +.dashboard-info img { + margin: 0 auto; +} +.dashboard-table { + border-top: 1px solid hsl(0, 0%, 87%); + margin-top: 5px; + width: 100%; +} +.dashboard-info h5 { + font-size: 11px; + font-weight: bold; +} +.dashboard-block { + background: linear-gradient(to bottom, hsl(0, 0%, 95%) 0%, hsl(0, 0%, 86%) 100%) repeat scroll 0 0 hsla(0, 0%, 0%, 0); + border: 1px solid hsl(0, 0%, 76%); + border-radius: 3px; + box-shadow: 0 1px 0 hsl(0, 0%, 98%) inset; + margin-bottom: 20px; +} +.dashboard-block .dashboard-block-head { + background: linear-gradient(to bottom, hsl(0, 0%, 95%) 0%, hsl(0, 0%, 86%) 100%) repeat scroll 0 0 hsla(0, 0%, 0%, 0); + border-bottom: 1px solid hsl(0, 0%, 76%); + border-radius: 3px 3px 0 0; + box-shadow: 0 1px 0 hsl(0, 0%, 98%) inset, 0 0 3px hsl(0, 0%, 87%); + height: 40px; + position: relative; +} +.dashboard-block .dashboard-block-head h5 { + font-size: 12px; + margin: 0; + padding-left: 10px; + padding-top: 11px; + text-transform: uppercase; +} +.dashboard-block .dashboard-block-content { + background: none repeat scroll 0 0 hsl(0, 0%, 93%); + border-radius: 0 0 3px 3px; +} +.dashboard-block .dashboard-block-box { + background: none repeat scroll 0 0 hsl(0, 0%, 100%); + border-top: 1px solid hsl(0, 0%, 82%); + box-shadow: 0 0 5px hsl(0, 0%, 87%) inset; +} +.dashboard-block .dashboard-block-content .dashboard-block-box { + margin-top: 0 !important; +} +.dashboard-block .dashboard-block-content .dashboard-block-box .dashboard-block-table { + margin-bottom: 0 !important; +} +.dashboard-block-table { + background-color: hsla(0, 0%, 0%, 0); + border-collapse: collapse; + border-spacing: 0; + margin-bottom: 20px; + max-width: 100%; + width: 100%; +} +.dashboard-block-table th, .dashboard-block-table td { + border-top: 1px solid hsl(0, 0%, 87%); + line-height: 20px; + padding: 5px; + text-align: left; + vertical-align: middle; +} +.dashboard-badge { + background-color: hsl(0, 0%, 60%); + border-radius: 9px; + color: hsl(0, 0%, 100%); + font-size: 11.844px; + font-weight: bold; + line-height: 14px; + padding: 1px 9px 2px; + text-shadow: 0 -1px 0 hsla(0, 0%, 0%, 0.25); + vertical-align: baseline; + white-space: nowrap; +} \ No newline at end of file diff --git a/admin/assets/css/index.html b/admin/assets/css/index.html new file mode 100644 index 0000000..fa6d84e --- /dev/null +++ b/admin/assets/css/index.html @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/admin/assets/css/linker.css b/admin/assets/css/linker.css new file mode 100644 index 0000000..488f773 --- /dev/null +++ b/admin/assets/css/linker.css @@ -0,0 +1,19 @@ +/*----------------------------------------------------------------------------------| io.vdm.dev |----/ + Vast Development Method +/-------------------------------------------------------------------------------------------------------/ + + @package getBible.net + + @created 3rd December, 2015 + @author Llewellyn van der Merwe + @git Get Bible + @github Get Bible + @support Get Bible + @copyright Copyright (C) 2015. All Rights Reserved + @license GNU/GPL Version 2 or later - http://www.gnu.org/licenses/gpl-2.0.html + +/------------------------------------------------------------------------------------------------------*/ + +/* CSS Document */ + + diff --git a/admin/assets/css/linkers.css b/admin/assets/css/linkers.css new file mode 100644 index 0000000..488f773 --- /dev/null +++ b/admin/assets/css/linkers.css @@ -0,0 +1,19 @@ +/*----------------------------------------------------------------------------------| io.vdm.dev |----/ + Vast Development Method +/-------------------------------------------------------------------------------------------------------/ + + @package getBible.net + + @created 3rd December, 2015 + @author Llewellyn van der Merwe + @git Get Bible + @github Get Bible + @support Get Bible + @copyright Copyright (C) 2015. All Rights Reserved + @license GNU/GPL Version 2 or later - http://www.gnu.org/licenses/gpl-2.0.html + +/------------------------------------------------------------------------------------------------------*/ + +/* CSS Document */ + + diff --git a/admin/assets/css/note.css b/admin/assets/css/note.css new file mode 100644 index 0000000..488f773 --- /dev/null +++ b/admin/assets/css/note.css @@ -0,0 +1,19 @@ +/*----------------------------------------------------------------------------------| io.vdm.dev |----/ + Vast Development Method +/-------------------------------------------------------------------------------------------------------/ + + @package getBible.net + + @created 3rd December, 2015 + @author Llewellyn van der Merwe + @git Get Bible + @github Get Bible + @support Get Bible + @copyright Copyright (C) 2015. All Rights Reserved + @license GNU/GPL Version 2 or later - http://www.gnu.org/licenses/gpl-2.0.html + +/------------------------------------------------------------------------------------------------------*/ + +/* CSS Document */ + + diff --git a/admin/assets/css/notes.css b/admin/assets/css/notes.css new file mode 100644 index 0000000..488f773 --- /dev/null +++ b/admin/assets/css/notes.css @@ -0,0 +1,19 @@ +/*----------------------------------------------------------------------------------| io.vdm.dev |----/ + Vast Development Method +/-------------------------------------------------------------------------------------------------------/ + + @package getBible.net + + @created 3rd December, 2015 + @author Llewellyn van der Merwe + @git Get Bible + @github Get Bible + @support Get Bible + @copyright Copyright (C) 2015. All Rights Reserved + @license GNU/GPL Version 2 or later - http://www.gnu.org/licenses/gpl-2.0.html + +/------------------------------------------------------------------------------------------------------*/ + +/* CSS Document */ + + diff --git a/admin/assets/css/open_ai_message.css b/admin/assets/css/open_ai_message.css new file mode 100644 index 0000000..488f773 --- /dev/null +++ b/admin/assets/css/open_ai_message.css @@ -0,0 +1,19 @@ +/*----------------------------------------------------------------------------------| io.vdm.dev |----/ + Vast Development Method +/-------------------------------------------------------------------------------------------------------/ + + @package getBible.net + + @created 3rd December, 2015 + @author Llewellyn van der Merwe + @git Get Bible + @github Get Bible + @support Get Bible + @copyright Copyright (C) 2015. All Rights Reserved + @license GNU/GPL Version 2 or later - http://www.gnu.org/licenses/gpl-2.0.html + +/------------------------------------------------------------------------------------------------------*/ + +/* CSS Document */ + + diff --git a/admin/assets/css/open_ai_messages.css b/admin/assets/css/open_ai_messages.css new file mode 100644 index 0000000..488f773 --- /dev/null +++ b/admin/assets/css/open_ai_messages.css @@ -0,0 +1,19 @@ +/*----------------------------------------------------------------------------------| io.vdm.dev |----/ + Vast Development Method +/-------------------------------------------------------------------------------------------------------/ + + @package getBible.net + + @created 3rd December, 2015 + @author Llewellyn van der Merwe + @git Get Bible + @github Get Bible + @support Get Bible + @copyright Copyright (C) 2015. All Rights Reserved + @license GNU/GPL Version 2 or later - http://www.gnu.org/licenses/gpl-2.0.html + +/------------------------------------------------------------------------------------------------------*/ + +/* CSS Document */ + + diff --git a/admin/assets/css/open_ai_response.css b/admin/assets/css/open_ai_response.css new file mode 100644 index 0000000..488f773 --- /dev/null +++ b/admin/assets/css/open_ai_response.css @@ -0,0 +1,19 @@ +/*----------------------------------------------------------------------------------| io.vdm.dev |----/ + Vast Development Method +/-------------------------------------------------------------------------------------------------------/ + + @package getBible.net + + @created 3rd December, 2015 + @author Llewellyn van der Merwe + @git Get Bible + @github Get Bible + @support Get Bible + @copyright Copyright (C) 2015. All Rights Reserved + @license GNU/GPL Version 2 or later - http://www.gnu.org/licenses/gpl-2.0.html + +/------------------------------------------------------------------------------------------------------*/ + +/* CSS Document */ + + diff --git a/admin/assets/css/open_ai_responses.css b/admin/assets/css/open_ai_responses.css new file mode 100644 index 0000000..488f773 --- /dev/null +++ b/admin/assets/css/open_ai_responses.css @@ -0,0 +1,19 @@ +/*----------------------------------------------------------------------------------| io.vdm.dev |----/ + Vast Development Method +/-------------------------------------------------------------------------------------------------------/ + + @package getBible.net + + @created 3rd December, 2015 + @author Llewellyn van der Merwe + @git Get Bible + @github Get Bible + @support Get Bible + @copyright Copyright (C) 2015. All Rights Reserved + @license GNU/GPL Version 2 or later - http://www.gnu.org/licenses/gpl-2.0.html + +/------------------------------------------------------------------------------------------------------*/ + +/* CSS Document */ + + diff --git a/admin/assets/css/password.css b/admin/assets/css/password.css new file mode 100644 index 0000000..488f773 --- /dev/null +++ b/admin/assets/css/password.css @@ -0,0 +1,19 @@ +/*----------------------------------------------------------------------------------| io.vdm.dev |----/ + Vast Development Method +/-------------------------------------------------------------------------------------------------------/ + + @package getBible.net + + @created 3rd December, 2015 + @author Llewellyn van der Merwe + @git Get Bible + @github Get Bible + @support Get Bible + @copyright Copyright (C) 2015. All Rights Reserved + @license GNU/GPL Version 2 or later - http://www.gnu.org/licenses/gpl-2.0.html + +/------------------------------------------------------------------------------------------------------*/ + +/* CSS Document */ + + diff --git a/admin/assets/css/passwords.css b/admin/assets/css/passwords.css new file mode 100644 index 0000000..488f773 --- /dev/null +++ b/admin/assets/css/passwords.css @@ -0,0 +1,19 @@ +/*----------------------------------------------------------------------------------| io.vdm.dev |----/ + Vast Development Method +/-------------------------------------------------------------------------------------------------------/ + + @package getBible.net + + @created 3rd December, 2015 + @author Llewellyn van der Merwe + @git Get Bible + @github Get Bible + @support Get Bible + @copyright Copyright (C) 2015. All Rights Reserved + @license GNU/GPL Version 2 or later - http://www.gnu.org/licenses/gpl-2.0.html + +/------------------------------------------------------------------------------------------------------*/ + +/* CSS Document */ + + diff --git a/admin/assets/css/prompt.css b/admin/assets/css/prompt.css new file mode 100644 index 0000000..488f773 --- /dev/null +++ b/admin/assets/css/prompt.css @@ -0,0 +1,19 @@ +/*----------------------------------------------------------------------------------| io.vdm.dev |----/ + Vast Development Method +/-------------------------------------------------------------------------------------------------------/ + + @package getBible.net + + @created 3rd December, 2015 + @author Llewellyn van der Merwe + @git Get Bible + @github Get Bible + @support Get Bible + @copyright Copyright (C) 2015. All Rights Reserved + @license GNU/GPL Version 2 or later - http://www.gnu.org/licenses/gpl-2.0.html + +/------------------------------------------------------------------------------------------------------*/ + +/* CSS Document */ + + diff --git a/admin/assets/css/prompts.css b/admin/assets/css/prompts.css new file mode 100644 index 0000000..488f773 --- /dev/null +++ b/admin/assets/css/prompts.css @@ -0,0 +1,19 @@ +/*----------------------------------------------------------------------------------| io.vdm.dev |----/ + Vast Development Method +/-------------------------------------------------------------------------------------------------------/ + + @package getBible.net + + @created 3rd December, 2015 + @author Llewellyn van der Merwe + @git Get Bible + @github Get Bible + @support Get Bible + @copyright Copyright (C) 2015. All Rights Reserved + @license GNU/GPL Version 2 or later - http://www.gnu.org/licenses/gpl-2.0.html + +/------------------------------------------------------------------------------------------------------*/ + +/* CSS Document */ + + diff --git a/admin/assets/css/tag.css b/admin/assets/css/tag.css new file mode 100644 index 0000000..488f773 --- /dev/null +++ b/admin/assets/css/tag.css @@ -0,0 +1,19 @@ +/*----------------------------------------------------------------------------------| io.vdm.dev |----/ + Vast Development Method +/-------------------------------------------------------------------------------------------------------/ + + @package getBible.net + + @created 3rd December, 2015 + @author Llewellyn van der Merwe + @git Get Bible + @github Get Bible + @support Get Bible + @copyright Copyright (C) 2015. All Rights Reserved + @license GNU/GPL Version 2 or later - http://www.gnu.org/licenses/gpl-2.0.html + +/------------------------------------------------------------------------------------------------------*/ + +/* CSS Document */ + + diff --git a/admin/assets/css/tagged_verse.css b/admin/assets/css/tagged_verse.css new file mode 100644 index 0000000..488f773 --- /dev/null +++ b/admin/assets/css/tagged_verse.css @@ -0,0 +1,19 @@ +/*----------------------------------------------------------------------------------| io.vdm.dev |----/ + Vast Development Method +/-------------------------------------------------------------------------------------------------------/ + + @package getBible.net + + @created 3rd December, 2015 + @author Llewellyn van der Merwe + @git Get Bible + @github Get Bible + @support Get Bible + @copyright Copyright (C) 2015. All Rights Reserved + @license GNU/GPL Version 2 or later - http://www.gnu.org/licenses/gpl-2.0.html + +/------------------------------------------------------------------------------------------------------*/ + +/* CSS Document */ + + diff --git a/admin/assets/css/tagged_verses.css b/admin/assets/css/tagged_verses.css new file mode 100644 index 0000000..488f773 --- /dev/null +++ b/admin/assets/css/tagged_verses.css @@ -0,0 +1,19 @@ +/*----------------------------------------------------------------------------------| io.vdm.dev |----/ + Vast Development Method +/-------------------------------------------------------------------------------------------------------/ + + @package getBible.net + + @created 3rd December, 2015 + @author Llewellyn van der Merwe + @git Get Bible + @github Get Bible + @support Get Bible + @copyright Copyright (C) 2015. All Rights Reserved + @license GNU/GPL Version 2 or later - http://www.gnu.org/licenses/gpl-2.0.html + +/------------------------------------------------------------------------------------------------------*/ + +/* CSS Document */ + + diff --git a/admin/assets/css/tags.css b/admin/assets/css/tags.css new file mode 100644 index 0000000..488f773 --- /dev/null +++ b/admin/assets/css/tags.css @@ -0,0 +1,19 @@ +/*----------------------------------------------------------------------------------| io.vdm.dev |----/ + Vast Development Method +/-------------------------------------------------------------------------------------------------------/ + + @package getBible.net + + @created 3rd December, 2015 + @author Llewellyn van der Merwe + @git Get Bible + @github Get Bible + @support Get Bible + @copyright Copyright (C) 2015. All Rights Reserved + @license GNU/GPL Version 2 or later - http://www.gnu.org/licenses/gpl-2.0.html + +/------------------------------------------------------------------------------------------------------*/ + +/* CSS Document */ + + diff --git a/admin/assets/css/translation.css b/admin/assets/css/translation.css new file mode 100644 index 0000000..488f773 --- /dev/null +++ b/admin/assets/css/translation.css @@ -0,0 +1,19 @@ +/*----------------------------------------------------------------------------------| io.vdm.dev |----/ + Vast Development Method +/-------------------------------------------------------------------------------------------------------/ + + @package getBible.net + + @created 3rd December, 2015 + @author Llewellyn van der Merwe + @git Get Bible + @github Get Bible + @support Get Bible + @copyright Copyright (C) 2015. All Rights Reserved + @license GNU/GPL Version 2 or later - http://www.gnu.org/licenses/gpl-2.0.html + +/------------------------------------------------------------------------------------------------------*/ + +/* CSS Document */ + + diff --git a/admin/assets/css/translations.css b/admin/assets/css/translations.css new file mode 100644 index 0000000..488f773 --- /dev/null +++ b/admin/assets/css/translations.css @@ -0,0 +1,19 @@ +/*----------------------------------------------------------------------------------| io.vdm.dev |----/ + Vast Development Method +/-------------------------------------------------------------------------------------------------------/ + + @package getBible.net + + @created 3rd December, 2015 + @author Llewellyn van der Merwe + @git Get Bible + @github Get Bible + @support Get Bible + @copyright Copyright (C) 2015. All Rights Reserved + @license GNU/GPL Version 2 or later - http://www.gnu.org/licenses/gpl-2.0.html + +/------------------------------------------------------------------------------------------------------*/ + +/* CSS Document */ + + diff --git a/admin/assets/css/verse.css b/admin/assets/css/verse.css new file mode 100644 index 0000000..488f773 --- /dev/null +++ b/admin/assets/css/verse.css @@ -0,0 +1,19 @@ +/*----------------------------------------------------------------------------------| io.vdm.dev |----/ + Vast Development Method +/-------------------------------------------------------------------------------------------------------/ + + @package getBible.net + + @created 3rd December, 2015 + @author Llewellyn van der Merwe + @git Get Bible + @github Get Bible + @support Get Bible + @copyright Copyright (C) 2015. All Rights Reserved + @license GNU/GPL Version 2 or later - http://www.gnu.org/licenses/gpl-2.0.html + +/------------------------------------------------------------------------------------------------------*/ + +/* CSS Document */ + + diff --git a/admin/assets/css/verses.css b/admin/assets/css/verses.css new file mode 100644 index 0000000..488f773 --- /dev/null +++ b/admin/assets/css/verses.css @@ -0,0 +1,19 @@ +/*----------------------------------------------------------------------------------| io.vdm.dev |----/ + Vast Development Method +/-------------------------------------------------------------------------------------------------------/ + + @package getBible.net + + @created 3rd December, 2015 + @author Llewellyn van der Merwe + @git Get Bible + @github Get Bible + @support Get Bible + @copyright Copyright (C) 2015. All Rights Reserved + @license GNU/GPL Version 2 or later - http://www.gnu.org/licenses/gpl-2.0.html + +/------------------------------------------------------------------------------------------------------*/ + +/* CSS Document */ + + diff --git a/admin/assets/images/ajax.gif b/admin/assets/images/ajax.gif new file mode 100644 index 0000000..4371cc6 Binary files /dev/null and b/admin/assets/images/ajax.gif differ diff --git a/admin/assets/images/icons/books.png b/admin/assets/images/icons/books.png new file mode 100644 index 0000000..3076ed4 Binary files /dev/null and b/admin/assets/images/icons/books.png differ diff --git a/admin/assets/images/icons/chapters.png b/admin/assets/images/icons/chapters.png new file mode 100644 index 0000000..a19f2f3 Binary files /dev/null and b/admin/assets/images/icons/chapters.png differ diff --git a/admin/assets/images/icons/index.html b/admin/assets/images/icons/index.html new file mode 100644 index 0000000..fa6d84e --- /dev/null +++ b/admin/assets/images/icons/index.html @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/admin/assets/images/icons/linkers.png b/admin/assets/images/icons/linkers.png new file mode 100644 index 0000000..47f6805 Binary files /dev/null and b/admin/assets/images/icons/linkers.png differ diff --git a/admin/assets/images/icons/notes.png b/admin/assets/images/icons/notes.png new file mode 100644 index 0000000..c711b37 Binary files /dev/null and b/admin/assets/images/icons/notes.png differ diff --git a/admin/assets/images/icons/open_ai_responses.png b/admin/assets/images/icons/open_ai_responses.png new file mode 100644 index 0000000..fd3339c Binary files /dev/null and b/admin/assets/images/icons/open_ai_responses.png differ diff --git a/admin/assets/images/icons/prompts.png b/admin/assets/images/icons/prompts.png new file mode 100644 index 0000000..596f419 Binary files /dev/null and b/admin/assets/images/icons/prompts.png differ diff --git a/admin/assets/images/icons/tagged_verses.png b/admin/assets/images/icons/tagged_verses.png new file mode 100644 index 0000000..743dfaa Binary files /dev/null and b/admin/assets/images/icons/tagged_verses.png differ diff --git a/admin/assets/images/icons/tags.png b/admin/assets/images/icons/tags.png new file mode 100644 index 0000000..56ebd91 Binary files /dev/null and b/admin/assets/images/icons/tags.png differ diff --git a/admin/assets/images/icons/translations.png b/admin/assets/images/icons/translations.png new file mode 100644 index 0000000..4c3ca8c Binary files /dev/null and b/admin/assets/images/icons/translations.png differ diff --git a/admin/assets/images/icons/verses.png b/admin/assets/images/icons/verses.png new file mode 100644 index 0000000..9be5da3 Binary files /dev/null and b/admin/assets/images/icons/verses.png differ diff --git a/admin/assets/images/import.gif b/admin/assets/images/import.gif new file mode 100644 index 0000000..4371cc6 Binary files /dev/null and b/admin/assets/images/import.gif differ diff --git a/admin/assets/images/index.html b/admin/assets/images/index.html new file mode 100644 index 0000000..fa6d84e --- /dev/null +++ b/admin/assets/images/index.html @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/admin/assets/images/vdm-component.jpg b/admin/assets/images/vdm-component.jpg new file mode 100644 index 0000000..be6df55 Binary files /dev/null and b/admin/assets/images/vdm-component.jpg differ diff --git a/admin/assets/index.html b/admin/assets/index.html new file mode 100644 index 0000000..fa6d84e --- /dev/null +++ b/admin/assets/index.html @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/admin/assets/js/admin.js b/admin/assets/js/admin.js new file mode 100644 index 0000000..a32768d --- /dev/null +++ b/admin/assets/js/admin.js @@ -0,0 +1,17 @@ +/*----------------------------------------------------------------------------------| io.vdm.dev |----/ + Vast Development Method +/-------------------------------------------------------------------------------------------------------/ + + @package getBible.net + + @created 3rd December, 2015 + @author Llewellyn van der Merwe + @git Get Bible + @github Get Bible + @support Get Bible + @copyright Copyright (C) 2015. All Rights Reserved + @license GNU/GPL Version 2 or later - http://www.gnu.org/licenses/gpl-2.0.html + +/------------------------------------------------------------------------------------------------------*/ + +/* JS Document */ diff --git a/admin/assets/js/index.html b/admin/assets/js/index.html new file mode 100644 index 0000000..fa6d84e --- /dev/null +++ b/admin/assets/js/index.html @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/admin/config.xml b/admin/config.xml new file mode 100644 index 0000000..eacee4b --- /dev/null +++ b/admin/config.xml @@ -0,0 +1,1444 @@ + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+
+ + + " + " + + + + " + " + " + + + + " + " + +
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+
+ + + + + + + +
+
+ + + + + + + + + + + + + +
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+
+ +
+
\ No newline at end of file diff --git a/admin/controller.php b/admin/controller.php new file mode 100644 index 0000000..0b43409 --- /dev/null +++ b/admin/controller.php @@ -0,0 +1,130 @@ + + @git Get Bible + @github Get Bible + @support Get Bible + @copyright Copyright (C) 2015. All Rights Reserved + @license GNU/GPL Version 2 or later - http://www.gnu.org/licenses/gpl-2.0.html + +/------------------------------------------------------------------------------------------------------*/ + +// No direct access to this file +defined('_JEXEC') or die('Restricted access'); + +use Joomla\CMS\MVC\Controller\BaseController; +use Joomla\Utilities\ArrayHelper; + +/** + * General Controller of Getbible component + */ +class GetbibleController extends BaseController +{ + /** + * Constructor. + * + * @param array $config An optional associative array of configuration settings. + * Recognized key values include 'name', 'default_task', 'model_path', and + * 'view_path' (this list is not meant to be comprehensive). + * + * @since 3.0 + */ + public function __construct($config = array()) + { + // set the default view + $config['default_view'] = 'getbible'; + + parent::__construct($config); + } + + /** + * display task + * + * @return void + */ + function display($cachable = false, $urlparams = false) + { + // set default view if not set + $view = $this->input->getCmd('view', 'getbible'); + $data = $this->getViewRelation($view); + $layout = $this->input->get('layout', null, 'WORD'); + $id = $this->input->getInt('id'); + + // Check for edit form. + if(GetbibleHelper::checkArray($data)) + { + if ($data['edit'] && $layout == 'edit' && !$this->checkEditId('com_getbible.edit.'.$data['view'], $id)) + { + // Somehow the person just went to the form - we don't allow that. + $this->setError(JText::sprintf('JLIB_APPLICATION_ERROR_UNHELD_ID', $id)); + $this->setMessage($this->getError(), 'error'); + // check if item was opend from other then its own list view + $ref = $this->input->getCmd('ref', 0); + $refid = $this->input->getInt('refid', 0); + // set redirect + if ($refid > 0 && GetbibleHelper::checkString($ref)) + { + // redirect to item of ref + $this->setRedirect(JRoute::_('index.php?option=com_getbible&view='.(string)$ref.'&layout=edit&id='.(int)$refid, false)); + } + elseif (GetbibleHelper::checkString($ref)) + { + + // redirect to ref + $this->setRedirect(JRoute::_('index.php?option=com_getbible&view='.(string)$ref, false)); + } + else + { + // normal redirect back to the list view + $this->setRedirect(JRoute::_('index.php?option=com_getbible&view='.$data['views'], false)); + } + + return false; + } + } + + return parent::display($cachable, $urlparams); + } + + protected function getViewRelation($view) + { + // check the we have a value + if (GetbibleHelper::checkString($view)) + { + // the view relationships + $views = array( + 'linker' => 'linkers', + 'note' => 'notes', + 'tagged_verse' => 'tagged_verses', + 'prompt' => 'prompts', + 'open_ai_response' => 'open_ai_responses', + 'open_ai_message' => 'open_ai_messages', + 'password' => 'passwords', + 'tag' => 'tags', + 'translation' => 'translations', + 'book' => 'books', + 'chapter' => 'chapters', + 'verse' => 'verses' + ); + // check if this is a list view + if (in_array($view, $views)) + { + // this is a list view + return array('edit' => false, 'view' => array_search($view,$views), 'views' => $view); + } + // check if it is an edit view + elseif (array_key_exists($view, $views)) + { + // this is a edit view + return array('edit' => true, 'view' => $view, 'views' => $views[$view]); + } + } + return false; + } +} diff --git a/admin/controllers/ajax.json.php b/admin/controllers/ajax.json.php new file mode 100644 index 0000000..156bbaa --- /dev/null +++ b/admin/controllers/ajax.json.php @@ -0,0 +1,247 @@ + + @git Get Bible + @github Get Bible + @support Get Bible + @copyright Copyright (C) 2015. All Rights Reserved + @license GNU/GPL Version 2 or later - http://www.gnu.org/licenses/gpl-2.0.html + +/------------------------------------------------------------------------------------------------------*/ + +// No direct access to this file +defined('_JEXEC') or die('Restricted access'); + +use Joomla\CMS\MVC\Controller\BaseController; +use Joomla\Utilities\ArrayHelper; + +/** + * Getbible Ajax Base Controller + */ +class GetbibleControllerAjax extends BaseController +{ + public function __construct($config) + { + parent::__construct($config); + // make sure all json stuff are set + JFactory::getDocument()->setMimeEncoding( 'application/json' ); + // get the application + $app = JFactory::getApplication(); + $app->setHeader('Content-Disposition','attachment;filename="getajax.json"'); + $app->setHeader('Access-Control-Allow-Origin', '*'); + // load the tasks + $this->registerTask('isNew', 'ajax'); + $this->registerTask('isRead', 'ajax'); + $this->registerTask('getWiki', 'ajax'); + $this->registerTask('getVersion', 'ajax'); + } + + public function ajax() + { + // get the user for later use + $user = JFactory::getUser(); + // get the input values + $jinput = JFactory::getApplication()->input; + // check if we should return raw + $returnRaw = $jinput->get('raw', false, 'BOOLEAN'); + // return to a callback function + $callback = $jinput->get('callback', null, 'CMD'); + // Check Token! + $token = JSession::getFormToken(); + $call_token = $jinput->get('token', 0, 'ALNUM'); + if($jinput->get($token, 0, 'ALNUM') || $token === $call_token) + { + // get the task + $task = $this->getTask(); + switch($task) + { + case 'isNew': + try + { + $noticeValue = $jinput->get('notice', NULL, 'STRING'); + if($noticeValue && $user->id != 0) + { + $result = $this->getModel('ajax')->isNew($noticeValue); + } + else + { + $result = false; + } + if($callback) + { + echo $callback . "(".json_encode($result).");"; + } + elseif($returnRaw) + { + echo json_encode($result); + } + else + { + echo "(".json_encode($result).");"; + } + } + catch(Exception $e) + { + if($callback) + { + echo $callback."(".json_encode($e).");"; + } + elseif($returnRaw) + { + echo json_encode($e); + } + else + { + echo "(".json_encode($e).");"; + } + } + break; + case 'isRead': + try + { + $noticeValue = $jinput->get('notice', NULL, 'STRING'); + if($noticeValue && $user->id != 0) + { + $result = $this->getModel('ajax')->isRead($noticeValue); + } + else + { + $result = false; + } + if($callback) + { + echo $callback . "(".json_encode($result).");"; + } + elseif($returnRaw) + { + echo json_encode($result); + } + else + { + echo "(".json_encode($result).");"; + } + } + catch(Exception $e) + { + if($callback) + { + echo $callback."(".json_encode($e).");"; + } + elseif($returnRaw) + { + echo json_encode($e); + } + else + { + echo "(".json_encode($e).");"; + } + } + break; + case 'getWiki': + try + { + $nameValue = $jinput->get('name', NULL, 'WORD'); + if($nameValue && $user->id != 0) + { + $result = $this->getModel('ajax')->getWiki($nameValue); + } + else + { + $result = false; + } + if($callback) + { + echo $callback . "(".json_encode($result).");"; + } + elseif($returnRaw) + { + echo json_encode($result); + } + else + { + echo "(".json_encode($result).");"; + } + } + catch(Exception $e) + { + if($callback) + { + echo $callback."(".json_encode($e).");"; + } + elseif($returnRaw) + { + echo json_encode($e); + } + else + { + echo "(".json_encode($e).");"; + } + } + break; + case 'getVersion': + try + { + $versionValue = $jinput->get('version', NULL, 'INT'); + if($versionValue && $user->id != 0) + { + $result = $this->getModel('ajax')->getVersion($versionValue); + } + else + { + $result = false; + } + if($callback) + { + echo $callback . "(".json_encode($result).");"; + } + elseif($returnRaw) + { + echo json_encode($result); + } + else + { + echo "(".json_encode($result).");"; + } + } + catch(Exception $e) + { + if($callback) + { + echo $callback."(".json_encode($e).");"; + } + elseif($returnRaw) + { + echo json_encode($e); + } + else + { + echo "(".json_encode($e).");"; + } + } + break; + } + } + else + { + // return to a callback function + if($callback) + { + echo $callback."(".json_encode(false).");"; + } + elseif($returnRaw) + { + echo json_encode(false); + } + else + { + echo "(".json_encode(false).");"; + } + } + } +} diff --git a/admin/controllers/book.php b/admin/controllers/book.php new file mode 100644 index 0000000..5323de7 --- /dev/null +++ b/admin/controllers/book.php @@ -0,0 +1,330 @@ + + @git Get Bible + @github Get Bible + @support Get Bible + @copyright Copyright (C) 2015. All Rights Reserved + @license GNU/GPL Version 2 or later - http://www.gnu.org/licenses/gpl-2.0.html + +/------------------------------------------------------------------------------------------------------*/ + +// No direct access to this file +defined('_JEXEC') or die('Restricted access'); + +use Joomla\CMS\MVC\Controller\FormController; +use Joomla\Utilities\ArrayHelper; + +/** + * Book Form Controller + */ +class GetbibleControllerBook extends FormController +{ + /** + * Current or most recently performed task. + * + * @var string + * @since 12.2 + * @note Replaces _task. + */ + protected $task; + + /** + * Class constructor. + * + * @param array $config A named array of configuration variables. + * + * @since 1.6 + */ + public function __construct($config = array()) + { + $this->view_list = 'Books'; // safeguard for setting the return view listing to the main view. + parent::__construct($config); + }###ADMIN_CUSTOM_BUTTONS_CONTROLLER### + + /** + * Method override to check if you can add a new record. + * + * @param array $data An array of input data. + * + * @return boolean + * + * @since 1.6 + */ + protected function allowAdd($data = array()) + { + // Get user object. + $user = JFactory::getUser(); + // Access check. + $access = $user->authorise('book.access', 'com_getbible'); + if (!$access) + { + return false; + } + + // In the absense of better information, revert to the component permissions. + return $user->authorise('book.create', $this->option); + } + + /** + * Method override to check if you can edit an existing record. + * + * @param array $data An array of input data. + * @param string $key The name of the key for the primary key. + * + * @return boolean + * + * @since 1.6 + */ + protected function allowEdit($data = array(), $key = 'id') + { + // get user object. + $user = JFactory::getUser(); + // get record id. + $recordId = (int) isset($data[$key]) ? $data[$key] : 0; + + + // Access check. + $access = ($user->authorise('book.access', 'com_getbible.book.' . (int) $recordId) && $user->authorise('book.access', 'com_getbible')); + if (!$access) + { + return false; + } + + if ($recordId) + { + // The record has been set. Check the record permissions. + $permission = $user->authorise('book.edit', 'com_getbible.book.' . (int) $recordId); + if (!$permission) + { + if ($user->authorise('book.edit.own', 'com_getbible.book.' . $recordId)) + { + // Now test the owner is the user. + $ownerId = (int) isset($data['created_by']) ? $data['created_by'] : 0; + if (empty($ownerId)) + { + // Need to do a lookup from the model. + $record = $this->getModel()->getItem($recordId); + + if (empty($record)) + { + return false; + } + $ownerId = $record->created_by; + } + + // If the owner matches 'me' then allow. + if ($ownerId == $user->id) + { + if ($user->authorise('book.edit.own', 'com_getbible')) + { + return true; + } + } + } + return false; + } + } + // Since there is no permission, revert to the component permissions. + return $user->authorise('book.edit', $this->option); + } + + /** + * Gets the URL arguments to append to an item redirect. + * + * @param integer $recordId The primary key id for the item. + * @param string $urlVar The name of the URL variable for the id. + * + * @return string The arguments to append to the redirect URL. + * + * @since 1.6 + */ + protected function getRedirectToItemAppend($recordId = null, $urlVar = 'id') + { + // get the referral options (old method use return instead see parent) + $ref = $this->input->get('ref', 0, 'string'); + $refid = $this->input->get('refid', 0, 'int'); + + // get redirect info. + $append = parent::getRedirectToItemAppend($recordId, $urlVar); + + // set the referral options + if ($refid && $ref) + { + $append = '&ref=' . (string)$ref . '&refid='. (int)$refid . $append; + } + elseif ($ref) + { + $append = '&ref='. (string)$ref . $append; + } + + return $append; + } + + /** + * Method to run batch operations. + * + * @param object $model The model. + * + * @return boolean True if successful, false otherwise and internal error is set. + * + * @since 2.5 + */ + public function batch($model = null) + { + JSession::checkToken() or jexit(JText::_('JINVALID_TOKEN')); + + // Set the model + $model = $this->getModel('Book', '', array()); + + // Preset the redirect + $this->setRedirect(JRoute::_('index.php?option=com_getbible&view=books' . $this->getRedirectToListAppend(), false)); + + return parent::batch($model); + } + + /** + * Method to cancel an edit. + * + * @param string $key The name of the primary key of the URL variable. + * + * @return boolean True if access level checks pass, false otherwise. + * + * @since 12.2 + */ + public function cancel($key = null) + { + // get the referral options + $this->ref = $this->input->get('ref', 0, 'word'); + $this->refid = $this->input->get('refid', 0, 'int'); + + // Check if there is a return value + $return = $this->input->get('return', null, 'base64'); + + $cancel = parent::cancel($key); + + if (!is_null($return) && JUri::isInternal(base64_decode($return))) + { + $redirect = base64_decode($return); + + // Redirect to the return value. + $this->setRedirect( + JRoute::_( + $redirect, false + ) + ); + } + elseif ($this->refid && $this->ref) + { + $redirect = '&view=' . (string)$this->ref . '&layout=edit&id=' . (int)$this->refid; + + // Redirect to the item screen. + $this->setRedirect( + JRoute::_( + 'index.php?option=' . $this->option . $redirect, false + ) + ); + } + elseif ($this->ref) + { + $redirect = '&view='.(string)$this->ref; + + // Redirect to the list screen. + $this->setRedirect( + JRoute::_( + 'index.php?option=' . $this->option . $redirect, false + ) + ); + } + return $cancel; + } + + /** + * Method to save a record. + * + * @param string $key The name of the primary key of the URL variable. + * @param string $urlVar The name of the URL variable if different from the primary key (sometimes required to avoid router collisions). + * + * @return boolean True if successful, false otherwise. + * + * @since 12.2 + */ + public function save($key = null, $urlVar = null) + { + // get the referral options + $this->ref = $this->input->get('ref', 0, 'word'); + $this->refid = $this->input->get('refid', 0, 'int'); + + // Check if there is a return value + $return = $this->input->get('return', null, 'base64'); + $canReturn = (!is_null($return) && JUri::isInternal(base64_decode($return))); + + if ($this->ref || $this->refid || $canReturn) + { + // to make sure the item is checkedin on redirect + $this->task = 'save'; + } + + $saved = parent::save($key, $urlVar); + + // This is not needed since parent save already does this + // Due to the ref and refid implementation we need to add this + if ($canReturn) + { + $redirect = base64_decode($return); + + // Redirect to the return value. + $this->setRedirect( + JRoute::_( + $redirect, false + ) + ); + } + elseif ($this->refid && $this->ref) + { + $redirect = '&view=' . (string)$this->ref . '&layout=edit&id=' . (int)$this->refid; + + // Redirect to the item screen. + $this->setRedirect( + JRoute::_( + 'index.php?option=' . $this->option . $redirect, false + ) + ); + } + elseif ($this->ref) + { + $redirect = '&view=' . (string)$this->ref; + + // Redirect to the list screen. + $this->setRedirect( + JRoute::_( + 'index.php?option=' . $this->option . $redirect, false + ) + ); + } + return $saved; + } + + /** + * Function that allows child controller access to model data + * after the data has been saved. + * + * @param JModel &$model The data model object. + * @param array $validData The validated data. + * + * @return void + * + * @since 11.1 + */ + protected function postSaveHook(JModelLegacy $model, $validData = array()) + { + return; + } + +} diff --git a/admin/controllers/books.php b/admin/controllers/books.php new file mode 100644 index 0000000..c1f4c16 --- /dev/null +++ b/admin/controllers/books.php @@ -0,0 +1,52 @@ + + @git Get Bible + @github Get Bible + @support Get Bible + @copyright Copyright (C) 2015. All Rights Reserved + @license GNU/GPL Version 2 or later - http://www.gnu.org/licenses/gpl-2.0.html + +/------------------------------------------------------------------------------------------------------*/ + +// No direct access to this file +defined('_JEXEC') or die('Restricted access'); + +use Joomla\CMS\MVC\Controller\AdminController; +use Joomla\Utilities\ArrayHelper; + +/** + * Books Admin Controller + */ +class GetbibleControllerBooks extends AdminController +{ + /** + * The prefix to use with controller messages. + * + * @var string + * @since 1.6 + */ + protected $text_prefix = 'COM_GETBIBLE_BOOKS'; + + /** + * Method to get a model object, loading it if required. + * + * @param string $name The model name. Optional. + * @param string $prefix The class prefix. Optional. + * @param array $config Configuration array for model. Optional. + * + * @return JModelLegacy The model. + * + * @since 1.6 + */ + public function getModel($name = 'Book', $prefix = 'GetbibleModel', $config = array('ignore_request' => true)) + { + return parent::getModel($name, $prefix, $config); + } +} diff --git a/admin/controllers/chapter.php b/admin/controllers/chapter.php new file mode 100644 index 0000000..ca14d59 --- /dev/null +++ b/admin/controllers/chapter.php @@ -0,0 +1,330 @@ + + @git Get Bible + @github Get Bible + @support Get Bible + @copyright Copyright (C) 2015. All Rights Reserved + @license GNU/GPL Version 2 or later - http://www.gnu.org/licenses/gpl-2.0.html + +/------------------------------------------------------------------------------------------------------*/ + +// No direct access to this file +defined('_JEXEC') or die('Restricted access'); + +use Joomla\CMS\MVC\Controller\FormController; +use Joomla\Utilities\ArrayHelper; + +/** + * Chapter Form Controller + */ +class GetbibleControllerChapter extends FormController +{ + /** + * Current or most recently performed task. + * + * @var string + * @since 12.2 + * @note Replaces _task. + */ + protected $task; + + /** + * Class constructor. + * + * @param array $config A named array of configuration variables. + * + * @since 1.6 + */ + public function __construct($config = array()) + { + $this->view_list = 'Chapters'; // safeguard for setting the return view listing to the main view. + parent::__construct($config); + }###ADMIN_CUSTOM_BUTTONS_CONTROLLER### + + /** + * Method override to check if you can add a new record. + * + * @param array $data An array of input data. + * + * @return boolean + * + * @since 1.6 + */ + protected function allowAdd($data = array()) + { + // Get user object. + $user = JFactory::getUser(); + // Access check. + $access = $user->authorise('chapter.access', 'com_getbible'); + if (!$access) + { + return false; + } + + // In the absense of better information, revert to the component permissions. + return $user->authorise('chapter.create', $this->option); + } + + /** + * Method override to check if you can edit an existing record. + * + * @param array $data An array of input data. + * @param string $key The name of the key for the primary key. + * + * @return boolean + * + * @since 1.6 + */ + protected function allowEdit($data = array(), $key = 'id') + { + // get user object. + $user = JFactory::getUser(); + // get record id. + $recordId = (int) isset($data[$key]) ? $data[$key] : 0; + + + // Access check. + $access = ($user->authorise('chapter.access', 'com_getbible.chapter.' . (int) $recordId) && $user->authorise('chapter.access', 'com_getbible')); + if (!$access) + { + return false; + } + + if ($recordId) + { + // The record has been set. Check the record permissions. + $permission = $user->authorise('chapter.edit', 'com_getbible.chapter.' . (int) $recordId); + if (!$permission) + { + if ($user->authorise('chapter.edit.own', 'com_getbible.chapter.' . $recordId)) + { + // Now test the owner is the user. + $ownerId = (int) isset($data['created_by']) ? $data['created_by'] : 0; + if (empty($ownerId)) + { + // Need to do a lookup from the model. + $record = $this->getModel()->getItem($recordId); + + if (empty($record)) + { + return false; + } + $ownerId = $record->created_by; + } + + // If the owner matches 'me' then allow. + if ($ownerId == $user->id) + { + if ($user->authorise('chapter.edit.own', 'com_getbible')) + { + return true; + } + } + } + return false; + } + } + // Since there is no permission, revert to the component permissions. + return $user->authorise('chapter.edit', $this->option); + } + + /** + * Gets the URL arguments to append to an item redirect. + * + * @param integer $recordId The primary key id for the item. + * @param string $urlVar The name of the URL variable for the id. + * + * @return string The arguments to append to the redirect URL. + * + * @since 1.6 + */ + protected function getRedirectToItemAppend($recordId = null, $urlVar = 'id') + { + // get the referral options (old method use return instead see parent) + $ref = $this->input->get('ref', 0, 'string'); + $refid = $this->input->get('refid', 0, 'int'); + + // get redirect info. + $append = parent::getRedirectToItemAppend($recordId, $urlVar); + + // set the referral options + if ($refid && $ref) + { + $append = '&ref=' . (string)$ref . '&refid='. (int)$refid . $append; + } + elseif ($ref) + { + $append = '&ref='. (string)$ref . $append; + } + + return $append; + } + + /** + * Method to run batch operations. + * + * @param object $model The model. + * + * @return boolean True if successful, false otherwise and internal error is set. + * + * @since 2.5 + */ + public function batch($model = null) + { + JSession::checkToken() or jexit(JText::_('JINVALID_TOKEN')); + + // Set the model + $model = $this->getModel('Chapter', '', array()); + + // Preset the redirect + $this->setRedirect(JRoute::_('index.php?option=com_getbible&view=chapters' . $this->getRedirectToListAppend(), false)); + + return parent::batch($model); + } + + /** + * Method to cancel an edit. + * + * @param string $key The name of the primary key of the URL variable. + * + * @return boolean True if access level checks pass, false otherwise. + * + * @since 12.2 + */ + public function cancel($key = null) + { + // get the referral options + $this->ref = $this->input->get('ref', 0, 'word'); + $this->refid = $this->input->get('refid', 0, 'int'); + + // Check if there is a return value + $return = $this->input->get('return', null, 'base64'); + + $cancel = parent::cancel($key); + + if (!is_null($return) && JUri::isInternal(base64_decode($return))) + { + $redirect = base64_decode($return); + + // Redirect to the return value. + $this->setRedirect( + JRoute::_( + $redirect, false + ) + ); + } + elseif ($this->refid && $this->ref) + { + $redirect = '&view=' . (string)$this->ref . '&layout=edit&id=' . (int)$this->refid; + + // Redirect to the item screen. + $this->setRedirect( + JRoute::_( + 'index.php?option=' . $this->option . $redirect, false + ) + ); + } + elseif ($this->ref) + { + $redirect = '&view='.(string)$this->ref; + + // Redirect to the list screen. + $this->setRedirect( + JRoute::_( + 'index.php?option=' . $this->option . $redirect, false + ) + ); + } + return $cancel; + } + + /** + * Method to save a record. + * + * @param string $key The name of the primary key of the URL variable. + * @param string $urlVar The name of the URL variable if different from the primary key (sometimes required to avoid router collisions). + * + * @return boolean True if successful, false otherwise. + * + * @since 12.2 + */ + public function save($key = null, $urlVar = null) + { + // get the referral options + $this->ref = $this->input->get('ref', 0, 'word'); + $this->refid = $this->input->get('refid', 0, 'int'); + + // Check if there is a return value + $return = $this->input->get('return', null, 'base64'); + $canReturn = (!is_null($return) && JUri::isInternal(base64_decode($return))); + + if ($this->ref || $this->refid || $canReturn) + { + // to make sure the item is checkedin on redirect + $this->task = 'save'; + } + + $saved = parent::save($key, $urlVar); + + // This is not needed since parent save already does this + // Due to the ref and refid implementation we need to add this + if ($canReturn) + { + $redirect = base64_decode($return); + + // Redirect to the return value. + $this->setRedirect( + JRoute::_( + $redirect, false + ) + ); + } + elseif ($this->refid && $this->ref) + { + $redirect = '&view=' . (string)$this->ref . '&layout=edit&id=' . (int)$this->refid; + + // Redirect to the item screen. + $this->setRedirect( + JRoute::_( + 'index.php?option=' . $this->option . $redirect, false + ) + ); + } + elseif ($this->ref) + { + $redirect = '&view=' . (string)$this->ref; + + // Redirect to the list screen. + $this->setRedirect( + JRoute::_( + 'index.php?option=' . $this->option . $redirect, false + ) + ); + } + return $saved; + } + + /** + * Function that allows child controller access to model data + * after the data has been saved. + * + * @param JModel &$model The data model object. + * @param array $validData The validated data. + * + * @return void + * + * @since 11.1 + */ + protected function postSaveHook(JModelLegacy $model, $validData = array()) + { + return; + } + +} diff --git a/admin/controllers/chapters.php b/admin/controllers/chapters.php new file mode 100644 index 0000000..a157982 --- /dev/null +++ b/admin/controllers/chapters.php @@ -0,0 +1,52 @@ + + @git Get Bible + @github Get Bible + @support Get Bible + @copyright Copyright (C) 2015. All Rights Reserved + @license GNU/GPL Version 2 or later - http://www.gnu.org/licenses/gpl-2.0.html + +/------------------------------------------------------------------------------------------------------*/ + +// No direct access to this file +defined('_JEXEC') or die('Restricted access'); + +use Joomla\CMS\MVC\Controller\AdminController; +use Joomla\Utilities\ArrayHelper; + +/** + * Chapters Admin Controller + */ +class GetbibleControllerChapters extends AdminController +{ + /** + * The prefix to use with controller messages. + * + * @var string + * @since 1.6 + */ + protected $text_prefix = 'COM_GETBIBLE_CHAPTERS'; + + /** + * Method to get a model object, loading it if required. + * + * @param string $name The model name. Optional. + * @param string $prefix The class prefix. Optional. + * @param array $config Configuration array for model. Optional. + * + * @return JModelLegacy The model. + * + * @since 1.6 + */ + public function getModel($name = 'Chapter', $prefix = 'GetbibleModel', $config = array('ignore_request' => true)) + { + return parent::getModel($name, $prefix, $config); + } +} diff --git a/admin/controllers/getbible.php b/admin/controllers/getbible.php new file mode 100644 index 0000000..6a25675 --- /dev/null +++ b/admin/controllers/getbible.php @@ -0,0 +1,30 @@ + + @git Get Bible + @github Get Bible + @support Get Bible + @copyright Copyright (C) 2015. All Rights Reserved + @license GNU/GPL Version 2 or later - http://www.gnu.org/licenses/gpl-2.0.html + +/------------------------------------------------------------------------------------------------------*/ + +// No direct access to this file +defined('_JEXEC') or die('Restricted access'); + +use Joomla\CMS\MVC\Controller\AdminController; +use Joomla\Utilities\ArrayHelper; + +/** + * Getbible Admin Controller + */ +class GetbibleControllerGetbible extends AdminController +{ + +} diff --git a/admin/controllers/index.html b/admin/controllers/index.html new file mode 100644 index 0000000..fa6d84e --- /dev/null +++ b/admin/controllers/index.html @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/admin/controllers/linker.php b/admin/controllers/linker.php new file mode 100644 index 0000000..40dbe28 --- /dev/null +++ b/admin/controllers/linker.php @@ -0,0 +1,330 @@ + + @git Get Bible + @github Get Bible + @support Get Bible + @copyright Copyright (C) 2015. All Rights Reserved + @license GNU/GPL Version 2 or later - http://www.gnu.org/licenses/gpl-2.0.html + +/------------------------------------------------------------------------------------------------------*/ + +// No direct access to this file +defined('_JEXEC') or die('Restricted access'); + +use Joomla\CMS\MVC\Controller\FormController; +use Joomla\Utilities\ArrayHelper; + +/** + * Linker Form Controller + */ +class GetbibleControllerLinker extends FormController +{ + /** + * Current or most recently performed task. + * + * @var string + * @since 12.2 + * @note Replaces _task. + */ + protected $task; + + /** + * Class constructor. + * + * @param array $config A named array of configuration variables. + * + * @since 1.6 + */ + public function __construct($config = array()) + { + $this->view_list = 'Linkers'; // safeguard for setting the return view listing to the main view. + parent::__construct($config); + } + + /** + * Method override to check if you can add a new record. + * + * @param array $data An array of input data. + * + * @return boolean + * + * @since 1.6 + */ + protected function allowAdd($data = array()) + { + // Get user object. + $user = JFactory::getUser(); + // Access check. + $access = $user->authorise('linker.access', 'com_getbible'); + if (!$access) + { + return false; + } + + // In the absense of better information, revert to the component permissions. + return $user->authorise('linker.create', $this->option); + } + + /** + * Method override to check if you can edit an existing record. + * + * @param array $data An array of input data. + * @param string $key The name of the key for the primary key. + * + * @return boolean + * + * @since 1.6 + */ + protected function allowEdit($data = array(), $key = 'id') + { + // get user object. + $user = JFactory::getUser(); + // get record id. + $recordId = (int) isset($data[$key]) ? $data[$key] : 0; + + + // Access check. + $access = ($user->authorise('linker.access', 'com_getbible.linker.' . (int) $recordId) && $user->authorise('linker.access', 'com_getbible')); + if (!$access) + { + return false; + } + + if ($recordId) + { + // The record has been set. Check the record permissions. + $permission = $user->authorise('linker.edit', 'com_getbible.linker.' . (int) $recordId); + if (!$permission) + { + if ($user->authorise('linker.edit.own', 'com_getbible.linker.' . $recordId)) + { + // Now test the owner is the user. + $ownerId = (int) isset($data['created_by']) ? $data['created_by'] : 0; + if (empty($ownerId)) + { + // Need to do a lookup from the model. + $record = $this->getModel()->getItem($recordId); + + if (empty($record)) + { + return false; + } + $ownerId = $record->created_by; + } + + // If the owner matches 'me' then allow. + if ($ownerId == $user->id) + { + if ($user->authorise('linker.edit.own', 'com_getbible')) + { + return true; + } + } + } + return false; + } + } + // Since there is no permission, revert to the component permissions. + return $user->authorise('linker.edit', $this->option); + } + + /** + * Gets the URL arguments to append to an item redirect. + * + * @param integer $recordId The primary key id for the item. + * @param string $urlVar The name of the URL variable for the id. + * + * @return string The arguments to append to the redirect URL. + * + * @since 1.6 + */ + protected function getRedirectToItemAppend($recordId = null, $urlVar = 'id') + { + // get the referral options (old method use return instead see parent) + $ref = $this->input->get('ref', 0, 'string'); + $refid = $this->input->get('refid', 0, 'int'); + + // get redirect info. + $append = parent::getRedirectToItemAppend($recordId, $urlVar); + + // set the referral options + if ($refid && $ref) + { + $append = '&ref=' . (string)$ref . '&refid='. (int)$refid . $append; + } + elseif ($ref) + { + $append = '&ref='. (string)$ref . $append; + } + + return $append; + } + + /** + * Method to run batch operations. + * + * @param object $model The model. + * + * @return boolean True if successful, false otherwise and internal error is set. + * + * @since 2.5 + */ + public function batch($model = null) + { + JSession::checkToken() or jexit(JText::_('JINVALID_TOKEN')); + + // Set the model + $model = $this->getModel('Linker', '', array()); + + // Preset the redirect + $this->setRedirect(JRoute::_('index.php?option=com_getbible&view=linkers' . $this->getRedirectToListAppend(), false)); + + return parent::batch($model); + } + + /** + * Method to cancel an edit. + * + * @param string $key The name of the primary key of the URL variable. + * + * @return boolean True if access level checks pass, false otherwise. + * + * @since 12.2 + */ + public function cancel($key = null) + { + // get the referral options + $this->ref = $this->input->get('ref', 0, 'word'); + $this->refid = $this->input->get('refid', 0, 'int'); + + // Check if there is a return value + $return = $this->input->get('return', null, 'base64'); + + $cancel = parent::cancel($key); + + if (!is_null($return) && JUri::isInternal(base64_decode($return))) + { + $redirect = base64_decode($return); + + // Redirect to the return value. + $this->setRedirect( + JRoute::_( + $redirect, false + ) + ); + } + elseif ($this->refid && $this->ref) + { + $redirect = '&view=' . (string)$this->ref . '&layout=edit&id=' . (int)$this->refid; + + // Redirect to the item screen. + $this->setRedirect( + JRoute::_( + 'index.php?option=' . $this->option . $redirect, false + ) + ); + } + elseif ($this->ref) + { + $redirect = '&view='.(string)$this->ref; + + // Redirect to the list screen. + $this->setRedirect( + JRoute::_( + 'index.php?option=' . $this->option . $redirect, false + ) + ); + } + return $cancel; + } + + /** + * Method to save a record. + * + * @param string $key The name of the primary key of the URL variable. + * @param string $urlVar The name of the URL variable if different from the primary key (sometimes required to avoid router collisions). + * + * @return boolean True if successful, false otherwise. + * + * @since 12.2 + */ + public function save($key = null, $urlVar = null) + { + // get the referral options + $this->ref = $this->input->get('ref', 0, 'word'); + $this->refid = $this->input->get('refid', 0, 'int'); + + // Check if there is a return value + $return = $this->input->get('return', null, 'base64'); + $canReturn = (!is_null($return) && JUri::isInternal(base64_decode($return))); + + if ($this->ref || $this->refid || $canReturn) + { + // to make sure the item is checkedin on redirect + $this->task = 'save'; + } + + $saved = parent::save($key, $urlVar); + + // This is not needed since parent save already does this + // Due to the ref and refid implementation we need to add this + if ($canReturn) + { + $redirect = base64_decode($return); + + // Redirect to the return value. + $this->setRedirect( + JRoute::_( + $redirect, false + ) + ); + } + elseif ($this->refid && $this->ref) + { + $redirect = '&view=' . (string)$this->ref . '&layout=edit&id=' . (int)$this->refid; + + // Redirect to the item screen. + $this->setRedirect( + JRoute::_( + 'index.php?option=' . $this->option . $redirect, false + ) + ); + } + elseif ($this->ref) + { + $redirect = '&view=' . (string)$this->ref; + + // Redirect to the list screen. + $this->setRedirect( + JRoute::_( + 'index.php?option=' . $this->option . $redirect, false + ) + ); + } + return $saved; + } + + /** + * Function that allows child controller access to model data + * after the data has been saved. + * + * @param JModel &$model The data model object. + * @param array $validData The validated data. + * + * @return void + * + * @since 11.1 + */ + protected function postSaveHook(JModelLegacy $model, $validData = array()) + { + return; + } + +} diff --git a/admin/controllers/linkers.php b/admin/controllers/linkers.php new file mode 100644 index 0000000..65da3fe --- /dev/null +++ b/admin/controllers/linkers.php @@ -0,0 +1,52 @@ + + @git Get Bible + @github Get Bible + @support Get Bible + @copyright Copyright (C) 2015. All Rights Reserved + @license GNU/GPL Version 2 or later - http://www.gnu.org/licenses/gpl-2.0.html + +/------------------------------------------------------------------------------------------------------*/ + +// No direct access to this file +defined('_JEXEC') or die('Restricted access'); + +use Joomla\CMS\MVC\Controller\AdminController; +use Joomla\Utilities\ArrayHelper; + +/** + * Linkers Admin Controller + */ +class GetbibleControllerLinkers extends AdminController +{ + /** + * The prefix to use with controller messages. + * + * @var string + * @since 1.6 + */ + protected $text_prefix = 'COM_GETBIBLE_LINKERS'; + + /** + * Method to get a model object, loading it if required. + * + * @param string $name The model name. Optional. + * @param string $prefix The class prefix. Optional. + * @param array $config Configuration array for model. Optional. + * + * @return JModelLegacy The model. + * + * @since 1.6 + */ + public function getModel($name = 'Linker', $prefix = 'GetbibleModel', $config = array('ignore_request' => true)) + { + return parent::getModel($name, $prefix, $config); + } +} diff --git a/admin/controllers/note.php b/admin/controllers/note.php new file mode 100644 index 0000000..d1ddfd9 --- /dev/null +++ b/admin/controllers/note.php @@ -0,0 +1,330 @@ + + @git Get Bible + @github Get Bible + @support Get Bible + @copyright Copyright (C) 2015. All Rights Reserved + @license GNU/GPL Version 2 or later - http://www.gnu.org/licenses/gpl-2.0.html + +/------------------------------------------------------------------------------------------------------*/ + +// No direct access to this file +defined('_JEXEC') or die('Restricted access'); + +use Joomla\CMS\MVC\Controller\FormController; +use Joomla\Utilities\ArrayHelper; + +/** + * Note Form Controller + */ +class GetbibleControllerNote extends FormController +{ + /** + * Current or most recently performed task. + * + * @var string + * @since 12.2 + * @note Replaces _task. + */ + protected $task; + + /** + * Class constructor. + * + * @param array $config A named array of configuration variables. + * + * @since 1.6 + */ + public function __construct($config = array()) + { + $this->view_list = 'Notes'; // safeguard for setting the return view listing to the main view. + parent::__construct($config); + } + + /** + * Method override to check if you can add a new record. + * + * @param array $data An array of input data. + * + * @return boolean + * + * @since 1.6 + */ + protected function allowAdd($data = array()) + { + // Get user object. + $user = JFactory::getUser(); + // Access check. + $access = $user->authorise('note.access', 'com_getbible'); + if (!$access) + { + return false; + } + + // In the absense of better information, revert to the component permissions. + return $user->authorise('note.create', $this->option); + } + + /** + * Method override to check if you can edit an existing record. + * + * @param array $data An array of input data. + * @param string $key The name of the key for the primary key. + * + * @return boolean + * + * @since 1.6 + */ + protected function allowEdit($data = array(), $key = 'id') + { + // get user object. + $user = JFactory::getUser(); + // get record id. + $recordId = (int) isset($data[$key]) ? $data[$key] : 0; + + + // Access check. + $access = ($user->authorise('note.access', 'com_getbible.note.' . (int) $recordId) && $user->authorise('note.access', 'com_getbible')); + if (!$access) + { + return false; + } + + if ($recordId) + { + // The record has been set. Check the record permissions. + $permission = $user->authorise('note.edit', 'com_getbible.note.' . (int) $recordId); + if (!$permission) + { + if ($user->authorise('note.edit.own', 'com_getbible.note.' . $recordId)) + { + // Now test the owner is the user. + $ownerId = (int) isset($data['created_by']) ? $data['created_by'] : 0; + if (empty($ownerId)) + { + // Need to do a lookup from the model. + $record = $this->getModel()->getItem($recordId); + + if (empty($record)) + { + return false; + } + $ownerId = $record->created_by; + } + + // If the owner matches 'me' then allow. + if ($ownerId == $user->id) + { + if ($user->authorise('note.edit.own', 'com_getbible')) + { + return true; + } + } + } + return false; + } + } + // Since there is no permission, revert to the component permissions. + return $user->authorise('note.edit', $this->option); + } + + /** + * Gets the URL arguments to append to an item redirect. + * + * @param integer $recordId The primary key id for the item. + * @param string $urlVar The name of the URL variable for the id. + * + * @return string The arguments to append to the redirect URL. + * + * @since 1.6 + */ + protected function getRedirectToItemAppend($recordId = null, $urlVar = 'id') + { + // get the referral options (old method use return instead see parent) + $ref = $this->input->get('ref', 0, 'string'); + $refid = $this->input->get('refid', 0, 'int'); + + // get redirect info. + $append = parent::getRedirectToItemAppend($recordId, $urlVar); + + // set the referral options + if ($refid && $ref) + { + $append = '&ref=' . (string)$ref . '&refid='. (int)$refid . $append; + } + elseif ($ref) + { + $append = '&ref='. (string)$ref . $append; + } + + return $append; + } + + /** + * Method to run batch operations. + * + * @param object $model The model. + * + * @return boolean True if successful, false otherwise and internal error is set. + * + * @since 2.5 + */ + public function batch($model = null) + { + JSession::checkToken() or jexit(JText::_('JINVALID_TOKEN')); + + // Set the model + $model = $this->getModel('Note', '', array()); + + // Preset the redirect + $this->setRedirect(JRoute::_('index.php?option=com_getbible&view=notes' . $this->getRedirectToListAppend(), false)); + + return parent::batch($model); + } + + /** + * Method to cancel an edit. + * + * @param string $key The name of the primary key of the URL variable. + * + * @return boolean True if access level checks pass, false otherwise. + * + * @since 12.2 + */ + public function cancel($key = null) + { + // get the referral options + $this->ref = $this->input->get('ref', 0, 'word'); + $this->refid = $this->input->get('refid', 0, 'int'); + + // Check if there is a return value + $return = $this->input->get('return', null, 'base64'); + + $cancel = parent::cancel($key); + + if (!is_null($return) && JUri::isInternal(base64_decode($return))) + { + $redirect = base64_decode($return); + + // Redirect to the return value. + $this->setRedirect( + JRoute::_( + $redirect, false + ) + ); + } + elseif ($this->refid && $this->ref) + { + $redirect = '&view=' . (string)$this->ref . '&layout=edit&id=' . (int)$this->refid; + + // Redirect to the item screen. + $this->setRedirect( + JRoute::_( + 'index.php?option=' . $this->option . $redirect, false + ) + ); + } + elseif ($this->ref) + { + $redirect = '&view='.(string)$this->ref; + + // Redirect to the list screen. + $this->setRedirect( + JRoute::_( + 'index.php?option=' . $this->option . $redirect, false + ) + ); + } + return $cancel; + } + + /** + * Method to save a record. + * + * @param string $key The name of the primary key of the URL variable. + * @param string $urlVar The name of the URL variable if different from the primary key (sometimes required to avoid router collisions). + * + * @return boolean True if successful, false otherwise. + * + * @since 12.2 + */ + public function save($key = null, $urlVar = null) + { + // get the referral options + $this->ref = $this->input->get('ref', 0, 'word'); + $this->refid = $this->input->get('refid', 0, 'int'); + + // Check if there is a return value + $return = $this->input->get('return', null, 'base64'); + $canReturn = (!is_null($return) && JUri::isInternal(base64_decode($return))); + + if ($this->ref || $this->refid || $canReturn) + { + // to make sure the item is checkedin on redirect + $this->task = 'save'; + } + + $saved = parent::save($key, $urlVar); + + // This is not needed since parent save already does this + // Due to the ref and refid implementation we need to add this + if ($canReturn) + { + $redirect = base64_decode($return); + + // Redirect to the return value. + $this->setRedirect( + JRoute::_( + $redirect, false + ) + ); + } + elseif ($this->refid && $this->ref) + { + $redirect = '&view=' . (string)$this->ref . '&layout=edit&id=' . (int)$this->refid; + + // Redirect to the item screen. + $this->setRedirect( + JRoute::_( + 'index.php?option=' . $this->option . $redirect, false + ) + ); + } + elseif ($this->ref) + { + $redirect = '&view=' . (string)$this->ref; + + // Redirect to the list screen. + $this->setRedirect( + JRoute::_( + 'index.php?option=' . $this->option . $redirect, false + ) + ); + } + return $saved; + } + + /** + * Function that allows child controller access to model data + * after the data has been saved. + * + * @param JModel &$model The data model object. + * @param array $validData The validated data. + * + * @return void + * + * @since 11.1 + */ + protected function postSaveHook(JModelLegacy $model, $validData = array()) + { + return; + } + +} diff --git a/admin/controllers/notes.php b/admin/controllers/notes.php new file mode 100644 index 0000000..952ab27 --- /dev/null +++ b/admin/controllers/notes.php @@ -0,0 +1,52 @@ + + @git Get Bible + @github Get Bible + @support Get Bible + @copyright Copyright (C) 2015. All Rights Reserved + @license GNU/GPL Version 2 or later - http://www.gnu.org/licenses/gpl-2.0.html + +/------------------------------------------------------------------------------------------------------*/ + +// No direct access to this file +defined('_JEXEC') or die('Restricted access'); + +use Joomla\CMS\MVC\Controller\AdminController; +use Joomla\Utilities\ArrayHelper; + +/** + * Notes Admin Controller + */ +class GetbibleControllerNotes extends AdminController +{ + /** + * The prefix to use with controller messages. + * + * @var string + * @since 1.6 + */ + protected $text_prefix = 'COM_GETBIBLE_NOTES'; + + /** + * Method to get a model object, loading it if required. + * + * @param string $name The model name. Optional. + * @param string $prefix The class prefix. Optional. + * @param array $config Configuration array for model. Optional. + * + * @return JModelLegacy The model. + * + * @since 1.6 + */ + public function getModel($name = 'Note', $prefix = 'GetbibleModel', $config = array('ignore_request' => true)) + { + return parent::getModel($name, $prefix, $config); + } +} diff --git a/admin/controllers/open_ai_message.php b/admin/controllers/open_ai_message.php new file mode 100644 index 0000000..2f08b70 --- /dev/null +++ b/admin/controllers/open_ai_message.php @@ -0,0 +1,330 @@ + + @git Get Bible + @github Get Bible + @support Get Bible + @copyright Copyright (C) 2015. All Rights Reserved + @license GNU/GPL Version 2 or later - http://www.gnu.org/licenses/gpl-2.0.html + +/------------------------------------------------------------------------------------------------------*/ + +// No direct access to this file +defined('_JEXEC') or die('Restricted access'); + +use Joomla\CMS\MVC\Controller\FormController; +use Joomla\Utilities\ArrayHelper; + +/** + * Open_ai_message Form Controller + */ +class GetbibleControllerOpen_ai_message extends FormController +{ + /** + * Current or most recently performed task. + * + * @var string + * @since 12.2 + * @note Replaces _task. + */ + protected $task; + + /** + * Class constructor. + * + * @param array $config A named array of configuration variables. + * + * @since 1.6 + */ + public function __construct($config = array()) + { + $this->view_list = 'Open_ai_messages'; // safeguard for setting the return view listing to the main view. + parent::__construct($config); + } + + /** + * Method override to check if you can add a new record. + * + * @param array $data An array of input data. + * + * @return boolean + * + * @since 1.6 + */ + protected function allowAdd($data = array()) + { + // Get user object. + $user = JFactory::getUser(); + // Access check. + $access = $user->authorise('open_ai_message.access', 'com_getbible'); + if (!$access) + { + return false; + } + + // In the absense of better information, revert to the component permissions. + return $user->authorise('open_ai_message.create', $this->option); + } + + /** + * Method override to check if you can edit an existing record. + * + * @param array $data An array of input data. + * @param string $key The name of the key for the primary key. + * + * @return boolean + * + * @since 1.6 + */ + protected function allowEdit($data = array(), $key = 'id') + { + // get user object. + $user = JFactory::getUser(); + // get record id. + $recordId = (int) isset($data[$key]) ? $data[$key] : 0; + + + // Access check. + $access = ($user->authorise('open_ai_message.access', 'com_getbible.open_ai_message.' . (int) $recordId) && $user->authorise('open_ai_message.access', 'com_getbible')); + if (!$access) + { + return false; + } + + if ($recordId) + { + // The record has been set. Check the record permissions. + $permission = $user->authorise('open_ai_message.edit', 'com_getbible.open_ai_message.' . (int) $recordId); + if (!$permission) + { + if ($user->authorise('open_ai_message.edit.own', 'com_getbible.open_ai_message.' . $recordId)) + { + // Now test the owner is the user. + $ownerId = (int) isset($data['created_by']) ? $data['created_by'] : 0; + if (empty($ownerId)) + { + // Need to do a lookup from the model. + $record = $this->getModel()->getItem($recordId); + + if (empty($record)) + { + return false; + } + $ownerId = $record->created_by; + } + + // If the owner matches 'me' then allow. + if ($ownerId == $user->id) + { + if ($user->authorise('open_ai_message.edit.own', 'com_getbible')) + { + return true; + } + } + } + return false; + } + } + // Since there is no permission, revert to the component permissions. + return $user->authorise('open_ai_message.edit', $this->option); + } + + /** + * Gets the URL arguments to append to an item redirect. + * + * @param integer $recordId The primary key id for the item. + * @param string $urlVar The name of the URL variable for the id. + * + * @return string The arguments to append to the redirect URL. + * + * @since 1.6 + */ + protected function getRedirectToItemAppend($recordId = null, $urlVar = 'id') + { + // get the referral options (old method use return instead see parent) + $ref = $this->input->get('ref', 0, 'string'); + $refid = $this->input->get('refid', 0, 'int'); + + // get redirect info. + $append = parent::getRedirectToItemAppend($recordId, $urlVar); + + // set the referral options + if ($refid && $ref) + { + $append = '&ref=' . (string)$ref . '&refid='. (int)$refid . $append; + } + elseif ($ref) + { + $append = '&ref='. (string)$ref . $append; + } + + return $append; + } + + /** + * Method to run batch operations. + * + * @param object $model The model. + * + * @return boolean True if successful, false otherwise and internal error is set. + * + * @since 2.5 + */ + public function batch($model = null) + { + JSession::checkToken() or jexit(JText::_('JINVALID_TOKEN')); + + // Set the model + $model = $this->getModel('Open_ai_message', '', array()); + + // Preset the redirect + $this->setRedirect(JRoute::_('index.php?option=com_getbible&view=open_ai_messages' . $this->getRedirectToListAppend(), false)); + + return parent::batch($model); + } + + /** + * Method to cancel an edit. + * + * @param string $key The name of the primary key of the URL variable. + * + * @return boolean True if access level checks pass, false otherwise. + * + * @since 12.2 + */ + public function cancel($key = null) + { + // get the referral options + $this->ref = $this->input->get('ref', 0, 'word'); + $this->refid = $this->input->get('refid', 0, 'int'); + + // Check if there is a return value + $return = $this->input->get('return', null, 'base64'); + + $cancel = parent::cancel($key); + + if (!is_null($return) && JUri::isInternal(base64_decode($return))) + { + $redirect = base64_decode($return); + + // Redirect to the return value. + $this->setRedirect( + JRoute::_( + $redirect, false + ) + ); + } + elseif ($this->refid && $this->ref) + { + $redirect = '&view=' . (string)$this->ref . '&layout=edit&id=' . (int)$this->refid; + + // Redirect to the item screen. + $this->setRedirect( + JRoute::_( + 'index.php?option=' . $this->option . $redirect, false + ) + ); + } + elseif ($this->ref) + { + $redirect = '&view='.(string)$this->ref; + + // Redirect to the list screen. + $this->setRedirect( + JRoute::_( + 'index.php?option=' . $this->option . $redirect, false + ) + ); + } + return $cancel; + } + + /** + * Method to save a record. + * + * @param string $key The name of the primary key of the URL variable. + * @param string $urlVar The name of the URL variable if different from the primary key (sometimes required to avoid router collisions). + * + * @return boolean True if successful, false otherwise. + * + * @since 12.2 + */ + public function save($key = null, $urlVar = null) + { + // get the referral options + $this->ref = $this->input->get('ref', 0, 'word'); + $this->refid = $this->input->get('refid', 0, 'int'); + + // Check if there is a return value + $return = $this->input->get('return', null, 'base64'); + $canReturn = (!is_null($return) && JUri::isInternal(base64_decode($return))); + + if ($this->ref || $this->refid || $canReturn) + { + // to make sure the item is checkedin on redirect + $this->task = 'save'; + } + + $saved = parent::save($key, $urlVar); + + // This is not needed since parent save already does this + // Due to the ref and refid implementation we need to add this + if ($canReturn) + { + $redirect = base64_decode($return); + + // Redirect to the return value. + $this->setRedirect( + JRoute::_( + $redirect, false + ) + ); + } + elseif ($this->refid && $this->ref) + { + $redirect = '&view=' . (string)$this->ref . '&layout=edit&id=' . (int)$this->refid; + + // Redirect to the item screen. + $this->setRedirect( + JRoute::_( + 'index.php?option=' . $this->option . $redirect, false + ) + ); + } + elseif ($this->ref) + { + $redirect = '&view=' . (string)$this->ref; + + // Redirect to the list screen. + $this->setRedirect( + JRoute::_( + 'index.php?option=' . $this->option . $redirect, false + ) + ); + } + return $saved; + } + + /** + * Function that allows child controller access to model data + * after the data has been saved. + * + * @param JModel &$model The data model object. + * @param array $validData The validated data. + * + * @return void + * + * @since 11.1 + */ + protected function postSaveHook(JModelLegacy $model, $validData = array()) + { + return; + } + +} diff --git a/admin/controllers/open_ai_messages.php b/admin/controllers/open_ai_messages.php new file mode 100644 index 0000000..d1a88c2 --- /dev/null +++ b/admin/controllers/open_ai_messages.php @@ -0,0 +1,52 @@ + + @git Get Bible + @github Get Bible + @support Get Bible + @copyright Copyright (C) 2015. All Rights Reserved + @license GNU/GPL Version 2 or later - http://www.gnu.org/licenses/gpl-2.0.html + +/------------------------------------------------------------------------------------------------------*/ + +// No direct access to this file +defined('_JEXEC') or die('Restricted access'); + +use Joomla\CMS\MVC\Controller\AdminController; +use Joomla\Utilities\ArrayHelper; + +/** + * Open_ai_messages Admin Controller + */ +class GetbibleControllerOpen_ai_messages extends AdminController +{ + /** + * The prefix to use with controller messages. + * + * @var string + * @since 1.6 + */ + protected $text_prefix = 'COM_GETBIBLE_OPEN_AI_MESSAGES'; + + /** + * Method to get a model object, loading it if required. + * + * @param string $name The model name. Optional. + * @param string $prefix The class prefix. Optional. + * @param array $config Configuration array for model. Optional. + * + * @return JModelLegacy The model. + * + * @since 1.6 + */ + public function getModel($name = 'Open_ai_message', $prefix = 'GetbibleModel', $config = array('ignore_request' => true)) + { + return parent::getModel($name, $prefix, $config); + } +} diff --git a/admin/controllers/open_ai_response.php b/admin/controllers/open_ai_response.php new file mode 100644 index 0000000..f075763 --- /dev/null +++ b/admin/controllers/open_ai_response.php @@ -0,0 +1,330 @@ + + @git Get Bible + @github Get Bible + @support Get Bible + @copyright Copyright (C) 2015. All Rights Reserved + @license GNU/GPL Version 2 or later - http://www.gnu.org/licenses/gpl-2.0.html + +/------------------------------------------------------------------------------------------------------*/ + +// No direct access to this file +defined('_JEXEC') or die('Restricted access'); + +use Joomla\CMS\MVC\Controller\FormController; +use Joomla\Utilities\ArrayHelper; + +/** + * Open_ai_response Form Controller + */ +class GetbibleControllerOpen_ai_response extends FormController +{ + /** + * Current or most recently performed task. + * + * @var string + * @since 12.2 + * @note Replaces _task. + */ + protected $task; + + /** + * Class constructor. + * + * @param array $config A named array of configuration variables. + * + * @since 1.6 + */ + public function __construct($config = array()) + { + $this->view_list = 'Open_ai_responses'; // safeguard for setting the return view listing to the main view. + parent::__construct($config); + } + + /** + * Method override to check if you can add a new record. + * + * @param array $data An array of input data. + * + * @return boolean + * + * @since 1.6 + */ + protected function allowAdd($data = array()) + { + // Get user object. + $user = JFactory::getUser(); + // Access check. + $access = $user->authorise('open_ai_response.access', 'com_getbible'); + if (!$access) + { + return false; + } + + // In the absense of better information, revert to the component permissions. + return $user->authorise('open_ai_response.create', $this->option); + } + + /** + * Method override to check if you can edit an existing record. + * + * @param array $data An array of input data. + * @param string $key The name of the key for the primary key. + * + * @return boolean + * + * @since 1.6 + */ + protected function allowEdit($data = array(), $key = 'id') + { + // get user object. + $user = JFactory::getUser(); + // get record id. + $recordId = (int) isset($data[$key]) ? $data[$key] : 0; + + + // Access check. + $access = ($user->authorise('open_ai_response.access', 'com_getbible.open_ai_response.' . (int) $recordId) && $user->authorise('open_ai_response.access', 'com_getbible')); + if (!$access) + { + return false; + } + + if ($recordId) + { + // The record has been set. Check the record permissions. + $permission = $user->authorise('open_ai_response.edit', 'com_getbible.open_ai_response.' . (int) $recordId); + if (!$permission) + { + if ($user->authorise('open_ai_response.edit.own', 'com_getbible.open_ai_response.' . $recordId)) + { + // Now test the owner is the user. + $ownerId = (int) isset($data['created_by']) ? $data['created_by'] : 0; + if (empty($ownerId)) + { + // Need to do a lookup from the model. + $record = $this->getModel()->getItem($recordId); + + if (empty($record)) + { + return false; + } + $ownerId = $record->created_by; + } + + // If the owner matches 'me' then allow. + if ($ownerId == $user->id) + { + if ($user->authorise('open_ai_response.edit.own', 'com_getbible')) + { + return true; + } + } + } + return false; + } + } + // Since there is no permission, revert to the component permissions. + return $user->authorise('open_ai_response.edit', $this->option); + } + + /** + * Gets the URL arguments to append to an item redirect. + * + * @param integer $recordId The primary key id for the item. + * @param string $urlVar The name of the URL variable for the id. + * + * @return string The arguments to append to the redirect URL. + * + * @since 1.6 + */ + protected function getRedirectToItemAppend($recordId = null, $urlVar = 'id') + { + // get the referral options (old method use return instead see parent) + $ref = $this->input->get('ref', 0, 'string'); + $refid = $this->input->get('refid', 0, 'int'); + + // get redirect info. + $append = parent::getRedirectToItemAppend($recordId, $urlVar); + + // set the referral options + if ($refid && $ref) + { + $append = '&ref=' . (string)$ref . '&refid='. (int)$refid . $append; + } + elseif ($ref) + { + $append = '&ref='. (string)$ref . $append; + } + + return $append; + } + + /** + * Method to run batch operations. + * + * @param object $model The model. + * + * @return boolean True if successful, false otherwise and internal error is set. + * + * @since 2.5 + */ + public function batch($model = null) + { + JSession::checkToken() or jexit(JText::_('JINVALID_TOKEN')); + + // Set the model + $model = $this->getModel('Open_ai_response', '', array()); + + // Preset the redirect + $this->setRedirect(JRoute::_('index.php?option=com_getbible&view=open_ai_responses' . $this->getRedirectToListAppend(), false)); + + return parent::batch($model); + } + + /** + * Method to cancel an edit. + * + * @param string $key The name of the primary key of the URL variable. + * + * @return boolean True if access level checks pass, false otherwise. + * + * @since 12.2 + */ + public function cancel($key = null) + { + // get the referral options + $this->ref = $this->input->get('ref', 0, 'word'); + $this->refid = $this->input->get('refid', 0, 'int'); + + // Check if there is a return value + $return = $this->input->get('return', null, 'base64'); + + $cancel = parent::cancel($key); + + if (!is_null($return) && JUri::isInternal(base64_decode($return))) + { + $redirect = base64_decode($return); + + // Redirect to the return value. + $this->setRedirect( + JRoute::_( + $redirect, false + ) + ); + } + elseif ($this->refid && $this->ref) + { + $redirect = '&view=' . (string)$this->ref . '&layout=edit&id=' . (int)$this->refid; + + // Redirect to the item screen. + $this->setRedirect( + JRoute::_( + 'index.php?option=' . $this->option . $redirect, false + ) + ); + } + elseif ($this->ref) + { + $redirect = '&view='.(string)$this->ref; + + // Redirect to the list screen. + $this->setRedirect( + JRoute::_( + 'index.php?option=' . $this->option . $redirect, false + ) + ); + } + return $cancel; + } + + /** + * Method to save a record. + * + * @param string $key The name of the primary key of the URL variable. + * @param string $urlVar The name of the URL variable if different from the primary key (sometimes required to avoid router collisions). + * + * @return boolean True if successful, false otherwise. + * + * @since 12.2 + */ + public function save($key = null, $urlVar = null) + { + // get the referral options + $this->ref = $this->input->get('ref', 0, 'word'); + $this->refid = $this->input->get('refid', 0, 'int'); + + // Check if there is a return value + $return = $this->input->get('return', null, 'base64'); + $canReturn = (!is_null($return) && JUri::isInternal(base64_decode($return))); + + if ($this->ref || $this->refid || $canReturn) + { + // to make sure the item is checkedin on redirect + $this->task = 'save'; + } + + $saved = parent::save($key, $urlVar); + + // This is not needed since parent save already does this + // Due to the ref and refid implementation we need to add this + if ($canReturn) + { + $redirect = base64_decode($return); + + // Redirect to the return value. + $this->setRedirect( + JRoute::_( + $redirect, false + ) + ); + } + elseif ($this->refid && $this->ref) + { + $redirect = '&view=' . (string)$this->ref . '&layout=edit&id=' . (int)$this->refid; + + // Redirect to the item screen. + $this->setRedirect( + JRoute::_( + 'index.php?option=' . $this->option . $redirect, false + ) + ); + } + elseif ($this->ref) + { + $redirect = '&view=' . (string)$this->ref; + + // Redirect to the list screen. + $this->setRedirect( + JRoute::_( + 'index.php?option=' . $this->option . $redirect, false + ) + ); + } + return $saved; + } + + /** + * Function that allows child controller access to model data + * after the data has been saved. + * + * @param JModel &$model The data model object. + * @param array $validData The validated data. + * + * @return void + * + * @since 11.1 + */ + protected function postSaveHook(JModelLegacy $model, $validData = array()) + { + return; + } + +} diff --git a/admin/controllers/open_ai_responses.php b/admin/controllers/open_ai_responses.php new file mode 100644 index 0000000..f7856fd --- /dev/null +++ b/admin/controllers/open_ai_responses.php @@ -0,0 +1,52 @@ + + @git Get Bible + @github Get Bible + @support Get Bible + @copyright Copyright (C) 2015. All Rights Reserved + @license GNU/GPL Version 2 or later - http://www.gnu.org/licenses/gpl-2.0.html + +/------------------------------------------------------------------------------------------------------*/ + +// No direct access to this file +defined('_JEXEC') or die('Restricted access'); + +use Joomla\CMS\MVC\Controller\AdminController; +use Joomla\Utilities\ArrayHelper; + +/** + * Open_ai_responses Admin Controller + */ +class GetbibleControllerOpen_ai_responses extends AdminController +{ + /** + * The prefix to use with controller messages. + * + * @var string + * @since 1.6 + */ + protected $text_prefix = 'COM_GETBIBLE_OPEN_AI_RESPONSES'; + + /** + * Method to get a model object, loading it if required. + * + * @param string $name The model name. Optional. + * @param string $prefix The class prefix. Optional. + * @param array $config Configuration array for model. Optional. + * + * @return JModelLegacy The model. + * + * @since 1.6 + */ + public function getModel($name = 'Open_ai_response', $prefix = 'GetbibleModel', $config = array('ignore_request' => true)) + { + return parent::getModel($name, $prefix, $config); + } +} diff --git a/admin/controllers/password.php b/admin/controllers/password.php new file mode 100644 index 0000000..4b1d2d0 --- /dev/null +++ b/admin/controllers/password.php @@ -0,0 +1,330 @@ + + @git Get Bible + @github Get Bible + @support Get Bible + @copyright Copyright (C) 2015. All Rights Reserved + @license GNU/GPL Version 2 or later - http://www.gnu.org/licenses/gpl-2.0.html + +/------------------------------------------------------------------------------------------------------*/ + +// No direct access to this file +defined('_JEXEC') or die('Restricted access'); + +use Joomla\CMS\MVC\Controller\FormController; +use Joomla\Utilities\ArrayHelper; + +/** + * Password Form Controller + */ +class GetbibleControllerPassword extends FormController +{ + /** + * Current or most recently performed task. + * + * @var string + * @since 12.2 + * @note Replaces _task. + */ + protected $task; + + /** + * Class constructor. + * + * @param array $config A named array of configuration variables. + * + * @since 1.6 + */ + public function __construct($config = array()) + { + $this->view_list = 'Passwords'; // safeguard for setting the return view listing to the main view. + parent::__construct($config); + } + + /** + * Method override to check if you can add a new record. + * + * @param array $data An array of input data. + * + * @return boolean + * + * @since 1.6 + */ + protected function allowAdd($data = array()) + { + // Get user object. + $user = JFactory::getUser(); + // Access check. + $access = $user->authorise('password.access', 'com_getbible'); + if (!$access) + { + return false; + } + + // In the absense of better information, revert to the component permissions. + return $user->authorise('password.create', $this->option); + } + + /** + * Method override to check if you can edit an existing record. + * + * @param array $data An array of input data. + * @param string $key The name of the key for the primary key. + * + * @return boolean + * + * @since 1.6 + */ + protected function allowEdit($data = array(), $key = 'id') + { + // get user object. + $user = JFactory::getUser(); + // get record id. + $recordId = (int) isset($data[$key]) ? $data[$key] : 0; + + + // Access check. + $access = ($user->authorise('password.access', 'com_getbible.password.' . (int) $recordId) && $user->authorise('password.access', 'com_getbible')); + if (!$access) + { + return false; + } + + if ($recordId) + { + // The record has been set. Check the record permissions. + $permission = $user->authorise('password.edit', 'com_getbible.password.' . (int) $recordId); + if (!$permission) + { + if ($user->authorise('password.edit.own', 'com_getbible.password.' . $recordId)) + { + // Now test the owner is the user. + $ownerId = (int) isset($data['created_by']) ? $data['created_by'] : 0; + if (empty($ownerId)) + { + // Need to do a lookup from the model. + $record = $this->getModel()->getItem($recordId); + + if (empty($record)) + { + return false; + } + $ownerId = $record->created_by; + } + + // If the owner matches 'me' then allow. + if ($ownerId == $user->id) + { + if ($user->authorise('password.edit.own', 'com_getbible')) + { + return true; + } + } + } + return false; + } + } + // Since there is no permission, revert to the component permissions. + return $user->authorise('password.edit', $this->option); + } + + /** + * Gets the URL arguments to append to an item redirect. + * + * @param integer $recordId The primary key id for the item. + * @param string $urlVar The name of the URL variable for the id. + * + * @return string The arguments to append to the redirect URL. + * + * @since 1.6 + */ + protected function getRedirectToItemAppend($recordId = null, $urlVar = 'id') + { + // get the referral options (old method use return instead see parent) + $ref = $this->input->get('ref', 0, 'string'); + $refid = $this->input->get('refid', 0, 'int'); + + // get redirect info. + $append = parent::getRedirectToItemAppend($recordId, $urlVar); + + // set the referral options + if ($refid && $ref) + { + $append = '&ref=' . (string)$ref . '&refid='. (int)$refid . $append; + } + elseif ($ref) + { + $append = '&ref='. (string)$ref . $append; + } + + return $append; + } + + /** + * Method to run batch operations. + * + * @param object $model The model. + * + * @return boolean True if successful, false otherwise and internal error is set. + * + * @since 2.5 + */ + public function batch($model = null) + { + JSession::checkToken() or jexit(JText::_('JINVALID_TOKEN')); + + // Set the model + $model = $this->getModel('Password', '', array()); + + // Preset the redirect + $this->setRedirect(JRoute::_('index.php?option=com_getbible&view=passwords' . $this->getRedirectToListAppend(), false)); + + return parent::batch($model); + } + + /** + * Method to cancel an edit. + * + * @param string $key The name of the primary key of the URL variable. + * + * @return boolean True if access level checks pass, false otherwise. + * + * @since 12.2 + */ + public function cancel($key = null) + { + // get the referral options + $this->ref = $this->input->get('ref', 0, 'word'); + $this->refid = $this->input->get('refid', 0, 'int'); + + // Check if there is a return value + $return = $this->input->get('return', null, 'base64'); + + $cancel = parent::cancel($key); + + if (!is_null($return) && JUri::isInternal(base64_decode($return))) + { + $redirect = base64_decode($return); + + // Redirect to the return value. + $this->setRedirect( + JRoute::_( + $redirect, false + ) + ); + } + elseif ($this->refid && $this->ref) + { + $redirect = '&view=' . (string)$this->ref . '&layout=edit&id=' . (int)$this->refid; + + // Redirect to the item screen. + $this->setRedirect( + JRoute::_( + 'index.php?option=' . $this->option . $redirect, false + ) + ); + } + elseif ($this->ref) + { + $redirect = '&view='.(string)$this->ref; + + // Redirect to the list screen. + $this->setRedirect( + JRoute::_( + 'index.php?option=' . $this->option . $redirect, false + ) + ); + } + return $cancel; + } + + /** + * Method to save a record. + * + * @param string $key The name of the primary key of the URL variable. + * @param string $urlVar The name of the URL variable if different from the primary key (sometimes required to avoid router collisions). + * + * @return boolean True if successful, false otherwise. + * + * @since 12.2 + */ + public function save($key = null, $urlVar = null) + { + // get the referral options + $this->ref = $this->input->get('ref', 0, 'word'); + $this->refid = $this->input->get('refid', 0, 'int'); + + // Check if there is a return value + $return = $this->input->get('return', null, 'base64'); + $canReturn = (!is_null($return) && JUri::isInternal(base64_decode($return))); + + if ($this->ref || $this->refid || $canReturn) + { + // to make sure the item is checkedin on redirect + $this->task = 'save'; + } + + $saved = parent::save($key, $urlVar); + + // This is not needed since parent save already does this + // Due to the ref and refid implementation we need to add this + if ($canReturn) + { + $redirect = base64_decode($return); + + // Redirect to the return value. + $this->setRedirect( + JRoute::_( + $redirect, false + ) + ); + } + elseif ($this->refid && $this->ref) + { + $redirect = '&view=' . (string)$this->ref . '&layout=edit&id=' . (int)$this->refid; + + // Redirect to the item screen. + $this->setRedirect( + JRoute::_( + 'index.php?option=' . $this->option . $redirect, false + ) + ); + } + elseif ($this->ref) + { + $redirect = '&view=' . (string)$this->ref; + + // Redirect to the list screen. + $this->setRedirect( + JRoute::_( + 'index.php?option=' . $this->option . $redirect, false + ) + ); + } + return $saved; + } + + /** + * Function that allows child controller access to model data + * after the data has been saved. + * + * @param JModel &$model The data model object. + * @param array $validData The validated data. + * + * @return void + * + * @since 11.1 + */ + protected function postSaveHook(JModelLegacy $model, $validData = array()) + { + return; + } + +} diff --git a/admin/controllers/passwords.php b/admin/controllers/passwords.php new file mode 100644 index 0000000..4a008ef --- /dev/null +++ b/admin/controllers/passwords.php @@ -0,0 +1,52 @@ + + @git Get Bible + @github Get Bible + @support Get Bible + @copyright Copyright (C) 2015. All Rights Reserved + @license GNU/GPL Version 2 or later - http://www.gnu.org/licenses/gpl-2.0.html + +/------------------------------------------------------------------------------------------------------*/ + +// No direct access to this file +defined('_JEXEC') or die('Restricted access'); + +use Joomla\CMS\MVC\Controller\AdminController; +use Joomla\Utilities\ArrayHelper; + +/** + * Passwords Admin Controller + */ +class GetbibleControllerPasswords extends AdminController +{ + /** + * The prefix to use with controller messages. + * + * @var string + * @since 1.6 + */ + protected $text_prefix = 'COM_GETBIBLE_PASSWORDS'; + + /** + * Method to get a model object, loading it if required. + * + * @param string $name The model name. Optional. + * @param string $prefix The class prefix. Optional. + * @param array $config Configuration array for model. Optional. + * + * @return JModelLegacy The model. + * + * @since 1.6 + */ + public function getModel($name = 'Password', $prefix = 'GetbibleModel', $config = array('ignore_request' => true)) + { + return parent::getModel($name, $prefix, $config); + } +} diff --git a/admin/controllers/prompt.php b/admin/controllers/prompt.php new file mode 100644 index 0000000..cb6d4c6 --- /dev/null +++ b/admin/controllers/prompt.php @@ -0,0 +1,330 @@ + + @git Get Bible + @github Get Bible + @support Get Bible + @copyright Copyright (C) 2015. All Rights Reserved + @license GNU/GPL Version 2 or later - http://www.gnu.org/licenses/gpl-2.0.html + +/------------------------------------------------------------------------------------------------------*/ + +// No direct access to this file +defined('_JEXEC') or die('Restricted access'); + +use Joomla\CMS\MVC\Controller\FormController; +use Joomla\Utilities\ArrayHelper; + +/** + * Prompt Form Controller + */ +class GetbibleControllerPrompt extends FormController +{ + /** + * Current or most recently performed task. + * + * @var string + * @since 12.2 + * @note Replaces _task. + */ + protected $task; + + /** + * Class constructor. + * + * @param array $config A named array of configuration variables. + * + * @since 1.6 + */ + public function __construct($config = array()) + { + $this->view_list = 'Prompts'; // safeguard for setting the return view listing to the main view. + parent::__construct($config); + } + + /** + * Method override to check if you can add a new record. + * + * @param array $data An array of input data. + * + * @return boolean + * + * @since 1.6 + */ + protected function allowAdd($data = array()) + { + // Get user object. + $user = JFactory::getUser(); + // Access check. + $access = $user->authorise('prompt.access', 'com_getbible'); + if (!$access) + { + return false; + } + + // In the absense of better information, revert to the component permissions. + return $user->authorise('prompt.create', $this->option); + } + + /** + * Method override to check if you can edit an existing record. + * + * @param array $data An array of input data. + * @param string $key The name of the key for the primary key. + * + * @return boolean + * + * @since 1.6 + */ + protected function allowEdit($data = array(), $key = 'id') + { + // get user object. + $user = JFactory::getUser(); + // get record id. + $recordId = (int) isset($data[$key]) ? $data[$key] : 0; + + + // Access check. + $access = ($user->authorise('prompt.access', 'com_getbible.prompt.' . (int) $recordId) && $user->authorise('prompt.access', 'com_getbible')); + if (!$access) + { + return false; + } + + if ($recordId) + { + // The record has been set. Check the record permissions. + $permission = $user->authorise('prompt.edit', 'com_getbible.prompt.' . (int) $recordId); + if (!$permission) + { + if ($user->authorise('prompt.edit.own', 'com_getbible.prompt.' . $recordId)) + { + // Now test the owner is the user. + $ownerId = (int) isset($data['created_by']) ? $data['created_by'] : 0; + if (empty($ownerId)) + { + // Need to do a lookup from the model. + $record = $this->getModel()->getItem($recordId); + + if (empty($record)) + { + return false; + } + $ownerId = $record->created_by; + } + + // If the owner matches 'me' then allow. + if ($ownerId == $user->id) + { + if ($user->authorise('prompt.edit.own', 'com_getbible')) + { + return true; + } + } + } + return false; + } + } + // Since there is no permission, revert to the component permissions. + return $user->authorise('prompt.edit', $this->option); + } + + /** + * Gets the URL arguments to append to an item redirect. + * + * @param integer $recordId The primary key id for the item. + * @param string $urlVar The name of the URL variable for the id. + * + * @return string The arguments to append to the redirect URL. + * + * @since 1.6 + */ + protected function getRedirectToItemAppend($recordId = null, $urlVar = 'id') + { + // get the referral options (old method use return instead see parent) + $ref = $this->input->get('ref', 0, 'string'); + $refid = $this->input->get('refid', 0, 'int'); + + // get redirect info. + $append = parent::getRedirectToItemAppend($recordId, $urlVar); + + // set the referral options + if ($refid && $ref) + { + $append = '&ref=' . (string)$ref . '&refid='. (int)$refid . $append; + } + elseif ($ref) + { + $append = '&ref='. (string)$ref . $append; + } + + return $append; + } + + /** + * Method to run batch operations. + * + * @param object $model The model. + * + * @return boolean True if successful, false otherwise and internal error is set. + * + * @since 2.5 + */ + public function batch($model = null) + { + JSession::checkToken() or jexit(JText::_('JINVALID_TOKEN')); + + // Set the model + $model = $this->getModel('Prompt', '', array()); + + // Preset the redirect + $this->setRedirect(JRoute::_('index.php?option=com_getbible&view=prompts' . $this->getRedirectToListAppend(), false)); + + return parent::batch($model); + } + + /** + * Method to cancel an edit. + * + * @param string $key The name of the primary key of the URL variable. + * + * @return boolean True if access level checks pass, false otherwise. + * + * @since 12.2 + */ + public function cancel($key = null) + { + // get the referral options + $this->ref = $this->input->get('ref', 0, 'word'); + $this->refid = $this->input->get('refid', 0, 'int'); + + // Check if there is a return value + $return = $this->input->get('return', null, 'base64'); + + $cancel = parent::cancel($key); + + if (!is_null($return) && JUri::isInternal(base64_decode($return))) + { + $redirect = base64_decode($return); + + // Redirect to the return value. + $this->setRedirect( + JRoute::_( + $redirect, false + ) + ); + } + elseif ($this->refid && $this->ref) + { + $redirect = '&view=' . (string)$this->ref . '&layout=edit&id=' . (int)$this->refid; + + // Redirect to the item screen. + $this->setRedirect( + JRoute::_( + 'index.php?option=' . $this->option . $redirect, false + ) + ); + } + elseif ($this->ref) + { + $redirect = '&view='.(string)$this->ref; + + // Redirect to the list screen. + $this->setRedirect( + JRoute::_( + 'index.php?option=' . $this->option . $redirect, false + ) + ); + } + return $cancel; + } + + /** + * Method to save a record. + * + * @param string $key The name of the primary key of the URL variable. + * @param string $urlVar The name of the URL variable if different from the primary key (sometimes required to avoid router collisions). + * + * @return boolean True if successful, false otherwise. + * + * @since 12.2 + */ + public function save($key = null, $urlVar = null) + { + // get the referral options + $this->ref = $this->input->get('ref', 0, 'word'); + $this->refid = $this->input->get('refid', 0, 'int'); + + // Check if there is a return value + $return = $this->input->get('return', null, 'base64'); + $canReturn = (!is_null($return) && JUri::isInternal(base64_decode($return))); + + if ($this->ref || $this->refid || $canReturn) + { + // to make sure the item is checkedin on redirect + $this->task = 'save'; + } + + $saved = parent::save($key, $urlVar); + + // This is not needed since parent save already does this + // Due to the ref and refid implementation we need to add this + if ($canReturn) + { + $redirect = base64_decode($return); + + // Redirect to the return value. + $this->setRedirect( + JRoute::_( + $redirect, false + ) + ); + } + elseif ($this->refid && $this->ref) + { + $redirect = '&view=' . (string)$this->ref . '&layout=edit&id=' . (int)$this->refid; + + // Redirect to the item screen. + $this->setRedirect( + JRoute::_( + 'index.php?option=' . $this->option . $redirect, false + ) + ); + } + elseif ($this->ref) + { + $redirect = '&view=' . (string)$this->ref; + + // Redirect to the list screen. + $this->setRedirect( + JRoute::_( + 'index.php?option=' . $this->option . $redirect, false + ) + ); + } + return $saved; + } + + /** + * Function that allows child controller access to model data + * after the data has been saved. + * + * @param JModel &$model The data model object. + * @param array $validData The validated data. + * + * @return void + * + * @since 11.1 + */ + protected function postSaveHook(JModelLegacy $model, $validData = array()) + { + return; + } + +} diff --git a/admin/controllers/prompts.php b/admin/controllers/prompts.php new file mode 100644 index 0000000..d144152 --- /dev/null +++ b/admin/controllers/prompts.php @@ -0,0 +1,52 @@ + + @git Get Bible + @github Get Bible + @support Get Bible + @copyright Copyright (C) 2015. All Rights Reserved + @license GNU/GPL Version 2 or later - http://www.gnu.org/licenses/gpl-2.0.html + +/------------------------------------------------------------------------------------------------------*/ + +// No direct access to this file +defined('_JEXEC') or die('Restricted access'); + +use Joomla\CMS\MVC\Controller\AdminController; +use Joomla\Utilities\ArrayHelper; + +/** + * Prompts Admin Controller + */ +class GetbibleControllerPrompts extends AdminController +{ + /** + * The prefix to use with controller messages. + * + * @var string + * @since 1.6 + */ + protected $text_prefix = 'COM_GETBIBLE_PROMPTS'; + + /** + * Method to get a model object, loading it if required. + * + * @param string $name The model name. Optional. + * @param string $prefix The class prefix. Optional. + * @param array $config Configuration array for model. Optional. + * + * @return JModelLegacy The model. + * + * @since 1.6 + */ + public function getModel($name = 'Prompt', $prefix = 'GetbibleModel', $config = array('ignore_request' => true)) + { + return parent::getModel($name, $prefix, $config); + } +} diff --git a/admin/controllers/tag.php b/admin/controllers/tag.php new file mode 100644 index 0000000..21c13fa --- /dev/null +++ b/admin/controllers/tag.php @@ -0,0 +1,330 @@ + + @git Get Bible + @github Get Bible + @support Get Bible + @copyright Copyright (C) 2015. All Rights Reserved + @license GNU/GPL Version 2 or later - http://www.gnu.org/licenses/gpl-2.0.html + +/------------------------------------------------------------------------------------------------------*/ + +// No direct access to this file +defined('_JEXEC') or die('Restricted access'); + +use Joomla\CMS\MVC\Controller\FormController; +use Joomla\Utilities\ArrayHelper; + +/** + * Tag Form Controller + */ +class GetbibleControllerTag extends FormController +{ + /** + * Current or most recently performed task. + * + * @var string + * @since 12.2 + * @note Replaces _task. + */ + protected $task; + + /** + * Class constructor. + * + * @param array $config A named array of configuration variables. + * + * @since 1.6 + */ + public function __construct($config = array()) + { + $this->view_list = 'Tags'; // safeguard for setting the return view listing to the main view. + parent::__construct($config); + } + + /** + * Method override to check if you can add a new record. + * + * @param array $data An array of input data. + * + * @return boolean + * + * @since 1.6 + */ + protected function allowAdd($data = array()) + { + // Get user object. + $user = JFactory::getUser(); + // Access check. + $access = $user->authorise('tag.access', 'com_getbible'); + if (!$access) + { + return false; + } + + // In the absense of better information, revert to the component permissions. + return $user->authorise('tag.create', $this->option); + } + + /** + * Method override to check if you can edit an existing record. + * + * @param array $data An array of input data. + * @param string $key The name of the key for the primary key. + * + * @return boolean + * + * @since 1.6 + */ + protected function allowEdit($data = array(), $key = 'id') + { + // get user object. + $user = JFactory::getUser(); + // get record id. + $recordId = (int) isset($data[$key]) ? $data[$key] : 0; + + + // Access check. + $access = ($user->authorise('tag.access', 'com_getbible.tag.' . (int) $recordId) && $user->authorise('tag.access', 'com_getbible')); + if (!$access) + { + return false; + } + + if ($recordId) + { + // The record has been set. Check the record permissions. + $permission = $user->authorise('tag.edit', 'com_getbible.tag.' . (int) $recordId); + if (!$permission) + { + if ($user->authorise('tag.edit.own', 'com_getbible.tag.' . $recordId)) + { + // Now test the owner is the user. + $ownerId = (int) isset($data['created_by']) ? $data['created_by'] : 0; + if (empty($ownerId)) + { + // Need to do a lookup from the model. + $record = $this->getModel()->getItem($recordId); + + if (empty($record)) + { + return false; + } + $ownerId = $record->created_by; + } + + // If the owner matches 'me' then allow. + if ($ownerId == $user->id) + { + if ($user->authorise('tag.edit.own', 'com_getbible')) + { + return true; + } + } + } + return false; + } + } + // Since there is no permission, revert to the component permissions. + return $user->authorise('tag.edit', $this->option); + } + + /** + * Gets the URL arguments to append to an item redirect. + * + * @param integer $recordId The primary key id for the item. + * @param string $urlVar The name of the URL variable for the id. + * + * @return string The arguments to append to the redirect URL. + * + * @since 1.6 + */ + protected function getRedirectToItemAppend($recordId = null, $urlVar = 'id') + { + // get the referral options (old method use return instead see parent) + $ref = $this->input->get('ref', 0, 'string'); + $refid = $this->input->get('refid', 0, 'int'); + + // get redirect info. + $append = parent::getRedirectToItemAppend($recordId, $urlVar); + + // set the referral options + if ($refid && $ref) + { + $append = '&ref=' . (string)$ref . '&refid='. (int)$refid . $append; + } + elseif ($ref) + { + $append = '&ref='. (string)$ref . $append; + } + + return $append; + } + + /** + * Method to run batch operations. + * + * @param object $model The model. + * + * @return boolean True if successful, false otherwise and internal error is set. + * + * @since 2.5 + */ + public function batch($model = null) + { + JSession::checkToken() or jexit(JText::_('JINVALID_TOKEN')); + + // Set the model + $model = $this->getModel('Tag', '', array()); + + // Preset the redirect + $this->setRedirect(JRoute::_('index.php?option=com_getbible&view=tags' . $this->getRedirectToListAppend(), false)); + + return parent::batch($model); + } + + /** + * Method to cancel an edit. + * + * @param string $key The name of the primary key of the URL variable. + * + * @return boolean True if access level checks pass, false otherwise. + * + * @since 12.2 + */ + public function cancel($key = null) + { + // get the referral options + $this->ref = $this->input->get('ref', 0, 'word'); + $this->refid = $this->input->get('refid', 0, 'int'); + + // Check if there is a return value + $return = $this->input->get('return', null, 'base64'); + + $cancel = parent::cancel($key); + + if (!is_null($return) && JUri::isInternal(base64_decode($return))) + { + $redirect = base64_decode($return); + + // Redirect to the return value. + $this->setRedirect( + JRoute::_( + $redirect, false + ) + ); + } + elseif ($this->refid && $this->ref) + { + $redirect = '&view=' . (string)$this->ref . '&layout=edit&id=' . (int)$this->refid; + + // Redirect to the item screen. + $this->setRedirect( + JRoute::_( + 'index.php?option=' . $this->option . $redirect, false + ) + ); + } + elseif ($this->ref) + { + $redirect = '&view='.(string)$this->ref; + + // Redirect to the list screen. + $this->setRedirect( + JRoute::_( + 'index.php?option=' . $this->option . $redirect, false + ) + ); + } + return $cancel; + } + + /** + * Method to save a record. + * + * @param string $key The name of the primary key of the URL variable. + * @param string $urlVar The name of the URL variable if different from the primary key (sometimes required to avoid router collisions). + * + * @return boolean True if successful, false otherwise. + * + * @since 12.2 + */ + public function save($key = null, $urlVar = null) + { + // get the referral options + $this->ref = $this->input->get('ref', 0, 'word'); + $this->refid = $this->input->get('refid', 0, 'int'); + + // Check if there is a return value + $return = $this->input->get('return', null, 'base64'); + $canReturn = (!is_null($return) && JUri::isInternal(base64_decode($return))); + + if ($this->ref || $this->refid || $canReturn) + { + // to make sure the item is checkedin on redirect + $this->task = 'save'; + } + + $saved = parent::save($key, $urlVar); + + // This is not needed since parent save already does this + // Due to the ref and refid implementation we need to add this + if ($canReturn) + { + $redirect = base64_decode($return); + + // Redirect to the return value. + $this->setRedirect( + JRoute::_( + $redirect, false + ) + ); + } + elseif ($this->refid && $this->ref) + { + $redirect = '&view=' . (string)$this->ref . '&layout=edit&id=' . (int)$this->refid; + + // Redirect to the item screen. + $this->setRedirect( + JRoute::_( + 'index.php?option=' . $this->option . $redirect, false + ) + ); + } + elseif ($this->ref) + { + $redirect = '&view=' . (string)$this->ref; + + // Redirect to the list screen. + $this->setRedirect( + JRoute::_( + 'index.php?option=' . $this->option . $redirect, false + ) + ); + } + return $saved; + } + + /** + * Function that allows child controller access to model data + * after the data has been saved. + * + * @param JModel &$model The data model object. + * @param array $validData The validated data. + * + * @return void + * + * @since 11.1 + */ + protected function postSaveHook(JModelLegacy $model, $validData = array()) + { + return; + } + +} diff --git a/admin/controllers/tagged_verse.php b/admin/controllers/tagged_verse.php new file mode 100644 index 0000000..2be0bca --- /dev/null +++ b/admin/controllers/tagged_verse.php @@ -0,0 +1,330 @@ + + @git Get Bible + @github Get Bible + @support Get Bible + @copyright Copyright (C) 2015. All Rights Reserved + @license GNU/GPL Version 2 or later - http://www.gnu.org/licenses/gpl-2.0.html + +/------------------------------------------------------------------------------------------------------*/ + +// No direct access to this file +defined('_JEXEC') or die('Restricted access'); + +use Joomla\CMS\MVC\Controller\FormController; +use Joomla\Utilities\ArrayHelper; + +/** + * Tagged_verse Form Controller + */ +class GetbibleControllerTagged_verse extends FormController +{ + /** + * Current or most recently performed task. + * + * @var string + * @since 12.2 + * @note Replaces _task. + */ + protected $task; + + /** + * Class constructor. + * + * @param array $config A named array of configuration variables. + * + * @since 1.6 + */ + public function __construct($config = array()) + { + $this->view_list = 'Tagged_verses'; // safeguard for setting the return view listing to the main view. + parent::__construct($config); + } + + /** + * Method override to check if you can add a new record. + * + * @param array $data An array of input data. + * + * @return boolean + * + * @since 1.6 + */ + protected function allowAdd($data = array()) + { + // Get user object. + $user = JFactory::getUser(); + // Access check. + $access = $user->authorise('tagged_verse.access', 'com_getbible'); + if (!$access) + { + return false; + } + + // In the absense of better information, revert to the component permissions. + return $user->authorise('tagged_verse.create', $this->option); + } + + /** + * Method override to check if you can edit an existing record. + * + * @param array $data An array of input data. + * @param string $key The name of the key for the primary key. + * + * @return boolean + * + * @since 1.6 + */ + protected function allowEdit($data = array(), $key = 'id') + { + // get user object. + $user = JFactory::getUser(); + // get record id. + $recordId = (int) isset($data[$key]) ? $data[$key] : 0; + + + // Access check. + $access = ($user->authorise('tagged_verse.access', 'com_getbible.tagged_verse.' . (int) $recordId) && $user->authorise('tagged_verse.access', 'com_getbible')); + if (!$access) + { + return false; + } + + if ($recordId) + { + // The record has been set. Check the record permissions. + $permission = $user->authorise('tagged_verse.edit', 'com_getbible.tagged_verse.' . (int) $recordId); + if (!$permission) + { + if ($user->authorise('tagged_verse.edit.own', 'com_getbible.tagged_verse.' . $recordId)) + { + // Now test the owner is the user. + $ownerId = (int) isset($data['created_by']) ? $data['created_by'] : 0; + if (empty($ownerId)) + { + // Need to do a lookup from the model. + $record = $this->getModel()->getItem($recordId); + + if (empty($record)) + { + return false; + } + $ownerId = $record->created_by; + } + + // If the owner matches 'me' then allow. + if ($ownerId == $user->id) + { + if ($user->authorise('tagged_verse.edit.own', 'com_getbible')) + { + return true; + } + } + } + return false; + } + } + // Since there is no permission, revert to the component permissions. + return $user->authorise('tagged_verse.edit', $this->option); + } + + /** + * Gets the URL arguments to append to an item redirect. + * + * @param integer $recordId The primary key id for the item. + * @param string $urlVar The name of the URL variable for the id. + * + * @return string The arguments to append to the redirect URL. + * + * @since 1.6 + */ + protected function getRedirectToItemAppend($recordId = null, $urlVar = 'id') + { + // get the referral options (old method use return instead see parent) + $ref = $this->input->get('ref', 0, 'string'); + $refid = $this->input->get('refid', 0, 'int'); + + // get redirect info. + $append = parent::getRedirectToItemAppend($recordId, $urlVar); + + // set the referral options + if ($refid && $ref) + { + $append = '&ref=' . (string)$ref . '&refid='. (int)$refid . $append; + } + elseif ($ref) + { + $append = '&ref='. (string)$ref . $append; + } + + return $append; + } + + /** + * Method to run batch operations. + * + * @param object $model The model. + * + * @return boolean True if successful, false otherwise and internal error is set. + * + * @since 2.5 + */ + public function batch($model = null) + { + JSession::checkToken() or jexit(JText::_('JINVALID_TOKEN')); + + // Set the model + $model = $this->getModel('Tagged_verse', '', array()); + + // Preset the redirect + $this->setRedirect(JRoute::_('index.php?option=com_getbible&view=tagged_verses' . $this->getRedirectToListAppend(), false)); + + return parent::batch($model); + } + + /** + * Method to cancel an edit. + * + * @param string $key The name of the primary key of the URL variable. + * + * @return boolean True if access level checks pass, false otherwise. + * + * @since 12.2 + */ + public function cancel($key = null) + { + // get the referral options + $this->ref = $this->input->get('ref', 0, 'word'); + $this->refid = $this->input->get('refid', 0, 'int'); + + // Check if there is a return value + $return = $this->input->get('return', null, 'base64'); + + $cancel = parent::cancel($key); + + if (!is_null($return) && JUri::isInternal(base64_decode($return))) + { + $redirect = base64_decode($return); + + // Redirect to the return value. + $this->setRedirect( + JRoute::_( + $redirect, false + ) + ); + } + elseif ($this->refid && $this->ref) + { + $redirect = '&view=' . (string)$this->ref . '&layout=edit&id=' . (int)$this->refid; + + // Redirect to the item screen. + $this->setRedirect( + JRoute::_( + 'index.php?option=' . $this->option . $redirect, false + ) + ); + } + elseif ($this->ref) + { + $redirect = '&view='.(string)$this->ref; + + // Redirect to the list screen. + $this->setRedirect( + JRoute::_( + 'index.php?option=' . $this->option . $redirect, false + ) + ); + } + return $cancel; + } + + /** + * Method to save a record. + * + * @param string $key The name of the primary key of the URL variable. + * @param string $urlVar The name of the URL variable if different from the primary key (sometimes required to avoid router collisions). + * + * @return boolean True if successful, false otherwise. + * + * @since 12.2 + */ + public function save($key = null, $urlVar = null) + { + // get the referral options + $this->ref = $this->input->get('ref', 0, 'word'); + $this->refid = $this->input->get('refid', 0, 'int'); + + // Check if there is a return value + $return = $this->input->get('return', null, 'base64'); + $canReturn = (!is_null($return) && JUri::isInternal(base64_decode($return))); + + if ($this->ref || $this->refid || $canReturn) + { + // to make sure the item is checkedin on redirect + $this->task = 'save'; + } + + $saved = parent::save($key, $urlVar); + + // This is not needed since parent save already does this + // Due to the ref and refid implementation we need to add this + if ($canReturn) + { + $redirect = base64_decode($return); + + // Redirect to the return value. + $this->setRedirect( + JRoute::_( + $redirect, false + ) + ); + } + elseif ($this->refid && $this->ref) + { + $redirect = '&view=' . (string)$this->ref . '&layout=edit&id=' . (int)$this->refid; + + // Redirect to the item screen. + $this->setRedirect( + JRoute::_( + 'index.php?option=' . $this->option . $redirect, false + ) + ); + } + elseif ($this->ref) + { + $redirect = '&view=' . (string)$this->ref; + + // Redirect to the list screen. + $this->setRedirect( + JRoute::_( + 'index.php?option=' . $this->option . $redirect, false + ) + ); + } + return $saved; + } + + /** + * Function that allows child controller access to model data + * after the data has been saved. + * + * @param JModel &$model The data model object. + * @param array $validData The validated data. + * + * @return void + * + * @since 11.1 + */ + protected function postSaveHook(JModelLegacy $model, $validData = array()) + { + return; + } + +} diff --git a/admin/controllers/tagged_verses.php b/admin/controllers/tagged_verses.php new file mode 100644 index 0000000..3ef684f --- /dev/null +++ b/admin/controllers/tagged_verses.php @@ -0,0 +1,52 @@ + + @git Get Bible + @github Get Bible + @support Get Bible + @copyright Copyright (C) 2015. All Rights Reserved + @license GNU/GPL Version 2 or later - http://www.gnu.org/licenses/gpl-2.0.html + +/------------------------------------------------------------------------------------------------------*/ + +// No direct access to this file +defined('_JEXEC') or die('Restricted access'); + +use Joomla\CMS\MVC\Controller\AdminController; +use Joomla\Utilities\ArrayHelper; + +/** + * Tagged_verses Admin Controller + */ +class GetbibleControllerTagged_verses extends AdminController +{ + /** + * The prefix to use with controller messages. + * + * @var string + * @since 1.6 + */ + protected $text_prefix = 'COM_GETBIBLE_TAGGED_VERSES'; + + /** + * Method to get a model object, loading it if required. + * + * @param string $name The model name. Optional. + * @param string $prefix The class prefix. Optional. + * @param array $config Configuration array for model. Optional. + * + * @return JModelLegacy The model. + * + * @since 1.6 + */ + public function getModel($name = 'Tagged_verse', $prefix = 'GetbibleModel', $config = array('ignore_request' => true)) + { + return parent::getModel($name, $prefix, $config); + } +} diff --git a/admin/controllers/tags.php b/admin/controllers/tags.php new file mode 100644 index 0000000..360a32e --- /dev/null +++ b/admin/controllers/tags.php @@ -0,0 +1,52 @@ + + @git Get Bible + @github Get Bible + @support Get Bible + @copyright Copyright (C) 2015. All Rights Reserved + @license GNU/GPL Version 2 or later - http://www.gnu.org/licenses/gpl-2.0.html + +/------------------------------------------------------------------------------------------------------*/ + +// No direct access to this file +defined('_JEXEC') or die('Restricted access'); + +use Joomla\CMS\MVC\Controller\AdminController; +use Joomla\Utilities\ArrayHelper; + +/** + * Tags Admin Controller + */ +class GetbibleControllerTags extends AdminController +{ + /** + * The prefix to use with controller messages. + * + * @var string + * @since 1.6 + */ + protected $text_prefix = 'COM_GETBIBLE_TAGS'; + + /** + * Method to get a model object, loading it if required. + * + * @param string $name The model name. Optional. + * @param string $prefix The class prefix. Optional. + * @param array $config Configuration array for model. Optional. + * + * @return JModelLegacy The model. + * + * @since 1.6 + */ + public function getModel($name = 'Tag', $prefix = 'GetbibleModel', $config = array('ignore_request' => true)) + { + return parent::getModel($name, $prefix, $config); + } +} diff --git a/admin/controllers/translation.php b/admin/controllers/translation.php new file mode 100644 index 0000000..ec1474e --- /dev/null +++ b/admin/controllers/translation.php @@ -0,0 +1,330 @@ + + @git Get Bible + @github Get Bible + @support Get Bible + @copyright Copyright (C) 2015. All Rights Reserved + @license GNU/GPL Version 2 or later - http://www.gnu.org/licenses/gpl-2.0.html + +/------------------------------------------------------------------------------------------------------*/ + +// No direct access to this file +defined('_JEXEC') or die('Restricted access'); + +use Joomla\CMS\MVC\Controller\FormController; +use Joomla\Utilities\ArrayHelper; + +/** + * Translation Form Controller + */ +class GetbibleControllerTranslation extends FormController +{ + /** + * Current or most recently performed task. + * + * @var string + * @since 12.2 + * @note Replaces _task. + */ + protected $task; + + /** + * Class constructor. + * + * @param array $config A named array of configuration variables. + * + * @since 1.6 + */ + public function __construct($config = array()) + { + $this->view_list = 'Translations'; // safeguard for setting the return view listing to the main view. + parent::__construct($config); + }###ADMIN_CUSTOM_BUTTONS_CONTROLLER### + + /** + * Method override to check if you can add a new record. + * + * @param array $data An array of input data. + * + * @return boolean + * + * @since 1.6 + */ + protected function allowAdd($data = array()) + { + // Get user object. + $user = JFactory::getUser(); + // Access check. + $access = $user->authorise('translation.access', 'com_getbible'); + if (!$access) + { + return false; + } + + // In the absense of better information, revert to the component permissions. + return $user->authorise('translation.create', $this->option); + } + + /** + * Method override to check if you can edit an existing record. + * + * @param array $data An array of input data. + * @param string $key The name of the key for the primary key. + * + * @return boolean + * + * @since 1.6 + */ + protected function allowEdit($data = array(), $key = 'id') + { + // get user object. + $user = JFactory::getUser(); + // get record id. + $recordId = (int) isset($data[$key]) ? $data[$key] : 0; + + + // Access check. + $access = ($user->authorise('translation.access', 'com_getbible.translation.' . (int) $recordId) && $user->authorise('translation.access', 'com_getbible')); + if (!$access) + { + return false; + } + + if ($recordId) + { + // The record has been set. Check the record permissions. + $permission = $user->authorise('translation.edit', 'com_getbible.translation.' . (int) $recordId); + if (!$permission) + { + if ($user->authorise('translation.edit.own', 'com_getbible.translation.' . $recordId)) + { + // Now test the owner is the user. + $ownerId = (int) isset($data['created_by']) ? $data['created_by'] : 0; + if (empty($ownerId)) + { + // Need to do a lookup from the model. + $record = $this->getModel()->getItem($recordId); + + if (empty($record)) + { + return false; + } + $ownerId = $record->created_by; + } + + // If the owner matches 'me' then allow. + if ($ownerId == $user->id) + { + if ($user->authorise('translation.edit.own', 'com_getbible')) + { + return true; + } + } + } + return false; + } + } + // Since there is no permission, revert to the component permissions. + return $user->authorise('translation.edit', $this->option); + } + + /** + * Gets the URL arguments to append to an item redirect. + * + * @param integer $recordId The primary key id for the item. + * @param string $urlVar The name of the URL variable for the id. + * + * @return string The arguments to append to the redirect URL. + * + * @since 1.6 + */ + protected function getRedirectToItemAppend($recordId = null, $urlVar = 'id') + { + // get the referral options (old method use return instead see parent) + $ref = $this->input->get('ref', 0, 'string'); + $refid = $this->input->get('refid', 0, 'int'); + + // get redirect info. + $append = parent::getRedirectToItemAppend($recordId, $urlVar); + + // set the referral options + if ($refid && $ref) + { + $append = '&ref=' . (string)$ref . '&refid='. (int)$refid . $append; + } + elseif ($ref) + { + $append = '&ref='. (string)$ref . $append; + } + + return $append; + } + + /** + * Method to run batch operations. + * + * @param object $model The model. + * + * @return boolean True if successful, false otherwise and internal error is set. + * + * @since 2.5 + */ + public function batch($model = null) + { + JSession::checkToken() or jexit(JText::_('JINVALID_TOKEN')); + + // Set the model + $model = $this->getModel('Translation', '', array()); + + // Preset the redirect + $this->setRedirect(JRoute::_('index.php?option=com_getbible&view=translations' . $this->getRedirectToListAppend(), false)); + + return parent::batch($model); + } + + /** + * Method to cancel an edit. + * + * @param string $key The name of the primary key of the URL variable. + * + * @return boolean True if access level checks pass, false otherwise. + * + * @since 12.2 + */ + public function cancel($key = null) + { + // get the referral options + $this->ref = $this->input->get('ref', 0, 'word'); + $this->refid = $this->input->get('refid', 0, 'int'); + + // Check if there is a return value + $return = $this->input->get('return', null, 'base64'); + + $cancel = parent::cancel($key); + + if (!is_null($return) && JUri::isInternal(base64_decode($return))) + { + $redirect = base64_decode($return); + + // Redirect to the return value. + $this->setRedirect( + JRoute::_( + $redirect, false + ) + ); + } + elseif ($this->refid && $this->ref) + { + $redirect = '&view=' . (string)$this->ref . '&layout=edit&id=' . (int)$this->refid; + + // Redirect to the item screen. + $this->setRedirect( + JRoute::_( + 'index.php?option=' . $this->option . $redirect, false + ) + ); + } + elseif ($this->ref) + { + $redirect = '&view='.(string)$this->ref; + + // Redirect to the list screen. + $this->setRedirect( + JRoute::_( + 'index.php?option=' . $this->option . $redirect, false + ) + ); + } + return $cancel; + } + + /** + * Method to save a record. + * + * @param string $key The name of the primary key of the URL variable. + * @param string $urlVar The name of the URL variable if different from the primary key (sometimes required to avoid router collisions). + * + * @return boolean True if successful, false otherwise. + * + * @since 12.2 + */ + public function save($key = null, $urlVar = null) + { + // get the referral options + $this->ref = $this->input->get('ref', 0, 'word'); + $this->refid = $this->input->get('refid', 0, 'int'); + + // Check if there is a return value + $return = $this->input->get('return', null, 'base64'); + $canReturn = (!is_null($return) && JUri::isInternal(base64_decode($return))); + + if ($this->ref || $this->refid || $canReturn) + { + // to make sure the item is checkedin on redirect + $this->task = 'save'; + } + + $saved = parent::save($key, $urlVar); + + // This is not needed since parent save already does this + // Due to the ref and refid implementation we need to add this + if ($canReturn) + { + $redirect = base64_decode($return); + + // Redirect to the return value. + $this->setRedirect( + JRoute::_( + $redirect, false + ) + ); + } + elseif ($this->refid && $this->ref) + { + $redirect = '&view=' . (string)$this->ref . '&layout=edit&id=' . (int)$this->refid; + + // Redirect to the item screen. + $this->setRedirect( + JRoute::_( + 'index.php?option=' . $this->option . $redirect, false + ) + ); + } + elseif ($this->ref) + { + $redirect = '&view=' . (string)$this->ref; + + // Redirect to the list screen. + $this->setRedirect( + JRoute::_( + 'index.php?option=' . $this->option . $redirect, false + ) + ); + } + return $saved; + } + + /** + * Function that allows child controller access to model data + * after the data has been saved. + * + * @param JModel &$model The data model object. + * @param array $validData The validated data. + * + * @return void + * + * @since 11.1 + */ + protected function postSaveHook(JModelLegacy $model, $validData = array()) + { + return; + } + +} diff --git a/admin/controllers/translations.php b/admin/controllers/translations.php new file mode 100644 index 0000000..5291825 --- /dev/null +++ b/admin/controllers/translations.php @@ -0,0 +1,52 @@ + + @git Get Bible + @github Get Bible + @support Get Bible + @copyright Copyright (C) 2015. All Rights Reserved + @license GNU/GPL Version 2 or later - http://www.gnu.org/licenses/gpl-2.0.html + +/------------------------------------------------------------------------------------------------------*/ + +// No direct access to this file +defined('_JEXEC') or die('Restricted access'); + +use Joomla\CMS\MVC\Controller\AdminController; +use Joomla\Utilities\ArrayHelper; + +/** + * Translations Admin Controller + */ +class GetbibleControllerTranslations extends AdminController +{ + /** + * The prefix to use with controller messages. + * + * @var string + * @since 1.6 + */ + protected $text_prefix = 'COM_GETBIBLE_TRANSLATIONS'; + + /** + * Method to get a model object, loading it if required. + * + * @param string $name The model name. Optional. + * @param string $prefix The class prefix. Optional. + * @param array $config Configuration array for model. Optional. + * + * @return JModelLegacy The model. + * + * @since 1.6 + */ + public function getModel($name = 'Translation', $prefix = 'GetbibleModel', $config = array('ignore_request' => true)) + { + return parent::getModel($name, $prefix, $config); + } +} diff --git a/admin/controllers/verse.php b/admin/controllers/verse.php new file mode 100644 index 0000000..fc04a0f --- /dev/null +++ b/admin/controllers/verse.php @@ -0,0 +1,330 @@ + + @git Get Bible + @github Get Bible + @support Get Bible + @copyright Copyright (C) 2015. All Rights Reserved + @license GNU/GPL Version 2 or later - http://www.gnu.org/licenses/gpl-2.0.html + +/------------------------------------------------------------------------------------------------------*/ + +// No direct access to this file +defined('_JEXEC') or die('Restricted access'); + +use Joomla\CMS\MVC\Controller\FormController; +use Joomla\Utilities\ArrayHelper; + +/** + * Verse Form Controller + */ +class GetbibleControllerVerse extends FormController +{ + /** + * Current or most recently performed task. + * + * @var string + * @since 12.2 + * @note Replaces _task. + */ + protected $task; + + /** + * Class constructor. + * + * @param array $config A named array of configuration variables. + * + * @since 1.6 + */ + public function __construct($config = array()) + { + $this->view_list = 'Verses'; // safeguard for setting the return view listing to the main view. + parent::__construct($config); + }###ADMIN_CUSTOM_BUTTONS_CONTROLLER### + + /** + * Method override to check if you can add a new record. + * + * @param array $data An array of input data. + * + * @return boolean + * + * @since 1.6 + */ + protected function allowAdd($data = array()) + { + // Get user object. + $user = JFactory::getUser(); + // Access check. + $access = $user->authorise('verse.access', 'com_getbible'); + if (!$access) + { + return false; + } + + // In the absense of better information, revert to the component permissions. + return $user->authorise('verse.create', $this->option); + } + + /** + * Method override to check if you can edit an existing record. + * + * @param array $data An array of input data. + * @param string $key The name of the key for the primary key. + * + * @return boolean + * + * @since 1.6 + */ + protected function allowEdit($data = array(), $key = 'id') + { + // get user object. + $user = JFactory::getUser(); + // get record id. + $recordId = (int) isset($data[$key]) ? $data[$key] : 0; + + + // Access check. + $access = ($user->authorise('verse.access', 'com_getbible.verse.' . (int) $recordId) && $user->authorise('verse.access', 'com_getbible')); + if (!$access) + { + return false; + } + + if ($recordId) + { + // The record has been set. Check the record permissions. + $permission = $user->authorise('verse.edit', 'com_getbible.verse.' . (int) $recordId); + if (!$permission) + { + if ($user->authorise('verse.edit.own', 'com_getbible.verse.' . $recordId)) + { + // Now test the owner is the user. + $ownerId = (int) isset($data['created_by']) ? $data['created_by'] : 0; + if (empty($ownerId)) + { + // Need to do a lookup from the model. + $record = $this->getModel()->getItem($recordId); + + if (empty($record)) + { + return false; + } + $ownerId = $record->created_by; + } + + // If the owner matches 'me' then allow. + if ($ownerId == $user->id) + { + if ($user->authorise('verse.edit.own', 'com_getbible')) + { + return true; + } + } + } + return false; + } + } + // Since there is no permission, revert to the component permissions. + return $user->authorise('verse.edit', $this->option); + } + + /** + * Gets the URL arguments to append to an item redirect. + * + * @param integer $recordId The primary key id for the item. + * @param string $urlVar The name of the URL variable for the id. + * + * @return string The arguments to append to the redirect URL. + * + * @since 1.6 + */ + protected function getRedirectToItemAppend($recordId = null, $urlVar = 'id') + { + // get the referral options (old method use return instead see parent) + $ref = $this->input->get('ref', 0, 'string'); + $refid = $this->input->get('refid', 0, 'int'); + + // get redirect info. + $append = parent::getRedirectToItemAppend($recordId, $urlVar); + + // set the referral options + if ($refid && $ref) + { + $append = '&ref=' . (string)$ref . '&refid='. (int)$refid . $append; + } + elseif ($ref) + { + $append = '&ref='. (string)$ref . $append; + } + + return $append; + } + + /** + * Method to run batch operations. + * + * @param object $model The model. + * + * @return boolean True if successful, false otherwise and internal error is set. + * + * @since 2.5 + */ + public function batch($model = null) + { + JSession::checkToken() or jexit(JText::_('JINVALID_TOKEN')); + + // Set the model + $model = $this->getModel('Verse', '', array()); + + // Preset the redirect + $this->setRedirect(JRoute::_('index.php?option=com_getbible&view=verses' . $this->getRedirectToListAppend(), false)); + + return parent::batch($model); + } + + /** + * Method to cancel an edit. + * + * @param string $key The name of the primary key of the URL variable. + * + * @return boolean True if access level checks pass, false otherwise. + * + * @since 12.2 + */ + public function cancel($key = null) + { + // get the referral options + $this->ref = $this->input->get('ref', 0, 'word'); + $this->refid = $this->input->get('refid', 0, 'int'); + + // Check if there is a return value + $return = $this->input->get('return', null, 'base64'); + + $cancel = parent::cancel($key); + + if (!is_null($return) && JUri::isInternal(base64_decode($return))) + { + $redirect = base64_decode($return); + + // Redirect to the return value. + $this->setRedirect( + JRoute::_( + $redirect, false + ) + ); + } + elseif ($this->refid && $this->ref) + { + $redirect = '&view=' . (string)$this->ref . '&layout=edit&id=' . (int)$this->refid; + + // Redirect to the item screen. + $this->setRedirect( + JRoute::_( + 'index.php?option=' . $this->option . $redirect, false + ) + ); + } + elseif ($this->ref) + { + $redirect = '&view='.(string)$this->ref; + + // Redirect to the list screen. + $this->setRedirect( + JRoute::_( + 'index.php?option=' . $this->option . $redirect, false + ) + ); + } + return $cancel; + } + + /** + * Method to save a record. + * + * @param string $key The name of the primary key of the URL variable. + * @param string $urlVar The name of the URL variable if different from the primary key (sometimes required to avoid router collisions). + * + * @return boolean True if successful, false otherwise. + * + * @since 12.2 + */ + public function save($key = null, $urlVar = null) + { + // get the referral options + $this->ref = $this->input->get('ref', 0, 'word'); + $this->refid = $this->input->get('refid', 0, 'int'); + + // Check if there is a return value + $return = $this->input->get('return', null, 'base64'); + $canReturn = (!is_null($return) && JUri::isInternal(base64_decode($return))); + + if ($this->ref || $this->refid || $canReturn) + { + // to make sure the item is checkedin on redirect + $this->task = 'save'; + } + + $saved = parent::save($key, $urlVar); + + // This is not needed since parent save already does this + // Due to the ref and refid implementation we need to add this + if ($canReturn) + { + $redirect = base64_decode($return); + + // Redirect to the return value. + $this->setRedirect( + JRoute::_( + $redirect, false + ) + ); + } + elseif ($this->refid && $this->ref) + { + $redirect = '&view=' . (string)$this->ref . '&layout=edit&id=' . (int)$this->refid; + + // Redirect to the item screen. + $this->setRedirect( + JRoute::_( + 'index.php?option=' . $this->option . $redirect, false + ) + ); + } + elseif ($this->ref) + { + $redirect = '&view=' . (string)$this->ref; + + // Redirect to the list screen. + $this->setRedirect( + JRoute::_( + 'index.php?option=' . $this->option . $redirect, false + ) + ); + } + return $saved; + } + + /** + * Function that allows child controller access to model data + * after the data has been saved. + * + * @param JModel &$model The data model object. + * @param array $validData The validated data. + * + * @return void + * + * @since 11.1 + */ + protected function postSaveHook(JModelLegacy $model, $validData = array()) + { + return; + } + +} diff --git a/admin/controllers/verses.php b/admin/controllers/verses.php new file mode 100644 index 0000000..754606f --- /dev/null +++ b/admin/controllers/verses.php @@ -0,0 +1,52 @@ + + @git Get Bible + @github Get Bible + @support Get Bible + @copyright Copyright (C) 2015. All Rights Reserved + @license GNU/GPL Version 2 or later - http://www.gnu.org/licenses/gpl-2.0.html + +/------------------------------------------------------------------------------------------------------*/ + +// No direct access to this file +defined('_JEXEC') or die('Restricted access'); + +use Joomla\CMS\MVC\Controller\AdminController; +use Joomla\Utilities\ArrayHelper; + +/** + * Verses Admin Controller + */ +class GetbibleControllerVerses extends AdminController +{ + /** + * The prefix to use with controller messages. + * + * @var string + * @since 1.6 + */ + protected $text_prefix = 'COM_GETBIBLE_VERSES'; + + /** + * Method to get a model object, loading it if required. + * + * @param string $name The model name. Optional. + * @param string $prefix The class prefix. Optional. + * @param array $config Configuration array for model. Optional. + * + * @return JModelLegacy The model. + * + * @since 1.6 + */ + public function getModel($name = 'Verse', $prefix = 'GetbibleModel', $config = array('ignore_request' => true)) + { + return parent::getModel($name, $prefix, $config); + } +} diff --git a/admin/getbible.php b/admin/getbible.php new file mode 100644 index 0000000..435b779 --- /dev/null +++ b/admin/getbible.php @@ -0,0 +1,91 @@ + + @git Get Bible + @github Get Bible + @support Get Bible + @copyright Copyright (C) 2015. All Rights Reserved + @license GNU/GPL Version 2 or later - http://www.gnu.org/licenses/gpl-2.0.html + +/------------------------------------------------------------------------------------------------------*/ + +// No direct access to this file +defined('_JEXEC') or die('Restricted access'); + +// register this component namespace +spl_autoload_register(function ($class) { + // project-specific base directories and namespace prefix + $search = [ + 'libraries/jcb_powers/VDM.Joomla.GetBible' => 'VDM\\Joomla\\GetBible', + 'libraries/jcb_powers/VDM.Joomla.Openai' => 'VDM\\Joomla\\Openai', + 'libraries/jcb_powers/VDM.Joomla.Gitea' => 'VDM\\Joomla\\Gitea', + 'libraries/jcb_powers/VDM.Joomla' => 'VDM\\Joomla' + ]; + // Start the search and load if found + $found = false; + $found_base_dir = ""; + $found_len = 0; + foreach ($search as $base_dir => $prefix) + { + // does the class use the namespace prefix? + $len = strlen($prefix); + if (strncmp($prefix, $class, $len) === 0) + { + // we have a match so load the values + $found = true; + $found_base_dir = $base_dir; + $found_len = $len; + // done here + break; + } + } + // check if we found a match + if (!$found) + { + // not found so move to the next registered autoloader + return; + } + // get the relative class name + $relative_class = substr($class, $found_len); + // replace the namespace prefix with the base directory, replace namespace + // separators with directory separators in the relative class name, append + // with .php + $file = JPATH_ROOT . '/' . $found_base_dir . '/src' . str_replace('\\', '/', $relative_class) . '.php'; + // if the file exists, require it + if (file_exists($file)) + { + require $file; + } +}); + + + +// Access check. +if (!JFactory::getUser()->authorise('core.manage', 'com_getbible')) +{ + throw new JAccessExceptionNotallowed(JText::_('JERROR_ALERTNOAUTHOR'), 403); +}; + +// Add CSS file for all pages +$document = JFactory::getDocument(); +$document->addStyleSheet('components/com_getbible/assets/css/admin.css'); +$document->addScript('components/com_getbible/assets/js/admin.js'); + +// require helper files +JLoader::register('GetbibleHelper', __DIR__ . '/helpers/getbible.php'); +JLoader::register('JHtmlBatch_', __DIR__ . '/helpers/html/batch_.php'); + +// Get an instance of the controller prefixed by Getbible +$controller = JControllerLegacy::getInstance('Getbible'); + +// Perform the Request task +$controller->execute(JFactory::getApplication()->input->get('task')); + +// Redirect if set by the controller +$controller->redirect(); diff --git a/admin/helpers/getbible.php b/admin/helpers/getbible.php new file mode 100644 index 0000000..7461ab1 --- /dev/null +++ b/admin/helpers/getbible.php @@ -0,0 +1,1465 @@ + + @git Get Bible + @github Get Bible + @support Get Bible + @copyright Copyright (C) 2015. All Rights Reserved + @license GNU/GPL Version 2 or later - http://www.gnu.org/licenses/gpl-2.0.html + +/------------------------------------------------------------------------------------------------------*/ + +// No direct access to this file +defined('_JEXEC') or die('Restricted access'); + +// register this component namespace +spl_autoload_register(function ($class) { + // project-specific base directories and namespace prefix + $search = [ + 'libraries/jcb_powers/VDM.Joomla.GetBible' => 'VDM\\Joomla\\GetBible', + 'libraries/jcb_powers/VDM.Joomla.Openai' => 'VDM\\Joomla\\Openai', + 'libraries/jcb_powers/VDM.Joomla.Gitea' => 'VDM\\Joomla\\Gitea', + 'libraries/jcb_powers/VDM.Joomla' => 'VDM\\Joomla' + ]; + // Start the search and load if found + $found = false; + $found_base_dir = ""; + $found_len = 0; + foreach ($search as $base_dir => $prefix) + { + // does the class use the namespace prefix? + $len = strlen($prefix); + if (strncmp($prefix, $class, $len) === 0) + { + // we have a match so load the values + $found = true; + $found_base_dir = $base_dir; + $found_len = $len; + // done here + break; + } + } + // check if we found a match + if (!$found) + { + // not found so move to the next registered autoloader + return; + } + // get the relative class name + $relative_class = substr($class, $found_len); + // replace the namespace prefix with the base directory, replace namespace + // separators with directory separators in the relative class name, append + // with .php + $file = JPATH_ROOT . '/' . $found_base_dir . '/src' . str_replace('\\', '/', $relative_class) . '.php'; + // if the file exists, require it + if (file_exists($file)) + { + require $file; + } +}); + +use Joomla\CMS\Filesystem\File; +use Joomla\CMS\Language\Language; +use Joomla\Registry\Registry; +use Joomla\String\StringHelper; +use Joomla\Utilities\ArrayHelper; +use VDM\Joomla\GetBible\Factory; + +/** + * Getbible component helper. + */ +abstract class GetbibleHelper +{ + /** + * Composer Switch + * + * @var array + */ + protected static $composer = array(); + + /** + * The Main Active Language + * + * @var string + */ + public static $langTag; + + /** + * Load the scripture into content + * + * @param object &$row The article object. Note $article->text is also available + * @param object $plugin The plugin params + * + * @return void + * @since 2.0.1 + **/ + public static function loadScripture(object &$row, object $plugin): void + { + // get call string + $call_class = $plugin->get('call_class', 'getBible'); + + // Simple performance check to determine whether bot should process further + if (strpos($row->text, $call_class) === false) + { + return; + } + + Factory::_('GetBible.Loader')->set($row, $plugin); + } + + /** + * Load the Composer Vendors + */ + public static function composerAutoload($target) + { + // insure we load the composer vendor only once + if (!isset(self::$composer[$target])) + { + // get the function name + $functionName = self::safeString('compose' . $target); + // check if method exist + if (method_exists(__CLASS__, $functionName)) + { + return self::{$functionName}(); + } + return false; + } + return self::$composer[$target]; + } + + /** + * Load the Component xml manifest. + */ + public static function manifest() + { + $manifestUrl = JPATH_ADMINISTRATOR."/components/com_getbible/getbible.xml"; + return simplexml_load_file($manifestUrl); + } + + /** + * Joomla version object + */ + protected static $JVersion; + + /** + * set/get Joomla version + */ + public static function jVersion() + { + // check if set + if (!self::checkObject(self::$JVersion)) + { + self::$JVersion = new JVersion(); + } + return self::$JVersion; + } + + /** + * Load the Contributors details. + */ + public static function getContributors() + { + // get params + $params = JComponentHelper::getParams('com_getbible'); + // start contributors array + $contributors = array(); + // get all Contributors (max 20) + $searchArray = range('0','20'); + foreach($searchArray as $nr) + { + if ((NULL !== $params->get("showContributor".$nr)) && ($params->get("showContributor".$nr) == 1 || $params->get("showContributor".$nr) == 3)) + { + // set link based of selected option + if($params->get("useContributor".$nr) == 1) + { + $link_front = ''; + $link_back = ''; + } + elseif($params->get("useContributor".$nr) == 2) + { + $link_front = ''; + $link_back = ''; + } + else + { + $link_front = ''; + $link_back = ''; + } + $contributors[$nr]['title'] = self::htmlEscape($params->get("titleContributor".$nr)); + $contributors[$nr]['name'] = $link_front.self::htmlEscape($params->get("nameContributor".$nr)).$link_back; + } + } + return $contributors; + } + + /** + * Can be used to build help urls. + **/ + public static function getHelpUrl($view) + { + return false; + } + + /** + * Configure the Linkbar. + */ + public static function addSubmenu($submenu) + { + // load user for access menus + $user = JFactory::getUser(); + // load the submenus to sidebar + JHtmlSidebar::addEntry(JText::_('COM_GETBIBLE_SUBMENU_DASHBOARD'), 'index.php?option=com_getbible&view=getbible', $submenu === 'getbible'); + if ($user->authorise('linker.access', 'com_getbible') && $user->authorise('linker.submenu', 'com_getbible')) + { + JHtmlSidebar::addEntry(JText::_('COM_GETBIBLE_SUBMENU_LINKERS'), 'index.php?option=com_getbible&view=linkers', $submenu === 'linkers'); + } + if ($user->authorise('note.access', 'com_getbible') && $user->authorise('note.submenu', 'com_getbible')) + { + JHtmlSidebar::addEntry(JText::_('COM_GETBIBLE_SUBMENU_NOTES'), 'index.php?option=com_getbible&view=notes', $submenu === 'notes'); + } + if ($user->authorise('tagged_verse.access', 'com_getbible') && $user->authorise('tagged_verse.submenu', 'com_getbible')) + { + JHtmlSidebar::addEntry(JText::_('COM_GETBIBLE_SUBMENU_TAGGED_VERSES'), 'index.php?option=com_getbible&view=tagged_verses', $submenu === 'tagged_verses'); + } + if ($user->authorise('prompt.access', 'com_getbible') && $user->authorise('prompt.submenu', 'com_getbible')) + { + JHtmlSidebar::addEntry(JText::_('COM_GETBIBLE_SUBMENU_PROMPTS'), 'index.php?option=com_getbible&view=prompts', $submenu === 'prompts'); + } + if ($user->authorise('open_ai_response.access', 'com_getbible') && $user->authorise('open_ai_response.submenu', 'com_getbible')) + { + JHtmlSidebar::addEntry(JText::_('COM_GETBIBLE_SUBMENU_OPEN_AI_RESPONSES'), 'index.php?option=com_getbible&view=open_ai_responses', $submenu === 'open_ai_responses'); + } + if ($user->authorise('tag.access', 'com_getbible') && $user->authorise('tag.submenu', 'com_getbible')) + { + JHtmlSidebar::addEntry(JText::_('COM_GETBIBLE_SUBMENU_TAGS'), 'index.php?option=com_getbible&view=tags', $submenu === 'tags'); + } + if ($user->authorise('translation.access', 'com_getbible') && $user->authorise('translation.submenu', 'com_getbible')) + { + JHtmlSidebar::addEntry(JText::_('COM_GETBIBLE_SUBMENU_TRANSLATIONS'), 'index.php?option=com_getbible&view=translations', $submenu === 'translations'); + } + if ($user->authorise('book.access', 'com_getbible') && $user->authorise('book.submenu', 'com_getbible')) + { + JHtmlSidebar::addEntry(JText::_('COM_GETBIBLE_SUBMENU_BOOKS'), 'index.php?option=com_getbible&view=books', $submenu === 'books'); + } + if ($user->authorise('chapter.access', 'com_getbible') && $user->authorise('chapter.submenu', 'com_getbible')) + { + JHtmlSidebar::addEntry(JText::_('COM_GETBIBLE_SUBMENU_CHAPTERS'), 'index.php?option=com_getbible&view=chapters', $submenu === 'chapters'); + } + if ($user->authorise('verse.access', 'com_getbible') && $user->authorise('verse.submenu', 'com_getbible')) + { + JHtmlSidebar::addEntry(JText::_('COM_GETBIBLE_SUBMENU_VERSES'), 'index.php?option=com_getbible&view=verses', $submenu === 'verses'); + } + } + + /** + * Get a Variable + * + * @param string $table The table from which to get the variable + * @param string $where The value where + * @param string $whereString The target/field string where/name + * @param string $what The return field + * @param string $operator The operator between $whereString/field and $where/value + * @param string $main The component in which the table is found + * + * @return mix string/int/float + * + */ + public static function getVar($table, $where = null, $whereString = 'user', $what = 'id', $operator = '=', $main = 'getbible') + { + if(!$where) + { + $where = JFactory::getUser()->id; + } + // Get a db connection. + $db = JFactory::getDbo(); + // Create a new query object. + $query = $db->getQuery(true); + $query->select($db->quoteName(array($what))); + if (empty($table)) + { + $query->from($db->quoteName('#__'.$main)); + } + else + { + $query->from($db->quoteName('#__'.$main.'_'.$table)); + } + if (is_numeric($where)) + { + $query->where($db->quoteName($whereString) . ' '.$operator.' '.(int) $where); + } + elseif (is_string($where)) + { + $query->where($db->quoteName($whereString) . ' '.$operator.' '. $db->quote((string)$where)); + } + else + { + return false; + } + $db->setQuery($query); + $db->execute(); + if ($db->getNumRows()) + { + return $db->loadResult(); + } + return false; + } + + /** + * Get array of variables + * + * @param string $table The table from which to get the variables + * @param string $where The value where + * @param string $whereString The target/field string where/name + * @param string $what The return field + * @param string $operator The operator between $whereString/field and $where/value + * @param string $main The component in which the table is found + * @param bool $unique The switch to return a unique array + * + * @return array + * + */ + public static function getVars($table, $where = null, $whereString = 'user', $what = 'id', $operator = 'IN', $main = 'getbible', $unique = true) + { + if(!$where) + { + $where = JFactory::getUser()->id; + } + + if (!self::checkArray($where) && $where > 0) + { + $where = array($where); + } + + if (self::checkArray($where)) + { + // prep main <-- why? well if $main='' is empty then $table can be categories or users + if (self::checkString($main)) + { + $main = '_'.ltrim($main, '_'); + } + // Get a db connection. + $db = JFactory::getDbo(); + // Create a new query object. + $query = $db->getQuery(true); + + $query->select($db->quoteName(array($what))); + if (empty($table)) + { + $query->from($db->quoteName('#__'.$main)); + } + else + { + $query->from($db->quoteName('#_'.$main.'_'.$table)); + } + // add strings to array search + if ('IN_STRINGS' === $operator || 'NOT IN_STRINGS' === $operator) + { + $query->where($db->quoteName($whereString) . ' ' . str_replace('_STRINGS', '', $operator) . ' ("' . implode('","',$where) . '")'); + } + else + { + $query->where($db->quoteName($whereString) . ' ' . $operator . ' (' . implode(',',$where) . ')'); + } + $db->setQuery($query); + $db->execute(); + if ($db->getNumRows()) + { + if ($unique) + { + return array_unique($db->loadColumn()); + } + return $db->loadColumn(); + } + } + return false; + } + + public static function jsonToString($value, $sperator = ", ", $table = null, $id = 'id', $name = 'name') + { + // do some table foot work + $external = false; + if (strpos($table, '#__') !== false) + { + $external = true; + $table = str_replace('#__', '', $table); + } + // check if string is JSON + $result = json_decode($value, true); + if (json_last_error() === JSON_ERROR_NONE) + { + // is JSON + if (self::checkArray($result)) + { + if (self::checkString($table)) + { + $names = array(); + foreach ($result as $val) + { + if ($external) + { + if ($_name = self::getVar(null, $val, $id, $name, '=', $table)) + { + $names[] = $_name; + } + } + else + { + if ($_name = self::getVar($table, $val, $id, $name)) + { + $names[] = $_name; + } + } + } + if (self::checkArray($names)) + { + return (string) implode($sperator,$names); + } + } + return (string) implode($sperator,$result); + } + return (string) json_decode($value); + } + return $value; + } + + public static function isPublished($id,$type) + { + if ($type == 'raw') + { + $type = 'item'; + } + $db = JFactory::getDbo(); + $query = $db->getQuery(true); + $query->select(array('a.published')); + $query->from('#__getbible_'.$type.' AS a'); + $query->where('a.id = '. (int) $id); + $query->where('a.published = 1'); + $db->setQuery($query); + $db->execute(); + $found = $db->getNumRows(); + if($found) + { + return true; + } + return false; + } + + public static function getGroupName($id) + { + $db = JFactory::getDBO(); + $query = $db->getQuery(true); + $query->select(array('a.title')); + $query->from('#__usergroups AS a'); + $query->where('a.id = '. (int) $id); + $db->setQuery($query); + $db->execute(); + $found = $db->getNumRows(); + if($found) + { + return $db->loadResult(); + } + return $id; + } + + /** + * Get the action permissions + * + * @param string $view The related view name + * @param int $record The item to act upon + * @param string $views The related list view name + * @param mixed $target Only get this permission (like edit, create, delete) + * @param string $component The target component + * @param object $user The user whose permissions we are loading + * + * @return object The JObject of permission/authorised actions + * + */ + public static function getActions($view, &$record = null, $views = null, $target = null, $component = 'getbible', $user = 'null') + { + // load the user if not given + if (!self::checkObject($user)) + { + // get the user object + $user = JFactory::getUser(); + } + // load the JObject + $result = new JObject; + // make view name safe (just incase) + $view = self::safeString($view); + if (self::checkString($views)) + { + $views = self::safeString($views); + } + // get all actions from component + $actions = JAccess::getActionsFromFile( + JPATH_ADMINISTRATOR . '/components/com_' . $component . '/access.xml', + "/access/section[@name='component']/" + ); + // if non found then return empty JObject + if (empty($actions)) + { + return $result; + } + // get created by if not found + if (self::checkObject($record) && !isset($record->created_by) && isset($record->id)) + { + $record->created_by = self::getVar($view, $record->id, 'id', 'created_by', '=', $component); + } + // set actions only set in component settings + $componentActions = array('core.admin', 'core.manage', 'core.options', 'core.export'); + // check if we have a target + $checkTarget = false; + if ($target) + { + // convert to an array + if (self::checkString($target)) + { + $target = array($target); + } + // check if we are good to go + if (self::checkArray($target)) + { + $checkTarget = true; + } + } + // loop the actions and set the permissions + foreach ($actions as $action) + { + // check target action filter + if ($checkTarget && self::filterActions($view, $action->name, $target)) + { + continue; + } + // set to use component default + $fallback = true; + // reset permission per/action + $permission = false; + $catpermission = false; + // set area + $area = 'comp'; + // check if the record has an ID and the action is item related (not a component action) + if (self::checkObject($record) && isset($record->id) && $record->id > 0 && !in_array($action->name, $componentActions) && + (strpos($action->name, 'core.') !== false || strpos($action->name, $view . '.') !== false)) + { + // we are in item + $area = 'item'; + // The record has been set. Check the record permissions. + $permission = $user->authorise($action->name, 'com_' . $component . '.' . $view . '.' . (int) $record->id); + // if no permission found, check edit own + if (!$permission) + { + // With edit, if the created_by matches current user then dig deeper. + if (($action->name === 'core.edit' || $action->name === $view . '.edit') && $record->created_by > 0 && ($record->created_by == $user->id)) + { + // the correct target + $coreCheck = (array) explode('.', $action->name); + // check that we have both local and global access + if ($user->authorise($coreCheck[0] . '.edit.own', 'com_' . $component . '.' . $view . '.' . (int) $record->id) && + $user->authorise($coreCheck[0] . '.edit.own', 'com_' . $component)) + { + // allow edit + $result->set($action->name, true); + // set not to use global default + // because we already validated it + $fallback = false; + } + else + { + // do not allow edit + $result->set($action->name, false); + $fallback = false; + } + } + } + elseif (self::checkString($views) && isset($record->catid) && $record->catid > 0) + { + // we are in item + $area = 'category'; + // set the core check + $coreCheck = explode('.', $action->name); + $core = $coreCheck[0]; + // make sure we use the core. action check for the categories + if (strpos($action->name, $view) !== false && strpos($action->name, 'core.') === false ) + { + $coreCheck[0] = 'core'; + $categoryCheck = implode('.', $coreCheck); + } + else + { + $categoryCheck = $action->name; + } + // The record has a category. Check the category permissions. + $catpermission = $user->authorise($categoryCheck, 'com_' . $component . '.' . $views . '.category.' . (int) $record->catid); + if (!$catpermission && !is_null($catpermission)) + { + // With edit, if the created_by matches current user then dig deeper. + if (($action->name === 'core.edit' || $action->name === $view . '.edit') && $record->created_by > 0 && ($record->created_by == $user->id)) + { + // check that we have both local and global access + if ($user->authorise('core.edit.own', 'com_' . $component . '.' . $views . '.category.' . (int) $record->catid) && + $user->authorise($core . '.edit.own', 'com_' . $component)) + { + // allow edit + $result->set($action->name, true); + // set not to use global default + // because we already validated it + $fallback = false; + } + else + { + // do not allow edit + $result->set($action->name, false); + $fallback = false; + } + } + } + } + } + // if allowed then fallback on component global settings + if ($fallback) + { + // if item/category blocks access then don't fall back on global + if ((($area === 'item') && !$permission) || (($area === 'category') && !$catpermission)) + { + // do not allow + $result->set($action->name, false); + } + // Finally remember the global settings have the final say. (even if item allow) + // The local item permissions can block, but it can't open and override of global permissions. + // Since items are created by users and global permissions is set by system admin. + else + { + $result->set($action->name, $user->authorise($action->name, 'com_' . $component)); + } + } + } + return $result; + } + + /** + * Filter the action permissions + * + * @param string $action The action to check + * @param array $targets The array of target actions + * + * @return boolean true if action should be filtered out + * + */ + protected static function filterActions(&$view, &$action, &$targets) + { + foreach ($targets as $target) + { + if (strpos($action, $view . '.' . $target) !== false || + strpos($action, 'core.' . $target) !== false) + { + return false; + break; + } + } + return true; + } + + /** + * Get any component's model + */ + public static function getModel($name, $path = JPATH_COMPONENT_ADMINISTRATOR, $Component = 'Getbible', $config = array()) + { + // fix the name + $name = self::safeString($name); + // full path to models + $fullPathModels = $path . '/models'; + // load the model file + JModelLegacy::addIncludePath($fullPathModels, $Component . 'Model'); + // make sure the table path is loaded + if (!isset($config['table_path']) || !self::checkString($config['table_path'])) + { + // This is the JCB default path to tables in Joomla 3.x + $config['table_path'] = JPATH_ADMINISTRATOR . '/components/com_' . strtolower($Component) . '/tables'; + } + // get instance + $model = JModelLegacy::getInstance($name, $Component . 'Model', $config); + // if model not found (strange) + if ($model == false) + { + jimport('joomla.filesystem.file'); + // get file path + $filePath = $path . '/' . $name . '.php'; + $fullPathModel = $fullPathModels . '/' . $name . '.php'; + // check if it exists + if (File::exists($filePath)) + { + // get the file + require_once $filePath; + } + elseif (File::exists($fullPathModel)) + { + // get the file + require_once $fullPathModel; + } + // build class names + $modelClass = $Component . 'Model' . $name; + if (class_exists($modelClass)) + { + // initialize the model + return new $modelClass($config); + } + } + return $model; + } + + /** + * Add to asset Table + */ + public static function setAsset($id, $table, $inherit = true) + { + $parent = JTable::getInstance('Asset'); + $parent->loadByName('com_getbible'); + + $parentId = $parent->id; + $name = 'com_getbible.'.$table.'.'.$id; + $title = ''; + + $asset = JTable::getInstance('Asset'); + $asset->loadByName($name); + + // Check for an error. + $error = $asset->getError(); + + if ($error) + { + return false; + } + else + { + // Specify how a new or moved node asset is inserted into the tree. + if ($asset->parent_id != $parentId) + { + $asset->setLocation($parentId, 'last-child'); + } + + // Prepare the asset to be stored. + $asset->parent_id = $parentId; + $asset->name = $name; + $asset->title = $title; + // get the default asset rules + $rules = self::getDefaultAssetRules('com_getbible', $table, $inherit); + if ($rules instanceof JAccessRules) + { + $asset->rules = (string) $rules; + } + + if (!$asset->check() || !$asset->store()) + { + JFactory::getApplication()->enqueueMessage($asset->getError(), 'warning'); + return false; + } + else + { + // Create an asset_id or heal one that is corrupted. + $object = new stdClass(); + + // Must be a valid primary key value. + $object->id = $id; + $object->asset_id = (int) $asset->id; + + // Update their asset_id to link to the asset table. + return JFactory::getDbo()->updateObject('#__getbible_'.$table, $object, 'id'); + } + } + return false; + } + + /** + * Gets the default asset Rules for a component/view. + */ + protected static function getDefaultAssetRules($component, $view, $inherit = true) + { + // if new or inherited + $assetId = 0; + // Only get the actual item rules if not inheriting + if (!$inherit) + { + // Need to find the asset id by the name of the component. + $db = JFactory::getDbo(); + $query = $db->getQuery(true) + ->select($db->quoteName('id')) + ->from($db->quoteName('#__assets')) + ->where($db->quoteName('name') . ' = ' . $db->quote($component)); + $db->setQuery($query); + $db->execute(); + // check that there is a value + if ($db->getNumRows()) + { + // asset already set so use saved rules + $assetId = (int) $db->loadResult(); + } + } + // get asset rules + $result = JAccess::getAssetRules($assetId); + if ($result instanceof JAccessRules) + { + $_result = (string) $result; + $_result = json_decode($_result); + foreach ($_result as $name => &$rule) + { + $v = explode('.', $name); + if ($view !== $v[0]) + { + // remove since it is not part of this view + unset($_result->$name); + } + elseif ($inherit) + { + // clear the value since we inherit + $rule = array(); + } + } + // check if there are any view values remaining + if (count((array) $_result)) + { + $_result = json_encode($_result); + $_result = array($_result); + // Instantiate and return the JAccessRules object for the asset rules. + $rules = new JAccessRules($_result); + // return filtered rules + return $rules; + } + } + return $result; + } + + /** + * xmlAppend + * + * @param SimpleXMLElement $xml The XML element reference in which to inject a comment + * @param mixed $node A SimpleXMLElement node to append to the XML element reference, or a stdClass object containing a comment attribute to be injected before the XML node and a fieldXML attribute containing a SimpleXMLElement + * + * @return null + * + */ + public static function xmlAppend(&$xml, $node) + { + if (!$node) + { + // element was not returned + return; + } + switch (get_class($node)) + { + case 'stdClass': + if (property_exists($node, 'comment')) + { + self::xmlComment($xml, $node->comment); + } + if (property_exists($node, 'fieldXML')) + { + self::xmlAppend($xml, $node->fieldXML); + } + break; + case 'SimpleXMLElement': + $domXML = dom_import_simplexml($xml); + $domNode = dom_import_simplexml($node); + $domXML->appendChild($domXML->ownerDocument->importNode($domNode, true)); + $xml = simplexml_import_dom($domXML); + break; + } + } + + /** + * xmlComment + * + * @param SimpleXMLElement $xml The XML element reference in which to inject a comment + * @param string $comment The comment to inject + * + * @return null + * + */ + public static function xmlComment(&$xml, $comment) + { + $domXML = dom_import_simplexml($xml); + $domComment = new DOMComment($comment); + $nodeTarget = $domXML->ownerDocument->importNode($domComment, true); + $domXML->appendChild($nodeTarget); + $xml = simplexml_import_dom($domXML); + } + + /** + * xmlAddAttributes + * + * @param SimpleXMLElement $xml The XML element reference in which to inject a comment + * @param array $attributes The attributes to apply to the XML element + * + * @return null + * + */ + public static function xmlAddAttributes(&$xml, $attributes = array()) + { + foreach ($attributes as $key => $value) + { + $xml->addAttribute($key, $value); + } + } + + /** + * xmlAddOptions + * + * @param SimpleXMLElement $xml The XML element reference in which to inject a comment + * @param array $options The options to apply to the XML element + * + * @return void + * + */ + public static function xmlAddOptions(&$xml, $options = array()) + { + foreach ($options as $key => $value) + { + $addOption = $xml->addChild('option'); + $addOption->addAttribute('value', $key); + $addOption[] = $value; + } + } + + /** + * get the field object + * + * @param array $attributes The array of attributes + * @param string $default The default of the field + * @param array $options The options to apply to the XML element + * + * @return object + * + */ + public static function getFieldObject(&$attributes, $default = '', $options = null) + { + // make sure we have attributes and a type value + if (self::checkArray($attributes) && isset($attributes['type'])) + { + // make sure the form helper class is loaded + if (!method_exists('JFormHelper', 'loadFieldType')) + { + jimport('joomla.form.form'); + } + // get field type + $field = JFormHelper::loadFieldType($attributes['type'], true); + // get field xml + $XML = self::getFieldXML($attributes, $options); + // setup the field + $field->setup($XML, $default); + // return the field object + return $field; + } + return false; + } + + /** + * get the field xml + * + * @param array $attributes The array of attributes + * @param array $options The options to apply to the XML element + * + * @return object + * + */ + public static function getFieldXML(&$attributes, $options = null) + { + // make sure we have attributes and a type value + if (self::checkArray($attributes)) + { + // start field xml + $XML = new SimpleXMLElement(''); + // load the attributes + self::xmlAddAttributes($XML, $attributes); + // check if we have options + if (self::checkArray($options)) + { + // load the options + self::xmlAddOptions($XML, $options); + } + // return the field xml + return $XML; + } + return false; + } + + /** + * Render Bool Button + * + * @param array $args All the args for the button + * 0) name + * 1) additional (options class) // not used at this time + * 2) default + * 3) yes (name) + * 4) no (name) + * + * @return string The input html of the button + * + */ + public static function renderBoolButton() + { + $args = func_get_args(); + // check if there is additional button class + $additional = isset($args[1]) ? (string) $args[1] : ''; // not used at this time + // button attributes + $buttonAttributes = array( + 'type' => 'radio', + 'name' => isset($args[0]) ? self::htmlEscape($args[0]) : 'bool_button', + 'label' => isset($args[0]) ? self::safeString(self::htmlEscape($args[0]), 'Ww') : 'Bool Button', // not seen anyway + 'class' => 'btn-group', + 'filter' => 'INT', + 'default' => isset($args[2]) ? (int) $args[2] : 0); + // set the button options + $buttonOptions = array( + '1' => isset($args[3]) ? self::htmlEscape($args[3]) : 'JYES', + '0' => isset($args[4]) ? self::htmlEscape($args[4]) : 'JNO'); + // return the input + return self::getFieldObject($buttonAttributes, $buttonAttributes['default'], $buttonOptions)->input; + } + + /** + * Check if have an json string + * + * @input string The json string to check + * + * @returns bool true on success + */ + public static function checkJson($string) + { + if (self::checkString($string)) + { + json_decode($string); + return (json_last_error() === JSON_ERROR_NONE); + } + return false; + } + + /** + * Check if have an object with a length + * + * @input object The object to check + * + * @returns bool true on success + */ + public static function checkObject($object) + { + if (isset($object) && is_object($object)) + { + return count((array)$object) > 0; + } + return false; + } + + /** + * Check if have an array with a length + * + * @input array The array to check + * + * @returns bool/int number of items in array on success + */ + public static function checkArray($array, $removeEmptyString = false) + { + if (isset($array) && is_array($array) && ($nr = count((array)$array)) > 0) + { + // also make sure the empty strings are removed + if ($removeEmptyString) + { + foreach ($array as $key => $string) + { + if (empty($string)) + { + unset($array[$key]); + } + } + return self::checkArray($array, false); + } + return $nr; + } + return false; + } + + /** + * Check if have a string with a length + * + * @input string The string to check + * + * @returns bool true on success + */ + public static function checkString($string) + { + if (isset($string) && is_string($string) && strlen($string) > 0) + { + return true; + } + return false; + } + + /** + * Check if we are connected + * Thanks https://stackoverflow.com/a/4860432/1429677 + * + * @returns bool true on success + */ + public static function isConnected() + { + // If example.com is down, then probably the whole internet is down, since IANA maintains the domain. Right? + $connected = @fsockopen("www.example.com", 80); + // website, port (try 80 or 443) + if ($connected) + { + //action when connected + $is_conn = true; + fclose($connected); + } + else + { + //action in connection failure + $is_conn = false; + } + return $is_conn; + } + + /** + * Merge an array of array's + * + * @input array The arrays you would like to merge + * + * @returns array on success + */ + public static function mergeArrays($arrays) + { + if(self::checkArray($arrays)) + { + $arrayBuket = array(); + foreach ($arrays as $array) + { + if (self::checkArray($array)) + { + $arrayBuket = array_merge($arrayBuket, $array); + } + } + return $arrayBuket; + } + return false; + } + + // typo sorry! + public static function sorten($string, $length = 40, $addTip = true) + { + return self::shorten($string, $length, $addTip); + } + + /** + * Shorten a string + * + * @input string The you would like to shorten + * + * @returns string on success + */ + public static function shorten($string, $length = 40, $addTip = true) + { + if (self::checkString($string)) + { + $initial = strlen($string); + $words = preg_split('/([\s\n\r]+)/', $string, null, PREG_SPLIT_DELIM_CAPTURE); + $words_count = count((array)$words); + + $word_length = 0; + $last_word = 0; + for (; $last_word < $words_count; ++$last_word) + { + $word_length += strlen($words[$last_word]); + if ($word_length > $length) + { + break; + } + } + + $newString = implode(array_slice($words, 0, $last_word)); + $final = strlen($newString); + if ($initial != $final && $addTip) + { + $title = self::shorten($string, 400 , false); + return ''.trim($newString).'...'; + } + elseif ($initial != $final && !$addTip) + { + return trim($newString).'...'; + } + } + return $string; + } + + /** + * Making strings safe (various ways) + * + * @input string The you would like to make safe + * + * @returns string on success + */ + public static function safeString($string, $type = 'L', $spacer = '_', $replaceNumbers = true, $keepOnlyCharacters = true) + { + if ($replaceNumbers === true) + { + // remove all numbers and replace with english text version (works well only up to millions) + $string = self::replaceNumbers($string); + } + // 0nly continue if we have a string + if (self::checkString($string)) + { + // create file name without the extention that is safe + if ($type === 'filename') + { + // make sure VDM is not in the string + $string = str_replace('VDM', 'vDm', $string); + // Remove anything which isn't a word, whitespace, number + // or any of the following caracters -_() + // If you don't need to handle multi-byte characters + // you can use preg_replace rather than mb_ereg_replace + // Thanks @Łukasz Rysiak! + // $string = mb_ereg_replace("([^\w\s\d\-_\(\)])", '', $string); + $string = preg_replace("([^\w\s\d\-_\(\)])", '', $string); + // http://stackoverflow.com/a/2021729/1429677 + return preg_replace('/\s+/', ' ', $string); + } + // remove all other characters + $string = trim($string); + $string = preg_replace('/'.$spacer.'+/', ' ', $string); + $string = preg_replace('/\s+/', ' ', $string); + // Transliterate string + $string = self::transliterate($string); + // remove all and keep only characters + if ($keepOnlyCharacters) + { + $string = preg_replace("/[^A-Za-z ]/", '', $string); + } + // keep both numbers and characters + else + { + $string = preg_replace("/[^A-Za-z0-9 ]/", '', $string); + } + // select final adaptations + if ($type === 'L' || $type === 'strtolower') + { + // replace white space with underscore + $string = preg_replace('/\s+/', $spacer, $string); + // default is to return lower + return strtolower($string); + } + elseif ($type === 'W') + { + // return a string with all first letter of each word uppercase(no undersocre) + return ucwords(strtolower($string)); + } + elseif ($type === 'w' || $type === 'word') + { + // return a string with all lowercase(no undersocre) + return strtolower($string); + } + elseif ($type === 'Ww' || $type === 'Word') + { + // return a string with first letter of the first word uppercase and all the rest lowercase(no undersocre) + return ucfirst(strtolower($string)); + } + elseif ($type === 'WW' || $type === 'WORD') + { + // return a string with all the uppercase(no undersocre) + return strtoupper($string); + } + elseif ($type === 'U' || $type === 'strtoupper') + { + // replace white space with underscore + $string = preg_replace('/\s+/', $spacer, $string); + // return all upper + return strtoupper($string); + } + elseif ($type === 'F' || $type === 'ucfirst') + { + // replace white space with underscore + $string = preg_replace('/\s+/', $spacer, $string); + // return with first caracter to upper + return ucfirst(strtolower($string)); + } + elseif ($type === 'cA' || $type === 'cAmel' || $type === 'camelcase') + { + // convert all words to first letter uppercase + $string = ucwords(strtolower($string)); + // remove white space + $string = preg_replace('/\s+/', '', $string); + // now return first letter lowercase + return lcfirst($string); + } + // return string + return $string; + } + // not a string + return ''; + } + + public static function transliterate($string) + { + // set tag only once + if (!self::checkString(self::$langTag)) + { + // get global value + self::$langTag = JComponentHelper::getParams('com_getbible')->get('language', 'en-GB'); + } + // Transliterate on the language requested + $lang = Language::getInstance(self::$langTag); + return $lang->transliterate($string); + } + + public static function htmlEscape($var, $charset = 'UTF-8', $shorten = false, $length = 40) + { + if (self::checkString($var)) + { + $filter = new JFilterInput(); + $string = $filter->clean(html_entity_decode(htmlentities($var, ENT_COMPAT, $charset)), 'HTML'); + if ($shorten) + { + return self::shorten($string,$length); + } + return $string; + } + else + { + return ''; + } + } + + public static function replaceNumbers($string) + { + // set numbers array + $numbers = array(); + // first get all numbers + preg_match_all('!\d+!', $string, $numbers); + // check if we have any numbers + if (isset($numbers[0]) && self::checkArray($numbers[0])) + { + foreach ($numbers[0] as $number) + { + $searchReplace[$number] = self::numberToString((int)$number); + } + // now replace numbers in string + $string = str_replace(array_keys($searchReplace), array_values($searchReplace),$string); + // check if we missed any, strange if we did. + return self::replaceNumbers($string); + } + // return the string with no numbers remaining. + return $string; + } + + /** + * Convert an integer into an English word string + * Thanks to Tom Nicholson + * + * @input an int + * @returns a string + */ + public static function numberToString($x) + { + $nwords = array( "zero", "one", "two", "three", "four", "five", "six", "seven", + "eight", "nine", "ten", "eleven", "twelve", "thirteen", + "fourteen", "fifteen", "sixteen", "seventeen", "eighteen", + "nineteen", "twenty", 30 => "thirty", 40 => "forty", + 50 => "fifty", 60 => "sixty", 70 => "seventy", 80 => "eighty", + 90 => "ninety" ); + + if(!is_numeric($x)) + { + $w = $x; + } + elseif(fmod($x, 1) != 0) + { + $w = $x; + } + else + { + if($x < 0) + { + $w = 'minus '; + $x = -$x; + } + else + { + $w = ''; + // ... now $x is a non-negative integer. + } + + if($x < 21) // 0 to 20 + { + $w .= $nwords[$x]; + } + elseif($x < 100) // 21 to 99 + { + $w .= $nwords[10 * floor($x/10)]; + $r = fmod($x, 10); + if($r > 0) + { + $w .= ' '. $nwords[$r]; + } + } + elseif($x < 1000) // 100 to 999 + { + $w .= $nwords[floor($x/100)] .' hundred'; + $r = fmod($x, 100); + if($r > 0) + { + $w .= ' and '. self::numberToString($r); + } + } + elseif($x < 1000000) // 1000 to 999999 + { + $w .= self::numberToString(floor($x/1000)) .' thousand'; + $r = fmod($x, 1000); + if($r > 0) + { + $w .= ' '; + if($r < 100) + { + $w .= 'and '; + } + $w .= self::numberToString($r); + } + } + else // millions + { + $w .= self::numberToString(floor($x/1000000)) .' million'; + $r = fmod($x, 1000000); + if($r > 0) + { + $w .= ' '; + if($r < 100) + { + $w .= 'and '; + } + $w .= self::numberToString($r); + } + } + } + return $w; + } + + /** + * Random Key + * + * @returns a string + */ + public static function randomkey($size) + { + $bag = "abcefghijknopqrstuwxyzABCDDEFGHIJKLLMMNOPQRSTUVVWXYZabcddefghijkllmmnopqrstuvvwxyzABCEFGHIJKNOPQRSTUWXYZ"; + $key = array(); + $bagsize = strlen($bag) - 1; + for ($i = 0; $i < $size; $i++) + { + $get = rand(0, $bagsize); + $key[] = $bag[$get]; + } + return implode($key); + } +} + diff --git a/admin/helpers/headercheck.php b/admin/helpers/headercheck.php new file mode 100644 index 0000000..171cdbe --- /dev/null +++ b/admin/helpers/headercheck.php @@ -0,0 +1,77 @@ + + @git Get Bible + @github Get Bible + @support Get Bible + @copyright Copyright (C) 2015. All Rights Reserved + @license GNU/GPL Version 2 or later - http://www.gnu.org/licenses/gpl-2.0.html + +/------------------------------------------------------------------------------------------------------*/ + +// No direct access to this file +defined('_JEXEC') or die('Restricted access'); + +class getbibleHeaderCheck +{ + function js_loaded($script_name) + { + // UIkit check point + if (strpos($script_name,'uikit') !== false) + { + $app = JFactory::getApplication(); + $getTemplateName = $app->getTemplate('template')->template; + + if (strpos($getTemplateName,'yoo') !== false) + { + return true; + } + } + + $document = JFactory::getDocument(); + $head_data = $document->getHeadData(); + foreach (array_keys($head_data['scripts']) as $script) + { + if (stristr($script, $script_name)) + { + return true; + } + } + + return false; + } + + function css_loaded($script_name) + { + // UIkit check point + if (strpos($script_name,'uikit') !== false) + { + $app = JFactory::getApplication(); + $getTemplateName = $app->getTemplate('template')->template; + + if (strpos($getTemplateName,'yoo') !== false) + { + return true; + } + } + + $document = JFactory::getDocument(); + $head_data = $document->getHeadData(); + + foreach (array_keys($head_data['styleSheets']) as $script) + { + if (stristr($script, $script_name)) + { + return true; + } + } + + return false; + } +} \ No newline at end of file diff --git a/admin/helpers/html/batch_.php b/admin/helpers/html/batch_.php new file mode 100644 index 0000000..1abd495 --- /dev/null +++ b/admin/helpers/html/batch_.php @@ -0,0 +1,84 @@ + + @git Get Bible + @github Get Bible + @support Get Bible + @copyright Copyright (C) 2015. All Rights Reserved + @license GNU/GPL Version 2 or later - http://www.gnu.org/licenses/gpl-2.0.html + +/------------------------------------------------------------------------------------------------------*/ + +// No direct access to this file +defined('JPATH_PLATFORM') or die; + +/** + * Utility class to render a list view batch selection options + * + * @since 3.0 + */ +abstract class JHtmlBatch_ +{ + /** + * ListSelection + * + * @var array + * @since 3.0 + */ + protected static $ListSelection = array(); + + /** + * Render the batch selection options. + * + * @return string The necessary HTML to display the batch selection options + * + * @since 3.0 + */ + public static function render() + { + // Collect display data + $data = new stdClass; + $data->ListSelection = static::getListSelection(); + + // Create a layout object and ask it to render the batch selection options + $layout = new JLayoutFile('batchselection'); + $batchHtml = $layout->render($data); + + return $batchHtml; + } + + /** + * Method to add a list selection to the batch modal + * + * @param string $label Label for the menu item. + * @param string $name Name for the filter. Also used as id. + * @param string $options Options for the select field. + * @param bool $noDefault Don't the label as the empty option + * + * @return void + * + * @since 3.0 + */ + public static function addListSelection($label, $name, $options, $noDefault = false) + { + array_push(static::$ListSelection, array('label' => $label, 'name' => $name, 'options' => $options, 'noDefault' => $noDefault)); + } + + /** + * Returns an array of all ListSelection + * + * @return array + * + * @since 3.0 + */ + public static function getListSelection() + { + return static::$ListSelection; + } +} diff --git a/admin/helpers/html/index.html b/admin/helpers/html/index.html new file mode 100644 index 0000000..fa6d84e --- /dev/null +++ b/admin/helpers/html/index.html @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/admin/helpers/index.html b/admin/helpers/index.html new file mode 100644 index 0000000..fa6d84e --- /dev/null +++ b/admin/helpers/index.html @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/admin/index.html b/admin/index.html new file mode 100644 index 0000000..fa6d84e --- /dev/null +++ b/admin/index.html @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/admin/language/en-GB/en-GB.com_getbible.ini b/admin/language/en-GB/en-GB.com_getbible.ini new file mode 100644 index 0000000..62282c5 --- /dev/null +++ b/admin/language/en-GB/en-GB.com_getbible.ini @@ -0,0 +1,1853 @@ +COM_GETBIBLE="Get Bible" +COM_GETBIBLE_ACCESS_ALREADY_EXIST_BUT_COULD_NOT_BE_REACTIVATED="Access already exist, but could not be reactivated." +COM_GETBIBLE_ALL_IS_GOOD_PLEASE_CHECK_AGAIN_LATTER="All is good, please check again latter." +COM_GETBIBLE_ALL_TRANSLATIONS="All Translations" +COM_GETBIBLE_ARCHIVED="Archived" +COM_GETBIBLE_ARE_YOU_SURE_YOU_WANT_TO_DELETE_CONFIRMING_WILL_PERMANENTLY_DELETE_THE_SELECTED_ITEMS="Are you sure you want to delete? Confirming will permanently delete the selected item(s)!" +COM_GETBIBLE_AUTHOR="Author" +COM_GETBIBLE_BACK="Back" +COM_GETBIBLE_BETA_RELEASE="Beta Release" +COM_GETBIBLE_BOOK="Book" +COM_GETBIBLE_BOOKS="Books" +COM_GETBIBLE_BOOKS_ACCESS="Books Access" +COM_GETBIBLE_BOOKS_ACCESS_DESC="Allows the users in this group to access access books" +COM_GETBIBLE_BOOKS_BATCH_OPTIONS="Batch process the selected Books" +COM_GETBIBLE_BOOKS_BATCH_TIP="All changes will be applied to all selected Books" +COM_GETBIBLE_BOOKS_BATCH_USE="Books Batch Use" +COM_GETBIBLE_BOOKS_BATCH_USE_DESC="Allows users in this group to use batch copy/update method of batch books" +COM_GETBIBLE_BOOKS_CREATE="Books Create" +COM_GETBIBLE_BOOKS_CREATE_DESC="Allows the users in this group to create create books" +COM_GETBIBLE_BOOKS_DASHBOARD_LIST="Books Dashboard List" +COM_GETBIBLE_BOOKS_DASHBOARD_LIST_DESC="Allows the users in this group to dashboard list of book" +COM_GETBIBLE_BOOKS_DELETE="Books Delete" +COM_GETBIBLE_BOOKS_DELETE_DESC="Allows the users in this group to delete delete books" +COM_GETBIBLE_BOOKS_EDIT="Books Edit" +COM_GETBIBLE_BOOKS_EDIT_ABBREVIATION="Books Edit Abbreviation" +COM_GETBIBLE_BOOKS_EDIT_ABBREVIATION_DESC="Allows the users in this group to edit abbreviation of book" +COM_GETBIBLE_BOOKS_EDIT_CREATED_BY="Books Edit Created By" +COM_GETBIBLE_BOOKS_EDIT_CREATED_BY_DESC="Allows the users in this group to update the created by of the edit created by books" +COM_GETBIBLE_BOOKS_EDIT_CREATED_DATE="Books Edit Created Date" +COM_GETBIBLE_BOOKS_EDIT_CREATED_DATE_DESC="Allows the users in this group to update the created date of the edit created books" +COM_GETBIBLE_BOOKS_EDIT_DESC="Allows the users in this group to edit the book" +COM_GETBIBLE_BOOKS_EDIT_NAME="Books Edit Name" +COM_GETBIBLE_BOOKS_EDIT_NAME_DESC="Allows the users in this group to edit name of book" +COM_GETBIBLE_BOOKS_EDIT_NR="Books Edit Nr" +COM_GETBIBLE_BOOKS_EDIT_NR_DESC="Allows the users in this group to edit nr of book" +COM_GETBIBLE_BOOKS_EDIT_OWN="Books Edit Own" +COM_GETBIBLE_BOOKS_EDIT_OWN_DESC="Allows the users in this group to edit edit own books created by them" +COM_GETBIBLE_BOOKS_EDIT_SHA="Books Edit Sha" +COM_GETBIBLE_BOOKS_EDIT_SHA_DESC="Allows the users in this group to edit sha of book" +COM_GETBIBLE_BOOKS_EDIT_STATE="Books Edit State" +COM_GETBIBLE_BOOKS_EDIT_STATE_DESC="Allows the users in this group to update the state of the book" +COM_GETBIBLE_BOOKS_N_ITEMS_ARCHIVED="%s Books archived." +COM_GETBIBLE_BOOKS_N_ITEMS_ARCHIVED_1="%s Book archived." +COM_GETBIBLE_BOOKS_N_ITEMS_CHECKED_IN_0="No Book successfully checked in." +COM_GETBIBLE_BOOKS_N_ITEMS_CHECKED_IN_1="%d Book successfully checked in." +COM_GETBIBLE_BOOKS_N_ITEMS_CHECKED_IN_MORE="%d Books successfully checked in." +COM_GETBIBLE_BOOKS_N_ITEMS_DELETED="%s Books deleted." +COM_GETBIBLE_BOOKS_N_ITEMS_DELETED_1="%s Book deleted." +COM_GETBIBLE_BOOKS_N_ITEMS_FAILED_PUBLISHING="%s Books failed publishing." +COM_GETBIBLE_BOOKS_N_ITEMS_FAILED_PUBLISHING_1="%s Book failed publishing." +COM_GETBIBLE_BOOKS_N_ITEMS_FEATURED="%s Books featured." +COM_GETBIBLE_BOOKS_N_ITEMS_FEATURED_1="%s Book featured." +COM_GETBIBLE_BOOKS_N_ITEMS_PUBLISHED="%s Books published." +COM_GETBIBLE_BOOKS_N_ITEMS_PUBLISHED_1="%s Book published." +COM_GETBIBLE_BOOKS_N_ITEMS_TRASHED="%s Books trashed." +COM_GETBIBLE_BOOKS_N_ITEMS_TRASHED_1="%s Book trashed." +COM_GETBIBLE_BOOKS_N_ITEMS_UNFEATURED="%s Books unfeatured." +COM_GETBIBLE_BOOKS_N_ITEMS_UNFEATURED_1="%s Book unfeatured." +COM_GETBIBLE_BOOKS_N_ITEMS_UNPUBLISHED="%s Books unpublished." +COM_GETBIBLE_BOOKS_N_ITEMS_UNPUBLISHED_1="%s Book unpublished." +COM_GETBIBLE_BOOKS_SUBMENU="Books Submenu" +COM_GETBIBLE_BOOKS_SUBMENU_DESC="Allows the users in this group to submenu of book" +COM_GETBIBLE_BOOK_ABBREVIATION_DESCRIPTION="Select a Bible translation" +COM_GETBIBLE_BOOK_ABBREVIATION_LABEL="Translation" +COM_GETBIBLE_BOOK_CREATED_BY_DESC="The user that created this Book." +COM_GETBIBLE_BOOK_CREATED_BY_LABEL="Created By" +COM_GETBIBLE_BOOK_CREATED_DATE_DESC="The date this Book was created." +COM_GETBIBLE_BOOK_CREATED_DATE_LABEL="Created Date" +COM_GETBIBLE_BOOK_DETAILS="Details" +COM_GETBIBLE_BOOK_ERROR_UNIQUE_ALIAS="Another Book has the same alias." +COM_GETBIBLE_BOOK_ID="Id" +COM_GETBIBLE_BOOK_MODIFIED_BY_DESC="The last user that modified this Book." +COM_GETBIBLE_BOOK_MODIFIED_BY_LABEL="Modified By" +COM_GETBIBLE_BOOK_MODIFIED_DATE_DESC="The date this Book was modified." +COM_GETBIBLE_BOOK_MODIFIED_DATE_LABEL="Modified Date" +COM_GETBIBLE_BOOK_NAME_DESCRIPTION="Enter Name Here" +COM_GETBIBLE_BOOK_NAME_HINT="Name Here" +COM_GETBIBLE_BOOK_NAME_LABEL="Name" +COM_GETBIBLE_BOOK_NAME_MESSAGE="Error! Please add name here." +COM_GETBIBLE_BOOK_NR_DESCRIPTION="Select the book number" +COM_GETBIBLE_BOOK_NR_LABEL="Number" +COM_GETBIBLE_BOOK_ORDERING_LABEL="Ordering" +COM_GETBIBLE_BOOK_PERMISSION="Permissions" +COM_GETBIBLE_BOOK_PUBLISHING="Publishing" +COM_GETBIBLE_BOOK_READONLY="Book :: Readonly" +COM_GETBIBLE_BOOK_SAVE_WARNING="Alias already existed so a number was added at the end. You can re-edit the Book to customise the alias." +COM_GETBIBLE_BOOK_SHA_DESCRIPTION="Enter some checksum sha" +COM_GETBIBLE_BOOK_SHA_LABEL="Checksum" +COM_GETBIBLE_BOOK_SHA_MESSAGE="Error! Please add some checksum sha here." +COM_GETBIBLE_BOOK_STATUS="Status" +COM_GETBIBLE_BOOK_VERSION_DESC="A count of the number of times this Book has been revised." +COM_GETBIBLE_BOOK_VERSION_LABEL="Version" +COM_GETBIBLE_CHAPTER="Chapter" +COM_GETBIBLE_CHAPTERS="Chapters" +COM_GETBIBLE_CHAPTERS_ACCESS="Chapters Access" +COM_GETBIBLE_CHAPTERS_ACCESS_DESC="Allows the users in this group to access access chapters" +COM_GETBIBLE_CHAPTERS_BATCH_OPTIONS="Batch process the selected Chapters" +COM_GETBIBLE_CHAPTERS_BATCH_TIP="All changes will be applied to all selected Chapters" +COM_GETBIBLE_CHAPTERS_BATCH_USE="Chapters Batch Use" +COM_GETBIBLE_CHAPTERS_BATCH_USE_DESC="Allows users in this group to use batch copy/update method of batch chapters" +COM_GETBIBLE_CHAPTERS_CREATE="Chapters Create" +COM_GETBIBLE_CHAPTERS_CREATE_DESC="Allows the users in this group to create create chapters" +COM_GETBIBLE_CHAPTERS_DASHBOARD_LIST="Chapters Dashboard List" +COM_GETBIBLE_CHAPTERS_DASHBOARD_LIST_DESC="Allows the users in this group to dashboard list of chapter" +COM_GETBIBLE_CHAPTERS_DELETE="Chapters Delete" +COM_GETBIBLE_CHAPTERS_DELETE_DESC="Allows the users in this group to delete delete chapters" +COM_GETBIBLE_CHAPTERS_EDIT="Chapters Edit" +COM_GETBIBLE_CHAPTERS_EDIT_ABBREVIATION="Chapters Edit Abbreviation" +COM_GETBIBLE_CHAPTERS_EDIT_ABBREVIATION_DESC="Allows the users in this group to edit abbreviation of chapter" +COM_GETBIBLE_CHAPTERS_EDIT_BOOK_NR="Chapters Edit Book Nr" +COM_GETBIBLE_CHAPTERS_EDIT_BOOK_NR_DESC="Allows the users in this group to edit book nr of chapter" +COM_GETBIBLE_CHAPTERS_EDIT_CHAPTER="Chapters Edit Chapter" +COM_GETBIBLE_CHAPTERS_EDIT_CHAPTER_DESC="Allows the users in this group to edit chapter of chapter" +COM_GETBIBLE_CHAPTERS_EDIT_CREATED_BY="Chapters Edit Created By" +COM_GETBIBLE_CHAPTERS_EDIT_CREATED_BY_DESC="Allows the users in this group to update the created by of the edit created by chapters" +COM_GETBIBLE_CHAPTERS_EDIT_CREATED_DATE="Chapters Edit Created Date" +COM_GETBIBLE_CHAPTERS_EDIT_CREATED_DATE_DESC="Allows the users in this group to update the created date of the edit created chapters" +COM_GETBIBLE_CHAPTERS_EDIT_DESC="Allows the users in this group to edit the chapter" +COM_GETBIBLE_CHAPTERS_EDIT_NAME="Chapters Edit Name" +COM_GETBIBLE_CHAPTERS_EDIT_NAME_DESC="Allows the users in this group to edit name of chapter" +COM_GETBIBLE_CHAPTERS_EDIT_OWN="Chapters Edit Own" +COM_GETBIBLE_CHAPTERS_EDIT_OWN_DESC="Allows the users in this group to edit edit own chapters created by them" +COM_GETBIBLE_CHAPTERS_EDIT_SHA="Chapters Edit Sha" +COM_GETBIBLE_CHAPTERS_EDIT_SHA_DESC="Allows the users in this group to edit sha of chapter" +COM_GETBIBLE_CHAPTERS_EDIT_STATE="Chapters Edit State" +COM_GETBIBLE_CHAPTERS_EDIT_STATE_DESC="Allows the users in this group to update the state of the chapter" +COM_GETBIBLE_CHAPTERS_N_ITEMS_ARCHIVED="%s Chapters archived." +COM_GETBIBLE_CHAPTERS_N_ITEMS_ARCHIVED_1="%s Chapter archived." +COM_GETBIBLE_CHAPTERS_N_ITEMS_CHECKED_IN_0="No Chapter successfully checked in." +COM_GETBIBLE_CHAPTERS_N_ITEMS_CHECKED_IN_1="%d Chapter successfully checked in." +COM_GETBIBLE_CHAPTERS_N_ITEMS_CHECKED_IN_MORE="%d Chapters successfully checked in." +COM_GETBIBLE_CHAPTERS_N_ITEMS_DELETED="%s Chapters deleted." +COM_GETBIBLE_CHAPTERS_N_ITEMS_DELETED_1="%s Chapter deleted." +COM_GETBIBLE_CHAPTERS_N_ITEMS_FAILED_PUBLISHING="%s Chapters failed publishing." +COM_GETBIBLE_CHAPTERS_N_ITEMS_FAILED_PUBLISHING_1="%s Chapter failed publishing." +COM_GETBIBLE_CHAPTERS_N_ITEMS_FEATURED="%s Chapters featured." +COM_GETBIBLE_CHAPTERS_N_ITEMS_FEATURED_1="%s Chapter featured." +COM_GETBIBLE_CHAPTERS_N_ITEMS_PUBLISHED="%s Chapters published." +COM_GETBIBLE_CHAPTERS_N_ITEMS_PUBLISHED_1="%s Chapter published." +COM_GETBIBLE_CHAPTERS_N_ITEMS_TRASHED="%s Chapters trashed." +COM_GETBIBLE_CHAPTERS_N_ITEMS_TRASHED_1="%s Chapter trashed." +COM_GETBIBLE_CHAPTERS_N_ITEMS_UNFEATURED="%s Chapters unfeatured." +COM_GETBIBLE_CHAPTERS_N_ITEMS_UNFEATURED_1="%s Chapter unfeatured." +COM_GETBIBLE_CHAPTERS_N_ITEMS_UNPUBLISHED="%s Chapters unpublished." +COM_GETBIBLE_CHAPTERS_N_ITEMS_UNPUBLISHED_1="%s Chapter unpublished." +COM_GETBIBLE_CHAPTERS_SUBMENU="Chapters Submenu" +COM_GETBIBLE_CHAPTERS_SUBMENU_DESC="Allows the users in this group to submenu of chapter" +COM_GETBIBLE_CHAPTER_ABBREVIATION_DESCRIPTION="Select a Bible translation" +COM_GETBIBLE_CHAPTER_ABBREVIATION_LABEL="Translation" +COM_GETBIBLE_CHAPTER_BOOK_NR_DESCRIPTION="Select the book number" +COM_GETBIBLE_CHAPTER_BOOK_NR_LABEL="Book Number" +COM_GETBIBLE_CHAPTER_CHAPTER_DESCRIPTION="Select the chapter number" +COM_GETBIBLE_CHAPTER_CHAPTER_LABEL="Chapter" +COM_GETBIBLE_CHAPTER_CREATED_BY_DESC="The user that created this Chapter." +COM_GETBIBLE_CHAPTER_CREATED_BY_LABEL="Created By" +COM_GETBIBLE_CHAPTER_CREATED_DATE_DESC="The date this Chapter was created." +COM_GETBIBLE_CHAPTER_CREATED_DATE_LABEL="Created Date" +COM_GETBIBLE_CHAPTER_DETAILS="Details" +COM_GETBIBLE_CHAPTER_ERROR_UNIQUE_ALIAS="Another Chapter has the same alias." +COM_GETBIBLE_CHAPTER_ID="Id" +COM_GETBIBLE_CHAPTER_MODIFIED_BY_DESC="The last user that modified this Chapter." +COM_GETBIBLE_CHAPTER_MODIFIED_BY_LABEL="Modified By" +COM_GETBIBLE_CHAPTER_MODIFIED_DATE_DESC="The date this Chapter was modified." +COM_GETBIBLE_CHAPTER_MODIFIED_DATE_LABEL="Modified Date" +COM_GETBIBLE_CHAPTER_NAME_DESCRIPTION="Enter Name Here" +COM_GETBIBLE_CHAPTER_NAME_HINT="Name Here" +COM_GETBIBLE_CHAPTER_NAME_LABEL="Name" +COM_GETBIBLE_CHAPTER_NAME_MESSAGE="Error! Please add name here." +COM_GETBIBLE_CHAPTER_ORDERING_LABEL="Ordering" +COM_GETBIBLE_CHAPTER_PERMISSION="Permissions" +COM_GETBIBLE_CHAPTER_PUBLISHING="Publishing" +COM_GETBIBLE_CHAPTER_READONLY="Chapter :: Readonly" +COM_GETBIBLE_CHAPTER_SAVE_WARNING="Alias already existed so a number was added at the end. You can re-edit the Chapter to customise the alias." +COM_GETBIBLE_CHAPTER_SHA_DESCRIPTION="Enter some checksum sha" +COM_GETBIBLE_CHAPTER_SHA_LABEL="Checksum" +COM_GETBIBLE_CHAPTER_SHA_MESSAGE="Error! Please add some checksum sha here." +COM_GETBIBLE_CHAPTER_STATUS="Status" +COM_GETBIBLE_CHAPTER_VERSION_DESC="A count of the number of times this Chapter has been revised." +COM_GETBIBLE_CHAPTER_VERSION_LABEL="Version" +COM_GETBIBLE_CLOSE_NEW="Close & New" +COM_GETBIBLE_CONFIG_ABBREVIATION="Abbreviation" +COM_GETBIBLE_CONFIG_ACTIVATE_NOTES_DESCRIPTION="Activate the option to add notes on verses." +COM_GETBIBLE_CONFIG_ACTIVATE_NOTES_LABEL="Activate Notes" +COM_GETBIBLE_CONFIG_ACTIVATE_SEARCH_DESCRIPTION="Activate the option to search verses." +COM_GETBIBLE_CONFIG_ACTIVATE_SEARCH_LABEL="Activate Search" +COM_GETBIBLE_CONFIG_ACTIVATE_SHARING_DESCRIPTION="Activate the option to share verses." +COM_GETBIBLE_CONFIG_ACTIVATE_SHARING_LABEL="Activate Sharing" +COM_GETBIBLE_CONFIG_ACTIVATE_TAGS_DESCRIPTION="Activate the option to tag verses." +COM_GETBIBLE_CONFIG_ACTIVATE_TAGS_LABEL="Activate Tags" +COM_GETBIBLE_CONFIG_ACTIVE_SHARING_NOTE_DESCRIPTION="We cache the user selection, which means that these settings only form the default advance options for new visitors, or for those who clear their cache." +COM_GETBIBLE_CONFIG_ACTIVE_SHARING_NOTE_LABEL="Default Advance Options" +COM_GETBIBLE_CONFIG_ADD="Add" +COM_GETBIBLE_CONFIG_ALLOW_UNTAGGING_DESCRIPTION="Allow users to remove the system tags from verses for themselves (only)." +COM_GETBIBLE_CONFIG_ALLOW_UNTAGGING_LABEL="Allow Untagging" +COM_GETBIBLE_CONFIG_ALL_WORDS="All Words" +COM_GETBIBLE_CONFIG_ANY_WORDS="Any Words" +COM_GETBIBLE_CONFIG_APP="App" +COM_GETBIBLE_CONFIG_APP_MENU_DESCRIPTION="Select the menu item of the app page." +COM_GETBIBLE_CONFIG_APP_MENU_LABEL="Bible App Menu Item" +COM_GETBIBLE_CONFIG_ARRAY="array" +COM_GETBIBLE_CONFIG_AUTHOR="Author Info" +COM_GETBIBLE_CONFIG_AUTHOR_EMAIL_DESC="The email address of the author of this component." +COM_GETBIBLE_CONFIG_AUTHOR_EMAIL_LABEL="Author Email" +COM_GETBIBLE_CONFIG_AUTHOR_NAME_DESC="The name of the author of this component." +COM_GETBIBLE_CONFIG_AUTHOR_NAME_LABEL="Author Name" +COM_GETBIBLE_CONFIG_AUTO_LOAD="Auto" +COM_GETBIBLE_CONFIG_BOOKS_CARD_STYLE_LABEL="Books Card Style" +COM_GETBIBLE_CONFIG_BOOKS_ICON_DESCRIPTION="Set the books custom icon" +COM_GETBIBLE_CONFIG_BOOKS_ICON_HINT="album" +COM_GETBIBLE_CONFIG_BOOKS_ICON_LABEL="Books Icon" +COM_GETBIBLE_CONFIG_BOOKS_ICON_MESSAGE="Error! Please add some icon name here." +COM_GETBIBLE_CONFIG_BOOKS_TAB_DESCRIPTION="The books tab name" +COM_GETBIBLE_CONFIG_BOOKS_TAB_HINT="Books" +COM_GETBIBLE_CONFIG_BOOKS_TAB_LABEL="Books Tab" +COM_GETBIBLE_CONFIG_BOOKS_TAB_MESSAGE="Error! Please add some name here." +COM_GETBIBLE_CONFIG_BOTTOM="Bottom" +COM_GETBIBLE_CONFIG_BOTTOM_MENU_TYPE_LABEL="Bottom Menu Type" +COM_GETBIBLE_CONFIG_BREAK="break" +COM_GETBIBLE_CONFIG_CASE_INSENSITIVE="Case Insensitive" +COM_GETBIBLE_CONFIG_CASE_SENSITIVE="Case Sensitive" +COM_GETBIBLE_CONFIG_CHAPTERS_CARD_STYLE_LABEL="Chapters Card Style" +COM_GETBIBLE_CONFIG_CHAPTERS_ICON_DESCRIPTION="Set the chapters custom icon" +COM_GETBIBLE_CONFIG_CHAPTERS_ICON_HINT="grid" +COM_GETBIBLE_CONFIG_CHAPTERS_ICON_LABEL="Chapters Icon" +COM_GETBIBLE_CONFIG_CHAPTERS_ICON_MESSAGE="Error! Please add some icon name here." +COM_GETBIBLE_CONFIG_CHAPTERS_TAB_DESCRIPTION="The chapters tab name" +COM_GETBIBLE_CONFIG_CHAPTERS_TAB_HINT="Chapters" +COM_GETBIBLE_CONFIG_CHAPTERS_TAB_LABEL="Chapters Tab" +COM_GETBIBLE_CONFIG_CHAPTERS_TAB_MESSAGE="Error! Please add some name here." +COM_GETBIBLE_CONFIG_CHECK_TIMER_DESC="Set the intervals for the auto checkin fuction of tables that checks out the items to an user." +COM_GETBIBLE_CONFIG_CHECK_TIMER_LABEL="Check in timer" +COM_GETBIBLE_CONFIG_CHECK_TIMER_OPTION_FIVE="Once a week" +COM_GETBIBLE_CONFIG_CHECK_TIMER_OPTION_FOUR="Every second day" +COM_GETBIBLE_CONFIG_CHECK_TIMER_OPTION_ONE="Every five hours" +COM_GETBIBLE_CONFIG_CHECK_TIMER_OPTION_SIX="Never" +COM_GETBIBLE_CONFIG_CHECK_TIMER_OPTION_THREE="Once a day" +COM_GETBIBLE_CONFIG_CHECK_TIMER_OPTION_TWO="Every twelve hours" +COM_GETBIBLE_CONFIG_CLASS_HINT="Blank for none" +COM_GETBIBLE_CONFIG_CLASS_LABEL="Class" +COM_GETBIBLE_CONFIG_CLASS_MESSAGE="Error! Please add some Class here." +COM_GETBIBLE_CONFIG_CUSTOM_ICONS_DESCRIPTION="Use this option to set custom icons found at https://getuikit.com/docs/icon" +COM_GETBIBLE_CONFIG_CUSTOM_ICONS_LABEL="Set Custom Icons" +COM_GETBIBLE_CONFIG_CUSTOM_TABS_LABEL="Custom Tabs" +COM_GETBIBLE_CONFIG_DEBUG_DESCRIPTION="Show Debugging Information" +COM_GETBIBLE_CONFIG_DEBUG_LABEL="Debugging" +COM_GETBIBLE_CONFIG_DEFAULT="default" +COM_GETBIBLE_CONFIG_DEFAULT_FORMAT_SHARE_LABEL="Default Format Share" +COM_GETBIBLE_CONFIG_DETAILS_CARD_STYLE_LABEL="Details Card Style" +COM_GETBIBLE_CONFIG_DETAILS_ICON_DESCRIPTION="Set the details custom icon" +COM_GETBIBLE_CONFIG_DETAILS_ICON_HINT="info" +COM_GETBIBLE_CONFIG_DETAILS_ICON_LABEL="Details Icon" +COM_GETBIBLE_CONFIG_DETAILS_ICON_MESSAGE="Error! Please add some icon name here." +COM_GETBIBLE_CONFIG_DETAILS_TAB_DESCRIPTION="The details tab name" +COM_GETBIBLE_CONFIG_DETAILS_TAB_HINT="Details" +COM_GETBIBLE_CONFIG_DETAILS_TAB_LABEL="Details Tab" +COM_GETBIBLE_CONFIG_DETAILS_TAB_MESSAGE="Error! Please add some name here." +COM_GETBIBLE_CONFIG_DIV="div" +COM_GETBIBLE_CONFIG_DONT_LOAD="Not" +COM_GETBIBLE_CONFIG_ENABLE_OPEN_AI_DESCRIPTION="Enable Openai" +COM_GETBIBLE_CONFIG_ENABLE_OPEN_AI_LABEL="Enable Openai" +COM_GETBIBLE_CONFIG_ENABLE_OPEN_AI_ORG_DESCRIPTION="Enable Organisation Openai" +COM_GETBIBLE_CONFIG_ENABLE_OPEN_AI_ORG_LABEL="Enable Organisation Openai" +COM_GETBIBLE_CONFIG_EXACT_MATCH="Exact Match" +COM_GETBIBLE_CONFIG_EXACT_PHRASE="Exact Phrase" +COM_GETBIBLE_CONFIG_FORCE_LOAD="Force" +COM_GETBIBLE_CONFIG_GLOBAL_DESC="The Global Parameters" +COM_GETBIBLE_CONFIG_GLOBAL_LABEL="Global" +COM_GETBIBLE_CONFIG_GPT35TURBO="gpt-3.5-turbo" +COM_GETBIBLE_CONFIG_GPT35TURBO0613="gpt-3.5-turbo-0613" +COM_GETBIBLE_CONFIG_GPT35TURBO16K="gpt-3.5-turbo-16k" +COM_GETBIBLE_CONFIG_GPT35TURBO16K0613="gpt-3.5-turbo-16k-0613" +COM_GETBIBLE_CONFIG_GPT4="gpt-4" +COM_GETBIBLE_CONFIG_GPT40613="gpt-4-0613" +COM_GETBIBLE_CONFIG_GPT432K="gpt-4-32k" +COM_GETBIBLE_CONFIG_GPT432K0613="gpt-4-32k-0613" +COM_GETBIBLE_CONFIG_HIDE="Hide" +COM_GETBIBLE_CONFIG_HTML="HTML" +COM_GETBIBLE_CONFIG_JQUERY_LOAD="Load jQuery" +COM_GETBIBLE_CONFIG_JQUERY_LOAD_DESC="Would you like to load the Joomla jQuery Framework?" +COM_GETBIBLE_CONFIG_JQUERY_LOAD_LABEL="Load Joomla jQuery" +COM_GETBIBLE_CONFIG_JQUERY_REMOVE="Remove jQuery" +COM_GETBIBLE_CONFIG_LIST="list" +COM_GETBIBLE_CONFIG_LOCAL_LINK_SHARE_LABEL="Local Link Share" +COM_GETBIBLE_CONFIG_MARKDOWN="Markdown" +COM_GETBIBLE_CONFIG_NAME="Name" +COM_GETBIBLE_CONFIG_NAME_DESCRIPTION="Name" +COM_GETBIBLE_CONFIG_NAME_HINT="Tab Name" +COM_GETBIBLE_CONFIG_NAME_LABEL="Tab" +COM_GETBIBLE_CONFIG_NAME_MESSAGE="Error! Please add some name here." +COM_GETBIBLE_CONFIG_NO="No" +COM_GETBIBLE_CONFIG_NONE="None" +COM_GETBIBLE_CONFIG_NOTES="Notes" +COM_GETBIBLE_CONFIG_ONLY_EXTRA="Only Extra" +COM_GETBIBLE_CONFIG_OPENAI_DOCUMENTATION_NOTE_DESCRIPTION="

Please review the OpenAI API documentation for creating a chat conversation at this link. The document provides a comprehensive guide on parameters and methods to create chat completion using OpenAI's model. It includes instructions on:

  • How to post a request to create model responses
  • The format for the request body including role, model, messages, and optional parameters such as name, content, and function_call
  • Different ways to control the model's response such as temperature and top_p
  • How to control the number of generated chat completion choices, the stop sequences, and maximum number of tokens
  • Utilizing penalties and biases for managing the output
  • Additional features like streaming and user tracking for abuse monitoring
" +COM_GETBIBLE_CONFIG_OPENAI_DOCUMENTATION_NOTE_LABEL="Documentation" +COM_GETBIBLE_CONFIG_OPENAI_FREQUENCY_PENALTY_DESCRIPTION="Penalty for new tokens based on their frequency in the text" +COM_GETBIBLE_CONFIG_OPENAI_FREQUENCY_PENALTY_LABEL="Frequency Penalty" +COM_GETBIBLE_CONFIG_OPENAI_FREQUENCY_PENALTY_NOTE_DESCRIPTION="

The "frequency_penalty" is another optional parameter that defaults to 0. This is also a value between -2.0 and 2.0. Positive values penalize new tokens based on their existing frequency in the text so far, decreasing the model's likelihood to repeat the same line verbatim.

  • For example, a high frequency penalty discourages the model from excessively repeating the same words or phrases, encouraging it to produce more diverse and creative text.
" +COM_GETBIBLE_CONFIG_OPENAI_FREQUENCY_PENALTY_NOTE_LABEL="Frequency Penalty" +COM_GETBIBLE_CONFIG_OPENAI_MAX_TOKENS_DESCRIPTION="Maximum number of tokens to generate." +COM_GETBIBLE_CONFIG_OPENAI_MAX_TOKENS_LABEL="Max Tokens" +COM_GETBIBLE_CONFIG_OPENAI_MAX_TOKENS_NOTE_DESCRIPTION="

The "max_tokens" parameter sets the maximum number of tokens to generate in the chat completion. This is an optional parameter that defaults to infinity if not specified.

  • Note that the total length of both the input tokens and the generated tokens is limited by the model's context length. For instance, if a model has a context length of 100 tokens and you've used 20 tokens in your input, you could generate up to 80 additional tokens.
" +COM_GETBIBLE_CONFIG_OPENAI_MAX_TOKENS_NOTE_LABEL="Max Tokens" +COM_GETBIBLE_CONFIG_OPENAI_MODEL_DESCRIPTION="ID of the model to use." +COM_GETBIBLE_CONFIG_OPENAI_MODEL_LABEL="Model" +COM_GETBIBLE_CONFIG_OPENAI_N_DESCRIPTION="The number of chat completion choices to generate" +COM_GETBIBLE_CONFIG_OPENAI_N_LABEL="Number AI Response Per/Prompt" +COM_GETBIBLE_CONFIG_OPENAI_N_NOTE_DESCRIPTION="

The "n" parameter determines how many independent completions to generate for each input message. This can be used when you want multiple distinct responses for a single prompt.

  • Setting "n" to 3, for instance, would make the model generate 3 separate responses for each input message.
" +COM_GETBIBLE_CONFIG_OPENAI_N_NOTE_LABEL="Number AI Response Per/Prompt" +COM_GETBIBLE_CONFIG_OPENAI_ORG_TOKEN_DESCRIPTION="Your Organisation Token" +COM_GETBIBLE_CONFIG_OPENAI_ORG_TOKEN_HINT="// get your token from your Organisation on Open AI" +COM_GETBIBLE_CONFIG_OPENAI_ORG_TOKEN_LABEL="Openai Organisation Token" +COM_GETBIBLE_CONFIG_OPENAI_ORG_TOKEN_NOTE_DESCRIPTION="

How to Get an OpenAI Organization API Token

  1. Sign In to OpenAI: Visit OpenAI and click on the 'Sign In' button to access your account.
  2. Access the Organization Settings: Navigate to the organization settings page. This is typically accessible from your dashboard or account settings. Look for a section or tab labeled 'Organization' or 'Organization Settings.'
  3. Create a New Organization API Key: From the organization settings page, find the section for API keys. There should be an option to create a new API key. Click on this and follow the prompts to create your new organization API key.
  4. Copy the API Key: Once created, your new organization API key will be displayed. Make sure to copy and store this key securely. Just like personal API keys, you won't be able to view this key again for security reasons, so it's essential to save it somewhere safe.
  5. Use the Organization API Key: You can now use this organization API key to make requests to the OpenAI API on behalf of your organization. Include this key in the headers of your HTTP requests, just like you would with a personal API key.

Remember, organization API keys represent access to your entire organization's OpenAI account, so be especially careful with these. Don't share them publicly, and make sure only trusted individuals within your organization have access. If you believe an organization API key has been compromised, delete it and create a new one immediately.

" +COM_GETBIBLE_CONFIG_OPENAI_ORG_TOKEN_NOTE_LABEL="Get Open AI Organization Token" +COM_GETBIBLE_CONFIG_OPENAI_PRESENCE_PENALTY_DESCRIPTION="Penalty for new tokens based on whether they appear in the text" +COM_GETBIBLE_CONFIG_OPENAI_PRESENCE_PENALTY_LABEL="Presence Penalty" +COM_GETBIBLE_CONFIG_OPENAI_PRESENCE_PENALTY_NOTE_DESCRIPTION="

The "presence_penalty" is an optional parameter that defaults to 0. This is a value between -2.0 and 2.0. Positive values penalize new tokens based on whether they appear in the text so far, increasing the model's likelihood to talk about new topics.

  • For example, a high presence penalty encourages the model to generate text involving a wider variety of topics or themes, rather than focusing on a single topic or repeatedly using the same phrases.
" +COM_GETBIBLE_CONFIG_OPENAI_PRESENCE_PENALTY_NOTE_LABEL="Presence Penalty" +COM_GETBIBLE_CONFIG_OPENAI_TEMPERATURE_DESCRIPTION="The sampling temperature to use" +COM_GETBIBLE_CONFIG_OPENAI_TEMPERATURE_LABEL="Temperature" +COM_GETBIBLE_CONFIG_OPENAI_TEMPERATURE_NOTE_DESCRIPTION="

The "temperature" is a parameter that controls the randomness of the model's output. Its value ranges between 0 and 2. A higher temperature value results in more randomness, while a lower value results in less randomness. This affects the selection of the next word during text generation.

  • At a higher value like 2, the model has a greater probability of picking less likely words, which may lead to more diverse and creative outputs.
  • At a lower value like 0.2, the model's output becomes more deterministic, primarily choosing words with the highest predicted probabilities, leading to more focused and predictable responses.
" +COM_GETBIBLE_CONFIG_OPENAI_TEMPERATURE_NOTE_LABEL="Temperature" +COM_GETBIBLE_CONFIG_OPENAI_TOKEN_DESCRIPTION="Your Openai Token" +COM_GETBIBLE_CONFIG_OPENAI_TOKEN_HINT="// get your token from Open AI" +COM_GETBIBLE_CONFIG_OPENAI_TOKEN_LABEL="Openai Token" +COM_GETBIBLE_CONFIG_OPENAI_TOKEN_NOTE_DESCRIPTION="

How to Get an OpenAI API Token

  1. Sign Up on OpenAI: Visit OpenAI and click on the 'Sign Up' button to create a new account. You'll need to provide some basic information like your name and email address.
  2. Confirm your Email: After signing up, you'll receive an email from OpenAI to verify your email address. Click on the verification link to confirm your account.
  3. Access the Dashboard: Once your email is verified, log in to your OpenAI account and navigate to the Dashboard. You should see an option to create a new API key.
  4. Create a New API Key: Click on the 'Create New API Key' button. You'll be asked to name your API key and specify whether it has read and/or write access. Be sure to select the appropriate access level based on your needs.
  5. Copy your API Key: After creating the key, it will be displayed on your screen. Make sure to copy it and store it securely. You won't be able to view this key again for security reasons, so it's essential that you save it somewhere safe.
  6. Use your API Key: Now that you have your API key, you can use it to make requests to the OpenAI API. Typically, you will include this key in the headers of your HTTP requests.

Keep in mind that OpenAI's API has usage limits depending on your type of account (free, pay-as-you-go, etc.), so make sure you understand these limits to avoid unexpected charges or service interruptions. You can find information about usage limits on the OpenAI Pricing page.

Additionally, remember to keep your API key secure. Do not share it publicly or commit it to public repositories. If you believe your API key has been compromised, you can delete it and generate a new one from your OpenAI dashboard.

" +COM_GETBIBLE_CONFIG_OPENAI_TOKEN_NOTE_LABEL="Get Open AI Token" +COM_GETBIBLE_CONFIG_OPENAI_TOP_P_DESCRIPTION="The nucleus sampling parameter" +COM_GETBIBLE_CONFIG_OPENAI_TOP_P_LABEL="Top P" +COM_GETBIBLE_CONFIG_OPENAI_TOP_P_NOTE_DESCRIPTION="

The "top_p" parameter is used for "nucleus sampling," an alternative to the temperature-based sampling. It defines a threshold for the cumulative probability of the chosen tokens. Rather than considering all possible tokens for the next word, it only considers the smallest set of tokens whose cumulative probability exceeds the set "top_p" value.

  • Setting "top_p" to 0.1 means the model will only consider the tokens comprising the top 10% probability mass for the next word.
  • If "top_p" is set to 0.9, the model considers a wider range of tokens for the next word but still limits to those within the top 90% of the probability distribution.
" +COM_GETBIBLE_CONFIG_OPENAI_TOP_P_NOTE_LABEL="Top P" +COM_GETBIBLE_CONFIG_OPEN_AI="Open AI" +COM_GETBIBLE_CONFIG_PARAGRAPH="Paragraph" +COM_GETBIBLE_CONFIG_PARTIAL_MATCH="Partial Match" +COM_GETBIBLE_CONFIG_PER_LINE="Per Line" +COM_GETBIBLE_CONFIG_PLAIN_TEXT="Plain Text" +COM_GETBIBLE_CONFIG_POSITION_DESCRIPTION="Position" +COM_GETBIBLE_CONFIG_POSITION_HINT="ModulePosition" +COM_GETBIBLE_CONFIG_POSITION_LABEL="Module" +COM_GETBIBLE_CONFIG_POSITION_MESSAGE="Error! Please add some position name here." +COM_GETBIBLE_CONFIG_PREVIOUS_NEXT_NAVIGATION_DESCRIPTION="Show the previous and next navigation buttons" +COM_GETBIBLE_CONFIG_PREVIOUS_NEXT_NAVIGATION_LABEL="Show Previous and Next Navigation" +COM_GETBIBLE_CONFIG_PRIMARY="primary" +COM_GETBIBLE_CONFIG_REMOVE="Remove" +COM_GETBIBLE_CONFIG_SCRIPTURE_CARD_STYLE_LABEL="Scripture Card Style" +COM_GETBIBLE_CONFIG_SCRIPTURE_ICON_DESCRIPTION="Set the scripture custom icon" +COM_GETBIBLE_CONFIG_SCRIPTURE_ICON_HINT="heart" +COM_GETBIBLE_CONFIG_SCRIPTURE_ICON_LABEL="Scripture Icon" +COM_GETBIBLE_CONFIG_SCRIPTURE_ICON_MESSAGE="Error! Please add some icon name here." +COM_GETBIBLE_CONFIG_SCRIPTURE_TAB_DESCRIPTION="The scripture tab name" +COM_GETBIBLE_CONFIG_SCRIPTURE_TAB_HINT="Scripture" +COM_GETBIBLE_CONFIG_SCRIPTURE_TAB_LABEL="Scripture Tab" +COM_GETBIBLE_CONFIG_SCRIPTURE_TAB_MESSAGE="Error! Please add some name here." +COM_GETBIBLE_CONFIG_SEARCH="Search" +COM_GETBIBLE_CONFIG_SEARCH_CASE_DESCRIPTION="Search behaviour around each word case." +COM_GETBIBLE_CONFIG_SEARCH_CASE_LABEL="Case" +COM_GETBIBLE_CONFIG_SEARCH_FOUND_COLOR_DESCRIPTION="Select the search word found colour here." +COM_GETBIBLE_CONFIG_SEARCH_FOUND_COLOR_LABEL="Search Found Colour" +COM_GETBIBLE_CONFIG_SEARCH_MATCH_DESCRIPTION="Search behaviour around each word match." +COM_GETBIBLE_CONFIG_SEARCH_MATCH_LABEL="Match" +COM_GETBIBLE_CONFIG_SEARCH_WORDS_DESCRIPTION="Search behaviour around each word." +COM_GETBIBLE_CONFIG_SEARCH_WORDS_LABEL="Words" +COM_GETBIBLE_CONFIG_SECONDARY="secondary" +COM_GETBIBLE_CONFIG_SEPARATOR_LABEL="Separator" +COM_GETBIBLE_CONFIG_SETTINGS_CARD_STYLE_LABEL="Settings Card Style" +COM_GETBIBLE_CONFIG_SETTINGS_ICON_DESCRIPTION="Set the settings custom icon" +COM_GETBIBLE_CONFIG_SETTINGS_ICON_HINT="settings" +COM_GETBIBLE_CONFIG_SETTINGS_ICON_LABEL="Settings Icon" +COM_GETBIBLE_CONFIG_SETTINGS_ICON_MESSAGE="Error! Please add some icon name here." +COM_GETBIBLE_CONFIG_SETTINGS_TAB_DESCRIPTION="The settings tab name" +COM_GETBIBLE_CONFIG_SETTINGS_TAB_HINT="Settings" +COM_GETBIBLE_CONFIG_SETTINGS_TAB_LABEL="Settings Tab" +COM_GETBIBLE_CONFIG_SETTINGS_TAB_MESSAGE="Error! Please add some name here." +COM_GETBIBLE_CONFIG_SET_CUSTOM_TABS_DESCRIPTION="Set your own custom tabs" +COM_GETBIBLE_CONFIG_SET_CUSTOM_TABS_LABEL="Set Custom Tabs" +COM_GETBIBLE_CONFIG_SET_DEFAULT_TAB_NAMES_DESCRIPTION="Activate the option to set the default tab names." +COM_GETBIBLE_CONFIG_SET_DEFAULT_TAB_NAMES_LABEL="Set Default Tab Names" +COM_GETBIBLE_CONFIG_SHARE="Share" +COM_GETBIBLE_CONFIG_SHOW="Show" +COM_GETBIBLE_CONFIG_SHOW_API_LINK_DESCRIPTION="Show API link" +COM_GETBIBLE_CONFIG_SHOW_API_LINK_LABEL="API Link" +COM_GETBIBLE_CONFIG_SHOW_BOOKS_CARD_LABEL="Show Books Card" +COM_GETBIBLE_CONFIG_SHOW_BOOKS_ICON_LABEL="Show Books Icon" +COM_GETBIBLE_CONFIG_SHOW_BOOKS_TAB_TEXT_LABEL="Show Books Tab Text" +COM_GETBIBLE_CONFIG_SHOW_BOTTOM_MENU_LABEL="Show Bottom Menu" +COM_GETBIBLE_CONFIG_SHOW_CHAPTERS_CARD_LABEL="Show Chapters Card" +COM_GETBIBLE_CONFIG_SHOW_CHAPTERS_ICON_LABEL="Show Chapters Icon" +COM_GETBIBLE_CONFIG_SHOW_CHAPTERS_TAB_TEXT_LABEL="Show Chapters Tab Text" +COM_GETBIBLE_CONFIG_SHOW_DETAILS_CARD_LABEL="Show Details Card" +COM_GETBIBLE_CONFIG_SHOW_DETAILS_DESCRIPTION="Show the details tab" +COM_GETBIBLE_CONFIG_SHOW_DETAILS_ICON_LABEL="Show Details Icon" +COM_GETBIBLE_CONFIG_SHOW_DETAILS_LABEL="Show Details" +COM_GETBIBLE_CONFIG_SHOW_DETAILS_TAB_TEXT_LABEL="Show Details Tab Text" +COM_GETBIBLE_CONFIG_SHOW_GETBIBLE_LINK_DESCRIPTION="Show GetBible link" +COM_GETBIBLE_CONFIG_SHOW_GETBIBLE_LINK_LABEL="GetBible Link" +COM_GETBIBLE_CONFIG_SHOW_GETBIBLE_LOGO_DESCRIPTION="Show GetBible Logo" +COM_GETBIBLE_CONFIG_SHOW_GETBIBLE_LOGO_LABEL="GetBible Logo" +COM_GETBIBLE_CONFIG_SHOW_HASH_VALIDATION_DESCRIPTION="Show hash validation details" +COM_GETBIBLE_CONFIG_SHOW_HASH_VALIDATION_LABEL="Hash Validation" +COM_GETBIBLE_CONFIG_SHOW_HEADER_LABEL="Show Header" +COM_GETBIBLE_CONFIG_SHOW_INSTALL_BUTTON_DESCRIPTION="Show install translation button on the Bible app page. This is normally only needed during the setup of your application on your website the first time." +COM_GETBIBLE_CONFIG_SHOW_INSTALL_BUTTON_LABEL="Show Install Button" +COM_GETBIBLE_CONFIG_SHOW_SCRIPTURE_CARD_LABEL="Show Scripture Card" +COM_GETBIBLE_CONFIG_SHOW_SCRIPTURE_ICON_LABEL="Show Scripture Icon" +COM_GETBIBLE_CONFIG_SHOW_SCRIPTURE_TAB_TEXT_LABEL="Show Scripture Tab Text" +COM_GETBIBLE_CONFIG_SHOW_SETTINGS_CARD_LABEL="Show Settings Card" +COM_GETBIBLE_CONFIG_SHOW_SETTINGS_DESCRIPTION="Show the settings tab" +COM_GETBIBLE_CONFIG_SHOW_SETTINGS_ICON_LABEL="Show Settings Icon" +COM_GETBIBLE_CONFIG_SHOW_SETTINGS_LABEL="Show Settings" +COM_GETBIBLE_CONFIG_SHOW_SETTINGS_TAB_TEXT_LABEL="Show Settings Tab Text" +COM_GETBIBLE_CONFIG_SHOW_TOP_MENU_LABEL="Show Top Menu" +COM_GETBIBLE_CONFIG_SHOW_TRANSLATIONS_CARD_LABEL="Show Translations Card" +COM_GETBIBLE_CONFIG_SHOW_TRANSLATIONS_ICON_LABEL="Show Translations Icon" +COM_GETBIBLE_CONFIG_SHOW_TRANSLATIONS_TAB_TEXT_LABEL="Show Translations Tab Text" +COM_GETBIBLE_CONFIG_SUBNAVPILL="subnav-pill" +COM_GETBIBLE_CONFIG_TABLE_SELECTION_COLOR_DESCRIPTION="Select the table selection colour here." +COM_GETBIBLE_CONFIG_TABLE_SELECTION_COLOR_LABEL="Table Selection Colour" +COM_GETBIBLE_CONFIG_TABS="tabs" +COM_GETBIBLE_CONFIG_TAG="Tag" +COM_GETBIBLE_CONFIG_TEXT_REFERENCE_SHARE_LABEL="Text Reference Share" +COM_GETBIBLE_CONFIG_TOP="Top" +COM_GETBIBLE_CONFIG_TOP_MENU_TYPE_LABEL="Top Menu Type" +COM_GETBIBLE_CONFIG_TRANSLATIONS_CARD_STYLE_LABEL="Translations Card Style" +COM_GETBIBLE_CONFIG_TRANSLATIONS_ICON_DESCRIPTION="Set the translations custom icon" +COM_GETBIBLE_CONFIG_TRANSLATIONS_ICON_HINT="world" +COM_GETBIBLE_CONFIG_TRANSLATIONS_ICON_LABEL="Translations Icon" +COM_GETBIBLE_CONFIG_TRANSLATIONS_ICON_MESSAGE="Error! Please add some icon name here." +COM_GETBIBLE_CONFIG_TRANSLATIONS_TAB_DESCRIPTION="The translations tab name" +COM_GETBIBLE_CONFIG_TRANSLATIONS_TAB_HINT="Translations" +COM_GETBIBLE_CONFIG_TRANSLATIONS_TAB_LABEL="Translations Tab" +COM_GETBIBLE_CONFIG_TRANSLATIONS_TAB_MESSAGE="Error! Please add some name here." +COM_GETBIBLE_CONFIG_TYPE_TRANSLATION_SHARE_LABEL="Type Translation Share" +COM_GETBIBLE_CONFIG_UIKIT_DESC="The Parameters for the uikit are set here.
Uikit is a lightweight and modular front-end frameworkfor developing fast and powerful web interfaces. For more info visit https://getuikit.com/" +COM_GETBIBLE_CONFIG_UIKIT_LABEL="Uikit3 Settings" +COM_GETBIBLE_CONFIG_UIKIT_LOAD_DESC="Set the uikit loading option." +COM_GETBIBLE_CONFIG_UIKIT_LOAD_LABEL="Loading Options" +COM_GETBIBLE_CONFIG_UIKIT_MIN_DESC="Should the minified version of uikit files be loaded?" +COM_GETBIBLE_CONFIG_UIKIT_MIN_LABEL="Load Minified" +COM_GETBIBLE_CONFIG_VERSE_LAYOUT_SHARE_LABEL="Verse Layout Share" +COM_GETBIBLE_CONFIG_VERSE_NUMBER_SHARE_LABEL="Verse Number Share" +COM_GETBIBLE_CONFIG_VERSE_PER_LINE_DESCRIPTION="Load each Verse on its own line" +COM_GETBIBLE_CONFIG_VERSE_PER_LINE_LABEL="Verse Per Line" +COM_GETBIBLE_CONFIG_VERSE_SELECTED_COLOR_DESCRIPTION="Select the verse selected colour here." +COM_GETBIBLE_CONFIG_VERSE_SELECTED_COLOR_LABEL="Verse Selected Colour" +COM_GETBIBLE_CONFIG_YES="Yes" +COM_GETBIBLE_CONTRIBUTOR="Contributor" +COM_GETBIBLE_CONTRIBUTORS="Contributors" +COM_GETBIBLE_CREATE_NEW_S="Create New %s" +COM_GETBIBLE_DASH="Dashboard" +COM_GETBIBLE_DASHBOARD="Get Bible Dashboard" +COM_GETBIBLE_DASHBOARD_BOOKS="Books

" +COM_GETBIBLE_DASHBOARD_CHAPTERS="Chapters

" +COM_GETBIBLE_DASHBOARD_LINKERS="Linkers

" +COM_GETBIBLE_DASHBOARD_NOTES="Notes

" +COM_GETBIBLE_DASHBOARD_OPEN_AI_RESPONSES="Open Ai Responses

" +COM_GETBIBLE_DASHBOARD_PROMPTS="Prompts

" +COM_GETBIBLE_DASHBOARD_TAGGED_VERSES="Tagged Verses

" +COM_GETBIBLE_DASHBOARD_TAGS="Tags

" +COM_GETBIBLE_DASHBOARD_TRANSLATIONS="Translations

" +COM_GETBIBLE_DASHBOARD_VERSES="Verses

" +COM_GETBIBLE_DATE="Date" +COM_GETBIBLE_DOWNLOAD_UPDATE="Download Update" +COM_GETBIBLE_EDIT_CREATED_BY="Edit Created By" +COM_GETBIBLE_EDIT_CREATED_BY_DESC="Allows users in this group to edit created by." +COM_GETBIBLE_EDIT_CREATED_DATE="Edit Created Date" +COM_GETBIBLE_EDIT_CREATED_DATE_DESC="Allows users in this group to edit created date." +COM_GETBIBLE_EDIT_S="Edit %s" +COM_GETBIBLE_EDIT_VERSIONS="Edit Version" +COM_GETBIBLE_EDIT_VERSIONS_DESC="Allows users in this group to edit versions." +COM_GETBIBLE_EMPTY_TRASH="Empty trash" +COM_GETBIBLE_EXIT_TRASH="Exit trash" +COM_GETBIBLE_FAVOURITE_VERSE_COULD_NOT_BE_CHANGED="Favourite verse could not be changed." +COM_GETBIBLE_FAVOURITE_VERSE_COULD_NOT_BE_STORED="Favourite verse could not be stored." +COM_GETBIBLE_FAVOURITE_VERSE_SUCCESSFULLY_SET="Favourite verse successfully set." +COM_GETBIBLE_FILTER_ABBREVIATION_ASCENDING="Abbreviation ascending" +COM_GETBIBLE_FILTER_ABBREVIATION_DESCENDING="Abbreviation descending" +COM_GETBIBLE_FILTER_ACCESS_ASCENDING="Access ascending" +COM_GETBIBLE_FILTER_ACCESS_DESCENDING="Access descending" +COM_GETBIBLE_FILTER_BOOK_NUMBER_ASCENDING="Book Number ascending" +COM_GETBIBLE_FILTER_BOOK_NUMBER_DESCENDING="Book Number descending" +COM_GETBIBLE_FILTER_CACHE_BEHAVIOUR_ASCENDING="Cache Behaviour ascending" +COM_GETBIBLE_FILTER_CACHE_BEHAVIOUR_DESCENDING="Cache Behaviour descending" +COM_GETBIBLE_FILTER_CHAPTER_ASCENDING="Chapter ascending" +COM_GETBIBLE_FILTER_CHAPTER_DESCENDING="Chapter descending" +COM_GETBIBLE_FILTER_DIRECTIONAL_ASCENDING="Directional ascending" +COM_GETBIBLE_FILTER_DIRECTIONAL_DESCENDING="Directional descending" +COM_GETBIBLE_FILTER_LANGUAGE_ASCENDING="Language ascending" +COM_GETBIBLE_FILTER_LANGUAGE_DESCENDING="Language descending" +COM_GETBIBLE_FILTER_LINKER_ASCENDING="Linker ascending" +COM_GETBIBLE_FILTER_LINKER_DESCENDING="Linker descending" +COM_GETBIBLE_FILTER_MODEL_ASCENDING="Model ascending" +COM_GETBIBLE_FILTER_MODEL_DESCENDING="Model descending" +COM_GETBIBLE_FILTER_NAME_ASCENDING="Name ascending" +COM_GETBIBLE_FILTER_NAME_DESCENDING="Name descending" +COM_GETBIBLE_FILTER_NUMBER_ASCENDING="Number ascending" +COM_GETBIBLE_FILTER_NUMBER_DESCENDING="Number descending" +COM_GETBIBLE_FILTER_OPEN_AI_RESPONSE_ASCENDING="Open AI Response ascending" +COM_GETBIBLE_FILTER_OPEN_AI_RESPONSE_DESCENDING="Open AI Response descending" +COM_GETBIBLE_FILTER_PROMPT_ASCENDING="Prompt ascending" +COM_GETBIBLE_FILTER_PROMPT_DESCENDING="Prompt descending" +COM_GETBIBLE_FILTER_PROMPT_INTEGRATION_SCOPE_ASCENDING="Prompt Integration Scope ascending" +COM_GETBIBLE_FILTER_PROMPT_INTEGRATION_SCOPE_DESCENDING="Prompt Integration Scope descending" +COM_GETBIBLE_FILTER_PUBLISHED="Status" +COM_GETBIBLE_FILTER_PUBLISHED_BOOKS="Status options for books" +COM_GETBIBLE_FILTER_PUBLISHED_CHAPTERS="Status options for chapters" +COM_GETBIBLE_FILTER_PUBLISHED_LINKERS="Status options for linkers" +COM_GETBIBLE_FILTER_PUBLISHED_NOTES="Status options for notes" +COM_GETBIBLE_FILTER_PUBLISHED_OPEN_AI_MESSAGES="Status options for open ai messages" +COM_GETBIBLE_FILTER_PUBLISHED_OPEN_AI_RESPONSES="Status options for open ai responses" +COM_GETBIBLE_FILTER_PUBLISHED_PASSWORDS="Status options for passwords" +COM_GETBIBLE_FILTER_PUBLISHED_PROMPTS="Status options for prompts" +COM_GETBIBLE_FILTER_PUBLISHED_TAGGED_VERSES="Status options for tagged verses" +COM_GETBIBLE_FILTER_PUBLISHED_TAGS="Status options for tags" +COM_GETBIBLE_FILTER_PUBLISHED_TRANSLATIONS="Status options for translations" +COM_GETBIBLE_FILTER_PUBLISHED_VERSES="Status options for verses" +COM_GETBIBLE_FILTER_RESPONSE_ID_ASCENDING="Response ID ascending" +COM_GETBIBLE_FILTER_RESPONSE_ID_DESCENDING="Response ID descending" +COM_GETBIBLE_FILTER_RESPONSE_MODEL_ASCENDING="Response model ascending" +COM_GETBIBLE_FILTER_RESPONSE_MODEL_DESCENDING="Response model descending" +COM_GETBIBLE_FILTER_RESPONSE_OBJECT_ENDPOINT_ASCENDING="Response object (end-point) ascending" +COM_GETBIBLE_FILTER_RESPONSE_OBJECT_ENDPOINT_DESCENDING="Response object (end-point) descending" +COM_GETBIBLE_FILTER_ROLE_ASCENDING="Role ascending" +COM_GETBIBLE_FILTER_ROLE_DESCENDING="Role descending" +COM_GETBIBLE_FILTER_SEARCH="Searchlinkers" +COM_GETBIBLE_FILTER_SEARCH_BOOKS="Search the book items. Prefix with ID: to search for an item by ID." +COM_GETBIBLE_FILTER_SEARCH_CHAPTERS="Search the chapter items. Prefix with ID: to search for an item by ID." +COM_GETBIBLE_FILTER_SEARCH_LINKERS="Search the linker items. Prefix with ID: to search for an item by ID." +COM_GETBIBLE_FILTER_SEARCH_NOTES="Search the note items. Prefix with ID: to search for an item by ID." +COM_GETBIBLE_FILTER_SEARCH_OPEN_AI_MESSAGES="Search the open ai message items. Prefix with ID: to search for an item by ID." +COM_GETBIBLE_FILTER_SEARCH_OPEN_AI_RESPONSES="Search the open ai response items. Prefix with ID: to search for an item by ID." +COM_GETBIBLE_FILTER_SEARCH_PASSWORDS="Search the password items. Prefix with ID: to search for an item by ID." +COM_GETBIBLE_FILTER_SEARCH_PROMPTS="Search the prompt items. Prefix with ID: to search for an item by ID." +COM_GETBIBLE_FILTER_SEARCH_TAGGED_VERSES="Search the tagged verse items. Prefix with ID: to search for an item by ID." +COM_GETBIBLE_FILTER_SEARCH_TAGS="Search the tag items. Prefix with ID: to search for an item by ID." +COM_GETBIBLE_FILTER_SEARCH_TRANSLATIONS="Search the translation items. Prefix with ID: to search for an item by ID." +COM_GETBIBLE_FILTER_SEARCH_VERSES="Search the verse items. Prefix with ID: to search for an item by ID." +COM_GETBIBLE_FILTER_SELECT_ACCESS="Select Access" +COM_GETBIBLE_FILTER_SELECT_BOOK_NUMBER="Select Book Number" +COM_GETBIBLE_FILTER_SELECT_CACHE_BEHAVIOUR="Select Cache Behaviour" +COM_GETBIBLE_FILTER_SELECT_CHAPTER="Select Chapter" +COM_GETBIBLE_FILTER_SELECT_DIRECTIONAL="Select Directional" +COM_GETBIBLE_FILTER_SELECT_LINKER="Select Linker" +COM_GETBIBLE_FILTER_SELECT_MODEL="Select Model" +COM_GETBIBLE_FILTER_SELECT_NAME="Select Name" +COM_GETBIBLE_FILTER_SELECT_NUMBER="Select Number" +COM_GETBIBLE_FILTER_SELECT_OPEN_AI_RESPONSE="Select Open AI Response" +COM_GETBIBLE_FILTER_SELECT_PROMPT="Select Prompt" +COM_GETBIBLE_FILTER_SELECT_RESPONSE_ID="Select Response ID" +COM_GETBIBLE_FILTER_SELECT_RESPONSE_MODEL="Select Response model" +COM_GETBIBLE_FILTER_SELECT_ROLE="Select Role" +COM_GETBIBLE_FILTER_SELECT_SOURCE="Select Source" +COM_GETBIBLE_FILTER_SELECT_TAG="Select Tag" +COM_GETBIBLE_FILTER_SELECT_TARGET_TRANSLATION="Select Target Translation" +COM_GETBIBLE_FILTER_SELECT_TRANSLATION="Select Translation" +COM_GETBIBLE_FILTER_SELECT_VERSE="Select Verse" +COM_GETBIBLE_FILTER_SOURCE_ASCENDING="Source ascending" +COM_GETBIBLE_FILTER_SOURCE_DESCENDING="Source descending" +COM_GETBIBLE_FILTER_TAG_ASCENDING="Tag ascending" +COM_GETBIBLE_FILTER_TAG_DESCENDING="Tag descending" +COM_GETBIBLE_FILTER_TOTAL_TOKENS_ASCENDING="Total Tokens ascending" +COM_GETBIBLE_FILTER_TOTAL_TOKENS_DESCENDING="Total Tokens descending" +COM_GETBIBLE_FILTER_TRANSLATION_ASCENDING="Translation ascending" +COM_GETBIBLE_FILTER_TRANSLATION_DESCENDING="Translation descending" +COM_GETBIBLE_FILTER_VERSE_ASCENDING="Verse ascending" +COM_GETBIBLE_FILTER_VERSE_DESCENDING="Verse descending" +COM_GETBIBLE_GET_TOKEN="Get Token" +COM_GETBIBLE_GET_TOKEN_FROM_VDM_TO_GET_UPDATE_NOTICE_AND_ADD_IT_TO_YOUR_GLOBAL_OPTIONS="Get token from VDM to get update notice, and add it to your global options." +COM_GETBIBLE_HELP_MANAGER="Help" +COM_GETBIBLE_HTWOCURL_NOT_FOUNDHTWOPPLEASE_SETUP_CURL_ON_YOUR_SYSTEM_OR_BGETBIBLEB_WILL_NOT_FUNCTION_CORRECTLYP="

Curl Not Found!

Please setup curl on your system, or getbible will not function correctly!

" +COM_GETBIBLE_INACTIVE="Inactive" +COM_GETBIBLE_INCORRECT_FAVOURITE_VERSE_SELECTED="Incorrect favourite verse selected." +COM_GETBIBLE_INVALID_SESSION_KEY_VALUE="Invalid session key value." +COM_GETBIBLE_KEEP_ORIGINAL_ACCESS="- Keep Original Access -" +COM_GETBIBLE_KEEP_ORIGINAL_CATEGORY="- Keep Original Category -" +COM_GETBIBLE_KEEP_ORIGINAL_STATE="- Keep Original State -" +COM_GETBIBLE_LICENSE="License" +COM_GETBIBLE_LINKER="Linker" +COM_GETBIBLE_LINKERS="Linkers" +COM_GETBIBLE_LINKERS_ACCESS="Linkers Access" +COM_GETBIBLE_LINKERS_ACCESS_DESC="Allows the users in this group to access access linkers" +COM_GETBIBLE_LINKERS_BATCH_OPTIONS="Batch process the selected Linkers" +COM_GETBIBLE_LINKERS_BATCH_TIP="All changes will be applied to all selected Linkers" +COM_GETBIBLE_LINKERS_BATCH_USE="Linkers Batch Use" +COM_GETBIBLE_LINKERS_BATCH_USE_DESC="Allows users in this group to use batch copy/update method of batch linkers" +COM_GETBIBLE_LINKERS_CREATE="Linkers Create" +COM_GETBIBLE_LINKERS_CREATE_DESC="Allows the users in this group to create create linkers" +COM_GETBIBLE_LINKERS_DASHBOARD_LIST="Linkers Dashboard List" +COM_GETBIBLE_LINKERS_DASHBOARD_LIST_DESC="Allows the users in this group to dashboard list of linker" +COM_GETBIBLE_LINKERS_DELETE="Linkers Delete" +COM_GETBIBLE_LINKERS_DELETE_DESC="Allows the users in this group to delete delete linkers" +COM_GETBIBLE_LINKERS_EDIT="Linkers Edit" +COM_GETBIBLE_LINKERS_EDIT_CREATED_BY="Linkers Edit Created By" +COM_GETBIBLE_LINKERS_EDIT_CREATED_BY_DESC="Allows the users in this group to update the created by of the edit created by linkers" +COM_GETBIBLE_LINKERS_EDIT_CREATED_DATE="Linkers Edit Created Date" +COM_GETBIBLE_LINKERS_EDIT_CREATED_DATE_DESC="Allows the users in this group to update the created date of the edit created linkers" +COM_GETBIBLE_LINKERS_EDIT_DESC="Allows the users in this group to edit the linker" +COM_GETBIBLE_LINKERS_EDIT_GUID="Linkers Edit Guid" +COM_GETBIBLE_LINKERS_EDIT_GUID_DESC="Allows the users in this group to edit guid of linker" +COM_GETBIBLE_LINKERS_EDIT_NAME="Linkers Edit Name" +COM_GETBIBLE_LINKERS_EDIT_NAME_DESC="Allows the users in this group to edit name of linker" +COM_GETBIBLE_LINKERS_EDIT_OWN="Linkers Edit Own" +COM_GETBIBLE_LINKERS_EDIT_OWN_DESC="Allows the users in this group to edit edit own linkers created by them" +COM_GETBIBLE_LINKERS_EDIT_STATE="Linkers Edit State" +COM_GETBIBLE_LINKERS_EDIT_STATE_DESC="Allows the users in this group to update the state of the linker" +COM_GETBIBLE_LINKERS_N_ITEMS_ARCHIVED="%s Linkers archived." +COM_GETBIBLE_LINKERS_N_ITEMS_ARCHIVED_1="%s Linker archived." +COM_GETBIBLE_LINKERS_N_ITEMS_CHECKED_IN_0="No Linker successfully checked in." +COM_GETBIBLE_LINKERS_N_ITEMS_CHECKED_IN_1="%d Linker successfully checked in." +COM_GETBIBLE_LINKERS_N_ITEMS_CHECKED_IN_MORE="%d Linkers successfully checked in." +COM_GETBIBLE_LINKERS_N_ITEMS_DELETED="%s Linkers deleted." +COM_GETBIBLE_LINKERS_N_ITEMS_DELETED_1="%s Linker deleted." +COM_GETBIBLE_LINKERS_N_ITEMS_FAILED_PUBLISHING="%s Linkers failed publishing." +COM_GETBIBLE_LINKERS_N_ITEMS_FAILED_PUBLISHING_1="%s Linker failed publishing." +COM_GETBIBLE_LINKERS_N_ITEMS_FEATURED="%s Linkers featured." +COM_GETBIBLE_LINKERS_N_ITEMS_FEATURED_1="%s Linker featured." +COM_GETBIBLE_LINKERS_N_ITEMS_PUBLISHED="%s Linkers published." +COM_GETBIBLE_LINKERS_N_ITEMS_PUBLISHED_1="%s Linker published." +COM_GETBIBLE_LINKERS_N_ITEMS_TRASHED="%s Linkers trashed." +COM_GETBIBLE_LINKERS_N_ITEMS_TRASHED_1="%s Linker trashed." +COM_GETBIBLE_LINKERS_N_ITEMS_UNFEATURED="%s Linkers unfeatured." +COM_GETBIBLE_LINKERS_N_ITEMS_UNFEATURED_1="%s Linker unfeatured." +COM_GETBIBLE_LINKERS_N_ITEMS_UNPUBLISHED="%s Linkers unpublished." +COM_GETBIBLE_LINKERS_N_ITEMS_UNPUBLISHED_1="%s Linker unpublished." +COM_GETBIBLE_LINKERS_SUBMENU="Linkers Submenu" +COM_GETBIBLE_LINKERS_SUBMENU_DESC="Allows the users in this group to submenu of linker" +COM_GETBIBLE_LINKER_CREATED_BY_DESC="The user that created this Linker." +COM_GETBIBLE_LINKER_CREATED_BY_LABEL="Created By" +COM_GETBIBLE_LINKER_CREATED_DATE_DESC="The date this Linker was created." +COM_GETBIBLE_LINKER_CREATED_DATE_LABEL="Created Date" +COM_GETBIBLE_LINKER_DETAILS="Details" +COM_GETBIBLE_LINKER_EDIT="Editing the Linker" +COM_GETBIBLE_LINKER_ERROR_UNIQUE_ALIAS="Another Linker has the same alias." +COM_GETBIBLE_LINKER_GUID_DESCRIPTION="Globally Unique Identifier" +COM_GETBIBLE_LINKER_GUID_HINT="Auto Generated" +COM_GETBIBLE_LINKER_GUID_LABEL="GUID" +COM_GETBIBLE_LINKER_ID="Id" +COM_GETBIBLE_LINKER_MODIFIED_BY_DESC="The last user that modified this Linker." +COM_GETBIBLE_LINKER_MODIFIED_BY_LABEL="Modified By" +COM_GETBIBLE_LINKER_MODIFIED_DATE_DESC="The date this Linker was modified." +COM_GETBIBLE_LINKER_MODIFIED_DATE_LABEL="Modified Date" +COM_GETBIBLE_LINKER_NAME_HINT="Name Here" +COM_GETBIBLE_LINKER_NAME_LABEL="Name" +COM_GETBIBLE_LINKER_NAME_MESSAGE="Error! Please add name here." +COM_GETBIBLE_LINKER_NEW="A New Linker" +COM_GETBIBLE_LINKER_NOTES="Notes" +COM_GETBIBLE_LINKER_ORDERING_LABEL="Ordering" +COM_GETBIBLE_LINKER_PASSWORDS="Passwords" +COM_GETBIBLE_LINKER_PERMISSION="Permissions" +COM_GETBIBLE_LINKER_PUBLISHING="Publishing" +COM_GETBIBLE_LINKER_SAVE_WARNING="Alias already existed so a number was added at the end. You can re-edit the Linker to customise the alias." +COM_GETBIBLE_LINKER_STATUS="Status" +COM_GETBIBLE_LINKER_TAGS="Tags" +COM_GETBIBLE_LINKER_VERSION_DESC="A count of the number of times this Linker has been revised." +COM_GETBIBLE_LINKER_VERSION_LABEL="Version" +COM_GETBIBLE_NEW="New" +COM_GETBIBLE_NOTE="Note" +COM_GETBIBLE_NOTES="Notes" +COM_GETBIBLE_NOTES_ACCESS="Notes Access" +COM_GETBIBLE_NOTES_ACCESS_DESC="Allows the users in this group to access access notes" +COM_GETBIBLE_NOTES_BATCH_OPTIONS="Batch process the selected Notes" +COM_GETBIBLE_NOTES_BATCH_TIP="All changes will be applied to all selected Notes" +COM_GETBIBLE_NOTES_BATCH_USE="Notes Batch Use" +COM_GETBIBLE_NOTES_BATCH_USE_DESC="Allows users in this group to use batch copy/update method of batch notes" +COM_GETBIBLE_NOTES_CREATE="Notes Create" +COM_GETBIBLE_NOTES_CREATE_DESC="Allows the users in this group to create create notes" +COM_GETBIBLE_NOTES_DASHBOARD_LIST="Notes Dashboard List" +COM_GETBIBLE_NOTES_DASHBOARD_LIST_DESC="Allows the users in this group to dashboard list of note" +COM_GETBIBLE_NOTES_DELETE="Notes Delete" +COM_GETBIBLE_NOTES_DELETE_DESC="Allows the users in this group to delete delete notes" +COM_GETBIBLE_NOTES_EDIT="Notes Edit" +COM_GETBIBLE_NOTES_EDIT_ACCESS="Notes Edit Access" +COM_GETBIBLE_NOTES_EDIT_ACCESS_DESC="Allows the users in this group to change the access of the edit access notes" +COM_GETBIBLE_NOTES_EDIT_BOOK_NR="Notes Edit Book Nr" +COM_GETBIBLE_NOTES_EDIT_BOOK_NR_DESC="Allows the users in this group to edit book nr of note" +COM_GETBIBLE_NOTES_EDIT_CHAPTER="Notes Edit Chapter" +COM_GETBIBLE_NOTES_EDIT_CHAPTER_DESC="Allows the users in this group to edit chapter of note" +COM_GETBIBLE_NOTES_EDIT_CREATED_BY="Notes Edit Created By" +COM_GETBIBLE_NOTES_EDIT_CREATED_BY_DESC="Allows the users in this group to update the created by of the edit created by notes" +COM_GETBIBLE_NOTES_EDIT_CREATED_DATE="Notes Edit Created Date" +COM_GETBIBLE_NOTES_EDIT_CREATED_DATE_DESC="Allows the users in this group to update the created date of the edit created notes" +COM_GETBIBLE_NOTES_EDIT_DESC="Allows the users in this group to edit the note" +COM_GETBIBLE_NOTES_EDIT_GUID="Notes Edit Guid" +COM_GETBIBLE_NOTES_EDIT_GUID_DESC="Allows the users in this group to edit guid of note" +COM_GETBIBLE_NOTES_EDIT_LINKER="Notes Edit Linker" +COM_GETBIBLE_NOTES_EDIT_LINKER_DESC="Allows the users in this group to edit linker of note" +COM_GETBIBLE_NOTES_EDIT_NOTE="Notes Edit Note" +COM_GETBIBLE_NOTES_EDIT_NOTE_DESC="Allows the users in this group to edit note of note" +COM_GETBIBLE_NOTES_EDIT_OWN="Notes Edit Own" +COM_GETBIBLE_NOTES_EDIT_OWN_DESC="Allows the users in this group to edit edit own notes created by them" +COM_GETBIBLE_NOTES_EDIT_STATE="Notes Edit State" +COM_GETBIBLE_NOTES_EDIT_STATE_DESC="Allows the users in this group to update the state of the note" +COM_GETBIBLE_NOTES_EDIT_VERSE="Notes Edit Verse" +COM_GETBIBLE_NOTES_EDIT_VERSE_DESC="Allows the users in this group to edit verse of note" +COM_GETBIBLE_NOTES_EDIT_VERSION="Notes Edit Version" +COM_GETBIBLE_NOTES_EDIT_VERSION_DESC="Allows users in this group to edit versions of version notes" +COM_GETBIBLE_NOTES_N_ITEMS_ARCHIVED="%s Notes archived." +COM_GETBIBLE_NOTES_N_ITEMS_ARCHIVED_1="%s Note archived." +COM_GETBIBLE_NOTES_N_ITEMS_CHECKED_IN_0="No Note successfully checked in." +COM_GETBIBLE_NOTES_N_ITEMS_CHECKED_IN_1="%d Note successfully checked in." +COM_GETBIBLE_NOTES_N_ITEMS_CHECKED_IN_MORE="%d Notes successfully checked in." +COM_GETBIBLE_NOTES_N_ITEMS_DELETED="%s Notes deleted." +COM_GETBIBLE_NOTES_N_ITEMS_DELETED_1="%s Note deleted." +COM_GETBIBLE_NOTES_N_ITEMS_FAILED_PUBLISHING="%s Notes failed publishing." +COM_GETBIBLE_NOTES_N_ITEMS_FAILED_PUBLISHING_1="%s Note failed publishing." +COM_GETBIBLE_NOTES_N_ITEMS_FEATURED="%s Notes featured." +COM_GETBIBLE_NOTES_N_ITEMS_FEATURED_1="%s Note featured." +COM_GETBIBLE_NOTES_N_ITEMS_PUBLISHED="%s Notes published." +COM_GETBIBLE_NOTES_N_ITEMS_PUBLISHED_1="%s Note published." +COM_GETBIBLE_NOTES_N_ITEMS_TRASHED="%s Notes trashed." +COM_GETBIBLE_NOTES_N_ITEMS_TRASHED_1="%s Note trashed." +COM_GETBIBLE_NOTES_N_ITEMS_UNFEATURED="%s Notes unfeatured." +COM_GETBIBLE_NOTES_N_ITEMS_UNFEATURED_1="%s Note unfeatured." +COM_GETBIBLE_NOTES_N_ITEMS_UNPUBLISHED="%s Notes unpublished." +COM_GETBIBLE_NOTES_N_ITEMS_UNPUBLISHED_1="%s Note unpublished." +COM_GETBIBLE_NOTES_SUBMENU="Notes Submenu" +COM_GETBIBLE_NOTES_SUBMENU_DESC="Allows the users in this group to submenu of note" +COM_GETBIBLE_NOTE_ACCESS_LABEL="Access" +COM_GETBIBLE_NOTE_ALREADY_EXIST_BUT_COULD_NOT_BE_REACTIVATED="Note already exist, but could not be reactivated." +COM_GETBIBLE_NOTE_ALREADY_EXIST_BUT_COULD_NOT_UPDATE_THE_NOTE_TEXT="Note already exist, but could not update the note text." +COM_GETBIBLE_NOTE_BOOK_NR_DESCRIPTION="Select the book number" +COM_GETBIBLE_NOTE_BOOK_NR_LABEL="Book Number" +COM_GETBIBLE_NOTE_CHAPTER_DESCRIPTION="Select the chapter number" +COM_GETBIBLE_NOTE_CHAPTER_LABEL="Chapter" +COM_GETBIBLE_NOTE_CREATED_BY_DESC="The user that created this Note." +COM_GETBIBLE_NOTE_CREATED_BY_LABEL="Created By" +COM_GETBIBLE_NOTE_CREATED_DATE_DESC="The date this Note was created." +COM_GETBIBLE_NOTE_CREATED_DATE_LABEL="Created Date" +COM_GETBIBLE_NOTE_DETAILS="Details" +COM_GETBIBLE_NOTE_EDIT="Editing the Note" +COM_GETBIBLE_NOTE_ERROR_UNIQUE_ALIAS="Another Note has the same alias." +COM_GETBIBLE_NOTE_GUID_DESCRIPTION="Globally Unique Identifier" +COM_GETBIBLE_NOTE_GUID_HINT="Auto Generated" +COM_GETBIBLE_NOTE_GUID_LABEL="GUID" +COM_GETBIBLE_NOTE_ID="Id" +COM_GETBIBLE_NOTE_LINKER_DESCRIPTION="Globally Unique Linker" +COM_GETBIBLE_NOTE_LINKER_LABEL="Linker" +COM_GETBIBLE_NOTE_MODIFIED_BY_DESC="The last user that modified this Note." +COM_GETBIBLE_NOTE_MODIFIED_BY_LABEL="Modified By" +COM_GETBIBLE_NOTE_MODIFIED_DATE_DESC="The date this Note was modified." +COM_GETBIBLE_NOTE_MODIFIED_DATE_LABEL="Modified Date" +COM_GETBIBLE_NOTE_NEW="A New Note" +COM_GETBIBLE_NOTE_NOTE_DESCRIPTION="Text Area" +COM_GETBIBLE_NOTE_NOTE_HINT="add note here" +COM_GETBIBLE_NOTE_NOTE_LABEL="Text" +COM_GETBIBLE_NOTE_ORDERING_LABEL="Ordering" +COM_GETBIBLE_NOTE_PERMISSION="Permissions" +COM_GETBIBLE_NOTE_PRIVATE="Private" +COM_GETBIBLE_NOTE_PUBLIC="Public" +COM_GETBIBLE_NOTE_PUBLISHING="Publishing" +COM_GETBIBLE_NOTE_SAVE_WARNING="Alias already existed so a number was added at the end. You can re-edit the Note to customise the alias." +COM_GETBIBLE_NOTE_STATUS="Status" +COM_GETBIBLE_NOTE_VERSE_DESCRIPTION="Select the verse number" +COM_GETBIBLE_NOTE_VERSE_LABEL="Verse" +COM_GETBIBLE_NOTE_VERSION_DESC="A count of the number of times this Note has been revised." +COM_GETBIBLE_NOTE_VERSION_LABEL="Version" +COM_GETBIBLE_NOT_FOUND_OR_ACCESS_DENIED="Not found, or access denied." +COM_GETBIBLE_NO_ACCESS_GRANTED="No Access Granted!" +COM_GETBIBLE_OPEN_AI_DISABLED="Open AI (disabled)" +COM_GETBIBLE_OPEN_AI_MESSAGE="Open AI Message" +COM_GETBIBLE_OPEN_AI_MESSAGES="Open AI Messages" +COM_GETBIBLE_OPEN_AI_MESSAGES_ACCESS="Open Ai Messages Access" +COM_GETBIBLE_OPEN_AI_MESSAGES_ACCESS_DESC="Allows the users in this group to access access open ai messages" +COM_GETBIBLE_OPEN_AI_MESSAGES_BATCH_OPTIONS="Batch process the selected Open AI Messages" +COM_GETBIBLE_OPEN_AI_MESSAGES_BATCH_TIP="All changes will be applied to all selected Open AI Messages" +COM_GETBIBLE_OPEN_AI_MESSAGES_BATCH_USE="Open Ai Messages Batch Use" +COM_GETBIBLE_OPEN_AI_MESSAGES_BATCH_USE_DESC="Allows users in this group to use batch copy/update method of batch open ai messages" +COM_GETBIBLE_OPEN_AI_MESSAGES_CREATE="Open Ai Messages Create" +COM_GETBIBLE_OPEN_AI_MESSAGES_CREATE_DESC="Allows the users in this group to create create open ai messages" +COM_GETBIBLE_OPEN_AI_MESSAGES_DELETE="Open Ai Messages Delete" +COM_GETBIBLE_OPEN_AI_MESSAGES_DELETE_DESC="Allows the users in this group to delete delete open ai messages" +COM_GETBIBLE_OPEN_AI_MESSAGES_EDIT="Open Ai Messages Edit" +COM_GETBIBLE_OPEN_AI_MESSAGES_EDIT_CONTENT="Open Ai Messages Edit Content" +COM_GETBIBLE_OPEN_AI_MESSAGES_EDIT_CONTENT_DESC="Allows the users in this group to edit content of open ai message" +COM_GETBIBLE_OPEN_AI_MESSAGES_EDIT_CREATED_BY="Open Ai Messages Edit Created By" +COM_GETBIBLE_OPEN_AI_MESSAGES_EDIT_CREATED_BY_DESC="Allows the users in this group to update the created by of the edit created by open ai messages" +COM_GETBIBLE_OPEN_AI_MESSAGES_EDIT_CREATED_DATE="Open Ai Messages Edit Created Date" +COM_GETBIBLE_OPEN_AI_MESSAGES_EDIT_CREATED_DATE_DESC="Allows the users in this group to update the created date of the edit created open ai messages" +COM_GETBIBLE_OPEN_AI_MESSAGES_EDIT_DESC="Allows the users in this group to edit the open ai message" +COM_GETBIBLE_OPEN_AI_MESSAGES_EDIT_INDEX="Open Ai Messages Edit Index" +COM_GETBIBLE_OPEN_AI_MESSAGES_EDIT_INDEX_DESC="Allows the users in this group to edit index of open ai message" +COM_GETBIBLE_OPEN_AI_MESSAGES_EDIT_NAME="Open Ai Messages Edit Name" +COM_GETBIBLE_OPEN_AI_MESSAGES_EDIT_NAME_DESC="Allows the users in this group to edit name of open ai message" +COM_GETBIBLE_OPEN_AI_MESSAGES_EDIT_OPEN_AI_RESPONSE="Open Ai Messages Edit Open Ai Response" +COM_GETBIBLE_OPEN_AI_MESSAGES_EDIT_OPEN_AI_RESPONSE_DESC="Allows the users in this group to edit open ai response of open ai message" +COM_GETBIBLE_OPEN_AI_MESSAGES_EDIT_OWN="Open Ai Messages Edit Own" +COM_GETBIBLE_OPEN_AI_MESSAGES_EDIT_OWN_DESC="Allows the users in this group to edit edit own open ai messages created by them" +COM_GETBIBLE_OPEN_AI_MESSAGES_EDIT_PROMPT="Open Ai Messages Edit Prompt" +COM_GETBIBLE_OPEN_AI_MESSAGES_EDIT_PROMPT_DESC="Allows the users in this group to edit prompt of open ai message" +COM_GETBIBLE_OPEN_AI_MESSAGES_EDIT_ROLE="Open Ai Messages Edit Role" +COM_GETBIBLE_OPEN_AI_MESSAGES_EDIT_ROLE_DESC="Allows the users in this group to edit role of open ai message" +COM_GETBIBLE_OPEN_AI_MESSAGES_EDIT_SOURCE="Open Ai Messages Edit Source" +COM_GETBIBLE_OPEN_AI_MESSAGES_EDIT_SOURCE_DESC="Allows the users in this group to edit source of open ai message" +COM_GETBIBLE_OPEN_AI_MESSAGES_EDIT_STATE="Open Ai Messages Edit State" +COM_GETBIBLE_OPEN_AI_MESSAGES_EDIT_STATE_DESC="Allows the users in this group to update the state of the open ai message" +COM_GETBIBLE_OPEN_AI_MESSAGES_EDIT_VERSION="Open Ai Messages Edit Version" +COM_GETBIBLE_OPEN_AI_MESSAGES_EDIT_VERSION_DESC="Allows users in this group to edit versions of version open ai messages" +COM_GETBIBLE_OPEN_AI_MESSAGES_N_ITEMS_ARCHIVED="%s Open AI Messages archived." +COM_GETBIBLE_OPEN_AI_MESSAGES_N_ITEMS_ARCHIVED_1="%s Open AI Message archived." +COM_GETBIBLE_OPEN_AI_MESSAGES_N_ITEMS_CHECKED_IN_0="No Open AI Message successfully checked in." +COM_GETBIBLE_OPEN_AI_MESSAGES_N_ITEMS_CHECKED_IN_1="%d Open AI Message successfully checked in." +COM_GETBIBLE_OPEN_AI_MESSAGES_N_ITEMS_CHECKED_IN_MORE="%d Open AI Messages successfully checked in." +COM_GETBIBLE_OPEN_AI_MESSAGES_N_ITEMS_DELETED="%s Open AI Messages deleted." +COM_GETBIBLE_OPEN_AI_MESSAGES_N_ITEMS_DELETED_1="%s Open AI Message deleted." +COM_GETBIBLE_OPEN_AI_MESSAGES_N_ITEMS_FAILED_PUBLISHING="%s Open AI Messages failed publishing." +COM_GETBIBLE_OPEN_AI_MESSAGES_N_ITEMS_FAILED_PUBLISHING_1="%s Open AI Message failed publishing." +COM_GETBIBLE_OPEN_AI_MESSAGES_N_ITEMS_FEATURED="%s Open AI Messages featured." +COM_GETBIBLE_OPEN_AI_MESSAGES_N_ITEMS_FEATURED_1="%s Open AI Message featured." +COM_GETBIBLE_OPEN_AI_MESSAGES_N_ITEMS_PUBLISHED="%s Open AI Messages published." +COM_GETBIBLE_OPEN_AI_MESSAGES_N_ITEMS_PUBLISHED_1="%s Open AI Message published." +COM_GETBIBLE_OPEN_AI_MESSAGES_N_ITEMS_TRASHED="%s Open AI Messages trashed." +COM_GETBIBLE_OPEN_AI_MESSAGES_N_ITEMS_TRASHED_1="%s Open AI Message trashed." +COM_GETBIBLE_OPEN_AI_MESSAGES_N_ITEMS_UNFEATURED="%s Open AI Messages unfeatured." +COM_GETBIBLE_OPEN_AI_MESSAGES_N_ITEMS_UNFEATURED_1="%s Open AI Message unfeatured." +COM_GETBIBLE_OPEN_AI_MESSAGES_N_ITEMS_UNPUBLISHED="%s Open AI Messages unpublished." +COM_GETBIBLE_OPEN_AI_MESSAGES_N_ITEMS_UNPUBLISHED_1="%s Open AI Message unpublished." +COM_GETBIBLE_OPEN_AI_MESSAGE_ASSISTANT="assistant" +COM_GETBIBLE_OPEN_AI_MESSAGE_CONTENT_HINT="the response content will go here..." +COM_GETBIBLE_OPEN_AI_MESSAGE_CONTENT_LABEL="Content" +COM_GETBIBLE_OPEN_AI_MESSAGE_CREATED_BY_DESC="The user that created this Open AI Message." +COM_GETBIBLE_OPEN_AI_MESSAGE_CREATED_BY_LABEL="Created By" +COM_GETBIBLE_OPEN_AI_MESSAGE_CREATED_DATE_DESC="The date this Open AI Message was created." +COM_GETBIBLE_OPEN_AI_MESSAGE_CREATED_DATE_LABEL="Created Date" +COM_GETBIBLE_OPEN_AI_MESSAGE_EDIT="Editing the Open AI Message" +COM_GETBIBLE_OPEN_AI_MESSAGE_ERROR_UNIQUE_ALIAS="Another Open AI Message has the same alias." +COM_GETBIBLE_OPEN_AI_MESSAGE_FUNCTION="function" +COM_GETBIBLE_OPEN_AI_MESSAGE_ID="Id" +COM_GETBIBLE_OPEN_AI_MESSAGE_INDEX_DESCRIPTION="Message index" +COM_GETBIBLE_OPEN_AI_MESSAGE_INDEX_LABEL="Index" +COM_GETBIBLE_OPEN_AI_MESSAGE_MESSAGE="Message" +COM_GETBIBLE_OPEN_AI_MESSAGE_MODIFIED_BY_DESC="The last user that modified this Open AI Message." +COM_GETBIBLE_OPEN_AI_MESSAGE_MODIFIED_BY_LABEL="Modified By" +COM_GETBIBLE_OPEN_AI_MESSAGE_MODIFIED_DATE_DESC="The date this Open AI Message was modified." +COM_GETBIBLE_OPEN_AI_MESSAGE_MODIFIED_DATE_LABEL="Modified Date" +COM_GETBIBLE_OPEN_AI_MESSAGE_NAME_DESCRIPTION="Name" +COM_GETBIBLE_OPEN_AI_MESSAGE_NAME_HINT="add the author name here... (optional)" +COM_GETBIBLE_OPEN_AI_MESSAGE_NAME_LABEL="Author" +COM_GETBIBLE_OPEN_AI_MESSAGE_NAME_MESSAGE="Error! Please add some text here." +COM_GETBIBLE_OPEN_AI_MESSAGE_NEW="A New Open AI Message" +COM_GETBIBLE_OPEN_AI_MESSAGE_OPEN_AI="Open AI" +COM_GETBIBLE_OPEN_AI_MESSAGE_OPEN_AI_RESPONSE_LABEL="Open AI Response" +COM_GETBIBLE_OPEN_AI_MESSAGE_ORDERING_LABEL="Ordering" +COM_GETBIBLE_OPEN_AI_MESSAGE_PERMISSION="Permissions" +COM_GETBIBLE_OPEN_AI_MESSAGE_PROMPT="Prompt" +COM_GETBIBLE_OPEN_AI_MESSAGE_PROMPT_LABEL="Prompt" +COM_GETBIBLE_OPEN_AI_MESSAGE_PUBLISHING="Publishing" +COM_GETBIBLE_OPEN_AI_MESSAGE_ROLE_LABEL="Role" +COM_GETBIBLE_OPEN_AI_MESSAGE_SAVE_WARNING="Alias already existed so a number was added at the end. You can re-edit the Open AI Message to customise the alias." +COM_GETBIBLE_OPEN_AI_MESSAGE_SOURCE_DESCRIPTION="Source of message" +COM_GETBIBLE_OPEN_AI_MESSAGE_SOURCE_LABEL="Source" +COM_GETBIBLE_OPEN_AI_MESSAGE_STATUS="Status" +COM_GETBIBLE_OPEN_AI_MESSAGE_SYSTEM="system" +COM_GETBIBLE_OPEN_AI_MESSAGE_USER="user" +COM_GETBIBLE_OPEN_AI_MESSAGE_VERSION_DESC="A count of the number of times this Open AI Message has been revised." +COM_GETBIBLE_OPEN_AI_MESSAGE_VERSION_LABEL="Version" +COM_GETBIBLE_OPEN_AI_RESPONSE="Open AI Response" +COM_GETBIBLE_OPEN_AI_RESPONSES="Open AI Responses" +COM_GETBIBLE_OPEN_AI_RESPONSES_ACCESS="Open Ai Responses Access" +COM_GETBIBLE_OPEN_AI_RESPONSES_ACCESS_DESC="Allows the users in this group to access access open ai responses" +COM_GETBIBLE_OPEN_AI_RESPONSES_BATCH_OPTIONS="Batch process the selected Open AI Responses" +COM_GETBIBLE_OPEN_AI_RESPONSES_BATCH_TIP="All changes will be applied to all selected Open AI Responses" +COM_GETBIBLE_OPEN_AI_RESPONSES_BATCH_USE="Open Ai Responses Batch Use" +COM_GETBIBLE_OPEN_AI_RESPONSES_BATCH_USE_DESC="Allows users in this group to use batch copy/update method of batch open ai responses" +COM_GETBIBLE_OPEN_AI_RESPONSES_CREATE="Open Ai Responses Create" +COM_GETBIBLE_OPEN_AI_RESPONSES_CREATE_DESC="Allows the users in this group to create create open ai responses" +COM_GETBIBLE_OPEN_AI_RESPONSES_DASHBOARD_LIST="Open Ai Responses Dashboard List" +COM_GETBIBLE_OPEN_AI_RESPONSES_DASHBOARD_LIST_DESC="Allows the users in this group to dashboard list of open ai response" +COM_GETBIBLE_OPEN_AI_RESPONSES_DELETE="Open Ai Responses Delete" +COM_GETBIBLE_OPEN_AI_RESPONSES_DELETE_DESC="Allows the users in this group to delete delete open ai responses" +COM_GETBIBLE_OPEN_AI_RESPONSES_EDIT="Open Ai Responses Edit" +COM_GETBIBLE_OPEN_AI_RESPONSES_EDIT_ABBREVIATION="Open Ai Responses Edit Abbreviation" +COM_GETBIBLE_OPEN_AI_RESPONSES_EDIT_ABBREVIATION_DESC="Allows the users in this group to edit abbreviation of open ai response" +COM_GETBIBLE_OPEN_AI_RESPONSES_EDIT_BOOK="Open Ai Responses Edit Book" +COM_GETBIBLE_OPEN_AI_RESPONSES_EDIT_BOOK_DESC="Allows the users in this group to edit book of open ai response" +COM_GETBIBLE_OPEN_AI_RESPONSES_EDIT_CHAPTER="Open Ai Responses Edit Chapter" +COM_GETBIBLE_OPEN_AI_RESPONSES_EDIT_CHAPTER_DESC="Allows the users in this group to edit chapter of open ai response" +COM_GETBIBLE_OPEN_AI_RESPONSES_EDIT_COMPLETION_TOKENS="Open Ai Responses Edit Completion Tokens" +COM_GETBIBLE_OPEN_AI_RESPONSES_EDIT_COMPLETION_TOKENS_DESC="Allows the users in this group to edit completion tokens of open ai response" +COM_GETBIBLE_OPEN_AI_RESPONSES_EDIT_CREATED_BY="Open Ai Responses Edit Created By" +COM_GETBIBLE_OPEN_AI_RESPONSES_EDIT_CREATED_BY_DESC="Allows the users in this group to update the created by of the edit created by open ai responses" +COM_GETBIBLE_OPEN_AI_RESPONSES_EDIT_CREATED_DATE="Open Ai Responses Edit Created Date" +COM_GETBIBLE_OPEN_AI_RESPONSES_EDIT_CREATED_DATE_DESC="Allows the users in this group to update the created date of the edit created open ai responses" +COM_GETBIBLE_OPEN_AI_RESPONSES_EDIT_DESC="Allows the users in this group to edit the open ai response" +COM_GETBIBLE_OPEN_AI_RESPONSES_EDIT_FREQUENCY_PENALTY="Open Ai Responses Edit Frequency Penalty" +COM_GETBIBLE_OPEN_AI_RESPONSES_EDIT_FREQUENCY_PENALTY_DESC="Allows the users in this group to edit frequency penalty of open ai response" +COM_GETBIBLE_OPEN_AI_RESPONSES_EDIT_LANGUAGE="Open Ai Responses Edit Language" +COM_GETBIBLE_OPEN_AI_RESPONSES_EDIT_LANGUAGE_DESC="Allows the users in this group to edit language of open ai response" +COM_GETBIBLE_OPEN_AI_RESPONSES_EDIT_LCSH="Open Ai Responses Edit Lcsh" +COM_GETBIBLE_OPEN_AI_RESPONSES_EDIT_LCSH_DESC="Allows the users in this group to edit lcsh of open ai response" +COM_GETBIBLE_OPEN_AI_RESPONSES_EDIT_MAX_TOKENS="Open Ai Responses Edit Max Tokens" +COM_GETBIBLE_OPEN_AI_RESPONSES_EDIT_MAX_TOKENS_DESC="Allows the users in this group to edit max tokens of open ai response" +COM_GETBIBLE_OPEN_AI_RESPONSES_EDIT_MODEL="Open Ai Responses Edit Model" +COM_GETBIBLE_OPEN_AI_RESPONSES_EDIT_MODEL_DESC="Allows the users in this group to edit model of open ai response" +COM_GETBIBLE_OPEN_AI_RESPONSES_EDIT_N="Open Ai Responses Edit N" +COM_GETBIBLE_OPEN_AI_RESPONSES_EDIT_N_DESC="Allows the users in this group to edit n of open ai response" +COM_GETBIBLE_OPEN_AI_RESPONSES_EDIT_OWN="Open Ai Responses Edit Own" +COM_GETBIBLE_OPEN_AI_RESPONSES_EDIT_OWN_DESC="Allows the users in this group to edit edit own open ai responses created by them" +COM_GETBIBLE_OPEN_AI_RESPONSES_EDIT_PRESENCE_PENALTY="Open Ai Responses Edit Presence Penalty" +COM_GETBIBLE_OPEN_AI_RESPONSES_EDIT_PRESENCE_PENALTY_DESC="Allows the users in this group to edit presence penalty of open ai response" +COM_GETBIBLE_OPEN_AI_RESPONSES_EDIT_PROMPT="Open Ai Responses Edit Prompt" +COM_GETBIBLE_OPEN_AI_RESPONSES_EDIT_PROMPT_DESC="Allows the users in this group to edit prompt of open ai response" +COM_GETBIBLE_OPEN_AI_RESPONSES_EDIT_PROMPT_TOKENS="Open Ai Responses Edit Prompt Tokens" +COM_GETBIBLE_OPEN_AI_RESPONSES_EDIT_PROMPT_TOKENS_DESC="Allows the users in this group to edit prompt tokens of open ai response" +COM_GETBIBLE_OPEN_AI_RESPONSES_EDIT_RESPONSE_CREATED="Open Ai Responses Edit Response Created" +COM_GETBIBLE_OPEN_AI_RESPONSES_EDIT_RESPONSE_CREATED_DESC="Allows the users in this group to edit response created of open ai response" +COM_GETBIBLE_OPEN_AI_RESPONSES_EDIT_RESPONSE_ID="Open Ai Responses Edit Response Id" +COM_GETBIBLE_OPEN_AI_RESPONSES_EDIT_RESPONSE_ID_DESC="Allows the users in this group to edit response id of open ai response" +COM_GETBIBLE_OPEN_AI_RESPONSES_EDIT_RESPONSE_MODEL="Open Ai Responses Edit Response Model" +COM_GETBIBLE_OPEN_AI_RESPONSES_EDIT_RESPONSE_MODEL_DESC="Allows the users in this group to edit response model of open ai response" +COM_GETBIBLE_OPEN_AI_RESPONSES_EDIT_RESPONSE_OBJECT="Open Ai Responses Edit Response Object" +COM_GETBIBLE_OPEN_AI_RESPONSES_EDIT_RESPONSE_OBJECT_DESC="Allows the users in this group to edit response object of open ai response" +COM_GETBIBLE_OPEN_AI_RESPONSES_EDIT_SELECTED_WORD="Open Ai Responses Edit Selected Word" +COM_GETBIBLE_OPEN_AI_RESPONSES_EDIT_SELECTED_WORD_DESC="Allows the users in this group to edit selected word of open ai response" +COM_GETBIBLE_OPEN_AI_RESPONSES_EDIT_STATE="Open Ai Responses Edit State" +COM_GETBIBLE_OPEN_AI_RESPONSES_EDIT_STATE_DESC="Allows the users in this group to update the state of the open ai response" +COM_GETBIBLE_OPEN_AI_RESPONSES_EDIT_TEMPERATURE="Open Ai Responses Edit Temperature" +COM_GETBIBLE_OPEN_AI_RESPONSES_EDIT_TEMPERATURE_DESC="Allows the users in this group to edit temperature of open ai response" +COM_GETBIBLE_OPEN_AI_RESPONSES_EDIT_TOP_P="Open Ai Responses Edit Top P" +COM_GETBIBLE_OPEN_AI_RESPONSES_EDIT_TOP_P_DESC="Allows the users in this group to edit top p of open ai response" +COM_GETBIBLE_OPEN_AI_RESPONSES_EDIT_TOTAL_TOKENS="Open Ai Responses Edit Total Tokens" +COM_GETBIBLE_OPEN_AI_RESPONSES_EDIT_TOTAL_TOKENS_DESC="Allows the users in this group to edit total tokens of open ai response" +COM_GETBIBLE_OPEN_AI_RESPONSES_EDIT_VERSE="Open Ai Responses Edit Verse" +COM_GETBIBLE_OPEN_AI_RESPONSES_EDIT_VERSE_DESC="Allows the users in this group to edit verse of open ai response" +COM_GETBIBLE_OPEN_AI_RESPONSES_EDIT_VERSION="Open Ai Responses Edit Version" +COM_GETBIBLE_OPEN_AI_RESPONSES_EDIT_VERSION_DESC="Allows users in this group to edit versions of version open ai responses" +COM_GETBIBLE_OPEN_AI_RESPONSES_EDIT_WORD="Open Ai Responses Edit Word" +COM_GETBIBLE_OPEN_AI_RESPONSES_EDIT_WORD_DESC="Allows the users in this group to edit word of open ai response" +COM_GETBIBLE_OPEN_AI_RESPONSES_N_ITEMS_ARCHIVED="%s Open AI Responses archived." +COM_GETBIBLE_OPEN_AI_RESPONSES_N_ITEMS_ARCHIVED_1="%s Open AI Response archived." +COM_GETBIBLE_OPEN_AI_RESPONSES_N_ITEMS_CHECKED_IN_0="No Open AI Response successfully checked in." +COM_GETBIBLE_OPEN_AI_RESPONSES_N_ITEMS_CHECKED_IN_1="%d Open AI Response successfully checked in." +COM_GETBIBLE_OPEN_AI_RESPONSES_N_ITEMS_CHECKED_IN_MORE="%d Open AI Responses successfully checked in." +COM_GETBIBLE_OPEN_AI_RESPONSES_N_ITEMS_DELETED="%s Open AI Responses deleted." +COM_GETBIBLE_OPEN_AI_RESPONSES_N_ITEMS_DELETED_1="%s Open AI Response deleted." +COM_GETBIBLE_OPEN_AI_RESPONSES_N_ITEMS_FAILED_PUBLISHING="%s Open AI Responses failed publishing." +COM_GETBIBLE_OPEN_AI_RESPONSES_N_ITEMS_FAILED_PUBLISHING_1="%s Open AI Response failed publishing." +COM_GETBIBLE_OPEN_AI_RESPONSES_N_ITEMS_FEATURED="%s Open AI Responses featured." +COM_GETBIBLE_OPEN_AI_RESPONSES_N_ITEMS_FEATURED_1="%s Open AI Response featured." +COM_GETBIBLE_OPEN_AI_RESPONSES_N_ITEMS_PUBLISHED="%s Open AI Responses published." +COM_GETBIBLE_OPEN_AI_RESPONSES_N_ITEMS_PUBLISHED_1="%s Open AI Response published." +COM_GETBIBLE_OPEN_AI_RESPONSES_N_ITEMS_TRASHED="%s Open AI Responses trashed." +COM_GETBIBLE_OPEN_AI_RESPONSES_N_ITEMS_TRASHED_1="%s Open AI Response trashed." +COM_GETBIBLE_OPEN_AI_RESPONSES_N_ITEMS_UNFEATURED="%s Open AI Responses unfeatured." +COM_GETBIBLE_OPEN_AI_RESPONSES_N_ITEMS_UNFEATURED_1="%s Open AI Response unfeatured." +COM_GETBIBLE_OPEN_AI_RESPONSES_N_ITEMS_UNPUBLISHED="%s Open AI Responses unpublished." +COM_GETBIBLE_OPEN_AI_RESPONSES_N_ITEMS_UNPUBLISHED_1="%s Open AI Response unpublished." +COM_GETBIBLE_OPEN_AI_RESPONSES_SUBMENU="Open Ai Responses Submenu" +COM_GETBIBLE_OPEN_AI_RESPONSES_SUBMENU_DESC="Allows the users in this group to submenu of open ai response" +COM_GETBIBLE_OPEN_AI_RESPONSE_ABBREVIATION_DESCRIPTION="Select a Bible translation" +COM_GETBIBLE_OPEN_AI_RESPONSE_ABBREVIATION_LABEL="Target Translation" +COM_GETBIBLE_OPEN_AI_RESPONSE_BIBLE="Bible" +COM_GETBIBLE_OPEN_AI_RESPONSE_BOOK_DESCRIPTION="The book number" +COM_GETBIBLE_OPEN_AI_RESPONSE_BOOK_HINT="Book Number" +COM_GETBIBLE_OPEN_AI_RESPONSE_BOOK_LABEL="Book" +COM_GETBIBLE_OPEN_AI_RESPONSE_CHAPTER_DESCRIPTION="The chapter number" +COM_GETBIBLE_OPEN_AI_RESPONSE_CHAPTER_HINT="Chapter Number" +COM_GETBIBLE_OPEN_AI_RESPONSE_CHAPTER_LABEL="Chapter" +COM_GETBIBLE_OPEN_AI_RESPONSE_COMPLETION_TOKENS_DESCRIPTION="Completion number of tokens used." +COM_GETBIBLE_OPEN_AI_RESPONSE_COMPLETION_TOKENS_LABEL="Completion Tokens" +COM_GETBIBLE_OPEN_AI_RESPONSE_CREATED_BY_DESC="The user that created this Open AI Response." +COM_GETBIBLE_OPEN_AI_RESPONSE_CREATED_BY_LABEL="Created By" +COM_GETBIBLE_OPEN_AI_RESPONSE_CREATED_DATE_DESC="The date this Open AI Response was created." +COM_GETBIBLE_OPEN_AI_RESPONSE_CREATED_DATE_LABEL="Created Date" +COM_GETBIBLE_OPEN_AI_RESPONSE_DETAILS="Details" +COM_GETBIBLE_OPEN_AI_RESPONSE_EDIT="Editing the Open AI Response" +COM_GETBIBLE_OPEN_AI_RESPONSE_ERROR_UNIQUE_ALIAS="Another Open AI Response has the same alias." +COM_GETBIBLE_OPEN_AI_RESPONSE_FREQUENCY_PENALTY_DESCRIPTION="Penalty for new tokens based on their frequency in the text" +COM_GETBIBLE_OPEN_AI_RESPONSE_FREQUENCY_PENALTY_LABEL="Frequency Penalty" +COM_GETBIBLE_OPEN_AI_RESPONSE_GPT35TURBO="gpt-3.5-turbo" +COM_GETBIBLE_OPEN_AI_RESPONSE_GPT35TURBO0613="gpt-3.5-turbo-0613" +COM_GETBIBLE_OPEN_AI_RESPONSE_GPT35TURBO16K="gpt-3.5-turbo-16k" +COM_GETBIBLE_OPEN_AI_RESPONSE_GPT35TURBO16K0613="gpt-3.5-turbo-16k-0613" +COM_GETBIBLE_OPEN_AI_RESPONSE_GPT4="gpt-4" +COM_GETBIBLE_OPEN_AI_RESPONSE_GPT40613="gpt-4-0613" +COM_GETBIBLE_OPEN_AI_RESPONSE_GPT432K="gpt-4-32k" +COM_GETBIBLE_OPEN_AI_RESPONSE_GPT432K0613="gpt-4-32k-0613" +COM_GETBIBLE_OPEN_AI_RESPONSE_ID="Id" +COM_GETBIBLE_OPEN_AI_RESPONSE_LANGUAGE_DESCRIPTION="The translation language" +COM_GETBIBLE_OPEN_AI_RESPONSE_LANGUAGE_HINT="Language" +COM_GETBIBLE_OPEN_AI_RESPONSE_LANGUAGE_LABEL="Language" +COM_GETBIBLE_OPEN_AI_RESPONSE_LCSH_DESCRIPTION="The library of congress subject headings" +COM_GETBIBLE_OPEN_AI_RESPONSE_LCSH_HINT="LCSH" +COM_GETBIBLE_OPEN_AI_RESPONSE_LCSH_LABEL="LCSH" +COM_GETBIBLE_OPEN_AI_RESPONSE_MAX_TOKENS_DESCRIPTION="Maximum number of tokens to generate." +COM_GETBIBLE_OPEN_AI_RESPONSE_MAX_TOKENS_LABEL="Max Tokens" +COM_GETBIBLE_OPEN_AI_RESPONSE_MESSAGE="Message" +COM_GETBIBLE_OPEN_AI_RESPONSE_MODEL_DESCRIPTION="ID of the model to use." +COM_GETBIBLE_OPEN_AI_RESPONSE_MODEL_LABEL="Model" +COM_GETBIBLE_OPEN_AI_RESPONSE_MODIFIED_BY_DESC="The last user that modified this Open AI Response." +COM_GETBIBLE_OPEN_AI_RESPONSE_MODIFIED_BY_LABEL="Modified By" +COM_GETBIBLE_OPEN_AI_RESPONSE_MODIFIED_DATE_DESC="The date this Open AI Response was modified." +COM_GETBIBLE_OPEN_AI_RESPONSE_MODIFIED_DATE_LABEL="Modified Date" +COM_GETBIBLE_OPEN_AI_RESPONSE_NEW="A New Open AI Response" +COM_GETBIBLE_OPEN_AI_RESPONSE_N_DESCRIPTION="The number of chat completion choices to generate" +COM_GETBIBLE_OPEN_AI_RESPONSE_N_LABEL="Number AI Response Per/Prompt" +COM_GETBIBLE_OPEN_AI_RESPONSE_ORDERING_LABEL="Ordering" +COM_GETBIBLE_OPEN_AI_RESPONSE_PERMISSION="Permissions" +COM_GETBIBLE_OPEN_AI_RESPONSE_PRESENCE_PENALTY_DESCRIPTION="Penalty for new tokens based on whether they appear in the text" +COM_GETBIBLE_OPEN_AI_RESPONSE_PRESENCE_PENALTY_LABEL="Presence Penalty" +COM_GETBIBLE_OPEN_AI_RESPONSE_PROMPT="Prompt" +COM_GETBIBLE_OPEN_AI_RESPONSE_PROMPT_LABEL="Prompt" +COM_GETBIBLE_OPEN_AI_RESPONSE_PROMPT_TOKENS_DESCRIPTION="Prompt number of tokens used." +COM_GETBIBLE_OPEN_AI_RESPONSE_PROMPT_TOKENS_LABEL="Prompt Tokens" +COM_GETBIBLE_OPEN_AI_RESPONSE_PUBLISHING="Publishing" +COM_GETBIBLE_OPEN_AI_RESPONSE_RESPONSE_CREATED_DESCRIPTION="The response created" +COM_GETBIBLE_OPEN_AI_RESPONSE_RESPONSE_CREATED_HINT="a time stamp" +COM_GETBIBLE_OPEN_AI_RESPONSE_RESPONSE_CREATED_LABEL="Response created" +COM_GETBIBLE_OPEN_AI_RESPONSE_RESPONSE_ID_DESCRIPTION="The response ID" +COM_GETBIBLE_OPEN_AI_RESPONSE_RESPONSE_ID_HINT="auto assigned id" +COM_GETBIBLE_OPEN_AI_RESPONSE_RESPONSE_ID_LABEL="Response ID" +COM_GETBIBLE_OPEN_AI_RESPONSE_RESPONSE_ID_MESSAGE="Error! Please add some text here." +COM_GETBIBLE_OPEN_AI_RESPONSE_RESPONSE_MODEL_DESCRIPTION="The response model" +COM_GETBIBLE_OPEN_AI_RESPONSE_RESPONSE_MODEL_HINT="gpt-4" +COM_GETBIBLE_OPEN_AI_RESPONSE_RESPONSE_MODEL_LABEL="Response model" +COM_GETBIBLE_OPEN_AI_RESPONSE_RESPONSE_OBJECT_DESCRIPTION="The response object" +COM_GETBIBLE_OPEN_AI_RESPONSE_RESPONSE_OBJECT_HINT="end-point" +COM_GETBIBLE_OPEN_AI_RESPONSE_RESPONSE_OBJECT_LABEL="Response object (end-point)" +COM_GETBIBLE_OPEN_AI_RESPONSE_RESPONSE_OBJECT_MESSAGE="Error! Please add some text here." +COM_GETBIBLE_OPEN_AI_RESPONSE_SAVE_WARNING="Alias already existed so a number was added at the end. You can re-edit the Open AI Response to customise the alias." +COM_GETBIBLE_OPEN_AI_RESPONSE_SELECTED_WORD_DESCRIPTION="The word/s selected" +COM_GETBIBLE_OPEN_AI_RESPONSE_SELECTED_WORD_HINT="Actual Selected Word/s" +COM_GETBIBLE_OPEN_AI_RESPONSE_SELECTED_WORD_LABEL="Selected Word/s" +COM_GETBIBLE_OPEN_AI_RESPONSE_STATUS="Status" +COM_GETBIBLE_OPEN_AI_RESPONSE_TEMPERATURE_DESCRIPTION="The sampling temperature to use" +COM_GETBIBLE_OPEN_AI_RESPONSE_TEMPERATURE_LABEL="Temperature" +COM_GETBIBLE_OPEN_AI_RESPONSE_TOP_P_DESCRIPTION="The nucleus sampling parameter" +COM_GETBIBLE_OPEN_AI_RESPONSE_TOP_P_LABEL="Top P" +COM_GETBIBLE_OPEN_AI_RESPONSE_TOTAL_TOKENS_DESCRIPTION="Total number of tokens used." +COM_GETBIBLE_OPEN_AI_RESPONSE_TOTAL_TOKENS_LABEL="Total Tokens" +COM_GETBIBLE_OPEN_AI_RESPONSE_VERSE_DESCRIPTION="The verse numbers" +COM_GETBIBLE_OPEN_AI_RESPONSE_VERSE_HINT="Verse Numbers" +COM_GETBIBLE_OPEN_AI_RESPONSE_VERSE_LABEL="Verse" +COM_GETBIBLE_OPEN_AI_RESPONSE_VERSION_DESC="A count of the number of times this Open AI Response has been revised." +COM_GETBIBLE_OPEN_AI_RESPONSE_VERSION_LABEL="Version" +COM_GETBIBLE_OPEN_AI_RESPONSE_WORD_DESCRIPTION="The word/s numbers" +COM_GETBIBLE_OPEN_AI_RESPONSE_WORD_HINT="Word/s Number/s" +COM_GETBIBLE_OPEN_AI_RESPONSE_WORD_LABEL="Word/s" +COM_GETBIBLE_OUT_OF_DATE="Out of date" +COM_GETBIBLE_PASSWORD="Password" +COM_GETBIBLE_PASSWORDS="Passwords" +COM_GETBIBLE_PASSWORDS_ACCESS="Passwords Access" +COM_GETBIBLE_PASSWORDS_ACCESS_DESC="Allows the users in this group to access access passwords" +COM_GETBIBLE_PASSWORDS_ACCESS_PASSWORD="Passwords Access Password" +COM_GETBIBLE_PASSWORDS_ACCESS_PASSWORD_DESC="Allows the users in this group to access password of password" +COM_GETBIBLE_PASSWORDS_BATCH_OPTIONS="Batch process the selected Passwords" +COM_GETBIBLE_PASSWORDS_BATCH_TIP="All changes will be applied to all selected Passwords" +COM_GETBIBLE_PASSWORDS_BATCH_USE="Passwords Batch Use" +COM_GETBIBLE_PASSWORDS_BATCH_USE_DESC="Allows users in this group to use batch copy/update method of batch passwords" +COM_GETBIBLE_PASSWORDS_CREATE="Passwords Create" +COM_GETBIBLE_PASSWORDS_CREATE_DESC="Allows the users in this group to create create passwords" +COM_GETBIBLE_PASSWORDS_DELETE="Passwords Delete" +COM_GETBIBLE_PASSWORDS_DELETE_DESC="Allows the users in this group to delete delete passwords" +COM_GETBIBLE_PASSWORDS_EDIT="Passwords Edit" +COM_GETBIBLE_PASSWORDS_EDIT_CREATED_BY="Passwords Edit Created By" +COM_GETBIBLE_PASSWORDS_EDIT_CREATED_BY_DESC="Allows the users in this group to update the created by of the edit created by passwords" +COM_GETBIBLE_PASSWORDS_EDIT_CREATED_DATE="Passwords Edit Created Date" +COM_GETBIBLE_PASSWORDS_EDIT_CREATED_DATE_DESC="Allows the users in this group to update the created date of the edit created passwords" +COM_GETBIBLE_PASSWORDS_EDIT_DESC="Allows the users in this group to edit the password" +COM_GETBIBLE_PASSWORDS_EDIT_GUID="Passwords Edit Guid" +COM_GETBIBLE_PASSWORDS_EDIT_GUID_DESC="Allows the users in this group to edit guid of password" +COM_GETBIBLE_PASSWORDS_EDIT_LINKER="Passwords Edit Linker" +COM_GETBIBLE_PASSWORDS_EDIT_LINKER_DESC="Allows the users in this group to edit linker of password" +COM_GETBIBLE_PASSWORDS_EDIT_NAME="Passwords Edit Name" +COM_GETBIBLE_PASSWORDS_EDIT_NAME_DESC="Allows the users in this group to edit name of password" +COM_GETBIBLE_PASSWORDS_EDIT_OWN="Passwords Edit Own" +COM_GETBIBLE_PASSWORDS_EDIT_OWN_DESC="Allows the users in this group to edit edit own passwords created by them" +COM_GETBIBLE_PASSWORDS_EDIT_PASSWORD="Passwords Edit Password" +COM_GETBIBLE_PASSWORDS_EDIT_PASSWORD_DESC="Allows the users in this group to edit password of password" +COM_GETBIBLE_PASSWORDS_EDIT_STATE="Passwords Edit State" +COM_GETBIBLE_PASSWORDS_EDIT_STATE_DESC="Allows the users in this group to update the state of the password" +COM_GETBIBLE_PASSWORDS_N_ITEMS_ARCHIVED="%s Passwords archived." +COM_GETBIBLE_PASSWORDS_N_ITEMS_ARCHIVED_1="%s Password archived." +COM_GETBIBLE_PASSWORDS_N_ITEMS_CHECKED_IN_0="No Password successfully checked in." +COM_GETBIBLE_PASSWORDS_N_ITEMS_CHECKED_IN_1="%d Password successfully checked in." +COM_GETBIBLE_PASSWORDS_N_ITEMS_CHECKED_IN_MORE="%d Passwords successfully checked in." +COM_GETBIBLE_PASSWORDS_N_ITEMS_DELETED="%s Passwords deleted." +COM_GETBIBLE_PASSWORDS_N_ITEMS_DELETED_1="%s Password deleted." +COM_GETBIBLE_PASSWORDS_N_ITEMS_FAILED_PUBLISHING="%s Passwords failed publishing." +COM_GETBIBLE_PASSWORDS_N_ITEMS_FAILED_PUBLISHING_1="%s Password failed publishing." +COM_GETBIBLE_PASSWORDS_N_ITEMS_FEATURED="%s Passwords featured." +COM_GETBIBLE_PASSWORDS_N_ITEMS_FEATURED_1="%s Password featured." +COM_GETBIBLE_PASSWORDS_N_ITEMS_PUBLISHED="%s Passwords published." +COM_GETBIBLE_PASSWORDS_N_ITEMS_PUBLISHED_1="%s Password published." +COM_GETBIBLE_PASSWORDS_N_ITEMS_TRASHED="%s Passwords trashed." +COM_GETBIBLE_PASSWORDS_N_ITEMS_TRASHED_1="%s Password trashed." +COM_GETBIBLE_PASSWORDS_N_ITEMS_UNFEATURED="%s Passwords unfeatured." +COM_GETBIBLE_PASSWORDS_N_ITEMS_UNFEATURED_1="%s Password unfeatured." +COM_GETBIBLE_PASSWORDS_N_ITEMS_UNPUBLISHED="%s Passwords unpublished." +COM_GETBIBLE_PASSWORDS_N_ITEMS_UNPUBLISHED_1="%s Password unpublished." +COM_GETBIBLE_PASSWORDS_VIEW_PASSWORD="Passwords View Password" +COM_GETBIBLE_PASSWORDS_VIEW_PASSWORD_DESC="Allows the users in this group to view password of password" +COM_GETBIBLE_PASSWORD_CREATED_BY_DESC="The user that created this Password." +COM_GETBIBLE_PASSWORD_CREATED_BY_LABEL="Created By" +COM_GETBIBLE_PASSWORD_CREATED_DATE_DESC="The date this Password was created." +COM_GETBIBLE_PASSWORD_CREATED_DATE_LABEL="Created Date" +COM_GETBIBLE_PASSWORD_DETAILS="Details" +COM_GETBIBLE_PASSWORD_EDIT="Editing the Password" +COM_GETBIBLE_PASSWORD_ERROR_UNIQUE_ALIAS="Another Password has the same alias." +COM_GETBIBLE_PASSWORD_GUID_DESCRIPTION="Globally Unique Identifier" +COM_GETBIBLE_PASSWORD_GUID_HINT="Auto Generated" +COM_GETBIBLE_PASSWORD_GUID_LABEL="GUID" +COM_GETBIBLE_PASSWORD_ID="Id" +COM_GETBIBLE_PASSWORD_LINKER_DESCRIPTION="Globally Unique Linker" +COM_GETBIBLE_PASSWORD_LINKER_LABEL="Linker" +COM_GETBIBLE_PASSWORD_MODIFIED_BY_DESC="The last user that modified this Password." +COM_GETBIBLE_PASSWORD_MODIFIED_BY_LABEL="Modified By" +COM_GETBIBLE_PASSWORD_MODIFIED_DATE_DESC="The date this Password was modified." +COM_GETBIBLE_PASSWORD_MODIFIED_DATE_LABEL="Modified Date" +COM_GETBIBLE_PASSWORD_NAME_HINT="Name Here" +COM_GETBIBLE_PASSWORD_NAME_LABEL="Name" +COM_GETBIBLE_PASSWORD_NAME_MESSAGE="Error! Please add name here." +COM_GETBIBLE_PASSWORD_NEW="A New Password" +COM_GETBIBLE_PASSWORD_ORDERING_LABEL="Ordering" +COM_GETBIBLE_PASSWORD_PASSWORD_DESCRIPTION="Your Password" +COM_GETBIBLE_PASSWORD_PASSWORD_HINT="// share password" +COM_GETBIBLE_PASSWORD_PASSWORD_LABEL="Password" +COM_GETBIBLE_PASSWORD_PERMISSION="Permissions" +COM_GETBIBLE_PASSWORD_PUBLISHING="Publishing" +COM_GETBIBLE_PASSWORD_SAVE_WARNING="Alias already existed so a number was added at the end. You can re-edit the Password to customise the alias." +COM_GETBIBLE_PASSWORD_STATUS="Status" +COM_GETBIBLE_PASSWORD_TO_SHORT_USE_A_LONGER_PASSWORD="Password to short, use a longer password." +COM_GETBIBLE_PASSWORD_VERSION_DESC="A count of the number of times this Password has been revised." +COM_GETBIBLE_PASSWORD_VERSION_LABEL="Version" +COM_GETBIBLE_PLEASE_CHECK_AGAIN_LATTER="Please check again latter." +COM_GETBIBLE_PROMPT="Prompt" +COM_GETBIBLE_PROMPTS="Prompts" +COM_GETBIBLE_PROMPTS_ACCESS="Prompts Access" +COM_GETBIBLE_PROMPTS_ACCESS_DESC="Allows the users in this group to access access prompts" +COM_GETBIBLE_PROMPTS_ACCESS_TEMPERATURE_OVERRIDE="Prompts Access Temperature Override" +COM_GETBIBLE_PROMPTS_ACCESS_TEMPERATURE_OVERRIDE_DESC="Allows the users in this group to access temperature override of prompt" +COM_GETBIBLE_PROMPTS_BATCH_OPTIONS="Batch process the selected Prompts" +COM_GETBIBLE_PROMPTS_BATCH_TIP="All changes will be applied to all selected Prompts" +COM_GETBIBLE_PROMPTS_BATCH_USE="Prompts Batch Use" +COM_GETBIBLE_PROMPTS_BATCH_USE_DESC="Allows users in this group to use batch copy/update method of batch prompts" +COM_GETBIBLE_PROMPTS_CREATE="Prompts Create" +COM_GETBIBLE_PROMPTS_CREATE_DESC="Allows the users in this group to create create prompts" +COM_GETBIBLE_PROMPTS_DASHBOARD_LIST="Prompts Dashboard List" +COM_GETBIBLE_PROMPTS_DASHBOARD_LIST_DESC="Allows the users in this group to dashboard list of prompt" +COM_GETBIBLE_PROMPTS_DELETE="Prompts Delete" +COM_GETBIBLE_PROMPTS_DELETE_DESC="Allows the users in this group to delete delete prompts" +COM_GETBIBLE_PROMPTS_EDIT="Prompts Edit" +COM_GETBIBLE_PROMPTS_EDIT_ABBREVIATION="Prompts Edit Abbreviation" +COM_GETBIBLE_PROMPTS_EDIT_ABBREVIATION_DESC="Allows the users in this group to edit abbreviation of prompt" +COM_GETBIBLE_PROMPTS_EDIT_AI_ORG_TOKEN_OVERRIDE="Prompts Edit Ai Org Token Override" +COM_GETBIBLE_PROMPTS_EDIT_AI_ORG_TOKEN_OVERRIDE_DESC="Allows the users in this group to edit ai org token override of prompt" +COM_GETBIBLE_PROMPTS_EDIT_CACHE_BEHAVIOUR="Prompts Edit Cache Behaviour" +COM_GETBIBLE_PROMPTS_EDIT_CACHE_BEHAVIOUR_DESC="Allows the users in this group to edit cache behaviour of prompt" +COM_GETBIBLE_PROMPTS_EDIT_CREATED_BY="Prompts Edit Created By" +COM_GETBIBLE_PROMPTS_EDIT_CREATED_BY_DESC="Allows the users in this group to update the created by of the edit created by prompts" +COM_GETBIBLE_PROMPTS_EDIT_CREATED_DATE="Prompts Edit Created Date" +COM_GETBIBLE_PROMPTS_EDIT_CREATED_DATE_DESC="Allows the users in this group to update the created date of the edit created prompts" +COM_GETBIBLE_PROMPTS_EDIT_DESC="Allows the users in this group to edit the prompt" +COM_GETBIBLE_PROMPTS_EDIT_FREQUENCY_PENALTY="Prompts Edit Frequency Penalty" +COM_GETBIBLE_PROMPTS_EDIT_FREQUENCY_PENALTY_DESC="Allows the users in this group to edit frequency penalty of prompt" +COM_GETBIBLE_PROMPTS_EDIT_FREQUENCY_PENALTY_OVERRIDE="Prompts Edit Frequency Penalty Override" +COM_GETBIBLE_PROMPTS_EDIT_FREQUENCY_PENALTY_OVERRIDE_DESC="Allows the users in this group to edit frequency penalty override of prompt" +COM_GETBIBLE_PROMPTS_EDIT_GUID="Prompts Edit Guid" +COM_GETBIBLE_PROMPTS_EDIT_GUID_DESC="Allows the users in this group to edit guid of prompt" +COM_GETBIBLE_PROMPTS_EDIT_INTEGRATION="Prompts Edit Integration" +COM_GETBIBLE_PROMPTS_EDIT_INTEGRATION_DESC="Allows the users in this group to edit integration of prompt" +COM_GETBIBLE_PROMPTS_EDIT_MAX_TOKENS="Prompts Edit Max Tokens" +COM_GETBIBLE_PROMPTS_EDIT_MAX_TOKENS_DESC="Allows the users in this group to edit max tokens of prompt" +COM_GETBIBLE_PROMPTS_EDIT_MAX_TOKENS_OVERRIDE="Prompts Edit Max Tokens Override" +COM_GETBIBLE_PROMPTS_EDIT_MAX_TOKENS_OVERRIDE_DESC="Allows the users in this group to edit max tokens override of prompt" +COM_GETBIBLE_PROMPTS_EDIT_MESSAGES="Prompts Edit Messages" +COM_GETBIBLE_PROMPTS_EDIT_MESSAGES_DESC="Allows the users in this group to edit messages of prompt" +COM_GETBIBLE_PROMPTS_EDIT_MODEL="Prompts Edit Model" +COM_GETBIBLE_PROMPTS_EDIT_MODEL_DESC="Allows the users in this group to edit model of prompt" +COM_GETBIBLE_PROMPTS_EDIT_N="Prompts Edit N" +COM_GETBIBLE_PROMPTS_EDIT_NAME="Prompts Edit Name" +COM_GETBIBLE_PROMPTS_EDIT_NAME_DESC="Allows the users in this group to edit name of prompt" +COM_GETBIBLE_PROMPTS_EDIT_N_DESC="Allows the users in this group to edit n of prompt" +COM_GETBIBLE_PROMPTS_EDIT_N_OVERRIDE="Prompts Edit N Override" +COM_GETBIBLE_PROMPTS_EDIT_N_OVERRIDE_DESC="Allows the users in this group to edit n override of prompt" +COM_GETBIBLE_PROMPTS_EDIT_ORG_TOKEN="Prompts Edit Org Token" +COM_GETBIBLE_PROMPTS_EDIT_ORG_TOKEN_DESC="Allows the users in this group to edit org token of prompt" +COM_GETBIBLE_PROMPTS_EDIT_OWN="Prompts Edit Own" +COM_GETBIBLE_PROMPTS_EDIT_OWN_DESC="Allows the users in this group to edit edit own prompts created by them" +COM_GETBIBLE_PROMPTS_EDIT_PRESENCE_PENALTY="Prompts Edit Presence Penalty" +COM_GETBIBLE_PROMPTS_EDIT_PRESENCE_PENALTY_DESC="Allows the users in this group to edit presence penalty of prompt" +COM_GETBIBLE_PROMPTS_EDIT_PRESENCE_PENALTY_OVERRIDE="Prompts Edit Presence Penalty Override" +COM_GETBIBLE_PROMPTS_EDIT_PRESENCE_PENALTY_OVERRIDE_DESC="Allows the users in this group to edit presence penalty override of prompt" +COM_GETBIBLE_PROMPTS_EDIT_RESPONSE_RETRIEVAL="Prompts Edit Response Retrieval" +COM_GETBIBLE_PROMPTS_EDIT_RESPONSE_RETRIEVAL_DESC="Allows the users in this group to edit response retrieval of prompt" +COM_GETBIBLE_PROMPTS_EDIT_STATE="Prompts Edit State" +COM_GETBIBLE_PROMPTS_EDIT_STATE_DESC="Allows the users in this group to update the state of the prompt" +COM_GETBIBLE_PROMPTS_EDIT_TEMPERATURE="Prompts Edit Temperature" +COM_GETBIBLE_PROMPTS_EDIT_TEMPERATURE_DESC="Allows the users in this group to edit temperature of prompt" +COM_GETBIBLE_PROMPTS_EDIT_TOKEN="Prompts Edit Token" +COM_GETBIBLE_PROMPTS_EDIT_TOKEN_DESC="Allows the users in this group to edit token of prompt" +COM_GETBIBLE_PROMPTS_EDIT_TOKEN_OVERRIDE="Prompts Edit Token Override" +COM_GETBIBLE_PROMPTS_EDIT_TOKEN_OVERRIDE_DESC="Allows the users in this group to edit token override of prompt" +COM_GETBIBLE_PROMPTS_EDIT_TOP_P="Prompts Edit Top P" +COM_GETBIBLE_PROMPTS_EDIT_TOP_P_DESC="Allows the users in this group to edit top p of prompt" +COM_GETBIBLE_PROMPTS_EDIT_TOP_P_OVERRIDE="Prompts Edit Top P Override" +COM_GETBIBLE_PROMPTS_EDIT_TOP_P_OVERRIDE_DESC="Allows the users in this group to edit top p override of prompt" +COM_GETBIBLE_PROMPTS_EDIT_VERSION="Prompts Edit Version" +COM_GETBIBLE_PROMPTS_EDIT_VERSION_DESC="Allows users in this group to edit versions of version prompts" +COM_GETBIBLE_PROMPTS_N_ITEMS_ARCHIVED="%s Prompts archived." +COM_GETBIBLE_PROMPTS_N_ITEMS_ARCHIVED_1="%s Prompt archived." +COM_GETBIBLE_PROMPTS_N_ITEMS_CHECKED_IN_0="No Prompt successfully checked in." +COM_GETBIBLE_PROMPTS_N_ITEMS_CHECKED_IN_1="%d Prompt successfully checked in." +COM_GETBIBLE_PROMPTS_N_ITEMS_CHECKED_IN_MORE="%d Prompts successfully checked in." +COM_GETBIBLE_PROMPTS_N_ITEMS_DELETED="%s Prompts deleted." +COM_GETBIBLE_PROMPTS_N_ITEMS_DELETED_1="%s Prompt deleted." +COM_GETBIBLE_PROMPTS_N_ITEMS_FAILED_PUBLISHING="%s Prompts failed publishing." +COM_GETBIBLE_PROMPTS_N_ITEMS_FAILED_PUBLISHING_1="%s Prompt failed publishing." +COM_GETBIBLE_PROMPTS_N_ITEMS_FEATURED="%s Prompts featured." +COM_GETBIBLE_PROMPTS_N_ITEMS_FEATURED_1="%s Prompt featured." +COM_GETBIBLE_PROMPTS_N_ITEMS_PUBLISHED="%s Prompts published." +COM_GETBIBLE_PROMPTS_N_ITEMS_PUBLISHED_1="%s Prompt published." +COM_GETBIBLE_PROMPTS_N_ITEMS_TRASHED="%s Prompts trashed." +COM_GETBIBLE_PROMPTS_N_ITEMS_TRASHED_1="%s Prompt trashed." +COM_GETBIBLE_PROMPTS_N_ITEMS_UNFEATURED="%s Prompts unfeatured." +COM_GETBIBLE_PROMPTS_N_ITEMS_UNFEATURED_1="%s Prompt unfeatured." +COM_GETBIBLE_PROMPTS_N_ITEMS_UNPUBLISHED="%s Prompts unpublished." +COM_GETBIBLE_PROMPTS_N_ITEMS_UNPUBLISHED_1="%s Prompt unpublished." +COM_GETBIBLE_PROMPTS_SUBMENU="Prompts Submenu" +COM_GETBIBLE_PROMPTS_SUBMENU_DESC="Allows the users in this group to submenu of prompt" +COM_GETBIBLE_PROMPT_ABBREVIATION_DESCRIPTION="Select a Bible translation" +COM_GETBIBLE_PROMPT_ABBREVIATION_LABEL="Target Translation" +COM_GETBIBLE_PROMPT_ADVANCED_CACHING_VERSECONTEX="Advanced Caching - Verse/Contex" +COM_GETBIBLE_PROMPT_AI_ORG_TOKEN_OVERRIDE_DESCRIPTION="Would you like to override the global openai organisation token value." +COM_GETBIBLE_PROMPT_AI_ORG_TOKEN_OVERRIDE_LABEL="Openai Organisation Token (override)" +COM_GETBIBLE_PROMPT_ASSISTANT="assistant" +COM_GETBIBLE_PROMPT_BASIC_CACHING_WORDSLANGUAGE="Basic Caching - Words/Language" +COM_GETBIBLE_PROMPT_CACHE_ADVANCE_NOTE_DESCRIPTION="

Recommended: Cache responses related to specific verses from a particular book, chapter, and translation. Provides more context-specific accuracy, but potentially more costly.

The "Advanced Caching - Verse/Context" strategy is our recommended choice for queries that focus on the interpretation of specific verses from a particular book, chapter, and translation of the Bible. Here's a breakdown of its operation and considerations:

  • Function: When a query is made, the system checks the cache for prior responses tied to the same verse within the same book, chapter, and translation. If a match is discovered, the cached response is delivered, improving speed while also managing costs.
  • Pros: This strategy offers improved context-specific accuracy by considering the specific verse, chapter, and book where the word or phrase is located. This results in more precise interpretations and a superior user experience.
  • Cons: As a trade-off for its higher accuracy, this method may be more costly than the "Basic Caching - Words/Language" strategy due to the necessity of caching a wider range of unique queries.
  • Recommendation: Despite the potential increased cost, we strongly advocate for this method due to its emphasis on context and accuracy.
" +COM_GETBIBLE_PROMPT_CACHE_ADVANCE_NOTE_LABEL="Discover the Advanced Caching Strategy" +COM_GETBIBLE_PROMPT_CACHE_BASIC_NOTE_DESCRIPTION="

Cache responses based on specific words or phrases within a particular language.

The "Basic Caching - Words/Language" strategy is designed to handle queries that focus on the meaning or interpretation of specific words or phrases within a given language. Here's how it works and what to consider:

  • Function: When a query is initiated, the system searches the cache to determine if the same word or phrase has been previously requested in the same language. If a match is found, the cached response is given, enhancing speed and managing costs.
  • Pros: This method can be more cost-effective and faster as it avoids repeated API calls for identical queries.
  • Cons: The major drawback of this approach is its potential for less accurate interpretations. It doesn't take into account the specific context provided by the verse, chapter, and book of the Bible where the word or phrase is found.
  • Recommendation: While this method can be efficient, for more contextually accurate responses, consider the "Advanced Caching - Verse/Context" strategy.
" +COM_GETBIBLE_PROMPT_CACHE_BASIC_NOTE_LABEL="Understand the Basic Caching Strategy" +COM_GETBIBLE_PROMPT_CACHE_BEHAVIOUR_DESCRIPTION="Determine the caching behaviour of this prompt. Be aware, this is a crucial setting that significantly impacts the prompt's operation." +COM_GETBIBLE_PROMPT_CACHE_BEHAVIOUR_LABEL="Cache Behaviour" +COM_GETBIBLE_PROMPT_CACHE_CAPACITY_DESCRIPTION="Determine the maximum number of unique responses to be stored in the cache for each word (in the 'Basic Caching - Words/Language' strategy) or each verse (in the 'Advanced Caching - Verse/Context' strategy), before additional calls to OpenAI's API are halted. This setting helps manage your usage of OpenAI's services by setting a limit on the variety of cached responses." +COM_GETBIBLE_PROMPT_CACHE_CAPACITY_LABEL="Cache Capacity" +COM_GETBIBLE_PROMPT_CACHE_CAPACITY_NOTE_DESCRIPTION="

The 'Cache Capacity' feature is an essential tool designed to help you manage the usage of OpenAI's API services more efficiently and cost-effectively. It functions by setting an upper limit on the number of unique responses that the system stores in the cache before it stops making additional calls to OpenAI's API.

In the 'Basic Caching - Words/Language' strategy, a 'unique response' refers to the cached answer to a query about a specific word or phrase in a particular language. Once the number of cached responses for each unique word or phrase reaches the defined 'Cache Capacity', the system will not initiate new API calls for that word or phrase. Instead, it will deliver already cached responses, either at random or in total, depending on your 'Response Retrieval' settings.

Similarly, in the 'Advanced Caching - Verse/Context' strategy, a 'unique response' pertains to the cached answer to a query about a specific verse from a particular book, chapter, and translation of the Bible. When the cache capacity for each unique verse is reached, the system will refrain from making new API calls for that verse, and deliver the responses from the cache, again following your 'Response Retrieval' preferences.

By using the 'Cache Capacity' feature, you gain control over the diversity of responses that are cached and reduce the potential costs of repeated API calls. Please note that the 'Cache Capacity' applies separately to each word or phrase in the basic strategy, and to each verse in the advanced strategy, allowing for fine-tuned control over the caching process.

However, keep in mind that setting the 'Cache Capacity' too low might limit the variety of responses, while setting it too high may lead to increased caching costs. Therefore, it's crucial to find a balance that suits your specific needs and the nature of your application.

" +COM_GETBIBLE_PROMPT_CACHE_CAPACITY_NOTE_LABEL="Cache Capacity Details" +COM_GETBIBLE_PROMPT_CACHE_PERSISTENTLY_EXPANSIVE_CACHING_NOTE_DESCRIPTION="

Persistently Expansive Caching Strategy

Intended for use in testing or by experienced users, this strategy always caches responses but does not use the cache to respond to subsequent queries.

Our "Persistently Expansive Caching" strategy represents a significant shift in our caching paradigms. Contrary to 'none,' where caching was non-existent, and unlike 'basic' or 'advanced,' where previous responses are used to inform future ones, this strategy stores every interaction but doesn't utilize this cache to respond to subsequent similar queries. Here are some crucial aspects to bear in mind:

  • Function: Every query initiated will invoke an API call to OpenAI, and its response will be cached. However, unlike our other strategies, the system will not use this cache to respond to future similar queries. This strategy ensures a fresh interaction with OpenAI for each query, providing unique responses each time.
  • Pros: You will have a comprehensive record of all interactions with OpenAI, helpful for deep-dive analyses, or rigorous testing scenarios. This method ensures the most recent and contextually accurate responses from OpenAI at all times.
  • Cons: This method is the most resource-intensive and expansive of our caching strategies. Each query incurs a new cost, regardless of whether the same question has been asked before. It can rapidly escalate expenses if not managed prudently.
  • Warning: We still recommend using this strategy sparingly and mostly for testing purposes due to its extensive resource and cost implications. It should be employed by experienced users who fully understand its expansive nature and have strategies to manage the associated costs effectively.

While 'Persistently Expansive Caching' offers the advantage of fresh interactions and comprehensive caching, remember the virtues of 'Basic' and 'Advanced' caching strategies. These strategies balance cost, speed, and accuracy by smartly utilizing cache to respond to repeat queries, thereby optimizing your OpenAI interactions. Your choice should align with your unique requirements, your cost management strategies, and your desired balance between speed, cost, and accuracy.

" +COM_GETBIBLE_PROMPT_CACHE_PERSISTENTLY_EXPANSIVE_CACHING_NOTE_LABEL="Persistently Expansive Caching" +COM_GETBIBLE_PROMPT_CONTENT_DESCRIPTION="Content" +COM_GETBIBLE_PROMPT_CONTENT_HINT="add the prompt content here..." +COM_GETBIBLE_PROMPT_CONTENT_LABEL="Prompt" +COM_GETBIBLE_PROMPT_CREATED_BY_DESC="The user that created this Prompt." +COM_GETBIBLE_PROMPT_CREATED_BY_LABEL="Created By" +COM_GETBIBLE_PROMPT_CREATED_DATE_DESC="The date this Prompt was created." +COM_GETBIBLE_PROMPT_CREATED_DATE_LABEL="Created Date" +COM_GETBIBLE_PROMPT_EDIT="Editing the Prompt" +COM_GETBIBLE_PROMPT_ERROR_UNIQUE_ALIAS="Another Prompt has the same alias." +COM_GETBIBLE_PROMPT_FREQUENCY_PENALTY_DESCRIPTION="Penalty for new tokens based on their frequency in the text" +COM_GETBIBLE_PROMPT_FREQUENCY_PENALTY_LABEL="Frequency Penalty" +COM_GETBIBLE_PROMPT_FREQUENCY_PENALTY_NOTE_DESCRIPTION="

The "frequency_penalty" is another optional parameter that defaults to 0. This is also a value between -2.0 and 2.0. Positive values penalize new tokens based on their existing frequency in the text so far, decreasing the model's likelihood to repeat the same line verbatim.

  • For example, a high frequency penalty discourages the model from excessively repeating the same words or phrases, encouraging it to produce more diverse and creative text.
" +COM_GETBIBLE_PROMPT_FREQUENCY_PENALTY_NOTE_LABEL="Frequency Penalty" +COM_GETBIBLE_PROMPT_FREQUENCY_PENALTY_OVERRIDE_DESCRIPTION="Would you like to override the global frequency penalty value." +COM_GETBIBLE_PROMPT_FREQUENCY_PENALTY_OVERRIDE_LABEL="Frequency Penalty" +COM_GETBIBLE_PROMPT_FUNCTION="function" +COM_GETBIBLE_PROMPT_GPT35TURBO="gpt-3.5-turbo" +COM_GETBIBLE_PROMPT_GPT35TURBO0613="gpt-3.5-turbo-0613" +COM_GETBIBLE_PROMPT_GPT35TURBO16K="gpt-3.5-turbo-16k" +COM_GETBIBLE_PROMPT_GPT35TURBO16K0613="gpt-3.5-turbo-16k-0613" +COM_GETBIBLE_PROMPT_GPT4="gpt-4" +COM_GETBIBLE_PROMPT_GPT40613="gpt-4-0613" +COM_GETBIBLE_PROMPT_GPT432K="gpt-4-32k" +COM_GETBIBLE_PROMPT_GPT432K0613="gpt-4-32k-0613" +COM_GETBIBLE_PROMPT_GUID_DESCRIPTION="Globally Unique Identifier" +COM_GETBIBLE_PROMPT_GUID_HINT="Auto Generated" +COM_GETBIBLE_PROMPT_GUID_LABEL="GUID" +COM_GETBIBLE_PROMPT_ID="Id" +COM_GETBIBLE_PROMPT_INTEGRATION_DESCRIPTION="Determine the extent of Bible text that this prompt can encompass when interacting with OpenAI API." +COM_GETBIBLE_PROMPT_INTEGRATION_LABEL="Prompt Integration Scope" +COM_GETBIBLE_PROMPT_INTEGRATION_NOTE_DESCRIPTION="

The 'Prompt Integration Scope' feature is instrumental in defining the scope of the Bible text that your prompt can integrate with when querying the OpenAI API. Depending on your selection, this directly impacts how the application interacts with OpenAI's services and how responses are cached and presented to the user.

  • Word-Based: If you select this option, your prompt will be available whenever a single word is selected within the application. This strategy is more granular and allows for highly targeted queries based on individual words. However, this option can lead to a higher number of API calls if the selected word varies frequently. Note that the caching behavior in this case will be based on the selected word(s).
  • Verse-Based: Opting for this will make your prompt available for entire verses. It does not target individual words within a verse but treats the verse as a whole. This approach results in fewer API calls as long as the verse remains the same. Note that caching in this mode will be linked to the specific verse, not to individual words in the verse. This option only utilizes the placeholder [selected_verse].
  • Selection-Based: With this selection, your prompt becomes available when one or more words across one or more verses are selected. This gives maximum flexibility but can also lead to increased API calls, especially if the selections change frequently. The caching strategy in this case will be tied to the specific word(s) and verse(s) selected.

Choosing the right 'Prompt Integration Scope' is vital as it directly affects the positioning and availability of the prompt in the GUI, the interaction with the OpenAI API, and the caching strategy and behavior. Be sure to select the option that best suits the nature of your queries and the needs of your users.

" +COM_GETBIBLE_PROMPT_INTEGRATION_NOTE_LABEL="Prompt Integration Scope Details" +COM_GETBIBLE_PROMPT_MAX_TOKENS_DESCRIPTION="Maximum number of tokens to generate." +COM_GETBIBLE_PROMPT_MAX_TOKENS_LABEL="Max Tokens" +COM_GETBIBLE_PROMPT_MAX_TOKENS_NOTE_DESCRIPTION="

The "max_tokens" parameter sets the maximum number of tokens to generate in the chat completion. This is an optional parameter that defaults to infinity if not specified.

  • Note that the total length of both the input tokens and the generated tokens is limited by the model's context length. For instance, if a model has a context length of 100 tokens and you've used 20 tokens in your input, you could generate up to 80 additional tokens.
" +COM_GETBIBLE_PROMPT_MAX_TOKENS_NOTE_LABEL="Max Tokens" +COM_GETBIBLE_PROMPT_MAX_TOKENS_OVERRIDE_DESCRIPTION="Would you like to override the global max tokens value." +COM_GETBIBLE_PROMPT_MAX_TOKENS_OVERRIDE_LABEL="Max Tokens" +COM_GETBIBLE_PROMPT_MESSAGES_LABEL="Prompt Messages" +COM_GETBIBLE_PROMPT_MODEL_DESCRIPTION="ID of the model to use." +COM_GETBIBLE_PROMPT_MODEL_LABEL="Model" +COM_GETBIBLE_PROMPT_MODIFIED_BY_DESC="The last user that modified this Prompt." +COM_GETBIBLE_PROMPT_MODIFIED_BY_LABEL="Modified By" +COM_GETBIBLE_PROMPT_MODIFIED_DATE_DESC="The date this Prompt was modified." +COM_GETBIBLE_PROMPT_MODIFIED_DATE_LABEL="Modified Date" +COM_GETBIBLE_PROMPT_NAME_DESCRIPTION="Name" +COM_GETBIBLE_PROMPT_NAME_HINT="Name Here" +COM_GETBIBLE_PROMPT_NAME_LABEL="Name" +COM_GETBIBLE_PROMPT_NAME_MESSAGE="Error! Please add name here." +COM_GETBIBLE_PROMPT_NEW="A New Prompt" +COM_GETBIBLE_PROMPT_N_DESCRIPTION="The number of chat completion choices to generate" +COM_GETBIBLE_PROMPT_N_LABEL="Number AI Response Per/Prompt" +COM_GETBIBLE_PROMPT_N_NOTE_DESCRIPTION="

The "n" parameter determines how many independent completions to generate for each input message. This can be used when you want multiple distinct responses for a single prompt.

  • Setting "n" to 3, for instance, would make the model generate 3 separate responses for each input message.
" +COM_GETBIBLE_PROMPT_N_NOTE_LABEL="Number AI Response Per/Prompt" +COM_GETBIBLE_PROMPT_N_OVERRIDE_DESCRIPTION="Would you like to override the global n value." +COM_GETBIBLE_PROMPT_N_OVERRIDE_LABEL="Number AI Response Per/Prompt" +COM_GETBIBLE_PROMPT_OPENAI_DOCUMENTATION_NOTE_DESCRIPTION="

Please review the OpenAI API documentation for creating a chat conversation at this link. The document provides a comprehensive guide on parameters and methods to create chat completion using OpenAI's model. It includes instructions on:

  • How to post a request to create model responses
  • The format for the request body including role, model, messages, and optional parameters such as name, content, and function_call
  • Different ways to control the model's response such as temperature and top_p
  • How to control the number of generated chat completion choices, the stop sequences, and maximum number of tokens
  • Utilizing penalties and biases for managing the output
  • Additional features like streaming and user tracking for abuse monitoring
" +COM_GETBIBLE_PROMPT_OPENAI_DOCUMENTATION_NOTE_LABEL="Chat Completion (end-point)" +COM_GETBIBLE_PROMPT_OPENAI_PROMPTS_PLACEHOLDERS_ADVANCED_CACHING_NOTE_DESCRIPTION="

You can use the following placeholders in the prompts:

[translation_name][translation_language][translation_lcsh][translation_abbreviation][book_name][chapter_number][chapter_name][chapter_text][verse_number][verse_name][verse_text][selected_word_number][selected_word_text]
Utilizing these placeholders is crucial to enhancing the distinctiveness of responses from Open AI. Be aware that using the [chapter_text] placeholder loads the complete text of the chapter. This significantly increases the size of the query and might cause failures in certain circumstances. Exercise caution and restraint when implementing the [chapter_text] placeholder!" +COM_GETBIBLE_PROMPT_OPENAI_PROMPTS_PLACEHOLDERS_ADVANCED_CACHING_NOTE_LABEL="Prompts Placeholders (Advanced Caching)" +COM_GETBIBLE_PROMPT_OPENAI_PROMPTS_PLACEHOLDERS_BASIC_CACHING_NOTE_DESCRIPTION="

You can use the following placeholders in the prompts:

[translation_language][translation_lcsh][selected_word_text]
Utilizing these placeholders is crucial to enhancing the distinctiveness of responses from Open AI. Please not that only these placeholders are available in basic caching mode." +COM_GETBIBLE_PROMPT_OPENAI_PROMPTS_PLACEHOLDERS_BASIC_CACHING_NOTE_LABEL="Prompts Placeholders (Basic Caching)" +COM_GETBIBLE_PROMPT_OPENAI_PROMPTS_PLACEHOLDERS_NONE_CACHING_NOTE_DESCRIPTION="

You can use the following placeholders in the prompts:

[translation_name][translation_language][translation_lcsh][translation_abbreviation][book_name][chapter_number][chapter_name][chapter_text][verse_number][verse_name][verse_text][selected_word_number][selected_word_text]
Utilizing these placeholders is crucial to enhancing the distinctiveness of responses from Open AI. Be aware that using the [chapter_text] placeholder loads the complete text of the chapter. This significantly increases the size of the query and might cause failures in certain circumstances. Exercise caution and restraint when implementing the [chapter_text] placeholder!" +COM_GETBIBLE_PROMPT_OPENAI_PROMPTS_PLACEHOLDERS_NONE_CACHING_NOTE_LABEL="Prompts Placeholders (No Caching)" +COM_GETBIBLE_PROMPT_OPEN_AI="Open AI" +COM_GETBIBLE_PROMPT_ORDERING_LABEL="Ordering" +COM_GETBIBLE_PROMPT_ORG_TOKEN_DESCRIPTION="Your Organisation Token" +COM_GETBIBLE_PROMPT_ORG_TOKEN_HINT="// get your token from your Organisation on Open AI" +COM_GETBIBLE_PROMPT_ORG_TOKEN_LABEL="Openai Organisation Token" +COM_GETBIBLE_PROMPT_OVERRIDE="Override" +COM_GETBIBLE_PROMPT_PERMISSION="Permissions" +COM_GETBIBLE_PROMPT_PERSISTENTLY_EXPANSIVE_CACHING="Persistently Expansive Caching" +COM_GETBIBLE_PROMPT_PRESENCE_PENALTY_DESCRIPTION="Penalty for new tokens based on whether they appear in the text" +COM_GETBIBLE_PROMPT_PRESENCE_PENALTY_LABEL="Presence Penalty" +COM_GETBIBLE_PROMPT_PRESENCE_PENALTY_NOTE_DESCRIPTION="

The "presence_penalty" is an optional parameter that defaults to 0. This is a value between -2.0 and 2.0. Positive values penalize new tokens based on whether they appear in the text so far, increasing the model's likelihood to talk about new topics.

  • For example, a high presence penalty encourages the model to generate text involving a wider variety of topics or themes, rather than focusing on a single topic or repeatedly using the same phrases.
" +COM_GETBIBLE_PROMPT_PRESENCE_PENALTY_NOTE_LABEL="Presence Penalty" +COM_GETBIBLE_PROMPT_PRESENCE_PENALTY_OVERRIDE_DESCRIPTION="Would you like to override the global presence penalty value." +COM_GETBIBLE_PROMPT_PRESENCE_PENALTY_OVERRIDE_LABEL="Presence Penalty" +COM_GETBIBLE_PROMPT_PROMPT="Prompt" +COM_GETBIBLE_PROMPT_PUBLISHING="Publishing" +COM_GETBIBLE_PROMPT_RANDOM="Random" +COM_GETBIBLE_PROMPT_RESPONSE_RETRIEVAL_DESCRIPTION="Choose how cached responses are delivered: either a 'Total Retrieval' of all relevant cached responses or a 'Random Retrieval' of a single relevant response from the cache." +COM_GETBIBLE_PROMPT_RESPONSE_RETRIEVAL_LABEL="Response Retrieval" +COM_GETBIBLE_PROMPT_RESPONSE_RETRIEVAL_NOTE_DESCRIPTION="

The 'Response Retrieval' feature provides you with control over how cached responses are served when a cache hit occurs. You have two options to choose from:

  • Total Retrieval: This option delivers all cached responses that are relevant to a query. For instance, if multiple unique responses are stored in the cache for a particular word or verse, 'Total Retrieval' will present all of these responses.
  • Random Retrieval: With this selection, the system will pick and present a single relevant response from the cache at random for a given query.

These settings can be applied to both the 'Basic Caching - Words/Language' and the 'Advanced Caching - Verse/Context' strategies, adding an extra layer of flexibility to how you manage and utilize your cached data.

Remember, the choice between 'Total Retrieval' and 'Random Retrieval' can impact the user experience. 'Total Retrieval' may provide a more comprehensive overview of possible responses, while 'Random Retrieval' might offer a more streamlined and varied experience.

" +COM_GETBIBLE_PROMPT_RESPONSE_RETRIEVAL_NOTE_LABEL="Response Retrieval" +COM_GETBIBLE_PROMPT_ROLE_DESCRIPTION="Role" +COM_GETBIBLE_PROMPT_ROLE_LABEL="Prompt" +COM_GETBIBLE_PROMPT_SAVE_WARNING="Alias already existed so a number was added at the end. You can re-edit the Prompt to customise the alias." +COM_GETBIBLE_PROMPT_SELECTIONBASED="Selection-Based" +COM_GETBIBLE_PROMPT_SELECT_AN_OPTION="Select an option" +COM_GETBIBLE_PROMPT_STATUS="Status" +COM_GETBIBLE_PROMPT_SYSTEM="system" +COM_GETBIBLE_PROMPT_TEMPERATURE_DESCRIPTION="The sampling temperature to use" +COM_GETBIBLE_PROMPT_TEMPERATURE_LABEL="Temperature" +COM_GETBIBLE_PROMPT_TEMPERATURE_NOTE_DESCRIPTION="

The "temperature" is a parameter that controls the randomness of the model's output. Its value ranges between 0 and 2. A higher temperature value results in more randomness, while a lower value results in less randomness. This affects the selection of the next word during text generation.

  • At a higher value like 2, the model has a greater probability of picking less likely words, which may lead to more diverse and creative outputs.
  • At a lower value like 0.2, the model's output becomes more deterministic, primarily choosing words with the highest predicted probabilities, leading to more focused and predictable responses.
" +COM_GETBIBLE_PROMPT_TEMPERATURE_NOTE_LABEL="Temperature" +COM_GETBIBLE_PROMPT_TEMPERATURE_OVERRIDE_DESCRIPTION="Would you like to override the global temperature value." +COM_GETBIBLE_PROMPT_TEMPERATURE_OVERRIDE_LABEL="Temperature" +COM_GETBIBLE_PROMPT_TOKEN_DESCRIPTION="Your Openai Token" +COM_GETBIBLE_PROMPT_TOKEN_HINT="// get your token from Open AI" +COM_GETBIBLE_PROMPT_TOKEN_LABEL="Openai Token" +COM_GETBIBLE_PROMPT_TOKEN_OVERRIDE_DESCRIPTION="Would you like to override the global openai token value." +COM_GETBIBLE_PROMPT_TOKEN_OVERRIDE_LABEL="Openai Token" +COM_GETBIBLE_PROMPT_TOP_P_DESCRIPTION="The nucleus sampling parameter" +COM_GETBIBLE_PROMPT_TOP_P_LABEL="Top P" +COM_GETBIBLE_PROMPT_TOP_P_NOTE_DESCRIPTION="

The "top_p" parameter is used for "nucleus sampling," an alternative to the temperature-based sampling. It defines a threshold for the cumulative probability of the chosen tokens. Rather than considering all possible tokens for the next word, it only considers the smallest set of tokens whose cumulative probability exceeds the set "top_p" value.

  • Setting "top_p" to 0.1 means the model will only consider the tokens comprising the top 10% probability mass for the next word.
  • If "top_p" is set to 0.9, the model considers a wider range of tokens for the next word but still limits to those within the top 90% of the probability distribution.
" +COM_GETBIBLE_PROMPT_TOP_P_NOTE_LABEL="Top P" +COM_GETBIBLE_PROMPT_TOP_P_OVERRIDE_DESCRIPTION="Would you like to override the global top p value." +COM_GETBIBLE_PROMPT_TOP_P_OVERRIDE_LABEL="Top P" +COM_GETBIBLE_PROMPT_TOTAL="Total" +COM_GETBIBLE_PROMPT_USER="user" +COM_GETBIBLE_PROMPT_USE_GLOBAL="Use Global" +COM_GETBIBLE_PROMPT_VERSEBASED="Verse-Based" +COM_GETBIBLE_PROMPT_VERSION_DESC="A count of the number of times this Prompt has been revised." +COM_GETBIBLE_PROMPT_VERSION_LABEL="Version" +COM_GETBIBLE_PROMPT_WORDBASED="Word-Based" +COM_GETBIBLE_PUBLISHED="Published" +COM_GETBIBLE_SAVE_SUCCESS="Great! Item successfully saved." +COM_GETBIBLE_SAVE_WARNING="The value already existed so please select another." +COM_GETBIBLE_SELECT_AN_OPTION="Select an option" +COM_GETBIBLE_SESSION_KEY_COULD_NOT_BE_STORED="Session key could not be stored." +COM_GETBIBLE_SUBMENU_BOOKS="Books" +COM_GETBIBLE_SUBMENU_CHAPTERS="Chapters" +COM_GETBIBLE_SUBMENU_DASHBOARD="Dashboard" +COM_GETBIBLE_SUBMENU_LINKERS="Linkers" +COM_GETBIBLE_SUBMENU_NOTES="Notes" +COM_GETBIBLE_SUBMENU_OPEN_AI_RESPONSES="Open AI Responses" +COM_GETBIBLE_SUBMENU_PROMPTS="Prompts" +COM_GETBIBLE_SUBMENU_TAGGED_VERSES="Tagged Verses" +COM_GETBIBLE_SUBMENU_TAGS="Tags" +COM_GETBIBLE_SUBMENU_TRANSLATIONS="Translations" +COM_GETBIBLE_SUBMENU_VERSES="Verses" +COM_GETBIBLE_TAG="Tag" +COM_GETBIBLE_TAGGED_VERSE="Tagged Verse" +COM_GETBIBLE_TAGGED_VERSES="Tagged Verses" +COM_GETBIBLE_TAGGED_VERSES_ACCESS="Tagged Verses Access" +COM_GETBIBLE_TAGGED_VERSES_ACCESS_DESC="Allows the users in this group to access access tagged verses" +COM_GETBIBLE_TAGGED_VERSES_BATCH_OPTIONS="Batch process the selected Tagged Verses" +COM_GETBIBLE_TAGGED_VERSES_BATCH_TIP="All changes will be applied to all selected Tagged Verses" +COM_GETBIBLE_TAGGED_VERSES_BATCH_USE="Tagged Verses Batch Use" +COM_GETBIBLE_TAGGED_VERSES_BATCH_USE_DESC="Allows users in this group to use batch copy/update method of batch tagged verses" +COM_GETBIBLE_TAGGED_VERSES_CREATE="Tagged Verses Create" +COM_GETBIBLE_TAGGED_VERSES_CREATE_DESC="Allows the users in this group to create create tagged verses" +COM_GETBIBLE_TAGGED_VERSES_DASHBOARD_LIST="Tagged Verses Dashboard List" +COM_GETBIBLE_TAGGED_VERSES_DASHBOARD_LIST_DESC="Allows the users in this group to dashboard list of tagged verse" +COM_GETBIBLE_TAGGED_VERSES_DELETE="Tagged Verses Delete" +COM_GETBIBLE_TAGGED_VERSES_DELETE_DESC="Allows the users in this group to delete delete tagged verses" +COM_GETBIBLE_TAGGED_VERSES_EDIT="Tagged Verses Edit" +COM_GETBIBLE_TAGGED_VERSES_EDIT_ABBREVIATION="Tagged Verses Edit Abbreviation" +COM_GETBIBLE_TAGGED_VERSES_EDIT_ABBREVIATION_DESC="Allows the users in this group to edit abbreviation of tagged verse" +COM_GETBIBLE_TAGGED_VERSES_EDIT_ACCESS="Tagged Verses Edit Access" +COM_GETBIBLE_TAGGED_VERSES_EDIT_ACCESS_DESC="Allows the users in this group to change the access of the edit access tagged verses" +COM_GETBIBLE_TAGGED_VERSES_EDIT_BOOK_NR="Tagged Verses Edit Book Nr" +COM_GETBIBLE_TAGGED_VERSES_EDIT_BOOK_NR_DESC="Allows the users in this group to edit book nr of tagged verse" +COM_GETBIBLE_TAGGED_VERSES_EDIT_CHAPTER="Tagged Verses Edit Chapter" +COM_GETBIBLE_TAGGED_VERSES_EDIT_CHAPTER_DESC="Allows the users in this group to edit chapter of tagged verse" +COM_GETBIBLE_TAGGED_VERSES_EDIT_CREATED_BY="Tagged Verses Edit Created By" +COM_GETBIBLE_TAGGED_VERSES_EDIT_CREATED_BY_DESC="Allows the users in this group to update the created by of the edit created by tagged verses" +COM_GETBIBLE_TAGGED_VERSES_EDIT_CREATED_DATE="Tagged Verses Edit Created Date" +COM_GETBIBLE_TAGGED_VERSES_EDIT_CREATED_DATE_DESC="Allows the users in this group to update the created date of the edit created tagged verses" +COM_GETBIBLE_TAGGED_VERSES_EDIT_DESC="Allows the users in this group to edit the tagged verse" +COM_GETBIBLE_TAGGED_VERSES_EDIT_GUID="Tagged Verses Edit Guid" +COM_GETBIBLE_TAGGED_VERSES_EDIT_GUID_DESC="Allows the users in this group to edit guid of tagged verse" +COM_GETBIBLE_TAGGED_VERSES_EDIT_LINKER="Tagged Verses Edit Linker" +COM_GETBIBLE_TAGGED_VERSES_EDIT_LINKER_DESC="Allows the users in this group to edit linker of tagged verse" +COM_GETBIBLE_TAGGED_VERSES_EDIT_OWN="Tagged Verses Edit Own" +COM_GETBIBLE_TAGGED_VERSES_EDIT_OWN_DESC="Allows the users in this group to edit edit own tagged verses created by them" +COM_GETBIBLE_TAGGED_VERSES_EDIT_STATE="Tagged Verses Edit State" +COM_GETBIBLE_TAGGED_VERSES_EDIT_STATE_DESC="Allows the users in this group to update the state of the tagged verse" +COM_GETBIBLE_TAGGED_VERSES_EDIT_TAG="Tagged Verses Edit Tag" +COM_GETBIBLE_TAGGED_VERSES_EDIT_TAG_DESC="Allows the users in this group to edit tag of tagged verse" +COM_GETBIBLE_TAGGED_VERSES_EDIT_VERSE="Tagged Verses Edit Verse" +COM_GETBIBLE_TAGGED_VERSES_EDIT_VERSE_DESC="Allows the users in this group to edit verse of tagged verse" +COM_GETBIBLE_TAGGED_VERSES_EDIT_VERSION="Tagged Verses Edit Version" +COM_GETBIBLE_TAGGED_VERSES_EDIT_VERSION_DESC="Allows users in this group to edit versions of version tagged verses" +COM_GETBIBLE_TAGGED_VERSES_N_ITEMS_ARCHIVED="%s Tagged Verses archived." +COM_GETBIBLE_TAGGED_VERSES_N_ITEMS_ARCHIVED_1="%s Tagged Verse archived." +COM_GETBIBLE_TAGGED_VERSES_N_ITEMS_CHECKED_IN_0="No Tagged Verse successfully checked in." +COM_GETBIBLE_TAGGED_VERSES_N_ITEMS_CHECKED_IN_1="%d Tagged Verse successfully checked in." +COM_GETBIBLE_TAGGED_VERSES_N_ITEMS_CHECKED_IN_MORE="%d Tagged Verses successfully checked in." +COM_GETBIBLE_TAGGED_VERSES_N_ITEMS_DELETED="%s Tagged Verses deleted." +COM_GETBIBLE_TAGGED_VERSES_N_ITEMS_DELETED_1="%s Tagged Verse deleted." +COM_GETBIBLE_TAGGED_VERSES_N_ITEMS_FAILED_PUBLISHING="%s Tagged Verses failed publishing." +COM_GETBIBLE_TAGGED_VERSES_N_ITEMS_FAILED_PUBLISHING_1="%s Tagged Verse failed publishing." +COM_GETBIBLE_TAGGED_VERSES_N_ITEMS_FEATURED="%s Tagged Verses featured." +COM_GETBIBLE_TAGGED_VERSES_N_ITEMS_FEATURED_1="%s Tagged Verse featured." +COM_GETBIBLE_TAGGED_VERSES_N_ITEMS_PUBLISHED="%s Tagged Verses published." +COM_GETBIBLE_TAGGED_VERSES_N_ITEMS_PUBLISHED_1="%s Tagged Verse published." +COM_GETBIBLE_TAGGED_VERSES_N_ITEMS_TRASHED="%s Tagged Verses trashed." +COM_GETBIBLE_TAGGED_VERSES_N_ITEMS_TRASHED_1="%s Tagged Verse trashed." +COM_GETBIBLE_TAGGED_VERSES_N_ITEMS_UNFEATURED="%s Tagged Verses unfeatured." +COM_GETBIBLE_TAGGED_VERSES_N_ITEMS_UNFEATURED_1="%s Tagged Verse unfeatured." +COM_GETBIBLE_TAGGED_VERSES_N_ITEMS_UNPUBLISHED="%s Tagged Verses unpublished." +COM_GETBIBLE_TAGGED_VERSES_N_ITEMS_UNPUBLISHED_1="%s Tagged Verse unpublished." +COM_GETBIBLE_TAGGED_VERSES_REFERENCE="Reference" +COM_GETBIBLE_TAGGED_VERSES_SUBMENU="Tagged Verses Submenu" +COM_GETBIBLE_TAGGED_VERSES_SUBMENU_DESC="Allows the users in this group to submenu of tagged verse" +COM_GETBIBLE_TAGGED_VERSE_ABBREVIATION_DESCRIPTION="Select a Bible translation" +COM_GETBIBLE_TAGGED_VERSE_ABBREVIATION_LABEL="Translation" +COM_GETBIBLE_TAGGED_VERSE_ACCESS_LABEL="Access" +COM_GETBIBLE_TAGGED_VERSE_ALREADY_EXIST_BUT_COULD_NOT_BE_REACTIVATED="Tagged verse already exist, but could not be reactivated." +COM_GETBIBLE_TAGGED_VERSE_BOOK_NR_DESCRIPTION="Select the book number" +COM_GETBIBLE_TAGGED_VERSE_BOOK_NR_LABEL="Book Number" +COM_GETBIBLE_TAGGED_VERSE_CHAPTER_DESCRIPTION="Select the chapter number" +COM_GETBIBLE_TAGGED_VERSE_CHAPTER_LABEL="Chapter" +COM_GETBIBLE_TAGGED_VERSE_CREATED_BY_DESC="The user that created this Tagged Verse." +COM_GETBIBLE_TAGGED_VERSE_CREATED_BY_LABEL="Created By" +COM_GETBIBLE_TAGGED_VERSE_CREATED_DATE_DESC="The date this Tagged Verse was created." +COM_GETBIBLE_TAGGED_VERSE_CREATED_DATE_LABEL="Created Date" +COM_GETBIBLE_TAGGED_VERSE_DETAILS="Details" +COM_GETBIBLE_TAGGED_VERSE_EDIT="Editing the Tagged Verse" +COM_GETBIBLE_TAGGED_VERSE_ERROR_UNIQUE_ALIAS="Another Tagged Verse has the same alias." +COM_GETBIBLE_TAGGED_VERSE_GUID_DESCRIPTION="Globally Unique Identifier" +COM_GETBIBLE_TAGGED_VERSE_GUID_HINT="Auto Generated" +COM_GETBIBLE_TAGGED_VERSE_GUID_LABEL="GUID" +COM_GETBIBLE_TAGGED_VERSE_ID="Id" +COM_GETBIBLE_TAGGED_VERSE_LINKER_DESCRIPTION="Globally Unique Linker" +COM_GETBIBLE_TAGGED_VERSE_LINKER_LABEL="Linker" +COM_GETBIBLE_TAGGED_VERSE_MODIFIED_BY_DESC="The last user that modified this Tagged Verse." +COM_GETBIBLE_TAGGED_VERSE_MODIFIED_BY_LABEL="Modified By" +COM_GETBIBLE_TAGGED_VERSE_MODIFIED_DATE_DESC="The date this Tagged Verse was modified." +COM_GETBIBLE_TAGGED_VERSE_MODIFIED_DATE_LABEL="Modified Date" +COM_GETBIBLE_TAGGED_VERSE_NEW="A New Tagged Verse" +COM_GETBIBLE_TAGGED_VERSE_ORDERING_LABEL="Ordering" +COM_GETBIBLE_TAGGED_VERSE_PERMISSION="Permissions" +COM_GETBIBLE_TAGGED_VERSE_PRIVATE="Private" +COM_GETBIBLE_TAGGED_VERSE_PUBLIC="Public" +COM_GETBIBLE_TAGGED_VERSE_PUBLISHING="Publishing" +COM_GETBIBLE_TAGGED_VERSE_SAVE_WARNING="Alias already existed so a number was added at the end. You can re-edit the Tagged Verse to customise the alias." +COM_GETBIBLE_TAGGED_VERSE_STATUS="Status" +COM_GETBIBLE_TAGGED_VERSE_TAG_LABEL="Tag" +COM_GETBIBLE_TAGGED_VERSE_VERSE_DESCRIPTION="Select the verse number" +COM_GETBIBLE_TAGGED_VERSE_VERSE_LABEL="Verse" +COM_GETBIBLE_TAGGED_VERSE_VERSION_DESC="A count of the number of times this Tagged Verse has been revised." +COM_GETBIBLE_TAGGED_VERSE_VERSION_LABEL="Version" +COM_GETBIBLE_TAGS="Tags" +COM_GETBIBLE_TAGS_ACCESS="Tags Access" +COM_GETBIBLE_TAGS_ACCESS_DESC="Allows the users in this group to access access tags" +COM_GETBIBLE_TAGS_BATCH_OPTIONS="Batch process the selected Tags" +COM_GETBIBLE_TAGS_BATCH_TIP="All changes will be applied to all selected Tags" +COM_GETBIBLE_TAGS_BATCH_USE="Tags Batch Use" +COM_GETBIBLE_TAGS_BATCH_USE_DESC="Allows users in this group to use batch copy/update method of batch tags" +COM_GETBIBLE_TAGS_CREATE="Tags Create" +COM_GETBIBLE_TAGS_CREATE_DESC="Allows the users in this group to create create tags" +COM_GETBIBLE_TAGS_DASHBOARD_LIST="Tags Dashboard List" +COM_GETBIBLE_TAGS_DASHBOARD_LIST_DESC="Allows the users in this group to dashboard list of tag" +COM_GETBIBLE_TAGS_DELETE="Tags Delete" +COM_GETBIBLE_TAGS_DELETE_DESC="Allows the users in this group to delete delete tags" +COM_GETBIBLE_TAGS_EDIT="Tags Edit" +COM_GETBIBLE_TAGS_EDIT_ACCESS="Tags Edit Access" +COM_GETBIBLE_TAGS_EDIT_ACCESS_DESC="Allows the users in this group to change the access of the edit access tags" +COM_GETBIBLE_TAGS_EDIT_CREATED_BY="Tags Edit Created By" +COM_GETBIBLE_TAGS_EDIT_CREATED_BY_DESC="Allows the users in this group to update the created by of the edit created by tags" +COM_GETBIBLE_TAGS_EDIT_CREATED_DATE="Tags Edit Created Date" +COM_GETBIBLE_TAGS_EDIT_CREATED_DATE_DESC="Allows the users in this group to update the created date of the edit created tags" +COM_GETBIBLE_TAGS_EDIT_DESC="Allows the users in this group to edit the tag" +COM_GETBIBLE_TAGS_EDIT_DESCRIPTION="Tags Edit Description" +COM_GETBIBLE_TAGS_EDIT_DESCRIPTION_DESC="Allows the users in this group to edit description of tag" +COM_GETBIBLE_TAGS_EDIT_GUID="Tags Edit Guid" +COM_GETBIBLE_TAGS_EDIT_GUID_DESC="Allows the users in this group to edit guid of tag" +COM_GETBIBLE_TAGS_EDIT_LINKER="Tags Edit Linker" +COM_GETBIBLE_TAGS_EDIT_LINKER_DESC="Allows the users in this group to edit linker of tag" +COM_GETBIBLE_TAGS_EDIT_NAME="Tags Edit Name" +COM_GETBIBLE_TAGS_EDIT_NAME_DESC="Allows the users in this group to edit name of tag" +COM_GETBIBLE_TAGS_EDIT_OWN="Tags Edit Own" +COM_GETBIBLE_TAGS_EDIT_OWN_DESC="Allows the users in this group to edit edit own tags created by them" +COM_GETBIBLE_TAGS_EDIT_STATE="Tags Edit State" +COM_GETBIBLE_TAGS_EDIT_STATE_DESC="Allows the users in this group to update the state of the tag" +COM_GETBIBLE_TAGS_EDIT_VERSION="Tags Edit Version" +COM_GETBIBLE_TAGS_EDIT_VERSION_DESC="Allows users in this group to edit versions of version tags" +COM_GETBIBLE_TAGS_N_ITEMS_ARCHIVED="%s Tags archived." +COM_GETBIBLE_TAGS_N_ITEMS_ARCHIVED_1="%s Tag archived." +COM_GETBIBLE_TAGS_N_ITEMS_CHECKED_IN_0="No Tag successfully checked in." +COM_GETBIBLE_TAGS_N_ITEMS_CHECKED_IN_1="%d Tag successfully checked in." +COM_GETBIBLE_TAGS_N_ITEMS_CHECKED_IN_MORE="%d Tags successfully checked in." +COM_GETBIBLE_TAGS_N_ITEMS_DELETED="%s Tags deleted." +COM_GETBIBLE_TAGS_N_ITEMS_DELETED_1="%s Tag deleted." +COM_GETBIBLE_TAGS_N_ITEMS_FAILED_PUBLISHING="%s Tags failed publishing." +COM_GETBIBLE_TAGS_N_ITEMS_FAILED_PUBLISHING_1="%s Tag failed publishing." +COM_GETBIBLE_TAGS_N_ITEMS_FEATURED="%s Tags featured." +COM_GETBIBLE_TAGS_N_ITEMS_FEATURED_1="%s Tag featured." +COM_GETBIBLE_TAGS_N_ITEMS_PUBLISHED="%s Tags published." +COM_GETBIBLE_TAGS_N_ITEMS_PUBLISHED_1="%s Tag published." +COM_GETBIBLE_TAGS_N_ITEMS_TRASHED="%s Tags trashed." +COM_GETBIBLE_TAGS_N_ITEMS_TRASHED_1="%s Tag trashed." +COM_GETBIBLE_TAGS_N_ITEMS_UNFEATURED="%s Tags unfeatured." +COM_GETBIBLE_TAGS_N_ITEMS_UNFEATURED_1="%s Tag unfeatured." +COM_GETBIBLE_TAGS_N_ITEMS_UNPUBLISHED="%s Tags unpublished." +COM_GETBIBLE_TAGS_N_ITEMS_UNPUBLISHED_1="%s Tag unpublished." +COM_GETBIBLE_TAGS_SUBMENU="Tags Submenu" +COM_GETBIBLE_TAGS_SUBMENU_DESC="Allows the users in this group to submenu of tag" +COM_GETBIBLE_TAG_ACCESS_LABEL="Access" +COM_GETBIBLE_TAG_ALREADY_EXIST_BUT_COULD_NOT_BE_REACTIVATED="Tag already exist, but could not be reactivated." +COM_GETBIBLE_TAG_CREATED_BY_DESC="The user that created this Tag." +COM_GETBIBLE_TAG_CREATED_BY_LABEL="Created By" +COM_GETBIBLE_TAG_CREATED_DATE_DESC="The date this Tag was created." +COM_GETBIBLE_TAG_CREATED_DATE_LABEL="Created Date" +COM_GETBIBLE_TAG_DESCRIPTION_DESCRIPTION="Add Description Here" +COM_GETBIBLE_TAG_DESCRIPTION_HINT="Add Description Here" +COM_GETBIBLE_TAG_DESCRIPTION_LABEL="Description" +COM_GETBIBLE_TAG_DETAILS="Details" +COM_GETBIBLE_TAG_EDIT="Editing the Tag" +COM_GETBIBLE_TAG_ERROR_UNIQUE_ALIAS="Another Tag has the same alias." +COM_GETBIBLE_TAG_GUID_DESCRIPTION="Globally Unique Identifier" +COM_GETBIBLE_TAG_GUID_HINT="Auto Generated" +COM_GETBIBLE_TAG_GUID_LABEL="GUID" +COM_GETBIBLE_TAG_ID="Id" +COM_GETBIBLE_TAG_LINKER_DESCRIPTION="Globally Unique Linker" +COM_GETBIBLE_TAG_LINKER_LABEL="Linker" +COM_GETBIBLE_TAG_MODIFIED_BY_DESC="The last user that modified this Tag." +COM_GETBIBLE_TAG_MODIFIED_BY_LABEL="Modified By" +COM_GETBIBLE_TAG_MODIFIED_DATE_DESC="The date this Tag was modified." +COM_GETBIBLE_TAG_MODIFIED_DATE_LABEL="Modified Date" +COM_GETBIBLE_TAG_NAME_HINT="Name Here" +COM_GETBIBLE_TAG_NAME_LABEL="Name" +COM_GETBIBLE_TAG_NAME_MESSAGE="Error! Please add name here." +COM_GETBIBLE_TAG_NEW="A New Tag" +COM_GETBIBLE_TAG_ORDERING_LABEL="Ordering" +COM_GETBIBLE_TAG_PERMISSION="Permissions" +COM_GETBIBLE_TAG_PRIVATE="Private" +COM_GETBIBLE_TAG_PUBLIC="Public" +COM_GETBIBLE_TAG_PUBLISHING="Publishing" +COM_GETBIBLE_TAG_SAVE_WARNING="Alias already existed so a number was added at the end. You can re-edit the Tag to customise the alias." +COM_GETBIBLE_TAG_STATUS="Status" +COM_GETBIBLE_TAG_VERSION_DESC="A count of the number of times this Tag has been revised." +COM_GETBIBLE_TAG_VERSION_LABEL="Version" +COM_GETBIBLE_THE_NOTE_WAS_SUCCESSFULLY_CREATED="The note was successfully created." +COM_GETBIBLE_THE_NOTE_WAS_SUCCESSFULLY_UPDATED="The note was successfully updated." +COM_GETBIBLE_THE_NOTICE_BOARD_IS_LOADING="The notice board is loading" +COM_GETBIBLE_THE_README_IS_LOADING="The readme is loading" +COM_GETBIBLE_THE_TAG_SELECTED_IS_NOT_ACTIVE_PLEASE_SELECT_AN_ACTIVE_TAG="The tag selected is not active, please select an active tag." +COM_GETBIBLE_THE_TAG_WAS_SUCCESSFULLY_REMOVED_FROM_THE_VERSE="The tag was successfully removed from the verse." +COM_GETBIBLE_THE_TAG_WAS_SUCCESSFULLY_SET="The tag was successfully set." +COM_GETBIBLE_THE_VERSE_WAS_SUCCESSFULLY_TAGGED="The verse was successfully tagged." +COM_GETBIBLE_THE_WIKI_CAN_ONLY_BE_LOADED_WHEN_YOUR_JCB_SYSTEM_HAS_INTERNET_CONNECTION="The wiki can only be loaded when your JCB system has internet connection." +COM_GETBIBLE_THE_WIKI_IS_LOADING="The wiki is loading" +COM_GETBIBLE_THIS_IS_A_GLOBAL_TAG_SET_BY_US_AT_BSB_FOR_YOUR_CONVENIENCE_WE_HOLD_THE_PRIVILEGE_TO_MODIFY_THESE_TAGS_IF_YOU_BELIEVE_ITS_SET_IN_ERROR_KINDLY_INFORM_US="This is a global tag, set by us at %s for your convenience. We hold the privilege to modify these tags. If you believe it's set in error, kindly inform us." +COM_GETBIBLE_THIS_TAG_COULD_NOT_BE_REMOVED="This tag could not be removed." +COM_GETBIBLE_TRANSLATION="Translation" +COM_GETBIBLE_TRANSLATIONS="Translations" +COM_GETBIBLE_TRANSLATIONS_ACCESS="Translations Access" +COM_GETBIBLE_TRANSLATIONS_ACCESS_DESC="Allows the users in this group to access access translations" +COM_GETBIBLE_TRANSLATIONS_BATCH_OPTIONS="Batch process the selected Translations" +COM_GETBIBLE_TRANSLATIONS_BATCH_TIP="All changes will be applied to all selected Translations" +COM_GETBIBLE_TRANSLATIONS_BATCH_USE="Translations Batch Use" +COM_GETBIBLE_TRANSLATIONS_BATCH_USE_DESC="Allows users in this group to use batch copy/update method of batch translations" +COM_GETBIBLE_TRANSLATIONS_CREATE="Translations Create" +COM_GETBIBLE_TRANSLATIONS_CREATE_DESC="Allows the users in this group to create create translations" +COM_GETBIBLE_TRANSLATIONS_DASHBOARD_LIST="Translations Dashboard List" +COM_GETBIBLE_TRANSLATIONS_DASHBOARD_LIST_DESC="Allows the users in this group to dashboard list of translation" +COM_GETBIBLE_TRANSLATIONS_DELETE="Translations Delete" +COM_GETBIBLE_TRANSLATIONS_DELETE_DESC="Allows the users in this group to delete delete translations" +COM_GETBIBLE_TRANSLATIONS_EDIT="Translations Edit" +COM_GETBIBLE_TRANSLATIONS_EDIT_ABBREVIATION="Translations Edit Abbreviation" +COM_GETBIBLE_TRANSLATIONS_EDIT_ABBREVIATION_DESC="Allows the users in this group to edit abbreviation of translation" +COM_GETBIBLE_TRANSLATIONS_EDIT_CREATED_BY="Translations Edit Created By" +COM_GETBIBLE_TRANSLATIONS_EDIT_CREATED_BY_DESC="Allows the users in this group to update the created by of the edit created by translations" +COM_GETBIBLE_TRANSLATIONS_EDIT_CREATED_DATE="Translations Edit Created Date" +COM_GETBIBLE_TRANSLATIONS_EDIT_CREATED_DATE_DESC="Allows the users in this group to update the created date of the edit created translations" +COM_GETBIBLE_TRANSLATIONS_EDIT_DESC="Allows the users in this group to edit the translation" +COM_GETBIBLE_TRANSLATIONS_EDIT_DIRECTION="Translations Edit Direction" +COM_GETBIBLE_TRANSLATIONS_EDIT_DIRECTION_DESC="Allows the users in this group to edit direction of translation" +COM_GETBIBLE_TRANSLATIONS_EDIT_DISTRIBUTION_ABBREVIATION="Translations Edit Distribution Abbreviation" +COM_GETBIBLE_TRANSLATIONS_EDIT_DISTRIBUTION_ABBREVIATION_DESC="Allows the users in this group to edit distribution abbreviation of translation" +COM_GETBIBLE_TRANSLATIONS_EDIT_DISTRIBUTION_ABOUT="Translations Edit Distribution About" +COM_GETBIBLE_TRANSLATIONS_EDIT_DISTRIBUTION_ABOUT_DESC="Allows the users in this group to edit distribution about of translation" +COM_GETBIBLE_TRANSLATIONS_EDIT_DISTRIBUTION_HISTORY="Translations Edit Distribution History" +COM_GETBIBLE_TRANSLATIONS_EDIT_DISTRIBUTION_HISTORY_DESC="Allows the users in this group to edit distribution history of translation" +COM_GETBIBLE_TRANSLATIONS_EDIT_DISTRIBUTION_LCSH="Translations Edit Distribution Lcsh" +COM_GETBIBLE_TRANSLATIONS_EDIT_DISTRIBUTION_LCSH_DESC="Allows the users in this group to edit distribution lcsh of translation" +COM_GETBIBLE_TRANSLATIONS_EDIT_DISTRIBUTION_LICENSE="Translations Edit Distribution License" +COM_GETBIBLE_TRANSLATIONS_EDIT_DISTRIBUTION_LICENSE_DESC="Allows the users in this group to edit distribution license of translation" +COM_GETBIBLE_TRANSLATIONS_EDIT_DISTRIBUTION_SOURCE="Translations Edit Distribution Source" +COM_GETBIBLE_TRANSLATIONS_EDIT_DISTRIBUTION_SOURCETYPE="Translations Edit Distribution Sourcetype" +COM_GETBIBLE_TRANSLATIONS_EDIT_DISTRIBUTION_SOURCETYPE_DESC="Allows the users in this group to edit distribution sourcetype of translation" +COM_GETBIBLE_TRANSLATIONS_EDIT_DISTRIBUTION_SOURCE_DESC="Allows the users in this group to edit distribution source of translation" +COM_GETBIBLE_TRANSLATIONS_EDIT_DISTRIBUTION_VERSIFICATION="Translations Edit Distribution Versification" +COM_GETBIBLE_TRANSLATIONS_EDIT_DISTRIBUTION_VERSIFICATION_DESC="Allows the users in this group to edit distribution versification of translation" +COM_GETBIBLE_TRANSLATIONS_EDIT_DISTRIBUTION_VERSION="Translations Edit Distribution Version" +COM_GETBIBLE_TRANSLATIONS_EDIT_DISTRIBUTION_VERSION_DATE="Translations Edit Distribution Version Date" +COM_GETBIBLE_TRANSLATIONS_EDIT_DISTRIBUTION_VERSION_DATE_DESC="Allows the users in this group to edit distribution version date of translation" +COM_GETBIBLE_TRANSLATIONS_EDIT_DISTRIBUTION_VERSION_DESC="Allows the users in this group to edit distribution version of translation" +COM_GETBIBLE_TRANSLATIONS_EDIT_ENCODING="Translations Edit Encoding" +COM_GETBIBLE_TRANSLATIONS_EDIT_ENCODING_DESC="Allows the users in this group to edit encoding of translation" +COM_GETBIBLE_TRANSLATIONS_EDIT_LANG="Translations Edit Lang" +COM_GETBIBLE_TRANSLATIONS_EDIT_LANGUAGE="Translations Edit Language" +COM_GETBIBLE_TRANSLATIONS_EDIT_LANGUAGE_DESC="Allows the users in this group to edit language of translation" +COM_GETBIBLE_TRANSLATIONS_EDIT_LANG_DESC="Allows the users in this group to edit lang of translation" +COM_GETBIBLE_TRANSLATIONS_EDIT_OWN="Translations Edit Own" +COM_GETBIBLE_TRANSLATIONS_EDIT_OWN_DESC="Allows the users in this group to edit edit own translations created by them" +COM_GETBIBLE_TRANSLATIONS_EDIT_SHA="Translations Edit Sha" +COM_GETBIBLE_TRANSLATIONS_EDIT_SHA_DESC="Allows the users in this group to edit sha of translation" +COM_GETBIBLE_TRANSLATIONS_EDIT_STATE="Translations Edit State" +COM_GETBIBLE_TRANSLATIONS_EDIT_STATE_DESC="Allows the users in this group to update the state of the translation" +COM_GETBIBLE_TRANSLATIONS_EDIT_TRANSLATION="Translations Edit Translation" +COM_GETBIBLE_TRANSLATIONS_EDIT_TRANSLATION_DESC="Allows the users in this group to edit translation of translation" +COM_GETBIBLE_TRANSLATIONS_N_ITEMS_ARCHIVED="%s Translations archived." +COM_GETBIBLE_TRANSLATIONS_N_ITEMS_ARCHIVED_1="%s Translation archived." +COM_GETBIBLE_TRANSLATIONS_N_ITEMS_CHECKED_IN_0="No Translation successfully checked in." +COM_GETBIBLE_TRANSLATIONS_N_ITEMS_CHECKED_IN_1="%d Translation successfully checked in." +COM_GETBIBLE_TRANSLATIONS_N_ITEMS_CHECKED_IN_MORE="%d Translations successfully checked in." +COM_GETBIBLE_TRANSLATIONS_N_ITEMS_DELETED="%s Translations deleted." +COM_GETBIBLE_TRANSLATIONS_N_ITEMS_DELETED_1="%s Translation deleted." +COM_GETBIBLE_TRANSLATIONS_N_ITEMS_FAILED_PUBLISHING="%s Translations failed publishing." +COM_GETBIBLE_TRANSLATIONS_N_ITEMS_FAILED_PUBLISHING_1="%s Translation failed publishing." +COM_GETBIBLE_TRANSLATIONS_N_ITEMS_FEATURED="%s Translations featured." +COM_GETBIBLE_TRANSLATIONS_N_ITEMS_FEATURED_1="%s Translation featured." +COM_GETBIBLE_TRANSLATIONS_N_ITEMS_PUBLISHED="%s Translations published." +COM_GETBIBLE_TRANSLATIONS_N_ITEMS_PUBLISHED_1="%s Translation published." +COM_GETBIBLE_TRANSLATIONS_N_ITEMS_TRASHED="%s Translations trashed." +COM_GETBIBLE_TRANSLATIONS_N_ITEMS_TRASHED_1="%s Translation trashed." +COM_GETBIBLE_TRANSLATIONS_N_ITEMS_UNFEATURED="%s Translations unfeatured." +COM_GETBIBLE_TRANSLATIONS_N_ITEMS_UNFEATURED_1="%s Translation unfeatured." +COM_GETBIBLE_TRANSLATIONS_N_ITEMS_UNPUBLISHED="%s Translations unpublished." +COM_GETBIBLE_TRANSLATIONS_N_ITEMS_UNPUBLISHED_1="%s Translation unpublished." +COM_GETBIBLE_TRANSLATIONS_SUBMENU="Translations Submenu" +COM_GETBIBLE_TRANSLATIONS_SUBMENU_DESC="Allows the users in this group to submenu of translation" +COM_GETBIBLE_TRANSLATION_ABBREVIATION_DESCRIPTION="Enter some abbreviation" +COM_GETBIBLE_TRANSLATION_ABBREVIATION_HINT="kjv" +COM_GETBIBLE_TRANSLATION_ABBREVIATION_LABEL="Abbreviation" +COM_GETBIBLE_TRANSLATION_ABBREVIATION_MESSAGE="Error! Please add some abbreviation here." +COM_GETBIBLE_TRANSLATION_CREATED_BY_DESC="The user that created this Translation." +COM_GETBIBLE_TRANSLATION_CREATED_BY_LABEL="Created By" +COM_GETBIBLE_TRANSLATION_CREATED_DATE_DESC="The date this Translation was created." +COM_GETBIBLE_TRANSLATION_CREATED_DATE_LABEL="Created Date" +COM_GETBIBLE_TRANSLATION_DESCRIPTION_HINT="history version desc" +COM_GETBIBLE_TRANSLATION_DESCRIPTION_LABEL="Description" +COM_GETBIBLE_TRANSLATION_DESCRIPTION_MESSAGE="Error! Please add some history version description here." +COM_GETBIBLE_TRANSLATION_DETAILS="Details" +COM_GETBIBLE_TRANSLATION_DEXTROSINISTRAL_RTL="Dextrosinistral (RTL)" +COM_GETBIBLE_TRANSLATION_DIRECTION_DESCRIPTION="Select Right-to-Left (RTL) or Left-to-Right (LTR)" +COM_GETBIBLE_TRANSLATION_DIRECTION_LABEL="Directional" +COM_GETBIBLE_TRANSLATION_DISTRIBUTION_ABBREVIATION_DESCRIPTION="Enter some distribution abbreviation" +COM_GETBIBLE_TRANSLATION_DISTRIBUTION_ABBREVIATION_HINT="kjv" +COM_GETBIBLE_TRANSLATION_DISTRIBUTION_ABBREVIATION_LABEL="Distribution Abbreviation" +COM_GETBIBLE_TRANSLATION_DISTRIBUTION_ABBREVIATION_MESSAGE="Error! Please add some distribution abbreviation here." +COM_GETBIBLE_TRANSLATION_DISTRIBUTION_ABOUT_DESCRIPTION="Enter some distribution about" +COM_GETBIBLE_TRANSLATION_DISTRIBUTION_ABOUT_LABEL="Distribution About" +COM_GETBIBLE_TRANSLATION_DISTRIBUTION_ABOUT_MESSAGE="Error! Please add some distribution about here." +COM_GETBIBLE_TRANSLATION_DISTRIBUTION_HISTORY_LABEL="Distribution History" +COM_GETBIBLE_TRANSLATION_DISTRIBUTION_LCSH_DESCRIPTION="Enter some distribution lcsh" +COM_GETBIBLE_TRANSLATION_DISTRIBUTION_LCSH_HINT="Bible. English." +COM_GETBIBLE_TRANSLATION_DISTRIBUTION_LCSH_LABEL="Library of Congress Subject Headings" +COM_GETBIBLE_TRANSLATION_DISTRIBUTION_LCSH_MESSAGE="Error! Please add some distribution lcsh here." +COM_GETBIBLE_TRANSLATION_DISTRIBUTION_LICENSE_DESCRIPTION="Add Translation Distribution License Here" +COM_GETBIBLE_TRANSLATION_DISTRIBUTION_LICENSE_HINT="Add Distribution License Here" +COM_GETBIBLE_TRANSLATION_DISTRIBUTION_LICENSE_LABEL="Distribution License" +COM_GETBIBLE_TRANSLATION_DISTRIBUTION_SOURCETYPE_DESCRIPTION="Enter some distribution source type" +COM_GETBIBLE_TRANSLATION_DISTRIBUTION_SOURCETYPE_HINT="OSIS" +COM_GETBIBLE_TRANSLATION_DISTRIBUTION_SOURCETYPE_LABEL="Distribution Source Type" +COM_GETBIBLE_TRANSLATION_DISTRIBUTION_SOURCETYPE_MESSAGE="Error! Please add some distribution source type here." +COM_GETBIBLE_TRANSLATION_DISTRIBUTION_SOURCE_DESCRIPTION="Enter some distribution source" +COM_GETBIBLE_TRANSLATION_DISTRIBUTION_SOURCE_LABEL="Distribution Source" +COM_GETBIBLE_TRANSLATION_DISTRIBUTION_SOURCE_MESSAGE="Error! Please add some distribution source here." +COM_GETBIBLE_TRANSLATION_DISTRIBUTION_VERSIFICATION_DESCRIPTION="Enter some distribution versification" +COM_GETBIBLE_TRANSLATION_DISTRIBUTION_VERSIFICATION_LABEL="Distribution Versification" +COM_GETBIBLE_TRANSLATION_DISTRIBUTION_VERSIFICATION_MESSAGE="Error! Please add some distribution versification here." +COM_GETBIBLE_TRANSLATION_DISTRIBUTION_VERSION_DATE_DESCRIPTION="Enter some distribution version date" +COM_GETBIBLE_TRANSLATION_DISTRIBUTION_VERSION_DATE_HINT="2002-09-05" +COM_GETBIBLE_TRANSLATION_DISTRIBUTION_VERSION_DATE_LABEL="Distribution Version Date" +COM_GETBIBLE_TRANSLATION_DISTRIBUTION_VERSION_DATE_MESSAGE="Error! Please add some distribution version date here." +COM_GETBIBLE_TRANSLATION_DISTRIBUTION_VERSION_DESCRIPTION="Enter some distribution version" +COM_GETBIBLE_TRANSLATION_DISTRIBUTION_VERSION_HINT="1.0" +COM_GETBIBLE_TRANSLATION_DISTRIBUTION_VERSION_LABEL="Distribution Version" +COM_GETBIBLE_TRANSLATION_DISTRIBUTION_VERSION_MESSAGE="Error! Please add some distribution version here." +COM_GETBIBLE_TRANSLATION_ENCODING_DESCRIPTION="Enter some encoding" +COM_GETBIBLE_TRANSLATION_ENCODING_LABEL="Encoding" +COM_GETBIBLE_TRANSLATION_ENCODING_MESSAGE="Error! Please add some encoding here." +COM_GETBIBLE_TRANSLATION_ERROR_UNIQUE_ALIAS="Another Translation has the same alias." +COM_GETBIBLE_TRANSLATION_ID="Id" +COM_GETBIBLE_TRANSLATION_LANGUAGE_DESCRIPTION="The translation language." +COM_GETBIBLE_TRANSLATION_LANGUAGE_HINT="English" +COM_GETBIBLE_TRANSLATION_LANGUAGE_LABEL="Language" +COM_GETBIBLE_TRANSLATION_LANGUAGE_MESSAGE="Error! Please add language tag here." +COM_GETBIBLE_TRANSLATION_LANG_DESCRIPTION="Enter some language abbreviation" +COM_GETBIBLE_TRANSLATION_LANG_HINT="en" +COM_GETBIBLE_TRANSLATION_LANG_LABEL="Two Letter Language Abbreviation" +COM_GETBIBLE_TRANSLATION_LANG_MESSAGE="Error! Please add some language abbreviation here." +COM_GETBIBLE_TRANSLATION_MODIFIED_BY_DESC="The last user that modified this Translation." +COM_GETBIBLE_TRANSLATION_MODIFIED_BY_LABEL="Modified By" +COM_GETBIBLE_TRANSLATION_MODIFIED_DATE_DESC="The date this Translation was modified." +COM_GETBIBLE_TRANSLATION_MODIFIED_DATE_LABEL="Modified Date" +COM_GETBIBLE_TRANSLATION_ORDERING_LABEL="Ordering" +COM_GETBIBLE_TRANSLATION_PERMISSION="Permissions" +COM_GETBIBLE_TRANSLATION_PUBLISHING="Publishing" +COM_GETBIBLE_TRANSLATION_READONLY="Translation :: Readonly" +COM_GETBIBLE_TRANSLATION_SAVE_WARNING="Alias already existed so a number was added at the end. You can re-edit the Translation to customise the alias." +COM_GETBIBLE_TRANSLATION_SHA_DESCRIPTION="Enter some checksum sha" +COM_GETBIBLE_TRANSLATION_SHA_LABEL="Checksum" +COM_GETBIBLE_TRANSLATION_SHA_MESSAGE="Error! Please add some checksum sha here." +COM_GETBIBLE_TRANSLATION_SINISTRODEXTRAL_LTR="Sinistrodextral (LTR)" +COM_GETBIBLE_TRANSLATION_STATUS="Status" +COM_GETBIBLE_TRANSLATION_TRANSLATION_DESCRIPTION="Enter some translation" +COM_GETBIBLE_TRANSLATION_TRANSLATION_HINT="King James Version" +COM_GETBIBLE_TRANSLATION_TRANSLATION_LABEL="Translation" +COM_GETBIBLE_TRANSLATION_TRANSLATION_MESSAGE="Error! Please add some translation here." +COM_GETBIBLE_TRANSLATION_VERSION_DESC="A count of the number of times this Translation has been revised." +COM_GETBIBLE_TRANSLATION_VERSION_HINT="history_1.0" +COM_GETBIBLE_TRANSLATION_VERSION_LABEL="Version" +COM_GETBIBLE_TRANSLATION_VERSION_MESSAGE="Error! Please add some history version here." +COM_GETBIBLE_TRASHED="Trashed" +COM_GETBIBLE_TRASHED_ITEMS="Trashed items" +COM_GETBIBLE_TRASH_AREA="Trash Area" +COM_GETBIBLE_TYPE_BOOK="Book" +COM_GETBIBLE_TYPE_CHAPTER="Chapter" +COM_GETBIBLE_TYPE_LINKER="Linker" +COM_GETBIBLE_TYPE_NOTE="Note" +COM_GETBIBLE_TYPE_OPEN_AI_MESSAGE="Open AI Message" +COM_GETBIBLE_TYPE_OPEN_AI_RESPONSE="Open AI Response" +COM_GETBIBLE_TYPE_PASSWORD="Password" +COM_GETBIBLE_TYPE_PROMPT="Prompt" +COM_GETBIBLE_TYPE_TAG="Tag" +COM_GETBIBLE_TYPE_TAGGED_VERSE="Tagged Verse" +COM_GETBIBLE_TYPE_TRANSLATION="Translation" +COM_GETBIBLE_TYPE_VERSE="Verse" +COM_GETBIBLE_UP_TO_DATE="Up to date" +COM_GETBIBLE_USE_BATCH="Use Batch" +COM_GETBIBLE_USE_BATCH_DESC="Allows users in this group to use batch copy/update method." +COM_GETBIBLE_VERSE="Verse" +COM_GETBIBLE_VERSES="Verses" +COM_GETBIBLE_VERSES_ACCESS="Verses Access" +COM_GETBIBLE_VERSES_ACCESS_DESC="Allows the users in this group to access access verses" +COM_GETBIBLE_VERSES_BATCH_OPTIONS="Batch process the selected Verses" +COM_GETBIBLE_VERSES_BATCH_TIP="All changes will be applied to all selected Verses" +COM_GETBIBLE_VERSES_BATCH_USE="Verses Batch Use" +COM_GETBIBLE_VERSES_BATCH_USE_DESC="Allows users in this group to use batch copy/update method of batch verses" +COM_GETBIBLE_VERSES_CREATE="Verses Create" +COM_GETBIBLE_VERSES_CREATE_DESC="Allows the users in this group to create create verses" +COM_GETBIBLE_VERSES_DASHBOARD_LIST="Verses Dashboard List" +COM_GETBIBLE_VERSES_DASHBOARD_LIST_DESC="Allows the users in this group to dashboard list of verse" +COM_GETBIBLE_VERSES_DELETE="Verses Delete" +COM_GETBIBLE_VERSES_DELETE_DESC="Allows the users in this group to delete delete verses" +COM_GETBIBLE_VERSES_EDIT="Verses Edit" +COM_GETBIBLE_VERSES_EDIT_ABBREVIATION="Verses Edit Abbreviation" +COM_GETBIBLE_VERSES_EDIT_ABBREVIATION_DESC="Allows the users in this group to edit abbreviation of verse" +COM_GETBIBLE_VERSES_EDIT_BOOK_NR="Verses Edit Book Nr" +COM_GETBIBLE_VERSES_EDIT_BOOK_NR_DESC="Allows the users in this group to edit book nr of verse" +COM_GETBIBLE_VERSES_EDIT_CHAPTER="Verses Edit Chapter" +COM_GETBIBLE_VERSES_EDIT_CHAPTER_DESC="Allows the users in this group to edit chapter of verse" +COM_GETBIBLE_VERSES_EDIT_CREATED_BY="Verses Edit Created By" +COM_GETBIBLE_VERSES_EDIT_CREATED_BY_DESC="Allows the users in this group to update the created by of the edit created by verses" +COM_GETBIBLE_VERSES_EDIT_CREATED_DATE="Verses Edit Created Date" +COM_GETBIBLE_VERSES_EDIT_CREATED_DATE_DESC="Allows the users in this group to update the created date of the edit created verses" +COM_GETBIBLE_VERSES_EDIT_DESC="Allows the users in this group to edit the verse" +COM_GETBIBLE_VERSES_EDIT_NAME="Verses Edit Name" +COM_GETBIBLE_VERSES_EDIT_NAME_DESC="Allows the users in this group to edit name of verse" +COM_GETBIBLE_VERSES_EDIT_OWN="Verses Edit Own" +COM_GETBIBLE_VERSES_EDIT_OWN_DESC="Allows the users in this group to edit edit own verses created by them" +COM_GETBIBLE_VERSES_EDIT_STATE="Verses Edit State" +COM_GETBIBLE_VERSES_EDIT_STATE_DESC="Allows the users in this group to update the state of the verse" +COM_GETBIBLE_VERSES_EDIT_TEXT="Verses Edit Text" +COM_GETBIBLE_VERSES_EDIT_TEXT_DESC="Allows the users in this group to edit text of verse" +COM_GETBIBLE_VERSES_EDIT_VERSE="Verses Edit Verse" +COM_GETBIBLE_VERSES_EDIT_VERSE_DESC="Allows the users in this group to edit verse of verse" +COM_GETBIBLE_VERSES_N_ITEMS_ARCHIVED="%s Verses archived." +COM_GETBIBLE_VERSES_N_ITEMS_ARCHIVED_1="%s Verse archived." +COM_GETBIBLE_VERSES_N_ITEMS_CHECKED_IN_0="No Verse successfully checked in." +COM_GETBIBLE_VERSES_N_ITEMS_CHECKED_IN_1="%d Verse successfully checked in." +COM_GETBIBLE_VERSES_N_ITEMS_CHECKED_IN_MORE="%d Verses successfully checked in." +COM_GETBIBLE_VERSES_N_ITEMS_DELETED="%s Verses deleted." +COM_GETBIBLE_VERSES_N_ITEMS_DELETED_1="%s Verse deleted." +COM_GETBIBLE_VERSES_N_ITEMS_FAILED_PUBLISHING="%s Verses failed publishing." +COM_GETBIBLE_VERSES_N_ITEMS_FAILED_PUBLISHING_1="%s Verse failed publishing." +COM_GETBIBLE_VERSES_N_ITEMS_FEATURED="%s Verses featured." +COM_GETBIBLE_VERSES_N_ITEMS_FEATURED_1="%s Verse featured." +COM_GETBIBLE_VERSES_N_ITEMS_PUBLISHED="%s Verses published." +COM_GETBIBLE_VERSES_N_ITEMS_PUBLISHED_1="%s Verse published." +COM_GETBIBLE_VERSES_N_ITEMS_TRASHED="%s Verses trashed." +COM_GETBIBLE_VERSES_N_ITEMS_TRASHED_1="%s Verse trashed." +COM_GETBIBLE_VERSES_N_ITEMS_UNFEATURED="%s Verses unfeatured." +COM_GETBIBLE_VERSES_N_ITEMS_UNFEATURED_1="%s Verse unfeatured." +COM_GETBIBLE_VERSES_N_ITEMS_UNPUBLISHED="%s Verses unpublished." +COM_GETBIBLE_VERSES_N_ITEMS_UNPUBLISHED_1="%s Verse unpublished." +COM_GETBIBLE_VERSES_SUBMENU="Verses Submenu" +COM_GETBIBLE_VERSES_SUBMENU_DESC="Allows the users in this group to submenu of verse" +COM_GETBIBLE_VERSE_ABBREVIATION_DESCRIPTION="Select a Bible translation" +COM_GETBIBLE_VERSE_ABBREVIATION_LABEL="Translation" +COM_GETBIBLE_VERSE_BOOK_NR_DESCRIPTION="Select the book number" +COM_GETBIBLE_VERSE_BOOK_NR_LABEL="Book Number" +COM_GETBIBLE_VERSE_CHAPTER_DESCRIPTION="Select the chapter number" +COM_GETBIBLE_VERSE_CHAPTER_LABEL="Chapter" +COM_GETBIBLE_VERSE_CREATED_BY_DESC="The user that created this Verse." +COM_GETBIBLE_VERSE_CREATED_BY_LABEL="Created By" +COM_GETBIBLE_VERSE_CREATED_DATE_DESC="The date this Verse was created." +COM_GETBIBLE_VERSE_CREATED_DATE_LABEL="Created Date" +COM_GETBIBLE_VERSE_DETAILS="Details" +COM_GETBIBLE_VERSE_ERROR_UNIQUE_ALIAS="Another Verse has the same alias." +COM_GETBIBLE_VERSE_ID="Id" +COM_GETBIBLE_VERSE_MODIFIED_BY_DESC="The last user that modified this Verse." +COM_GETBIBLE_VERSE_MODIFIED_BY_LABEL="Modified By" +COM_GETBIBLE_VERSE_MODIFIED_DATE_DESC="The date this Verse was modified." +COM_GETBIBLE_VERSE_MODIFIED_DATE_LABEL="Modified Date" +COM_GETBIBLE_VERSE_NAME_DESCRIPTION="Enter Name Here" +COM_GETBIBLE_VERSE_NAME_HINT="Name Here" +COM_GETBIBLE_VERSE_NAME_LABEL="Name" +COM_GETBIBLE_VERSE_NAME_MESSAGE="Error! Please add name here." +COM_GETBIBLE_VERSE_ORDERING_LABEL="Ordering" +COM_GETBIBLE_VERSE_PERMISSION="Permissions" +COM_GETBIBLE_VERSE_PUBLISHING="Publishing" +COM_GETBIBLE_VERSE_READONLY="Verse :: Readonly" +COM_GETBIBLE_VERSE_SAVE_WARNING="Alias already existed so a number was added at the end. You can re-edit the Verse to customise the alias." +COM_GETBIBLE_VERSE_STATUS="Status" +COM_GETBIBLE_VERSE_TEXT_DESCRIPTION="The Holy Scripture (do not change)" +COM_GETBIBLE_VERSE_TEXT_HINT="// Will be added during install of translations" +COM_GETBIBLE_VERSE_TEXT_LABEL="Scripture (verse)" +COM_GETBIBLE_VERSE_VERSE_DESCRIPTION="Select the verse number" +COM_GETBIBLE_VERSE_VERSE_LABEL="Verse" +COM_GETBIBLE_VERSE_VERSION_DESC="A count of the number of times this Verse has been revised." +COM_GETBIBLE_VERSE_VERSION_LABEL="Version" +COM_GETBIBLE_VERSION="Version" +COM_GETBIBLE_WEBSITE="Website" +COM_GETBIBLE_WITHOUT_SELECTING_THE_CORRECT_FAVOURITE_VERSE_YOU_CANT_PERFORM_THE_INITIAL_ACTION="Without selecting the correct favourite verse, you can't perform the initial action." +COM_GETBIBLE_YOU_ARE_CURRENTLY_VIEWING_THE_TRASHED_ITEMS="You are currently viewing the trashed items." +COM_GETBIBLE_YOU_ARE_CURRENTLY_VIEWING_THE_TRASH_AREA_AND_YOU_DONT_HAVE_ANY_ITEMS_IN_TRASH_AT_THE_MOMENT="You are currently viewing the trash area, and you don't have any items in trash at the moment!" +COM_GETBIBLE_YOU_CAN_DIRECTLY_DOWNLOAD_THE_LATEST_UPDATE_OR_USE_THE_JOOMLA_UPDATE_AREA="You can directly download the latest update, or use the Joomla update area." +COM_GETBIBLE_YOU_WILL_HAVE_TO_ENABLE_OPEN_AI_IN_THE_GLOBAL_OPTIONS_OF_YOUR_COMPONENT_SINCE_IT_IS_CURRENTLY_DISABLED="You will have to enable Open AI in the global options of your component, since it is currently disabled." \ No newline at end of file diff --git a/admin/language/en-GB/en-GB.com_getbible.sys.ini b/admin/language/en-GB/en-GB.com_getbible.sys.ini new file mode 100644 index 0000000..ef86291 --- /dev/null +++ b/admin/language/en-GB/en-GB.com_getbible.sys.ini @@ -0,0 +1,523 @@ +COM_GETBIBLE="Get Bible" +COM_GETBIBLE_BOOKS_ACCESS="Books Access" +COM_GETBIBLE_BOOKS_ACCESS_DESC="Allows the users in this group to access access books" +COM_GETBIBLE_BOOKS_BATCH_USE="Books Batch Use" +COM_GETBIBLE_BOOKS_BATCH_USE_DESC="Allows users in this group to use batch copy/update method of batch books" +COM_GETBIBLE_BOOKS_CREATE="Books Create" +COM_GETBIBLE_BOOKS_CREATE_DESC="Allows the users in this group to create create books" +COM_GETBIBLE_BOOKS_DASHBOARD_LIST="Books Dashboard List" +COM_GETBIBLE_BOOKS_DASHBOARD_LIST_DESC="Allows the users in this group to dashboard list of book" +COM_GETBIBLE_BOOKS_DELETE="Books Delete" +COM_GETBIBLE_BOOKS_DELETE_DESC="Allows the users in this group to delete delete books" +COM_GETBIBLE_BOOKS_EDIT="Books Edit" +COM_GETBIBLE_BOOKS_EDIT_ABBREVIATION="Books Edit Abbreviation" +COM_GETBIBLE_BOOKS_EDIT_ABBREVIATION_DESC="Allows the users in this group to edit abbreviation of book" +COM_GETBIBLE_BOOKS_EDIT_CREATED_BY="Books Edit Created By" +COM_GETBIBLE_BOOKS_EDIT_CREATED_BY_DESC="Allows the users in this group to update the created by of the edit created by books" +COM_GETBIBLE_BOOKS_EDIT_CREATED_DATE="Books Edit Created Date" +COM_GETBIBLE_BOOKS_EDIT_CREATED_DATE_DESC="Allows the users in this group to update the created date of the edit created books" +COM_GETBIBLE_BOOKS_EDIT_DESC="Allows the users in this group to edit the book" +COM_GETBIBLE_BOOKS_EDIT_NAME="Books Edit Name" +COM_GETBIBLE_BOOKS_EDIT_NAME_DESC="Allows the users in this group to edit name of book" +COM_GETBIBLE_BOOKS_EDIT_NR="Books Edit Nr" +COM_GETBIBLE_BOOKS_EDIT_NR_DESC="Allows the users in this group to edit nr of book" +COM_GETBIBLE_BOOKS_EDIT_OWN="Books Edit Own" +COM_GETBIBLE_BOOKS_EDIT_OWN_DESC="Allows the users in this group to edit edit own books created by them" +COM_GETBIBLE_BOOKS_EDIT_SHA="Books Edit Sha" +COM_GETBIBLE_BOOKS_EDIT_SHA_DESC="Allows the users in this group to edit sha of book" +COM_GETBIBLE_BOOKS_EDIT_STATE="Books Edit State" +COM_GETBIBLE_BOOKS_EDIT_STATE_DESC="Allows the users in this group to update the state of the book" +COM_GETBIBLE_BOOKS_SUBMENU="Books Submenu" +COM_GETBIBLE_BOOKS_SUBMENU_DESC="Allows the users in this group to submenu of book" +COM_GETBIBLE_CHAPTERS_ACCESS="Chapters Access" +COM_GETBIBLE_CHAPTERS_ACCESS_DESC="Allows the users in this group to access access chapters" +COM_GETBIBLE_CHAPTERS_BATCH_USE="Chapters Batch Use" +COM_GETBIBLE_CHAPTERS_BATCH_USE_DESC="Allows users in this group to use batch copy/update method of batch chapters" +COM_GETBIBLE_CHAPTERS_CREATE="Chapters Create" +COM_GETBIBLE_CHAPTERS_CREATE_DESC="Allows the users in this group to create create chapters" +COM_GETBIBLE_CHAPTERS_DASHBOARD_LIST="Chapters Dashboard List" +COM_GETBIBLE_CHAPTERS_DASHBOARD_LIST_DESC="Allows the users in this group to dashboard list of chapter" +COM_GETBIBLE_CHAPTERS_DELETE="Chapters Delete" +COM_GETBIBLE_CHAPTERS_DELETE_DESC="Allows the users in this group to delete delete chapters" +COM_GETBIBLE_CHAPTERS_EDIT="Chapters Edit" +COM_GETBIBLE_CHAPTERS_EDIT_ABBREVIATION="Chapters Edit Abbreviation" +COM_GETBIBLE_CHAPTERS_EDIT_ABBREVIATION_DESC="Allows the users in this group to edit abbreviation of chapter" +COM_GETBIBLE_CHAPTERS_EDIT_BOOK_NR="Chapters Edit Book Nr" +COM_GETBIBLE_CHAPTERS_EDIT_BOOK_NR_DESC="Allows the users in this group to edit book nr of chapter" +COM_GETBIBLE_CHAPTERS_EDIT_CHAPTER="Chapters Edit Chapter" +COM_GETBIBLE_CHAPTERS_EDIT_CHAPTER_DESC="Allows the users in this group to edit chapter of chapter" +COM_GETBIBLE_CHAPTERS_EDIT_CREATED_BY="Chapters Edit Created By" +COM_GETBIBLE_CHAPTERS_EDIT_CREATED_BY_DESC="Allows the users in this group to update the created by of the edit created by chapters" +COM_GETBIBLE_CHAPTERS_EDIT_CREATED_DATE="Chapters Edit Created Date" +COM_GETBIBLE_CHAPTERS_EDIT_CREATED_DATE_DESC="Allows the users in this group to update the created date of the edit created chapters" +COM_GETBIBLE_CHAPTERS_EDIT_DESC="Allows the users in this group to edit the chapter" +COM_GETBIBLE_CHAPTERS_EDIT_NAME="Chapters Edit Name" +COM_GETBIBLE_CHAPTERS_EDIT_NAME_DESC="Allows the users in this group to edit name of chapter" +COM_GETBIBLE_CHAPTERS_EDIT_OWN="Chapters Edit Own" +COM_GETBIBLE_CHAPTERS_EDIT_OWN_DESC="Allows the users in this group to edit edit own chapters created by them" +COM_GETBIBLE_CHAPTERS_EDIT_SHA="Chapters Edit Sha" +COM_GETBIBLE_CHAPTERS_EDIT_SHA_DESC="Allows the users in this group to edit sha of chapter" +COM_GETBIBLE_CHAPTERS_EDIT_STATE="Chapters Edit State" +COM_GETBIBLE_CHAPTERS_EDIT_STATE_DESC="Allows the users in this group to update the state of the chapter" +COM_GETBIBLE_CHAPTERS_SUBMENU="Chapters Submenu" +COM_GETBIBLE_CHAPTERS_SUBMENU_DESC="Allows the users in this group to submenu of chapter" +COM_GETBIBLE_CONFIGURATION="Get Bible Configuration" +COM_GETBIBLE_EDIT_CREATED_BY="Edit Created By" +COM_GETBIBLE_EDIT_CREATED_BY_DESC="Allows users in this group to edit created by." +COM_GETBIBLE_EDIT_CREATED_DATE="Edit Created Date" +COM_GETBIBLE_EDIT_CREATED_DATE_DESC="Allows users in this group to edit created date." +COM_GETBIBLE_EDIT_VERSIONS="Edit Version" +COM_GETBIBLE_EDIT_VERSIONS_DESC="Allows users in this group to edit versions." +COM_GETBIBLE_LINKERS_ACCESS="Linkers Access" +COM_GETBIBLE_LINKERS_ACCESS_DESC="Allows the users in this group to access access linkers" +COM_GETBIBLE_LINKERS_BATCH_USE="Linkers Batch Use" +COM_GETBIBLE_LINKERS_BATCH_USE_DESC="Allows users in this group to use batch copy/update method of batch linkers" +COM_GETBIBLE_LINKERS_CREATE="Linkers Create" +COM_GETBIBLE_LINKERS_CREATE_DESC="Allows the users in this group to create create linkers" +COM_GETBIBLE_LINKERS_DASHBOARD_LIST="Linkers Dashboard List" +COM_GETBIBLE_LINKERS_DASHBOARD_LIST_DESC="Allows the users in this group to dashboard list of linker" +COM_GETBIBLE_LINKERS_DELETE="Linkers Delete" +COM_GETBIBLE_LINKERS_DELETE_DESC="Allows the users in this group to delete delete linkers" +COM_GETBIBLE_LINKERS_EDIT="Linkers Edit" +COM_GETBIBLE_LINKERS_EDIT_CREATED_BY="Linkers Edit Created By" +COM_GETBIBLE_LINKERS_EDIT_CREATED_BY_DESC="Allows the users in this group to update the created by of the edit created by linkers" +COM_GETBIBLE_LINKERS_EDIT_CREATED_DATE="Linkers Edit Created Date" +COM_GETBIBLE_LINKERS_EDIT_CREATED_DATE_DESC="Allows the users in this group to update the created date of the edit created linkers" +COM_GETBIBLE_LINKERS_EDIT_DESC="Allows the users in this group to edit the linker" +COM_GETBIBLE_LINKERS_EDIT_GUID="Linkers Edit Guid" +COM_GETBIBLE_LINKERS_EDIT_GUID_DESC="Allows the users in this group to edit guid of linker" +COM_GETBIBLE_LINKERS_EDIT_NAME="Linkers Edit Name" +COM_GETBIBLE_LINKERS_EDIT_NAME_DESC="Allows the users in this group to edit name of linker" +COM_GETBIBLE_LINKERS_EDIT_OWN="Linkers Edit Own" +COM_GETBIBLE_LINKERS_EDIT_OWN_DESC="Allows the users in this group to edit edit own linkers created by them" +COM_GETBIBLE_LINKERS_EDIT_STATE="Linkers Edit State" +COM_GETBIBLE_LINKERS_EDIT_STATE_DESC="Allows the users in this group to update the state of the linker" +COM_GETBIBLE_LINKERS_SUBMENU="Linkers Submenu" +COM_GETBIBLE_LINKERS_SUBMENU_DESC="Allows the users in this group to submenu of linker" +COM_GETBIBLE_MENU="Get Bible" +COM_GETBIBLE_MENU_API_DESC="Api" +COM_GETBIBLE_MENU_API_OPTION="Api" +COM_GETBIBLE_MENU_API_TITLE="Api" +COM_GETBIBLE_MENU_APP_DESC="App" +COM_GETBIBLE_MENU_APP_OPTION="App" +COM_GETBIBLE_MENU_APP_TITLE="App" +COM_GETBIBLE_MENU_BOOKS="Books" +COM_GETBIBLE_MENU_CHAPTERS="Chapters" +COM_GETBIBLE_MENU_LINKERS="Linkers" +COM_GETBIBLE_MENU_NOTES="Notes" +COM_GETBIBLE_MENU_OPEN_AI_RESPONSES="Open AI Responses" +COM_GETBIBLE_MENU_PROMPTS="Prompts" +COM_GETBIBLE_MENU_TAGGED_VERSES="Tagged Verses" +COM_GETBIBLE_MENU_TAGS="Tags" +COM_GETBIBLE_MENU_TRANSLATIONS="Translations" +COM_GETBIBLE_MENU_VERSES="Verses" +COM_GETBIBLE_NOTES_ACCESS="Notes Access" +COM_GETBIBLE_NOTES_ACCESS_DESC="Allows the users in this group to access access notes" +COM_GETBIBLE_NOTES_BATCH_USE="Notes Batch Use" +COM_GETBIBLE_NOTES_BATCH_USE_DESC="Allows users in this group to use batch copy/update method of batch notes" +COM_GETBIBLE_NOTES_CREATE="Notes Create" +COM_GETBIBLE_NOTES_CREATE_DESC="Allows the users in this group to create create notes" +COM_GETBIBLE_NOTES_DASHBOARD_LIST="Notes Dashboard List" +COM_GETBIBLE_NOTES_DASHBOARD_LIST_DESC="Allows the users in this group to dashboard list of note" +COM_GETBIBLE_NOTES_DELETE="Notes Delete" +COM_GETBIBLE_NOTES_DELETE_DESC="Allows the users in this group to delete delete notes" +COM_GETBIBLE_NOTES_EDIT="Notes Edit" +COM_GETBIBLE_NOTES_EDIT_ACCESS="Notes Edit Access" +COM_GETBIBLE_NOTES_EDIT_ACCESS_DESC="Allows the users in this group to change the access of the edit access notes" +COM_GETBIBLE_NOTES_EDIT_BOOK_NR="Notes Edit Book Nr" +COM_GETBIBLE_NOTES_EDIT_BOOK_NR_DESC="Allows the users in this group to edit book nr of note" +COM_GETBIBLE_NOTES_EDIT_CHAPTER="Notes Edit Chapter" +COM_GETBIBLE_NOTES_EDIT_CHAPTER_DESC="Allows the users in this group to edit chapter of note" +COM_GETBIBLE_NOTES_EDIT_CREATED_BY="Notes Edit Created By" +COM_GETBIBLE_NOTES_EDIT_CREATED_BY_DESC="Allows the users in this group to update the created by of the edit created by notes" +COM_GETBIBLE_NOTES_EDIT_CREATED_DATE="Notes Edit Created Date" +COM_GETBIBLE_NOTES_EDIT_CREATED_DATE_DESC="Allows the users in this group to update the created date of the edit created notes" +COM_GETBIBLE_NOTES_EDIT_DESC="Allows the users in this group to edit the note" +COM_GETBIBLE_NOTES_EDIT_GUID="Notes Edit Guid" +COM_GETBIBLE_NOTES_EDIT_GUID_DESC="Allows the users in this group to edit guid of note" +COM_GETBIBLE_NOTES_EDIT_LINKER="Notes Edit Linker" +COM_GETBIBLE_NOTES_EDIT_LINKER_DESC="Allows the users in this group to edit linker of note" +COM_GETBIBLE_NOTES_EDIT_NOTE="Notes Edit Note" +COM_GETBIBLE_NOTES_EDIT_NOTE_DESC="Allows the users in this group to edit note of note" +COM_GETBIBLE_NOTES_EDIT_OWN="Notes Edit Own" +COM_GETBIBLE_NOTES_EDIT_OWN_DESC="Allows the users in this group to edit edit own notes created by them" +COM_GETBIBLE_NOTES_EDIT_STATE="Notes Edit State" +COM_GETBIBLE_NOTES_EDIT_STATE_DESC="Allows the users in this group to update the state of the note" +COM_GETBIBLE_NOTES_EDIT_VERSE="Notes Edit Verse" +COM_GETBIBLE_NOTES_EDIT_VERSE_DESC="Allows the users in this group to edit verse of note" +COM_GETBIBLE_NOTES_EDIT_VERSION="Notes Edit Version" +COM_GETBIBLE_NOTES_EDIT_VERSION_DESC="Allows users in this group to edit versions of version notes" +COM_GETBIBLE_NOTES_SUBMENU="Notes Submenu" +COM_GETBIBLE_NOTES_SUBMENU_DESC="Allows the users in this group to submenu of note" +COM_GETBIBLE_OPEN_AI_MESSAGES_ACCESS="Open Ai Messages Access" +COM_GETBIBLE_OPEN_AI_MESSAGES_ACCESS_DESC="Allows the users in this group to access access open ai messages" +COM_GETBIBLE_OPEN_AI_MESSAGES_BATCH_USE="Open Ai Messages Batch Use" +COM_GETBIBLE_OPEN_AI_MESSAGES_BATCH_USE_DESC="Allows users in this group to use batch copy/update method of batch open ai messages" +COM_GETBIBLE_OPEN_AI_MESSAGES_CREATE="Open Ai Messages Create" +COM_GETBIBLE_OPEN_AI_MESSAGES_CREATE_DESC="Allows the users in this group to create create open ai messages" +COM_GETBIBLE_OPEN_AI_MESSAGES_DELETE="Open Ai Messages Delete" +COM_GETBIBLE_OPEN_AI_MESSAGES_DELETE_DESC="Allows the users in this group to delete delete open ai messages" +COM_GETBIBLE_OPEN_AI_MESSAGES_EDIT="Open Ai Messages Edit" +COM_GETBIBLE_OPEN_AI_MESSAGES_EDIT_CONTENT="Open Ai Messages Edit Content" +COM_GETBIBLE_OPEN_AI_MESSAGES_EDIT_CONTENT_DESC="Allows the users in this group to edit content of open ai message" +COM_GETBIBLE_OPEN_AI_MESSAGES_EDIT_CREATED_BY="Open Ai Messages Edit Created By" +COM_GETBIBLE_OPEN_AI_MESSAGES_EDIT_CREATED_BY_DESC="Allows the users in this group to update the created by of the edit created by open ai messages" +COM_GETBIBLE_OPEN_AI_MESSAGES_EDIT_CREATED_DATE="Open Ai Messages Edit Created Date" +COM_GETBIBLE_OPEN_AI_MESSAGES_EDIT_CREATED_DATE_DESC="Allows the users in this group to update the created date of the edit created open ai messages" +COM_GETBIBLE_OPEN_AI_MESSAGES_EDIT_DESC="Allows the users in this group to edit the open ai message" +COM_GETBIBLE_OPEN_AI_MESSAGES_EDIT_INDEX="Open Ai Messages Edit Index" +COM_GETBIBLE_OPEN_AI_MESSAGES_EDIT_INDEX_DESC="Allows the users in this group to edit index of open ai message" +COM_GETBIBLE_OPEN_AI_MESSAGES_EDIT_NAME="Open Ai Messages Edit Name" +COM_GETBIBLE_OPEN_AI_MESSAGES_EDIT_NAME_DESC="Allows the users in this group to edit name of open ai message" +COM_GETBIBLE_OPEN_AI_MESSAGES_EDIT_OPEN_AI_RESPONSE="Open Ai Messages Edit Open Ai Response" +COM_GETBIBLE_OPEN_AI_MESSAGES_EDIT_OPEN_AI_RESPONSE_DESC="Allows the users in this group to edit open ai response of open ai message" +COM_GETBIBLE_OPEN_AI_MESSAGES_EDIT_OWN="Open Ai Messages Edit Own" +COM_GETBIBLE_OPEN_AI_MESSAGES_EDIT_OWN_DESC="Allows the users in this group to edit edit own open ai messages created by them" +COM_GETBIBLE_OPEN_AI_MESSAGES_EDIT_PROMPT="Open Ai Messages Edit Prompt" +COM_GETBIBLE_OPEN_AI_MESSAGES_EDIT_PROMPT_DESC="Allows the users in this group to edit prompt of open ai message" +COM_GETBIBLE_OPEN_AI_MESSAGES_EDIT_ROLE="Open Ai Messages Edit Role" +COM_GETBIBLE_OPEN_AI_MESSAGES_EDIT_ROLE_DESC="Allows the users in this group to edit role of open ai message" +COM_GETBIBLE_OPEN_AI_MESSAGES_EDIT_SOURCE="Open Ai Messages Edit Source" +COM_GETBIBLE_OPEN_AI_MESSAGES_EDIT_SOURCE_DESC="Allows the users in this group to edit source of open ai message" +COM_GETBIBLE_OPEN_AI_MESSAGES_EDIT_STATE="Open Ai Messages Edit State" +COM_GETBIBLE_OPEN_AI_MESSAGES_EDIT_STATE_DESC="Allows the users in this group to update the state of the open ai message" +COM_GETBIBLE_OPEN_AI_MESSAGES_EDIT_VERSION="Open Ai Messages Edit Version" +COM_GETBIBLE_OPEN_AI_MESSAGES_EDIT_VERSION_DESC="Allows users in this group to edit versions of version open ai messages" +COM_GETBIBLE_OPEN_AI_RESPONSES_ACCESS="Open Ai Responses Access" +COM_GETBIBLE_OPEN_AI_RESPONSES_ACCESS_DESC="Allows the users in this group to access access open ai responses" +COM_GETBIBLE_OPEN_AI_RESPONSES_BATCH_USE="Open Ai Responses Batch Use" +COM_GETBIBLE_OPEN_AI_RESPONSES_BATCH_USE_DESC="Allows users in this group to use batch copy/update method of batch open ai responses" +COM_GETBIBLE_OPEN_AI_RESPONSES_CREATE="Open Ai Responses Create" +COM_GETBIBLE_OPEN_AI_RESPONSES_CREATE_DESC="Allows the users in this group to create create open ai responses" +COM_GETBIBLE_OPEN_AI_RESPONSES_DASHBOARD_LIST="Open Ai Responses Dashboard List" +COM_GETBIBLE_OPEN_AI_RESPONSES_DASHBOARD_LIST_DESC="Allows the users in this group to dashboard list of open ai response" +COM_GETBIBLE_OPEN_AI_RESPONSES_DELETE="Open Ai Responses Delete" +COM_GETBIBLE_OPEN_AI_RESPONSES_DELETE_DESC="Allows the users in this group to delete delete open ai responses" +COM_GETBIBLE_OPEN_AI_RESPONSES_EDIT="Open Ai Responses Edit" +COM_GETBIBLE_OPEN_AI_RESPONSES_EDIT_ABBREVIATION="Open Ai Responses Edit Abbreviation" +COM_GETBIBLE_OPEN_AI_RESPONSES_EDIT_ABBREVIATION_DESC="Allows the users in this group to edit abbreviation of open ai response" +COM_GETBIBLE_OPEN_AI_RESPONSES_EDIT_BOOK="Open Ai Responses Edit Book" +COM_GETBIBLE_OPEN_AI_RESPONSES_EDIT_BOOK_DESC="Allows the users in this group to edit book of open ai response" +COM_GETBIBLE_OPEN_AI_RESPONSES_EDIT_CHAPTER="Open Ai Responses Edit Chapter" +COM_GETBIBLE_OPEN_AI_RESPONSES_EDIT_CHAPTER_DESC="Allows the users in this group to edit chapter of open ai response" +COM_GETBIBLE_OPEN_AI_RESPONSES_EDIT_COMPLETION_TOKENS="Open Ai Responses Edit Completion Tokens" +COM_GETBIBLE_OPEN_AI_RESPONSES_EDIT_COMPLETION_TOKENS_DESC="Allows the users in this group to edit completion tokens of open ai response" +COM_GETBIBLE_OPEN_AI_RESPONSES_EDIT_CREATED_BY="Open Ai Responses Edit Created By" +COM_GETBIBLE_OPEN_AI_RESPONSES_EDIT_CREATED_BY_DESC="Allows the users in this group to update the created by of the edit created by open ai responses" +COM_GETBIBLE_OPEN_AI_RESPONSES_EDIT_CREATED_DATE="Open Ai Responses Edit Created Date" +COM_GETBIBLE_OPEN_AI_RESPONSES_EDIT_CREATED_DATE_DESC="Allows the users in this group to update the created date of the edit created open ai responses" +COM_GETBIBLE_OPEN_AI_RESPONSES_EDIT_DESC="Allows the users in this group to edit the open ai response" +COM_GETBIBLE_OPEN_AI_RESPONSES_EDIT_FREQUENCY_PENALTY="Open Ai Responses Edit Frequency Penalty" +COM_GETBIBLE_OPEN_AI_RESPONSES_EDIT_FREQUENCY_PENALTY_DESC="Allows the users in this group to edit frequency penalty of open ai response" +COM_GETBIBLE_OPEN_AI_RESPONSES_EDIT_LANGUAGE="Open Ai Responses Edit Language" +COM_GETBIBLE_OPEN_AI_RESPONSES_EDIT_LANGUAGE_DESC="Allows the users in this group to edit language of open ai response" +COM_GETBIBLE_OPEN_AI_RESPONSES_EDIT_LCSH="Open Ai Responses Edit Lcsh" +COM_GETBIBLE_OPEN_AI_RESPONSES_EDIT_LCSH_DESC="Allows the users in this group to edit lcsh of open ai response" +COM_GETBIBLE_OPEN_AI_RESPONSES_EDIT_MAX_TOKENS="Open Ai Responses Edit Max Tokens" +COM_GETBIBLE_OPEN_AI_RESPONSES_EDIT_MAX_TOKENS_DESC="Allows the users in this group to edit max tokens of open ai response" +COM_GETBIBLE_OPEN_AI_RESPONSES_EDIT_MODEL="Open Ai Responses Edit Model" +COM_GETBIBLE_OPEN_AI_RESPONSES_EDIT_MODEL_DESC="Allows the users in this group to edit model of open ai response" +COM_GETBIBLE_OPEN_AI_RESPONSES_EDIT_N="Open Ai Responses Edit N" +COM_GETBIBLE_OPEN_AI_RESPONSES_EDIT_N_DESC="Allows the users in this group to edit n of open ai response" +COM_GETBIBLE_OPEN_AI_RESPONSES_EDIT_OWN="Open Ai Responses Edit Own" +COM_GETBIBLE_OPEN_AI_RESPONSES_EDIT_OWN_DESC="Allows the users in this group to edit edit own open ai responses created by them" +COM_GETBIBLE_OPEN_AI_RESPONSES_EDIT_PRESENCE_PENALTY="Open Ai Responses Edit Presence Penalty" +COM_GETBIBLE_OPEN_AI_RESPONSES_EDIT_PRESENCE_PENALTY_DESC="Allows the users in this group to edit presence penalty of open ai response" +COM_GETBIBLE_OPEN_AI_RESPONSES_EDIT_PROMPT="Open Ai Responses Edit Prompt" +COM_GETBIBLE_OPEN_AI_RESPONSES_EDIT_PROMPT_DESC="Allows the users in this group to edit prompt of open ai response" +COM_GETBIBLE_OPEN_AI_RESPONSES_EDIT_PROMPT_TOKENS="Open Ai Responses Edit Prompt Tokens" +COM_GETBIBLE_OPEN_AI_RESPONSES_EDIT_PROMPT_TOKENS_DESC="Allows the users in this group to edit prompt tokens of open ai response" +COM_GETBIBLE_OPEN_AI_RESPONSES_EDIT_RESPONSE_CREATED="Open Ai Responses Edit Response Created" +COM_GETBIBLE_OPEN_AI_RESPONSES_EDIT_RESPONSE_CREATED_DESC="Allows the users in this group to edit response created of open ai response" +COM_GETBIBLE_OPEN_AI_RESPONSES_EDIT_RESPONSE_ID="Open Ai Responses Edit Response Id" +COM_GETBIBLE_OPEN_AI_RESPONSES_EDIT_RESPONSE_ID_DESC="Allows the users in this group to edit response id of open ai response" +COM_GETBIBLE_OPEN_AI_RESPONSES_EDIT_RESPONSE_MODEL="Open Ai Responses Edit Response Model" +COM_GETBIBLE_OPEN_AI_RESPONSES_EDIT_RESPONSE_MODEL_DESC="Allows the users in this group to edit response model of open ai response" +COM_GETBIBLE_OPEN_AI_RESPONSES_EDIT_RESPONSE_OBJECT="Open Ai Responses Edit Response Object" +COM_GETBIBLE_OPEN_AI_RESPONSES_EDIT_RESPONSE_OBJECT_DESC="Allows the users in this group to edit response object of open ai response" +COM_GETBIBLE_OPEN_AI_RESPONSES_EDIT_SELECTED_WORD="Open Ai Responses Edit Selected Word" +COM_GETBIBLE_OPEN_AI_RESPONSES_EDIT_SELECTED_WORD_DESC="Allows the users in this group to edit selected word of open ai response" +COM_GETBIBLE_OPEN_AI_RESPONSES_EDIT_STATE="Open Ai Responses Edit State" +COM_GETBIBLE_OPEN_AI_RESPONSES_EDIT_STATE_DESC="Allows the users in this group to update the state of the open ai response" +COM_GETBIBLE_OPEN_AI_RESPONSES_EDIT_TEMPERATURE="Open Ai Responses Edit Temperature" +COM_GETBIBLE_OPEN_AI_RESPONSES_EDIT_TEMPERATURE_DESC="Allows the users in this group to edit temperature of open ai response" +COM_GETBIBLE_OPEN_AI_RESPONSES_EDIT_TOP_P="Open Ai Responses Edit Top P" +COM_GETBIBLE_OPEN_AI_RESPONSES_EDIT_TOP_P_DESC="Allows the users in this group to edit top p of open ai response" +COM_GETBIBLE_OPEN_AI_RESPONSES_EDIT_TOTAL_TOKENS="Open Ai Responses Edit Total Tokens" +COM_GETBIBLE_OPEN_AI_RESPONSES_EDIT_TOTAL_TOKENS_DESC="Allows the users in this group to edit total tokens of open ai response" +COM_GETBIBLE_OPEN_AI_RESPONSES_EDIT_VERSE="Open Ai Responses Edit Verse" +COM_GETBIBLE_OPEN_AI_RESPONSES_EDIT_VERSE_DESC="Allows the users in this group to edit verse of open ai response" +COM_GETBIBLE_OPEN_AI_RESPONSES_EDIT_VERSION="Open Ai Responses Edit Version" +COM_GETBIBLE_OPEN_AI_RESPONSES_EDIT_VERSION_DESC="Allows users in this group to edit versions of version open ai responses" +COM_GETBIBLE_OPEN_AI_RESPONSES_EDIT_WORD="Open Ai Responses Edit Word" +COM_GETBIBLE_OPEN_AI_RESPONSES_EDIT_WORD_DESC="Allows the users in this group to edit word of open ai response" +COM_GETBIBLE_OPEN_AI_RESPONSES_SUBMENU="Open Ai Responses Submenu" +COM_GETBIBLE_OPEN_AI_RESPONSES_SUBMENU_DESC="Allows the users in this group to submenu of open ai response" +COM_GETBIBLE_PASSWORDS_ACCESS="Passwords Access" +COM_GETBIBLE_PASSWORDS_ACCESS_DESC="Allows the users in this group to access access passwords" +COM_GETBIBLE_PASSWORDS_ACCESS_PASSWORD="Passwords Access Password" +COM_GETBIBLE_PASSWORDS_ACCESS_PASSWORD_DESC="Allows the users in this group to access password of password" +COM_GETBIBLE_PASSWORDS_BATCH_USE="Passwords Batch Use" +COM_GETBIBLE_PASSWORDS_BATCH_USE_DESC="Allows users in this group to use batch copy/update method of batch passwords" +COM_GETBIBLE_PASSWORDS_CREATE="Passwords Create" +COM_GETBIBLE_PASSWORDS_CREATE_DESC="Allows the users in this group to create create passwords" +COM_GETBIBLE_PASSWORDS_DELETE="Passwords Delete" +COM_GETBIBLE_PASSWORDS_DELETE_DESC="Allows the users in this group to delete delete passwords" +COM_GETBIBLE_PASSWORDS_EDIT="Passwords Edit" +COM_GETBIBLE_PASSWORDS_EDIT_CREATED_BY="Passwords Edit Created By" +COM_GETBIBLE_PASSWORDS_EDIT_CREATED_BY_DESC="Allows the users in this group to update the created by of the edit created by passwords" +COM_GETBIBLE_PASSWORDS_EDIT_CREATED_DATE="Passwords Edit Created Date" +COM_GETBIBLE_PASSWORDS_EDIT_CREATED_DATE_DESC="Allows the users in this group to update the created date of the edit created passwords" +COM_GETBIBLE_PASSWORDS_EDIT_DESC="Allows the users in this group to edit the password" +COM_GETBIBLE_PASSWORDS_EDIT_GUID="Passwords Edit Guid" +COM_GETBIBLE_PASSWORDS_EDIT_GUID_DESC="Allows the users in this group to edit guid of password" +COM_GETBIBLE_PASSWORDS_EDIT_LINKER="Passwords Edit Linker" +COM_GETBIBLE_PASSWORDS_EDIT_LINKER_DESC="Allows the users in this group to edit linker of password" +COM_GETBIBLE_PASSWORDS_EDIT_NAME="Passwords Edit Name" +COM_GETBIBLE_PASSWORDS_EDIT_NAME_DESC="Allows the users in this group to edit name of password" +COM_GETBIBLE_PASSWORDS_EDIT_OWN="Passwords Edit Own" +COM_GETBIBLE_PASSWORDS_EDIT_OWN_DESC="Allows the users in this group to edit edit own passwords created by them" +COM_GETBIBLE_PASSWORDS_EDIT_PASSWORD="Passwords Edit Password" +COM_GETBIBLE_PASSWORDS_EDIT_PASSWORD_DESC="Allows the users in this group to edit password of password" +COM_GETBIBLE_PASSWORDS_EDIT_STATE="Passwords Edit State" +COM_GETBIBLE_PASSWORDS_EDIT_STATE_DESC="Allows the users in this group to update the state of the password" +COM_GETBIBLE_PASSWORDS_VIEW_PASSWORD="Passwords View Password" +COM_GETBIBLE_PASSWORDS_VIEW_PASSWORD_DESC="Allows the users in this group to view password of password" +COM_GETBIBLE_PROMPTS_ACCESS="Prompts Access" +COM_GETBIBLE_PROMPTS_ACCESS_DESC="Allows the users in this group to access access prompts" +COM_GETBIBLE_PROMPTS_ACCESS_TEMPERATURE_OVERRIDE="Prompts Access Temperature Override" +COM_GETBIBLE_PROMPTS_ACCESS_TEMPERATURE_OVERRIDE_DESC="Allows the users in this group to access temperature override of prompt" +COM_GETBIBLE_PROMPTS_BATCH_USE="Prompts Batch Use" +COM_GETBIBLE_PROMPTS_BATCH_USE_DESC="Allows users in this group to use batch copy/update method of batch prompts" +COM_GETBIBLE_PROMPTS_CREATE="Prompts Create" +COM_GETBIBLE_PROMPTS_CREATE_DESC="Allows the users in this group to create create prompts" +COM_GETBIBLE_PROMPTS_DASHBOARD_LIST="Prompts Dashboard List" +COM_GETBIBLE_PROMPTS_DASHBOARD_LIST_DESC="Allows the users in this group to dashboard list of prompt" +COM_GETBIBLE_PROMPTS_DELETE="Prompts Delete" +COM_GETBIBLE_PROMPTS_DELETE_DESC="Allows the users in this group to delete delete prompts" +COM_GETBIBLE_PROMPTS_EDIT="Prompts Edit" +COM_GETBIBLE_PROMPTS_EDIT_ABBREVIATION="Prompts Edit Abbreviation" +COM_GETBIBLE_PROMPTS_EDIT_ABBREVIATION_DESC="Allows the users in this group to edit abbreviation of prompt" +COM_GETBIBLE_PROMPTS_EDIT_AI_ORG_TOKEN_OVERRIDE="Prompts Edit Ai Org Token Override" +COM_GETBIBLE_PROMPTS_EDIT_AI_ORG_TOKEN_OVERRIDE_DESC="Allows the users in this group to edit ai org token override of prompt" +COM_GETBIBLE_PROMPTS_EDIT_CACHE_BEHAVIOUR="Prompts Edit Cache Behaviour" +COM_GETBIBLE_PROMPTS_EDIT_CACHE_BEHAVIOUR_DESC="Allows the users in this group to edit cache behaviour of prompt" +COM_GETBIBLE_PROMPTS_EDIT_CREATED_BY="Prompts Edit Created By" +COM_GETBIBLE_PROMPTS_EDIT_CREATED_BY_DESC="Allows the users in this group to update the created by of the edit created by prompts" +COM_GETBIBLE_PROMPTS_EDIT_CREATED_DATE="Prompts Edit Created Date" +COM_GETBIBLE_PROMPTS_EDIT_CREATED_DATE_DESC="Allows the users in this group to update the created date of the edit created prompts" +COM_GETBIBLE_PROMPTS_EDIT_DESC="Allows the users in this group to edit the prompt" +COM_GETBIBLE_PROMPTS_EDIT_FREQUENCY_PENALTY="Prompts Edit Frequency Penalty" +COM_GETBIBLE_PROMPTS_EDIT_FREQUENCY_PENALTY_DESC="Allows the users in this group to edit frequency penalty of prompt" +COM_GETBIBLE_PROMPTS_EDIT_FREQUENCY_PENALTY_OVERRIDE="Prompts Edit Frequency Penalty Override" +COM_GETBIBLE_PROMPTS_EDIT_FREQUENCY_PENALTY_OVERRIDE_DESC="Allows the users in this group to edit frequency penalty override of prompt" +COM_GETBIBLE_PROMPTS_EDIT_GUID="Prompts Edit Guid" +COM_GETBIBLE_PROMPTS_EDIT_GUID_DESC="Allows the users in this group to edit guid of prompt" +COM_GETBIBLE_PROMPTS_EDIT_INTEGRATION="Prompts Edit Integration" +COM_GETBIBLE_PROMPTS_EDIT_INTEGRATION_DESC="Allows the users in this group to edit integration of prompt" +COM_GETBIBLE_PROMPTS_EDIT_MAX_TOKENS="Prompts Edit Max Tokens" +COM_GETBIBLE_PROMPTS_EDIT_MAX_TOKENS_DESC="Allows the users in this group to edit max tokens of prompt" +COM_GETBIBLE_PROMPTS_EDIT_MAX_TOKENS_OVERRIDE="Prompts Edit Max Tokens Override" +COM_GETBIBLE_PROMPTS_EDIT_MAX_TOKENS_OVERRIDE_DESC="Allows the users in this group to edit max tokens override of prompt" +COM_GETBIBLE_PROMPTS_EDIT_MESSAGES="Prompts Edit Messages" +COM_GETBIBLE_PROMPTS_EDIT_MESSAGES_DESC="Allows the users in this group to edit messages of prompt" +COM_GETBIBLE_PROMPTS_EDIT_MODEL="Prompts Edit Model" +COM_GETBIBLE_PROMPTS_EDIT_MODEL_DESC="Allows the users in this group to edit model of prompt" +COM_GETBIBLE_PROMPTS_EDIT_N="Prompts Edit N" +COM_GETBIBLE_PROMPTS_EDIT_NAME="Prompts Edit Name" +COM_GETBIBLE_PROMPTS_EDIT_NAME_DESC="Allows the users in this group to edit name of prompt" +COM_GETBIBLE_PROMPTS_EDIT_N_DESC="Allows the users in this group to edit n of prompt" +COM_GETBIBLE_PROMPTS_EDIT_N_OVERRIDE="Prompts Edit N Override" +COM_GETBIBLE_PROMPTS_EDIT_N_OVERRIDE_DESC="Allows the users in this group to edit n override of prompt" +COM_GETBIBLE_PROMPTS_EDIT_ORG_TOKEN="Prompts Edit Org Token" +COM_GETBIBLE_PROMPTS_EDIT_ORG_TOKEN_DESC="Allows the users in this group to edit org token of prompt" +COM_GETBIBLE_PROMPTS_EDIT_OWN="Prompts Edit Own" +COM_GETBIBLE_PROMPTS_EDIT_OWN_DESC="Allows the users in this group to edit edit own prompts created by them" +COM_GETBIBLE_PROMPTS_EDIT_PRESENCE_PENALTY="Prompts Edit Presence Penalty" +COM_GETBIBLE_PROMPTS_EDIT_PRESENCE_PENALTY_DESC="Allows the users in this group to edit presence penalty of prompt" +COM_GETBIBLE_PROMPTS_EDIT_PRESENCE_PENALTY_OVERRIDE="Prompts Edit Presence Penalty Override" +COM_GETBIBLE_PROMPTS_EDIT_PRESENCE_PENALTY_OVERRIDE_DESC="Allows the users in this group to edit presence penalty override of prompt" +COM_GETBIBLE_PROMPTS_EDIT_RESPONSE_RETRIEVAL="Prompts Edit Response Retrieval" +COM_GETBIBLE_PROMPTS_EDIT_RESPONSE_RETRIEVAL_DESC="Allows the users in this group to edit response retrieval of prompt" +COM_GETBIBLE_PROMPTS_EDIT_STATE="Prompts Edit State" +COM_GETBIBLE_PROMPTS_EDIT_STATE_DESC="Allows the users in this group to update the state of the prompt" +COM_GETBIBLE_PROMPTS_EDIT_TEMPERATURE="Prompts Edit Temperature" +COM_GETBIBLE_PROMPTS_EDIT_TEMPERATURE_DESC="Allows the users in this group to edit temperature of prompt" +COM_GETBIBLE_PROMPTS_EDIT_TOKEN="Prompts Edit Token" +COM_GETBIBLE_PROMPTS_EDIT_TOKEN_DESC="Allows the users in this group to edit token of prompt" +COM_GETBIBLE_PROMPTS_EDIT_TOKEN_OVERRIDE="Prompts Edit Token Override" +COM_GETBIBLE_PROMPTS_EDIT_TOKEN_OVERRIDE_DESC="Allows the users in this group to edit token override of prompt" +COM_GETBIBLE_PROMPTS_EDIT_TOP_P="Prompts Edit Top P" +COM_GETBIBLE_PROMPTS_EDIT_TOP_P_DESC="Allows the users in this group to edit top p of prompt" +COM_GETBIBLE_PROMPTS_EDIT_TOP_P_OVERRIDE="Prompts Edit Top P Override" +COM_GETBIBLE_PROMPTS_EDIT_TOP_P_OVERRIDE_DESC="Allows the users in this group to edit top p override of prompt" +COM_GETBIBLE_PROMPTS_EDIT_VERSION="Prompts Edit Version" +COM_GETBIBLE_PROMPTS_EDIT_VERSION_DESC="Allows users in this group to edit versions of version prompts" +COM_GETBIBLE_PROMPTS_SUBMENU="Prompts Submenu" +COM_GETBIBLE_PROMPTS_SUBMENU_DESC="Allows the users in this group to submenu of prompt" +COM_GETBIBLE_TAGGED_VERSES_ACCESS="Tagged Verses Access" +COM_GETBIBLE_TAGGED_VERSES_ACCESS_DESC="Allows the users in this group to access access tagged verses" +COM_GETBIBLE_TAGGED_VERSES_BATCH_USE="Tagged Verses Batch Use" +COM_GETBIBLE_TAGGED_VERSES_BATCH_USE_DESC="Allows users in this group to use batch copy/update method of batch tagged verses" +COM_GETBIBLE_TAGGED_VERSES_CREATE="Tagged Verses Create" +COM_GETBIBLE_TAGGED_VERSES_CREATE_DESC="Allows the users in this group to create create tagged verses" +COM_GETBIBLE_TAGGED_VERSES_DASHBOARD_LIST="Tagged Verses Dashboard List" +COM_GETBIBLE_TAGGED_VERSES_DASHBOARD_LIST_DESC="Allows the users in this group to dashboard list of tagged verse" +COM_GETBIBLE_TAGGED_VERSES_DELETE="Tagged Verses Delete" +COM_GETBIBLE_TAGGED_VERSES_DELETE_DESC="Allows the users in this group to delete delete tagged verses" +COM_GETBIBLE_TAGGED_VERSES_EDIT="Tagged Verses Edit" +COM_GETBIBLE_TAGGED_VERSES_EDIT_ABBREVIATION="Tagged Verses Edit Abbreviation" +COM_GETBIBLE_TAGGED_VERSES_EDIT_ABBREVIATION_DESC="Allows the users in this group to edit abbreviation of tagged verse" +COM_GETBIBLE_TAGGED_VERSES_EDIT_ACCESS="Tagged Verses Edit Access" +COM_GETBIBLE_TAGGED_VERSES_EDIT_ACCESS_DESC="Allows the users in this group to change the access of the edit access tagged verses" +COM_GETBIBLE_TAGGED_VERSES_EDIT_BOOK_NR="Tagged Verses Edit Book Nr" +COM_GETBIBLE_TAGGED_VERSES_EDIT_BOOK_NR_DESC="Allows the users in this group to edit book nr of tagged verse" +COM_GETBIBLE_TAGGED_VERSES_EDIT_CHAPTER="Tagged Verses Edit Chapter" +COM_GETBIBLE_TAGGED_VERSES_EDIT_CHAPTER_DESC="Allows the users in this group to edit chapter of tagged verse" +COM_GETBIBLE_TAGGED_VERSES_EDIT_CREATED_BY="Tagged Verses Edit Created By" +COM_GETBIBLE_TAGGED_VERSES_EDIT_CREATED_BY_DESC="Allows the users in this group to update the created by of the edit created by tagged verses" +COM_GETBIBLE_TAGGED_VERSES_EDIT_CREATED_DATE="Tagged Verses Edit Created Date" +COM_GETBIBLE_TAGGED_VERSES_EDIT_CREATED_DATE_DESC="Allows the users in this group to update the created date of the edit created tagged verses" +COM_GETBIBLE_TAGGED_VERSES_EDIT_DESC="Allows the users in this group to edit the tagged verse" +COM_GETBIBLE_TAGGED_VERSES_EDIT_GUID="Tagged Verses Edit Guid" +COM_GETBIBLE_TAGGED_VERSES_EDIT_GUID_DESC="Allows the users in this group to edit guid of tagged verse" +COM_GETBIBLE_TAGGED_VERSES_EDIT_LINKER="Tagged Verses Edit Linker" +COM_GETBIBLE_TAGGED_VERSES_EDIT_LINKER_DESC="Allows the users in this group to edit linker of tagged verse" +COM_GETBIBLE_TAGGED_VERSES_EDIT_OWN="Tagged Verses Edit Own" +COM_GETBIBLE_TAGGED_VERSES_EDIT_OWN_DESC="Allows the users in this group to edit edit own tagged verses created by them" +COM_GETBIBLE_TAGGED_VERSES_EDIT_STATE="Tagged Verses Edit State" +COM_GETBIBLE_TAGGED_VERSES_EDIT_STATE_DESC="Allows the users in this group to update the state of the tagged verse" +COM_GETBIBLE_TAGGED_VERSES_EDIT_TAG="Tagged Verses Edit Tag" +COM_GETBIBLE_TAGGED_VERSES_EDIT_TAG_DESC="Allows the users in this group to edit tag of tagged verse" +COM_GETBIBLE_TAGGED_VERSES_EDIT_VERSE="Tagged Verses Edit Verse" +COM_GETBIBLE_TAGGED_VERSES_EDIT_VERSE_DESC="Allows the users in this group to edit verse of tagged verse" +COM_GETBIBLE_TAGGED_VERSES_EDIT_VERSION="Tagged Verses Edit Version" +COM_GETBIBLE_TAGGED_VERSES_EDIT_VERSION_DESC="Allows users in this group to edit versions of version tagged verses" +COM_GETBIBLE_TAGGED_VERSES_SUBMENU="Tagged Verses Submenu" +COM_GETBIBLE_TAGGED_VERSES_SUBMENU_DESC="Allows the users in this group to submenu of tagged verse" +COM_GETBIBLE_TAGS_ACCESS="Tags Access" +COM_GETBIBLE_TAGS_ACCESS_DESC="Allows the users in this group to access access tags" +COM_GETBIBLE_TAGS_BATCH_USE="Tags Batch Use" +COM_GETBIBLE_TAGS_BATCH_USE_DESC="Allows users in this group to use batch copy/update method of batch tags" +COM_GETBIBLE_TAGS_CREATE="Tags Create" +COM_GETBIBLE_TAGS_CREATE_DESC="Allows the users in this group to create create tags" +COM_GETBIBLE_TAGS_DASHBOARD_LIST="Tags Dashboard List" +COM_GETBIBLE_TAGS_DASHBOARD_LIST_DESC="Allows the users in this group to dashboard list of tag" +COM_GETBIBLE_TAGS_DELETE="Tags Delete" +COM_GETBIBLE_TAGS_DELETE_DESC="Allows the users in this group to delete delete tags" +COM_GETBIBLE_TAGS_EDIT="Tags Edit" +COM_GETBIBLE_TAGS_EDIT_ACCESS="Tags Edit Access" +COM_GETBIBLE_TAGS_EDIT_ACCESS_DESC="Allows the users in this group to change the access of the edit access tags" +COM_GETBIBLE_TAGS_EDIT_CREATED_BY="Tags Edit Created By" +COM_GETBIBLE_TAGS_EDIT_CREATED_BY_DESC="Allows the users in this group to update the created by of the edit created by tags" +COM_GETBIBLE_TAGS_EDIT_CREATED_DATE="Tags Edit Created Date" +COM_GETBIBLE_TAGS_EDIT_CREATED_DATE_DESC="Allows the users in this group to update the created date of the edit created tags" +COM_GETBIBLE_TAGS_EDIT_DESC="Allows the users in this group to edit the tag" +COM_GETBIBLE_TAGS_EDIT_DESCRIPTION="Tags Edit Description" +COM_GETBIBLE_TAGS_EDIT_DESCRIPTION_DESC="Allows the users in this group to edit description of tag" +COM_GETBIBLE_TAGS_EDIT_GUID="Tags Edit Guid" +COM_GETBIBLE_TAGS_EDIT_GUID_DESC="Allows the users in this group to edit guid of tag" +COM_GETBIBLE_TAGS_EDIT_LINKER="Tags Edit Linker" +COM_GETBIBLE_TAGS_EDIT_LINKER_DESC="Allows the users in this group to edit linker of tag" +COM_GETBIBLE_TAGS_EDIT_NAME="Tags Edit Name" +COM_GETBIBLE_TAGS_EDIT_NAME_DESC="Allows the users in this group to edit name of tag" +COM_GETBIBLE_TAGS_EDIT_OWN="Tags Edit Own" +COM_GETBIBLE_TAGS_EDIT_OWN_DESC="Allows the users in this group to edit edit own tags created by them" +COM_GETBIBLE_TAGS_EDIT_STATE="Tags Edit State" +COM_GETBIBLE_TAGS_EDIT_STATE_DESC="Allows the users in this group to update the state of the tag" +COM_GETBIBLE_TAGS_EDIT_VERSION="Tags Edit Version" +COM_GETBIBLE_TAGS_EDIT_VERSION_DESC="Allows users in this group to edit versions of version tags" +COM_GETBIBLE_TAGS_SUBMENU="Tags Submenu" +COM_GETBIBLE_TAGS_SUBMENU_DESC="Allows the users in this group to submenu of tag" +COM_GETBIBLE_TRANSLATIONS_ACCESS="Translations Access" +COM_GETBIBLE_TRANSLATIONS_ACCESS_DESC="Allows the users in this group to access access translations" +COM_GETBIBLE_TRANSLATIONS_BATCH_USE="Translations Batch Use" +COM_GETBIBLE_TRANSLATIONS_BATCH_USE_DESC="Allows users in this group to use batch copy/update method of batch translations" +COM_GETBIBLE_TRANSLATIONS_CREATE="Translations Create" +COM_GETBIBLE_TRANSLATIONS_CREATE_DESC="Allows the users in this group to create create translations" +COM_GETBIBLE_TRANSLATIONS_DASHBOARD_LIST="Translations Dashboard List" +COM_GETBIBLE_TRANSLATIONS_DASHBOARD_LIST_DESC="Allows the users in this group to dashboard list of translation" +COM_GETBIBLE_TRANSLATIONS_DELETE="Translations Delete" +COM_GETBIBLE_TRANSLATIONS_DELETE_DESC="Allows the users in this group to delete delete translations" +COM_GETBIBLE_TRANSLATIONS_EDIT="Translations Edit" +COM_GETBIBLE_TRANSLATIONS_EDIT_ABBREVIATION="Translations Edit Abbreviation" +COM_GETBIBLE_TRANSLATIONS_EDIT_ABBREVIATION_DESC="Allows the users in this group to edit abbreviation of translation" +COM_GETBIBLE_TRANSLATIONS_EDIT_CREATED_BY="Translations Edit Created By" +COM_GETBIBLE_TRANSLATIONS_EDIT_CREATED_BY_DESC="Allows the users in this group to update the created by of the edit created by translations" +COM_GETBIBLE_TRANSLATIONS_EDIT_CREATED_DATE="Translations Edit Created Date" +COM_GETBIBLE_TRANSLATIONS_EDIT_CREATED_DATE_DESC="Allows the users in this group to update the created date of the edit created translations" +COM_GETBIBLE_TRANSLATIONS_EDIT_DESC="Allows the users in this group to edit the translation" +COM_GETBIBLE_TRANSLATIONS_EDIT_DIRECTION="Translations Edit Direction" +COM_GETBIBLE_TRANSLATIONS_EDIT_DIRECTION_DESC="Allows the users in this group to edit direction of translation" +COM_GETBIBLE_TRANSLATIONS_EDIT_DISTRIBUTION_ABBREVIATION="Translations Edit Distribution Abbreviation" +COM_GETBIBLE_TRANSLATIONS_EDIT_DISTRIBUTION_ABBREVIATION_DESC="Allows the users in this group to edit distribution abbreviation of translation" +COM_GETBIBLE_TRANSLATIONS_EDIT_DISTRIBUTION_ABOUT="Translations Edit Distribution About" +COM_GETBIBLE_TRANSLATIONS_EDIT_DISTRIBUTION_ABOUT_DESC="Allows the users in this group to edit distribution about of translation" +COM_GETBIBLE_TRANSLATIONS_EDIT_DISTRIBUTION_HISTORY="Translations Edit Distribution History" +COM_GETBIBLE_TRANSLATIONS_EDIT_DISTRIBUTION_HISTORY_DESC="Allows the users in this group to edit distribution history of translation" +COM_GETBIBLE_TRANSLATIONS_EDIT_DISTRIBUTION_LCSH="Translations Edit Distribution Lcsh" +COM_GETBIBLE_TRANSLATIONS_EDIT_DISTRIBUTION_LCSH_DESC="Allows the users in this group to edit distribution lcsh of translation" +COM_GETBIBLE_TRANSLATIONS_EDIT_DISTRIBUTION_LICENSE="Translations Edit Distribution License" +COM_GETBIBLE_TRANSLATIONS_EDIT_DISTRIBUTION_LICENSE_DESC="Allows the users in this group to edit distribution license of translation" +COM_GETBIBLE_TRANSLATIONS_EDIT_DISTRIBUTION_SOURCE="Translations Edit Distribution Source" +COM_GETBIBLE_TRANSLATIONS_EDIT_DISTRIBUTION_SOURCETYPE="Translations Edit Distribution Sourcetype" +COM_GETBIBLE_TRANSLATIONS_EDIT_DISTRIBUTION_SOURCETYPE_DESC="Allows the users in this group to edit distribution sourcetype of translation" +COM_GETBIBLE_TRANSLATIONS_EDIT_DISTRIBUTION_SOURCE_DESC="Allows the users in this group to edit distribution source of translation" +COM_GETBIBLE_TRANSLATIONS_EDIT_DISTRIBUTION_VERSIFICATION="Translations Edit Distribution Versification" +COM_GETBIBLE_TRANSLATIONS_EDIT_DISTRIBUTION_VERSIFICATION_DESC="Allows the users in this group to edit distribution versification of translation" +COM_GETBIBLE_TRANSLATIONS_EDIT_DISTRIBUTION_VERSION="Translations Edit Distribution Version" +COM_GETBIBLE_TRANSLATIONS_EDIT_DISTRIBUTION_VERSION_DATE="Translations Edit Distribution Version Date" +COM_GETBIBLE_TRANSLATIONS_EDIT_DISTRIBUTION_VERSION_DATE_DESC="Allows the users in this group to edit distribution version date of translation" +COM_GETBIBLE_TRANSLATIONS_EDIT_DISTRIBUTION_VERSION_DESC="Allows the users in this group to edit distribution version of translation" +COM_GETBIBLE_TRANSLATIONS_EDIT_ENCODING="Translations Edit Encoding" +COM_GETBIBLE_TRANSLATIONS_EDIT_ENCODING_DESC="Allows the users in this group to edit encoding of translation" +COM_GETBIBLE_TRANSLATIONS_EDIT_LANG="Translations Edit Lang" +COM_GETBIBLE_TRANSLATIONS_EDIT_LANGUAGE="Translations Edit Language" +COM_GETBIBLE_TRANSLATIONS_EDIT_LANGUAGE_DESC="Allows the users in this group to edit language of translation" +COM_GETBIBLE_TRANSLATIONS_EDIT_LANG_DESC="Allows the users in this group to edit lang of translation" +COM_GETBIBLE_TRANSLATIONS_EDIT_OWN="Translations Edit Own" +COM_GETBIBLE_TRANSLATIONS_EDIT_OWN_DESC="Allows the users in this group to edit edit own translations created by them" +COM_GETBIBLE_TRANSLATIONS_EDIT_SHA="Translations Edit Sha" +COM_GETBIBLE_TRANSLATIONS_EDIT_SHA_DESC="Allows the users in this group to edit sha of translation" +COM_GETBIBLE_TRANSLATIONS_EDIT_STATE="Translations Edit State" +COM_GETBIBLE_TRANSLATIONS_EDIT_STATE_DESC="Allows the users in this group to update the state of the translation" +COM_GETBIBLE_TRANSLATIONS_EDIT_TRANSLATION="Translations Edit Translation" +COM_GETBIBLE_TRANSLATIONS_EDIT_TRANSLATION_DESC="Allows the users in this group to edit translation of translation" +COM_GETBIBLE_TRANSLATIONS_SUBMENU="Translations Submenu" +COM_GETBIBLE_TRANSLATIONS_SUBMENU_DESC="Allows the users in this group to submenu of translation" +COM_GETBIBLE_USE_BATCH="Use Batch" +COM_GETBIBLE_USE_BATCH_DESC="Allows users in this group to use batch copy/update method." +COM_GETBIBLE_VERSES_ACCESS="Verses Access" +COM_GETBIBLE_VERSES_ACCESS_DESC="Allows the users in this group to access access verses" +COM_GETBIBLE_VERSES_BATCH_USE="Verses Batch Use" +COM_GETBIBLE_VERSES_BATCH_USE_DESC="Allows users in this group to use batch copy/update method of batch verses" +COM_GETBIBLE_VERSES_CREATE="Verses Create" +COM_GETBIBLE_VERSES_CREATE_DESC="Allows the users in this group to create create verses" +COM_GETBIBLE_VERSES_DASHBOARD_LIST="Verses Dashboard List" +COM_GETBIBLE_VERSES_DASHBOARD_LIST_DESC="Allows the users in this group to dashboard list of verse" +COM_GETBIBLE_VERSES_DELETE="Verses Delete" +COM_GETBIBLE_VERSES_DELETE_DESC="Allows the users in this group to delete delete verses" +COM_GETBIBLE_VERSES_EDIT="Verses Edit" +COM_GETBIBLE_VERSES_EDIT_ABBREVIATION="Verses Edit Abbreviation" +COM_GETBIBLE_VERSES_EDIT_ABBREVIATION_DESC="Allows the users in this group to edit abbreviation of verse" +COM_GETBIBLE_VERSES_EDIT_BOOK_NR="Verses Edit Book Nr" +COM_GETBIBLE_VERSES_EDIT_BOOK_NR_DESC="Allows the users in this group to edit book nr of verse" +COM_GETBIBLE_VERSES_EDIT_CHAPTER="Verses Edit Chapter" +COM_GETBIBLE_VERSES_EDIT_CHAPTER_DESC="Allows the users in this group to edit chapter of verse" +COM_GETBIBLE_VERSES_EDIT_CREATED_BY="Verses Edit Created By" +COM_GETBIBLE_VERSES_EDIT_CREATED_BY_DESC="Allows the users in this group to update the created by of the edit created by verses" +COM_GETBIBLE_VERSES_EDIT_CREATED_DATE="Verses Edit Created Date" +COM_GETBIBLE_VERSES_EDIT_CREATED_DATE_DESC="Allows the users in this group to update the created date of the edit created verses" +COM_GETBIBLE_VERSES_EDIT_DESC="Allows the users in this group to edit the verse" +COM_GETBIBLE_VERSES_EDIT_NAME="Verses Edit Name" +COM_GETBIBLE_VERSES_EDIT_NAME_DESC="Allows the users in this group to edit name of verse" +COM_GETBIBLE_VERSES_EDIT_OWN="Verses Edit Own" +COM_GETBIBLE_VERSES_EDIT_OWN_DESC="Allows the users in this group to edit edit own verses created by them" +COM_GETBIBLE_VERSES_EDIT_STATE="Verses Edit State" +COM_GETBIBLE_VERSES_EDIT_STATE_DESC="Allows the users in this group to update the state of the verse" +COM_GETBIBLE_VERSES_EDIT_TEXT="Verses Edit Text" +COM_GETBIBLE_VERSES_EDIT_TEXT_DESC="Allows the users in this group to edit text of verse" +COM_GETBIBLE_VERSES_EDIT_VERSE="Verses Edit Verse" +COM_GETBIBLE_VERSES_EDIT_VERSE_DESC="Allows the users in this group to edit verse of verse" +COM_GETBIBLE_VERSES_SUBMENU="Verses Submenu" +COM_GETBIBLE_VERSES_SUBMENU_DESC="Allows the users in this group to submenu of verse" \ No newline at end of file diff --git a/admin/language/en-GB/index.html b/admin/language/en-GB/index.html new file mode 100644 index 0000000..fa6d84e --- /dev/null +++ b/admin/language/en-GB/index.html @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/admin/language/index.html b/admin/language/index.html new file mode 100644 index 0000000..fa6d84e --- /dev/null +++ b/admin/language/index.html @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/admin/layouts/batchselection.php b/admin/layouts/batchselection.php new file mode 100644 index 0000000..8d8a328 --- /dev/null +++ b/admin/layouts/batchselection.php @@ -0,0 +1,54 @@ + + @git Get Bible + @github Get Bible + @support Get Bible + @copyright Copyright (C) 2015. All Rights Reserved + @license GNU/GPL Version 2 or later - http://www.gnu.org/licenses/gpl-2.0.html + +/------------------------------------------------------------------------------------------------------*/ + +// No direct access to this file +defined('JPATH_BASE') or die; + +JHtmlBehavior::core(); +$divWrapper = range(1,120,2); +$counter = 0; +?> +ListSelection) : ?> +
+ ListSelection as $ListSelection) : ?> +
+
+ + +
+
+ +
+
+ + + +
+
+
+ + +
+
+ \ No newline at end of file diff --git a/admin/layouts/book/details_above.php b/admin/layouts/book/details_above.php new file mode 100644 index 0000000..c896606 --- /dev/null +++ b/admin/layouts/book/details_above.php @@ -0,0 +1,51 @@ + + @git Get Bible + @github Get Bible + @support Get Bible + @copyright Copyright (C) 2015. All Rights Reserved + @license GNU/GPL Version 2 or later - http://www.gnu.org/licenses/gpl-2.0.html + +/------------------------------------------------------------------------------------------------------*/ + +// No direct access to this file +defined('_JEXEC') or die('Restricted access'); + +// get the form +$form = $displayData->getForm(); + +// get the layout fields override method name (from layout path/ID) +$layout_path_array = explode('.', $this->getLayoutId()); +// Since we cannot pass the layout and tab names as parameters to the model method +// this name combination of tab and layout in the method name is the only work around +// seeing that JCB uses those two values (tab_name & layout_name) as the layout file name. +// example of layout name: details_left.php +// example of method name: getFields_details_left() +$fields_tab_layout = 'fields_' . $layout_path_array[1]; + +// get the fields +$fields = $displayData->get($fields_tab_layout) ?: array( + 'name', + 'nr' +); + +$hiddenFields = $displayData->get('hidden_fields') ?: array(); + +?> + +
+ + + setFieldAttribute($field, 'type', 'hidden'); ?> + + renderField($field, null, null, array('class' => 'control-wrapper-' . $field)); ?> + +
+ diff --git a/admin/layouts/book/details_left.php b/admin/layouts/book/details_left.php new file mode 100644 index 0000000..88f95d4 --- /dev/null +++ b/admin/layouts/book/details_left.php @@ -0,0 +1,48 @@ + + @git Get Bible + @github Get Bible + @support Get Bible + @copyright Copyright (C) 2015. All Rights Reserved + @license GNU/GPL Version 2 or later - http://www.gnu.org/licenses/gpl-2.0.html + +/------------------------------------------------------------------------------------------------------*/ + +// No direct access to this file +defined('_JEXEC') or die('Restricted access'); + +// get the form +$form = $displayData->getForm(); + +// get the layout fields override method name (from layout path/ID) +$layout_path_array = explode('.', $this->getLayoutId()); +// Since we cannot pass the layout and tab names as parameters to the model method +// this name combination of tab and layout in the method name is the only work around +// seeing that JCB uses those two values (tab_name & layout_name) as the layout file name. +// example of layout name: details_left.php +// example of method name: getFields_details_left() +$fields_tab_layout = 'fields_' . $layout_path_array[1]; + +// get the fields +$fields = $displayData->get($fields_tab_layout) ?: array( + 'abbreviation' +); + +$hiddenFields = $displayData->get('hidden_fields') ?: array(); + +?> + + + + setFieldAttribute($field, 'type', 'hidden'); ?> + + renderField($field, null, null, array('class' => 'control-wrapper-' . $field)); ?> + + diff --git a/admin/layouts/book/details_right.php b/admin/layouts/book/details_right.php new file mode 100644 index 0000000..e4e14f4 --- /dev/null +++ b/admin/layouts/book/details_right.php @@ -0,0 +1,48 @@ + + @git Get Bible + @github Get Bible + @support Get Bible + @copyright Copyright (C) 2015. All Rights Reserved + @license GNU/GPL Version 2 or later - http://www.gnu.org/licenses/gpl-2.0.html + +/------------------------------------------------------------------------------------------------------*/ + +// No direct access to this file +defined('_JEXEC') or die('Restricted access'); + +// get the form +$form = $displayData->getForm(); + +// get the layout fields override method name (from layout path/ID) +$layout_path_array = explode('.', $this->getLayoutId()); +// Since we cannot pass the layout and tab names as parameters to the model method +// this name combination of tab and layout in the method name is the only work around +// seeing that JCB uses those two values (tab_name & layout_name) as the layout file name. +// example of layout name: details_left.php +// example of method name: getFields_details_left() +$fields_tab_layout = 'fields_' . $layout_path_array[1]; + +// get the fields +$fields = $displayData->get($fields_tab_layout) ?: array( + 'sha' +); + +$hiddenFields = $displayData->get('hidden_fields') ?: array(); + +?> + + + + setFieldAttribute($field, 'type', 'hidden'); ?> + + renderField($field, null, null, array('class' => 'control-wrapper-' . $field)); ?> + + diff --git a/admin/layouts/book/index.html b/admin/layouts/book/index.html new file mode 100644 index 0000000..fa6d84e --- /dev/null +++ b/admin/layouts/book/index.html @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/admin/layouts/book/publishing.php b/admin/layouts/book/publishing.php new file mode 100644 index 0000000..df756a0 --- /dev/null +++ b/admin/layouts/book/publishing.php @@ -0,0 +1,52 @@ + + @git Get Bible + @github Get Bible + @support Get Bible + @copyright Copyright (C) 2015. All Rights Reserved + @license GNU/GPL Version 2 or later - http://www.gnu.org/licenses/gpl-2.0.html + +/------------------------------------------------------------------------------------------------------*/ + +// No direct access to this file +defined('_JEXEC') or die('Restricted access'); + +// get the form +$form = $displayData->getForm(); + +// get the layout fields override method name (from layout path/ID) +$layout_path_array = explode('.', $this->getLayoutId()); +// Since we cannot pass the layout and tab names as parameters to the model method +// this name combination of tab and layout in the method name is the only work around +// seeing that JCB uses those two values (tab_name & layout_name) as the layout file name. +// example of layout name: details_left.php +// example of method name: getFields_details_left() +$fields_tab_layout = 'fields_' . $layout_path_array[1]; + +// get the fields +$fields = $displayData->get($fields_tab_layout) ?: array( + 'title', + 'created', + 'created_by', + 'modified', + 'modified_by' +); + +$hiddenFields = $displayData->get('hidden_fields') ?: array(); + +?> + + + + setFieldAttribute($field, 'type', 'hidden'); ?> + + renderField($field, null, null, array('class' => 'control-wrapper-' . $field)); ?> + + diff --git a/admin/layouts/book/publlshing.php b/admin/layouts/book/publlshing.php new file mode 100644 index 0000000..171f8c2 --- /dev/null +++ b/admin/layouts/book/publlshing.php @@ -0,0 +1,53 @@ + + @git Get Bible + @github Get Bible + @support Get Bible + @copyright Copyright (C) 2015. All Rights Reserved + @license GNU/GPL Version 2 or later - http://www.gnu.org/licenses/gpl-2.0.html + +/------------------------------------------------------------------------------------------------------*/ + +// No direct access to this file +defined('_JEXEC') or die('Restricted access'); + +// get the form +$form = $displayData->getForm(); + +// get the layout fields override method name (from layout path/ID) +$layout_path_array = explode('.', $this->getLayoutId()); +// Since we cannot pass the layout and tab names as parameters to the model method +// this name combination of tab and layout in the method name is the only work around +// seeing that JCB uses those two values (tab_name & layout_name) as the layout file name. +// example of layout name: details_left.php +// example of method name: getFields_details_left() +$fields_tab_layout = 'fields_' . $layout_path_array[1]; + +// get the fields +$fields = $displayData->get($fields_tab_layout) ?: array( + 'published', + 'ordering', + 'access', + 'version', + 'hits', + 'id' +); + +$hiddenFields = $displayData->get('hidden_fields') ?: array(); + +?> + + + + setFieldAttribute($field, 'type', 'hidden'); ?> + + renderField($field, null, null, array('class' => 'control-wrapper-' . $field)); ?> + + diff --git a/admin/layouts/chapter/details_above.php b/admin/layouts/chapter/details_above.php new file mode 100644 index 0000000..a21caa4 --- /dev/null +++ b/admin/layouts/chapter/details_above.php @@ -0,0 +1,52 @@ + + @git Get Bible + @github Get Bible + @support Get Bible + @copyright Copyright (C) 2015. All Rights Reserved + @license GNU/GPL Version 2 or later - http://www.gnu.org/licenses/gpl-2.0.html + +/------------------------------------------------------------------------------------------------------*/ + +// No direct access to this file +defined('_JEXEC') or die('Restricted access'); + +// get the form +$form = $displayData->getForm(); + +// get the layout fields override method name (from layout path/ID) +$layout_path_array = explode('.', $this->getLayoutId()); +// Since we cannot pass the layout and tab names as parameters to the model method +// this name combination of tab and layout in the method name is the only work around +// seeing that JCB uses those two values (tab_name & layout_name) as the layout file name. +// example of layout name: details_left.php +// example of method name: getFields_details_left() +$fields_tab_layout = 'fields_' . $layout_path_array[1]; + +// get the fields +$fields = $displayData->get($fields_tab_layout) ?: array( + 'name', + 'chapter', + 'book_nr' +); + +$hiddenFields = $displayData->get('hidden_fields') ?: array(); + +?> + +
+ + + setFieldAttribute($field, 'type', 'hidden'); ?> + + renderField($field, null, null, array('class' => 'control-wrapper-' . $field)); ?> + +
+ diff --git a/admin/layouts/chapter/details_left.php b/admin/layouts/chapter/details_left.php new file mode 100644 index 0000000..88f95d4 --- /dev/null +++ b/admin/layouts/chapter/details_left.php @@ -0,0 +1,48 @@ + + @git Get Bible + @github Get Bible + @support Get Bible + @copyright Copyright (C) 2015. All Rights Reserved + @license GNU/GPL Version 2 or later - http://www.gnu.org/licenses/gpl-2.0.html + +/------------------------------------------------------------------------------------------------------*/ + +// No direct access to this file +defined('_JEXEC') or die('Restricted access'); + +// get the form +$form = $displayData->getForm(); + +// get the layout fields override method name (from layout path/ID) +$layout_path_array = explode('.', $this->getLayoutId()); +// Since we cannot pass the layout and tab names as parameters to the model method +// this name combination of tab and layout in the method name is the only work around +// seeing that JCB uses those two values (tab_name & layout_name) as the layout file name. +// example of layout name: details_left.php +// example of method name: getFields_details_left() +$fields_tab_layout = 'fields_' . $layout_path_array[1]; + +// get the fields +$fields = $displayData->get($fields_tab_layout) ?: array( + 'abbreviation' +); + +$hiddenFields = $displayData->get('hidden_fields') ?: array(); + +?> + + + + setFieldAttribute($field, 'type', 'hidden'); ?> + + renderField($field, null, null, array('class' => 'control-wrapper-' . $field)); ?> + + diff --git a/admin/layouts/chapter/details_right.php b/admin/layouts/chapter/details_right.php new file mode 100644 index 0000000..e4e14f4 --- /dev/null +++ b/admin/layouts/chapter/details_right.php @@ -0,0 +1,48 @@ + + @git Get Bible + @github Get Bible + @support Get Bible + @copyright Copyright (C) 2015. All Rights Reserved + @license GNU/GPL Version 2 or later - http://www.gnu.org/licenses/gpl-2.0.html + +/------------------------------------------------------------------------------------------------------*/ + +// No direct access to this file +defined('_JEXEC') or die('Restricted access'); + +// get the form +$form = $displayData->getForm(); + +// get the layout fields override method name (from layout path/ID) +$layout_path_array = explode('.', $this->getLayoutId()); +// Since we cannot pass the layout and tab names as parameters to the model method +// this name combination of tab and layout in the method name is the only work around +// seeing that JCB uses those two values (tab_name & layout_name) as the layout file name. +// example of layout name: details_left.php +// example of method name: getFields_details_left() +$fields_tab_layout = 'fields_' . $layout_path_array[1]; + +// get the fields +$fields = $displayData->get($fields_tab_layout) ?: array( + 'sha' +); + +$hiddenFields = $displayData->get('hidden_fields') ?: array(); + +?> + + + + setFieldAttribute($field, 'type', 'hidden'); ?> + + renderField($field, null, null, array('class' => 'control-wrapper-' . $field)); ?> + + diff --git a/admin/layouts/chapter/index.html b/admin/layouts/chapter/index.html new file mode 100644 index 0000000..fa6d84e --- /dev/null +++ b/admin/layouts/chapter/index.html @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/admin/layouts/chapter/publishing.php b/admin/layouts/chapter/publishing.php new file mode 100644 index 0000000..df756a0 --- /dev/null +++ b/admin/layouts/chapter/publishing.php @@ -0,0 +1,52 @@ + + @git Get Bible + @github Get Bible + @support Get Bible + @copyright Copyright (C) 2015. All Rights Reserved + @license GNU/GPL Version 2 or later - http://www.gnu.org/licenses/gpl-2.0.html + +/------------------------------------------------------------------------------------------------------*/ + +// No direct access to this file +defined('_JEXEC') or die('Restricted access'); + +// get the form +$form = $displayData->getForm(); + +// get the layout fields override method name (from layout path/ID) +$layout_path_array = explode('.', $this->getLayoutId()); +// Since we cannot pass the layout and tab names as parameters to the model method +// this name combination of tab and layout in the method name is the only work around +// seeing that JCB uses those two values (tab_name & layout_name) as the layout file name. +// example of layout name: details_left.php +// example of method name: getFields_details_left() +$fields_tab_layout = 'fields_' . $layout_path_array[1]; + +// get the fields +$fields = $displayData->get($fields_tab_layout) ?: array( + 'title', + 'created', + 'created_by', + 'modified', + 'modified_by' +); + +$hiddenFields = $displayData->get('hidden_fields') ?: array(); + +?> + + + + setFieldAttribute($field, 'type', 'hidden'); ?> + + renderField($field, null, null, array('class' => 'control-wrapper-' . $field)); ?> + + diff --git a/admin/layouts/chapter/publlshing.php b/admin/layouts/chapter/publlshing.php new file mode 100644 index 0000000..171f8c2 --- /dev/null +++ b/admin/layouts/chapter/publlshing.php @@ -0,0 +1,53 @@ + + @git Get Bible + @github Get Bible + @support Get Bible + @copyright Copyright (C) 2015. All Rights Reserved + @license GNU/GPL Version 2 or later - http://www.gnu.org/licenses/gpl-2.0.html + +/------------------------------------------------------------------------------------------------------*/ + +// No direct access to this file +defined('_JEXEC') or die('Restricted access'); + +// get the form +$form = $displayData->getForm(); + +// get the layout fields override method name (from layout path/ID) +$layout_path_array = explode('.', $this->getLayoutId()); +// Since we cannot pass the layout and tab names as parameters to the model method +// this name combination of tab and layout in the method name is the only work around +// seeing that JCB uses those two values (tab_name & layout_name) as the layout file name. +// example of layout name: details_left.php +// example of method name: getFields_details_left() +$fields_tab_layout = 'fields_' . $layout_path_array[1]; + +// get the fields +$fields = $displayData->get($fields_tab_layout) ?: array( + 'published', + 'ordering', + 'access', + 'version', + 'hits', + 'id' +); + +$hiddenFields = $displayData->get('hidden_fields') ?: array(); + +?> + + + + setFieldAttribute($field, 'type', 'hidden'); ?> + + renderField($field, null, null, array('class' => 'control-wrapper-' . $field)); ?> + + diff --git a/admin/layouts/index.html b/admin/layouts/index.html new file mode 100644 index 0000000..fa6d84e --- /dev/null +++ b/admin/layouts/index.html @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/admin/layouts/linker/details_left.php b/admin/layouts/linker/details_left.php new file mode 100644 index 0000000..e867d90 --- /dev/null +++ b/admin/layouts/linker/details_left.php @@ -0,0 +1,48 @@ + + @git Get Bible + @github Get Bible + @support Get Bible + @copyright Copyright (C) 2015. All Rights Reserved + @license GNU/GPL Version 2 or later - http://www.gnu.org/licenses/gpl-2.0.html + +/------------------------------------------------------------------------------------------------------*/ + +// No direct access to this file +defined('_JEXEC') or die('Restricted access'); + +// get the form +$form = $displayData->getForm(); + +// get the layout fields override method name (from layout path/ID) +$layout_path_array = explode('.', $this->getLayoutId()); +// Since we cannot pass the layout and tab names as parameters to the model method +// this name combination of tab and layout in the method name is the only work around +// seeing that JCB uses those two values (tab_name & layout_name) as the layout file name. +// example of layout name: details_left.php +// example of method name: getFields_details_left() +$fields_tab_layout = 'fields_' . $layout_path_array[1]; + +// get the fields +$fields = $displayData->get($fields_tab_layout) ?: array( + 'name' +); + +$hiddenFields = $displayData->get('hidden_fields') ?: array(); + +?> + + + + setFieldAttribute($field, 'type', 'hidden'); ?> + + renderField($field, null, null, array('class' => 'control-wrapper-' . $field)); ?> + + diff --git a/admin/layouts/linker/index.html b/admin/layouts/linker/index.html new file mode 100644 index 0000000..fa6d84e --- /dev/null +++ b/admin/layouts/linker/index.html @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/admin/layouts/linker/notes_fullwidth.php b/admin/layouts/linker/notes_fullwidth.php new file mode 100644 index 0000000..57a7669 --- /dev/null +++ b/admin/layouts/linker/notes_fullwidth.php @@ -0,0 +1,149 @@ + + @git Get Bible + @github Get Bible + @support Get Bible + @copyright Copyright (C) 2015. All Rights Reserved + @license GNU/GPL Version 2 or later - http://www.gnu.org/licenses/gpl-2.0.html + +/------------------------------------------------------------------------------------------------------*/ + +// No direct access to this file +defined('_JEXEC') or die('Restricted access'); + +// set the defaults +$items = $displayData->vvwnotes; +$user = JFactory::getUser(); +$id = $displayData->item->id; +// set the edit URL +$edit = "index.php?option=com_getbible&view=notes&task=note.edit"; +// set a return value +$return = ($id) ? "index.php?option=com_getbible&view=linker&layout=edit&id=" . $id : ""; +// check for a return value +$jinput = JFactory::getApplication()->input; +if ($_return = $jinput->get('return', null, 'base64')) +{ + $return .= "&return=" . $_return; +} +// check if return value was set +if (GetbibleHelper::checkString($return)) +{ + // set the referral values + $ref = ($id) ? "&ref=linker&refid=" . $id . "&return=" . urlencode(base64_encode($return)) : "&return=" . urlencode(base64_encode($return)); +} +else +{ + $ref = ($id) ? "&ref=linker&refid=" . $id : ""; +} +// set the create new URL +$new = "index.php?option=com_getbible&view=notes&task=note.edit" . $ref; +// set the create new and close URL +$close_new = "index.php?option=com_getbible&view=notes&task=note.edit"; +// load the action object +$can = GetbibleHelper::getActions('note'); + +?> +
+get('note.create')): ?> +
+ + +


+ + + + + + + + + + + + + + $item): ?> + authorise('core.manage', 'com_checkin') || $item->checked_out == $user->id || $item->checked_out == 0; + $userChkOut = JFactory::getUser($item->checked_out); + $canDo = GetbibleHelper::getActions('note',$item,'notes'); + ?> + + + + + published == 1): ?> + + published == 0): ?> + + published == 2): ?> + + published == -2): ?> + + + + + + + + + + + +
+ + + + + + + + + +
+ get('note.edit')): ?> + escape($item->book_nr); ?> + checked_out): ?> + name, $item->checked_out_time, 'notes.', $canCheckin); ?> + + + escape($item->book_nr); ?> + + + escape($item->linker_name); ?> + + access); ?> + + + + + + + + + + + + + + + + + + id; ?> +
+ +
+ +
+ +
+ +
diff --git a/admin/layouts/linker/passwords_fullwidth.php b/admin/layouts/linker/passwords_fullwidth.php new file mode 100644 index 0000000..43406bd --- /dev/null +++ b/admin/layouts/linker/passwords_fullwidth.php @@ -0,0 +1,149 @@ + + @git Get Bible + @github Get Bible + @support Get Bible + @copyright Copyright (C) 2015. All Rights Reserved + @license GNU/GPL Version 2 or later - http://www.gnu.org/licenses/gpl-2.0.html + +/------------------------------------------------------------------------------------------------------*/ + +// No direct access to this file +defined('_JEXEC') or die('Restricted access'); + +// set the defaults +$items = $displayData->vvxpasswords; +$user = JFactory::getUser(); +$id = $displayData->item->id; +// set the edit URL +$edit = "index.php?option=com_getbible&view=passwords&task=password.edit"; +// set a return value +$return = ($id) ? "index.php?option=com_getbible&view=linker&layout=edit&id=" . $id : ""; +// check for a return value +$jinput = JFactory::getApplication()->input; +if ($_return = $jinput->get('return', null, 'base64')) +{ + $return .= "&return=" . $_return; +} +// check if return value was set +if (GetbibleHelper::checkString($return)) +{ + // set the referral values + $ref = ($id) ? "&ref=linker&refid=" . $id . "&return=" . urlencode(base64_encode($return)) : "&return=" . urlencode(base64_encode($return)); +} +else +{ + $ref = ($id) ? "&ref=linker&refid=" . $id : ""; +} +// set the create new URL +$new = "index.php?option=com_getbible&view=passwords&task=password.edit" . $ref; +// set the create new and close URL +$close_new = "index.php?option=com_getbible&view=passwords&task=password.edit"; +// load the action object +$can = GetbibleHelper::getActions('password'); + +?> +
+get('password.create')): ?> +
+ + +


+ + + + + + + + + + + + + + $item): ?> + authorise('core.manage', 'com_checkin') || $item->checked_out == $user->id || $item->checked_out == 0; + $userChkOut = JFactory::getUser($item->checked_out); + $canDo = GetbibleHelper::getActions('password',$item,'passwords'); + ?> + + + + + published == 1): ?> + + published == 0): ?> + + published == 2): ?> + + published == -2): ?> + + + + + + + + + + + +
+ + + + + + + + + +
+ get('password.edit')): ?> + escape($item->name); ?> + checked_out): ?> + name, $item->checked_out_time, 'passwords.', $canCheckin); ?> + + + escape($item->name); ?> + + + escape($item->linker_name); ?> + + escape($item->guid); ?> + + + + + + + + + + + + + + + + + + id; ?> +
+ +
+ +
+ +
+ +
diff --git a/admin/layouts/linker/publishing.php b/admin/layouts/linker/publishing.php new file mode 100644 index 0000000..72020c7 --- /dev/null +++ b/admin/layouts/linker/publishing.php @@ -0,0 +1,53 @@ + + @git Get Bible + @github Get Bible + @support Get Bible + @copyright Copyright (C) 2015. All Rights Reserved + @license GNU/GPL Version 2 or later - http://www.gnu.org/licenses/gpl-2.0.html + +/------------------------------------------------------------------------------------------------------*/ + +// No direct access to this file +defined('_JEXEC') or die('Restricted access'); + +// get the form +$form = $displayData->getForm(); + +// get the layout fields override method name (from layout path/ID) +$layout_path_array = explode('.', $this->getLayoutId()); +// Since we cannot pass the layout and tab names as parameters to the model method +// this name combination of tab and layout in the method name is the only work around +// seeing that JCB uses those two values (tab_name & layout_name) as the layout file name. +// example of layout name: details_left.php +// example of method name: getFields_details_left() +$fields_tab_layout = 'fields_' . $layout_path_array[1]; + +// get the fields +$fields = $displayData->get($fields_tab_layout) ?: array( + 'guid', + 'title', + 'created', + 'created_by', + 'modified', + 'modified_by' +); + +$hiddenFields = $displayData->get('hidden_fields') ?: array(); + +?> + + + + setFieldAttribute($field, 'type', 'hidden'); ?> + + renderField($field, null, null, array('class' => 'control-wrapper-' . $field)); ?> + + diff --git a/admin/layouts/linker/publlshing.php b/admin/layouts/linker/publlshing.php new file mode 100644 index 0000000..171f8c2 --- /dev/null +++ b/admin/layouts/linker/publlshing.php @@ -0,0 +1,53 @@ + + @git Get Bible + @github Get Bible + @support Get Bible + @copyright Copyright (C) 2015. All Rights Reserved + @license GNU/GPL Version 2 or later - http://www.gnu.org/licenses/gpl-2.0.html + +/------------------------------------------------------------------------------------------------------*/ + +// No direct access to this file +defined('_JEXEC') or die('Restricted access'); + +// get the form +$form = $displayData->getForm(); + +// get the layout fields override method name (from layout path/ID) +$layout_path_array = explode('.', $this->getLayoutId()); +// Since we cannot pass the layout and tab names as parameters to the model method +// this name combination of tab and layout in the method name is the only work around +// seeing that JCB uses those two values (tab_name & layout_name) as the layout file name. +// example of layout name: details_left.php +// example of method name: getFields_details_left() +$fields_tab_layout = 'fields_' . $layout_path_array[1]; + +// get the fields +$fields = $displayData->get($fields_tab_layout) ?: array( + 'published', + 'ordering', + 'access', + 'version', + 'hits', + 'id' +); + +$hiddenFields = $displayData->get('hidden_fields') ?: array(); + +?> + + + + setFieldAttribute($field, 'type', 'hidden'); ?> + + renderField($field, null, null, array('class' => 'control-wrapper-' . $field)); ?> + + diff --git a/admin/layouts/linker/tags_fullwidth.php b/admin/layouts/linker/tags_fullwidth.php new file mode 100644 index 0000000..1c4775e --- /dev/null +++ b/admin/layouts/linker/tags_fullwidth.php @@ -0,0 +1,169 @@ + + @git Get Bible + @github Get Bible + @support Get Bible + @copyright Copyright (C) 2015. All Rights Reserved + @license GNU/GPL Version 2 or later - http://www.gnu.org/licenses/gpl-2.0.html + +/------------------------------------------------------------------------------------------------------*/ + +// No direct access to this file +defined('_JEXEC') or die('Restricted access'); + +// set the defaults +$items = $displayData->vvvtags; +$user = JFactory::getUser(); +$id = $displayData->item->id; +// set the edit URL +$edit = "index.php?option=com_getbible&view=tagged_verses&task=tagged_verse.edit"; +// set a return value +$return = ($id) ? "index.php?option=com_getbible&view=linker&layout=edit&id=" . $id : ""; +// check for a return value +$jinput = JFactory::getApplication()->input; +if ($_return = $jinput->get('return', null, 'base64')) +{ + $return .= "&return=" . $_return; +} +// check if return value was set +if (GetbibleHelper::checkString($return)) +{ + // set the referral values + $ref = ($id) ? "&ref=linker&refid=" . $id . "&return=" . urlencode(base64_encode($return)) : "&return=" . urlencode(base64_encode($return)); +} +else +{ + $ref = ($id) ? "&ref=linker&refid=" . $id : ""; +} +// set the create new URL +$new = "index.php?option=com_getbible&view=tagged_verses&task=tagged_verse.edit" . $ref; +// set the create new and close URL +$close_new = "index.php?option=com_getbible&view=tagged_verses&task=tagged_verse.edit"; +// load the action object +$can = GetbibleHelper::getActions('tagged_verse'); + +?> +
+get('tagged_verse.create')): ?> +
+ + +


+ + + + + + + + + + + + + + + + $item): ?> + authorise('core.manage', 'com_checkin') || $item->checked_out == $user->id || $item->checked_out == 0; + $userChkOut = JFactory::getUser($item->checked_out); + $canDo = GetbibleHelper::getActions('tagged_verse',$item,'tagged_verses'); + ?> + + + + + + + published == 1): ?> + + published == 0): ?> + + published == 2): ?> + + published == -2): ?> + + + + + + + + + + + +
+ + + + + + + + + + + + + +
+ get('tagged_verse.edit')): ?> + escape($item->book_nr); ?> + checked_out): ?> + name, $item->checked_out_time, 'tagged_verses.', $canCheckin); ?> + + + escape($item->book_nr); ?> + + + authorise('translation.edit', 'com_getbible.translation.' . (int) $item->abbreviation_id)): ?> + escape($item->abbreviation_translation); ?> + + escape($item->abbreviation_translation); ?> + + + access); ?> + + escape($item->linker_name); ?> + + authorise('tag.edit', 'com_getbible.tag.' . (int) $item->tag_id)): ?> + escape($item->tag_name); ?> + + escape($item->tag_name); ?> + + + + + + + + + + + + + + + + + + + id; ?> +
+ +
+ +
+ +
+ +
diff --git a/admin/layouts/note/details_above.php b/admin/layouts/note/details_above.php new file mode 100644 index 0000000..2c98398 --- /dev/null +++ b/admin/layouts/note/details_above.php @@ -0,0 +1,51 @@ + + @git Get Bible + @github Get Bible + @support Get Bible + @copyright Copyright (C) 2015. All Rights Reserved + @license GNU/GPL Version 2 or later - http://www.gnu.org/licenses/gpl-2.0.html + +/------------------------------------------------------------------------------------------------------*/ + +// No direct access to this file +defined('_JEXEC') or die('Restricted access'); + +// get the form +$form = $displayData->getForm(); + +// get the layout fields override method name (from layout path/ID) +$layout_path_array = explode('.', $this->getLayoutId()); +// Since we cannot pass the layout and tab names as parameters to the model method +// this name combination of tab and layout in the method name is the only work around +// seeing that JCB uses those two values (tab_name & layout_name) as the layout file name. +// example of layout name: details_left.php +// example of method name: getFields_details_left() +$fields_tab_layout = 'fields_' . $layout_path_array[1]; + +// get the fields +$fields = $displayData->get($fields_tab_layout) ?: array( + 'access', + 'linker' +); + +$hiddenFields = $displayData->get('hidden_fields') ?: array(); + +?> + +
+ + + setFieldAttribute($field, 'type', 'hidden'); ?> + + renderField($field, null, null, array('class' => 'control-wrapper-' . $field)); ?> + +
+ diff --git a/admin/layouts/note/details_left.php b/admin/layouts/note/details_left.php new file mode 100644 index 0000000..42b9831 --- /dev/null +++ b/admin/layouts/note/details_left.php @@ -0,0 +1,50 @@ + + @git Get Bible + @github Get Bible + @support Get Bible + @copyright Copyright (C) 2015. All Rights Reserved + @license GNU/GPL Version 2 or later - http://www.gnu.org/licenses/gpl-2.0.html + +/------------------------------------------------------------------------------------------------------*/ + +// No direct access to this file +defined('_JEXEC') or die('Restricted access'); + +// get the form +$form = $displayData->getForm(); + +// get the layout fields override method name (from layout path/ID) +$layout_path_array = explode('.', $this->getLayoutId()); +// Since we cannot pass the layout and tab names as parameters to the model method +// this name combination of tab and layout in the method name is the only work around +// seeing that JCB uses those two values (tab_name & layout_name) as the layout file name. +// example of layout name: details_left.php +// example of method name: getFields_details_left() +$fields_tab_layout = 'fields_' . $layout_path_array[1]; + +// get the fields +$fields = $displayData->get($fields_tab_layout) ?: array( + 'book_nr', + 'chapter', + 'verse' +); + +$hiddenFields = $displayData->get('hidden_fields') ?: array(); + +?> + + + + setFieldAttribute($field, 'type', 'hidden'); ?> + + renderField($field, null, null, array('class' => 'control-wrapper-' . $field)); ?> + + diff --git a/admin/layouts/note/details_right.php b/admin/layouts/note/details_right.php new file mode 100644 index 0000000..118fdfe --- /dev/null +++ b/admin/layouts/note/details_right.php @@ -0,0 +1,48 @@ + + @git Get Bible + @github Get Bible + @support Get Bible + @copyright Copyright (C) 2015. All Rights Reserved + @license GNU/GPL Version 2 or later - http://www.gnu.org/licenses/gpl-2.0.html + +/------------------------------------------------------------------------------------------------------*/ + +// No direct access to this file +defined('_JEXEC') or die('Restricted access'); + +// get the form +$form = $displayData->getForm(); + +// get the layout fields override method name (from layout path/ID) +$layout_path_array = explode('.', $this->getLayoutId()); +// Since we cannot pass the layout and tab names as parameters to the model method +// this name combination of tab and layout in the method name is the only work around +// seeing that JCB uses those two values (tab_name & layout_name) as the layout file name. +// example of layout name: details_left.php +// example of method name: getFields_details_left() +$fields_tab_layout = 'fields_' . $layout_path_array[1]; + +// get the fields +$fields = $displayData->get($fields_tab_layout) ?: array( + 'note' +); + +$hiddenFields = $displayData->get('hidden_fields') ?: array(); + +?> + + + + setFieldAttribute($field, 'type', 'hidden'); ?> + + renderField($field, null, null, array('class' => 'control-wrapper-' . $field)); ?> + + diff --git a/admin/layouts/note/index.html b/admin/layouts/note/index.html new file mode 100644 index 0000000..fa6d84e --- /dev/null +++ b/admin/layouts/note/index.html @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/admin/layouts/note/publishing.php b/admin/layouts/note/publishing.php new file mode 100644 index 0000000..72020c7 --- /dev/null +++ b/admin/layouts/note/publishing.php @@ -0,0 +1,53 @@ + + @git Get Bible + @github Get Bible + @support Get Bible + @copyright Copyright (C) 2015. All Rights Reserved + @license GNU/GPL Version 2 or later - http://www.gnu.org/licenses/gpl-2.0.html + +/------------------------------------------------------------------------------------------------------*/ + +// No direct access to this file +defined('_JEXEC') or die('Restricted access'); + +// get the form +$form = $displayData->getForm(); + +// get the layout fields override method name (from layout path/ID) +$layout_path_array = explode('.', $this->getLayoutId()); +// Since we cannot pass the layout and tab names as parameters to the model method +// this name combination of tab and layout in the method name is the only work around +// seeing that JCB uses those two values (tab_name & layout_name) as the layout file name. +// example of layout name: details_left.php +// example of method name: getFields_details_left() +$fields_tab_layout = 'fields_' . $layout_path_array[1]; + +// get the fields +$fields = $displayData->get($fields_tab_layout) ?: array( + 'guid', + 'title', + 'created', + 'created_by', + 'modified', + 'modified_by' +); + +$hiddenFields = $displayData->get('hidden_fields') ?: array(); + +?> + + + + setFieldAttribute($field, 'type', 'hidden'); ?> + + renderField($field, null, null, array('class' => 'control-wrapper-' . $field)); ?> + + diff --git a/admin/layouts/note/publlshing.php b/admin/layouts/note/publlshing.php new file mode 100644 index 0000000..1c6d9d7 --- /dev/null +++ b/admin/layouts/note/publlshing.php @@ -0,0 +1,52 @@ + + @git Get Bible + @github Get Bible + @support Get Bible + @copyright Copyright (C) 2015. All Rights Reserved + @license GNU/GPL Version 2 or later - http://www.gnu.org/licenses/gpl-2.0.html + +/------------------------------------------------------------------------------------------------------*/ + +// No direct access to this file +defined('_JEXEC') or die('Restricted access'); + +// get the form +$form = $displayData->getForm(); + +// get the layout fields override method name (from layout path/ID) +$layout_path_array = explode('.', $this->getLayoutId()); +// Since we cannot pass the layout and tab names as parameters to the model method +// this name combination of tab and layout in the method name is the only work around +// seeing that JCB uses those two values (tab_name & layout_name) as the layout file name. +// example of layout name: details_left.php +// example of method name: getFields_details_left() +$fields_tab_layout = 'fields_' . $layout_path_array[1]; + +// get the fields +$fields = $displayData->get($fields_tab_layout) ?: array( + 'published', + 'ordering', + 'version', + 'hits', + 'id' +); + +$hiddenFields = $displayData->get('hidden_fields') ?: array(); + +?> + + + + setFieldAttribute($field, 'type', 'hidden'); ?> + + renderField($field, null, null, array('class' => 'control-wrapper-' . $field)); ?> + + diff --git a/admin/layouts/open_ai_message/index.html b/admin/layouts/open_ai_message/index.html new file mode 100644 index 0000000..fa6d84e --- /dev/null +++ b/admin/layouts/open_ai_message/index.html @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/admin/layouts/open_ai_message/message_above.php b/admin/layouts/open_ai_message/message_above.php new file mode 100644 index 0000000..b97d180 --- /dev/null +++ b/admin/layouts/open_ai_message/message_above.php @@ -0,0 +1,52 @@ + + @git Get Bible + @github Get Bible + @support Get Bible + @copyright Copyright (C) 2015. All Rights Reserved + @license GNU/GPL Version 2 or later - http://www.gnu.org/licenses/gpl-2.0.html + +/------------------------------------------------------------------------------------------------------*/ + +// No direct access to this file +defined('_JEXEC') or die('Restricted access'); + +// get the form +$form = $displayData->getForm(); + +// get the layout fields override method name (from layout path/ID) +$layout_path_array = explode('.', $this->getLayoutId()); +// Since we cannot pass the layout and tab names as parameters to the model method +// this name combination of tab and layout in the method name is the only work around +// seeing that JCB uses those two values (tab_name & layout_name) as the layout file name. +// example of layout name: details_left.php +// example of method name: getFields_details_left() +$fields_tab_layout = 'fields_' . $layout_path_array[1]; + +// get the fields +$fields = $displayData->get($fields_tab_layout) ?: array( + 'role', + 'open_ai_response', + 'prompt' +); + +$hiddenFields = $displayData->get('hidden_fields') ?: array(); + +?> + +
+ + + setFieldAttribute($field, 'type', 'hidden'); ?> + + renderField($field, null, null, array('class' => 'control-wrapper-' . $field)); ?> + +
+ diff --git a/admin/layouts/open_ai_message/message_fullwidth.php b/admin/layouts/open_ai_message/message_fullwidth.php new file mode 100644 index 0000000..d78d9bc --- /dev/null +++ b/admin/layouts/open_ai_message/message_fullwidth.php @@ -0,0 +1,50 @@ + + @git Get Bible + @github Get Bible + @support Get Bible + @copyright Copyright (C) 2015. All Rights Reserved + @license GNU/GPL Version 2 or later - http://www.gnu.org/licenses/gpl-2.0.html + +/------------------------------------------------------------------------------------------------------*/ + +// No direct access to this file +defined('_JEXEC') or die('Restricted access'); + +// get the form +$form = $displayData->getForm(); + +// get the layout fields override method name (from layout path/ID) +$layout_path_array = explode('.', $this->getLayoutId()); +// Since we cannot pass the layout and tab names as parameters to the model method +// this name combination of tab and layout in the method name is the only work around +// seeing that JCB uses those two values (tab_name & layout_name) as the layout file name. +// example of layout name: details_left.php +// example of method name: getFields_details_left() +$fields_tab_layout = 'fields_' . $layout_path_array[1]; + +// get the fields +$fields = $displayData->get($fields_tab_layout) ?: array( + 'content' +); + +$hiddenFields = $displayData->get('hidden_fields') ?: array(); + +?> + +
+ + + setFieldAttribute($field, 'type', 'hidden'); ?> + + renderField($field, null, null, array('class' => 'control-wrapper-' . $field)); ?> + +
+ diff --git a/admin/layouts/open_ai_message/message_left.php b/admin/layouts/open_ai_message/message_left.php new file mode 100644 index 0000000..5269e14 --- /dev/null +++ b/admin/layouts/open_ai_message/message_left.php @@ -0,0 +1,49 @@ + + @git Get Bible + @github Get Bible + @support Get Bible + @copyright Copyright (C) 2015. All Rights Reserved + @license GNU/GPL Version 2 or later - http://www.gnu.org/licenses/gpl-2.0.html + +/------------------------------------------------------------------------------------------------------*/ + +// No direct access to this file +defined('_JEXEC') or die('Restricted access'); + +// get the form +$form = $displayData->getForm(); + +// get the layout fields override method name (from layout path/ID) +$layout_path_array = explode('.', $this->getLayoutId()); +// Since we cannot pass the layout and tab names as parameters to the model method +// this name combination of tab and layout in the method name is the only work around +// seeing that JCB uses those two values (tab_name & layout_name) as the layout file name. +// example of layout name: details_left.php +// example of method name: getFields_details_left() +$fields_tab_layout = 'fields_' . $layout_path_array[1]; + +// get the fields +$fields = $displayData->get($fields_tab_layout) ?: array( + 'source', + 'index' +); + +$hiddenFields = $displayData->get('hidden_fields') ?: array(); + +?> + + + + setFieldAttribute($field, 'type', 'hidden'); ?> + + renderField($field, null, null, array('class' => 'control-wrapper-' . $field)); ?> + + diff --git a/admin/layouts/open_ai_message/message_right.php b/admin/layouts/open_ai_message/message_right.php new file mode 100644 index 0000000..e867d90 --- /dev/null +++ b/admin/layouts/open_ai_message/message_right.php @@ -0,0 +1,48 @@ + + @git Get Bible + @github Get Bible + @support Get Bible + @copyright Copyright (C) 2015. All Rights Reserved + @license GNU/GPL Version 2 or later - http://www.gnu.org/licenses/gpl-2.0.html + +/------------------------------------------------------------------------------------------------------*/ + +// No direct access to this file +defined('_JEXEC') or die('Restricted access'); + +// get the form +$form = $displayData->getForm(); + +// get the layout fields override method name (from layout path/ID) +$layout_path_array = explode('.', $this->getLayoutId()); +// Since we cannot pass the layout and tab names as parameters to the model method +// this name combination of tab and layout in the method name is the only work around +// seeing that JCB uses those two values (tab_name & layout_name) as the layout file name. +// example of layout name: details_left.php +// example of method name: getFields_details_left() +$fields_tab_layout = 'fields_' . $layout_path_array[1]; + +// get the fields +$fields = $displayData->get($fields_tab_layout) ?: array( + 'name' +); + +$hiddenFields = $displayData->get('hidden_fields') ?: array(); + +?> + + + + setFieldAttribute($field, 'type', 'hidden'); ?> + + renderField($field, null, null, array('class' => 'control-wrapper-' . $field)); ?> + + diff --git a/admin/layouts/open_ai_message/publishing.php b/admin/layouts/open_ai_message/publishing.php new file mode 100644 index 0000000..df756a0 --- /dev/null +++ b/admin/layouts/open_ai_message/publishing.php @@ -0,0 +1,52 @@ + + @git Get Bible + @github Get Bible + @support Get Bible + @copyright Copyright (C) 2015. All Rights Reserved + @license GNU/GPL Version 2 or later - http://www.gnu.org/licenses/gpl-2.0.html + +/------------------------------------------------------------------------------------------------------*/ + +// No direct access to this file +defined('_JEXEC') or die('Restricted access'); + +// get the form +$form = $displayData->getForm(); + +// get the layout fields override method name (from layout path/ID) +$layout_path_array = explode('.', $this->getLayoutId()); +// Since we cannot pass the layout and tab names as parameters to the model method +// this name combination of tab and layout in the method name is the only work around +// seeing that JCB uses those two values (tab_name & layout_name) as the layout file name. +// example of layout name: details_left.php +// example of method name: getFields_details_left() +$fields_tab_layout = 'fields_' . $layout_path_array[1]; + +// get the fields +$fields = $displayData->get($fields_tab_layout) ?: array( + 'title', + 'created', + 'created_by', + 'modified', + 'modified_by' +); + +$hiddenFields = $displayData->get('hidden_fields') ?: array(); + +?> + + + + setFieldAttribute($field, 'type', 'hidden'); ?> + + renderField($field, null, null, array('class' => 'control-wrapper-' . $field)); ?> + + diff --git a/admin/layouts/open_ai_message/publlshing.php b/admin/layouts/open_ai_message/publlshing.php new file mode 100644 index 0000000..171f8c2 --- /dev/null +++ b/admin/layouts/open_ai_message/publlshing.php @@ -0,0 +1,53 @@ + + @git Get Bible + @github Get Bible + @support Get Bible + @copyright Copyright (C) 2015. All Rights Reserved + @license GNU/GPL Version 2 or later - http://www.gnu.org/licenses/gpl-2.0.html + +/------------------------------------------------------------------------------------------------------*/ + +// No direct access to this file +defined('_JEXEC') or die('Restricted access'); + +// get the form +$form = $displayData->getForm(); + +// get the layout fields override method name (from layout path/ID) +$layout_path_array = explode('.', $this->getLayoutId()); +// Since we cannot pass the layout and tab names as parameters to the model method +// this name combination of tab and layout in the method name is the only work around +// seeing that JCB uses those two values (tab_name & layout_name) as the layout file name. +// example of layout name: details_left.php +// example of method name: getFields_details_left() +$fields_tab_layout = 'fields_' . $layout_path_array[1]; + +// get the fields +$fields = $displayData->get($fields_tab_layout) ?: array( + 'published', + 'ordering', + 'access', + 'version', + 'hits', + 'id' +); + +$hiddenFields = $displayData->get('hidden_fields') ?: array(); + +?> + + + + setFieldAttribute($field, 'type', 'hidden'); ?> + + renderField($field, null, null, array('class' => 'control-wrapper-' . $field)); ?> + + diff --git a/admin/layouts/open_ai_response/bible_left.php b/admin/layouts/open_ai_response/bible_left.php new file mode 100644 index 0000000..e6c3c51 --- /dev/null +++ b/admin/layouts/open_ai_response/bible_left.php @@ -0,0 +1,51 @@ + + @git Get Bible + @github Get Bible + @support Get Bible + @copyright Copyright (C) 2015. All Rights Reserved + @license GNU/GPL Version 2 or later - http://www.gnu.org/licenses/gpl-2.0.html + +/------------------------------------------------------------------------------------------------------*/ + +// No direct access to this file +defined('_JEXEC') or die('Restricted access'); + +// get the form +$form = $displayData->getForm(); + +// get the layout fields override method name (from layout path/ID) +$layout_path_array = explode('.', $this->getLayoutId()); +// Since we cannot pass the layout and tab names as parameters to the model method +// this name combination of tab and layout in the method name is the only work around +// seeing that JCB uses those two values (tab_name & layout_name) as the layout file name. +// example of layout name: details_left.php +// example of method name: getFields_details_left() +$fields_tab_layout = 'fields_' . $layout_path_array[1]; + +// get the fields +$fields = $displayData->get($fields_tab_layout) ?: array( + 'abbreviation', + 'language', + 'lcsh', + 'book' +); + +$hiddenFields = $displayData->get('hidden_fields') ?: array(); + +?> + + + + setFieldAttribute($field, 'type', 'hidden'); ?> + + renderField($field, null, null, array('class' => 'control-wrapper-' . $field)); ?> + + diff --git a/admin/layouts/open_ai_response/bible_right.php b/admin/layouts/open_ai_response/bible_right.php new file mode 100644 index 0000000..95d5418 --- /dev/null +++ b/admin/layouts/open_ai_response/bible_right.php @@ -0,0 +1,51 @@ + + @git Get Bible + @github Get Bible + @support Get Bible + @copyright Copyright (C) 2015. All Rights Reserved + @license GNU/GPL Version 2 or later - http://www.gnu.org/licenses/gpl-2.0.html + +/------------------------------------------------------------------------------------------------------*/ + +// No direct access to this file +defined('_JEXEC') or die('Restricted access'); + +// get the form +$form = $displayData->getForm(); + +// get the layout fields override method name (from layout path/ID) +$layout_path_array = explode('.', $this->getLayoutId()); +// Since we cannot pass the layout and tab names as parameters to the model method +// this name combination of tab and layout in the method name is the only work around +// seeing that JCB uses those two values (tab_name & layout_name) as the layout file name. +// example of layout name: details_left.php +// example of method name: getFields_details_left() +$fields_tab_layout = 'fields_' . $layout_path_array[1]; + +// get the fields +$fields = $displayData->get($fields_tab_layout) ?: array( + 'chapter', + 'verse', + 'word', + 'selected_word' +); + +$hiddenFields = $displayData->get('hidden_fields') ?: array(); + +?> + + + + setFieldAttribute($field, 'type', 'hidden'); ?> + + renderField($field, null, null, array('class' => 'control-wrapper-' . $field)); ?> + + diff --git a/admin/layouts/open_ai_response/details_above.php b/admin/layouts/open_ai_response/details_above.php new file mode 100644 index 0000000..e748888 --- /dev/null +++ b/admin/layouts/open_ai_response/details_above.php @@ -0,0 +1,51 @@ + + @git Get Bible + @github Get Bible + @support Get Bible + @copyright Copyright (C) 2015. All Rights Reserved + @license GNU/GPL Version 2 or later - http://www.gnu.org/licenses/gpl-2.0.html + +/------------------------------------------------------------------------------------------------------*/ + +// No direct access to this file +defined('_JEXEC') or die('Restricted access'); + +// get the form +$form = $displayData->getForm(); + +// get the layout fields override method name (from layout path/ID) +$layout_path_array = explode('.', $this->getLayoutId()); +// Since we cannot pass the layout and tab names as parameters to the model method +// this name combination of tab and layout in the method name is the only work around +// seeing that JCB uses those two values (tab_name & layout_name) as the layout file name. +// example of layout name: details_left.php +// example of method name: getFields_details_left() +$fields_tab_layout = 'fields_' . $layout_path_array[1]; + +// get the fields +$fields = $displayData->get($fields_tab_layout) ?: array( + 'response_id', + 'prompt' +); + +$hiddenFields = $displayData->get('hidden_fields') ?: array(); + +?> + +
+ + + setFieldAttribute($field, 'type', 'hidden'); ?> + + renderField($field, null, null, array('class' => 'control-wrapper-' . $field)); ?> + +
+ diff --git a/admin/layouts/open_ai_response/details_left.php b/admin/layouts/open_ai_response/details_left.php new file mode 100644 index 0000000..551ca06 --- /dev/null +++ b/admin/layouts/open_ai_response/details_left.php @@ -0,0 +1,50 @@ + + @git Get Bible + @github Get Bible + @support Get Bible + @copyright Copyright (C) 2015. All Rights Reserved + @license GNU/GPL Version 2 or later - http://www.gnu.org/licenses/gpl-2.0.html + +/------------------------------------------------------------------------------------------------------*/ + +// No direct access to this file +defined('_JEXEC') or die('Restricted access'); + +// get the form +$form = $displayData->getForm(); + +// get the layout fields override method name (from layout path/ID) +$layout_path_array = explode('.', $this->getLayoutId()); +// Since we cannot pass the layout and tab names as parameters to the model method +// this name combination of tab and layout in the method name is the only work around +// seeing that JCB uses those two values (tab_name & layout_name) as the layout file name. +// example of layout name: details_left.php +// example of method name: getFields_details_left() +$fields_tab_layout = 'fields_' . $layout_path_array[1]; + +// get the fields +$fields = $displayData->get($fields_tab_layout) ?: array( + 'response_object', + 'response_model', + 'response_created' +); + +$hiddenFields = $displayData->get('hidden_fields') ?: array(); + +?> + + + + setFieldAttribute($field, 'type', 'hidden'); ?> + + renderField($field, null, null, array('class' => 'control-wrapper-' . $field)); ?> + + diff --git a/admin/layouts/open_ai_response/details_right.php b/admin/layouts/open_ai_response/details_right.php new file mode 100644 index 0000000..3476e89 --- /dev/null +++ b/admin/layouts/open_ai_response/details_right.php @@ -0,0 +1,50 @@ + + @git Get Bible + @github Get Bible + @support Get Bible + @copyright Copyright (C) 2015. All Rights Reserved + @license GNU/GPL Version 2 or later - http://www.gnu.org/licenses/gpl-2.0.html + +/------------------------------------------------------------------------------------------------------*/ + +// No direct access to this file +defined('_JEXEC') or die('Restricted access'); + +// get the form +$form = $displayData->getForm(); + +// get the layout fields override method name (from layout path/ID) +$layout_path_array = explode('.', $this->getLayoutId()); +// Since we cannot pass the layout and tab names as parameters to the model method +// this name combination of tab and layout in the method name is the only work around +// seeing that JCB uses those two values (tab_name & layout_name) as the layout file name. +// example of layout name: details_left.php +// example of method name: getFields_details_left() +$fields_tab_layout = 'fields_' . $layout_path_array[1]; + +// get the fields +$fields = $displayData->get($fields_tab_layout) ?: array( + 'prompt_tokens', + 'completion_tokens', + 'total_tokens' +); + +$hiddenFields = $displayData->get('hidden_fields') ?: array(); + +?> + + + + setFieldAttribute($field, 'type', 'hidden'); ?> + + renderField($field, null, null, array('class' => 'control-wrapper-' . $field)); ?> + + diff --git a/admin/layouts/open_ai_response/index.html b/admin/layouts/open_ai_response/index.html new file mode 100644 index 0000000..fa6d84e --- /dev/null +++ b/admin/layouts/open_ai_response/index.html @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/admin/layouts/open_ai_response/message_fullwidth.php b/admin/layouts/open_ai_response/message_fullwidth.php new file mode 100644 index 0000000..08279a6 --- /dev/null +++ b/admin/layouts/open_ai_response/message_fullwidth.php @@ -0,0 +1,147 @@ + + @git Get Bible + @github Get Bible + @support Get Bible + @copyright Copyright (C) 2015. All Rights Reserved + @license GNU/GPL Version 2 or later - http://www.gnu.org/licenses/gpl-2.0.html + +/------------------------------------------------------------------------------------------------------*/ + +// No direct access to this file +defined('_JEXEC') or die('Restricted access'); + +// set the defaults +$items = $displayData->vvymessage; +$user = JFactory::getUser(); +$id = $displayData->item->id; +// set the edit URL +$edit = "index.php?option=com_getbible&view=open_ai_messages&task=open_ai_message.edit"; +// set a return value +$return = ($id) ? "index.php?option=com_getbible&view=open_ai_response&layout=edit&id=" . $id : ""; +// check for a return value +$jinput = JFactory::getApplication()->input; +if ($_return = $jinput->get('return', null, 'base64')) +{ + $return .= "&return=" . $_return; +} +// check if return value was set +if (GetbibleHelper::checkString($return)) +{ + // set the referral values + $ref = ($id) ? "&ref=open_ai_response&refid=" . $id . "&return=" . urlencode(base64_encode($return)) : "&return=" . urlencode(base64_encode($return)); +} +else +{ + $ref = ($id) ? "&ref=open_ai_response&refid=" . $id : ""; +} + +?> +
+ + + + + + + + + + + + + + $item): ?> + authorise('core.manage', 'com_checkin') || $item->checked_out == $user->id || $item->checked_out == 0; + $userChkOut = JFactory::getUser($item->checked_out); + $canDo = GetbibleHelper::getActions('open_ai_message',$item,'open_ai_messages'); + ?> + + + + + + published == 1): ?> + + published == 0): ?> + + published == 2): ?> + + published == -2): ?> + + + + + + + + + + + +
+ + + + + + + + + + + +
+ get('open_ai_message.edit')): ?> + role); ?> + checked_out): ?> + name, $item->checked_out_time, 'open_ai_messages.', $canCheckin); ?> + + + role); ?> + + + escape($item->open_ai_response_response_id); ?> + + authorise('prompt.edit', 'com_getbible.prompt.' . (int) $item->prompt_id)): ?> + escape($item->prompt_name); ?> + + escape($item->prompt_name); ?> + + + source); ?> + + + + + + + + + + + + + + + + + + id; ?> +
+ +
+ +
+ +
+ +
diff --git a/admin/layouts/open_ai_response/prompt_left.php b/admin/layouts/open_ai_response/prompt_left.php new file mode 100644 index 0000000..5265614 --- /dev/null +++ b/admin/layouts/open_ai_response/prompt_left.php @@ -0,0 +1,50 @@ + + @git Get Bible + @github Get Bible + @support Get Bible + @copyright Copyright (C) 2015. All Rights Reserved + @license GNU/GPL Version 2 or later - http://www.gnu.org/licenses/gpl-2.0.html + +/------------------------------------------------------------------------------------------------------*/ + +// No direct access to this file +defined('_JEXEC') or die('Restricted access'); + +// get the form +$form = $displayData->getForm(); + +// get the layout fields override method name (from layout path/ID) +$layout_path_array = explode('.', $this->getLayoutId()); +// Since we cannot pass the layout and tab names as parameters to the model method +// this name combination of tab and layout in the method name is the only work around +// seeing that JCB uses those two values (tab_name & layout_name) as the layout file name. +// example of layout name: details_left.php +// example of method name: getFields_details_left() +$fields_tab_layout = 'fields_' . $layout_path_array[1]; + +// get the fields +$fields = $displayData->get($fields_tab_layout) ?: array( + 'max_tokens', + 'temperature', + 'top_p' +); + +$hiddenFields = $displayData->get('hidden_fields') ?: array(); + +?> + + + + setFieldAttribute($field, 'type', 'hidden'); ?> + + renderField($field, null, null, array('class' => 'control-wrapper-' . $field)); ?> + + diff --git a/admin/layouts/open_ai_response/prompt_right.php b/admin/layouts/open_ai_response/prompt_right.php new file mode 100644 index 0000000..7ff9ded --- /dev/null +++ b/admin/layouts/open_ai_response/prompt_right.php @@ -0,0 +1,51 @@ + + @git Get Bible + @github Get Bible + @support Get Bible + @copyright Copyright (C) 2015. All Rights Reserved + @license GNU/GPL Version 2 or later - http://www.gnu.org/licenses/gpl-2.0.html + +/------------------------------------------------------------------------------------------------------*/ + +// No direct access to this file +defined('_JEXEC') or die('Restricted access'); + +// get the form +$form = $displayData->getForm(); + +// get the layout fields override method name (from layout path/ID) +$layout_path_array = explode('.', $this->getLayoutId()); +// Since we cannot pass the layout and tab names as parameters to the model method +// this name combination of tab and layout in the method name is the only work around +// seeing that JCB uses those two values (tab_name & layout_name) as the layout file name. +// example of layout name: details_left.php +// example of method name: getFields_details_left() +$fields_tab_layout = 'fields_' . $layout_path_array[1]; + +// get the fields +$fields = $displayData->get($fields_tab_layout) ?: array( + 'model', + 'presence_penalty', + 'frequency_penalty', + 'n' +); + +$hiddenFields = $displayData->get('hidden_fields') ?: array(); + +?> + + + + setFieldAttribute($field, 'type', 'hidden'); ?> + + renderField($field, null, null, array('class' => 'control-wrapper-' . $field)); ?> + + diff --git a/admin/layouts/open_ai_response/publishing.php b/admin/layouts/open_ai_response/publishing.php new file mode 100644 index 0000000..df756a0 --- /dev/null +++ b/admin/layouts/open_ai_response/publishing.php @@ -0,0 +1,52 @@ + + @git Get Bible + @github Get Bible + @support Get Bible + @copyright Copyright (C) 2015. All Rights Reserved + @license GNU/GPL Version 2 or later - http://www.gnu.org/licenses/gpl-2.0.html + +/------------------------------------------------------------------------------------------------------*/ + +// No direct access to this file +defined('_JEXEC') or die('Restricted access'); + +// get the form +$form = $displayData->getForm(); + +// get the layout fields override method name (from layout path/ID) +$layout_path_array = explode('.', $this->getLayoutId()); +// Since we cannot pass the layout and tab names as parameters to the model method +// this name combination of tab and layout in the method name is the only work around +// seeing that JCB uses those two values (tab_name & layout_name) as the layout file name. +// example of layout name: details_left.php +// example of method name: getFields_details_left() +$fields_tab_layout = 'fields_' . $layout_path_array[1]; + +// get the fields +$fields = $displayData->get($fields_tab_layout) ?: array( + 'title', + 'created', + 'created_by', + 'modified', + 'modified_by' +); + +$hiddenFields = $displayData->get('hidden_fields') ?: array(); + +?> + + + + setFieldAttribute($field, 'type', 'hidden'); ?> + + renderField($field, null, null, array('class' => 'control-wrapper-' . $field)); ?> + + diff --git a/admin/layouts/open_ai_response/publlshing.php b/admin/layouts/open_ai_response/publlshing.php new file mode 100644 index 0000000..171f8c2 --- /dev/null +++ b/admin/layouts/open_ai_response/publlshing.php @@ -0,0 +1,53 @@ + + @git Get Bible + @github Get Bible + @support Get Bible + @copyright Copyright (C) 2015. All Rights Reserved + @license GNU/GPL Version 2 or later - http://www.gnu.org/licenses/gpl-2.0.html + +/------------------------------------------------------------------------------------------------------*/ + +// No direct access to this file +defined('_JEXEC') or die('Restricted access'); + +// get the form +$form = $displayData->getForm(); + +// get the layout fields override method name (from layout path/ID) +$layout_path_array = explode('.', $this->getLayoutId()); +// Since we cannot pass the layout and tab names as parameters to the model method +// this name combination of tab and layout in the method name is the only work around +// seeing that JCB uses those two values (tab_name & layout_name) as the layout file name. +// example of layout name: details_left.php +// example of method name: getFields_details_left() +$fields_tab_layout = 'fields_' . $layout_path_array[1]; + +// get the fields +$fields = $displayData->get($fields_tab_layout) ?: array( + 'published', + 'ordering', + 'access', + 'version', + 'hits', + 'id' +); + +$hiddenFields = $displayData->get('hidden_fields') ?: array(); + +?> + + + + setFieldAttribute($field, 'type', 'hidden'); ?> + + renderField($field, null, null, array('class' => 'control-wrapper-' . $field)); ?> + + diff --git a/admin/layouts/password/details_above.php b/admin/layouts/password/details_above.php new file mode 100644 index 0000000..c787fff --- /dev/null +++ b/admin/layouts/password/details_above.php @@ -0,0 +1,50 @@ + + @git Get Bible + @github Get Bible + @support Get Bible + @copyright Copyright (C) 2015. All Rights Reserved + @license GNU/GPL Version 2 or later - http://www.gnu.org/licenses/gpl-2.0.html + +/------------------------------------------------------------------------------------------------------*/ + +// No direct access to this file +defined('_JEXEC') or die('Restricted access'); + +// get the form +$form = $displayData->getForm(); + +// get the layout fields override method name (from layout path/ID) +$layout_path_array = explode('.', $this->getLayoutId()); +// Since we cannot pass the layout and tab names as parameters to the model method +// this name combination of tab and layout in the method name is the only work around +// seeing that JCB uses those two values (tab_name & layout_name) as the layout file name. +// example of layout name: details_left.php +// example of method name: getFields_details_left() +$fields_tab_layout = 'fields_' . $layout_path_array[1]; + +// get the fields +$fields = $displayData->get($fields_tab_layout) ?: array( + 'linker' +); + +$hiddenFields = $displayData->get('hidden_fields') ?: array(); + +?> + +
+ + + setFieldAttribute($field, 'type', 'hidden'); ?> + + renderField($field, null, null, array('class' => 'control-wrapper-' . $field)); ?> + +
+ diff --git a/admin/layouts/password/details_left.php b/admin/layouts/password/details_left.php new file mode 100644 index 0000000..e867d90 --- /dev/null +++ b/admin/layouts/password/details_left.php @@ -0,0 +1,48 @@ + + @git Get Bible + @github Get Bible + @support Get Bible + @copyright Copyright (C) 2015. All Rights Reserved + @license GNU/GPL Version 2 or later - http://www.gnu.org/licenses/gpl-2.0.html + +/------------------------------------------------------------------------------------------------------*/ + +// No direct access to this file +defined('_JEXEC') or die('Restricted access'); + +// get the form +$form = $displayData->getForm(); + +// get the layout fields override method name (from layout path/ID) +$layout_path_array = explode('.', $this->getLayoutId()); +// Since we cannot pass the layout and tab names as parameters to the model method +// this name combination of tab and layout in the method name is the only work around +// seeing that JCB uses those two values (tab_name & layout_name) as the layout file name. +// example of layout name: details_left.php +// example of method name: getFields_details_left() +$fields_tab_layout = 'fields_' . $layout_path_array[1]; + +// get the fields +$fields = $displayData->get($fields_tab_layout) ?: array( + 'name' +); + +$hiddenFields = $displayData->get('hidden_fields') ?: array(); + +?> + + + + setFieldAttribute($field, 'type', 'hidden'); ?> + + renderField($field, null, null, array('class' => 'control-wrapper-' . $field)); ?> + + diff --git a/admin/layouts/password/details_right.php b/admin/layouts/password/details_right.php new file mode 100644 index 0000000..e142f5b --- /dev/null +++ b/admin/layouts/password/details_right.php @@ -0,0 +1,48 @@ + + @git Get Bible + @github Get Bible + @support Get Bible + @copyright Copyright (C) 2015. All Rights Reserved + @license GNU/GPL Version 2 or later - http://www.gnu.org/licenses/gpl-2.0.html + +/------------------------------------------------------------------------------------------------------*/ + +// No direct access to this file +defined('_JEXEC') or die('Restricted access'); + +// get the form +$form = $displayData->getForm(); + +// get the layout fields override method name (from layout path/ID) +$layout_path_array = explode('.', $this->getLayoutId()); +// Since we cannot pass the layout and tab names as parameters to the model method +// this name combination of tab and layout in the method name is the only work around +// seeing that JCB uses those two values (tab_name & layout_name) as the layout file name. +// example of layout name: details_left.php +// example of method name: getFields_details_left() +$fields_tab_layout = 'fields_' . $layout_path_array[1]; + +// get the fields +$fields = $displayData->get($fields_tab_layout) ?: array( + 'password' +); + +$hiddenFields = $displayData->get('hidden_fields') ?: array(); + +?> + + + + setFieldAttribute($field, 'type', 'hidden'); ?> + + renderField($field, null, null, array('class' => 'control-wrapper-' . $field)); ?> + + diff --git a/admin/layouts/password/index.html b/admin/layouts/password/index.html new file mode 100644 index 0000000..fa6d84e --- /dev/null +++ b/admin/layouts/password/index.html @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/admin/layouts/password/publishing.php b/admin/layouts/password/publishing.php new file mode 100644 index 0000000..72020c7 --- /dev/null +++ b/admin/layouts/password/publishing.php @@ -0,0 +1,53 @@ + + @git Get Bible + @github Get Bible + @support Get Bible + @copyright Copyright (C) 2015. All Rights Reserved + @license GNU/GPL Version 2 or later - http://www.gnu.org/licenses/gpl-2.0.html + +/------------------------------------------------------------------------------------------------------*/ + +// No direct access to this file +defined('_JEXEC') or die('Restricted access'); + +// get the form +$form = $displayData->getForm(); + +// get the layout fields override method name (from layout path/ID) +$layout_path_array = explode('.', $this->getLayoutId()); +// Since we cannot pass the layout and tab names as parameters to the model method +// this name combination of tab and layout in the method name is the only work around +// seeing that JCB uses those two values (tab_name & layout_name) as the layout file name. +// example of layout name: details_left.php +// example of method name: getFields_details_left() +$fields_tab_layout = 'fields_' . $layout_path_array[1]; + +// get the fields +$fields = $displayData->get($fields_tab_layout) ?: array( + 'guid', + 'title', + 'created', + 'created_by', + 'modified', + 'modified_by' +); + +$hiddenFields = $displayData->get('hidden_fields') ?: array(); + +?> + + + + setFieldAttribute($field, 'type', 'hidden'); ?> + + renderField($field, null, null, array('class' => 'control-wrapper-' . $field)); ?> + + diff --git a/admin/layouts/password/publlshing.php b/admin/layouts/password/publlshing.php new file mode 100644 index 0000000..171f8c2 --- /dev/null +++ b/admin/layouts/password/publlshing.php @@ -0,0 +1,53 @@ + + @git Get Bible + @github Get Bible + @support Get Bible + @copyright Copyright (C) 2015. All Rights Reserved + @license GNU/GPL Version 2 or later - http://www.gnu.org/licenses/gpl-2.0.html + +/------------------------------------------------------------------------------------------------------*/ + +// No direct access to this file +defined('_JEXEC') or die('Restricted access'); + +// get the form +$form = $displayData->getForm(); + +// get the layout fields override method name (from layout path/ID) +$layout_path_array = explode('.', $this->getLayoutId()); +// Since we cannot pass the layout and tab names as parameters to the model method +// this name combination of tab and layout in the method name is the only work around +// seeing that JCB uses those two values (tab_name & layout_name) as the layout file name. +// example of layout name: details_left.php +// example of method name: getFields_details_left() +$fields_tab_layout = 'fields_' . $layout_path_array[1]; + +// get the fields +$fields = $displayData->get($fields_tab_layout) ?: array( + 'published', + 'ordering', + 'access', + 'version', + 'hits', + 'id' +); + +$hiddenFields = $displayData->get('hidden_fields') ?: array(); + +?> + + + + setFieldAttribute($field, 'type', 'hidden'); ?> + + renderField($field, null, null, array('class' => 'control-wrapper-' . $field)); ?> + + diff --git a/admin/layouts/prompt/index.html b/admin/layouts/prompt/index.html new file mode 100644 index 0000000..fa6d84e --- /dev/null +++ b/admin/layouts/prompt/index.html @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/admin/layouts/prompt/open_ai_left.php b/admin/layouts/prompt/open_ai_left.php new file mode 100644 index 0000000..7edddf8 --- /dev/null +++ b/admin/layouts/prompt/open_ai_left.php @@ -0,0 +1,73 @@ + + @git Get Bible + @github Get Bible + @support Get Bible + @copyright Copyright (C) 2015. All Rights Reserved + @license GNU/GPL Version 2 or later - http://www.gnu.org/licenses/gpl-2.0.html + +/------------------------------------------------------------------------------------------------------*/ + +// No direct access to this file +defined('JPATH_BASE') or die('Restricted access'); +use VDM\Joomla\Utilities\Component\Helper; + +// get the form +$form = $displayData->getForm(); + +// get the layout fields override method name (from layout path/ID) +$layout_path_array = explode('.', $this->getLayoutId()); +// Since we cannot pass the layout and tab names as parameters to the model method +// this name combination of tab and layout in the method name is the only work around +// seeing that JCB uses those two values (tab_name & layout_name) as the layout file name. +// example of layout name: details_left.php +// example of method name: getFields_details_left() +$fields_tab_layout = 'fields_' . $layout_path_array[1]; + +$params = Helper::getParams('com_getbible'); +$active = $params->get('enable_open_ai', 0); + +// only load the fields if the OPEN AI is activated +$fields = []; +if ($active == 1) +{ + // get the fields + $fields = $displayData->get($fields_tab_layout) ?: array( + 'max_tokens_override', + 'max_tokens', + 'max_tokens_note', + 'temperature_override', + 'temperature', + 'temperature_note', + 'top_p_override', + 'top_p', + 'top_p_note', + 'n_override', + 'n', + 'n_note' + ); +} + +$hiddenFields = $displayData->get('hidden_fields') ?: array(); + +?> + + + + setFieldAttribute($field, 'type', 'hidden'); ?> + + renderField($field, null, null, array('class' => 'control-wrapper-' . $field)); ?> + + +
+

+

+
+ diff --git a/admin/layouts/prompt/open_ai_right.php b/admin/layouts/prompt/open_ai_right.php new file mode 100644 index 0000000..06e75fb --- /dev/null +++ b/admin/layouts/prompt/open_ai_right.php @@ -0,0 +1,68 @@ + + @git Get Bible + @github Get Bible + @support Get Bible + @copyright Copyright (C) 2015. All Rights Reserved + @license GNU/GPL Version 2 or later - http://www.gnu.org/licenses/gpl-2.0.html + +/------------------------------------------------------------------------------------------------------*/ + +// No direct access to this file +defined('JPATH_BASE') or die('Restricted access'); +use VDM\Joomla\Utilities\Component\Helper; + +// get the form +$form = $displayData->getForm(); + +// get the layout fields override method name (from layout path/ID) +$layout_path_array = explode('.', $this->getLayoutId()); +// Since we cannot pass the layout and tab names as parameters to the model method +// this name combination of tab and layout in the method name is the only work around +// seeing that JCB uses those two values (tab_name & layout_name) as the layout file name. +// example of layout name: details_left.php +// example of method name: getFields_details_left() +$fields_tab_layout = 'fields_' . $layout_path_array[1]; + +$params = Helper::getParams('com_getbible'); +$active = $params->get('enable_open_ai', 0); + +// only load the fields if the OPEN AI is activated +$fields = []; +if ($active == 1) +{ + // get the fields + $fields = $displayData->get($fields_tab_layout) ?: array( + 'token_override', + 'token', + 'ai_org_token_override', + 'org_token', + 'model', + 'openai_documentation_note', + 'presence_penalty_override', + 'presence_penalty', + 'presence_penalty_note', + 'frequency_penalty_override', + 'frequency_penalty', + 'frequency_penalty_note' + ); +} + +$hiddenFields = $displayData->get('hidden_fields') ?: array(); + +?> + + + + setFieldAttribute($field, 'type', 'hidden'); ?> + + renderField($field, null, null, array('class' => 'control-wrapper-' . $field)); ?> + + diff --git a/admin/layouts/prompt/prompt_above.php b/admin/layouts/prompt/prompt_above.php new file mode 100644 index 0000000..03d1854 --- /dev/null +++ b/admin/layouts/prompt/prompt_above.php @@ -0,0 +1,51 @@ + + @git Get Bible + @github Get Bible + @support Get Bible + @copyright Copyright (C) 2015. All Rights Reserved + @license GNU/GPL Version 2 or later - http://www.gnu.org/licenses/gpl-2.0.html + +/------------------------------------------------------------------------------------------------------*/ + +// No direct access to this file +defined('_JEXEC') or die('Restricted access'); + +// get the form +$form = $displayData->getForm(); + +// get the layout fields override method name (from layout path/ID) +$layout_path_array = explode('.', $this->getLayoutId()); +// Since we cannot pass the layout and tab names as parameters to the model method +// this name combination of tab and layout in the method name is the only work around +// seeing that JCB uses those two values (tab_name & layout_name) as the layout file name. +// example of layout name: details_left.php +// example of method name: getFields_details_left() +$fields_tab_layout = 'fields_' . $layout_path_array[1]; + +// get the fields +$fields = $displayData->get($fields_tab_layout) ?: array( + 'name', + 'abbreviation' +); + +$hiddenFields = $displayData->get('hidden_fields') ?: array(); + +?> + +
+ + + setFieldAttribute($field, 'type', 'hidden'); ?> + + renderField($field, null, null, array('class' => 'control-wrapper-' . $field)); ?> + +
+ diff --git a/admin/layouts/prompt/prompt_fullwidth.php b/admin/layouts/prompt/prompt_fullwidth.php new file mode 100644 index 0000000..6059cd2 --- /dev/null +++ b/admin/layouts/prompt/prompt_fullwidth.php @@ -0,0 +1,53 @@ + + @git Get Bible + @github Get Bible + @support Get Bible + @copyright Copyright (C) 2015. All Rights Reserved + @license GNU/GPL Version 2 or later - http://www.gnu.org/licenses/gpl-2.0.html + +/------------------------------------------------------------------------------------------------------*/ + +// No direct access to this file +defined('_JEXEC') or die('Restricted access'); + +// get the form +$form = $displayData->getForm(); + +// get the layout fields override method name (from layout path/ID) +$layout_path_array = explode('.', $this->getLayoutId()); +// Since we cannot pass the layout and tab names as parameters to the model method +// this name combination of tab and layout in the method name is the only work around +// seeing that JCB uses those two values (tab_name & layout_name) as the layout file name. +// example of layout name: details_left.php +// example of method name: getFields_details_left() +$fields_tab_layout = 'fields_' . $layout_path_array[1]; + +// get the fields +$fields = $displayData->get($fields_tab_layout) ?: array( + 'openai_prompts_placeholders_basic_caching_note', + 'openai_prompts_placeholders_advanced_caching_note', + 'openai_prompts_placeholders_none_caching_note', + 'messages' +); + +$hiddenFields = $displayData->get('hidden_fields') ?: array(); + +?> + +
+ + + setFieldAttribute($field, 'type', 'hidden'); ?> + + renderField($field, null, null, array('class' => 'control-wrapper-' . $field)); ?> + +
+ diff --git a/admin/layouts/prompt/prompt_left.php b/admin/layouts/prompt/prompt_left.php new file mode 100644 index 0000000..97ffcaf --- /dev/null +++ b/admin/layouts/prompt/prompt_left.php @@ -0,0 +1,53 @@ + + @git Get Bible + @github Get Bible + @support Get Bible + @copyright Copyright (C) 2015. All Rights Reserved + @license GNU/GPL Version 2 or later - http://www.gnu.org/licenses/gpl-2.0.html + +/------------------------------------------------------------------------------------------------------*/ + +// No direct access to this file +defined('_JEXEC') or die('Restricted access'); + +// get the form +$form = $displayData->getForm(); + +// get the layout fields override method name (from layout path/ID) +$layout_path_array = explode('.', $this->getLayoutId()); +// Since we cannot pass the layout and tab names as parameters to the model method +// this name combination of tab and layout in the method name is the only work around +// seeing that JCB uses those two values (tab_name & layout_name) as the layout file name. +// example of layout name: details_left.php +// example of method name: getFields_details_left() +$fields_tab_layout = 'fields_' . $layout_path_array[1]; + +// get the fields +$fields = $displayData->get($fields_tab_layout) ?: array( + 'integration', + 'integration_note', + 'cache_behaviour', + 'cache_persistently_expansive_caching_note', + 'cache_basic_note', + 'cache_advance_note' +); + +$hiddenFields = $displayData->get('hidden_fields') ?: array(); + +?> + + + + setFieldAttribute($field, 'type', 'hidden'); ?> + + renderField($field, null, null, array('class' => 'control-wrapper-' . $field)); ?> + + diff --git a/admin/layouts/prompt/prompt_right.php b/admin/layouts/prompt/prompt_right.php new file mode 100644 index 0000000..f99214b --- /dev/null +++ b/admin/layouts/prompt/prompt_right.php @@ -0,0 +1,51 @@ + + @git Get Bible + @github Get Bible + @support Get Bible + @copyright Copyright (C) 2015. All Rights Reserved + @license GNU/GPL Version 2 or later - http://www.gnu.org/licenses/gpl-2.0.html + +/------------------------------------------------------------------------------------------------------*/ + +// No direct access to this file +defined('_JEXEC') or die('Restricted access'); + +// get the form +$form = $displayData->getForm(); + +// get the layout fields override method name (from layout path/ID) +$layout_path_array = explode('.', $this->getLayoutId()); +// Since we cannot pass the layout and tab names as parameters to the model method +// this name combination of tab and layout in the method name is the only work around +// seeing that JCB uses those two values (tab_name & layout_name) as the layout file name. +// example of layout name: details_left.php +// example of method name: getFields_details_left() +$fields_tab_layout = 'fields_' . $layout_path_array[1]; + +// get the fields +$fields = $displayData->get($fields_tab_layout) ?: array( + 'cache_capacity', + 'cache_capacity_note', + 'response_retrieval', + 'response_retrieval_note' +); + +$hiddenFields = $displayData->get('hidden_fields') ?: array(); + +?> + + + + setFieldAttribute($field, 'type', 'hidden'); ?> + + renderField($field, null, null, array('class' => 'control-wrapper-' . $field)); ?> + + diff --git a/admin/layouts/prompt/publishing.php b/admin/layouts/prompt/publishing.php new file mode 100644 index 0000000..72020c7 --- /dev/null +++ b/admin/layouts/prompt/publishing.php @@ -0,0 +1,53 @@ + + @git Get Bible + @github Get Bible + @support Get Bible + @copyright Copyright (C) 2015. All Rights Reserved + @license GNU/GPL Version 2 or later - http://www.gnu.org/licenses/gpl-2.0.html + +/------------------------------------------------------------------------------------------------------*/ + +// No direct access to this file +defined('_JEXEC') or die('Restricted access'); + +// get the form +$form = $displayData->getForm(); + +// get the layout fields override method name (from layout path/ID) +$layout_path_array = explode('.', $this->getLayoutId()); +// Since we cannot pass the layout and tab names as parameters to the model method +// this name combination of tab and layout in the method name is the only work around +// seeing that JCB uses those two values (tab_name & layout_name) as the layout file name. +// example of layout name: details_left.php +// example of method name: getFields_details_left() +$fields_tab_layout = 'fields_' . $layout_path_array[1]; + +// get the fields +$fields = $displayData->get($fields_tab_layout) ?: array( + 'guid', + 'title', + 'created', + 'created_by', + 'modified', + 'modified_by' +); + +$hiddenFields = $displayData->get('hidden_fields') ?: array(); + +?> + + + + setFieldAttribute($field, 'type', 'hidden'); ?> + + renderField($field, null, null, array('class' => 'control-wrapper-' . $field)); ?> + + diff --git a/admin/layouts/prompt/publlshing.php b/admin/layouts/prompt/publlshing.php new file mode 100644 index 0000000..171f8c2 --- /dev/null +++ b/admin/layouts/prompt/publlshing.php @@ -0,0 +1,53 @@ + + @git Get Bible + @github Get Bible + @support Get Bible + @copyright Copyright (C) 2015. All Rights Reserved + @license GNU/GPL Version 2 or later - http://www.gnu.org/licenses/gpl-2.0.html + +/------------------------------------------------------------------------------------------------------*/ + +// No direct access to this file +defined('_JEXEC') or die('Restricted access'); + +// get the form +$form = $displayData->getForm(); + +// get the layout fields override method name (from layout path/ID) +$layout_path_array = explode('.', $this->getLayoutId()); +// Since we cannot pass the layout and tab names as parameters to the model method +// this name combination of tab and layout in the method name is the only work around +// seeing that JCB uses those two values (tab_name & layout_name) as the layout file name. +// example of layout name: details_left.php +// example of method name: getFields_details_left() +$fields_tab_layout = 'fields_' . $layout_path_array[1]; + +// get the fields +$fields = $displayData->get($fields_tab_layout) ?: array( + 'published', + 'ordering', + 'access', + 'version', + 'hits', + 'id' +); + +$hiddenFields = $displayData->get('hidden_fields') ?: array(); + +?> + + + + setFieldAttribute($field, 'type', 'hidden'); ?> + + renderField($field, null, null, array('class' => 'control-wrapper-' . $field)); ?> + + diff --git a/admin/layouts/tag/details_above.php b/admin/layouts/tag/details_above.php new file mode 100644 index 0000000..2c98398 --- /dev/null +++ b/admin/layouts/tag/details_above.php @@ -0,0 +1,51 @@ + + @git Get Bible + @github Get Bible + @support Get Bible + @copyright Copyright (C) 2015. All Rights Reserved + @license GNU/GPL Version 2 or later - http://www.gnu.org/licenses/gpl-2.0.html + +/------------------------------------------------------------------------------------------------------*/ + +// No direct access to this file +defined('_JEXEC') or die('Restricted access'); + +// get the form +$form = $displayData->getForm(); + +// get the layout fields override method name (from layout path/ID) +$layout_path_array = explode('.', $this->getLayoutId()); +// Since we cannot pass the layout and tab names as parameters to the model method +// this name combination of tab and layout in the method name is the only work around +// seeing that JCB uses those two values (tab_name & layout_name) as the layout file name. +// example of layout name: details_left.php +// example of method name: getFields_details_left() +$fields_tab_layout = 'fields_' . $layout_path_array[1]; + +// get the fields +$fields = $displayData->get($fields_tab_layout) ?: array( + 'access', + 'linker' +); + +$hiddenFields = $displayData->get('hidden_fields') ?: array(); + +?> + +
+ + + setFieldAttribute($field, 'type', 'hidden'); ?> + + renderField($field, null, null, array('class' => 'control-wrapper-' . $field)); ?> + +
+ diff --git a/admin/layouts/tag/details_fullwidth.php b/admin/layouts/tag/details_fullwidth.php new file mode 100644 index 0000000..bb29c45 --- /dev/null +++ b/admin/layouts/tag/details_fullwidth.php @@ -0,0 +1,50 @@ + + @git Get Bible + @github Get Bible + @support Get Bible + @copyright Copyright (C) 2015. All Rights Reserved + @license GNU/GPL Version 2 or later - http://www.gnu.org/licenses/gpl-2.0.html + +/------------------------------------------------------------------------------------------------------*/ + +// No direct access to this file +defined('_JEXEC') or die('Restricted access'); + +// get the form +$form = $displayData->getForm(); + +// get the layout fields override method name (from layout path/ID) +$layout_path_array = explode('.', $this->getLayoutId()); +// Since we cannot pass the layout and tab names as parameters to the model method +// this name combination of tab and layout in the method name is the only work around +// seeing that JCB uses those two values (tab_name & layout_name) as the layout file name. +// example of layout name: details_left.php +// example of method name: getFields_details_left() +$fields_tab_layout = 'fields_' . $layout_path_array[1]; + +// get the fields +$fields = $displayData->get($fields_tab_layout) ?: array( + 'description' +); + +$hiddenFields = $displayData->get('hidden_fields') ?: array(); + +?> + +
+ + + setFieldAttribute($field, 'type', 'hidden'); ?> + + renderField($field, null, null, array('class' => 'control-wrapper-' . $field)); ?> + +
+ diff --git a/admin/layouts/tag/details_left.php b/admin/layouts/tag/details_left.php new file mode 100644 index 0000000..e867d90 --- /dev/null +++ b/admin/layouts/tag/details_left.php @@ -0,0 +1,48 @@ + + @git Get Bible + @github Get Bible + @support Get Bible + @copyright Copyright (C) 2015. All Rights Reserved + @license GNU/GPL Version 2 or later - http://www.gnu.org/licenses/gpl-2.0.html + +/------------------------------------------------------------------------------------------------------*/ + +// No direct access to this file +defined('_JEXEC') or die('Restricted access'); + +// get the form +$form = $displayData->getForm(); + +// get the layout fields override method name (from layout path/ID) +$layout_path_array = explode('.', $this->getLayoutId()); +// Since we cannot pass the layout and tab names as parameters to the model method +// this name combination of tab and layout in the method name is the only work around +// seeing that JCB uses those two values (tab_name & layout_name) as the layout file name. +// example of layout name: details_left.php +// example of method name: getFields_details_left() +$fields_tab_layout = 'fields_' . $layout_path_array[1]; + +// get the fields +$fields = $displayData->get($fields_tab_layout) ?: array( + 'name' +); + +$hiddenFields = $displayData->get('hidden_fields') ?: array(); + +?> + + + + setFieldAttribute($field, 'type', 'hidden'); ?> + + renderField($field, null, null, array('class' => 'control-wrapper-' . $field)); ?> + + diff --git a/admin/layouts/tag/index.html b/admin/layouts/tag/index.html new file mode 100644 index 0000000..fa6d84e --- /dev/null +++ b/admin/layouts/tag/index.html @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/admin/layouts/tag/publishing.php b/admin/layouts/tag/publishing.php new file mode 100644 index 0000000..72020c7 --- /dev/null +++ b/admin/layouts/tag/publishing.php @@ -0,0 +1,53 @@ + + @git Get Bible + @github Get Bible + @support Get Bible + @copyright Copyright (C) 2015. All Rights Reserved + @license GNU/GPL Version 2 or later - http://www.gnu.org/licenses/gpl-2.0.html + +/------------------------------------------------------------------------------------------------------*/ + +// No direct access to this file +defined('_JEXEC') or die('Restricted access'); + +// get the form +$form = $displayData->getForm(); + +// get the layout fields override method name (from layout path/ID) +$layout_path_array = explode('.', $this->getLayoutId()); +// Since we cannot pass the layout and tab names as parameters to the model method +// this name combination of tab and layout in the method name is the only work around +// seeing that JCB uses those two values (tab_name & layout_name) as the layout file name. +// example of layout name: details_left.php +// example of method name: getFields_details_left() +$fields_tab_layout = 'fields_' . $layout_path_array[1]; + +// get the fields +$fields = $displayData->get($fields_tab_layout) ?: array( + 'guid', + 'title', + 'created', + 'created_by', + 'modified', + 'modified_by' +); + +$hiddenFields = $displayData->get('hidden_fields') ?: array(); + +?> + + + + setFieldAttribute($field, 'type', 'hidden'); ?> + + renderField($field, null, null, array('class' => 'control-wrapper-' . $field)); ?> + + diff --git a/admin/layouts/tag/publlshing.php b/admin/layouts/tag/publlshing.php new file mode 100644 index 0000000..1c6d9d7 --- /dev/null +++ b/admin/layouts/tag/publlshing.php @@ -0,0 +1,52 @@ + + @git Get Bible + @github Get Bible + @support Get Bible + @copyright Copyright (C) 2015. All Rights Reserved + @license GNU/GPL Version 2 or later - http://www.gnu.org/licenses/gpl-2.0.html + +/------------------------------------------------------------------------------------------------------*/ + +// No direct access to this file +defined('_JEXEC') or die('Restricted access'); + +// get the form +$form = $displayData->getForm(); + +// get the layout fields override method name (from layout path/ID) +$layout_path_array = explode('.', $this->getLayoutId()); +// Since we cannot pass the layout and tab names as parameters to the model method +// this name combination of tab and layout in the method name is the only work around +// seeing that JCB uses those two values (tab_name & layout_name) as the layout file name. +// example of layout name: details_left.php +// example of method name: getFields_details_left() +$fields_tab_layout = 'fields_' . $layout_path_array[1]; + +// get the fields +$fields = $displayData->get($fields_tab_layout) ?: array( + 'published', + 'ordering', + 'version', + 'hits', + 'id' +); + +$hiddenFields = $displayData->get('hidden_fields') ?: array(); + +?> + + + + setFieldAttribute($field, 'type', 'hidden'); ?> + + renderField($field, null, null, array('class' => 'control-wrapper-' . $field)); ?> + + diff --git a/admin/layouts/tagged_verse/details_above.php b/admin/layouts/tagged_verse/details_above.php new file mode 100644 index 0000000..a26fbde --- /dev/null +++ b/admin/layouts/tagged_verse/details_above.php @@ -0,0 +1,52 @@ + + @git Get Bible + @github Get Bible + @support Get Bible + @copyright Copyright (C) 2015. All Rights Reserved + @license GNU/GPL Version 2 or later - http://www.gnu.org/licenses/gpl-2.0.html + +/------------------------------------------------------------------------------------------------------*/ + +// No direct access to this file +defined('_JEXEC') or die('Restricted access'); + +// get the form +$form = $displayData->getForm(); + +// get the layout fields override method name (from layout path/ID) +$layout_path_array = explode('.', $this->getLayoutId()); +// Since we cannot pass the layout and tab names as parameters to the model method +// this name combination of tab and layout in the method name is the only work around +// seeing that JCB uses those two values (tab_name & layout_name) as the layout file name. +// example of layout name: details_left.php +// example of method name: getFields_details_left() +$fields_tab_layout = 'fields_' . $layout_path_array[1]; + +// get the fields +$fields = $displayData->get($fields_tab_layout) ?: array( + 'tag', + 'access', + 'linker' +); + +$hiddenFields = $displayData->get('hidden_fields') ?: array(); + +?> + +
+ + + setFieldAttribute($field, 'type', 'hidden'); ?> + + renderField($field, null, null, array('class' => 'control-wrapper-' . $field)); ?> + +
+ diff --git a/admin/layouts/tagged_verse/details_left.php b/admin/layouts/tagged_verse/details_left.php new file mode 100644 index 0000000..9871257 --- /dev/null +++ b/admin/layouts/tagged_verse/details_left.php @@ -0,0 +1,49 @@ + + @git Get Bible + @github Get Bible + @support Get Bible + @copyright Copyright (C) 2015. All Rights Reserved + @license GNU/GPL Version 2 or later - http://www.gnu.org/licenses/gpl-2.0.html + +/------------------------------------------------------------------------------------------------------*/ + +// No direct access to this file +defined('_JEXEC') or die('Restricted access'); + +// get the form +$form = $displayData->getForm(); + +// get the layout fields override method name (from layout path/ID) +$layout_path_array = explode('.', $this->getLayoutId()); +// Since we cannot pass the layout and tab names as parameters to the model method +// this name combination of tab and layout in the method name is the only work around +// seeing that JCB uses those two values (tab_name & layout_name) as the layout file name. +// example of layout name: details_left.php +// example of method name: getFields_details_left() +$fields_tab_layout = 'fields_' . $layout_path_array[1]; + +// get the fields +$fields = $displayData->get($fields_tab_layout) ?: array( + 'abbreviation', + 'book_nr' +); + +$hiddenFields = $displayData->get('hidden_fields') ?: array(); + +?> + + + + setFieldAttribute($field, 'type', 'hidden'); ?> + + renderField($field, null, null, array('class' => 'control-wrapper-' . $field)); ?> + + diff --git a/admin/layouts/tagged_verse/details_right.php b/admin/layouts/tagged_verse/details_right.php new file mode 100644 index 0000000..558b01a --- /dev/null +++ b/admin/layouts/tagged_verse/details_right.php @@ -0,0 +1,49 @@ + + @git Get Bible + @github Get Bible + @support Get Bible + @copyright Copyright (C) 2015. All Rights Reserved + @license GNU/GPL Version 2 or later - http://www.gnu.org/licenses/gpl-2.0.html + +/------------------------------------------------------------------------------------------------------*/ + +// No direct access to this file +defined('_JEXEC') or die('Restricted access'); + +// get the form +$form = $displayData->getForm(); + +// get the layout fields override method name (from layout path/ID) +$layout_path_array = explode('.', $this->getLayoutId()); +// Since we cannot pass the layout and tab names as parameters to the model method +// this name combination of tab and layout in the method name is the only work around +// seeing that JCB uses those two values (tab_name & layout_name) as the layout file name. +// example of layout name: details_left.php +// example of method name: getFields_details_left() +$fields_tab_layout = 'fields_' . $layout_path_array[1]; + +// get the fields +$fields = $displayData->get($fields_tab_layout) ?: array( + 'chapter', + 'verse' +); + +$hiddenFields = $displayData->get('hidden_fields') ?: array(); + +?> + + + + setFieldAttribute($field, 'type', 'hidden'); ?> + + renderField($field, null, null, array('class' => 'control-wrapper-' . $field)); ?> + + diff --git a/admin/layouts/tagged_verse/index.html b/admin/layouts/tagged_verse/index.html new file mode 100644 index 0000000..fa6d84e --- /dev/null +++ b/admin/layouts/tagged_verse/index.html @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/admin/layouts/tagged_verse/publishing.php b/admin/layouts/tagged_verse/publishing.php new file mode 100644 index 0000000..72020c7 --- /dev/null +++ b/admin/layouts/tagged_verse/publishing.php @@ -0,0 +1,53 @@ + + @git Get Bible + @github Get Bible + @support Get Bible + @copyright Copyright (C) 2015. All Rights Reserved + @license GNU/GPL Version 2 or later - http://www.gnu.org/licenses/gpl-2.0.html + +/------------------------------------------------------------------------------------------------------*/ + +// No direct access to this file +defined('_JEXEC') or die('Restricted access'); + +// get the form +$form = $displayData->getForm(); + +// get the layout fields override method name (from layout path/ID) +$layout_path_array = explode('.', $this->getLayoutId()); +// Since we cannot pass the layout and tab names as parameters to the model method +// this name combination of tab and layout in the method name is the only work around +// seeing that JCB uses those two values (tab_name & layout_name) as the layout file name. +// example of layout name: details_left.php +// example of method name: getFields_details_left() +$fields_tab_layout = 'fields_' . $layout_path_array[1]; + +// get the fields +$fields = $displayData->get($fields_tab_layout) ?: array( + 'guid', + 'title', + 'created', + 'created_by', + 'modified', + 'modified_by' +); + +$hiddenFields = $displayData->get('hidden_fields') ?: array(); + +?> + + + + setFieldAttribute($field, 'type', 'hidden'); ?> + + renderField($field, null, null, array('class' => 'control-wrapper-' . $field)); ?> + + diff --git a/admin/layouts/tagged_verse/publlshing.php b/admin/layouts/tagged_verse/publlshing.php new file mode 100644 index 0000000..1c6d9d7 --- /dev/null +++ b/admin/layouts/tagged_verse/publlshing.php @@ -0,0 +1,52 @@ + + @git Get Bible + @github Get Bible + @support Get Bible + @copyright Copyright (C) 2015. All Rights Reserved + @license GNU/GPL Version 2 or later - http://www.gnu.org/licenses/gpl-2.0.html + +/------------------------------------------------------------------------------------------------------*/ + +// No direct access to this file +defined('_JEXEC') or die('Restricted access'); + +// get the form +$form = $displayData->getForm(); + +// get the layout fields override method name (from layout path/ID) +$layout_path_array = explode('.', $this->getLayoutId()); +// Since we cannot pass the layout and tab names as parameters to the model method +// this name combination of tab and layout in the method name is the only work around +// seeing that JCB uses those two values (tab_name & layout_name) as the layout file name. +// example of layout name: details_left.php +// example of method name: getFields_details_left() +$fields_tab_layout = 'fields_' . $layout_path_array[1]; + +// get the fields +$fields = $displayData->get($fields_tab_layout) ?: array( + 'published', + 'ordering', + 'version', + 'hits', + 'id' +); + +$hiddenFields = $displayData->get('hidden_fields') ?: array(); + +?> + + + + setFieldAttribute($field, 'type', 'hidden'); ?> + + renderField($field, null, null, array('class' => 'control-wrapper-' . $field)); ?> + + diff --git a/admin/layouts/translation/details_above.php b/admin/layouts/translation/details_above.php new file mode 100644 index 0000000..fe171d8 --- /dev/null +++ b/admin/layouts/translation/details_above.php @@ -0,0 +1,52 @@ + + @git Get Bible + @github Get Bible + @support Get Bible + @copyright Copyright (C) 2015. All Rights Reserved + @license GNU/GPL Version 2 or later - http://www.gnu.org/licenses/gpl-2.0.html + +/------------------------------------------------------------------------------------------------------*/ + +// No direct access to this file +defined('_JEXEC') or die('Restricted access'); + +// get the form +$form = $displayData->getForm(); + +// get the layout fields override method name (from layout path/ID) +$layout_path_array = explode('.', $this->getLayoutId()); +// Since we cannot pass the layout and tab names as parameters to the model method +// this name combination of tab and layout in the method name is the only work around +// seeing that JCB uses those two values (tab_name & layout_name) as the layout file name. +// example of layout name: details_left.php +// example of method name: getFields_details_left() +$fields_tab_layout = 'fields_' . $layout_path_array[1]; + +// get the fields +$fields = $displayData->get($fields_tab_layout) ?: array( + 'translation', + 'abbreviation', + 'direction' +); + +$hiddenFields = $displayData->get('hidden_fields') ?: array(); + +?> + +
+ + + setFieldAttribute($field, 'type', 'hidden'); ?> + + renderField($field, null, null, array('class' => 'control-wrapper-' . $field)); ?> + +
+ diff --git a/admin/layouts/translation/details_fullwidth.php b/admin/layouts/translation/details_fullwidth.php new file mode 100644 index 0000000..b430e43 --- /dev/null +++ b/admin/layouts/translation/details_fullwidth.php @@ -0,0 +1,51 @@ + + @git Get Bible + @github Get Bible + @support Get Bible + @copyright Copyright (C) 2015. All Rights Reserved + @license GNU/GPL Version 2 or later - http://www.gnu.org/licenses/gpl-2.0.html + +/------------------------------------------------------------------------------------------------------*/ + +// No direct access to this file +defined('_JEXEC') or die('Restricted access'); + +// get the form +$form = $displayData->getForm(); + +// get the layout fields override method name (from layout path/ID) +$layout_path_array = explode('.', $this->getLayoutId()); +// Since we cannot pass the layout and tab names as parameters to the model method +// this name combination of tab and layout in the method name is the only work around +// seeing that JCB uses those two values (tab_name & layout_name) as the layout file name. +// example of layout name: details_left.php +// example of method name: getFields_details_left() +$fields_tab_layout = 'fields_' . $layout_path_array[1]; + +// get the fields +$fields = $displayData->get($fields_tab_layout) ?: array( + 'distribution_about', + 'distribution_history' +); + +$hiddenFields = $displayData->get('hidden_fields') ?: array(); + +?> + +
+ + + setFieldAttribute($field, 'type', 'hidden'); ?> + + renderField($field, null, null, array('class' => 'control-wrapper-' . $field)); ?> + +
+ diff --git a/admin/layouts/translation/details_left.php b/admin/layouts/translation/details_left.php new file mode 100644 index 0000000..3593ad1 --- /dev/null +++ b/admin/layouts/translation/details_left.php @@ -0,0 +1,54 @@ + + @git Get Bible + @github Get Bible + @support Get Bible + @copyright Copyright (C) 2015. All Rights Reserved + @license GNU/GPL Version 2 or later - http://www.gnu.org/licenses/gpl-2.0.html + +/------------------------------------------------------------------------------------------------------*/ + +// No direct access to this file +defined('_JEXEC') or die('Restricted access'); + +// get the form +$form = $displayData->getForm(); + +// get the layout fields override method name (from layout path/ID) +$layout_path_array = explode('.', $this->getLayoutId()); +// Since we cannot pass the layout and tab names as parameters to the model method +// this name combination of tab and layout in the method name is the only work around +// seeing that JCB uses those two values (tab_name & layout_name) as the layout file name. +// example of layout name: details_left.php +// example of method name: getFields_details_left() +$fields_tab_layout = 'fields_' . $layout_path_array[1]; + +// get the fields +$fields = $displayData->get($fields_tab_layout) ?: array( + 'distribution_abbreviation', + 'distribution_versification', + 'distribution_version', + 'distribution_version_date', + 'distribution_lcsh', + 'encoding', + 'sha' +); + +$hiddenFields = $displayData->get('hidden_fields') ?: array(); + +?> + + + + setFieldAttribute($field, 'type', 'hidden'); ?> + + renderField($field, null, null, array('class' => 'control-wrapper-' . $field)); ?> + + diff --git a/admin/layouts/translation/details_right.php b/admin/layouts/translation/details_right.php new file mode 100644 index 0000000..b42845e --- /dev/null +++ b/admin/layouts/translation/details_right.php @@ -0,0 +1,52 @@ + + @git Get Bible + @github Get Bible + @support Get Bible + @copyright Copyright (C) 2015. All Rights Reserved + @license GNU/GPL Version 2 or later - http://www.gnu.org/licenses/gpl-2.0.html + +/------------------------------------------------------------------------------------------------------*/ + +// No direct access to this file +defined('_JEXEC') or die('Restricted access'); + +// get the form +$form = $displayData->getForm(); + +// get the layout fields override method name (from layout path/ID) +$layout_path_array = explode('.', $this->getLayoutId()); +// Since we cannot pass the layout and tab names as parameters to the model method +// this name combination of tab and layout in the method name is the only work around +// seeing that JCB uses those two values (tab_name & layout_name) as the layout file name. +// example of layout name: details_left.php +// example of method name: getFields_details_left() +$fields_tab_layout = 'fields_' . $layout_path_array[1]; + +// get the fields +$fields = $displayData->get($fields_tab_layout) ?: array( + 'language', + 'lang', + 'distribution_sourcetype', + 'distribution_source', + 'distribution_license' +); + +$hiddenFields = $displayData->get('hidden_fields') ?: array(); + +?> + + + + setFieldAttribute($field, 'type', 'hidden'); ?> + + renderField($field, null, null, array('class' => 'control-wrapper-' . $field)); ?> + + diff --git a/admin/layouts/translation/index.html b/admin/layouts/translation/index.html new file mode 100644 index 0000000..fa6d84e --- /dev/null +++ b/admin/layouts/translation/index.html @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/admin/layouts/translation/publishing.php b/admin/layouts/translation/publishing.php new file mode 100644 index 0000000..df756a0 --- /dev/null +++ b/admin/layouts/translation/publishing.php @@ -0,0 +1,52 @@ + + @git Get Bible + @github Get Bible + @support Get Bible + @copyright Copyright (C) 2015. All Rights Reserved + @license GNU/GPL Version 2 or later - http://www.gnu.org/licenses/gpl-2.0.html + +/------------------------------------------------------------------------------------------------------*/ + +// No direct access to this file +defined('_JEXEC') or die('Restricted access'); + +// get the form +$form = $displayData->getForm(); + +// get the layout fields override method name (from layout path/ID) +$layout_path_array = explode('.', $this->getLayoutId()); +// Since we cannot pass the layout and tab names as parameters to the model method +// this name combination of tab and layout in the method name is the only work around +// seeing that JCB uses those two values (tab_name & layout_name) as the layout file name. +// example of layout name: details_left.php +// example of method name: getFields_details_left() +$fields_tab_layout = 'fields_' . $layout_path_array[1]; + +// get the fields +$fields = $displayData->get($fields_tab_layout) ?: array( + 'title', + 'created', + 'created_by', + 'modified', + 'modified_by' +); + +$hiddenFields = $displayData->get('hidden_fields') ?: array(); + +?> + + + + setFieldAttribute($field, 'type', 'hidden'); ?> + + renderField($field, null, null, array('class' => 'control-wrapper-' . $field)); ?> + + diff --git a/admin/layouts/translation/publlshing.php b/admin/layouts/translation/publlshing.php new file mode 100644 index 0000000..171f8c2 --- /dev/null +++ b/admin/layouts/translation/publlshing.php @@ -0,0 +1,53 @@ + + @git Get Bible + @github Get Bible + @support Get Bible + @copyright Copyright (C) 2015. All Rights Reserved + @license GNU/GPL Version 2 or later - http://www.gnu.org/licenses/gpl-2.0.html + +/------------------------------------------------------------------------------------------------------*/ + +// No direct access to this file +defined('_JEXEC') or die('Restricted access'); + +// get the form +$form = $displayData->getForm(); + +// get the layout fields override method name (from layout path/ID) +$layout_path_array = explode('.', $this->getLayoutId()); +// Since we cannot pass the layout and tab names as parameters to the model method +// this name combination of tab and layout in the method name is the only work around +// seeing that JCB uses those two values (tab_name & layout_name) as the layout file name. +// example of layout name: details_left.php +// example of method name: getFields_details_left() +$fields_tab_layout = 'fields_' . $layout_path_array[1]; + +// get the fields +$fields = $displayData->get($fields_tab_layout) ?: array( + 'published', + 'ordering', + 'access', + 'version', + 'hits', + 'id' +); + +$hiddenFields = $displayData->get('hidden_fields') ?: array(); + +?> + + + + setFieldAttribute($field, 'type', 'hidden'); ?> + + renderField($field, null, null, array('class' => 'control-wrapper-' . $field)); ?> + + diff --git a/admin/layouts/trashhelper.php b/admin/layouts/trashhelper.php new file mode 100644 index 0000000..95bc7c9 --- /dev/null +++ b/admin/layouts/trashhelper.php @@ -0,0 +1,79 @@ + + @git Get Bible + @github Get Bible + @support Get Bible + @copyright Copyright (C) 2015. All Rights Reserved + @license GNU/GPL Version 2 or later - http://www.gnu.org/licenses/gpl-2.0.html + +/------------------------------------------------------------------------------------------------------*/ + +// No direct access to this file +defined('JPATH_BASE') or die('Restricted access'); + + + +?> +state->get('filter.published') == -2 && ($displayData->canState && $displayData->canDelete)) : ?> + +
+ items)): ?> +

+ + +

+

+ +

+ + +

+

+ + + +
+ diff --git a/admin/layouts/verse/details_above.php b/admin/layouts/verse/details_above.php new file mode 100644 index 0000000..c662ca5 --- /dev/null +++ b/admin/layouts/verse/details_above.php @@ -0,0 +1,52 @@ + + @git Get Bible + @github Get Bible + @support Get Bible + @copyright Copyright (C) 2015. All Rights Reserved + @license GNU/GPL Version 2 or later - http://www.gnu.org/licenses/gpl-2.0.html + +/------------------------------------------------------------------------------------------------------*/ + +// No direct access to this file +defined('_JEXEC') or die('Restricted access'); + +// get the form +$form = $displayData->getForm(); + +// get the layout fields override method name (from layout path/ID) +$layout_path_array = explode('.', $this->getLayoutId()); +// Since we cannot pass the layout and tab names as parameters to the model method +// this name combination of tab and layout in the method name is the only work around +// seeing that JCB uses those two values (tab_name & layout_name) as the layout file name. +// example of layout name: details_left.php +// example of method name: getFields_details_left() +$fields_tab_layout = 'fields_' . $layout_path_array[1]; + +// get the fields +$fields = $displayData->get($fields_tab_layout) ?: array( + 'book_nr', + 'chapter', + 'verse' +); + +$hiddenFields = $displayData->get('hidden_fields') ?: array(); + +?> + +
+ + + setFieldAttribute($field, 'type', 'hidden'); ?> + + renderField($field, null, null, array('class' => 'control-wrapper-' . $field)); ?> + +
+ diff --git a/admin/layouts/verse/details_fullwidth.php b/admin/layouts/verse/details_fullwidth.php new file mode 100644 index 0000000..fc8106f --- /dev/null +++ b/admin/layouts/verse/details_fullwidth.php @@ -0,0 +1,50 @@ + + @git Get Bible + @github Get Bible + @support Get Bible + @copyright Copyright (C) 2015. All Rights Reserved + @license GNU/GPL Version 2 or later - http://www.gnu.org/licenses/gpl-2.0.html + +/------------------------------------------------------------------------------------------------------*/ + +// No direct access to this file +defined('_JEXEC') or die('Restricted access'); + +// get the form +$form = $displayData->getForm(); + +// get the layout fields override method name (from layout path/ID) +$layout_path_array = explode('.', $this->getLayoutId()); +// Since we cannot pass the layout and tab names as parameters to the model method +// this name combination of tab and layout in the method name is the only work around +// seeing that JCB uses those two values (tab_name & layout_name) as the layout file name. +// example of layout name: details_left.php +// example of method name: getFields_details_left() +$fields_tab_layout = 'fields_' . $layout_path_array[1]; + +// get the fields +$fields = $displayData->get($fields_tab_layout) ?: array( + 'text' +); + +$hiddenFields = $displayData->get('hidden_fields') ?: array(); + +?> + +
+ + + setFieldAttribute($field, 'type', 'hidden'); ?> + + renderField($field, null, null, array('class' => 'control-wrapper-' . $field)); ?> + +
+ diff --git a/admin/layouts/verse/details_left.php b/admin/layouts/verse/details_left.php new file mode 100644 index 0000000..88f95d4 --- /dev/null +++ b/admin/layouts/verse/details_left.php @@ -0,0 +1,48 @@ + + @git Get Bible + @github Get Bible + @support Get Bible + @copyright Copyright (C) 2015. All Rights Reserved + @license GNU/GPL Version 2 or later - http://www.gnu.org/licenses/gpl-2.0.html + +/------------------------------------------------------------------------------------------------------*/ + +// No direct access to this file +defined('_JEXEC') or die('Restricted access'); + +// get the form +$form = $displayData->getForm(); + +// get the layout fields override method name (from layout path/ID) +$layout_path_array = explode('.', $this->getLayoutId()); +// Since we cannot pass the layout and tab names as parameters to the model method +// this name combination of tab and layout in the method name is the only work around +// seeing that JCB uses those two values (tab_name & layout_name) as the layout file name. +// example of layout name: details_left.php +// example of method name: getFields_details_left() +$fields_tab_layout = 'fields_' . $layout_path_array[1]; + +// get the fields +$fields = $displayData->get($fields_tab_layout) ?: array( + 'abbreviation' +); + +$hiddenFields = $displayData->get('hidden_fields') ?: array(); + +?> + + + + setFieldAttribute($field, 'type', 'hidden'); ?> + + renderField($field, null, null, array('class' => 'control-wrapper-' . $field)); ?> + + diff --git a/admin/layouts/verse/details_right.php b/admin/layouts/verse/details_right.php new file mode 100644 index 0000000..e867d90 --- /dev/null +++ b/admin/layouts/verse/details_right.php @@ -0,0 +1,48 @@ + + @git Get Bible + @github Get Bible + @support Get Bible + @copyright Copyright (C) 2015. All Rights Reserved + @license GNU/GPL Version 2 or later - http://www.gnu.org/licenses/gpl-2.0.html + +/------------------------------------------------------------------------------------------------------*/ + +// No direct access to this file +defined('_JEXEC') or die('Restricted access'); + +// get the form +$form = $displayData->getForm(); + +// get the layout fields override method name (from layout path/ID) +$layout_path_array = explode('.', $this->getLayoutId()); +// Since we cannot pass the layout and tab names as parameters to the model method +// this name combination of tab and layout in the method name is the only work around +// seeing that JCB uses those two values (tab_name & layout_name) as the layout file name. +// example of layout name: details_left.php +// example of method name: getFields_details_left() +$fields_tab_layout = 'fields_' . $layout_path_array[1]; + +// get the fields +$fields = $displayData->get($fields_tab_layout) ?: array( + 'name' +); + +$hiddenFields = $displayData->get('hidden_fields') ?: array(); + +?> + + + + setFieldAttribute($field, 'type', 'hidden'); ?> + + renderField($field, null, null, array('class' => 'control-wrapper-' . $field)); ?> + + diff --git a/admin/layouts/verse/index.html b/admin/layouts/verse/index.html new file mode 100644 index 0000000..fa6d84e --- /dev/null +++ b/admin/layouts/verse/index.html @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/admin/layouts/verse/publishing.php b/admin/layouts/verse/publishing.php new file mode 100644 index 0000000..df756a0 --- /dev/null +++ b/admin/layouts/verse/publishing.php @@ -0,0 +1,52 @@ + + @git Get Bible + @github Get Bible + @support Get Bible + @copyright Copyright (C) 2015. All Rights Reserved + @license GNU/GPL Version 2 or later - http://www.gnu.org/licenses/gpl-2.0.html + +/------------------------------------------------------------------------------------------------------*/ + +// No direct access to this file +defined('_JEXEC') or die('Restricted access'); + +// get the form +$form = $displayData->getForm(); + +// get the layout fields override method name (from layout path/ID) +$layout_path_array = explode('.', $this->getLayoutId()); +// Since we cannot pass the layout and tab names as parameters to the model method +// this name combination of tab and layout in the method name is the only work around +// seeing that JCB uses those two values (tab_name & layout_name) as the layout file name. +// example of layout name: details_left.php +// example of method name: getFields_details_left() +$fields_tab_layout = 'fields_' . $layout_path_array[1]; + +// get the fields +$fields = $displayData->get($fields_tab_layout) ?: array( + 'title', + 'created', + 'created_by', + 'modified', + 'modified_by' +); + +$hiddenFields = $displayData->get('hidden_fields') ?: array(); + +?> + + + + setFieldAttribute($field, 'type', 'hidden'); ?> + + renderField($field, null, null, array('class' => 'control-wrapper-' . $field)); ?> + + diff --git a/admin/layouts/verse/publlshing.php b/admin/layouts/verse/publlshing.php new file mode 100644 index 0000000..171f8c2 --- /dev/null +++ b/admin/layouts/verse/publlshing.php @@ -0,0 +1,53 @@ + + @git Get Bible + @github Get Bible + @support Get Bible + @copyright Copyright (C) 2015. All Rights Reserved + @license GNU/GPL Version 2 or later - http://www.gnu.org/licenses/gpl-2.0.html + +/------------------------------------------------------------------------------------------------------*/ + +// No direct access to this file +defined('_JEXEC') or die('Restricted access'); + +// get the form +$form = $displayData->getForm(); + +// get the layout fields override method name (from layout path/ID) +$layout_path_array = explode('.', $this->getLayoutId()); +// Since we cannot pass the layout and tab names as parameters to the model method +// this name combination of tab and layout in the method name is the only work around +// seeing that JCB uses those two values (tab_name & layout_name) as the layout file name. +// example of layout name: details_left.php +// example of method name: getFields_details_left() +$fields_tab_layout = 'fields_' . $layout_path_array[1]; + +// get the fields +$fields = $displayData->get($fields_tab_layout) ?: array( + 'published', + 'ordering', + 'access', + 'version', + 'hits', + 'id' +); + +$hiddenFields = $displayData->get('hidden_fields') ?: array(); + +?> + + + + setFieldAttribute($field, 'type', 'hidden'); ?> + + renderField($field, null, null, array('class' => 'control-wrapper-' . $field)); ?> + + diff --git a/admin/models/ajax.php b/admin/models/ajax.php new file mode 100644 index 0000000..f5c4064 --- /dev/null +++ b/admin/models/ajax.php @@ -0,0 +1,255 @@ + + @git Get Bible + @github Get Bible + @support Get Bible + @copyright Copyright (C) 2015. All Rights Reserved + @license GNU/GPL Version 2 or later - http://www.gnu.org/licenses/gpl-2.0.html + +/------------------------------------------------------------------------------------------------------*/ + +// No direct access to this file +defined('_JEXEC') or die('Restricted access'); + +use Joomla\CMS\MVC\Model\ListModel; +use Joomla\Utilities\ArrayHelper; +use Joomla\Registry\Registry; +use Joomla\CMS\Language\Text; +use VDM\Joomla\Utilities\FileHelper; +use VDM\Joomla\Gitea\Factory; + +/** + * Getbible Ajax List Model + */ +class GetbibleModelAjax extends ListModel +{ + protected $app_params; + + public function __construct() + { + parent::__construct(); + // get params + $this->app_params = JComponentHelper::getParams('com_getbible'); + + } + + // Used in translation + + /** + * Check and if a notice is new (per/user) + * + * @param string|null $notice The current notice + * + * @return bool true if is new + * @since 2.0.0 + */ + public function isNew(?string $notice): bool + { + // first get the file path + $path_filename = FileHelper::getPath('path', 'usernotice', 'md', JFactory::getUser()->username, JPATH_COMPONENT_ADMINISTRATOR); + + // check if the file is set + if (($content = FileHelper::getContent($path_filename, FALSE)) !== FALSE) + { + if ($notice == $content) + { + return false; + } + } + return true; + } + + /** + * Check if a notice has been read (per/user) + * + * @param string|null $notice The current notice + * + * @return bool true if is read + * @since 2.0.0 + */ + public function isRead(?string $notice): bool + { + // first get the file path + $path_filename = FileHelper::getPath('path', 'usernotice', 'md', JFactory::getUser()->username, JPATH_COMPONENT_ADMINISTRATOR); + + // set as read if not already set + if (($content = FileHelper::getContent($path_filename, FALSE)) !== FALSE) + { + if ($notice == $content) + { + return true; + } + } + + return FileHelper::write($path_filename, $notice); + } + + /** + * get Current Version + * + * @param string|null $message The error messages if any. + * + * @return array The array of the notice or error message + * @since 2.3.0 + */ + public function getVersion($version = null) + { + // get the token if set + $token = $this->app_params->get('gitea_token', false); + + // only add if token is set + if ($token) + { + try + { + // load the API details + Factory::_('Gitea.Repository.Tags')->load_('https://git.vdm.dev', $token); + + // get the repository tags + $tags = Factory::_('Gitea.Repository.Tags')->list('getBible', 'joomla-component'); + } + catch (DomainException $e) + { + return $this->getTokenForVersion($e->getMessage()); + } + catch (InvalidArgumentException $e) + { + return $this->getTokenForVersion($e->getMessage()); + } + catch (Exception $e) + { + return $this->getTokenForVersion($e->getMessage()); + } + // do we have tags returned + if (isset($tags[0]) && isset($tags[0]->name)) + { + // get the version + $manifest = GetbibleHelper::manifest(); + $local_version = (string) $manifest->version; + $current_version = trim($tags[0]->name, 'vV'); + + // now check if this version is out dated + if ($current_version === $local_version) + { + return ['notice' => '' . Text::_('COM_GETBIBLE_UP_TO_DATE') . '']; + } + else + { + // check if this is beta version + $current_array = array_map(function ($v) { return (int) $v; }, (array) explode('.', $current_version)); + $local_array = array_map(function ($v) { return (int) $v; }, (array) explode('.', $local_version)); + if (($local_array[0] > $current_array[0]) || + ($local_array[0] == $current_array[0] && $local_array[1] > $current_array[1]) || + ($local_array[0] == $current_array[0] && $local_array[1] == $current_array[1] && $local_array[2] > $current_array[2])) + { + return ['notice' => '' . Text::_('COM_GETBIBLE_BETA_RELEASE') . '']; + } + else + { + // download link of the latest version + $download = "https://git.vdm.dev/api/v1/repos/joomla/[[[gitea_package_name]]]/archive/" . $tags[0]->name . ".zip?access_token=" . $token; + + return ['notice' => '' . Text::_('COM_GETBIBLE_OUT_OF_DATE') . '! ' . Text::_('COM_GETBIBLE_DOWNLOAD_UPDATE') . '!']; + } + } + } + } + + return $this->getTokenForVersion(); + } + + /** + * Instructions to get Token for version + * + * @param string|null $message The error messages if any. + * + * @return array The array of the error message + * @since 2.3.0 + */ + protected function getTokenForVersion(?string $message = null): array + { + // the URL + $url = 'https://git.vdm.dev/user/settings/applications'; + + // create link + $a = ''; + $_a = ''; + + if ($message) + { + return ['error' => $a . $message . $a_ . Text::_('COM_GETBIBLE_GET_TOKEN') . $_a]; + } + + return ['error' => $a . Text::_('COM_GETBIBLE_GET_TOKEN_FROM_VDM_TO_GET_UPDATE_NOTICE_AND_ADD_IT_TO_YOUR_GLOBAL_OPTIONS') . $a_ . Text::_('COM_GETBIBLE_GET_TOKEN') . $_a]; + } + + /** + * get Wiki Page + * + * @param string|null $message The error messages if any. + * + * @return array The array of the page or error message + * @since 2.3.0 + */ + public function getWiki(string $name = 'Home'): array + { + try + { + // load the API details + // Factory::_('Gitea.Repository.Wiki')->load_('https://git.vdm.dev', ''); + + // get the gitea wiki page im markdown + $wiki = Factory::_('Gitea.Repository.Wiki')->get('getBible', 'joomla-component', $name); + + // now render the page in HTML + $page = Factory::_('Gitea.Miscellaneous.Markdown')->render($wiki->content, true); + } + catch (DomainException $e) + { + return $this->getTokenForWiki($e->getMessage()); + } + catch (InvalidArgumentException $e) + { + return $this->getTokenForWiki($e->getMessage()); + } + catch (Exception $e) + { + return $this->getTokenForWiki($e->getMessage()); + } + + // get the html + if (isset($page)) + { + return ['page' => $page]; + } + + return $this->getTokenForWiki(); + } + + /** + * Instructions to get Token for wiki + * + * @param string|null $message The error messages if any. + * + * @return array The array of the error message + * @since 2.3.0 + */ + protected function getTokenForWiki(?string $message = null): array + { + if ($message) + { + return ['error' => $message]; + } + + return ['error' => Text::_('COM_GETBIBLE_THE_WIKI_CAN_ONLY_BE_LOADED_WHEN_YOUR_JCB_SYSTEM_HAS_INTERNET_CONNECTION')]; + } +} diff --git a/admin/models/book.php b/admin/models/book.php new file mode 100644 index 0000000..b750adc --- /dev/null +++ b/admin/models/book.php @@ -0,0 +1,951 @@ + + @git Get Bible + @github Get Bible + @support Get Bible + @copyright Copyright (C) 2015. All Rights Reserved + @license GNU/GPL Version 2 or later - http://www.gnu.org/licenses/gpl-2.0.html + +/------------------------------------------------------------------------------------------------------*/ + +// No direct access to this file +defined('_JEXEC') or die('Restricted access'); + +use Joomla\CMS\MVC\Model\AdminModel; +use Joomla\Registry\Registry; +use Joomla\String\StringHelper; +use Joomla\Utilities\ArrayHelper; + +/** + * Getbible Book Admin Model + */ +class GetbibleModelBook extends AdminModel +{ + /** + * The tab layout fields array. + * + * @var array + */ + protected $tabLayoutFields = array( + 'details' => array( + 'left' => array( + 'abbreviation' + ), + 'right' => array( + 'sha' + ), + 'above' => array( + 'name', + 'nr' + ) + ) + ); + + /** + * @var string The prefix to use with controller messages. + * @since 1.6 + */ + protected $text_prefix = 'COM_GETBIBLE'; + + /** + * The type alias for this content type. + * + * @var string + * @since 3.2 + */ + public $typeAlias = 'com_getbible.book'; + + /** + * Returns a Table object, always creating it + * + * @param type $type The table type to instantiate + * @param string $prefix A prefix for the table class name. Optional. + * @param array $config Configuration array for model. Optional. + * + * @return JTable A database object + * + * @since 1.6 + */ + public function getTable($type = 'book', $prefix = 'GetbibleTable', $config = array()) + { + // add table path for when model gets used from other component + $this->addTablePath(JPATH_ADMINISTRATOR . '/components/com_getbible/tables'); + // get instance of the table + return JTable::getInstance($type, $prefix, $config); + }###ADMIN_CUSTOM_BUTTONS_METHOD### + + /** + * Method to get a single record. + * + * @param integer $pk The id of the primary key. + * + * @return mixed Object on success, false on failure. + * + * @since 1.6 + */ + public function getItem($pk = null) + { + if ($item = parent::getItem($pk)) + { + if (!empty($item->params) && !is_array($item->params)) + { + // Convert the params field to an array. + $registry = new Registry; + $registry->loadString($item->params); + $item->params = $registry->toArray(); + } + + if (!empty($item->metadata)) + { + // Convert the metadata field to an array. + $registry = new Registry; + $registry->loadString($item->metadata); + $item->metadata = $registry->toArray(); + } + } + + return $item; + } + + /** + * Method to get the record form. + * + * @param array $data Data for the form. + * @param boolean $loadData True if the form is to load its own data (default case), false if not. + * @param array $options Optional array of options for the form creation. + * + * @return mixed A JForm object on success, false on failure + * + * @since 1.6 + */ + public function getForm($data = array(), $loadData = true, $options = array('control' => 'jform')) + { + // set load data option + $options['load_data'] = $loadData; + // check if xpath was set in options + $xpath = false; + if (isset($options['xpath'])) + { + $xpath = $options['xpath']; + unset($options['xpath']); + } + // check if clear form was set in options + $clear = false; + if (isset($options['clear'])) + { + $clear = $options['clear']; + unset($options['clear']); + } + + // Get the form. + $form = $this->loadForm('com_getbible.book', 'book', $options, $clear, $xpath); + + if (empty($form)) + { + return false; + } + + $jinput = JFactory::getApplication()->input; + + // The front end calls this model and uses a_id to avoid id clashes so we need to check for that first. + if ($jinput->get('a_id')) + { + $id = $jinput->get('a_id', 0, 'INT'); + } + // The back end uses id so we use that the rest of the time and set it to 0 by default. + else + { + $id = $jinput->get('id', 0, 'INT'); + } + + $user = JFactory::getUser(); + + // Check for existing item. + // Modify the form based on Edit State access controls. + if ($id != 0 && (!$user->authorise('book.edit.state', 'com_getbible.book.' . (int) $id)) + || ($id == 0 && !$user->authorise('book.edit.state', 'com_getbible'))) + { + // Disable fields for display. + $form->setFieldAttribute('ordering', 'disabled', 'true'); + $form->setFieldAttribute('published', 'disabled', 'true'); + // Disable fields while saving. + $form->setFieldAttribute('ordering', 'filter', 'unset'); + $form->setFieldAttribute('published', 'filter', 'unset'); + } + // If this is a new item insure the greated by is set. + if (0 == $id) + { + // Set the created_by to this user + $form->setValue('created_by', null, $user->id); + } + // Modify the form based on Edit Creaded By access controls. + if ($id != 0 && (!$user->authorise('book.edit.created_by', 'com_getbible.book.' . (int) $id)) + || ($id == 0 && !$user->authorise('book.edit.created_by', 'com_getbible'))) + { + // Disable fields for display. + $form->setFieldAttribute('created_by', 'disabled', 'true'); + // Disable fields for display. + $form->setFieldAttribute('created_by', 'readonly', 'true'); + // Disable fields while saving. + $form->setFieldAttribute('created_by', 'filter', 'unset'); + } + // Modify the form based on Edit Creaded Date access controls. + if ($id != 0 && (!$user->authorise('book.edit.created', 'com_getbible.book.' . (int) $id)) + || ($id == 0 && !$user->authorise('book.edit.created', 'com_getbible'))) + { + // Disable fields for display. + $form->setFieldAttribute('created', 'disabled', 'true'); + // Disable fields while saving. + $form->setFieldAttribute('created', 'filter', 'unset'); + } + // Modify the form based on Edit Name access controls. + if ($id != 0 && (!$user->authorise('book.edit.name', 'com_getbible.book.' . (int) $id)) + || ($id == 0 && !$user->authorise('book.edit.name', 'com_getbible'))) + { + // Disable fields for display. + $form->setFieldAttribute('name', 'disabled', 'true'); + // Disable fields for display. + $form->setFieldAttribute('name', 'readonly', 'true'); + // If there is no value continue. + if (!$form->getValue('name')) + { + // Disable fields while saving. + $form->setFieldAttribute('name', 'filter', 'unset'); + // Disable fields while saving. + $form->setFieldAttribute('name', 'required', 'false'); + } + } + // Modify the form based on Edit Abbreviation access controls. + if ($id != 0 && (!$user->authorise('book.edit.abbreviation', 'com_getbible.book.' . (int) $id)) + || ($id == 0 && !$user->authorise('book.edit.abbreviation', 'com_getbible'))) + { + // Disable fields for display. + $form->setFieldAttribute('abbreviation', 'disabled', 'true'); + // Disable fields for display. + $form->setFieldAttribute('abbreviation', 'readonly', 'true'); + // If there is no value continue. + if (!$form->getValue('abbreviation')) + { + // Disable fields while saving. + $form->setFieldAttribute('abbreviation', 'filter', 'unset'); + // Disable fields while saving. + $form->setFieldAttribute('abbreviation', 'required', 'false'); + } + } + // Modify the form based on Edit Nr access controls. + if ($id != 0 && (!$user->authorise('book.edit.nr', 'com_getbible.book.' . (int) $id)) + || ($id == 0 && !$user->authorise('book.edit.nr', 'com_getbible'))) + { + // Disable fields for display. + $form->setFieldAttribute('nr', 'disabled', 'true'); + // Disable fields for display. + $form->setFieldAttribute('nr', 'readonly', 'true'); + // If there is no value continue. + if (!$form->getValue('nr')) + { + // Disable fields while saving. + $form->setFieldAttribute('nr', 'filter', 'unset'); + // Disable fields while saving. + $form->setFieldAttribute('nr', 'required', 'false'); + } + } + // Modify the form based on Edit Sha access controls. + if ($id != 0 && (!$user->authorise('book.edit.sha', 'com_getbible.book.' . (int) $id)) + || ($id == 0 && !$user->authorise('book.edit.sha', 'com_getbible'))) + { + // Disable fields for display. + $form->setFieldAttribute('sha', 'disabled', 'true'); + // Disable fields for display. + $form->setFieldAttribute('sha', 'readonly', 'true'); + // If there is no value continue. + if (!$form->getValue('sha')) + { + // Disable fields while saving. + $form->setFieldAttribute('sha', 'filter', 'unset'); + // Disable fields while saving. + $form->setFieldAttribute('sha', 'required', 'false'); + } + } + // Only load these values if no id is found + if (0 == $id) + { + // Set redirected view name + $redirectedView = $jinput->get('ref', null, 'STRING'); + // Set field name (or fall back to view name) + $redirectedField = $jinput->get('field', $redirectedView, 'STRING'); + // Set redirected view id + $redirectedId = $jinput->get('refid', 0, 'INT'); + // Set field id (or fall back to redirected view id) + $redirectedValue = $jinput->get('field_id', $redirectedId, 'INT'); + if (0 != $redirectedValue && $redirectedField) + { + // Now set the local-redirected field default value + $form->setValue($redirectedField, null, $redirectedValue); + } + } + return $form; + } + + /** + * Method to get the script that have to be included on the form + * + * @return string script files + */ + public function getScript() + { + return 'media/com_getbible/js/book.js'; + } + + /** + * Method to test whether a record can be deleted. + * + * @param object $record A record object. + * + * @return boolean True if allowed to delete the record. Defaults to the permission set in the component. + * + * @since 1.6 + */ + protected function canDelete($record) + { + if (!empty($record->id)) + { + if ($record->published != -2) + { + return; + } + + $user = JFactory::getUser(); + // The record has been set. Check the record permissions. + return $user->authorise('book.delete', 'com_getbible.book.' . (int) $record->id); + } + return false; + } + + /** + * Method to test whether a record can have its state edited. + * + * @param object $record A record object. + * + * @return boolean True if allowed to change the state of the record. Defaults to the permission set in the component. + * + * @since 1.6 + */ + protected function canEditState($record) + { + $user = JFactory::getUser(); + $recordId = (!empty($record->id)) ? $record->id : 0; + + if ($recordId) + { + // The record has been set. Check the record permissions. + $permission = $user->authorise('book.edit.state', 'com_getbible.book.' . (int) $recordId); + if (!$permission && !is_null($permission)) + { + return false; + } + } + // In the absense of better information, revert to the component permissions. + return $user->authorise('book.edit.state', 'com_getbible'); + } + + /** + * Method override to check if you can edit an existing record. + * + * @param array $data An array of input data. + * @param string $key The name of the key for the primary key. + * + * @return boolean + * @since 2.5 + */ + protected function allowEdit($data = array(), $key = 'id') + { + // Check specific edit permission then general edit permission. + $user = JFactory::getUser(); + + return $user->authorise('book.edit', 'com_getbible.book.'. ((int) isset($data[$key]) ? $data[$key] : 0)) or $user->authorise('book.edit', 'com_getbible'); + } + + /** + * Prepare and sanitise the table data prior to saving. + * + * @param JTable $table A JTable object. + * + * @return void + * + * @since 1.6 + */ + protected function prepareTable($table) + { + $date = JFactory::getDate(); + $user = JFactory::getUser(); + + if (isset($table->name)) + { + $table->name = htmlspecialchars_decode($table->name, ENT_QUOTES); + } + + if (isset($table->alias) && empty($table->alias)) + { + $table->generateAlias(); + } + + if (empty($table->id)) + { + $table->created = $date->toSql(); + // set the user + if ($table->created_by == 0 || empty($table->created_by)) + { + $table->created_by = $user->id; + } + // Set ordering to the last item if not set + if (empty($table->ordering)) + { + $db = JFactory::getDbo(); + $query = $db->getQuery(true) + ->select('MAX(ordering)') + ->from($db->quoteName('#__getbible_book')); + $db->setQuery($query); + $max = $db->loadResult(); + + $table->ordering = $max + 1; + } + } + else + { + $table->modified = $date->toSql(); + $table->modified_by = $user->id; + } + + if (!empty($table->id)) + { + // Increment the items version number. + $table->version++; + } + } + + /** + * Method to get the data that should be injected in the form. + * + * @return mixed The data for the form. + * + * @since 1.6 + */ + protected function loadFormData() + { + // Check the session for previously entered form data. + $data = JFactory::getApplication()->getUserState('com_getbible.edit.book.data', array()); + + if (empty($data)) + { + $data = $this->getItem(); + // run the perprocess of the data + $this->preprocessData('com_getbible.book', $data); + } + + return $data; + } + + /** + * Method to get the unique fields of this table. + * + * @return mixed An array of field names, boolean false if none is set. + * + * @since 3.0 + */ + protected function getUniqueFields() + { + return false; + } + + /** + * Method to delete one or more records. + * + * @param array &$pks An array of record primary keys. + * + * @return boolean True if successful, false if an error occurs. + * + * @since 12.2 + */ + public function delete(&$pks) + { + if (!parent::delete($pks)) + { + return false; + } + + return true; + } + + /** + * Method to change the published state of one or more records. + * + * @param array &$pks A list of the primary keys to change. + * @param integer $value The value of the published state. + * + * @return boolean True on success. + * + * @since 12.2 + */ + public function publish(&$pks, $value = 1) + { + if (!parent::publish($pks, $value)) + { + return false; + } + + return true; + } + + /** + * Method to perform batch operations on an item or a set of items. + * + * @param array $commands An array of commands to perform. + * @param array $pks An array of item ids. + * @param array $contexts An array of item contexts. + * + * @return boolean Returns true on success, false on failure. + * + * @since 12.2 + */ + public function batch($commands, $pks, $contexts) + { + // Sanitize ids. + $pks = array_unique($pks); + ArrayHelper::toInteger($pks); + + // Remove any values of zero. + if (array_search(0, $pks, true)) + { + unset($pks[array_search(0, $pks, true)]); + } + + if (empty($pks)) + { + $this->setError(JText::_('JGLOBAL_NO_ITEM_SELECTED')); + return false; + } + + $done = false; + + // Set some needed variables. + $this->user = JFactory::getUser(); + $this->table = $this->getTable(); + $this->tableClassName = get_class($this->table); + $this->contentType = new JUcmType; + $this->type = $this->contentType->getTypeByTable($this->tableClassName); + $this->canDo = GetbibleHelper::getActions('book'); + $this->batchSet = true; + + if (!$this->canDo->get('core.batch')) + { + $this->setError(JText::_('JLIB_APPLICATION_ERROR_INSUFFICIENT_BATCH_INFORMATION')); + return false; + } + + if ($this->type == false) + { + $type = new JUcmType; + $this->type = $type->getTypeByAlias($this->typeAlias); + } + + $this->tagsObserver = $this->table->getObserverOfClass('JTableObserverTags'); + + if (!empty($commands['move_copy'])) + { + $cmd = ArrayHelper::getValue($commands, 'move_copy', 'c'); + + if ($cmd == 'c') + { + $result = $this->batchCopy($commands, $pks, $contexts); + + if (is_array($result)) + { + foreach ($result as $old => $new) + { + $contexts[$new] = $contexts[$old]; + } + $pks = array_values($result); + } + else + { + return false; + } + } + elseif ($cmd == 'm' && !$this->batchMove($commands, $pks, $contexts)) + { + return false; + } + + $done = true; + } + + if (!$done) + { + $this->setError(JText::_('JLIB_APPLICATION_ERROR_INSUFFICIENT_BATCH_INFORMATION')); + + return false; + } + + // Clear the cache + $this->cleanCache(); + + return true; + } + + /** + * Batch copy items to a new category or current. + * + * @param integer $values The new values. + * @param array $pks An array of row IDs. + * @param array $contexts An array of item contexts. + * + * @return mixed An array of new IDs on success, boolean false on failure. + * + * @since 12.2 + */ + protected function batchCopy($values, $pks, $contexts) + { + if (empty($this->batchSet)) + { + // Set some needed variables. + $this->user = JFactory::getUser(); + $this->table = $this->getTable(); + $this->tableClassName = get_class($this->table); + $this->canDo = GetbibleHelper::getActions('book'); + } + + if (!$this->canDo->get('book.create') && !$this->canDo->get('book.batch')) + { + return false; + } + + // get list of unique fields + $uniqueFields = $this->getUniqueFields(); + // remove move_copy from array + unset($values['move_copy']); + + // make sure published is set + if (!isset($values['published'])) + { + $values['published'] = 0; + } + elseif (isset($values['published']) && !$this->canDo->get('book.edit.state')) + { + $values['published'] = 0; + } + + $newIds = array(); + // Parent exists so let's proceed + while (!empty($pks)) + { + // Pop the first ID off the stack + $pk = array_shift($pks); + + $this->table->reset(); + + // only allow copy if user may edit this item. + if (!$this->user->authorise('book.edit', $contexts[$pk])) + { + // Not fatal error + $this->setError(JText::sprintf('JLIB_APPLICATION_ERROR_BATCH_MOVE_ROW_NOT_FOUND', $pk)); + continue; + } + + // Check that the row actually exists + if (!$this->table->load($pk)) + { + if ($error = $this->table->getError()) + { + // Fatal error + $this->setError($error); + return false; + } + else + { + // Not fatal error + $this->setError(JText::sprintf('JLIB_APPLICATION_ERROR_BATCH_MOVE_ROW_NOT_FOUND', $pk)); + continue; + } + } + + // Only for strings + if (GetbibleHelper::checkString($this->table->name) && !is_numeric($this->table->name)) + { + $this->table->name = $this->generateUnique('name',$this->table->name); + } + + // insert all set values + if (GetbibleHelper::checkArray($values)) + { + foreach ($values as $key => $value) + { + if (strlen($value) > 0 && isset($this->table->$key)) + { + $this->table->$key = $value; + } + } + } + + // update all unique fields + if (GetbibleHelper::checkArray($uniqueFields)) + { + foreach ($uniqueFields as $uniqueField) + { + $this->table->$uniqueField = $this->generateUnique($uniqueField,$this->table->$uniqueField); + } + } + + // Reset the ID because we are making a copy + $this->table->id = 0; + + // TODO: Deal with ordering? + // $this->table->ordering = 1; + + // Check the row. + if (!$this->table->check()) + { + $this->setError($this->table->getError()); + + return false; + } + + if (!empty($this->type)) + { + $this->createTagsHelper($this->tagsObserver, $this->type, $pk, $this->typeAlias, $this->table); + } + + // Store the row. + if (!$this->table->store()) + { + $this->setError($this->table->getError()); + + return false; + } + + // Get the new item ID + $newId = $this->table->get('id'); + + // Add the new ID to the array + $newIds[$pk] = $newId; + } + + // Clean the cache + $this->cleanCache(); + + return $newIds; + } + + /** + * Batch move items to a new category + * + * @param integer $value The new category ID. + * @param array $pks An array of row IDs. + * @param array $contexts An array of item contexts. + * + * @return boolean True if successful, false otherwise and internal error is set. + * + * @since 12.2 + */ + protected function batchMove($values, $pks, $contexts) + { + if (empty($this->batchSet)) + { + // Set some needed variables. + $this->user = JFactory::getUser(); + $this->table = $this->getTable(); + $this->tableClassName = get_class($this->table); + $this->canDo = GetbibleHelper::getActions('book'); + } + + if (!$this->canDo->get('book.edit') && !$this->canDo->get('book.batch')) + { + $this->setError(JText::_('JLIB_APPLICATION_ERROR_BATCH_CANNOT_EDIT')); + return false; + } + + // make sure published only updates if user has the permission. + if (isset($values['published']) && !$this->canDo->get('book.edit.state')) + { + unset($values['published']); + } + // remove move_copy from array + unset($values['move_copy']); + + // Parent exists so we proceed + foreach ($pks as $pk) + { + if (!$this->user->authorise('book.edit', $contexts[$pk])) + { + $this->setError(JText::_('JLIB_APPLICATION_ERROR_BATCH_CANNOT_EDIT')); + return false; + } + + // Check that the row actually exists + if (!$this->table->load($pk)) + { + if ($error = $this->table->getError()) + { + // Fatal error + $this->setError($error); + return false; + } + else + { + // Not fatal error + $this->setError(JText::sprintf('JLIB_APPLICATION_ERROR_BATCH_MOVE_ROW_NOT_FOUND', $pk)); + continue; + } + } + + // insert all set values. + if (GetbibleHelper::checkArray($values)) + { + foreach ($values as $key => $value) + { + // Do special action for access. + if ('access' === $key && strlen($value) > 0) + { + $this->table->$key = $value; + } + elseif (strlen($value) > 0 && isset($this->table->$key)) + { + $this->table->$key = $value; + } + } + } + + + // Check the row. + if (!$this->table->check()) + { + $this->setError($this->table->getError()); + + return false; + } + + if (!empty($this->type)) + { + $this->createTagsHelper($this->tagsObserver, $this->type, $pk, $this->typeAlias, $this->table); + } + + // Store the row. + if (!$this->table->store()) + { + $this->setError($this->table->getError()); + + return false; + } + } + + // Clean the cache + $this->cleanCache(); + + return true; + } + + /** + * Method to save the form data. + * + * @param array $data The form data. + * + * @return boolean True on success. + * + * @since 1.6 + */ + public function save($data) + { + $input = JFactory::getApplication()->input; + $filter = JFilterInput::getInstance(); + + // set the metadata to the Item Data + if (isset($data['metadata']) && isset($data['metadata']['author'])) + { + $data['metadata']['author'] = $filter->clean($data['metadata']['author'], 'TRIM'); + + $metadata = new JRegistry; + $metadata->loadArray($data['metadata']); + $data['metadata'] = (string) $metadata; + } + + // Set the Params Items to data + if (isset($data['params']) && is_array($data['params'])) + { + $params = new JRegistry; + $params->loadArray($data['params']); + $data['params'] = (string) $params; + } + + // Alter the unique field for save as copy + if ($input->get('task') === 'save2copy') + { + // Automatic handling of other unique fields + $uniqueFields = $this->getUniqueFields(); + if (GetbibleHelper::checkArray($uniqueFields)) + { + foreach ($uniqueFields as $uniqueField) + { + $data[$uniqueField] = $this->generateUnique($uniqueField,$data[$uniqueField]); + } + } + } + + if (parent::save($data)) + { + return true; + } + return false; + } + + /** + * Method to generate a unique value. + * + * @param string $field name. + * @param string $value data. + * + * @return string New value. + * + * @since 3.0 + */ + protected function generateUnique($field,$value) + { + + // set field value unique + $table = $this->getTable(); + + while ($table->load(array($field => $value))) + { + $value = StringHelper::increment($value); + } + + return $value; + } + + /** + * Method to change the title + * + * @param string $title The title. + * + * @return array Contains the modified title and alias. + * + */ + protected function _generateNewTitle($title) + { + + // Alter the title + $table = $this->getTable(); + + while ($table->load(array('title' => $title))) + { + $title = StringHelper::increment($title); + } + + return $title; + } +} diff --git a/admin/models/books.php b/admin/models/books.php new file mode 100644 index 0000000..37069d2 --- /dev/null +++ b/admin/models/books.php @@ -0,0 +1,380 @@ + + @git Get Bible + @github Get Bible + @support Get Bible + @copyright Copyright (C) 2015. All Rights Reserved + @license GNU/GPL Version 2 or later - http://www.gnu.org/licenses/gpl-2.0.html + +/------------------------------------------------------------------------------------------------------*/ + +// No direct access to this file +defined('_JEXEC') or die('Restricted access'); + +use Joomla\CMS\MVC\Model\ListModel; +use Joomla\Utilities\ArrayHelper; + +/** + * Books List Model + */ +class GetbibleModelBooks extends ListModel +{ + public function __construct($config = array()) + { + if (empty($config['filter_fields'])) + { + $config['filter_fields'] = array( + 'a.id','id', + 'a.published','published', + 'a.access','access', + 'a.ordering','ordering', + 'a.created_by','created_by', + 'a.modified_by','modified_by', + 'a.name','name', + 'g.translation','abbreviation', + 'a.nr','nr' + ); + } + + parent::__construct($config); + } + + /** + * Method to auto-populate the model state. + * + * Note. Calling getState in this method will result in recursion. + * + * @param string $ordering An optional ordering field. + * @param string $direction An optional direction (asc|desc). + * + * @return void + * + */ + protected function populateState($ordering = null, $direction = null) + { + $app = JFactory::getApplication(); + + // Adjust the context to support modal layouts. + if ($layout = $app->input->get('layout')) + { + $this->context .= '.' . $layout; + } + + // Check if the form was submitted + $formSubmited = $app->input->post->get('form_submited'); + + $access = $this->getUserStateFromRequest($this->context . '.filter.access', 'filter_access', 0, 'int'); + if ($formSubmited) + { + $access = $app->input->post->get('access'); + $this->setState('filter.access', $access); + } + + $published = $this->getUserStateFromRequest($this->context . '.filter.published', 'filter_published', ''); + $this->setState('filter.published', $published); + + $created_by = $this->getUserStateFromRequest($this->context . '.filter.created_by', 'filter_created_by', ''); + $this->setState('filter.created_by', $created_by); + + $created = $this->getUserStateFromRequest($this->context . '.filter.created', 'filter_created'); + $this->setState('filter.created', $created); + + $sorting = $this->getUserStateFromRequest($this->context . '.filter.sorting', 'filter_sorting', 0, 'int'); + $this->setState('filter.sorting', $sorting); + + $search = $this->getUserStateFromRequest($this->context . '.filter.search', 'filter_search'); + $this->setState('filter.search', $search); + + $name = $this->getUserStateFromRequest($this->context . '.filter.name', 'filter_name'); + if ($formSubmited) + { + $name = $app->input->post->get('name'); + $this->setState('filter.name', $name); + } + + $abbreviation = $this->getUserStateFromRequest($this->context . '.filter.abbreviation', 'filter_abbreviation'); + if ($formSubmited) + { + $abbreviation = $app->input->post->get('abbreviation'); + $this->setState('filter.abbreviation', $abbreviation); + } + + $nr = $this->getUserStateFromRequest($this->context . '.filter.nr', 'filter_nr'); + if ($formSubmited) + { + $nr = $app->input->post->get('nr'); + $this->setState('filter.nr', $nr); + } + + // List state information. + parent::populateState($ordering, $direction); + } + + /** + * Method to get an array of data items. + * + * @return mixed An array of data items on success, false on failure. + */ + public function getItems() + { + // Check in items + $this->checkInNow(); + + // load parent items + $items = parent::getItems(); + + // Set values to display correctly. + if (GetbibleHelper::checkArray($items)) + { + // Get the user object if not set. + if (!isset($user) || !GetbibleHelper::checkObject($user)) + { + $user = JFactory::getUser(); + } + foreach ($items as $nr => &$item) + { + // Remove items the user can't access. + $access = ($user->authorise('book.access', 'com_getbible.book.' . (int) $item->id) && $user->authorise('book.access', 'com_getbible')); + if (!$access) + { + unset($items[$nr]); + continue; + } + + } + } + + // return items + return $items; + } + + /** + * Method to build an SQL query to load the list data. + * + * @return string An SQL query + */ + protected function getListQuery() + { + // Get the user object. + $user = JFactory::getUser(); + // Create a new query object. + $db = JFactory::getDBO(); + $query = $db->getQuery(true); + + // Select some fields + $query->select('a.*'); + + // From the getbible_item table + $query->from($db->quoteName('#__getbible_book', 'a')); + + // From the getbible_translation table. + $query->select($db->quoteName(['g.translation','g.id'],['abbreviation_translation','abbreviation_id'])); + $query->join('LEFT', $db->quoteName('#__getbible_translation', 'g') . ' ON (' . $db->quoteName('a.abbreviation') . ' = ' . $db->quoteName('g.abbreviation') . ')'); + + // Filter by published state + $published = $this->getState('filter.published'); + if (is_numeric($published)) + { + $query->where('a.published = ' . (int) $published); + } + elseif ($published === '') + { + $query->where('(a.published = 0 OR a.published = 1)'); + } + + // Join over the asset groups. + $query->select('ag.title AS access_level'); + $query->join('LEFT', '#__viewlevels AS ag ON ag.id = a.access'); + // Filter by access level. + $_access = $this->getState('filter.access'); + if ($_access && is_numeric($_access)) + { + $query->where('a.access = ' . (int) $_access); + } + elseif (GetbibleHelper::checkArray($_access)) + { + // Secure the array for the query + $_access = ArrayHelper::toInteger($_access); + // Filter by the Access Array. + $query->where('a.access IN (' . implode(',', $_access) . ')'); + } + // Implement View Level Access + if (!$user->authorise('core.options', 'com_getbible')) + { + $groups = implode(',', $user->getAuthorisedViewLevels()); + $query->where('a.access IN (' . $groups . ')'); + } + // Filter by search. + $search = $this->getState('filter.search'); + if (!empty($search)) + { + if (stripos($search, 'id:') === 0) + { + $query->where('a.id = ' . (int) substr($search, 3)); + } + else + { + $search = $db->quote('%' . $db->escape($search) . '%'); + $query->where('(a.name LIKE '.$search.' OR a.abbreviation LIKE '.$search.' OR g.translation LIKE '.$search.' OR a.sha LIKE '.$search.')'); + } + } + + // Filter by Name. + $_name = $this->getState('filter.name'); + if (is_numeric($_name)) + { + if (is_float($_name)) + { + $query->where('a.name = ' . (float) $_name); + } + else + { + $query->where('a.name = ' . (int) $_name); + } + } + elseif (GetbibleHelper::checkString($_name)) + { + $query->where('a.name = ' . $db->quote($db->escape($_name))); + } + // Filter by Abbreviation. + $_abbreviation = $this->getState('filter.abbreviation'); + if (is_numeric($_abbreviation)) + { + if (is_float($_abbreviation)) + { + $query->where('a.abbreviation = ' . (float) $_abbreviation); + } + else + { + $query->where('a.abbreviation = ' . (int) $_abbreviation); + } + } + elseif (GetbibleHelper::checkString($_abbreviation)) + { + $query->where('a.abbreviation = ' . $db->quote($db->escape($_abbreviation))); + } + // Filter by Nr. + $_nr = $this->getState('filter.nr'); + if (is_numeric($_nr)) + { + if (is_float($_nr)) + { + $query->where('a.nr = ' . (float) $_nr); + } + else + { + $query->where('a.nr = ' . (int) $_nr); + } + } + elseif (GetbibleHelper::checkString($_nr)) + { + $query->where('a.nr = ' . $db->quote($db->escape($_nr))); + } + + // Add the list ordering clause. + $orderCol = $this->state->get('list.ordering', 'a.id'); + $orderDirn = $this->state->get('list.direction', 'desc'); + if ($orderCol != '') + { + $query->order($db->escape($orderCol . ' ' . $orderDirn)); + } + + return $query; + } + + /** + * Method to get a store id based on model configuration state. + * + * @return string A store id. + * + */ + protected function getStoreId($id = '') + { + // Compile the store id. + $id .= ':' . $this->getState('filter.id'); + $id .= ':' . $this->getState('filter.search'); + $id .= ':' . $this->getState('filter.published'); + // Check if the value is an array + $_access = $this->getState('filter.access'); + if (GetbibleHelper::checkArray($_access)) + { + $id .= ':' . implode(':', $_access); + } + // Check if this is only an number or string + elseif (is_numeric($_access) + || GetbibleHelper::checkString($_access)) + { + $id .= ':' . $_access; + } + $id .= ':' . $this->getState('filter.ordering'); + $id .= ':' . $this->getState('filter.created_by'); + $id .= ':' . $this->getState('filter.modified_by'); + $id .= ':' . $this->getState('filter.name'); + $id .= ':' . $this->getState('filter.abbreviation'); + $id .= ':' . $this->getState('filter.nr'); + + return parent::getStoreId($id); + } + + /** + * Build an SQL query to checkin all items left checked out longer then a set time. + * + * @return a bool + * + */ + protected function checkInNow() + { + // Get set check in time + $time = JComponentHelper::getParams('com_getbible')->get('check_in'); + + if ($time) + { + + // Get a db connection. + $db = JFactory::getDbo(); + // Reset query. + $query = $db->getQuery(true); + $query->select('*'); + $query->from($db->quoteName('#__getbible_book')); + // Only select items that are checked out. + $query->where($db->quoteName('checked_out') . '!=0'); + $db->setQuery($query, 0, 1); + $db->execute(); + if ($db->getNumRows()) + { + // Get Yesterdays date. + $date = JFactory::getDate()->modify($time)->toSql(); + // Reset query. + $query = $db->getQuery(true); + + // Fields to update. + $fields = array( + $db->quoteName('checked_out_time') . '=\'0000-00-00 00:00:00\'', + $db->quoteName('checked_out') . '=0' + ); + + // Conditions for which records should be updated. + $conditions = array( + $db->quoteName('checked_out') . '!=0', + $db->quoteName('checked_out_time') . '<\''.$date.'\'' + ); + + // Check table. + $query->update($db->quoteName('#__getbible_book'))->set($fields)->where($conditions); + + $db->setQuery($query); + + $db->execute(); + } + } + + return false; + } +} diff --git a/admin/models/chapter.php b/admin/models/chapter.php new file mode 100644 index 0000000..b4b85dc --- /dev/null +++ b/admin/models/chapter.php @@ -0,0 +1,969 @@ + + @git Get Bible + @github Get Bible + @support Get Bible + @copyright Copyright (C) 2015. All Rights Reserved + @license GNU/GPL Version 2 or later - http://www.gnu.org/licenses/gpl-2.0.html + +/------------------------------------------------------------------------------------------------------*/ + +// No direct access to this file +defined('_JEXEC') or die('Restricted access'); + +use Joomla\CMS\MVC\Model\AdminModel; +use Joomla\Registry\Registry; +use Joomla\String\StringHelper; +use Joomla\Utilities\ArrayHelper; + +/** + * Getbible Chapter Admin Model + */ +class GetbibleModelChapter extends AdminModel +{ + /** + * The tab layout fields array. + * + * @var array + */ + protected $tabLayoutFields = array( + 'details' => array( + 'left' => array( + 'abbreviation' + ), + 'right' => array( + 'sha' + ), + 'above' => array( + 'name', + 'chapter', + 'book_nr' + ) + ) + ); + + /** + * @var string The prefix to use with controller messages. + * @since 1.6 + */ + protected $text_prefix = 'COM_GETBIBLE'; + + /** + * The type alias for this content type. + * + * @var string + * @since 3.2 + */ + public $typeAlias = 'com_getbible.chapter'; + + /** + * Returns a Table object, always creating it + * + * @param type $type The table type to instantiate + * @param string $prefix A prefix for the table class name. Optional. + * @param array $config Configuration array for model. Optional. + * + * @return JTable A database object + * + * @since 1.6 + */ + public function getTable($type = 'chapter', $prefix = 'GetbibleTable', $config = array()) + { + // add table path for when model gets used from other component + $this->addTablePath(JPATH_ADMINISTRATOR . '/components/com_getbible/tables'); + // get instance of the table + return JTable::getInstance($type, $prefix, $config); + }###ADMIN_CUSTOM_BUTTONS_METHOD### + + /** + * Method to get a single record. + * + * @param integer $pk The id of the primary key. + * + * @return mixed Object on success, false on failure. + * + * @since 1.6 + */ + public function getItem($pk = null) + { + if ($item = parent::getItem($pk)) + { + if (!empty($item->params) && !is_array($item->params)) + { + // Convert the params field to an array. + $registry = new Registry; + $registry->loadString($item->params); + $item->params = $registry->toArray(); + } + + if (!empty($item->metadata)) + { + // Convert the metadata field to an array. + $registry = new Registry; + $registry->loadString($item->metadata); + $item->metadata = $registry->toArray(); + } + } + + return $item; + } + + /** + * Method to get the record form. + * + * @param array $data Data for the form. + * @param boolean $loadData True if the form is to load its own data (default case), false if not. + * @param array $options Optional array of options for the form creation. + * + * @return mixed A JForm object on success, false on failure + * + * @since 1.6 + */ + public function getForm($data = array(), $loadData = true, $options = array('control' => 'jform')) + { + // set load data option + $options['load_data'] = $loadData; + // check if xpath was set in options + $xpath = false; + if (isset($options['xpath'])) + { + $xpath = $options['xpath']; + unset($options['xpath']); + } + // check if clear form was set in options + $clear = false; + if (isset($options['clear'])) + { + $clear = $options['clear']; + unset($options['clear']); + } + + // Get the form. + $form = $this->loadForm('com_getbible.chapter', 'chapter', $options, $clear, $xpath); + + if (empty($form)) + { + return false; + } + + $jinput = JFactory::getApplication()->input; + + // The front end calls this model and uses a_id to avoid id clashes so we need to check for that first. + if ($jinput->get('a_id')) + { + $id = $jinput->get('a_id', 0, 'INT'); + } + // The back end uses id so we use that the rest of the time and set it to 0 by default. + else + { + $id = $jinput->get('id', 0, 'INT'); + } + + $user = JFactory::getUser(); + + // Check for existing item. + // Modify the form based on Edit State access controls. + if ($id != 0 && (!$user->authorise('chapter.edit.state', 'com_getbible.chapter.' . (int) $id)) + || ($id == 0 && !$user->authorise('chapter.edit.state', 'com_getbible'))) + { + // Disable fields for display. + $form->setFieldAttribute('ordering', 'disabled', 'true'); + $form->setFieldAttribute('published', 'disabled', 'true'); + // Disable fields while saving. + $form->setFieldAttribute('ordering', 'filter', 'unset'); + $form->setFieldAttribute('published', 'filter', 'unset'); + } + // If this is a new item insure the greated by is set. + if (0 == $id) + { + // Set the created_by to this user + $form->setValue('created_by', null, $user->id); + } + // Modify the form based on Edit Creaded By access controls. + if ($id != 0 && (!$user->authorise('chapter.edit.created_by', 'com_getbible.chapter.' . (int) $id)) + || ($id == 0 && !$user->authorise('chapter.edit.created_by', 'com_getbible'))) + { + // Disable fields for display. + $form->setFieldAttribute('created_by', 'disabled', 'true'); + // Disable fields for display. + $form->setFieldAttribute('created_by', 'readonly', 'true'); + // Disable fields while saving. + $form->setFieldAttribute('created_by', 'filter', 'unset'); + } + // Modify the form based on Edit Creaded Date access controls. + if ($id != 0 && (!$user->authorise('chapter.edit.created', 'com_getbible.chapter.' . (int) $id)) + || ($id == 0 && !$user->authorise('chapter.edit.created', 'com_getbible'))) + { + // Disable fields for display. + $form->setFieldAttribute('created', 'disabled', 'true'); + // Disable fields while saving. + $form->setFieldAttribute('created', 'filter', 'unset'); + } + // Modify the form based on Edit Name access controls. + if ($id != 0 && (!$user->authorise('chapter.edit.name', 'com_getbible.chapter.' . (int) $id)) + || ($id == 0 && !$user->authorise('chapter.edit.name', 'com_getbible'))) + { + // Disable fields for display. + $form->setFieldAttribute('name', 'disabled', 'true'); + // Disable fields for display. + $form->setFieldAttribute('name', 'readonly', 'true'); + // If there is no value continue. + if (!$form->getValue('name')) + { + // Disable fields while saving. + $form->setFieldAttribute('name', 'filter', 'unset'); + // Disable fields while saving. + $form->setFieldAttribute('name', 'required', 'false'); + } + } + // Modify the form based on Edit Chapter access controls. + if ($id != 0 && (!$user->authorise('chapter.edit.chapter', 'com_getbible.chapter.' . (int) $id)) + || ($id == 0 && !$user->authorise('chapter.edit.chapter', 'com_getbible'))) + { + // Disable fields for display. + $form->setFieldAttribute('chapter', 'disabled', 'true'); + // Disable fields for display. + $form->setFieldAttribute('chapter', 'readonly', 'true'); + // If there is no value continue. + if (!$form->getValue('chapter')) + { + // Disable fields while saving. + $form->setFieldAttribute('chapter', 'filter', 'unset'); + // Disable fields while saving. + $form->setFieldAttribute('chapter', 'required', 'false'); + } + } + // Modify the form based on Edit Book Nr access controls. + if ($id != 0 && (!$user->authorise('chapter.edit.book_nr', 'com_getbible.chapter.' . (int) $id)) + || ($id == 0 && !$user->authorise('chapter.edit.book_nr', 'com_getbible'))) + { + // Disable fields for display. + $form->setFieldAttribute('book_nr', 'disabled', 'true'); + // Disable fields for display. + $form->setFieldAttribute('book_nr', 'readonly', 'true'); + // If there is no value continue. + if (!$form->getValue('book_nr')) + { + // Disable fields while saving. + $form->setFieldAttribute('book_nr', 'filter', 'unset'); + // Disable fields while saving. + $form->setFieldAttribute('book_nr', 'required', 'false'); + } + } + // Modify the form based on Edit Abbreviation access controls. + if ($id != 0 && (!$user->authorise('chapter.edit.abbreviation', 'com_getbible.chapter.' . (int) $id)) + || ($id == 0 && !$user->authorise('chapter.edit.abbreviation', 'com_getbible'))) + { + // Disable fields for display. + $form->setFieldAttribute('abbreviation', 'disabled', 'true'); + // Disable fields for display. + $form->setFieldAttribute('abbreviation', 'readonly', 'true'); + // If there is no value continue. + if (!$form->getValue('abbreviation')) + { + // Disable fields while saving. + $form->setFieldAttribute('abbreviation', 'filter', 'unset'); + // Disable fields while saving. + $form->setFieldAttribute('abbreviation', 'required', 'false'); + } + } + // Modify the form based on Edit Sha access controls. + if ($id != 0 && (!$user->authorise('chapter.edit.sha', 'com_getbible.chapter.' . (int) $id)) + || ($id == 0 && !$user->authorise('chapter.edit.sha', 'com_getbible'))) + { + // Disable fields for display. + $form->setFieldAttribute('sha', 'disabled', 'true'); + // Disable fields for display. + $form->setFieldAttribute('sha', 'readonly', 'true'); + // If there is no value continue. + if (!$form->getValue('sha')) + { + // Disable fields while saving. + $form->setFieldAttribute('sha', 'filter', 'unset'); + // Disable fields while saving. + $form->setFieldAttribute('sha', 'required', 'false'); + } + } + // Only load these values if no id is found + if (0 == $id) + { + // Set redirected view name + $redirectedView = $jinput->get('ref', null, 'STRING'); + // Set field name (or fall back to view name) + $redirectedField = $jinput->get('field', $redirectedView, 'STRING'); + // Set redirected view id + $redirectedId = $jinput->get('refid', 0, 'INT'); + // Set field id (or fall back to redirected view id) + $redirectedValue = $jinput->get('field_id', $redirectedId, 'INT'); + if (0 != $redirectedValue && $redirectedField) + { + // Now set the local-redirected field default value + $form->setValue($redirectedField, null, $redirectedValue); + } + } + return $form; + } + + /** + * Method to get the script that have to be included on the form + * + * @return string script files + */ + public function getScript() + { + return 'media/com_getbible/js/chapter.js'; + } + + /** + * Method to test whether a record can be deleted. + * + * @param object $record A record object. + * + * @return boolean True if allowed to delete the record. Defaults to the permission set in the component. + * + * @since 1.6 + */ + protected function canDelete($record) + { + if (!empty($record->id)) + { + if ($record->published != -2) + { + return; + } + + $user = JFactory::getUser(); + // The record has been set. Check the record permissions. + return $user->authorise('chapter.delete', 'com_getbible.chapter.' . (int) $record->id); + } + return false; + } + + /** + * Method to test whether a record can have its state edited. + * + * @param object $record A record object. + * + * @return boolean True if allowed to change the state of the record. Defaults to the permission set in the component. + * + * @since 1.6 + */ + protected function canEditState($record) + { + $user = JFactory::getUser(); + $recordId = (!empty($record->id)) ? $record->id : 0; + + if ($recordId) + { + // The record has been set. Check the record permissions. + $permission = $user->authorise('chapter.edit.state', 'com_getbible.chapter.' . (int) $recordId); + if (!$permission && !is_null($permission)) + { + return false; + } + } + // In the absense of better information, revert to the component permissions. + return $user->authorise('chapter.edit.state', 'com_getbible'); + } + + /** + * Method override to check if you can edit an existing record. + * + * @param array $data An array of input data. + * @param string $key The name of the key for the primary key. + * + * @return boolean + * @since 2.5 + */ + protected function allowEdit($data = array(), $key = 'id') + { + // Check specific edit permission then general edit permission. + $user = JFactory::getUser(); + + return $user->authorise('chapter.edit', 'com_getbible.chapter.'. ((int) isset($data[$key]) ? $data[$key] : 0)) or $user->authorise('chapter.edit', 'com_getbible'); + } + + /** + * Prepare and sanitise the table data prior to saving. + * + * @param JTable $table A JTable object. + * + * @return void + * + * @since 1.6 + */ + protected function prepareTable($table) + { + $date = JFactory::getDate(); + $user = JFactory::getUser(); + + if (isset($table->name)) + { + $table->name = htmlspecialchars_decode($table->name, ENT_QUOTES); + } + + if (isset($table->alias) && empty($table->alias)) + { + $table->generateAlias(); + } + + if (empty($table->id)) + { + $table->created = $date->toSql(); + // set the user + if ($table->created_by == 0 || empty($table->created_by)) + { + $table->created_by = $user->id; + } + // Set ordering to the last item if not set + if (empty($table->ordering)) + { + $db = JFactory::getDbo(); + $query = $db->getQuery(true) + ->select('MAX(ordering)') + ->from($db->quoteName('#__getbible_chapter')); + $db->setQuery($query); + $max = $db->loadResult(); + + $table->ordering = $max + 1; + } + } + else + { + $table->modified = $date->toSql(); + $table->modified_by = $user->id; + } + + if (!empty($table->id)) + { + // Increment the items version number. + $table->version++; + } + } + + /** + * Method to get the data that should be injected in the form. + * + * @return mixed The data for the form. + * + * @since 1.6 + */ + protected function loadFormData() + { + // Check the session for previously entered form data. + $data = JFactory::getApplication()->getUserState('com_getbible.edit.chapter.data', array()); + + if (empty($data)) + { + $data = $this->getItem(); + // run the perprocess of the data + $this->preprocessData('com_getbible.chapter', $data); + } + + return $data; + } + + /** + * Method to get the unique fields of this table. + * + * @return mixed An array of field names, boolean false if none is set. + * + * @since 3.0 + */ + protected function getUniqueFields() + { + return false; + } + + /** + * Method to delete one or more records. + * + * @param array &$pks An array of record primary keys. + * + * @return boolean True if successful, false if an error occurs. + * + * @since 12.2 + */ + public function delete(&$pks) + { + if (!parent::delete($pks)) + { + return false; + } + + return true; + } + + /** + * Method to change the published state of one or more records. + * + * @param array &$pks A list of the primary keys to change. + * @param integer $value The value of the published state. + * + * @return boolean True on success. + * + * @since 12.2 + */ + public function publish(&$pks, $value = 1) + { + if (!parent::publish($pks, $value)) + { + return false; + } + + return true; + } + + /** + * Method to perform batch operations on an item or a set of items. + * + * @param array $commands An array of commands to perform. + * @param array $pks An array of item ids. + * @param array $contexts An array of item contexts. + * + * @return boolean Returns true on success, false on failure. + * + * @since 12.2 + */ + public function batch($commands, $pks, $contexts) + { + // Sanitize ids. + $pks = array_unique($pks); + ArrayHelper::toInteger($pks); + + // Remove any values of zero. + if (array_search(0, $pks, true)) + { + unset($pks[array_search(0, $pks, true)]); + } + + if (empty($pks)) + { + $this->setError(JText::_('JGLOBAL_NO_ITEM_SELECTED')); + return false; + } + + $done = false; + + // Set some needed variables. + $this->user = JFactory::getUser(); + $this->table = $this->getTable(); + $this->tableClassName = get_class($this->table); + $this->contentType = new JUcmType; + $this->type = $this->contentType->getTypeByTable($this->tableClassName); + $this->canDo = GetbibleHelper::getActions('chapter'); + $this->batchSet = true; + + if (!$this->canDo->get('core.batch')) + { + $this->setError(JText::_('JLIB_APPLICATION_ERROR_INSUFFICIENT_BATCH_INFORMATION')); + return false; + } + + if ($this->type == false) + { + $type = new JUcmType; + $this->type = $type->getTypeByAlias($this->typeAlias); + } + + $this->tagsObserver = $this->table->getObserverOfClass('JTableObserverTags'); + + if (!empty($commands['move_copy'])) + { + $cmd = ArrayHelper::getValue($commands, 'move_copy', 'c'); + + if ($cmd == 'c') + { + $result = $this->batchCopy($commands, $pks, $contexts); + + if (is_array($result)) + { + foreach ($result as $old => $new) + { + $contexts[$new] = $contexts[$old]; + } + $pks = array_values($result); + } + else + { + return false; + } + } + elseif ($cmd == 'm' && !$this->batchMove($commands, $pks, $contexts)) + { + return false; + } + + $done = true; + } + + if (!$done) + { + $this->setError(JText::_('JLIB_APPLICATION_ERROR_INSUFFICIENT_BATCH_INFORMATION')); + + return false; + } + + // Clear the cache + $this->cleanCache(); + + return true; + } + + /** + * Batch copy items to a new category or current. + * + * @param integer $values The new values. + * @param array $pks An array of row IDs. + * @param array $contexts An array of item contexts. + * + * @return mixed An array of new IDs on success, boolean false on failure. + * + * @since 12.2 + */ + protected function batchCopy($values, $pks, $contexts) + { + if (empty($this->batchSet)) + { + // Set some needed variables. + $this->user = JFactory::getUser(); + $this->table = $this->getTable(); + $this->tableClassName = get_class($this->table); + $this->canDo = GetbibleHelper::getActions('chapter'); + } + + if (!$this->canDo->get('chapter.create') && !$this->canDo->get('chapter.batch')) + { + return false; + } + + // get list of unique fields + $uniqueFields = $this->getUniqueFields(); + // remove move_copy from array + unset($values['move_copy']); + + // make sure published is set + if (!isset($values['published'])) + { + $values['published'] = 0; + } + elseif (isset($values['published']) && !$this->canDo->get('chapter.edit.state')) + { + $values['published'] = 0; + } + + $newIds = array(); + // Parent exists so let's proceed + while (!empty($pks)) + { + // Pop the first ID off the stack + $pk = array_shift($pks); + + $this->table->reset(); + + // only allow copy if user may edit this item. + if (!$this->user->authorise('chapter.edit', $contexts[$pk])) + { + // Not fatal error + $this->setError(JText::sprintf('JLIB_APPLICATION_ERROR_BATCH_MOVE_ROW_NOT_FOUND', $pk)); + continue; + } + + // Check that the row actually exists + if (!$this->table->load($pk)) + { + if ($error = $this->table->getError()) + { + // Fatal error + $this->setError($error); + return false; + } + else + { + // Not fatal error + $this->setError(JText::sprintf('JLIB_APPLICATION_ERROR_BATCH_MOVE_ROW_NOT_FOUND', $pk)); + continue; + } + } + + // Only for strings + if (GetbibleHelper::checkString($this->table->name) && !is_numeric($this->table->name)) + { + $this->table->name = $this->generateUnique('name',$this->table->name); + } + + // insert all set values + if (GetbibleHelper::checkArray($values)) + { + foreach ($values as $key => $value) + { + if (strlen($value) > 0 && isset($this->table->$key)) + { + $this->table->$key = $value; + } + } + } + + // update all unique fields + if (GetbibleHelper::checkArray($uniqueFields)) + { + foreach ($uniqueFields as $uniqueField) + { + $this->table->$uniqueField = $this->generateUnique($uniqueField,$this->table->$uniqueField); + } + } + + // Reset the ID because we are making a copy + $this->table->id = 0; + + // TODO: Deal with ordering? + // $this->table->ordering = 1; + + // Check the row. + if (!$this->table->check()) + { + $this->setError($this->table->getError()); + + return false; + } + + if (!empty($this->type)) + { + $this->createTagsHelper($this->tagsObserver, $this->type, $pk, $this->typeAlias, $this->table); + } + + // Store the row. + if (!$this->table->store()) + { + $this->setError($this->table->getError()); + + return false; + } + + // Get the new item ID + $newId = $this->table->get('id'); + + // Add the new ID to the array + $newIds[$pk] = $newId; + } + + // Clean the cache + $this->cleanCache(); + + return $newIds; + } + + /** + * Batch move items to a new category + * + * @param integer $value The new category ID. + * @param array $pks An array of row IDs. + * @param array $contexts An array of item contexts. + * + * @return boolean True if successful, false otherwise and internal error is set. + * + * @since 12.2 + */ + protected function batchMove($values, $pks, $contexts) + { + if (empty($this->batchSet)) + { + // Set some needed variables. + $this->user = JFactory::getUser(); + $this->table = $this->getTable(); + $this->tableClassName = get_class($this->table); + $this->canDo = GetbibleHelper::getActions('chapter'); + } + + if (!$this->canDo->get('chapter.edit') && !$this->canDo->get('chapter.batch')) + { + $this->setError(JText::_('JLIB_APPLICATION_ERROR_BATCH_CANNOT_EDIT')); + return false; + } + + // make sure published only updates if user has the permission. + if (isset($values['published']) && !$this->canDo->get('chapter.edit.state')) + { + unset($values['published']); + } + // remove move_copy from array + unset($values['move_copy']); + + // Parent exists so we proceed + foreach ($pks as $pk) + { + if (!$this->user->authorise('chapter.edit', $contexts[$pk])) + { + $this->setError(JText::_('JLIB_APPLICATION_ERROR_BATCH_CANNOT_EDIT')); + return false; + } + + // Check that the row actually exists + if (!$this->table->load($pk)) + { + if ($error = $this->table->getError()) + { + // Fatal error + $this->setError($error); + return false; + } + else + { + // Not fatal error + $this->setError(JText::sprintf('JLIB_APPLICATION_ERROR_BATCH_MOVE_ROW_NOT_FOUND', $pk)); + continue; + } + } + + // insert all set values. + if (GetbibleHelper::checkArray($values)) + { + foreach ($values as $key => $value) + { + // Do special action for access. + if ('access' === $key && strlen($value) > 0) + { + $this->table->$key = $value; + } + elseif (strlen($value) > 0 && isset($this->table->$key)) + { + $this->table->$key = $value; + } + } + } + + + // Check the row. + if (!$this->table->check()) + { + $this->setError($this->table->getError()); + + return false; + } + + if (!empty($this->type)) + { + $this->createTagsHelper($this->tagsObserver, $this->type, $pk, $this->typeAlias, $this->table); + } + + // Store the row. + if (!$this->table->store()) + { + $this->setError($this->table->getError()); + + return false; + } + } + + // Clean the cache + $this->cleanCache(); + + return true; + } + + /** + * Method to save the form data. + * + * @param array $data The form data. + * + * @return boolean True on success. + * + * @since 1.6 + */ + public function save($data) + { + $input = JFactory::getApplication()->input; + $filter = JFilterInput::getInstance(); + + // set the metadata to the Item Data + if (isset($data['metadata']) && isset($data['metadata']['author'])) + { + $data['metadata']['author'] = $filter->clean($data['metadata']['author'], 'TRIM'); + + $metadata = new JRegistry; + $metadata->loadArray($data['metadata']); + $data['metadata'] = (string) $metadata; + } + + // Set the Params Items to data + if (isset($data['params']) && is_array($data['params'])) + { + $params = new JRegistry; + $params->loadArray($data['params']); + $data['params'] = (string) $params; + } + + // Alter the unique field for save as copy + if ($input->get('task') === 'save2copy') + { + // Automatic handling of other unique fields + $uniqueFields = $this->getUniqueFields(); + if (GetbibleHelper::checkArray($uniqueFields)) + { + foreach ($uniqueFields as $uniqueField) + { + $data[$uniqueField] = $this->generateUnique($uniqueField,$data[$uniqueField]); + } + } + } + + if (parent::save($data)) + { + return true; + } + return false; + } + + /** + * Method to generate a unique value. + * + * @param string $field name. + * @param string $value data. + * + * @return string New value. + * + * @since 3.0 + */ + protected function generateUnique($field,$value) + { + + // set field value unique + $table = $this->getTable(); + + while ($table->load(array($field => $value))) + { + $value = StringHelper::increment($value); + } + + return $value; + } + + /** + * Method to change the title + * + * @param string $title The title. + * + * @return array Contains the modified title and alias. + * + */ + protected function _generateNewTitle($title) + { + + // Alter the title + $table = $this->getTable(); + + while ($table->load(array('title' => $title))) + { + $title = StringHelper::increment($title); + } + + return $title; + } +} diff --git a/admin/models/chapters.php b/admin/models/chapters.php new file mode 100644 index 0000000..440faff --- /dev/null +++ b/admin/models/chapters.php @@ -0,0 +1,457 @@ + + @git Get Bible + @github Get Bible + @support Get Bible + @copyright Copyright (C) 2015. All Rights Reserved + @license GNU/GPL Version 2 or later - http://www.gnu.org/licenses/gpl-2.0.html + +/------------------------------------------------------------------------------------------------------*/ + +// No direct access to this file +defined('_JEXEC') or die('Restricted access'); + +use Joomla\CMS\MVC\Model\ListModel; +use Joomla\Utilities\ArrayHelper; + +/** + * Chapters List Model + */ +class GetbibleModelChapters extends ListModel +{ + public function __construct($config = array()) + { + if (empty($config['filter_fields'])) + { + $config['filter_fields'] = array( + 'a.id','id', + 'a.published','published', + 'a.access','access', + 'a.ordering','ordering', + 'a.created_by','created_by', + 'a.modified_by','modified_by', + 'a.chapter','chapter', + 'a.book_nr','book_nr', + 'g.translation','abbreviation', + 'a.name','name' + ); + } + + parent::__construct($config); + } + + /** + * Method to auto-populate the model state. + * + * Note. Calling getState in this method will result in recursion. + * + * @param string $ordering An optional ordering field. + * @param string $direction An optional direction (asc|desc). + * + * @return void + * + */ + protected function populateState($ordering = null, $direction = null) + { + $app = JFactory::getApplication(); + + // Adjust the context to support modal layouts. + if ($layout = $app->input->get('layout')) + { + $this->context .= '.' . $layout; + } + + // Check if the form was submitted + $formSubmited = $app->input->post->get('form_submited'); + + $access = $this->getUserStateFromRequest($this->context . '.filter.access', 'filter_access', 0, 'int'); + if ($formSubmited) + { + $access = $app->input->post->get('access'); + $this->setState('filter.access', $access); + } + + $published = $this->getUserStateFromRequest($this->context . '.filter.published', 'filter_published', ''); + $this->setState('filter.published', $published); + + $created_by = $this->getUserStateFromRequest($this->context . '.filter.created_by', 'filter_created_by', ''); + $this->setState('filter.created_by', $created_by); + + $created = $this->getUserStateFromRequest($this->context . '.filter.created', 'filter_created'); + $this->setState('filter.created', $created); + + $sorting = $this->getUserStateFromRequest($this->context . '.filter.sorting', 'filter_sorting', 0, 'int'); + $this->setState('filter.sorting', $sorting); + + $search = $this->getUserStateFromRequest($this->context . '.filter.search', 'filter_search'); + $this->setState('filter.search', $search); + + $chapter = $this->getUserStateFromRequest($this->context . '.filter.chapter', 'filter_chapter'); + if ($formSubmited) + { + $chapter = $app->input->post->get('chapter'); + $this->setState('filter.chapter', $chapter); + } + + $book_nr = $this->getUserStateFromRequest($this->context . '.filter.book_nr', 'filter_book_nr'); + if ($formSubmited) + { + $book_nr = $app->input->post->get('book_nr'); + $this->setState('filter.book_nr', $book_nr); + } + + $abbreviation = $this->getUserStateFromRequest($this->context . '.filter.abbreviation', 'filter_abbreviation'); + if ($formSubmited) + { + $abbreviation = $app->input->post->get('abbreviation'); + $this->setState('filter.abbreviation', $abbreviation); + } + + $name = $this->getUserStateFromRequest($this->context . '.filter.name', 'filter_name'); + if ($formSubmited) + { + $name = $app->input->post->get('name'); + $this->setState('filter.name', $name); + } + + // List state information. + parent::populateState($ordering, $direction); + } + + /** + * Method to get an array of data items. + * + * @return mixed An array of data items on success, false on failure. + */ + public function getItems() + { + // Check in items + $this->checkInNow(); + + // load parent items + $items = parent::getItems(); + + // Set values to display correctly. + if (GetbibleHelper::checkArray($items)) + { + // Get the user object if not set. + if (!isset($user) || !GetbibleHelper::checkObject($user)) + { + $user = JFactory::getUser(); + } + foreach ($items as $nr => &$item) + { + // Remove items the user can't access. + $access = ($user->authorise('chapter.access', 'com_getbible.chapter.' . (int) $item->id) && $user->authorise('chapter.access', 'com_getbible')); + if (!$access) + { + unset($items[$nr]); + continue; + } + + } + } + + // return items + return $items; + } + + /** + * Method to build an SQL query to load the list data. + * + * @return string An SQL query + */ + protected function getListQuery() + { + // Get the user object. + $user = JFactory::getUser(); + // Create a new query object. + $db = JFactory::getDBO(); + $query = $db->getQuery(true); + + // Select some fields + $query->select('a.*'); + + // From the getbible_item table + $query->from($db->quoteName('#__getbible_chapter', 'a')); + + // From the getbible_translation table. + $query->select($db->quoteName(['g.translation','g.id'],['abbreviation_translation','abbreviation_id'])); + $query->join('LEFT', $db->quoteName('#__getbible_translation', 'g') . ' ON (' . $db->quoteName('a.abbreviation') . ' = ' . $db->quoteName('g.abbreviation') . ')'); + + // Filter by published state + $published = $this->getState('filter.published'); + if (is_numeric($published)) + { + $query->where('a.published = ' . (int) $published); + } + elseif ($published === '') + { + $query->where('(a.published = 0 OR a.published = 1)'); + } + + // Join over the asset groups. + $query->select('ag.title AS access_level'); + $query->join('LEFT', '#__viewlevels AS ag ON ag.id = a.access'); + // Filter by access level. + $_access = $this->getState('filter.access'); + if ($_access && is_numeric($_access)) + { + $query->where('a.access = ' . (int) $_access); + } + elseif (GetbibleHelper::checkArray($_access)) + { + // Secure the array for the query + $_access = ArrayHelper::toInteger($_access); + // Filter by the Access Array. + $query->where('a.access IN (' . implode(',', $_access) . ')'); + } + // Implement View Level Access + if (!$user->authorise('core.options', 'com_getbible')) + { + $groups = implode(',', $user->getAuthorisedViewLevels()); + $query->where('a.access IN (' . $groups . ')'); + } + // Filter by search. + $search = $this->getState('filter.search'); + if (!empty($search)) + { + if (stripos($search, 'id:') === 0) + { + $query->where('a.id = ' . (int) substr($search, 3)); + } + else + { + $search = $db->quote('%' . $db->escape($search) . '%'); + $query->where('(a.name LIKE '.$search.' OR a.chapter LIKE '.$search.' OR a.abbreviation LIKE '.$search.' OR g.translation LIKE '.$search.' OR a.sha LIKE '.$search.')'); + } + } + + // Filter by Chapter. + $_chapter = $this->getState('filter.chapter'); + if (is_numeric($_chapter)) + { + if (is_float($_chapter)) + { + $query->where('a.chapter = ' . (float) $_chapter); + } + else + { + $query->where('a.chapter = ' . (int) $_chapter); + } + } + elseif (GetbibleHelper::checkString($_chapter)) + { + $query->where('a.chapter = ' . $db->quote($db->escape($_chapter))); + } + elseif (GetbibleHelper::checkArray($_chapter)) + { + // Secure the array for the query + $_chapter = array_map( function ($val) use(&$db) { + if (is_numeric($val)) + { + if (is_float($val)) + { + return (float) $val; + } + else + { + return (int) $val; + } + } + elseif (GetbibleHelper::checkString($val)) + { + return $db->quote($db->escape($val)); + } + }, $_chapter); + // Filter by the Chapter Array. + $query->where('a.chapter IN (' . implode(',', $_chapter) . ')'); + } + // Filter by Book_nr. + $_book_nr = $this->getState('filter.book_nr'); + if (is_numeric($_book_nr)) + { + if (is_float($_book_nr)) + { + $query->where('a.book_nr = ' . (float) $_book_nr); + } + else + { + $query->where('a.book_nr = ' . (int) $_book_nr); + } + } + elseif (GetbibleHelper::checkString($_book_nr)) + { + $query->where('a.book_nr = ' . $db->quote($db->escape($_book_nr))); + } + elseif (GetbibleHelper::checkArray($_book_nr)) + { + // Secure the array for the query + $_book_nr = array_map( function ($val) use(&$db) { + if (is_numeric($val)) + { + if (is_float($val)) + { + return (float) $val; + } + else + { + return (int) $val; + } + } + elseif (GetbibleHelper::checkString($val)) + { + return $db->quote($db->escape($val)); + } + }, $_book_nr); + // Filter by the Book_nr Array. + $query->where('a.book_nr IN (' . implode(',', $_book_nr) . ')'); + } + // Filter by Abbreviation. + $_abbreviation = $this->getState('filter.abbreviation'); + if (is_numeric($_abbreviation)) + { + if (is_float($_abbreviation)) + { + $query->where('a.abbreviation = ' . (float) $_abbreviation); + } + else + { + $query->where('a.abbreviation = ' . (int) $_abbreviation); + } + } + elseif (GetbibleHelper::checkString($_abbreviation)) + { + $query->where('a.abbreviation = ' . $db->quote($db->escape($_abbreviation))); + } + + // Add the list ordering clause. + $orderCol = $this->state->get('list.ordering', 'a.id'); + $orderDirn = $this->state->get('list.direction', 'desc'); + if ($orderCol != '') + { + $query->order($db->escape($orderCol . ' ' . $orderDirn)); + } + + return $query; + } + + /** + * Method to get a store id based on model configuration state. + * + * @return string A store id. + * + */ + protected function getStoreId($id = '') + { + // Compile the store id. + $id .= ':' . $this->getState('filter.id'); + $id .= ':' . $this->getState('filter.search'); + $id .= ':' . $this->getState('filter.published'); + // Check if the value is an array + $_access = $this->getState('filter.access'); + if (GetbibleHelper::checkArray($_access)) + { + $id .= ':' . implode(':', $_access); + } + // Check if this is only an number or string + elseif (is_numeric($_access) + || GetbibleHelper::checkString($_access)) + { + $id .= ':' . $_access; + } + $id .= ':' . $this->getState('filter.ordering'); + $id .= ':' . $this->getState('filter.created_by'); + $id .= ':' . $this->getState('filter.modified_by'); + // Check if the value is an array + $_chapter = $this->getState('filter.chapter'); + if (GetbibleHelper::checkArray($_chapter)) + { + $id .= ':' . implode(':', $_chapter); + } + // Check if this is only an number or string + elseif (is_numeric($_chapter) + || GetbibleHelper::checkString($_chapter)) + { + $id .= ':' . $_chapter; + } + // Check if the value is an array + $_book_nr = $this->getState('filter.book_nr'); + if (GetbibleHelper::checkArray($_book_nr)) + { + $id .= ':' . implode(':', $_book_nr); + } + // Check if this is only an number or string + elseif (is_numeric($_book_nr) + || GetbibleHelper::checkString($_book_nr)) + { + $id .= ':' . $_book_nr; + } + $id .= ':' . $this->getState('filter.abbreviation'); + $id .= ':' . $this->getState('filter.name'); + + return parent::getStoreId($id); + } + + /** + * Build an SQL query to checkin all items left checked out longer then a set time. + * + * @return a bool + * + */ + protected function checkInNow() + { + // Get set check in time + $time = JComponentHelper::getParams('com_getbible')->get('check_in'); + + if ($time) + { + + // Get a db connection. + $db = JFactory::getDbo(); + // Reset query. + $query = $db->getQuery(true); + $query->select('*'); + $query->from($db->quoteName('#__getbible_chapter')); + // Only select items that are checked out. + $query->where($db->quoteName('checked_out') . '!=0'); + $db->setQuery($query, 0, 1); + $db->execute(); + if ($db->getNumRows()) + { + // Get Yesterdays date. + $date = JFactory::getDate()->modify($time)->toSql(); + // Reset query. + $query = $db->getQuery(true); + + // Fields to update. + $fields = array( + $db->quoteName('checked_out_time') . '=\'0000-00-00 00:00:00\'', + $db->quoteName('checked_out') . '=0' + ); + + // Conditions for which records should be updated. + $conditions = array( + $db->quoteName('checked_out') . '!=0', + $db->quoteName('checked_out_time') . '<\''.$date.'\'' + ); + + // Check table. + $query->update($db->quoteName('#__getbible_chapter'))->set($fields)->where($conditions); + + $db->setQuery($query); + + $db->execute(); + } + } + + return false; + } +} diff --git a/admin/models/fields/booksfiltername.php b/admin/models/fields/booksfiltername.php new file mode 100644 index 0000000..3684864 --- /dev/null +++ b/admin/models/fields/booksfiltername.php @@ -0,0 +1,73 @@ + + @git Get Bible + @github Get Bible + @support Get Bible + @copyright Copyright (C) 2015. All Rights Reserved + @license GNU/GPL Version 2 or later - http://www.gnu.org/licenses/gpl-2.0.html + +/------------------------------------------------------------------------------------------------------*/ + +// No direct access to this file +defined('_JEXEC') or die('Restricted access'); + +// import the list field type +jimport('joomla.form.helper'); +JFormHelper::loadFieldClass('list'); + +/** + * Booksfiltername Form Field class for the Getbible component + */ +class JFormFieldBooksfiltername extends JFormFieldList +{ + /** + * The booksfiltername field type. + * + * @var string + */ + public $type = 'booksfiltername'; + + /** + * Method to get a list of options for a list input. + * + * @return array An array of JHtml options. + */ + protected function getOptions() + { + // Get a db connection. + $db = JFactory::getDbo(); + + // Create a new query object. + $query = $db->getQuery(true); + + // Select the text. + $query->select($db->quoteName('name')); + $query->from($db->quoteName('#__getbible_book')); + $query->order($db->quoteName('name') . ' ASC'); + + // Reset the query using our newly populated query object. + $db->setQuery($query); + + $_results = $db->loadColumn(); + $_filter = array(); + $_filter[] = JHtml::_('select.option', '', '- ' . JText::_('COM_GETBIBLE_FILTER_SELECT_NAME') . ' -'); + + if ($_results) + { + $_results = array_unique($_results); + foreach ($_results as $name) + { + // Now add the name and its text to the options array + $_filter[] = JHtml::_('select.option', $name, $name); + } + } + return $_filter; + } +} diff --git a/admin/models/fields/booksfilternr.php b/admin/models/fields/booksfilternr.php new file mode 100644 index 0000000..4276585 --- /dev/null +++ b/admin/models/fields/booksfilternr.php @@ -0,0 +1,73 @@ + + @git Get Bible + @github Get Bible + @support Get Bible + @copyright Copyright (C) 2015. All Rights Reserved + @license GNU/GPL Version 2 or later - http://www.gnu.org/licenses/gpl-2.0.html + +/------------------------------------------------------------------------------------------------------*/ + +// No direct access to this file +defined('_JEXEC') or die('Restricted access'); + +// import the list field type +jimport('joomla.form.helper'); +JFormHelper::loadFieldClass('list'); + +/** + * Booksfilternr Form Field class for the Getbible component + */ +class JFormFieldBooksfilternr extends JFormFieldList +{ + /** + * The booksfilternr field type. + * + * @var string + */ + public $type = 'booksfilternr'; + + /** + * Method to get a list of options for a list input. + * + * @return array An array of JHtml options. + */ + protected function getOptions() + { + // Get a db connection. + $db = JFactory::getDbo(); + + // Create a new query object. + $query = $db->getQuery(true); + + // Select the text. + $query->select($db->quoteName('nr')); + $query->from($db->quoteName('#__getbible_book')); + $query->order($db->quoteName('nr') . ' ASC'); + + // Reset the query using our newly populated query object. + $db->setQuery($query); + + $_results = $db->loadColumn(); + $_filter = array(); + $_filter[] = JHtml::_('select.option', '', '- ' . JText::_('COM_GETBIBLE_FILTER_SELECT_NUMBER') . ' -'); + + if ($_results) + { + $_results = array_unique($_results); + foreach ($_results as $nr) + { + // Now add the nr and its text to the options array + $_filter[] = JHtml::_('select.option', $nr, $nr); + } + } + return $_filter; + } +} diff --git a/admin/models/fields/chaptersfilterbooknr.php b/admin/models/fields/chaptersfilterbooknr.php new file mode 100644 index 0000000..cde748b --- /dev/null +++ b/admin/models/fields/chaptersfilterbooknr.php @@ -0,0 +1,72 @@ + + @git Get Bible + @github Get Bible + @support Get Bible + @copyright Copyright (C) 2015. All Rights Reserved + @license GNU/GPL Version 2 or later - http://www.gnu.org/licenses/gpl-2.0.html + +/------------------------------------------------------------------------------------------------------*/ + +// No direct access to this file +defined('_JEXEC') or die('Restricted access'); + +// import the list field type +jimport('joomla.form.helper'); +JFormHelper::loadFieldClass('list'); + +/** + * Chaptersfilterbooknr Form Field class for the Getbible component + */ +class JFormFieldChaptersfilterbooknr extends JFormFieldList +{ + /** + * The chaptersfilterbooknr field type. + * + * @var string + */ + public $type = 'chaptersfilterbooknr'; + + /** + * Method to get a list of options for a list input. + * + * @return array An array of JHtml options. + */ + protected function getOptions() + { + // Get a db connection. + $db = JFactory::getDbo(); + + // Create a new query object. + $query = $db->getQuery(true); + + // Select the text. + $query->select($db->quoteName('book_nr')); + $query->from($db->quoteName('#__getbible_chapter')); + $query->order($db->quoteName('book_nr') . ' ASC'); + + // Reset the query using our newly populated query object. + $db->setQuery($query); + + $_results = $db->loadColumn(); + $_filter = array(); + + if ($_results) + { + $_results = array_unique($_results); + foreach ($_results as $book_nr) + { + // Now add the book_nr and its text to the options array + $_filter[] = JHtml::_('select.option', $book_nr, $book_nr); + } + } + return $_filter; + } +} diff --git a/admin/models/fields/chaptersfilterchapter.php b/admin/models/fields/chaptersfilterchapter.php new file mode 100644 index 0000000..c6f366d --- /dev/null +++ b/admin/models/fields/chaptersfilterchapter.php @@ -0,0 +1,72 @@ + + @git Get Bible + @github Get Bible + @support Get Bible + @copyright Copyright (C) 2015. All Rights Reserved + @license GNU/GPL Version 2 or later - http://www.gnu.org/licenses/gpl-2.0.html + +/------------------------------------------------------------------------------------------------------*/ + +// No direct access to this file +defined('_JEXEC') or die('Restricted access'); + +// import the list field type +jimport('joomla.form.helper'); +JFormHelper::loadFieldClass('list'); + +/** + * Chaptersfilterchapter Form Field class for the Getbible component + */ +class JFormFieldChaptersfilterchapter extends JFormFieldList +{ + /** + * The chaptersfilterchapter field type. + * + * @var string + */ + public $type = 'chaptersfilterchapter'; + + /** + * Method to get a list of options for a list input. + * + * @return array An array of JHtml options. + */ + protected function getOptions() + { + // Get a db connection. + $db = JFactory::getDbo(); + + // Create a new query object. + $query = $db->getQuery(true); + + // Select the text. + $query->select($db->quoteName('chapter')); + $query->from($db->quoteName('#__getbible_chapter')); + $query->order($db->quoteName('chapter') . ' ASC'); + + // Reset the query using our newly populated query object. + $db->setQuery($query); + + $_results = $db->loadColumn(); + $_filter = array(); + + if ($_results) + { + $_results = array_unique($_results); + foreach ($_results as $chapter) + { + // Now add the chapter and its text to the options array + $_filter[] = JHtml::_('select.option', $chapter, $chapter); + } + } + return $_filter; + } +} diff --git a/admin/models/fields/index.html b/admin/models/fields/index.html new file mode 100644 index 0000000..fa6d84e --- /dev/null +++ b/admin/models/fields/index.html @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/admin/models/fields/linkers.php b/admin/models/fields/linkers.php new file mode 100644 index 0000000..353f9dd --- /dev/null +++ b/admin/models/fields/linkers.php @@ -0,0 +1,183 @@ + + @git Get Bible + @github Get Bible + @support Get Bible + @copyright Copyright (C) 2015. All Rights Reserved + @license GNU/GPL Version 2 or later - http://www.gnu.org/licenses/gpl-2.0.html + +/------------------------------------------------------------------------------------------------------*/ + +// No direct access to this file +defined('_JEXEC') or die('Restricted access'); + +// import the list field type +jimport('joomla.form.helper'); +JFormHelper::loadFieldClass('list'); + +/** + * Linkers Form Field class for the Getbible component + */ +class JFormFieldLinkers extends JFormFieldList +{ + /** + * The linkers field type. + * + * @var string + */ + public $type = 'linkers'; + + /** + * Override to add new button + * + * @return string The field input markup. + * + * @since 3.2 + */ + protected function getInput() + { + // see if we should add buttons + $set_button = $this->getAttribute('button'); + // get html + $html = parent::getInput(); + // if true set button + if ($set_button === 'true') + { + $button = array(); + $script = array(); + $button_code_name = $this->getAttribute('name'); + // get the input from url + $app = JFactory::getApplication(); + $jinput = $app->input; + // get the view name & id + $values = $jinput->getArray(array( + 'id' => 'int', + 'view' => 'word' + )); + // check if new item + $ref = ''; + $refJ = ''; + if (!is_null($values['id']) && strlen($values['view'])) + { + // only load referral if not new item. + $ref = '&ref=' . $values['view'] . '&refid=' . $values['id']; + $refJ = '&ref=' . $values['view'] . '&refid=' . $values['id']; + // get the return value. + $_uri = (string) JUri::getInstance(); + $_return = urlencode(base64_encode($_uri)); + // load return value. + $ref .= '&return=' . $_return; + $refJ .= '&return=' . $_return; + } + // get button label + $button_label = trim($button_code_name); + $button_label = preg_replace('/_+/', ' ', $button_label); + $button_label = preg_replace('/\s+/', ' ', $button_label); + $button_label = preg_replace("/[^A-Za-z ]/", '', $button_label); + $button_label = ucfirst(strtolower($button_label)); + // get user object + $user = JFactory::getUser(); + // only add if user allowed to create linker + if ($user->authorise('linker.create', 'com_getbible') && $app->isAdmin()) // TODO for now only in admin area. + { + // build Create button + $button[] = ' + '; + } + // only add if user allowed to edit linker + if ($user->authorise('linker.edit', 'com_getbible') && $app->isAdmin()) // TODO for now only in admin area. + { + // build edit button + $button[] = ''; + // build script + $script[] = " + jQuery(document).ready(function() { + jQuery('#adminForm').on('change', '#jform_".$button_code_name."',function (e) { + e.preventDefault(); + var ".$button_code_name."Value = jQuery('#jform_".$button_code_name."').val(); + ".$button_code_name."Button(".$button_code_name."Value); + }); + var ".$button_code_name."Value = jQuery('#jform_".$button_code_name."').val(); + ".$button_code_name."Button(".$button_code_name."Value); + }); + function ".$button_code_name."Button(value) { + if (value > 0) { + // hide the create button + jQuery('#".$button_code_name."Create').hide(); + // show edit button + jQuery('#".$button_code_name."Edit').show(); + var url = 'index.php?option=com_getbible&view=linkers&task=linker.edit&id='+value+'".$refJ."'; + jQuery('#".$button_code_name."Edit').attr('href', url); + } else { + // show the create button + jQuery('#".$button_code_name."Create').show(); + // hide edit button + jQuery('#".$button_code_name."Edit').hide(); + } + }"; + } + // check if button was created for linker field. + if (is_array($button) && count($button) > 0) + { + // Load the needed script. + $document = JFactory::getDocument(); + $document->addScriptDeclaration(implode(' ',$script)); + // return the button attached to input field. + return '
' .$html . implode('',$button).'
'; + } + } + return $html; + } + + /** + * Method to get a list of options for a list input. + * + * @return array An array of JHtml options. + */ + protected function getOptions() + { + // Get the user object. + $user = JFactory::getUser(); + // Get the databse object. + $db = JFactory::getDBO(); + $query = $db->getQuery(true); + $query->select($db->quoteName(array('a.guid','a.name'),array('guid','linker_name'))); + $query->from($db->quoteName('#__getbible_linker', 'a')); + $query->where($db->quoteName('a.published') . ' = 1'); + $query->order('a.name ASC'); + // Implement View Level Access (if set in table) + if (!$user->authorise('core.options', 'com_getbible')) + { + $columns = $db->getTableColumns('#__getbible_linker'); + if(isset($columns['access'])) + { + $groups = implode(',', $user->getAuthorisedViewLevels()); + $query->where('a.access IN (' . $groups . ')'); + } + } + $db->setQuery((string)$query); + $items = $db->loadObjectList(); + $options = array(); + if ($items) + { + if ($this->multiple === false) + { + $options[] = JHtml::_('select.option', '', JText::_('COM_GETBIBLE_SELECT_AN_OPTION')); + } + foreach($items as $item) + { + $options[] = JHtml::_('select.option', $item->guid, $item->linker_name . ' (' . substr($item->guid, 0, 8) . ')'); + } + } + return $options; + } +} diff --git a/admin/models/fields/linkersfiltername.php b/admin/models/fields/linkersfiltername.php new file mode 100644 index 0000000..61be658 --- /dev/null +++ b/admin/models/fields/linkersfiltername.php @@ -0,0 +1,73 @@ + + @git Get Bible + @github Get Bible + @support Get Bible + @copyright Copyright (C) 2015. All Rights Reserved + @license GNU/GPL Version 2 or later - http://www.gnu.org/licenses/gpl-2.0.html + +/------------------------------------------------------------------------------------------------------*/ + +// No direct access to this file +defined('_JEXEC') or die('Restricted access'); + +// import the list field type +jimport('joomla.form.helper'); +JFormHelper::loadFieldClass('list'); + +/** + * Linkersfiltername Form Field class for the Getbible component + */ +class JFormFieldLinkersfiltername extends JFormFieldList +{ + /** + * The linkersfiltername field type. + * + * @var string + */ + public $type = 'linkersfiltername'; + + /** + * Method to get a list of options for a list input. + * + * @return array An array of JHtml options. + */ + protected function getOptions() + { + // Get a db connection. + $db = JFactory::getDbo(); + + // Create a new query object. + $query = $db->getQuery(true); + + // Select the text. + $query->select($db->quoteName('name')); + $query->from($db->quoteName('#__getbible_linker')); + $query->order($db->quoteName('name') . ' ASC'); + + // Reset the query using our newly populated query object. + $db->setQuery($query); + + $_results = $db->loadColumn(); + $_filter = array(); + $_filter[] = JHtml::_('select.option', '', '- ' . JText::_('COM_GETBIBLE_FILTER_SELECT_NAME') . ' -'); + + if ($_results) + { + $_results = array_unique($_results); + foreach ($_results as $name) + { + // Now add the name and its text to the options array + $_filter[] = JHtml::_('select.option', $name, $name); + } + } + return $_filter; + } +} diff --git a/admin/models/fields/notesfilteraccess.php b/admin/models/fields/notesfilteraccess.php new file mode 100644 index 0000000..bfd55ca --- /dev/null +++ b/admin/models/fields/notesfilteraccess.php @@ -0,0 +1,77 @@ + + @git Get Bible + @github Get Bible + @support Get Bible + @copyright Copyright (C) 2015. All Rights Reserved + @license GNU/GPL Version 2 or later - http://www.gnu.org/licenses/gpl-2.0.html + +/------------------------------------------------------------------------------------------------------*/ + +// No direct access to this file +defined('_JEXEC') or die('Restricted access'); + +// import the list field type +jimport('joomla.form.helper'); +JFormHelper::loadFieldClass('list'); + +/** + * Notesfilteraccess Form Field class for the Getbible component + */ +class JFormFieldNotesfilteraccess extends JFormFieldList +{ + /** + * The notesfilteraccess field type. + * + * @var string + */ + public $type = 'notesfilteraccess'; + + /** + * Method to get a list of options for a list input. + * + * @return array An array of JHtml options. + */ + protected function getOptions() + { + // Get a db connection. + $db = JFactory::getDbo(); + + // Create a new query object. + $query = $db->getQuery(true); + + // Select the text. + $query->select($db->quoteName('access')); + $query->from($db->quoteName('#__getbible_note')); + $query->order($db->quoteName('access') . ' ASC'); + + // Reset the query using our newly populated query object. + $db->setQuery($query); + + $_results = $db->loadColumn(); + $_filter = array(); + $_filter[] = JHtml::_('select.option', '', '- ' . JText::_('COM_GETBIBLE_FILTER_SELECT_ACCESS') . ' -'); + + if ($_results) + { + // get notesmodel + $_model = GetbibleHelper::getModel('notes'); + $_results = array_unique($_results); + foreach ($_results as $access) + { + // Translate the access selection + $_text = $_model->selectionTranslation($access,'access'); + // Now add the access and its text to the options array + $_filter[] = JHtml::_('select.option', $access, JText::_($_text)); + } + } + return $_filter; + } +} diff --git a/admin/models/fields/notesfilterbooknr.php b/admin/models/fields/notesfilterbooknr.php new file mode 100644 index 0000000..ed521db --- /dev/null +++ b/admin/models/fields/notesfilterbooknr.php @@ -0,0 +1,73 @@ + + @git Get Bible + @github Get Bible + @support Get Bible + @copyright Copyright (C) 2015. All Rights Reserved + @license GNU/GPL Version 2 or later - http://www.gnu.org/licenses/gpl-2.0.html + +/------------------------------------------------------------------------------------------------------*/ + +// No direct access to this file +defined('_JEXEC') or die('Restricted access'); + +// import the list field type +jimport('joomla.form.helper'); +JFormHelper::loadFieldClass('list'); + +/** + * Notesfilterbooknr Form Field class for the Getbible component + */ +class JFormFieldNotesfilterbooknr extends JFormFieldList +{ + /** + * The notesfilterbooknr field type. + * + * @var string + */ + public $type = 'notesfilterbooknr'; + + /** + * Method to get a list of options for a list input. + * + * @return array An array of JHtml options. + */ + protected function getOptions() + { + // Get a db connection. + $db = JFactory::getDbo(); + + // Create a new query object. + $query = $db->getQuery(true); + + // Select the text. + $query->select($db->quoteName('book_nr')); + $query->from($db->quoteName('#__getbible_note')); + $query->order($db->quoteName('book_nr') . ' ASC'); + + // Reset the query using our newly populated query object. + $db->setQuery($query); + + $_results = $db->loadColumn(); + $_filter = array(); + $_filter[] = JHtml::_('select.option', '', '- ' . JText::_('COM_GETBIBLE_FILTER_SELECT_BOOK_NUMBER') . ' -'); + + if ($_results) + { + $_results = array_unique($_results); + foreach ($_results as $book_nr) + { + // Now add the book_nr and its text to the options array + $_filter[] = JHtml::_('select.option', $book_nr, $book_nr); + } + } + return $_filter; + } +} diff --git a/admin/models/fields/notesfilterchapter.php b/admin/models/fields/notesfilterchapter.php new file mode 100644 index 0000000..406af4f --- /dev/null +++ b/admin/models/fields/notesfilterchapter.php @@ -0,0 +1,73 @@ + + @git Get Bible + @github Get Bible + @support Get Bible + @copyright Copyright (C) 2015. All Rights Reserved + @license GNU/GPL Version 2 or later - http://www.gnu.org/licenses/gpl-2.0.html + +/------------------------------------------------------------------------------------------------------*/ + +// No direct access to this file +defined('_JEXEC') or die('Restricted access'); + +// import the list field type +jimport('joomla.form.helper'); +JFormHelper::loadFieldClass('list'); + +/** + * Notesfilterchapter Form Field class for the Getbible component + */ +class JFormFieldNotesfilterchapter extends JFormFieldList +{ + /** + * The notesfilterchapter field type. + * + * @var string + */ + public $type = 'notesfilterchapter'; + + /** + * Method to get a list of options for a list input. + * + * @return array An array of JHtml options. + */ + protected function getOptions() + { + // Get a db connection. + $db = JFactory::getDbo(); + + // Create a new query object. + $query = $db->getQuery(true); + + // Select the text. + $query->select($db->quoteName('chapter')); + $query->from($db->quoteName('#__getbible_note')); + $query->order($db->quoteName('chapter') . ' ASC'); + + // Reset the query using our newly populated query object. + $db->setQuery($query); + + $_results = $db->loadColumn(); + $_filter = array(); + $_filter[] = JHtml::_('select.option', '', '- ' . JText::_('COM_GETBIBLE_FILTER_SELECT_CHAPTER') . ' -'); + + if ($_results) + { + $_results = array_unique($_results); + foreach ($_results as $chapter) + { + // Now add the chapter and its text to the options array + $_filter[] = JHtml::_('select.option', $chapter, $chapter); + } + } + return $_filter; + } +} diff --git a/admin/models/fields/notesfilterverse.php b/admin/models/fields/notesfilterverse.php new file mode 100644 index 0000000..514fc29 --- /dev/null +++ b/admin/models/fields/notesfilterverse.php @@ -0,0 +1,73 @@ + + @git Get Bible + @github Get Bible + @support Get Bible + @copyright Copyright (C) 2015. All Rights Reserved + @license GNU/GPL Version 2 or later - http://www.gnu.org/licenses/gpl-2.0.html + +/------------------------------------------------------------------------------------------------------*/ + +// No direct access to this file +defined('_JEXEC') or die('Restricted access'); + +// import the list field type +jimport('joomla.form.helper'); +JFormHelper::loadFieldClass('list'); + +/** + * Notesfilterverse Form Field class for the Getbible component + */ +class JFormFieldNotesfilterverse extends JFormFieldList +{ + /** + * The notesfilterverse field type. + * + * @var string + */ + public $type = 'notesfilterverse'; + + /** + * Method to get a list of options for a list input. + * + * @return array An array of JHtml options. + */ + protected function getOptions() + { + // Get a db connection. + $db = JFactory::getDbo(); + + // Create a new query object. + $query = $db->getQuery(true); + + // Select the text. + $query->select($db->quoteName('verse')); + $query->from($db->quoteName('#__getbible_note')); + $query->order($db->quoteName('verse') . ' ASC'); + + // Reset the query using our newly populated query object. + $db->setQuery($query); + + $_results = $db->loadColumn(); + $_filter = array(); + $_filter[] = JHtml::_('select.option', '', '- ' . JText::_('COM_GETBIBLE_FILTER_SELECT_VERSE') . ' -'); + + if ($_results) + { + $_results = array_unique($_results); + foreach ($_results as $verse) + { + // Now add the verse and its text to the options array + $_filter[] = JHtml::_('select.option', $verse, $verse); + } + } + return $_filter; + } +} diff --git a/admin/models/fields/openaimessagesfilterrole.php b/admin/models/fields/openaimessagesfilterrole.php new file mode 100644 index 0000000..b4f9067 --- /dev/null +++ b/admin/models/fields/openaimessagesfilterrole.php @@ -0,0 +1,77 @@ + + @git Get Bible + @github Get Bible + @support Get Bible + @copyright Copyright (C) 2015. All Rights Reserved + @license GNU/GPL Version 2 or later - http://www.gnu.org/licenses/gpl-2.0.html + +/------------------------------------------------------------------------------------------------------*/ + +// No direct access to this file +defined('_JEXEC') or die('Restricted access'); + +// import the list field type +jimport('joomla.form.helper'); +JFormHelper::loadFieldClass('list'); + +/** + * Openaimessagesfilterrole Form Field class for the Getbible component + */ +class JFormFieldOpenaimessagesfilterrole extends JFormFieldList +{ + /** + * The openaimessagesfilterrole field type. + * + * @var string + */ + public $type = 'openaimessagesfilterrole'; + + /** + * Method to get a list of options for a list input. + * + * @return array An array of JHtml options. + */ + protected function getOptions() + { + // Get a db connection. + $db = JFactory::getDbo(); + + // Create a new query object. + $query = $db->getQuery(true); + + // Select the text. + $query->select($db->quoteName('role')); + $query->from($db->quoteName('#__getbible_open_ai_message')); + $query->order($db->quoteName('role') . ' ASC'); + + // Reset the query using our newly populated query object. + $db->setQuery($query); + + $_results = $db->loadColumn(); + $_filter = array(); + $_filter[] = JHtml::_('select.option', '', '- ' . JText::_('COM_GETBIBLE_FILTER_SELECT_ROLE') . ' -'); + + if ($_results) + { + // get open_ai_messagesmodel + $_model = GetbibleHelper::getModel('open_ai_messages'); + $_results = array_unique($_results); + foreach ($_results as $role) + { + // Translate the role selection + $_text = $_model->selectionTranslation($role,'role'); + // Now add the role and its text to the options array + $_filter[] = JHtml::_('select.option', $role, JText::_($_text)); + } + } + return $_filter; + } +} diff --git a/admin/models/fields/openaimessagesfiltersource.php b/admin/models/fields/openaimessagesfiltersource.php new file mode 100644 index 0000000..6d1cd1f --- /dev/null +++ b/admin/models/fields/openaimessagesfiltersource.php @@ -0,0 +1,77 @@ + + @git Get Bible + @github Get Bible + @support Get Bible + @copyright Copyright (C) 2015. All Rights Reserved + @license GNU/GPL Version 2 or later - http://www.gnu.org/licenses/gpl-2.0.html + +/------------------------------------------------------------------------------------------------------*/ + +// No direct access to this file +defined('_JEXEC') or die('Restricted access'); + +// import the list field type +jimport('joomla.form.helper'); +JFormHelper::loadFieldClass('list'); + +/** + * Openaimessagesfiltersource Form Field class for the Getbible component + */ +class JFormFieldOpenaimessagesfiltersource extends JFormFieldList +{ + /** + * The openaimessagesfiltersource field type. + * + * @var string + */ + public $type = 'openaimessagesfiltersource'; + + /** + * Method to get a list of options for a list input. + * + * @return array An array of JHtml options. + */ + protected function getOptions() + { + // Get a db connection. + $db = JFactory::getDbo(); + + // Create a new query object. + $query = $db->getQuery(true); + + // Select the text. + $query->select($db->quoteName('source')); + $query->from($db->quoteName('#__getbible_open_ai_message')); + $query->order($db->quoteName('source') . ' ASC'); + + // Reset the query using our newly populated query object. + $db->setQuery($query); + + $_results = $db->loadColumn(); + $_filter = array(); + $_filter[] = JHtml::_('select.option', '', '- ' . JText::_('COM_GETBIBLE_FILTER_SELECT_SOURCE') . ' -'); + + if ($_results) + { + // get open_ai_messagesmodel + $_model = GetbibleHelper::getModel('open_ai_messages'); + $_results = array_unique($_results); + foreach ($_results as $source) + { + // Translate the source selection + $_text = $_model->selectionTranslation($source,'source'); + // Now add the source and its text to the options array + $_filter[] = JHtml::_('select.option', $source, JText::_($_text)); + } + } + return $_filter; + } +} diff --git a/admin/models/fields/openairesponses.php b/admin/models/fields/openairesponses.php new file mode 100644 index 0000000..8816b75 --- /dev/null +++ b/admin/models/fields/openairesponses.php @@ -0,0 +1,78 @@ + + @git Get Bible + @github Get Bible + @support Get Bible + @copyright Copyright (C) 2015. All Rights Reserved + @license GNU/GPL Version 2 or later - http://www.gnu.org/licenses/gpl-2.0.html + +/------------------------------------------------------------------------------------------------------*/ + +// No direct access to this file +defined('_JEXEC') or die('Restricted access'); + +// import the list field type +jimport('joomla.form.helper'); +JFormHelper::loadFieldClass('list'); + +/** + * Openairesponses Form Field class for the Getbible component + */ +class JFormFieldOpenairesponses extends JFormFieldList +{ + /** + * The openairesponses field type. + * + * @var string + */ + public $type = 'openairesponses'; + + /** + * Method to get a list of options for a list input. + * + * @return array An array of JHtml options. + */ + protected function getOptions() + { + // Get the user object. + $user = JFactory::getUser(); + // Get the databse object. + $db = JFactory::getDBO(); + $query = $db->getQuery(true); + $query->select($db->quoteName(array('a.response_id','a.response_id'),array('response_id','open_ai_response_response_id'))); + $query->from($db->quoteName('#__getbible_open_ai_response', 'a')); + $query->order('a.response_id ASC'); + // Implement View Level Access (if set in table) + if (!$user->authorise('core.options', 'com_getbible')) + { + $columns = $db->getTableColumns('#__getbible_open_ai_response'); + if(isset($columns['access'])) + { + $groups = implode(',', $user->getAuthorisedViewLevels()); + $query->where('a.access IN (' . $groups . ')'); + } + } + $db->setQuery((string)$query); + $items = $db->loadObjectList(); + $options = array(); + if ($items) + { + if ($this->multiple === false) + { + $options[] = JHtml::_('select.option', '', JText::_('COM_GETBIBLE_SELECT_AN_OPTION')); + } + foreach($items as $item) + { + $options[] = JHtml::_('select.option', $item->response_id, $item->open_ai_response_response_id); + } + } + return $options; + } +} diff --git a/admin/models/fields/openairesponsesfilterresponseid.php b/admin/models/fields/openairesponsesfilterresponseid.php new file mode 100644 index 0000000..5e19576 --- /dev/null +++ b/admin/models/fields/openairesponsesfilterresponseid.php @@ -0,0 +1,73 @@ + + @git Get Bible + @github Get Bible + @support Get Bible + @copyright Copyright (C) 2015. All Rights Reserved + @license GNU/GPL Version 2 or later - http://www.gnu.org/licenses/gpl-2.0.html + +/------------------------------------------------------------------------------------------------------*/ + +// No direct access to this file +defined('_JEXEC') or die('Restricted access'); + +// import the list field type +jimport('joomla.form.helper'); +JFormHelper::loadFieldClass('list'); + +/** + * Openairesponsesfilterresponseid Form Field class for the Getbible component + */ +class JFormFieldOpenairesponsesfilterresponseid extends JFormFieldList +{ + /** + * The openairesponsesfilterresponseid field type. + * + * @var string + */ + public $type = 'openairesponsesfilterresponseid'; + + /** + * Method to get a list of options for a list input. + * + * @return array An array of JHtml options. + */ + protected function getOptions() + { + // Get a db connection. + $db = JFactory::getDbo(); + + // Create a new query object. + $query = $db->getQuery(true); + + // Select the text. + $query->select($db->quoteName('response_id')); + $query->from($db->quoteName('#__getbible_open_ai_response')); + $query->order($db->quoteName('response_id') . ' ASC'); + + // Reset the query using our newly populated query object. + $db->setQuery($query); + + $_results = $db->loadColumn(); + $_filter = array(); + $_filter[] = JHtml::_('select.option', '', '- ' . JText::_('COM_GETBIBLE_FILTER_SELECT_RESPONSE_ID') . ' -'); + + if ($_results) + { + $_results = array_unique($_results); + foreach ($_results as $response_id) + { + // Now add the response_id and its text to the options array + $_filter[] = JHtml::_('select.option', $response_id, $response_id); + } + } + return $_filter; + } +} diff --git a/admin/models/fields/openairesponsesfilterresponsemodel.php b/admin/models/fields/openairesponsesfilterresponsemodel.php new file mode 100644 index 0000000..13741ae --- /dev/null +++ b/admin/models/fields/openairesponsesfilterresponsemodel.php @@ -0,0 +1,73 @@ + + @git Get Bible + @github Get Bible + @support Get Bible + @copyright Copyright (C) 2015. All Rights Reserved + @license GNU/GPL Version 2 or later - http://www.gnu.org/licenses/gpl-2.0.html + +/------------------------------------------------------------------------------------------------------*/ + +// No direct access to this file +defined('_JEXEC') or die('Restricted access'); + +// import the list field type +jimport('joomla.form.helper'); +JFormHelper::loadFieldClass('list'); + +/** + * Openairesponsesfilterresponsemodel Form Field class for the Getbible component + */ +class JFormFieldOpenairesponsesfilterresponsemodel extends JFormFieldList +{ + /** + * The openairesponsesfilterresponsemodel field type. + * + * @var string + */ + public $type = 'openairesponsesfilterresponsemodel'; + + /** + * Method to get a list of options for a list input. + * + * @return array An array of JHtml options. + */ + protected function getOptions() + { + // Get a db connection. + $db = JFactory::getDbo(); + + // Create a new query object. + $query = $db->getQuery(true); + + // Select the text. + $query->select($db->quoteName('response_model')); + $query->from($db->quoteName('#__getbible_open_ai_response')); + $query->order($db->quoteName('response_model') . ' ASC'); + + // Reset the query using our newly populated query object. + $db->setQuery($query); + + $_results = $db->loadColumn(); + $_filter = array(); + $_filter[] = JHtml::_('select.option', '', '- ' . JText::_('COM_GETBIBLE_FILTER_SELECT_RESPONSE_MODEL') . ' -'); + + if ($_results) + { + $_results = array_unique($_results); + foreach ($_results as $response_model) + { + // Now add the response_model and its text to the options array + $_filter[] = JHtml::_('select.option', $response_model, $response_model); + } + } + return $_filter; + } +} diff --git a/admin/models/fields/passwordsfiltername.php b/admin/models/fields/passwordsfiltername.php new file mode 100644 index 0000000..bc0b3f8 --- /dev/null +++ b/admin/models/fields/passwordsfiltername.php @@ -0,0 +1,73 @@ + + @git Get Bible + @github Get Bible + @support Get Bible + @copyright Copyright (C) 2015. All Rights Reserved + @license GNU/GPL Version 2 or later - http://www.gnu.org/licenses/gpl-2.0.html + +/------------------------------------------------------------------------------------------------------*/ + +// No direct access to this file +defined('_JEXEC') or die('Restricted access'); + +// import the list field type +jimport('joomla.form.helper'); +JFormHelper::loadFieldClass('list'); + +/** + * Passwordsfiltername Form Field class for the Getbible component + */ +class JFormFieldPasswordsfiltername extends JFormFieldList +{ + /** + * The passwordsfiltername field type. + * + * @var string + */ + public $type = 'passwordsfiltername'; + + /** + * Method to get a list of options for a list input. + * + * @return array An array of JHtml options. + */ + protected function getOptions() + { + // Get a db connection. + $db = JFactory::getDbo(); + + // Create a new query object. + $query = $db->getQuery(true); + + // Select the text. + $query->select($db->quoteName('name')); + $query->from($db->quoteName('#__getbible_password')); + $query->order($db->quoteName('name') . ' ASC'); + + // Reset the query using our newly populated query object. + $db->setQuery($query); + + $_results = $db->loadColumn(); + $_filter = array(); + $_filter[] = JHtml::_('select.option', '', '- ' . JText::_('COM_GETBIBLE_FILTER_SELECT_NAME') . ' -'); + + if ($_results) + { + $_results = array_unique($_results); + foreach ($_results as $name) + { + // Now add the name and its text to the options array + $_filter[] = JHtml::_('select.option', $name, $name); + } + } + return $_filter; + } +} diff --git a/admin/models/fields/prompts.php b/admin/models/fields/prompts.php new file mode 100644 index 0000000..dbfa2b2 --- /dev/null +++ b/admin/models/fields/prompts.php @@ -0,0 +1,78 @@ + + @git Get Bible + @github Get Bible + @support Get Bible + @copyright Copyright (C) 2015. All Rights Reserved + @license GNU/GPL Version 2 or later - http://www.gnu.org/licenses/gpl-2.0.html + +/------------------------------------------------------------------------------------------------------*/ + +// No direct access to this file +defined('_JEXEC') or die('Restricted access'); + +// import the list field type +jimport('joomla.form.helper'); +JFormHelper::loadFieldClass('list'); + +/** + * Prompts Form Field class for the Getbible component + */ +class JFormFieldPrompts extends JFormFieldList +{ + /** + * The prompts field type. + * + * @var string + */ + public $type = 'prompts'; + + /** + * Method to get a list of options for a list input. + * + * @return array An array of JHtml options. + */ + protected function getOptions() + { + // Get the user object. + $user = JFactory::getUser(); + // Get the databse object. + $db = JFactory::getDBO(); + $query = $db->getQuery(true); + $query->select($db->quoteName(array('a.guid','a.name'),array('guid','prompt_name'))); + $query->from($db->quoteName('#__getbible_prompt', 'a')); + $query->order('a.name ASC'); + // Implement View Level Access (if set in table) + if (!$user->authorise('core.options', 'com_getbible')) + { + $columns = $db->getTableColumns('#__getbible_prompt'); + if(isset($columns['access'])) + { + $groups = implode(',', $user->getAuthorisedViewLevels()); + $query->where('a.access IN (' . $groups . ')'); + } + } + $db->setQuery((string)$query); + $items = $db->loadObjectList(); + $options = array(); + if ($items) + { + if ($this->multiple === false) + { + $options[] = JHtml::_('select.option', '', JText::_('COM_GETBIBLE_SELECT_AN_OPTION')); + } + foreach($items as $item) + { + $options[] = JHtml::_('select.option', $item->guid, $item->prompt_name . ' (' . $item->guid . ')'); + } + } + return $options; + } +} diff --git a/admin/models/fields/promptsfiltercachebehaviour.php b/admin/models/fields/promptsfiltercachebehaviour.php new file mode 100644 index 0000000..c3796fc --- /dev/null +++ b/admin/models/fields/promptsfiltercachebehaviour.php @@ -0,0 +1,77 @@ + + @git Get Bible + @github Get Bible + @support Get Bible + @copyright Copyright (C) 2015. All Rights Reserved + @license GNU/GPL Version 2 or later - http://www.gnu.org/licenses/gpl-2.0.html + +/------------------------------------------------------------------------------------------------------*/ + +// No direct access to this file +defined('_JEXEC') or die('Restricted access'); + +// import the list field type +jimport('joomla.form.helper'); +JFormHelper::loadFieldClass('list'); + +/** + * Promptsfiltercachebehaviour Form Field class for the Getbible component + */ +class JFormFieldPromptsfiltercachebehaviour extends JFormFieldList +{ + /** + * The promptsfiltercachebehaviour field type. + * + * @var string + */ + public $type = 'promptsfiltercachebehaviour'; + + /** + * Method to get a list of options for a list input. + * + * @return array An array of JHtml options. + */ + protected function getOptions() + { + // Get a db connection. + $db = JFactory::getDbo(); + + // Create a new query object. + $query = $db->getQuery(true); + + // Select the text. + $query->select($db->quoteName('cache_behaviour')); + $query->from($db->quoteName('#__getbible_prompt')); + $query->order($db->quoteName('cache_behaviour') . ' ASC'); + + // Reset the query using our newly populated query object. + $db->setQuery($query); + + $_results = $db->loadColumn(); + $_filter = array(); + $_filter[] = JHtml::_('select.option', '', '- ' . JText::_('COM_GETBIBLE_FILTER_SELECT_CACHE_BEHAVIOUR') . ' -'); + + if ($_results) + { + // get promptsmodel + $_model = GetbibleHelper::getModel('prompts'); + $_results = array_unique($_results); + foreach ($_results as $cache_behaviour) + { + // Translate the cache_behaviour selection + $_text = $_model->selectionTranslation($cache_behaviour,'cache_behaviour'); + // Now add the cache_behaviour and its text to the options array + $_filter[] = JHtml::_('select.option', $cache_behaviour, JText::_($_text)); + } + } + return $_filter; + } +} diff --git a/admin/models/fields/promptsfiltermodel.php b/admin/models/fields/promptsfiltermodel.php new file mode 100644 index 0000000..fcd3556 --- /dev/null +++ b/admin/models/fields/promptsfiltermodel.php @@ -0,0 +1,77 @@ + + @git Get Bible + @github Get Bible + @support Get Bible + @copyright Copyright (C) 2015. All Rights Reserved + @license GNU/GPL Version 2 or later - http://www.gnu.org/licenses/gpl-2.0.html + +/------------------------------------------------------------------------------------------------------*/ + +// No direct access to this file +defined('_JEXEC') or die('Restricted access'); + +// import the list field type +jimport('joomla.form.helper'); +JFormHelper::loadFieldClass('list'); + +/** + * Promptsfiltermodel Form Field class for the Getbible component + */ +class JFormFieldPromptsfiltermodel extends JFormFieldList +{ + /** + * The promptsfiltermodel field type. + * + * @var string + */ + public $type = 'promptsfiltermodel'; + + /** + * Method to get a list of options for a list input. + * + * @return array An array of JHtml options. + */ + protected function getOptions() + { + // Get a db connection. + $db = JFactory::getDbo(); + + // Create a new query object. + $query = $db->getQuery(true); + + // Select the text. + $query->select($db->quoteName('model')); + $query->from($db->quoteName('#__getbible_prompt')); + $query->order($db->quoteName('model') . ' ASC'); + + // Reset the query using our newly populated query object. + $db->setQuery($query); + + $_results = $db->loadColumn(); + $_filter = array(); + $_filter[] = JHtml::_('select.option', '', '- ' . JText::_('COM_GETBIBLE_FILTER_SELECT_MODEL') . ' -'); + + if ($_results) + { + // get promptsmodel + $_model = GetbibleHelper::getModel('prompts'); + $_results = array_unique($_results); + foreach ($_results as $model) + { + // Translate the model selection + $_text = $_model->selectionTranslation($model,'model'); + // Now add the model and its text to the options array + $_filter[] = JHtml::_('select.option', $model, JText::_($_text)); + } + } + return $_filter; + } +} diff --git a/admin/models/fields/promptsfiltername.php b/admin/models/fields/promptsfiltername.php new file mode 100644 index 0000000..d116c01 --- /dev/null +++ b/admin/models/fields/promptsfiltername.php @@ -0,0 +1,73 @@ + + @git Get Bible + @github Get Bible + @support Get Bible + @copyright Copyright (C) 2015. All Rights Reserved + @license GNU/GPL Version 2 or later - http://www.gnu.org/licenses/gpl-2.0.html + +/------------------------------------------------------------------------------------------------------*/ + +// No direct access to this file +defined('_JEXEC') or die('Restricted access'); + +// import the list field type +jimport('joomla.form.helper'); +JFormHelper::loadFieldClass('list'); + +/** + * Promptsfiltername Form Field class for the Getbible component + */ +class JFormFieldPromptsfiltername extends JFormFieldList +{ + /** + * The promptsfiltername field type. + * + * @var string + */ + public $type = 'promptsfiltername'; + + /** + * Method to get a list of options for a list input. + * + * @return array An array of JHtml options. + */ + protected function getOptions() + { + // Get a db connection. + $db = JFactory::getDbo(); + + // Create a new query object. + $query = $db->getQuery(true); + + // Select the text. + $query->select($db->quoteName('name')); + $query->from($db->quoteName('#__getbible_prompt')); + $query->order($db->quoteName('name') . ' ASC'); + + // Reset the query using our newly populated query object. + $db->setQuery($query); + + $_results = $db->loadColumn(); + $_filter = array(); + $_filter[] = JHtml::_('select.option', '', '- ' . JText::_('COM_GETBIBLE_FILTER_SELECT_NAME') . ' -'); + + if ($_results) + { + $_results = array_unique($_results); + foreach ($_results as $name) + { + // Now add the name and its text to the options array + $_filter[] = JHtml::_('select.option', $name, $name); + } + } + return $_filter; + } +} diff --git a/admin/models/fields/tagers.php b/admin/models/fields/tagers.php new file mode 100644 index 0000000..315797b --- /dev/null +++ b/admin/models/fields/tagers.php @@ -0,0 +1,183 @@ + + @git Get Bible + @github Get Bible + @support Get Bible + @copyright Copyright (C) 2015. All Rights Reserved + @license GNU/GPL Version 2 or later - http://www.gnu.org/licenses/gpl-2.0.html + +/------------------------------------------------------------------------------------------------------*/ + +// No direct access to this file +defined('_JEXEC') or die('Restricted access'); + +// import the list field type +jimport('joomla.form.helper'); +JFormHelper::loadFieldClass('list'); + +/** + * Tagers Form Field class for the Getbible component + */ +class JFormFieldTagers extends JFormFieldList +{ + /** + * The tagers field type. + * + * @var string + */ + public $type = 'tagers'; + + /** + * Override to add new button + * + * @return string The field input markup. + * + * @since 3.2 + */ + protected function getInput() + { + // see if we should add buttons + $set_button = $this->getAttribute('button'); + // get html + $html = parent::getInput(); + // if true set button + if ($set_button === 'true') + { + $button = array(); + $script = array(); + $button_code_name = $this->getAttribute('name'); + // get the input from url + $app = JFactory::getApplication(); + $jinput = $app->input; + // get the view name & id + $values = $jinput->getArray(array( + 'id' => 'int', + 'view' => 'word' + )); + // check if new item + $ref = ''; + $refJ = ''; + if (!is_null($values['id']) && strlen($values['view'])) + { + // only load referral if not new item. + $ref = '&ref=' . $values['view'] . '&refid=' . $values['id']; + $refJ = '&ref=' . $values['view'] . '&refid=' . $values['id']; + // get the return value. + $_uri = (string) JUri::getInstance(); + $_return = urlencode(base64_encode($_uri)); + // load return value. + $ref .= '&return=' . $_return; + $refJ .= '&return=' . $_return; + } + // get button label + $button_label = trim($button_code_name); + $button_label = preg_replace('/_+/', ' ', $button_label); + $button_label = preg_replace('/\s+/', ' ', $button_label); + $button_label = preg_replace("/[^A-Za-z ]/", '', $button_label); + $button_label = ucfirst(strtolower($button_label)); + // get user object + $user = JFactory::getUser(); + // only add if user allowed to create tag + if ($user->authorise('tag.create', 'com_getbible') && $app->isAdmin()) // TODO for now only in admin area. + { + // build Create button + $button[] = ' + '; + } + // only add if user allowed to edit tag + if ($user->authorise('tag.edit', 'com_getbible') && $app->isAdmin()) // TODO for now only in admin area. + { + // build edit button + $button[] = ''; + // build script + $script[] = " + jQuery(document).ready(function() { + jQuery('#adminForm').on('change', '#jform_".$button_code_name."',function (e) { + e.preventDefault(); + var ".$button_code_name."Value = jQuery('#jform_".$button_code_name."').val(); + ".$button_code_name."Button(".$button_code_name."Value); + }); + var ".$button_code_name."Value = jQuery('#jform_".$button_code_name."').val(); + ".$button_code_name."Button(".$button_code_name."Value); + }); + function ".$button_code_name."Button(value) { + if (value > 0) { + // hide the create button + jQuery('#".$button_code_name."Create').hide(); + // show edit button + jQuery('#".$button_code_name."Edit').show(); + var url = 'index.php?option=com_getbible&view=tags&task=tag.edit&id='+value+'".$refJ."'; + jQuery('#".$button_code_name."Edit').attr('href', url); + } else { + // show the create button + jQuery('#".$button_code_name."Create').show(); + // hide edit button + jQuery('#".$button_code_name."Edit').hide(); + } + }"; + } + // check if button was created for tag field. + if (is_array($button) && count($button) > 0) + { + // Load the needed script. + $document = JFactory::getDocument(); + $document->addScriptDeclaration(implode(' ',$script)); + // return the button attached to input field. + return '
' .$html . implode('',$button).'
'; + } + } + return $html; + } + + /** + * Method to get a list of options for a list input. + * + * @return array An array of JHtml options. + */ + protected function getOptions() + { + // Get the user object. + $user = JFactory::getUser(); + // Get the databse object. + $db = JFactory::getDBO(); + $query = $db->getQuery(true); + $query->select($db->quoteName(array('a.guid','a.name'),array('guid','tag_name'))); + $query->from($db->quoteName('#__getbible_tag', 'a')); + $query->where($db->quoteName('a.published') . ' = 1'); + $query->order('a.name ASC'); + // Implement View Level Access (if set in table) + if (!$user->authorise('core.options', 'com_getbible')) + { + $columns = $db->getTableColumns('#__getbible_tag'); + if(isset($columns['access'])) + { + $groups = implode(',', $user->getAuthorisedViewLevels()); + $query->where('a.access IN (' . $groups . ')'); + } + } + $db->setQuery((string)$query); + $items = $db->loadObjectList(); + $options = array(); + if ($items) + { + if ($this->multiple === false) + { + $options[] = JHtml::_('select.option', '', JText::_('COM_GETBIBLE_SELECT_AN_OPTION')); + } + foreach($items as $item) + { + $options[] = JHtml::_('select.option', $item->guid, $item->tag_name . ' (' . substr($item->guid, 0, 8) . ')'); + } + } + return $options; + } +} diff --git a/admin/models/fields/taggedversesfilteraccess.php b/admin/models/fields/taggedversesfilteraccess.php new file mode 100644 index 0000000..98be0bd --- /dev/null +++ b/admin/models/fields/taggedversesfilteraccess.php @@ -0,0 +1,77 @@ + + @git Get Bible + @github Get Bible + @support Get Bible + @copyright Copyright (C) 2015. All Rights Reserved + @license GNU/GPL Version 2 or later - http://www.gnu.org/licenses/gpl-2.0.html + +/------------------------------------------------------------------------------------------------------*/ + +// No direct access to this file +defined('_JEXEC') or die('Restricted access'); + +// import the list field type +jimport('joomla.form.helper'); +JFormHelper::loadFieldClass('list'); + +/** + * Taggedversesfilteraccess Form Field class for the Getbible component + */ +class JFormFieldTaggedversesfilteraccess extends JFormFieldList +{ + /** + * The taggedversesfilteraccess field type. + * + * @var string + */ + public $type = 'taggedversesfilteraccess'; + + /** + * Method to get a list of options for a list input. + * + * @return array An array of JHtml options. + */ + protected function getOptions() + { + // Get a db connection. + $db = JFactory::getDbo(); + + // Create a new query object. + $query = $db->getQuery(true); + + // Select the text. + $query->select($db->quoteName('access')); + $query->from($db->quoteName('#__getbible_tagged_verse')); + $query->order($db->quoteName('access') . ' ASC'); + + // Reset the query using our newly populated query object. + $db->setQuery($query); + + $_results = $db->loadColumn(); + $_filter = array(); + $_filter[] = JHtml::_('select.option', '', '- ' . JText::_('COM_GETBIBLE_FILTER_SELECT_ACCESS') . ' -'); + + if ($_results) + { + // get tagged_versesmodel + $_model = GetbibleHelper::getModel('tagged_verses'); + $_results = array_unique($_results); + foreach ($_results as $access) + { + // Translate the access selection + $_text = $_model->selectionTranslation($access,'access'); + // Now add the access and its text to the options array + $_filter[] = JHtml::_('select.option', $access, JText::_($_text)); + } + } + return $_filter; + } +} diff --git a/admin/models/fields/taggedversesfilterbooknr.php b/admin/models/fields/taggedversesfilterbooknr.php new file mode 100644 index 0000000..d86ad5d --- /dev/null +++ b/admin/models/fields/taggedversesfilterbooknr.php @@ -0,0 +1,72 @@ + + @git Get Bible + @github Get Bible + @support Get Bible + @copyright Copyright (C) 2015. All Rights Reserved + @license GNU/GPL Version 2 or later - http://www.gnu.org/licenses/gpl-2.0.html + +/------------------------------------------------------------------------------------------------------*/ + +// No direct access to this file +defined('_JEXEC') or die('Restricted access'); + +// import the list field type +jimport('joomla.form.helper'); +JFormHelper::loadFieldClass('list'); + +/** + * Taggedversesfilterbooknr Form Field class for the Getbible component + */ +class JFormFieldTaggedversesfilterbooknr extends JFormFieldList +{ + /** + * The taggedversesfilterbooknr field type. + * + * @var string + */ + public $type = 'taggedversesfilterbooknr'; + + /** + * Method to get a list of options for a list input. + * + * @return array An array of JHtml options. + */ + protected function getOptions() + { + // Get a db connection. + $db = JFactory::getDbo(); + + // Create a new query object. + $query = $db->getQuery(true); + + // Select the text. + $query->select($db->quoteName('book_nr')); + $query->from($db->quoteName('#__getbible_tagged_verse')); + $query->order($db->quoteName('book_nr') . ' ASC'); + + // Reset the query using our newly populated query object. + $db->setQuery($query); + + $_results = $db->loadColumn(); + $_filter = array(); + + if ($_results) + { + $_results = array_unique($_results); + foreach ($_results as $book_nr) + { + // Now add the book_nr and its text to the options array + $_filter[] = JHtml::_('select.option', $book_nr, $book_nr); + } + } + return $_filter; + } +} diff --git a/admin/models/fields/taggedversesfilterchapter.php b/admin/models/fields/taggedversesfilterchapter.php new file mode 100644 index 0000000..a1b3e19 --- /dev/null +++ b/admin/models/fields/taggedversesfilterchapter.php @@ -0,0 +1,72 @@ + + @git Get Bible + @github Get Bible + @support Get Bible + @copyright Copyright (C) 2015. All Rights Reserved + @license GNU/GPL Version 2 or later - http://www.gnu.org/licenses/gpl-2.0.html + +/------------------------------------------------------------------------------------------------------*/ + +// No direct access to this file +defined('_JEXEC') or die('Restricted access'); + +// import the list field type +jimport('joomla.form.helper'); +JFormHelper::loadFieldClass('list'); + +/** + * Taggedversesfilterchapter Form Field class for the Getbible component + */ +class JFormFieldTaggedversesfilterchapter extends JFormFieldList +{ + /** + * The taggedversesfilterchapter field type. + * + * @var string + */ + public $type = 'taggedversesfilterchapter'; + + /** + * Method to get a list of options for a list input. + * + * @return array An array of JHtml options. + */ + protected function getOptions() + { + // Get a db connection. + $db = JFactory::getDbo(); + + // Create a new query object. + $query = $db->getQuery(true); + + // Select the text. + $query->select($db->quoteName('chapter')); + $query->from($db->quoteName('#__getbible_tagged_verse')); + $query->order($db->quoteName('chapter') . ' ASC'); + + // Reset the query using our newly populated query object. + $db->setQuery($query); + + $_results = $db->loadColumn(); + $_filter = array(); + + if ($_results) + { + $_results = array_unique($_results); + foreach ($_results as $chapter) + { + // Now add the chapter and its text to the options array + $_filter[] = JHtml::_('select.option', $chapter, $chapter); + } + } + return $_filter; + } +} diff --git a/admin/models/fields/taggedversesfilterverse.php b/admin/models/fields/taggedversesfilterverse.php new file mode 100644 index 0000000..c6e1254 --- /dev/null +++ b/admin/models/fields/taggedversesfilterverse.php @@ -0,0 +1,72 @@ + + @git Get Bible + @github Get Bible + @support Get Bible + @copyright Copyright (C) 2015. All Rights Reserved + @license GNU/GPL Version 2 or later - http://www.gnu.org/licenses/gpl-2.0.html + +/------------------------------------------------------------------------------------------------------*/ + +// No direct access to this file +defined('_JEXEC') or die('Restricted access'); + +// import the list field type +jimport('joomla.form.helper'); +JFormHelper::loadFieldClass('list'); + +/** + * Taggedversesfilterverse Form Field class for the Getbible component + */ +class JFormFieldTaggedversesfilterverse extends JFormFieldList +{ + /** + * The taggedversesfilterverse field type. + * + * @var string + */ + public $type = 'taggedversesfilterverse'; + + /** + * Method to get a list of options for a list input. + * + * @return array An array of JHtml options. + */ + protected function getOptions() + { + // Get a db connection. + $db = JFactory::getDbo(); + + // Create a new query object. + $query = $db->getQuery(true); + + // Select the text. + $query->select($db->quoteName('verse')); + $query->from($db->quoteName('#__getbible_tagged_verse')); + $query->order($db->quoteName('verse') . ' ASC'); + + // Reset the query using our newly populated query object. + $db->setQuery($query); + + $_results = $db->loadColumn(); + $_filter = array(); + + if ($_results) + { + $_results = array_unique($_results); + foreach ($_results as $verse) + { + // Now add the verse and its text to the options array + $_filter[] = JHtml::_('select.option', $verse, $verse); + } + } + return $_filter; + } +} diff --git a/admin/models/fields/tagsfilteraccess.php b/admin/models/fields/tagsfilteraccess.php new file mode 100644 index 0000000..5bbc513 --- /dev/null +++ b/admin/models/fields/tagsfilteraccess.php @@ -0,0 +1,77 @@ + + @git Get Bible + @github Get Bible + @support Get Bible + @copyright Copyright (C) 2015. All Rights Reserved + @license GNU/GPL Version 2 or later - http://www.gnu.org/licenses/gpl-2.0.html + +/------------------------------------------------------------------------------------------------------*/ + +// No direct access to this file +defined('_JEXEC') or die('Restricted access'); + +// import the list field type +jimport('joomla.form.helper'); +JFormHelper::loadFieldClass('list'); + +/** + * Tagsfilteraccess Form Field class for the Getbible component + */ +class JFormFieldTagsfilteraccess extends JFormFieldList +{ + /** + * The tagsfilteraccess field type. + * + * @var string + */ + public $type = 'tagsfilteraccess'; + + /** + * Method to get a list of options for a list input. + * + * @return array An array of JHtml options. + */ + protected function getOptions() + { + // Get a db connection. + $db = JFactory::getDbo(); + + // Create a new query object. + $query = $db->getQuery(true); + + // Select the text. + $query->select($db->quoteName('access')); + $query->from($db->quoteName('#__getbible_tag')); + $query->order($db->quoteName('access') . ' ASC'); + + // Reset the query using our newly populated query object. + $db->setQuery($query); + + $_results = $db->loadColumn(); + $_filter = array(); + $_filter[] = JHtml::_('select.option', '', '- ' . JText::_('COM_GETBIBLE_FILTER_SELECT_ACCESS') . ' -'); + + if ($_results) + { + // get tagsmodel + $_model = GetbibleHelper::getModel('tags'); + $_results = array_unique($_results); + foreach ($_results as $access) + { + // Translate the access selection + $_text = $_model->selectionTranslation($access,'access'); + // Now add the access and its text to the options array + $_filter[] = JHtml::_('select.option', $access, JText::_($_text)); + } + } + return $_filter; + } +} diff --git a/admin/models/fields/targettranslations.php b/admin/models/fields/targettranslations.php new file mode 100644 index 0000000..29e9b34 --- /dev/null +++ b/admin/models/fields/targettranslations.php @@ -0,0 +1,80 @@ + + @git Get Bible + @github Get Bible + @support Get Bible + @copyright Copyright (C) 2015. All Rights Reserved + @license GNU/GPL Version 2 or later - http://www.gnu.org/licenses/gpl-2.0.html + +/------------------------------------------------------------------------------------------------------*/ + +// No direct access to this file +defined('_JEXEC') or die('Restricted access'); + +// import the list field type +jimport('joomla.form.helper'); +JFormHelper::loadFieldClass('list'); + +/** + * Targettranslations Form Field class for the Getbible component + */ +class JFormFieldTargettranslations extends JFormFieldList +{ + /** + * The targettranslations field type. + * + * @var string + */ + public $type = 'targettranslations'; + + /** + * Method to get a list of options for a list input. + * + * @return array An array of JHtml options. + */ + protected function getOptions() + { + // Get the user object. + $user = JFactory::getUser(); + // Get the databse object. + $db = JFactory::getDBO(); + $query = $db->getQuery(true); + $query->select($db->quoteName(array('a.abbreviation','a.translation'),array('abbreviation','abbreviation_translation'))); + $query->from($db->quoteName('#__getbible_translation', 'a')); + $query->where($db->quoteName('a.published') . ' = 1'); + $query->order('a.translation ASC'); + // Implement View Level Access (if set in table) + if (!$user->authorise('core.options', 'com_getbible')) + { + $columns = $db->getTableColumns('#__getbible_translation'); + if(isset($columns['access'])) + { + $groups = implode(',', $user->getAuthorisedViewLevels()); + $query->where('a.access IN (' . $groups . ')'); + } + } + $db->setQuery((string)$query); + $items = $db->loadObjectList(); + $options = array(); + if ($items) + { + if ($this->multiple === false) + { + $options[] = JHtml::_('select.option', '', JText::_('COM_GETBIBLE_SELECT_AN_OPTION')); + } + $options[] = JHtml::_('select.option', 'all', JText::_('COM_GETBIBLE_ALL_TRANSLATIONS')); + foreach($items as $item) + { + $options[] = JHtml::_('select.option', $item->abbreviation, $item->abbreviation_translation.' (' .$item->abbreviation.')'); + } + } + return $options; + } +} diff --git a/admin/models/fields/translations.php b/admin/models/fields/translations.php new file mode 100644 index 0000000..e2e65d6 --- /dev/null +++ b/admin/models/fields/translations.php @@ -0,0 +1,79 @@ + + @git Get Bible + @github Get Bible + @support Get Bible + @copyright Copyright (C) 2015. All Rights Reserved + @license GNU/GPL Version 2 or later - http://www.gnu.org/licenses/gpl-2.0.html + +/------------------------------------------------------------------------------------------------------*/ + +// No direct access to this file +defined('_JEXEC') or die('Restricted access'); + +// import the list field type +jimport('joomla.form.helper'); +JFormHelper::loadFieldClass('list'); + +/** + * Translations Form Field class for the Getbible component + */ +class JFormFieldTranslations extends JFormFieldList +{ + /** + * The translations field type. + * + * @var string + */ + public $type = 'translations'; + + /** + * Method to get a list of options for a list input. + * + * @return array An array of JHtml options. + */ + protected function getOptions() + { + // Get the user object. + $user = JFactory::getUser(); + // Get the databse object. + $db = JFactory::getDBO(); + $query = $db->getQuery(true); + $query->select($db->quoteName(array('a.abbreviation','a.translation'),array('abbreviation','abbreviation_translation'))); + $query->from($db->quoteName('#__getbible_translation', 'a')); + $query->where($db->quoteName('a.published') . ' = 1'); + $query->order('a.translation ASC'); + // Implement View Level Access (if set in table) + if (!$user->authorise('core.options', 'com_getbible')) + { + $columns = $db->getTableColumns('#__getbible_translation'); + if(isset($columns['access'])) + { + $groups = implode(',', $user->getAuthorisedViewLevels()); + $query->where('a.access IN (' . $groups . ')'); + } + } + $db->setQuery((string)$query); + $items = $db->loadObjectList(); + $options = array(); + if ($items) + { + if ($this->multiple === false) + { + $options[] = JHtml::_('select.option', '', JText::_('COM_GETBIBLE_SELECT_AN_OPTION')); + } + foreach($items as $item) + { + $options[] = JHtml::_('select.option', $item->abbreviation, $item->abbreviation_translation.' (' .$item->abbreviation.')'); + } + } + return $options; + } +} diff --git a/admin/models/fields/translationsfilterdirection.php b/admin/models/fields/translationsfilterdirection.php new file mode 100644 index 0000000..23c3d5c --- /dev/null +++ b/admin/models/fields/translationsfilterdirection.php @@ -0,0 +1,77 @@ + + @git Get Bible + @github Get Bible + @support Get Bible + @copyright Copyright (C) 2015. All Rights Reserved + @license GNU/GPL Version 2 or later - http://www.gnu.org/licenses/gpl-2.0.html + +/------------------------------------------------------------------------------------------------------*/ + +// No direct access to this file +defined('_JEXEC') or die('Restricted access'); + +// import the list field type +jimport('joomla.form.helper'); +JFormHelper::loadFieldClass('list'); + +/** + * Translationsfilterdirection Form Field class for the Getbible component + */ +class JFormFieldTranslationsfilterdirection extends JFormFieldList +{ + /** + * The translationsfilterdirection field type. + * + * @var string + */ + public $type = 'translationsfilterdirection'; + + /** + * Method to get a list of options for a list input. + * + * @return array An array of JHtml options. + */ + protected function getOptions() + { + // Get a db connection. + $db = JFactory::getDbo(); + + // Create a new query object. + $query = $db->getQuery(true); + + // Select the text. + $query->select($db->quoteName('direction')); + $query->from($db->quoteName('#__getbible_translation')); + $query->order($db->quoteName('direction') . ' ASC'); + + // Reset the query using our newly populated query object. + $db->setQuery($query); + + $_results = $db->loadColumn(); + $_filter = array(); + $_filter[] = JHtml::_('select.option', '', '- ' . JText::_('COM_GETBIBLE_FILTER_SELECT_DIRECTIONAL') . ' -'); + + if ($_results) + { + // get translationsmodel + $_model = GetbibleHelper::getModel('translations'); + $_results = array_unique($_results); + foreach ($_results as $direction) + { + // Translate the direction selection + $_text = $_model->selectionTranslation($direction,'direction'); + // Now add the direction and its text to the options array + $_filter[] = JHtml::_('select.option', $direction, JText::_($_text)); + } + } + return $_filter; + } +} diff --git a/admin/models/fields/versesfilterbooknr.php b/admin/models/fields/versesfilterbooknr.php new file mode 100644 index 0000000..3a06f5b --- /dev/null +++ b/admin/models/fields/versesfilterbooknr.php @@ -0,0 +1,73 @@ + + @git Get Bible + @github Get Bible + @support Get Bible + @copyright Copyright (C) 2015. All Rights Reserved + @license GNU/GPL Version 2 or later - http://www.gnu.org/licenses/gpl-2.0.html + +/------------------------------------------------------------------------------------------------------*/ + +// No direct access to this file +defined('_JEXEC') or die('Restricted access'); + +// import the list field type +jimport('joomla.form.helper'); +JFormHelper::loadFieldClass('list'); + +/** + * Versesfilterbooknr Form Field class for the Getbible component + */ +class JFormFieldVersesfilterbooknr extends JFormFieldList +{ + /** + * The versesfilterbooknr field type. + * + * @var string + */ + public $type = 'versesfilterbooknr'; + + /** + * Method to get a list of options for a list input. + * + * @return array An array of JHtml options. + */ + protected function getOptions() + { + // Get a db connection. + $db = JFactory::getDbo(); + + // Create a new query object. + $query = $db->getQuery(true); + + // Select the text. + $query->select($db->quoteName('book_nr')); + $query->from($db->quoteName('#__getbible_verse')); + $query->order($db->quoteName('book_nr') . ' ASC'); + + // Reset the query using our newly populated query object. + $db->setQuery($query); + + $_results = $db->loadColumn(); + $_filter = array(); + $_filter[] = JHtml::_('select.option', '', '- ' . JText::_('COM_GETBIBLE_FILTER_SELECT_BOOK_NUMBER') . ' -'); + + if ($_results) + { + $_results = array_unique($_results); + foreach ($_results as $book_nr) + { + // Now add the book_nr and its text to the options array + $_filter[] = JHtml::_('select.option', $book_nr, $book_nr); + } + } + return $_filter; + } +} diff --git a/admin/models/fields/versesfilterchapter.php b/admin/models/fields/versesfilterchapter.php new file mode 100644 index 0000000..757b747 --- /dev/null +++ b/admin/models/fields/versesfilterchapter.php @@ -0,0 +1,73 @@ + + @git Get Bible + @github Get Bible + @support Get Bible + @copyright Copyright (C) 2015. All Rights Reserved + @license GNU/GPL Version 2 or later - http://www.gnu.org/licenses/gpl-2.0.html + +/------------------------------------------------------------------------------------------------------*/ + +// No direct access to this file +defined('_JEXEC') or die('Restricted access'); + +// import the list field type +jimport('joomla.form.helper'); +JFormHelper::loadFieldClass('list'); + +/** + * Versesfilterchapter Form Field class for the Getbible component + */ +class JFormFieldVersesfilterchapter extends JFormFieldList +{ + /** + * The versesfilterchapter field type. + * + * @var string + */ + public $type = 'versesfilterchapter'; + + /** + * Method to get a list of options for a list input. + * + * @return array An array of JHtml options. + */ + protected function getOptions() + { + // Get a db connection. + $db = JFactory::getDbo(); + + // Create a new query object. + $query = $db->getQuery(true); + + // Select the text. + $query->select($db->quoteName('chapter')); + $query->from($db->quoteName('#__getbible_verse')); + $query->order($db->quoteName('chapter') . ' ASC'); + + // Reset the query using our newly populated query object. + $db->setQuery($query); + + $_results = $db->loadColumn(); + $_filter = array(); + $_filter[] = JHtml::_('select.option', '', '- ' . JText::_('COM_GETBIBLE_FILTER_SELECT_CHAPTER') . ' -'); + + if ($_results) + { + $_results = array_unique($_results); + foreach ($_results as $chapter) + { + // Now add the chapter and its text to the options array + $_filter[] = JHtml::_('select.option', $chapter, $chapter); + } + } + return $_filter; + } +} diff --git a/admin/models/fields/versesfilterverse.php b/admin/models/fields/versesfilterverse.php new file mode 100644 index 0000000..dc5bac4 --- /dev/null +++ b/admin/models/fields/versesfilterverse.php @@ -0,0 +1,73 @@ + + @git Get Bible + @github Get Bible + @support Get Bible + @copyright Copyright (C) 2015. All Rights Reserved + @license GNU/GPL Version 2 or later - http://www.gnu.org/licenses/gpl-2.0.html + +/------------------------------------------------------------------------------------------------------*/ + +// No direct access to this file +defined('_JEXEC') or die('Restricted access'); + +// import the list field type +jimport('joomla.form.helper'); +JFormHelper::loadFieldClass('list'); + +/** + * Versesfilterverse Form Field class for the Getbible component + */ +class JFormFieldVersesfilterverse extends JFormFieldList +{ + /** + * The versesfilterverse field type. + * + * @var string + */ + public $type = 'versesfilterverse'; + + /** + * Method to get a list of options for a list input. + * + * @return array An array of JHtml options. + */ + protected function getOptions() + { + // Get a db connection. + $db = JFactory::getDbo(); + + // Create a new query object. + $query = $db->getQuery(true); + + // Select the text. + $query->select($db->quoteName('verse')); + $query->from($db->quoteName('#__getbible_verse')); + $query->order($db->quoteName('verse') . ' ASC'); + + // Reset the query using our newly populated query object. + $db->setQuery($query); + + $_results = $db->loadColumn(); + $_filter = array(); + $_filter[] = JHtml::_('select.option', '', '- ' . JText::_('COM_GETBIBLE_FILTER_SELECT_VERSE') . ' -'); + + if ($_results) + { + $_results = array_unique($_results); + foreach ($_results as $verse) + { + // Now add the verse and its text to the options array + $_filter[] = JHtml::_('select.option', $verse, $verse); + } + } + return $_filter; + } +} diff --git a/admin/models/forms/book.xml b/admin/models/forms/book.xml new file mode 100644 index 0000000..637d005 --- /dev/null +++ b/admin/models/forms/book.xml @@ -0,0 +1,184 @@ + +
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ + +
+ + + + +
+
\ No newline at end of file diff --git a/admin/models/forms/chapter.xml b/admin/models/forms/chapter.xml new file mode 100644 index 0000000..04ebb2a --- /dev/null +++ b/admin/models/forms/chapter.xml @@ -0,0 +1,196 @@ + +
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ + +
+ + + + +
+
\ No newline at end of file diff --git a/admin/models/forms/filter_books.xml b/admin/models/forms/filter_books.xml new file mode 100644 index 0000000..7d73d57 --- /dev/null +++ b/admin/models/forms/filter_books.xml @@ -0,0 +1,92 @@ + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
\ No newline at end of file diff --git a/admin/models/forms/filter_chapters.xml b/admin/models/forms/filter_chapters.xml new file mode 100644 index 0000000..8416068 --- /dev/null +++ b/admin/models/forms/filter_chapters.xml @@ -0,0 +1,96 @@ + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
\ No newline at end of file diff --git a/admin/models/forms/filter_linkers.xml b/admin/models/forms/filter_linkers.xml new file mode 100644 index 0000000..a0dcc2b --- /dev/null +++ b/admin/models/forms/filter_linkers.xml @@ -0,0 +1,74 @@ + +
+ + + + + + + + + + + + + + + + + + + + + + + + + +
\ No newline at end of file diff --git a/admin/models/forms/filter_notes.xml b/admin/models/forms/filter_notes.xml new file mode 100644 index 0000000..eb993ae --- /dev/null +++ b/admin/models/forms/filter_notes.xml @@ -0,0 +1,97 @@ + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
\ No newline at end of file diff --git a/admin/models/forms/filter_open_ai_messages.xml b/admin/models/forms/filter_open_ai_messages.xml new file mode 100644 index 0000000..e063789 --- /dev/null +++ b/admin/models/forms/filter_open_ai_messages.xml @@ -0,0 +1,101 @@ + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
\ No newline at end of file diff --git a/admin/models/forms/filter_open_ai_responses.xml b/admin/models/forms/filter_open_ai_responses.xml new file mode 100644 index 0000000..d202ba3 --- /dev/null +++ b/admin/models/forms/filter_open_ai_responses.xml @@ -0,0 +1,96 @@ + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
\ No newline at end of file diff --git a/admin/models/forms/filter_passwords.xml b/admin/models/forms/filter_passwords.xml new file mode 100644 index 0000000..4e85b64 --- /dev/null +++ b/admin/models/forms/filter_passwords.xml @@ -0,0 +1,83 @@ + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + +
\ No newline at end of file diff --git a/admin/models/forms/filter_prompts.xml b/admin/models/forms/filter_prompts.xml new file mode 100644 index 0000000..5e4de04 --- /dev/null +++ b/admin/models/forms/filter_prompts.xml @@ -0,0 +1,101 @@ + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
\ No newline at end of file diff --git a/admin/models/forms/filter_tagged_verses.xml b/admin/models/forms/filter_tagged_verses.xml new file mode 100644 index 0000000..e2b8cc8 --- /dev/null +++ b/admin/models/forms/filter_tagged_verses.xml @@ -0,0 +1,119 @@ + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
\ No newline at end of file diff --git a/admin/models/forms/filter_tags.xml b/admin/models/forms/filter_tags.xml new file mode 100644 index 0000000..3e20fac --- /dev/null +++ b/admin/models/forms/filter_tags.xml @@ -0,0 +1,76 @@ + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
\ No newline at end of file diff --git a/admin/models/forms/filter_translations.xml b/admin/models/forms/filter_translations.xml new file mode 100644 index 0000000..7c772f2 --- /dev/null +++ b/admin/models/forms/filter_translations.xml @@ -0,0 +1,80 @@ + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
\ No newline at end of file diff --git a/admin/models/forms/filter_verses.xml b/admin/models/forms/filter_verses.xml new file mode 100644 index 0000000..cdaccbf --- /dev/null +++ b/admin/models/forms/filter_verses.xml @@ -0,0 +1,101 @@ + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
\ No newline at end of file diff --git a/admin/models/forms/index.html b/admin/models/forms/index.html new file mode 100644 index 0000000..fa6d84e --- /dev/null +++ b/admin/models/forms/index.html @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/admin/models/forms/linker.xml b/admin/models/forms/linker.xml new file mode 100644 index 0000000..6996ada --- /dev/null +++ b/admin/models/forms/linker.xml @@ -0,0 +1,148 @@ + +
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ + +
+ + + + +
+
\ No newline at end of file diff --git a/admin/models/forms/note.xml b/admin/models/forms/note.xml new file mode 100644 index 0000000..637b0f6 --- /dev/null +++ b/admin/models/forms/note.xml @@ -0,0 +1,200 @@ + +
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ + +
+ + + + +
+
\ No newline at end of file diff --git a/admin/models/forms/open_ai_message.xml b/admin/models/forms/open_ai_message.xml new file mode 100644 index 0000000..8b344ae --- /dev/null +++ b/admin/models/forms/open_ai_message.xml @@ -0,0 +1,212 @@ + +
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ + +
+ + + + +
+
\ No newline at end of file diff --git a/admin/models/forms/open_ai_response.xml b/admin/models/forms/open_ai_response.xml new file mode 100644 index 0000000..d321225 --- /dev/null +++ b/admin/models/forms/open_ai_response.xml @@ -0,0 +1,419 @@ + +
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ + +
+ + + + +
+
\ No newline at end of file diff --git a/admin/models/forms/password.xml b/admin/models/forms/password.xml new file mode 100644 index 0000000..9617f3e --- /dev/null +++ b/admin/models/forms/password.xml @@ -0,0 +1,174 @@ + +
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ + +
+ + + + +
+
\ No newline at end of file diff --git a/admin/models/forms/prompt.xml b/admin/models/forms/prompt.xml new file mode 100644 index 0000000..317ad61 --- /dev/null +++ b/admin/models/forms/prompt.xml @@ -0,0 +1,571 @@ + +
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ + +
+ + + + +
+ \ No newline at end of file diff --git a/admin/models/forms/tag.xml b/admin/models/forms/tag.xml new file mode 100644 index 0000000..a65e7f4 --- /dev/null +++ b/admin/models/forms/tag.xml @@ -0,0 +1,178 @@ + +
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ + +
+ + + + +
+
\ No newline at end of file diff --git a/admin/models/forms/tagged_verse.xml b/admin/models/forms/tagged_verse.xml new file mode 100644 index 0000000..c19c1e3 --- /dev/null +++ b/admin/models/forms/tagged_verse.xml @@ -0,0 +1,209 @@ + +
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ + +
+ + + + +
+
\ No newline at end of file diff --git a/admin/models/forms/translation.xml b/admin/models/forms/translation.xml new file mode 100644 index 0000000..c253374 --- /dev/null +++ b/admin/models/forms/translation.xml @@ -0,0 +1,415 @@ + +
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ + +
+ + + + +
+ \ No newline at end of file diff --git a/admin/models/forms/verse.xml b/admin/models/forms/verse.xml new file mode 100644 index 0000000..19d7c39 --- /dev/null +++ b/admin/models/forms/verse.xml @@ -0,0 +1,209 @@ + +
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ + +
+ + + + +
+
\ No newline at end of file diff --git a/admin/models/getbible.php b/admin/models/getbible.php new file mode 100644 index 0000000..a676612 --- /dev/null +++ b/admin/models/getbible.php @@ -0,0 +1,431 @@ + + @git Get Bible + @github Get Bible + @support Get Bible + @copyright Copyright (C) 2015. All Rights Reserved + @license GNU/GPL Version 2 or later - http://www.gnu.org/licenses/gpl-2.0.html + +/------------------------------------------------------------------------------------------------------*/ + +// No direct access to this file +defined('_JEXEC') or die('Restricted access'); + +use Joomla\CMS\MVC\Model\ListModel; +use Joomla\Utilities\ArrayHelper; +use Joomla\Registry\Registry; + +/** + * Getbible List Model + */ +class GetbibleModelGetbible extends ListModel +{ + public function getIcons() + { + // load user for access menus + $user = JFactory::getUser(); + // reset icon array + $icons = array(); + // view groups array + $viewGroups = array( + 'main' => array('png.linkers', 'png.notes', 'png.tagged_verses', 'png.prompts', 'png.open_ai_responses', 'png.tags', 'png.translations', 'png.books', 'png.chapters', 'png.verses') + ); + // view access array + $viewAccess = array( + 'linker.create' => 'linker.create', + 'linkers.access' => 'linker.access', + 'linker.access' => 'linker.access', + 'linkers.submenu' => 'linker.submenu', + 'linkers.dashboard_list' => 'linker.dashboard_list', + 'note.create' => 'note.create', + 'notes.access' => 'note.access', + 'note.access' => 'note.access', + 'notes.submenu' => 'note.submenu', + 'notes.dashboard_list' => 'note.dashboard_list', + 'tagged_verse.create' => 'tagged_verse.create', + 'tagged_verses.access' => 'tagged_verse.access', + 'tagged_verse.access' => 'tagged_verse.access', + 'tagged_verses.submenu' => 'tagged_verse.submenu', + 'tagged_verses.dashboard_list' => 'tagged_verse.dashboard_list', + 'prompt.create' => 'prompt.create', + 'prompts.access' => 'prompt.access', + 'prompt.access' => 'prompt.access', + 'prompts.submenu' => 'prompt.submenu', + 'prompts.dashboard_list' => 'prompt.dashboard_list', + 'open_ai_response.create' => 'open_ai_response.create', + 'open_ai_responses.access' => 'open_ai_response.access', + 'open_ai_response.access' => 'open_ai_response.access', + 'open_ai_responses.submenu' => 'open_ai_response.submenu', + 'open_ai_responses.dashboard_list' => 'open_ai_response.dashboard_list', + 'open_ai_message.create' => 'open_ai_message.create', + 'open_ai_messages.access' => 'open_ai_message.access', + 'open_ai_message.access' => 'open_ai_message.access', + 'password.create' => 'password.create', + 'passwords.access' => 'password.access', + 'password.access' => 'password.access', + 'tag.create' => 'tag.create', + 'tags.access' => 'tag.access', + 'tag.access' => 'tag.access', + 'tags.submenu' => 'tag.submenu', + 'tags.dashboard_list' => 'tag.dashboard_list', + 'translation.create' => 'translation.create', + 'translations.access' => 'translation.access', + 'translation.access' => 'translation.access', + 'translations.submenu' => 'translation.submenu', + 'translations.dashboard_list' => 'translation.dashboard_list', + 'book.create' => 'book.create', + 'books.access' => 'book.access', + 'book.access' => 'book.access', + 'books.submenu' => 'book.submenu', + 'books.dashboard_list' => 'book.dashboard_list', + 'chapter.create' => 'chapter.create', + 'chapters.access' => 'chapter.access', + 'chapter.access' => 'chapter.access', + 'chapters.submenu' => 'chapter.submenu', + 'chapters.dashboard_list' => 'chapter.dashboard_list', + 'verse.create' => 'verse.create', + 'verses.access' => 'verse.access', + 'verse.access' => 'verse.access', + 'verses.submenu' => 'verse.submenu', + 'verses.dashboard_list' => 'verse.dashboard_list'); + // loop over the $views + foreach($viewGroups as $group => $views) + { + $i = 0; + if (GetbibleHelper::checkArray($views)) + { + foreach($views as $view) + { + $add = false; + // external views (links) + if (strpos($view,'||') !== false) + { + $dwd = explode('||', $view); + if (count($dwd) == 3) + { + list($type, $name, $url) = $dwd; + $viewName = $name; + $alt = $name; + $url = $url; + $image = $name . '.' . $type; + $name = 'COM_GETBIBLE_DASHBOARD_' . GetbibleHelper::safeString($name,'U'); + } + } + // internal views + elseif (strpos($view,'.') !== false) + { + $dwd = explode('.', $view); + if (count($dwd) == 3) + { + list($type, $name, $action) = $dwd; + } + elseif (count($dwd) == 2) + { + list($type, $name) = $dwd; + $action = false; + } + if ($action) + { + $viewName = $name; + switch($action) + { + case 'add': + $url = 'index.php?option=com_getbible&view=' . $name . '&layout=edit'; + $image = $name . '_' . $action. '.' . $type; + $alt = $name . ' ' . $action; + $name = 'COM_GETBIBLE_DASHBOARD_'.GetbibleHelper::safeString($name,'U').'_ADD'; + $add = true; + break; + default: + // check for new convention (more stable) + if (strpos($action, '_qpo0O0oqp_') !== false) + { + list($action, $extension) = (array) explode('_qpo0O0oqp_', $action); + $extension = str_replace('_po0O0oq_', '.', $extension); + } + else + { + $extension = 'com_getbible.' . $name; + } + $url = 'index.php?option=com_categories&view=categories&extension=' . $extension; + $image = $name . '_' . $action . '.' . $type; + $alt = $viewName . ' ' . $action; + $name = 'COM_GETBIBLE_DASHBOARD_' . GetbibleHelper::safeString($name,'U') . '_' . GetbibleHelper::safeString($action,'U'); + break; + } + } + else + { + $viewName = $name; + $alt = $name; + $url = 'index.php?option=com_getbible&view=' . $name; + $image = $name . '.' . $type; + $name = 'COM_GETBIBLE_DASHBOARD_' . GetbibleHelper::safeString($name,'U'); + $hover = false; + } + } + else + { + $viewName = $view; + $alt = $view; + $url = 'index.php?option=com_getbible&view=' . $view; + $image = $view . '.png'; + $name = ucwords($view).'

'; + $hover = false; + } + // first make sure the view access is set + if (GetbibleHelper::checkArray($viewAccess)) + { + // setup some defaults + $dashboard_add = false; + $dashboard_list = false; + $accessTo = ''; + $accessAdd = ''; + // access checking start + $accessCreate = (isset($viewAccess[$viewName.'.create'])) ? GetbibleHelper::checkString($viewAccess[$viewName.'.create']):false; + $accessAccess = (isset($viewAccess[$viewName.'.access'])) ? GetbibleHelper::checkString($viewAccess[$viewName.'.access']):false; + // set main controllers + $accessDashboard_add = (isset($viewAccess[$viewName.'.dashboard_add'])) ? GetbibleHelper::checkString($viewAccess[$viewName.'.dashboard_add']):false; + $accessDashboard_list = (isset($viewAccess[$viewName.'.dashboard_list'])) ? GetbibleHelper::checkString($viewAccess[$viewName.'.dashboard_list']):false; + // check for adding access + if ($add && $accessCreate) + { + $accessAdd = $viewAccess[$viewName.'.create']; + } + elseif ($add) + { + $accessAdd = 'core.create'; + } + // check if access to view is set + if ($accessAccess) + { + $accessTo = $viewAccess[$viewName.'.access']; + } + // set main access controllers + if ($accessDashboard_add) + { + $dashboard_add = $user->authorise($viewAccess[$viewName.'.dashboard_add'], 'com_getbible'); + } + if ($accessDashboard_list) + { + $dashboard_list = $user->authorise($viewAccess[$viewName.'.dashboard_list'], 'com_getbible'); + } + if (GetbibleHelper::checkString($accessAdd) && GetbibleHelper::checkString($accessTo)) + { + // check access + if($user->authorise($accessAdd, 'com_getbible') && $user->authorise($accessTo, 'com_getbible') && $dashboard_add) + { + $icons[$group][$i] = new StdClass; + $icons[$group][$i]->url = $url; + $icons[$group][$i]->name = $name; + $icons[$group][$i]->image = $image; + $icons[$group][$i]->alt = $alt; + } + } + elseif (GetbibleHelper::checkString($accessTo)) + { + // check access + if($user->authorise($accessTo, 'com_getbible') && $dashboard_list) + { + $icons[$group][$i] = new StdClass; + $icons[$group][$i]->url = $url; + $icons[$group][$i]->name = $name; + $icons[$group][$i]->image = $image; + $icons[$group][$i]->alt = $alt; + } + } + elseif (GetbibleHelper::checkString($accessAdd)) + { + // check access + if($user->authorise($accessAdd, 'com_getbible') && $dashboard_add) + { + $icons[$group][$i] = new StdClass; + $icons[$group][$i]->url = $url; + $icons[$group][$i]->name = $name; + $icons[$group][$i]->image = $image; + $icons[$group][$i]->alt = $alt; + } + } + else + { + $icons[$group][$i] = new StdClass; + $icons[$group][$i]->url = $url; + $icons[$group][$i]->name = $name; + $icons[$group][$i]->image = $image; + $icons[$group][$i]->alt = $alt; + } + } + else + { + $icons[$group][$i] = new StdClass; + $icons[$group][$i]->url = $url; + $icons[$group][$i]->name = $name; + $icons[$group][$i]->image = $image; + $icons[$group][$i]->alt = $alt; + } + $i++; + } + } + else + { + $icons[$group][$i] = false; + } + } + return $icons; + } + + + public function getWiki() + { + // the call URL + $call_url = JUri::base() . 'index.php?option=com_getbible&task=ajax.getWiki&format=json&raw=true&' . JSession::getFormToken() . '=1&name=Home'; + $document = JFactory::getDocument(); + $document->addScriptDeclaration(' + function getWikiPage(){ + + fetch("' . $call_url . '").then((response) => { + if (response.ok) { + return response.json(); + } + }).then((result) => { + if (typeof result.page !== "undefined") { + document.getElementById("wiki-md").innerHTML = result.page; + } else if (typeof result.error !== "undefined") { + document.getElementById("wiki-md-error").innerHTML = result.error + } + }); + } + setTimeout(getWikiPage, 1000);'); + + return '
'.JText::_('COM_GETBIBLE_THE_WIKI_IS_LOADING').'..
'; + } + + + public function getNoticeboard() + { + // get the document to load the scripts + $document = JFactory::getDocument(); + $document->addScript(JURI::root() . "media/com_getbible/js/marked.js"); + $document->addScriptDeclaration(' + var token = "'.JSession::getFormToken().'"; + var noticeboard = "https://vdm.bz/getbible-noticeboard-md"; + jQuery(document).ready(function () { + jQuery.get(noticeboard) + .success(function(board) { + if (board.length > 5) { + jQuery("#noticeboard-md").html(marked.parse(board)); + getIS(1,board).done(function(result) { + if (result){ + jQuery("#cpanel_tabTabs a").each(function() { + if (this.href.indexOf("#vast_development_method") >= 0 || this.href.indexOf("#notice_board") >= 0) { + var textVDM = jQuery(this).text(); + jQuery(this).html("1 "+textVDM); + jQuery(this).attr("id","vdm-new-notice"); + jQuery("#vdm-new-notice").click(function() { + getIS(2,board).done(function(result) { + if (result) { + jQuery(".vdm-new-notice").fadeOut(500); + } + }); + }); + } + }); + } + }); + } else { + jQuery("#noticeboard-md").html("'.JText::_('COM_GETBIBLE_ALL_IS_GOOD_PLEASE_CHECK_AGAIN_LATTER').'"); + } + }) + .error(function(jqXHR, textStatus, errorThrown) { + jQuery("#noticeboard-md").html("'.JText::_('COM_GETBIBLE_ALL_IS_GOOD_PLEASE_CHECK_AGAIN_LATTER').'"); + }); + }); + // to check is READ/NEW + function getIS(type,notice){ + if(type == 1){ + var getUrl = "index.php?option=com_getbible&task=ajax.isNew&format=json&raw=true"; + } else if (type == 2) { + var getUrl = "index.php?option=com_getbible&task=ajax.isRead&format=json&raw=true"; + } + if(token.length > 0 && notice.length){ + var request = token+"=1¬ice="+notice; + } + return jQuery.ajax({ + type: "POST", + url: getUrl, + dataType: "json", + data: request, + jsonp: false + }); + } + +// nice little dot trick :) +jQuery(document).ready( function($) { + var x=0; + setInterval(function() { + var dots = ""; + x++; + for (var y=0; y < x%8; y++) { + dots+="."; + } + $(".loading-dots").text(dots); + } , 500); +});'); + + return '
'.JText::_('COM_GETBIBLE_THE_NOTICE_BOARD_IS_LOADING').'..
'; + } + + public function getReadme() + { + $document = JFactory::getDocument(); + $document->addScriptDeclaration(' + var getreadme = "'. JURI::root() . 'administrator/components/com_getbible/README.txt"; + jQuery(document).ready(function () { + jQuery.get(getreadme) + .success(function(readme) { + jQuery("#readme-md").html(marked.parse(readme)); + }) + .error(function(jqXHR, textStatus, errorThrown) { + jQuery("#readme-md").html("'.JText::_('COM_GETBIBLE_PLEASE_CHECK_AGAIN_LATTER').'"); + }); + });'); + + return '
'.JText::_('COM_GETBIBLE_THE_README_IS_LOADING').'..
'; + } + + /** + * get Current Version Bay adding JavaScript to the Page + * + * @return void + * @since 2.3.0 + */ + public function getVersion() + { + // the call URL + $call_url = JUri::base() . 'index.php?option=com_getbible&task=ajax.getVersion&format=json&raw=true&' . JSession::getFormToken() . '=1&version=1'; + $document = JFactory::getDocument(); + $document->addScriptDeclaration(' + function getComponentVersionStatus() { + fetch("' . $call_url . '").then((response) => { + if (response.ok) { + return response.json(); + } + }).then((result) => { + if (typeof result.notice !== "undefined") { + document.getElementById("component-update-notice").innerHTML = result.notice; + } else if (typeof result.error !== "undefined") { + document.getElementById("component-update-notice").innerHTML = result.error; + } + }); + } + setTimeout(getComponentVersionStatus, 800);'); + } + +} diff --git a/admin/models/index.html b/admin/models/index.html new file mode 100644 index 0000000..fa6d84e --- /dev/null +++ b/admin/models/index.html @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/admin/models/linker.php b/admin/models/linker.php new file mode 100644 index 0000000..7c018aa --- /dev/null +++ b/admin/models/linker.php @@ -0,0 +1,1280 @@ + + @git Get Bible + @github Get Bible + @support Get Bible + @copyright Copyright (C) 2015. All Rights Reserved + @license GNU/GPL Version 2 or later - http://www.gnu.org/licenses/gpl-2.0.html + +/------------------------------------------------------------------------------------------------------*/ + +// No direct access to this file +defined('_JEXEC') or die('Restricted access'); + +use Joomla\CMS\MVC\Model\AdminModel; +use Joomla\Registry\Registry; +use Joomla\String\StringHelper; +use Joomla\Utilities\ArrayHelper; +use VDM\Joomla\Utilities\GuidHelper; +use VDM\Joomla\Utilities\GetHelper; + +/** + * Getbible Linker Admin Model + */ +class GetbibleModelLinker extends AdminModel +{ + /** + * The tab layout fields array. + * + * @var array + */ + protected $tabLayoutFields = array( + 'details' => array( + 'left' => array( + 'name' + ) + ) + ); + + /** + * @var string The prefix to use with controller messages. + * @since 1.6 + */ + protected $text_prefix = 'COM_GETBIBLE'; + + /** + * The type alias for this content type. + * + * @var string + * @since 3.2 + */ + public $typeAlias = 'com_getbible.linker'; + + /** + * Returns a Table object, always creating it + * + * @param type $type The table type to instantiate + * @param string $prefix A prefix for the table class name. Optional. + * @param array $config Configuration array for model. Optional. + * + * @return JTable A database object + * + * @since 1.6 + */ + public function getTable($type = 'linker', $prefix = 'GetbibleTable', $config = array()) + { + // add table path for when model gets used from other component + $this->addTablePath(JPATH_ADMINISTRATOR . '/components/com_getbible/tables'); + // get instance of the table + return JTable::getInstance($type, $prefix, $config); + } + + /** + * Method to get a single record. + * + * @param integer $pk The id of the primary key. + * + * @return mixed Object on success, false on failure. + * + * @since 1.6 + */ + public function getItem($pk = null) + { + if ($item = parent::getItem($pk)) + { + if (!empty($item->params) && !is_array($item->params)) + { + // Convert the params field to an array. + $registry = new Registry; + $registry->loadString($item->params); + $item->params = $registry->toArray(); + } + + if (!empty($item->metadata)) + { + // Convert the metadata field to an array. + $registry = new Registry; + $registry->loadString($item->metadata); + $item->metadata = $registry->toArray(); + } + } + $this->linkervvvv = $item->guid; + $this->linkervvvw = $item->guid; + $this->linkervvvx = $item->guid; + + return $item; + } + + /** + * Method to get list data. + * + * @return mixed An array of data items on success, false on failure. + */ + public function getVvvtags() + { + // Get the user object. + $user = JFactory::getUser(); + // Create a new query object. + $db = JFactory::getDBO(); + $query = $db->getQuery(true); + + // Select some fields + $query->select('a.*'); + + // From the getbible_tagged_verse table + $query->from($db->quoteName('#__getbible_tagged_verse', 'a')); + + // From the getbible_translation table. + $query->select($db->quoteName(['g.translation','g.id'],['abbreviation_translation','abbreviation_id'])); + $query->join('LEFT', $db->quoteName('#__getbible_translation', 'g') . ' ON (' . $db->quoteName('a.abbreviation') . ' = ' . $db->quoteName('g.abbreviation') . ')'); + + // From the getbible_linker table. + $query->select($db->quoteName(['h.name','h.id'],['linker_name','linker_id'])); + $query->join('LEFT', $db->quoteName('#__getbible_linker', 'h') . ' ON (' . $db->quoteName('a.linker') . ' = ' . $db->quoteName('h.guid') . ')'); + + // From the getbible_tag table. + $query->select($db->quoteName(['i.name','i.id'],['tag_name','tag_id'])); + $query->join('LEFT', $db->quoteName('#__getbible_tag', 'i') . ' ON (' . $db->quoteName('a.tag') . ' = ' . $db->quoteName('i.guid') . ')'); + + // Filter by linkervvvv global. + $linkervvvv = $this->linkervvvv; + if (is_numeric($linkervvvv )) + { + $query->where('a.linker = ' . (int) $linkervvvv ); + } + elseif (is_string($linkervvvv)) + { + $query->where('a.linker = ' . $db->quote($linkervvvv)); + } + else + { + $query->where('a.linker = -5'); + } + + // Join over the asset groups. + $query->select('ag.title AS access_level'); + $query->join('LEFT', '#__viewlevels AS ag ON ag.id = a.access'); + // Implement View Level Access + if (!$user->authorise('core.options', 'com_getbible')) + { + $groups = implode(',', $user->getAuthorisedViewLevels()); + $query->where('a.access IN (' . $groups . ')'); + } + + // Order the results by ordering + $query->order('a.published ASC'); + $query->order('a.ordering ASC'); + + // Load the items + $db->setQuery($query); + $db->execute(); + if ($db->getNumRows()) + { + $items = $db->loadObjectList(); + + // Set values to display correctly. + if (GetbibleHelper::checkArray($items)) + { + // Get the user object if not set. + if (!isset($user) || !GetbibleHelper::checkObject($user)) + { + $user = JFactory::getUser(); + } + foreach ($items as $nr => &$item) + { + // Remove items the user can't access. + $access = ($user->authorise('tagged_verse.access', 'com_getbible.tagged_verse.' . (int) $item->id) && $user->authorise('tagged_verse.access', 'com_getbible')); + if (!$access) + { + unset($items[$nr]); + continue; + } + + $item->book_nr = $item->book_nr . ' ' . $item->chapter . ':' . $item->verse; + } + } + + // set selection value to a translatable value + if (GetbibleHelper::checkArray($items)) + { + foreach ($items as $nr => &$item) + { + // convert access + $item->access = $this->selectionTranslationVvvtags($item->access, 'access'); + } + } + + return $items; + } + return false; + } + + /** + * Method to convert selection values to translatable string. + * + * @return translatable string + */ + public function selectionTranslationVvvtags($value,$name) + { + // Array of access language strings + if ($name === 'access') + { + $accessArray = array( + 1 => 'COM_GETBIBLE_TAGGED_VERSE_PUBLIC', + 0 => 'COM_GETBIBLE_TAGGED_VERSE_PRIVATE' + ); + // Now check if value is found in this array + if (isset($accessArray[$value]) && GetbibleHelper::checkString($accessArray[$value])) + { + return $accessArray[$value]; + } + } + return $value; + } + + /** + * Method to get list data. + * + * @return mixed An array of data items on success, false on failure. + */ + public function getVvwnotes() + { + // Get the user object. + $user = JFactory::getUser(); + // Create a new query object. + $db = JFactory::getDBO(); + $query = $db->getQuery(true); + + // Select some fields + $query->select('a.*'); + + // From the getbible_note table + $query->from($db->quoteName('#__getbible_note', 'a')); + + // From the getbible_linker table. + $query->select($db->quoteName(['g.name','g.id'],['linker_name','linker_id'])); + $query->join('LEFT', $db->quoteName('#__getbible_linker', 'g') . ' ON (' . $db->quoteName('a.linker') . ' = ' . $db->quoteName('g.guid') . ')'); + + // Filter by linkervvvw global. + $linkervvvw = $this->linkervvvw; + if (is_numeric($linkervvvw )) + { + $query->where('a.linker = ' . (int) $linkervvvw ); + } + elseif (is_string($linkervvvw)) + { + $query->where('a.linker = ' . $db->quote($linkervvvw)); + } + else + { + $query->where('a.linker = -5'); + } + + // Join over the asset groups. + $query->select('ag.title AS access_level'); + $query->join('LEFT', '#__viewlevels AS ag ON ag.id = a.access'); + // Implement View Level Access + if (!$user->authorise('core.options', 'com_getbible')) + { + $groups = implode(',', $user->getAuthorisedViewLevels()); + $query->where('a.access IN (' . $groups . ')'); + } + + // Order the results by ordering + $query->order('a.published ASC'); + $query->order('a.ordering ASC'); + + // Load the items + $db->setQuery($query); + $db->execute(); + if ($db->getNumRows()) + { + $items = $db->loadObjectList(); + + // Set values to display correctly. + if (GetbibleHelper::checkArray($items)) + { + // Get the user object if not set. + if (!isset($user) || !GetbibleHelper::checkObject($user)) + { + $user = JFactory::getUser(); + } + foreach ($items as $nr => &$item) + { + // Remove items the user can't access. + $access = ($user->authorise('note.access', 'com_getbible.note.' . (int) $item->id) && $user->authorise('note.access', 'com_getbible')); + if (!$access) + { + unset($items[$nr]); + continue; + } + + $item->book_nr = $item->book_nr . ' ' . $item->chapter . ':' . $item->verse; + } + } + + // set selection value to a translatable value + if (GetbibleHelper::checkArray($items)) + { + foreach ($items as $nr => &$item) + { + // convert access + $item->access = $this->selectionTranslationVvwnotes($item->access, 'access'); + } + } + + return $items; + } + return false; + } + + /** + * Method to convert selection values to translatable string. + * + * @return translatable string + */ + public function selectionTranslationVvwnotes($value,$name) + { + // Array of access language strings + if ($name === 'access') + { + $accessArray = array( + 1 => 'COM_GETBIBLE_NOTE_PUBLIC', + 0 => 'COM_GETBIBLE_NOTE_PRIVATE' + ); + // Now check if value is found in this array + if (isset($accessArray[$value]) && GetbibleHelper::checkString($accessArray[$value])) + { + return $accessArray[$value]; + } + } + return $value; + } + + /** + * Method to get list data. + * + * @return mixed An array of data items on success, false on failure. + */ + public function getVvxpasswords() + { + // Get the user object. + $user = JFactory::getUser(); + // Create a new query object. + $db = JFactory::getDBO(); + $query = $db->getQuery(true); + + // Select some fields + $query->select('a.*'); + + // From the getbible_password table + $query->from($db->quoteName('#__getbible_password', 'a')); + + // From the getbible_linker table. + $query->select($db->quoteName(['g.name','g.id'],['linker_name','linker_id'])); + $query->join('LEFT', $db->quoteName('#__getbible_linker', 'g') . ' ON (' . $db->quoteName('a.linker') . ' = ' . $db->quoteName('g.guid') . ')'); + + // Filter by linkervvvx global. + $linkervvvx = $this->linkervvvx; + if (is_numeric($linkervvvx )) + { + $query->where('a.linker = ' . (int) $linkervvvx ); + } + elseif (is_string($linkervvvx)) + { + $query->where('a.linker = ' . $db->quote($linkervvvx)); + } + else + { + $query->where('a.linker = -5'); + } + + // Join over the asset groups. + $query->select('ag.title AS access_level'); + $query->join('LEFT', '#__viewlevels AS ag ON ag.id = a.access'); + // Filter by access level. + $_access = $this->getState('filter.access'); + if ($_access && is_numeric($_access)) + { + $query->where('a.access = ' . (int) $_access); + } + elseif (GetbibleHelper::checkArray($_access)) + { + // Secure the array for the query + $_access = ArrayHelper::toInteger($_access); + // Filter by the Access Array. + $query->where('a.access IN (' . implode(',', $_access) . ')'); + } + // Implement View Level Access + if (!$user->authorise('core.options', 'com_getbible')) + { + $groups = implode(',', $user->getAuthorisedViewLevels()); + $query->where('a.access IN (' . $groups . ')'); + } + + // Order the results by ordering + $query->order('a.published ASC'); + $query->order('a.ordering ASC'); + + // Load the items + $db->setQuery($query); + $db->execute(); + if ($db->getNumRows()) + { + $items = $db->loadObjectList(); + + // Set values to display correctly. + if (GetbibleHelper::checkArray($items)) + { + // Get the user object if not set. + if (!isset($user) || !GetbibleHelper::checkObject($user)) + { + $user = JFactory::getUser(); + } + foreach ($items as $nr => &$item) + { + // Remove items the user can't access. + $access = ($user->authorise('password.access', 'com_getbible.password.' . (int) $item->id) && $user->authorise('password.access', 'com_getbible')); + if (!$access) + { + unset($items[$nr]); + continue; + } + + } + } + return $items; + } + return false; + } + + /** + * Method to get the record form. + * + * @param array $data Data for the form. + * @param boolean $loadData True if the form is to load its own data (default case), false if not. + * @param array $options Optional array of options for the form creation. + * + * @return mixed A JForm object on success, false on failure + * + * @since 1.6 + */ + public function getForm($data = array(), $loadData = true, $options = array('control' => 'jform')) + { + // set load data option + $options['load_data'] = $loadData; + // check if xpath was set in options + $xpath = false; + if (isset($options['xpath'])) + { + $xpath = $options['xpath']; + unset($options['xpath']); + } + // check if clear form was set in options + $clear = false; + if (isset($options['clear'])) + { + $clear = $options['clear']; + unset($options['clear']); + } + + // Get the form. + $form = $this->loadForm('com_getbible.linker', 'linker', $options, $clear, $xpath); + + if (empty($form)) + { + return false; + } + + $jinput = JFactory::getApplication()->input; + + // The front end calls this model and uses a_id to avoid id clashes so we need to check for that first. + if ($jinput->get('a_id')) + { + $id = $jinput->get('a_id', 0, 'INT'); + } + // The back end uses id so we use that the rest of the time and set it to 0 by default. + else + { + $id = $jinput->get('id', 0, 'INT'); + } + + $user = JFactory::getUser(); + + // Check for existing item. + // Modify the form based on Edit State access controls. + if ($id != 0 && (!$user->authorise('linker.edit.state', 'com_getbible.linker.' . (int) $id)) + || ($id == 0 && !$user->authorise('linker.edit.state', 'com_getbible'))) + { + // Disable fields for display. + $form->setFieldAttribute('ordering', 'disabled', 'true'); + $form->setFieldAttribute('published', 'disabled', 'true'); + // Disable fields while saving. + $form->setFieldAttribute('ordering', 'filter', 'unset'); + $form->setFieldAttribute('published', 'filter', 'unset'); + } + // If this is a new item insure the greated by is set. + if (0 == $id) + { + // Set the created_by to this user + $form->setValue('created_by', null, $user->id); + } + // Modify the form based on Edit Creaded By access controls. + if ($id != 0 && (!$user->authorise('linker.edit.created_by', 'com_getbible.linker.' . (int) $id)) + || ($id == 0 && !$user->authorise('linker.edit.created_by', 'com_getbible'))) + { + // Disable fields for display. + $form->setFieldAttribute('created_by', 'disabled', 'true'); + // Disable fields for display. + $form->setFieldAttribute('created_by', 'readonly', 'true'); + // Disable fields while saving. + $form->setFieldAttribute('created_by', 'filter', 'unset'); + } + // Modify the form based on Edit Creaded Date access controls. + if ($id != 0 && (!$user->authorise('linker.edit.created', 'com_getbible.linker.' . (int) $id)) + || ($id == 0 && !$user->authorise('linker.edit.created', 'com_getbible'))) + { + // Disable fields for display. + $form->setFieldAttribute('created', 'disabled', 'true'); + // Disable fields while saving. + $form->setFieldAttribute('created', 'filter', 'unset'); + } + // Modify the form based on Edit Name access controls. + if ($id != 0 && (!$user->authorise('linker.edit.name', 'com_getbible.linker.' . (int) $id)) + || ($id == 0 && !$user->authorise('linker.edit.name', 'com_getbible'))) + { + // Disable fields for display. + $form->setFieldAttribute('name', 'disabled', 'true'); + // Disable fields for display. + $form->setFieldAttribute('name', 'readonly', 'true'); + // If there is no value continue. + if (!$form->getValue('name')) + { + // Disable fields while saving. + $form->setFieldAttribute('name', 'filter', 'unset'); + // Disable fields while saving. + $form->setFieldAttribute('name', 'required', 'false'); + } + } + // Modify the form based on Edit Guid access controls. + if ($id != 0 && (!$user->authorise('linker.edit.guid', 'com_getbible.linker.' . (int) $id)) + || ($id == 0 && !$user->authorise('linker.edit.guid', 'com_getbible'))) + { + // Disable fields for display. + $form->setFieldAttribute('guid', 'disabled', 'true'); + // Disable fields for display. + $form->setFieldAttribute('guid', 'readonly', 'true'); + // If there is no value continue. + if (!$form->getValue('guid')) + { + // Disable fields while saving. + $form->setFieldAttribute('guid', 'filter', 'unset'); + // Disable fields while saving. + $form->setFieldAttribute('guid', 'required', 'false'); + } + } + // Only load these values if no id is found + if (0 == $id) + { + // Set redirected view name + $redirectedView = $jinput->get('ref', null, 'STRING'); + // Set field name (or fall back to view name) + $redirectedField = $jinput->get('field', $redirectedView, 'STRING'); + // Set redirected view id + $redirectedId = $jinput->get('refid', 0, 'INT'); + // Set field id (or fall back to redirected view id) + $redirectedValue = $jinput->get('field_id', $redirectedId, 'INT'); + if (0 != $redirectedValue && $redirectedField) + { + // Now set the local-redirected field default value + $form->setValue($redirectedField, null, $redirectedValue); + } + } + + // Only load the GUID if new item (or empty) + if (0 == $id || !($val = $form->getValue('guid'))) + { + $form->setValue('guid', null, GuidHelper::get()); + } + + return $form; + } + + /** + * Method to get the script that have to be included on the form + * + * @return string script files + */ + public function getScript() + { + return 'media/com_getbible/js/linker.js'; + } + + /** + * Method to test whether a record can be deleted. + * + * @param object $record A record object. + * + * @return boolean True if allowed to delete the record. Defaults to the permission set in the component. + * + * @since 1.6 + */ + protected function canDelete($record) + { + if (!empty($record->id)) + { + if ($record->published != -2) + { + return; + } + + $user = JFactory::getUser(); + // The record has been set. Check the record permissions. + return $user->authorise('linker.delete', 'com_getbible.linker.' . (int) $record->id); + } + return false; + } + + /** + * Method to test whether a record can have its state edited. + * + * @param object $record A record object. + * + * @return boolean True if allowed to change the state of the record. Defaults to the permission set in the component. + * + * @since 1.6 + */ + protected function canEditState($record) + { + $user = JFactory::getUser(); + $recordId = (!empty($record->id)) ? $record->id : 0; + + if ($recordId) + { + // The record has been set. Check the record permissions. + $permission = $user->authorise('linker.edit.state', 'com_getbible.linker.' . (int) $recordId); + if (!$permission && !is_null($permission)) + { + return false; + } + } + // In the absense of better information, revert to the component permissions. + return $user->authorise('linker.edit.state', 'com_getbible'); + } + + /** + * Method override to check if you can edit an existing record. + * + * @param array $data An array of input data. + * @param string $key The name of the key for the primary key. + * + * @return boolean + * @since 2.5 + */ + protected function allowEdit($data = array(), $key = 'id') + { + // Check specific edit permission then general edit permission. + $user = JFactory::getUser(); + + return $user->authorise('linker.edit', 'com_getbible.linker.'. ((int) isset($data[$key]) ? $data[$key] : 0)) or $user->authorise('linker.edit', 'com_getbible'); + } + + /** + * Prepare and sanitise the table data prior to saving. + * + * @param JTable $table A JTable object. + * + * @return void + * + * @since 1.6 + */ + protected function prepareTable($table) + { + $date = JFactory::getDate(); + $user = JFactory::getUser(); + + if (isset($table->name)) + { + $table->name = htmlspecialchars_decode($table->name, ENT_QUOTES); + } + + if (isset($table->alias) && empty($table->alias)) + { + $table->generateAlias(); + } + + if (empty($table->id)) + { + $table->created = $date->toSql(); + // set the user + if ($table->created_by == 0 || empty($table->created_by)) + { + $table->created_by = $user->id; + } + // Set ordering to the last item if not set + if (empty($table->ordering)) + { + $db = JFactory::getDbo(); + $query = $db->getQuery(true) + ->select('MAX(ordering)') + ->from($db->quoteName('#__getbible_linker')); + $db->setQuery($query); + $max = $db->loadResult(); + + $table->ordering = $max + 1; + } + } + else + { + $table->modified = $date->toSql(); + $table->modified_by = $user->id; + } + + if (!empty($table->id)) + { + // Increment the items version number. + $table->version++; + } + } + + /** + * Method to get the data that should be injected in the form. + * + * @return mixed The data for the form. + * + * @since 1.6 + */ + protected function loadFormData() + { + // Check the session for previously entered form data. + $data = JFactory::getApplication()->getUserState('com_getbible.edit.linker.data', array()); + + if (empty($data)) + { + $data = $this->getItem(); + // run the perprocess of the data + $this->preprocessData('com_getbible.linker', $data); + } + + return $data; + } + + /** + * Method to get the unique fields of this table. + * + * @return mixed An array of field names, boolean false if none is set. + * + * @since 3.0 + */ + protected function getUniqueFields() + { + return array('guid'); + } + + /** + * Method to delete one or more records. + * + * @param array &$pks An array of record primary keys. + * + * @return boolean True if successful, false if an error occurs. + * + * @since 12.2 + */ + public function delete(&$pks) + { + if (!parent::delete($pks)) + { + return false; + } + + return true; + } + + /** + * Method to change the published state of one or more records. + * + * @param array &$pks A list of the primary keys to change. + * @param integer $value The value of the published state. + * + * @return boolean True on success. + * + * @since 12.2 + */ + public function publish(&$pks, $value = 1) + { + if (!parent::publish($pks, $value)) + { + return false; + } + + return true; + } + + /** + * Method to perform batch operations on an item or a set of items. + * + * @param array $commands An array of commands to perform. + * @param array $pks An array of item ids. + * @param array $contexts An array of item contexts. + * + * @return boolean Returns true on success, false on failure. + * + * @since 12.2 + */ + public function batch($commands, $pks, $contexts) + { + // Sanitize ids. + $pks = array_unique($pks); + ArrayHelper::toInteger($pks); + + // Remove any values of zero. + if (array_search(0, $pks, true)) + { + unset($pks[array_search(0, $pks, true)]); + } + + if (empty($pks)) + { + $this->setError(JText::_('JGLOBAL_NO_ITEM_SELECTED')); + return false; + } + + $done = false; + + // Set some needed variables. + $this->user = JFactory::getUser(); + $this->table = $this->getTable(); + $this->tableClassName = get_class($this->table); + $this->contentType = new JUcmType; + $this->type = $this->contentType->getTypeByTable($this->tableClassName); + $this->canDo = GetbibleHelper::getActions('linker'); + $this->batchSet = true; + + if (!$this->canDo->get('core.batch')) + { + $this->setError(JText::_('JLIB_APPLICATION_ERROR_INSUFFICIENT_BATCH_INFORMATION')); + return false; + } + + if ($this->type == false) + { + $type = new JUcmType; + $this->type = $type->getTypeByAlias($this->typeAlias); + } + + $this->tagsObserver = $this->table->getObserverOfClass('JTableObserverTags'); + + if (!empty($commands['move_copy'])) + { + $cmd = ArrayHelper::getValue($commands, 'move_copy', 'c'); + + if ($cmd == 'c') + { + $result = $this->batchCopy($commands, $pks, $contexts); + + if (is_array($result)) + { + foreach ($result as $old => $new) + { + $contexts[$new] = $contexts[$old]; + } + $pks = array_values($result); + } + else + { + return false; + } + } + elseif ($cmd == 'm' && !$this->batchMove($commands, $pks, $contexts)) + { + return false; + } + + $done = true; + } + + if (!$done) + { + $this->setError(JText::_('JLIB_APPLICATION_ERROR_INSUFFICIENT_BATCH_INFORMATION')); + + return false; + } + + // Clear the cache + $this->cleanCache(); + + return true; + } + + /** + * Batch copy items to a new category or current. + * + * @param integer $values The new values. + * @param array $pks An array of row IDs. + * @param array $contexts An array of item contexts. + * + * @return mixed An array of new IDs on success, boolean false on failure. + * + * @since 12.2 + */ + protected function batchCopy($values, $pks, $contexts) + { + if (empty($this->batchSet)) + { + // Set some needed variables. + $this->user = JFactory::getUser(); + $this->table = $this->getTable(); + $this->tableClassName = get_class($this->table); + $this->canDo = GetbibleHelper::getActions('linker'); + } + + if (!$this->canDo->get('linker.create') && !$this->canDo->get('linker.batch')) + { + return false; + } + + // get list of unique fields + $uniqueFields = $this->getUniqueFields(); + // remove move_copy from array + unset($values['move_copy']); + + // make sure published is set + if (!isset($values['published'])) + { + $values['published'] = 0; + } + elseif (isset($values['published']) && !$this->canDo->get('linker.edit.state')) + { + $values['published'] = 0; + } + + $newIds = array(); + // Parent exists so let's proceed + while (!empty($pks)) + { + // Pop the first ID off the stack + $pk = array_shift($pks); + + $this->table->reset(); + + // only allow copy if user may edit this item. + if (!$this->user->authorise('linker.edit', $contexts[$pk])) + { + // Not fatal error + $this->setError(JText::sprintf('JLIB_APPLICATION_ERROR_BATCH_MOVE_ROW_NOT_FOUND', $pk)); + continue; + } + + // Check that the row actually exists + if (!$this->table->load($pk)) + { + if ($error = $this->table->getError()) + { + // Fatal error + $this->setError($error); + return false; + } + else + { + // Not fatal error + $this->setError(JText::sprintf('JLIB_APPLICATION_ERROR_BATCH_MOVE_ROW_NOT_FOUND', $pk)); + continue; + } + } + + // Only for strings + if (GetbibleHelper::checkString($this->table->name) && !is_numeric($this->table->name)) + { + $this->table->name = $this->generateUnique('name',$this->table->name); + } + + // insert all set values + if (GetbibleHelper::checkArray($values)) + { + foreach ($values as $key => $value) + { + if (strlen($value) > 0 && isset($this->table->$key)) + { + $this->table->$key = $value; + } + } + } + + // update all unique fields + if (GetbibleHelper::checkArray($uniqueFields)) + { + foreach ($uniqueFields as $uniqueField) + { + $this->table->$uniqueField = $this->generateUnique($uniqueField,$this->table->$uniqueField); + } + } + + // Reset the ID because we are making a copy + $this->table->id = 0; + + // TODO: Deal with ordering? + // $this->table->ordering = 1; + + // Check the row. + if (!$this->table->check()) + { + $this->setError($this->table->getError()); + + return false; + } + + if (!empty($this->type)) + { + $this->createTagsHelper($this->tagsObserver, $this->type, $pk, $this->typeAlias, $this->table); + } + + // Store the row. + if (!$this->table->store()) + { + $this->setError($this->table->getError()); + + return false; + } + + // Get the new item ID + $newId = $this->table->get('id'); + + // Add the new ID to the array + $newIds[$pk] = $newId; + } + + // Clean the cache + $this->cleanCache(); + + return $newIds; + } + + /** + * Batch move items to a new category + * + * @param integer $value The new category ID. + * @param array $pks An array of row IDs. + * @param array $contexts An array of item contexts. + * + * @return boolean True if successful, false otherwise and internal error is set. + * + * @since 12.2 + */ + protected function batchMove($values, $pks, $contexts) + { + if (empty($this->batchSet)) + { + // Set some needed variables. + $this->user = JFactory::getUser(); + $this->table = $this->getTable(); + $this->tableClassName = get_class($this->table); + $this->canDo = GetbibleHelper::getActions('linker'); + } + + if (!$this->canDo->get('linker.edit') && !$this->canDo->get('linker.batch')) + { + $this->setError(JText::_('JLIB_APPLICATION_ERROR_BATCH_CANNOT_EDIT')); + return false; + } + + // make sure published only updates if user has the permission. + if (isset($values['published']) && !$this->canDo->get('linker.edit.state')) + { + unset($values['published']); + } + // remove move_copy from array + unset($values['move_copy']); + + // Parent exists so we proceed + foreach ($pks as $pk) + { + if (!$this->user->authorise('linker.edit', $contexts[$pk])) + { + $this->setError(JText::_('JLIB_APPLICATION_ERROR_BATCH_CANNOT_EDIT')); + return false; + } + + // Check that the row actually exists + if (!$this->table->load($pk)) + { + if ($error = $this->table->getError()) + { + // Fatal error + $this->setError($error); + return false; + } + else + { + // Not fatal error + $this->setError(JText::sprintf('JLIB_APPLICATION_ERROR_BATCH_MOVE_ROW_NOT_FOUND', $pk)); + continue; + } + } + + // insert all set values. + if (GetbibleHelper::checkArray($values)) + { + foreach ($values as $key => $value) + { + // Do special action for access. + if ('access' === $key && strlen($value) > 0) + { + $this->table->$key = $value; + } + elseif (strlen($value) > 0 && isset($this->table->$key)) + { + $this->table->$key = $value; + } + } + } + + + // Check the row. + if (!$this->table->check()) + { + $this->setError($this->table->getError()); + + return false; + } + + if (!empty($this->type)) + { + $this->createTagsHelper($this->tagsObserver, $this->type, $pk, $this->typeAlias, $this->table); + } + + // Store the row. + if (!$this->table->store()) + { + $this->setError($this->table->getError()); + + return false; + } + } + + // Clean the cache + $this->cleanCache(); + + return true; + } + + /** + * Method to save the form data. + * + * @param array $data The form data. + * + * @return boolean True on success. + * + * @since 1.6 + */ + public function save($data) + { + $input = JFactory::getApplication()->input; + $filter = JFilterInput::getInstance(); + + // set the metadata to the Item Data + if (isset($data['metadata']) && isset($data['metadata']['author'])) + { + $data['metadata']['author'] = $filter->clean($data['metadata']['author'], 'TRIM'); + + $metadata = new JRegistry; + $metadata->loadArray($data['metadata']); + $data['metadata'] = (string) $metadata; + } + + + // Set the GUID if empty or not valid + if (empty($data['guid']) && $data['id'] > 0) + { + // get the existing one + $data['guid'] = (string) GetHelper::var('linker', $data['id'], 'id', 'guid'); + } + + // Set the GUID if empty or not valid + while (!GuidHelper::valid($data['guid'], "linker", $data['id'])) + { + // must always be set + $data['guid'] = (string) GuidHelper::get(); + } + + // Set the Params Items to data + if (isset($data['params']) && is_array($data['params'])) + { + $params = new JRegistry; + $params->loadArray($data['params']); + $data['params'] = (string) $params; + } + + // Alter the unique field for save as copy + if ($input->get('task') === 'save2copy') + { + // Automatic handling of other unique fields + $uniqueFields = $this->getUniqueFields(); + if (GetbibleHelper::checkArray($uniqueFields)) + { + foreach ($uniqueFields as $uniqueField) + { + $data[$uniqueField] = $this->generateUnique($uniqueField,$data[$uniqueField]); + } + } + } + + if (parent::save($data)) + { + return true; + } + return false; + } + + /** + * Method to generate a unique value. + * + * @param string $field name. + * @param string $value data. + * + * @return string New value. + * + * @since 3.0 + */ + protected function generateUnique($field,$value) + { + + // set field value unique + $table = $this->getTable(); + + while ($table->load(array($field => $value))) + { + $value = StringHelper::increment($value); + } + + return $value; + } + + /** + * Method to change the title + * + * @param string $title The title. + * + * @return array Contains the modified title and alias. + * + */ + protected function _generateNewTitle($title) + { + + // Alter the title + $table = $this->getTable(); + + while ($table->load(array('title' => $title))) + { + $title = StringHelper::increment($title); + } + + return $title; + } +} diff --git a/admin/models/linkers.php b/admin/models/linkers.php new file mode 100644 index 0000000..55fa01b --- /dev/null +++ b/admin/models/linkers.php @@ -0,0 +1,324 @@ + + @git Get Bible + @github Get Bible + @support Get Bible + @copyright Copyright (C) 2015. All Rights Reserved + @license GNU/GPL Version 2 or later - http://www.gnu.org/licenses/gpl-2.0.html + +/------------------------------------------------------------------------------------------------------*/ + +// No direct access to this file +defined('_JEXEC') or die('Restricted access'); + +use Joomla\CMS\MVC\Model\ListModel; +use Joomla\Utilities\ArrayHelper; + +/** + * Linkers List Model + */ +class GetbibleModelLinkers extends ListModel +{ + public function __construct($config = array()) + { + if (empty($config['filter_fields'])) + { + $config['filter_fields'] = array( + 'a.id','id', + 'a.published','published', + 'a.access','access', + 'a.ordering','ordering', + 'a.created_by','created_by', + 'a.modified_by','modified_by', + 'a.name','name' + ); + } + + parent::__construct($config); + } + + /** + * Method to auto-populate the model state. + * + * Note. Calling getState in this method will result in recursion. + * + * @param string $ordering An optional ordering field. + * @param string $direction An optional direction (asc|desc). + * + * @return void + * + */ + protected function populateState($ordering = null, $direction = null) + { + $app = JFactory::getApplication(); + + // Adjust the context to support modal layouts. + if ($layout = $app->input->get('layout')) + { + $this->context .= '.' . $layout; + } + + // Check if the form was submitted + $formSubmited = $app->input->post->get('form_submited'); + + $access = $this->getUserStateFromRequest($this->context . '.filter.access', 'filter_access', 0, 'int'); + if ($formSubmited) + { + $access = $app->input->post->get('access'); + $this->setState('filter.access', $access); + } + + $published = $this->getUserStateFromRequest($this->context . '.filter.published', 'filter_published', ''); + $this->setState('filter.published', $published); + + $created_by = $this->getUserStateFromRequest($this->context . '.filter.created_by', 'filter_created_by', ''); + $this->setState('filter.created_by', $created_by); + + $created = $this->getUserStateFromRequest($this->context . '.filter.created', 'filter_created'); + $this->setState('filter.created', $created); + + $sorting = $this->getUserStateFromRequest($this->context . '.filter.sorting', 'filter_sorting', 0, 'int'); + $this->setState('filter.sorting', $sorting); + + $search = $this->getUserStateFromRequest($this->context . '.filter.search', 'filter_search'); + $this->setState('filter.search', $search); + + $name = $this->getUserStateFromRequest($this->context . '.filter.name', 'filter_name'); + if ($formSubmited) + { + $name = $app->input->post->get('name'); + $this->setState('filter.name', $name); + } + + // List state information. + parent::populateState($ordering, $direction); + } + + /** + * Method to get an array of data items. + * + * @return mixed An array of data items on success, false on failure. + */ + public function getItems() + { + // Check in items + $this->checkInNow(); + + // load parent items + $items = parent::getItems(); + + // Set values to display correctly. + if (GetbibleHelper::checkArray($items)) + { + // Get the user object if not set. + if (!isset($user) || !GetbibleHelper::checkObject($user)) + { + $user = JFactory::getUser(); + } + foreach ($items as $nr => &$item) + { + // Remove items the user can't access. + $access = ($user->authorise('linker.access', 'com_getbible.linker.' . (int) $item->id) && $user->authorise('linker.access', 'com_getbible')); + if (!$access) + { + unset($items[$nr]); + continue; + } + + } + } + + // return items + return $items; + } + + /** + * Method to build an SQL query to load the list data. + * + * @return string An SQL query + */ + protected function getListQuery() + { + // Get the user object. + $user = JFactory::getUser(); + // Create a new query object. + $db = JFactory::getDBO(); + $query = $db->getQuery(true); + + // Select some fields + $query->select('a.*'); + + // From the getbible_item table + $query->from($db->quoteName('#__getbible_linker', 'a')); + + // Filter by published state + $published = $this->getState('filter.published'); + if (is_numeric($published)) + { + $query->where('a.published = ' . (int) $published); + } + elseif ($published === '') + { + $query->where('(a.published = 0 OR a.published = 1)'); + } + + // Join over the asset groups. + $query->select('ag.title AS access_level'); + $query->join('LEFT', '#__viewlevels AS ag ON ag.id = a.access'); + // Filter by access level. + $_access = $this->getState('filter.access'); + if ($_access && is_numeric($_access)) + { + $query->where('a.access = ' . (int) $_access); + } + elseif (GetbibleHelper::checkArray($_access)) + { + // Secure the array for the query + $_access = ArrayHelper::toInteger($_access); + // Filter by the Access Array. + $query->where('a.access IN (' . implode(',', $_access) . ')'); + } + // Implement View Level Access + if (!$user->authorise('core.options', 'com_getbible')) + { + $groups = implode(',', $user->getAuthorisedViewLevels()); + $query->where('a.access IN (' . $groups . ')'); + } + // Filter by search. + $search = $this->getState('filter.search'); + if (!empty($search)) + { + if (stripos($search, 'id:') === 0) + { + $query->where('a.id = ' . (int) substr($search, 3)); + } + else + { + $search = $db->quote('%' . $db->escape($search) . '%'); + $query->where('(a.name LIKE '.$search.')'); + } + } + + // Filter by Name. + $_name = $this->getState('filter.name'); + if (is_numeric($_name)) + { + if (is_float($_name)) + { + $query->where('a.name = ' . (float) $_name); + } + else + { + $query->where('a.name = ' . (int) $_name); + } + } + elseif (GetbibleHelper::checkString($_name)) + { + $query->where('a.name = ' . $db->quote($db->escape($_name))); + } + + // Add the list ordering clause. + $orderCol = $this->state->get('list.ordering', 'a.id'); + $orderDirn = $this->state->get('list.direction', 'desc'); + if ($orderCol != '') + { + $query->order($db->escape($orderCol . ' ' . $orderDirn)); + } + + return $query; + } + + /** + * Method to get a store id based on model configuration state. + * + * @return string A store id. + * + */ + protected function getStoreId($id = '') + { + // Compile the store id. + $id .= ':' . $this->getState('filter.id'); + $id .= ':' . $this->getState('filter.search'); + $id .= ':' . $this->getState('filter.published'); + // Check if the value is an array + $_access = $this->getState('filter.access'); + if (GetbibleHelper::checkArray($_access)) + { + $id .= ':' . implode(':', $_access); + } + // Check if this is only an number or string + elseif (is_numeric($_access) + || GetbibleHelper::checkString($_access)) + { + $id .= ':' . $_access; + } + $id .= ':' . $this->getState('filter.ordering'); + $id .= ':' . $this->getState('filter.created_by'); + $id .= ':' . $this->getState('filter.modified_by'); + $id .= ':' . $this->getState('filter.name'); + + return parent::getStoreId($id); + } + + /** + * Build an SQL query to checkin all items left checked out longer then a set time. + * + * @return a bool + * + */ + protected function checkInNow() + { + // Get set check in time + $time = JComponentHelper::getParams('com_getbible')->get('check_in'); + + if ($time) + { + + // Get a db connection. + $db = JFactory::getDbo(); + // Reset query. + $query = $db->getQuery(true); + $query->select('*'); + $query->from($db->quoteName('#__getbible_linker')); + // Only select items that are checked out. + $query->where($db->quoteName('checked_out') . '!=0'); + $db->setQuery($query, 0, 1); + $db->execute(); + if ($db->getNumRows()) + { + // Get Yesterdays date. + $date = JFactory::getDate()->modify($time)->toSql(); + // Reset query. + $query = $db->getQuery(true); + + // Fields to update. + $fields = array( + $db->quoteName('checked_out_time') . '=\'0000-00-00 00:00:00\'', + $db->quoteName('checked_out') . '=0' + ); + + // Conditions for which records should be updated. + $conditions = array( + $db->quoteName('checked_out') . '!=0', + $db->quoteName('checked_out_time') . '<\''.$date.'\'' + ); + + // Check table. + $query->update($db->quoteName('#__getbible_linker'))->set($fields)->where($conditions); + + $db->setQuery($query); + + $db->execute(); + } + } + + return false; + } +} diff --git a/admin/models/note.php b/admin/models/note.php new file mode 100644 index 0000000..3481114 --- /dev/null +++ b/admin/models/note.php @@ -0,0 +1,992 @@ + + @git Get Bible + @github Get Bible + @support Get Bible + @copyright Copyright (C) 2015. All Rights Reserved + @license GNU/GPL Version 2 or later - http://www.gnu.org/licenses/gpl-2.0.html + +/------------------------------------------------------------------------------------------------------*/ + +// No direct access to this file +defined('_JEXEC') or die('Restricted access'); + +use Joomla\CMS\MVC\Model\AdminModel; +use Joomla\Registry\Registry; +use Joomla\String\StringHelper; +use Joomla\Utilities\ArrayHelper; +use VDM\Joomla\Utilities\GuidHelper; +use VDM\Joomla\Utilities\GetHelper; + +/** + * Getbible Note Admin Model + */ +class GetbibleModelNote extends AdminModel +{ + /** + * The tab layout fields array. + * + * @var array + */ + protected $tabLayoutFields = array( + 'details' => array( + 'left' => array( + 'book_nr', + 'chapter', + 'verse' + ), + 'right' => array( + 'note' + ), + 'above' => array( + 'access', + 'linker' + ) + ) + ); + + /** + * @var string The prefix to use with controller messages. + * @since 1.6 + */ + protected $text_prefix = 'COM_GETBIBLE'; + + /** + * The type alias for this content type. + * + * @var string + * @since 3.2 + */ + public $typeAlias = 'com_getbible.note'; + + /** + * Returns a Table object, always creating it + * + * @param type $type The table type to instantiate + * @param string $prefix A prefix for the table class name. Optional. + * @param array $config Configuration array for model. Optional. + * + * @return JTable A database object + * + * @since 1.6 + */ + public function getTable($type = 'note', $prefix = 'GetbibleTable', $config = array()) + { + // add table path for when model gets used from other component + $this->addTablePath(JPATH_ADMINISTRATOR . '/components/com_getbible/tables'); + // get instance of the table + return JTable::getInstance($type, $prefix, $config); + } + + /** + * Method to get a single record. + * + * @param integer $pk The id of the primary key. + * + * @return mixed Object on success, false on failure. + * + * @since 1.6 + */ + public function getItem($pk = null) + { + if ($item = parent::getItem($pk)) + { + if (!empty($item->params) && !is_array($item->params)) + { + // Convert the params field to an array. + $registry = new Registry; + $registry->loadString($item->params); + $item->params = $registry->toArray(); + } + + if (!empty($item->metadata)) + { + // Convert the metadata field to an array. + $registry = new Registry; + $registry->loadString($item->metadata); + $item->metadata = $registry->toArray(); + } + } + + return $item; + } + + /** + * Method to get the record form. + * + * @param array $data Data for the form. + * @param boolean $loadData True if the form is to load its own data (default case), false if not. + * @param array $options Optional array of options for the form creation. + * + * @return mixed A JForm object on success, false on failure + * + * @since 1.6 + */ + public function getForm($data = array(), $loadData = true, $options = array('control' => 'jform')) + { + // set load data option + $options['load_data'] = $loadData; + // check if xpath was set in options + $xpath = false; + if (isset($options['xpath'])) + { + $xpath = $options['xpath']; + unset($options['xpath']); + } + // check if clear form was set in options + $clear = false; + if (isset($options['clear'])) + { + $clear = $options['clear']; + unset($options['clear']); + } + + // Get the form. + $form = $this->loadForm('com_getbible.note', 'note', $options, $clear, $xpath); + + if (empty($form)) + { + return false; + } + + $jinput = JFactory::getApplication()->input; + + // The front end calls this model and uses a_id to avoid id clashes so we need to check for that first. + if ($jinput->get('a_id')) + { + $id = $jinput->get('a_id', 0, 'INT'); + } + // The back end uses id so we use that the rest of the time and set it to 0 by default. + else + { + $id = $jinput->get('id', 0, 'INT'); + } + + $user = JFactory::getUser(); + + // Check for existing item. + // Modify the form based on Edit State access controls. + if ($id != 0 && (!$user->authorise('note.edit.state', 'com_getbible.note.' . (int) $id)) + || ($id == 0 && !$user->authorise('note.edit.state', 'com_getbible'))) + { + // Disable fields for display. + $form->setFieldAttribute('ordering', 'disabled', 'true'); + $form->setFieldAttribute('published', 'disabled', 'true'); + // Disable fields while saving. + $form->setFieldAttribute('ordering', 'filter', 'unset'); + $form->setFieldAttribute('published', 'filter', 'unset'); + } + // If this is a new item insure the greated by is set. + if (0 == $id) + { + // Set the created_by to this user + $form->setValue('created_by', null, $user->id); + } + // Modify the form based on Edit Creaded By access controls. + if ($id != 0 && (!$user->authorise('note.edit.created_by', 'com_getbible.note.' . (int) $id)) + || ($id == 0 && !$user->authorise('note.edit.created_by', 'com_getbible'))) + { + // Disable fields for display. + $form->setFieldAttribute('created_by', 'disabled', 'true'); + // Disable fields for display. + $form->setFieldAttribute('created_by', 'readonly', 'true'); + // Disable fields while saving. + $form->setFieldAttribute('created_by', 'filter', 'unset'); + } + // Modify the form based on Edit Creaded Date access controls. + if ($id != 0 && (!$user->authorise('note.edit.created', 'com_getbible.note.' . (int) $id)) + || ($id == 0 && !$user->authorise('note.edit.created', 'com_getbible'))) + { + // Disable fields for display. + $form->setFieldAttribute('created', 'disabled', 'true'); + // Disable fields while saving. + $form->setFieldAttribute('created', 'filter', 'unset'); + } + // Modify the form based on Edit Access 'access' controls. + if ($id != 0 && (!$user->authorise('note.edit.access', 'com_getbible.note.' . (int) $id)) + || ($id == 0 && !$user->authorise('note.edit.access', 'com_getbible'))) + { + // Disable fields for display. + $form->setFieldAttribute('access', 'disabled', 'true'); + // Disable fields while saving. + $form->setFieldAttribute('access', 'filter', 'unset'); + } + // Modify the form based on Edit Book Nr access controls. + if ($id != 0 && (!$user->authorise('note.edit.book_nr', 'com_getbible.note.' . (int) $id)) + || ($id == 0 && !$user->authorise('note.edit.book_nr', 'com_getbible'))) + { + // Disable fields for display. + $form->setFieldAttribute('book_nr', 'disabled', 'true'); + // Disable fields for display. + $form->setFieldAttribute('book_nr', 'readonly', 'true'); + // If there is no value continue. + if (!$form->getValue('book_nr')) + { + // Disable fields while saving. + $form->setFieldAttribute('book_nr', 'filter', 'unset'); + // Disable fields while saving. + $form->setFieldAttribute('book_nr', 'required', 'false'); + } + } + // Modify the form based on Edit Linker access controls. + if ($id != 0 && (!$user->authorise('note.edit.linker', 'com_getbible.note.' . (int) $id)) + || ($id == 0 && !$user->authorise('note.edit.linker', 'com_getbible'))) + { + // Disable fields for display. + $form->setFieldAttribute('linker', 'disabled', 'true'); + // Disable fields for display. + $form->setFieldAttribute('linker', 'readonly', 'true'); + // If there is no value continue. + if (!$form->getValue('linker')) + { + // Disable fields while saving. + $form->setFieldAttribute('linker', 'filter', 'unset'); + // Disable fields while saving. + $form->setFieldAttribute('linker', 'required', 'false'); + } + } + // Modify the form based on Edit Guid access controls. + if ($id != 0 && (!$user->authorise('note.edit.guid', 'com_getbible.note.' . (int) $id)) + || ($id == 0 && !$user->authorise('note.edit.guid', 'com_getbible'))) + { + // Disable fields for display. + $form->setFieldAttribute('guid', 'disabled', 'true'); + // Disable fields for display. + $form->setFieldAttribute('guid', 'readonly', 'true'); + // If there is no value continue. + if (!$form->getValue('guid')) + { + // Disable fields while saving. + $form->setFieldAttribute('guid', 'filter', 'unset'); + // Disable fields while saving. + $form->setFieldAttribute('guid', 'required', 'false'); + } + } + // Modify the form based on Edit Note access controls. + if ($id != 0 && (!$user->authorise('note.edit.note', 'com_getbible.note.' . (int) $id)) + || ($id == 0 && !$user->authorise('note.edit.note', 'com_getbible'))) + { + // Disable fields for display. + $form->setFieldAttribute('note', 'disabled', 'true'); + // Disable fields for display. + $form->setFieldAttribute('note', 'readonly', 'true'); + // If there is no value continue. + if (!$form->getValue('note')) + { + // Disable fields while saving. + $form->setFieldAttribute('note', 'filter', 'unset'); + // Disable fields while saving. + $form->setFieldAttribute('note', 'required', 'false'); + } + } + // Modify the form based on Edit Verse access controls. + if ($id != 0 && (!$user->authorise('note.edit.verse', 'com_getbible.note.' . (int) $id)) + || ($id == 0 && !$user->authorise('note.edit.verse', 'com_getbible'))) + { + // Disable fields for display. + $form->setFieldAttribute('verse', 'disabled', 'true'); + // Disable fields for display. + $form->setFieldAttribute('verse', 'readonly', 'true'); + // If there is no value continue. + if (!$form->getValue('verse')) + { + // Disable fields while saving. + $form->setFieldAttribute('verse', 'filter', 'unset'); + // Disable fields while saving. + $form->setFieldAttribute('verse', 'required', 'false'); + } + } + // Modify the form based on Edit Chapter access controls. + if ($id != 0 && (!$user->authorise('note.edit.chapter', 'com_getbible.note.' . (int) $id)) + || ($id == 0 && !$user->authorise('note.edit.chapter', 'com_getbible'))) + { + // Disable fields for display. + $form->setFieldAttribute('chapter', 'disabled', 'true'); + // Disable fields for display. + $form->setFieldAttribute('chapter', 'readonly', 'true'); + // If there is no value continue. + if (!$form->getValue('chapter')) + { + // Disable fields while saving. + $form->setFieldAttribute('chapter', 'filter', 'unset'); + // Disable fields while saving. + $form->setFieldAttribute('chapter', 'required', 'false'); + } + } + // Only load these values if no id is found + if (0 == $id) + { + // Set redirected view name + $redirectedView = $jinput->get('ref', null, 'STRING'); + // Set field name (or fall back to view name) + $redirectedField = $jinput->get('field', $redirectedView, 'STRING'); + // Set redirected view id + $redirectedId = $jinput->get('refid', 0, 'INT'); + // Set field id (or fall back to redirected view id) + $redirectedValue = $jinput->get('field_id', $redirectedId, 'INT'); + if (0 != $redirectedValue && $redirectedField) + { + // Now set the local-redirected field default value + $form->setValue($redirectedField, null, $redirectedValue); + } + } + + // Only load the GUID if new item (or empty) + if (0 == $id || !($val = $form->getValue('guid'))) + { + $form->setValue('guid', null, GuidHelper::get()); + } + + return $form; + } + + /** + * Method to get the script that have to be included on the form + * + * @return string script files + */ + public function getScript() + { + return 'media/com_getbible/js/note.js'; + } + + /** + * Method to test whether a record can be deleted. + * + * @param object $record A record object. + * + * @return boolean True if allowed to delete the record. Defaults to the permission set in the component. + * + * @since 1.6 + */ + protected function canDelete($record) + { + if (!empty($record->id)) + { + if ($record->published != -2) + { + return; + } + + $user = JFactory::getUser(); + // The record has been set. Check the record permissions. + return $user->authorise('note.delete', 'com_getbible.note.' . (int) $record->id); + } + return false; + } + + /** + * Method to test whether a record can have its state edited. + * + * @param object $record A record object. + * + * @return boolean True if allowed to change the state of the record. Defaults to the permission set in the component. + * + * @since 1.6 + */ + protected function canEditState($record) + { + $user = JFactory::getUser(); + $recordId = (!empty($record->id)) ? $record->id : 0; + + if ($recordId) + { + // The record has been set. Check the record permissions. + $permission = $user->authorise('note.edit.state', 'com_getbible.note.' . (int) $recordId); + if (!$permission && !is_null($permission)) + { + return false; + } + } + // In the absense of better information, revert to the component permissions. + return $user->authorise('note.edit.state', 'com_getbible'); + } + + /** + * Method override to check if you can edit an existing record. + * + * @param array $data An array of input data. + * @param string $key The name of the key for the primary key. + * + * @return boolean + * @since 2.5 + */ + protected function allowEdit($data = array(), $key = 'id') + { + // Check specific edit permission then general edit permission. + $user = JFactory::getUser(); + + return $user->authorise('note.edit', 'com_getbible.note.'. ((int) isset($data[$key]) ? $data[$key] : 0)) or $user->authorise('note.edit', 'com_getbible'); + } + + /** + * Prepare and sanitise the table data prior to saving. + * + * @param JTable $table A JTable object. + * + * @return void + * + * @since 1.6 + */ + protected function prepareTable($table) + { + $date = JFactory::getDate(); + $user = JFactory::getUser(); + + if (isset($table->name)) + { + $table->name = htmlspecialchars_decode($table->name, ENT_QUOTES); + } + + if (isset($table->alias) && empty($table->alias)) + { + $table->generateAlias(); + } + + if (empty($table->id)) + { + $table->created = $date->toSql(); + // set the user + if ($table->created_by == 0 || empty($table->created_by)) + { + $table->created_by = $user->id; + } + // Set ordering to the last item if not set + if (empty($table->ordering)) + { + $db = JFactory::getDbo(); + $query = $db->getQuery(true) + ->select('MAX(ordering)') + ->from($db->quoteName('#__getbible_note')); + $db->setQuery($query); + $max = $db->loadResult(); + + $table->ordering = $max + 1; + } + } + else + { + $table->modified = $date->toSql(); + $table->modified_by = $user->id; + } + + if (!empty($table->id)) + { + // Increment the items version number. + $table->version++; + } + } + + /** + * Method to get the data that should be injected in the form. + * + * @return mixed The data for the form. + * + * @since 1.6 + */ + protected function loadFormData() + { + // Check the session for previously entered form data. + $data = JFactory::getApplication()->getUserState('com_getbible.edit.note.data', array()); + + if (empty($data)) + { + $data = $this->getItem(); + // run the perprocess of the data + $this->preprocessData('com_getbible.note', $data); + } + + return $data; + } + + /** + * Method to get the unique fields of this table. + * + * @return mixed An array of field names, boolean false if none is set. + * + * @since 3.0 + */ + protected function getUniqueFields() + { + return array('guid'); + } + + /** + * Method to delete one or more records. + * + * @param array &$pks An array of record primary keys. + * + * @return boolean True if successful, false if an error occurs. + * + * @since 12.2 + */ + public function delete(&$pks) + { + if (!parent::delete($pks)) + { + return false; + } + + return true; + } + + /** + * Method to change the published state of one or more records. + * + * @param array &$pks A list of the primary keys to change. + * @param integer $value The value of the published state. + * + * @return boolean True on success. + * + * @since 12.2 + */ + public function publish(&$pks, $value = 1) + { + if (!parent::publish($pks, $value)) + { + return false; + } + + return true; + } + + /** + * Method to perform batch operations on an item or a set of items. + * + * @param array $commands An array of commands to perform. + * @param array $pks An array of item ids. + * @param array $contexts An array of item contexts. + * + * @return boolean Returns true on success, false on failure. + * + * @since 12.2 + */ + public function batch($commands, $pks, $contexts) + { + // Sanitize ids. + $pks = array_unique($pks); + ArrayHelper::toInteger($pks); + + // Remove any values of zero. + if (array_search(0, $pks, true)) + { + unset($pks[array_search(0, $pks, true)]); + } + + if (empty($pks)) + { + $this->setError(JText::_('JGLOBAL_NO_ITEM_SELECTED')); + return false; + } + + $done = false; + + // Set some needed variables. + $this->user = JFactory::getUser(); + $this->table = $this->getTable(); + $this->tableClassName = get_class($this->table); + $this->contentType = new JUcmType; + $this->type = $this->contentType->getTypeByTable($this->tableClassName); + $this->canDo = GetbibleHelper::getActions('note'); + $this->batchSet = true; + + if (!$this->canDo->get('core.batch')) + { + $this->setError(JText::_('JLIB_APPLICATION_ERROR_INSUFFICIENT_BATCH_INFORMATION')); + return false; + } + + if ($this->type == false) + { + $type = new JUcmType; + $this->type = $type->getTypeByAlias($this->typeAlias); + } + + $this->tagsObserver = $this->table->getObserverOfClass('JTableObserverTags'); + + if (!empty($commands['move_copy'])) + { + $cmd = ArrayHelper::getValue($commands, 'move_copy', 'c'); + + if ($cmd == 'c') + { + $result = $this->batchCopy($commands, $pks, $contexts); + + if (is_array($result)) + { + foreach ($result as $old => $new) + { + $contexts[$new] = $contexts[$old]; + } + $pks = array_values($result); + } + else + { + return false; + } + } + elseif ($cmd == 'm' && !$this->batchMove($commands, $pks, $contexts)) + { + return false; + } + + $done = true; + } + + if (!$done) + { + $this->setError(JText::_('JLIB_APPLICATION_ERROR_INSUFFICIENT_BATCH_INFORMATION')); + + return false; + } + + // Clear the cache + $this->cleanCache(); + + return true; + } + + /** + * Batch copy items to a new category or current. + * + * @param integer $values The new values. + * @param array $pks An array of row IDs. + * @param array $contexts An array of item contexts. + * + * @return mixed An array of new IDs on success, boolean false on failure. + * + * @since 12.2 + */ + protected function batchCopy($values, $pks, $contexts) + { + if (empty($this->batchSet)) + { + // Set some needed variables. + $this->user = JFactory::getUser(); + $this->table = $this->getTable(); + $this->tableClassName = get_class($this->table); + $this->canDo = GetbibleHelper::getActions('note'); + } + + if (!$this->canDo->get('note.create') && !$this->canDo->get('note.batch')) + { + return false; + } + + // get list of unique fields + $uniqueFields = $this->getUniqueFields(); + // remove move_copy from array + unset($values['move_copy']); + + // make sure published is set + if (!isset($values['published'])) + { + $values['published'] = 0; + } + elseif (isset($values['published']) && !$this->canDo->get('note.edit.state')) + { + $values['published'] = 0; + } + + $newIds = array(); + // Parent exists so let's proceed + while (!empty($pks)) + { + // Pop the first ID off the stack + $pk = array_shift($pks); + + $this->table->reset(); + + // only allow copy if user may edit this item. + if (!$this->user->authorise('note.edit', $contexts[$pk])) + { + // Not fatal error + $this->setError(JText::sprintf('JLIB_APPLICATION_ERROR_BATCH_MOVE_ROW_NOT_FOUND', $pk)); + continue; + } + + // Check that the row actually exists + if (!$this->table->load($pk)) + { + if ($error = $this->table->getError()) + { + // Fatal error + $this->setError($error); + return false; + } + else + { + // Not fatal error + $this->setError(JText::sprintf('JLIB_APPLICATION_ERROR_BATCH_MOVE_ROW_NOT_FOUND', $pk)); + continue; + } + } + + // insert all set values + if (GetbibleHelper::checkArray($values)) + { + foreach ($values as $key => $value) + { + if (strlen($value) > 0 && isset($this->table->$key)) + { + $this->table->$key = $value; + } + } + } + + // update all unique fields + if (GetbibleHelper::checkArray($uniqueFields)) + { + foreach ($uniqueFields as $uniqueField) + { + $this->table->$uniqueField = $this->generateUnique($uniqueField,$this->table->$uniqueField); + } + } + + // Reset the ID because we are making a copy + $this->table->id = 0; + + // TODO: Deal with ordering? + // $this->table->ordering = 1; + + // Check the row. + if (!$this->table->check()) + { + $this->setError($this->table->getError()); + + return false; + } + + if (!empty($this->type)) + { + $this->createTagsHelper($this->tagsObserver, $this->type, $pk, $this->typeAlias, $this->table); + } + + // Store the row. + if (!$this->table->store()) + { + $this->setError($this->table->getError()); + + return false; + } + + // Get the new item ID + $newId = $this->table->get('id'); + + // Add the new ID to the array + $newIds[$pk] = $newId; + } + + // Clean the cache + $this->cleanCache(); + + return $newIds; + } + + /** + * Batch move items to a new category + * + * @param integer $value The new category ID. + * @param array $pks An array of row IDs. + * @param array $contexts An array of item contexts. + * + * @return boolean True if successful, false otherwise and internal error is set. + * + * @since 12.2 + */ + protected function batchMove($values, $pks, $contexts) + { + if (empty($this->batchSet)) + { + // Set some needed variables. + $this->user = JFactory::getUser(); + $this->table = $this->getTable(); + $this->tableClassName = get_class($this->table); + $this->canDo = GetbibleHelper::getActions('note'); + } + + if (!$this->canDo->get('note.edit') && !$this->canDo->get('note.batch')) + { + $this->setError(JText::_('JLIB_APPLICATION_ERROR_BATCH_CANNOT_EDIT')); + return false; + } + + // make sure published only updates if user has the permission. + if (isset($values['published']) && !$this->canDo->get('note.edit.state')) + { + unset($values['published']); + } + // remove move_copy from array + unset($values['move_copy']); + + // Parent exists so we proceed + foreach ($pks as $pk) + { + if (!$this->user->authorise('note.edit', $contexts[$pk])) + { + $this->setError(JText::_('JLIB_APPLICATION_ERROR_BATCH_CANNOT_EDIT')); + return false; + } + + // Check that the row actually exists + if (!$this->table->load($pk)) + { + if ($error = $this->table->getError()) + { + // Fatal error + $this->setError($error); + return false; + } + else + { + // Not fatal error + $this->setError(JText::sprintf('JLIB_APPLICATION_ERROR_BATCH_MOVE_ROW_NOT_FOUND', $pk)); + continue; + } + } + + // insert all set values. + if (GetbibleHelper::checkArray($values)) + { + foreach ($values as $key => $value) + { + // Do special action for access. + if ('access' === $key && strlen($value) > 0) + { + $this->table->$key = $value; + } + elseif (strlen($value) > 0 && isset($this->table->$key)) + { + $this->table->$key = $value; + } + } + } + + + // Check the row. + if (!$this->table->check()) + { + $this->setError($this->table->getError()); + + return false; + } + + if (!empty($this->type)) + { + $this->createTagsHelper($this->tagsObserver, $this->type, $pk, $this->typeAlias, $this->table); + } + + // Store the row. + if (!$this->table->store()) + { + $this->setError($this->table->getError()); + + return false; + } + } + + // Clean the cache + $this->cleanCache(); + + return true; + } + + /** + * Method to save the form data. + * + * @param array $data The form data. + * + * @return boolean True on success. + * + * @since 1.6 + */ + public function save($data) + { + $input = JFactory::getApplication()->input; + $filter = JFilterInput::getInstance(); + + // set the metadata to the Item Data + if (isset($data['metadata']) && isset($data['metadata']['author'])) + { + $data['metadata']['author'] = $filter->clean($data['metadata']['author'], 'TRIM'); + + $metadata = new JRegistry; + $metadata->loadArray($data['metadata']); + $data['metadata'] = (string) $metadata; + } + + + // Set the GUID if empty or not valid + if (empty($data['guid']) && $data['id'] > 0) + { + // get the existing one + $data['guid'] = (string) GetHelper::var('note', $data['id'], 'id', 'guid'); + } + + // Set the GUID if empty or not valid + while (!GuidHelper::valid($data['guid'], "note", $data['id'])) + { + // must always be set + $data['guid'] = (string) GuidHelper::get(); + } + + // Set the Params Items to data + if (isset($data['params']) && is_array($data['params'])) + { + $params = new JRegistry; + $params->loadArray($data['params']); + $data['params'] = (string) $params; + } + + // Alter the unique field for save as copy + if ($input->get('task') === 'save2copy') + { + // Automatic handling of other unique fields + $uniqueFields = $this->getUniqueFields(); + if (GetbibleHelper::checkArray($uniqueFields)) + { + foreach ($uniqueFields as $uniqueField) + { + $data[$uniqueField] = $this->generateUnique($uniqueField,$data[$uniqueField]); + } + } + } + + if (parent::save($data)) + { + return true; + } + return false; + } + + /** + * Method to generate a unique value. + * + * @param string $field name. + * @param string $value data. + * + * @return string New value. + * + * @since 3.0 + */ + protected function generateUnique($field,$value) + { + + // set field value unique + $table = $this->getTable(); + + while ($table->load(array($field => $value))) + { + $value = StringHelper::increment($value); + } + + return $value; + } +} diff --git a/admin/models/notes.php b/admin/models/notes.php new file mode 100644 index 0000000..f41fa53 --- /dev/null +++ b/admin/models/notes.php @@ -0,0 +1,433 @@ + + @git Get Bible + @github Get Bible + @support Get Bible + @copyright Copyright (C) 2015. All Rights Reserved + @license GNU/GPL Version 2 or later - http://www.gnu.org/licenses/gpl-2.0.html + +/------------------------------------------------------------------------------------------------------*/ + +// No direct access to this file +defined('_JEXEC') or die('Restricted access'); + +use Joomla\CMS\MVC\Model\ListModel; +use Joomla\Utilities\ArrayHelper; + +/** + * Notes List Model + */ +class GetbibleModelNotes extends ListModel +{ + public function __construct($config = array()) + { + if (empty($config['filter_fields'])) + { + $config['filter_fields'] = array( + 'a.id','id', + 'a.published','published', + 'a.access','access', + 'a.ordering','ordering', + 'a.created_by','created_by', + 'a.modified_by','modified_by', + 'a.book_nr','book_nr', + 'g.name','linker', + 'a.verse','verse', + 'a.chapter','chapter' + ); + } + + parent::__construct($config); + } + + /** + * Method to auto-populate the model state. + * + * Note. Calling getState in this method will result in recursion. + * + * @param string $ordering An optional ordering field. + * @param string $direction An optional direction (asc|desc). + * + * @return void + * + */ + protected function populateState($ordering = null, $direction = null) + { + $app = JFactory::getApplication(); + + // Adjust the context to support modal layouts. + if ($layout = $app->input->get('layout')) + { + $this->context .= '.' . $layout; + } + + // Check if the form was submitted + $formSubmited = $app->input->post->get('form_submited'); + + $published = $this->getUserStateFromRequest($this->context . '.filter.published', 'filter_published', ''); + $this->setState('filter.published', $published); + + $created_by = $this->getUserStateFromRequest($this->context . '.filter.created_by', 'filter_created_by', ''); + $this->setState('filter.created_by', $created_by); + + $created = $this->getUserStateFromRequest($this->context . '.filter.created', 'filter_created'); + $this->setState('filter.created', $created); + + $sorting = $this->getUserStateFromRequest($this->context . '.filter.sorting', 'filter_sorting', 0, 'int'); + $this->setState('filter.sorting', $sorting); + + $search = $this->getUserStateFromRequest($this->context . '.filter.search', 'filter_search'); + $this->setState('filter.search', $search); + + $book_nr = $this->getUserStateFromRequest($this->context . '.filter.book_nr', 'filter_book_nr'); + if ($formSubmited) + { + $book_nr = $app->input->post->get('book_nr'); + $this->setState('filter.book_nr', $book_nr); + } + + $linker = $this->getUserStateFromRequest($this->context . '.filter.linker', 'filter_linker'); + if ($formSubmited) + { + $linker = $app->input->post->get('linker'); + $this->setState('filter.linker', $linker); + } + + $access = $this->getUserStateFromRequest($this->context . '.filter.access', 'filter_access'); + if ($formSubmited) + { + $access = $app->input->post->get('access'); + $this->setState('filter.access', $access); + } + + $verse = $this->getUserStateFromRequest($this->context . '.filter.verse', 'filter_verse'); + if ($formSubmited) + { + $verse = $app->input->post->get('verse'); + $this->setState('filter.verse', $verse); + } + + $chapter = $this->getUserStateFromRequest($this->context . '.filter.chapter', 'filter_chapter'); + if ($formSubmited) + { + $chapter = $app->input->post->get('chapter'); + $this->setState('filter.chapter', $chapter); + } + + // List state information. + parent::populateState($ordering, $direction); + } + + /** + * Method to get an array of data items. + * + * @return mixed An array of data items on success, false on failure. + */ + public function getItems() + { + // Check in items + $this->checkInNow(); + + // load parent items + $items = parent::getItems(); + + // Set values to display correctly. + if (GetbibleHelper::checkArray($items)) + { + // Get the user object if not set. + if (!isset($user) || !GetbibleHelper::checkObject($user)) + { + $user = JFactory::getUser(); + } + foreach ($items as $nr => &$item) + { + // Remove items the user can't access. + $access = ($user->authorise('note.access', 'com_getbible.note.' . (int) $item->id) && $user->authorise('note.access', 'com_getbible')); + if (!$access) + { + unset($items[$nr]); + continue; + } + + $item->book_nr = $item->book_nr . ' ' . $item->chapter . ':' . $item->verse; + } + } + + // set selection value to a translatable value + if (GetbibleHelper::checkArray($items)) + { + foreach ($items as $nr => &$item) + { + // convert access + $item->access = $this->selectionTranslation($item->access, 'access'); + } + } + + + // return items + return $items; + } + + /** + * Method to convert selection values to translatable string. + * + * @return translatable string + */ + public function selectionTranslation($value,$name) + { + // Array of access language strings + if ($name === 'access') + { + $accessArray = array( + 1 => 'COM_GETBIBLE_NOTE_PUBLIC', + 0 => 'COM_GETBIBLE_NOTE_PRIVATE' + ); + // Now check if value is found in this array + if (isset($accessArray[$value]) && GetbibleHelper::checkString($accessArray[$value])) + { + return $accessArray[$value]; + } + } + return $value; + } + + /** + * Method to build an SQL query to load the list data. + * + * @return string An SQL query + */ + protected function getListQuery() + { + // Get the user object. + $user = JFactory::getUser(); + // Create a new query object. + $db = JFactory::getDBO(); + $query = $db->getQuery(true); + + // Select some fields + $query->select('a.*'); + + // From the getbible_item table + $query->from($db->quoteName('#__getbible_note', 'a')); + + // From the getbible_linker table. + $query->select($db->quoteName(['g.name','g.id'],['linker_name','linker_id'])); + $query->join('LEFT', $db->quoteName('#__getbible_linker', 'g') . ' ON (' . $db->quoteName('a.linker') . ' = ' . $db->quoteName('g.guid') . ')'); + + // Filter by published state + $published = $this->getState('filter.published'); + if (is_numeric($published)) + { + $query->where('a.published = ' . (int) $published); + } + elseif ($published === '') + { + $query->where('(a.published = 0 OR a.published = 1)'); + } + + // Join over the asset groups. + $query->select('ag.title AS access_level'); + $query->join('LEFT', '#__viewlevels AS ag ON ag.id = a.access'); + // Implement View Level Access + if (!$user->authorise('core.options', 'com_getbible')) + { + $groups = implode(',', $user->getAuthorisedViewLevels()); + $query->where('a.access IN (' . $groups . ')'); + } + // Filter by search. + $search = $this->getState('filter.search'); + if (!empty($search)) + { + if (stripos($search, 'id:') === 0) + { + $query->where('a.id = ' . (int) substr($search, 3)); + } + else + { + $search = $db->quote('%' . $db->escape($search) . '%'); + $query->where('(a.book_nr LIKE '.$search.' OR a.linker LIKE '.$search.' OR g.name LIKE '.$search.' OR a.note LIKE '.$search.')'); + } + } + + // Filter by Book_nr. + $_book_nr = $this->getState('filter.book_nr'); + if (is_numeric($_book_nr)) + { + if (is_float($_book_nr)) + { + $query->where('a.book_nr = ' . (float) $_book_nr); + } + else + { + $query->where('a.book_nr = ' . (int) $_book_nr); + } + } + elseif (GetbibleHelper::checkString($_book_nr)) + { + $query->where('a.book_nr = ' . $db->quote($db->escape($_book_nr))); + } + // Filter by Linker. + $_linker = $this->getState('filter.linker'); + if (is_numeric($_linker)) + { + if (is_float($_linker)) + { + $query->where('a.linker = ' . (float) $_linker); + } + else + { + $query->where('a.linker = ' . (int) $_linker); + } + } + elseif (GetbibleHelper::checkString($_linker)) + { + $query->where('a.linker = ' . $db->quote($db->escape($_linker))); + } + // Filter by Access. + $_access = $this->getState('filter.access'); + if (is_numeric($_access)) + { + if (is_float($_access)) + { + $query->where('a.access = ' . (float) $_access); + } + else + { + $query->where('a.access = ' . (int) $_access); + } + } + elseif (GetbibleHelper::checkString($_access)) + { + $query->where('a.access = ' . $db->quote($db->escape($_access))); + } + // Filter by Verse. + $_verse = $this->getState('filter.verse'); + if (is_numeric($_verse)) + { + if (is_float($_verse)) + { + $query->where('a.verse = ' . (float) $_verse); + } + else + { + $query->where('a.verse = ' . (int) $_verse); + } + } + elseif (GetbibleHelper::checkString($_verse)) + { + $query->where('a.verse = ' . $db->quote($db->escape($_verse))); + } + // Filter by Chapter. + $_chapter = $this->getState('filter.chapter'); + if (is_numeric($_chapter)) + { + if (is_float($_chapter)) + { + $query->where('a.chapter = ' . (float) $_chapter); + } + else + { + $query->where('a.chapter = ' . (int) $_chapter); + } + } + elseif (GetbibleHelper::checkString($_chapter)) + { + $query->where('a.chapter = ' . $db->quote($db->escape($_chapter))); + } + + // Add the list ordering clause. + $orderCol = $this->state->get('list.ordering', 'a.id'); + $orderDirn = $this->state->get('list.direction', 'desc'); + if ($orderCol != '') + { + $query->order($db->escape($orderCol . ' ' . $orderDirn)); + } + + return $query; + } + + /** + * Method to get a store id based on model configuration state. + * + * @return string A store id. + * + */ + protected function getStoreId($id = '') + { + // Compile the store id. + $id .= ':' . $this->getState('filter.id'); + $id .= ':' . $this->getState('filter.search'); + $id .= ':' . $this->getState('filter.published'); + $id .= ':' . $this->getState('filter.ordering'); + $id .= ':' . $this->getState('filter.created_by'); + $id .= ':' . $this->getState('filter.modified_by'); + $id .= ':' . $this->getState('filter.book_nr'); + $id .= ':' . $this->getState('filter.linker'); + $id .= ':' . $this->getState('filter.verse'); + $id .= ':' . $this->getState('filter.chapter'); + + return parent::getStoreId($id); + } + + /** + * Build an SQL query to checkin all items left checked out longer then a set time. + * + * @return a bool + * + */ + protected function checkInNow() + { + // Get set check in time + $time = JComponentHelper::getParams('com_getbible')->get('check_in'); + + if ($time) + { + + // Get a db connection. + $db = JFactory::getDbo(); + // Reset query. + $query = $db->getQuery(true); + $query->select('*'); + $query->from($db->quoteName('#__getbible_note')); + // Only select items that are checked out. + $query->where($db->quoteName('checked_out') . '!=0'); + $db->setQuery($query, 0, 1); + $db->execute(); + if ($db->getNumRows()) + { + // Get Yesterdays date. + $date = JFactory::getDate()->modify($time)->toSql(); + // Reset query. + $query = $db->getQuery(true); + + // Fields to update. + $fields = array( + $db->quoteName('checked_out_time') . '=\'0000-00-00 00:00:00\'', + $db->quoteName('checked_out') . '=0' + ); + + // Conditions for which records should be updated. + $conditions = array( + $db->quoteName('checked_out') . '!=0', + $db->quoteName('checked_out_time') . '<\''.$date.'\'' + ); + + // Check table. + $query->update($db->quoteName('#__getbible_note'))->set($fields)->where($conditions); + + $db->setQuery($query); + + $db->execute(); + } + } + + return false; + } +} diff --git a/admin/models/open_ai_message.php b/admin/models/open_ai_message.php new file mode 100644 index 0000000..a9a8321 --- /dev/null +++ b/admin/models/open_ai_message.php @@ -0,0 +1,1010 @@ + + @git Get Bible + @github Get Bible + @support Get Bible + @copyright Copyright (C) 2015. All Rights Reserved + @license GNU/GPL Version 2 or later - http://www.gnu.org/licenses/gpl-2.0.html + +/------------------------------------------------------------------------------------------------------*/ + +// No direct access to this file +defined('_JEXEC') or die('Restricted access'); + +use Joomla\CMS\MVC\Model\AdminModel; +use Joomla\Registry\Registry; +use Joomla\String\StringHelper; +use Joomla\Utilities\ArrayHelper; + +/** + * Getbible Open_ai_message Admin Model + */ +class GetbibleModelOpen_ai_message extends AdminModel +{ + /** + * The tab layout fields array. + * + * @var array + */ + protected $tabLayoutFields = array( + 'message' => array( + 'left' => array( + 'source', + 'index' + ), + 'right' => array( + 'name' + ), + 'fullwidth' => array( + 'content' + ), + 'above' => array( + 'role', + 'open_ai_response', + 'prompt' + ) + ) + ); + + /** + * @var string The prefix to use with controller messages. + * @since 1.6 + */ + protected $text_prefix = 'COM_GETBIBLE'; + + /** + * The type alias for this content type. + * + * @var string + * @since 3.2 + */ + public $typeAlias = 'com_getbible.open_ai_message'; + + /** + * Returns a Table object, always creating it + * + * @param type $type The table type to instantiate + * @param string $prefix A prefix for the table class name. Optional. + * @param array $config Configuration array for model. Optional. + * + * @return JTable A database object + * + * @since 1.6 + */ + public function getTable($type = 'open_ai_message', $prefix = 'GetbibleTable', $config = array()) + { + // add table path for when model gets used from other component + $this->addTablePath(JPATH_ADMINISTRATOR . '/components/com_getbible/tables'); + // get instance of the table + return JTable::getInstance($type, $prefix, $config); + } + + /** + * Method to get a single record. + * + * @param integer $pk The id of the primary key. + * + * @return mixed Object on success, false on failure. + * + * @since 1.6 + */ + public function getItem($pk = null) + { + if ($item = parent::getItem($pk)) + { + if (!empty($item->params) && !is_array($item->params)) + { + // Convert the params field to an array. + $registry = new Registry; + $registry->loadString($item->params); + $item->params = $registry->toArray(); + } + + if (!empty($item->metadata)) + { + // Convert the metadata field to an array. + $registry = new Registry; + $registry->loadString($item->metadata); + $item->metadata = $registry->toArray(); + } + } + + return $item; + } + + /** + * Method to get the record form. + * + * @param array $data Data for the form. + * @param boolean $loadData True if the form is to load its own data (default case), false if not. + * @param array $options Optional array of options for the form creation. + * + * @return mixed A JForm object on success, false on failure + * + * @since 1.6 + */ + public function getForm($data = array(), $loadData = true, $options = array('control' => 'jform')) + { + // set load data option + $options['load_data'] = $loadData; + // check if xpath was set in options + $xpath = false; + if (isset($options['xpath'])) + { + $xpath = $options['xpath']; + unset($options['xpath']); + } + // check if clear form was set in options + $clear = false; + if (isset($options['clear'])) + { + $clear = $options['clear']; + unset($options['clear']); + } + + // Get the form. + $form = $this->loadForm('com_getbible.open_ai_message', 'open_ai_message', $options, $clear, $xpath); + + if (empty($form)) + { + return false; + } + + $jinput = JFactory::getApplication()->input; + + // The front end calls this model and uses a_id to avoid id clashes so we need to check for that first. + if ($jinput->get('a_id')) + { + $id = $jinput->get('a_id', 0, 'INT'); + } + // The back end uses id so we use that the rest of the time and set it to 0 by default. + else + { + $id = $jinput->get('id', 0, 'INT'); + } + + $user = JFactory::getUser(); + + // Check for existing item. + // Modify the form based on Edit State access controls. + if ($id != 0 && (!$user->authorise('open_ai_message.edit.state', 'com_getbible.open_ai_message.' . (int) $id)) + || ($id == 0 && !$user->authorise('open_ai_message.edit.state', 'com_getbible'))) + { + // Disable fields for display. + $form->setFieldAttribute('ordering', 'disabled', 'true'); + $form->setFieldAttribute('published', 'disabled', 'true'); + // Disable fields while saving. + $form->setFieldAttribute('ordering', 'filter', 'unset'); + $form->setFieldAttribute('published', 'filter', 'unset'); + } + // If this is a new item insure the greated by is set. + if (0 == $id) + { + // Set the created_by to this user + $form->setValue('created_by', null, $user->id); + } + // Modify the form based on Edit Creaded By access controls. + if ($id != 0 && (!$user->authorise('open_ai_message.edit.created_by', 'com_getbible.open_ai_message.' . (int) $id)) + || ($id == 0 && !$user->authorise('open_ai_message.edit.created_by', 'com_getbible'))) + { + // Disable fields for display. + $form->setFieldAttribute('created_by', 'disabled', 'true'); + // Disable fields for display. + $form->setFieldAttribute('created_by', 'readonly', 'true'); + // Disable fields while saving. + $form->setFieldAttribute('created_by', 'filter', 'unset'); + } + // Modify the form based on Edit Creaded Date access controls. + if ($id != 0 && (!$user->authorise('open_ai_message.edit.created', 'com_getbible.open_ai_message.' . (int) $id)) + || ($id == 0 && !$user->authorise('open_ai_message.edit.created', 'com_getbible'))) + { + // Disable fields for display. + $form->setFieldAttribute('created', 'disabled', 'true'); + // Disable fields while saving. + $form->setFieldAttribute('created', 'filter', 'unset'); + } + // Modify the form based on Edit Role access controls. + if ($id != 0 && (!$user->authorise('open_ai_message.edit.role', 'com_getbible.open_ai_message.' . (int) $id)) + || ($id == 0 && !$user->authorise('open_ai_message.edit.role', 'com_getbible'))) + { + // Disable fields for display. + $form->setFieldAttribute('role', 'disabled', 'true'); + // Disable fields for display. + $form->setFieldAttribute('role', 'readonly', 'true'); + // If there is no value continue. + if (!$form->getValue('role')) + { + // Disable fields while saving. + $form->setFieldAttribute('role', 'filter', 'unset'); + // Disable fields while saving. + $form->setFieldAttribute('role', 'required', 'false'); + } + } + // Modify the form based on Edit Open Ai Response access controls. + if ($id != 0 && (!$user->authorise('open_ai_message.edit.open_ai_response', 'com_getbible.open_ai_message.' . (int) $id)) + || ($id == 0 && !$user->authorise('open_ai_message.edit.open_ai_response', 'com_getbible'))) + { + // Disable fields for display. + $form->setFieldAttribute('open_ai_response', 'disabled', 'true'); + // Disable fields for display. + $form->setFieldAttribute('open_ai_response', 'readonly', 'true'); + // If there is no value continue. + if (!$form->getValue('open_ai_response')) + { + // Disable fields while saving. + $form->setFieldAttribute('open_ai_response', 'filter', 'unset'); + // Disable fields while saving. + $form->setFieldAttribute('open_ai_response', 'required', 'false'); + } + } + // Modify the form based on Edit Prompt access controls. + if ($id != 0 && (!$user->authorise('open_ai_message.edit.prompt', 'com_getbible.open_ai_message.' . (int) $id)) + || ($id == 0 && !$user->authorise('open_ai_message.edit.prompt', 'com_getbible'))) + { + // Disable fields for display. + $form->setFieldAttribute('prompt', 'disabled', 'true'); + // Disable fields for display. + $form->setFieldAttribute('prompt', 'readonly', 'true'); + // If there is no value continue. + if (!$form->getValue('prompt')) + { + // Disable fields while saving. + $form->setFieldAttribute('prompt', 'filter', 'unset'); + // Disable fields while saving. + $form->setFieldAttribute('prompt', 'required', 'false'); + } + } + // Modify the form based on Edit Source access controls. + if ($id != 0 && (!$user->authorise('open_ai_message.edit.source', 'com_getbible.open_ai_message.' . (int) $id)) + || ($id == 0 && !$user->authorise('open_ai_message.edit.source', 'com_getbible'))) + { + // Disable fields for display. + $form->setFieldAttribute('source', 'disabled', 'true'); + // Disable fields for display. + $form->setFieldAttribute('source', 'readonly', 'true'); + // Disable radio button for display. + $class = $form->getFieldAttribute('source', 'class', ''); + $form->setFieldAttribute('source', 'class', $class.' disabled no-click'); + // If there is no value continue. + if (!$form->getValue('source')) + { + // Disable fields while saving. + $form->setFieldAttribute('source', 'filter', 'unset'); + // Disable fields while saving. + $form->setFieldAttribute('source', 'required', 'false'); + } + } + // Modify the form based on Edit Content access controls. + if ($id != 0 && (!$user->authorise('open_ai_message.edit.content', 'com_getbible.open_ai_message.' . (int) $id)) + || ($id == 0 && !$user->authorise('open_ai_message.edit.content', 'com_getbible'))) + { + // Disable fields for display. + $form->setFieldAttribute('content', 'disabled', 'true'); + // Disable fields for display. + $form->setFieldAttribute('content', 'readonly', 'true'); + // If there is no value continue. + if (!$form->getValue('content')) + { + // Disable fields while saving. + $form->setFieldAttribute('content', 'filter', 'unset'); + // Disable fields while saving. + $form->setFieldAttribute('content', 'required', 'false'); + } + } + // Modify the form based on Edit Name access controls. + if ($id != 0 && (!$user->authorise('open_ai_message.edit.name', 'com_getbible.open_ai_message.' . (int) $id)) + || ($id == 0 && !$user->authorise('open_ai_message.edit.name', 'com_getbible'))) + { + // Disable fields for display. + $form->setFieldAttribute('name', 'disabled', 'true'); + // Disable fields for display. + $form->setFieldAttribute('name', 'readonly', 'true'); + // If there is no value continue. + if (!$form->getValue('name')) + { + // Disable fields while saving. + $form->setFieldAttribute('name', 'filter', 'unset'); + // Disable fields while saving. + $form->setFieldAttribute('name', 'required', 'false'); + } + } + // Modify the form based on Edit Index access controls. + if ($id != 0 && (!$user->authorise('open_ai_message.edit.index', 'com_getbible.open_ai_message.' . (int) $id)) + || ($id == 0 && !$user->authorise('open_ai_message.edit.index', 'com_getbible'))) + { + // Disable fields for display. + $form->setFieldAttribute('index', 'disabled', 'true'); + // Disable fields for display. + $form->setFieldAttribute('index', 'readonly', 'true'); + // If there is no value continue. + if (!$form->getValue('index')) + { + // Disable fields while saving. + $form->setFieldAttribute('index', 'filter', 'unset'); + // Disable fields while saving. + $form->setFieldAttribute('index', 'required', 'false'); + } + } + // Only load these values if no id is found + if (0 == $id) + { + // Set redirected view name + $redirectedView = $jinput->get('ref', null, 'STRING'); + // Set field name (or fall back to view name) + $redirectedField = $jinput->get('field', $redirectedView, 'STRING'); + // Set redirected view id + $redirectedId = $jinput->get('refid', 0, 'INT'); + // Set field id (or fall back to redirected view id) + $redirectedValue = $jinput->get('field_id', $redirectedId, 'INT'); + if (0 != $redirectedValue && $redirectedField) + { + // Now set the local-redirected field default value + $form->setValue($redirectedField, null, $redirectedValue); + } + } + return $form; + } + + /** + * Method to get the script that have to be included on the form + * + * @return string script files + */ + public function getScript() + { + return 'media/com_getbible/js/open_ai_message.js'; + } + + /** + * Method to test whether a record can be deleted. + * + * @param object $record A record object. + * + * @return boolean True if allowed to delete the record. Defaults to the permission set in the component. + * + * @since 1.6 + */ + protected function canDelete($record) + { + if (!empty($record->id)) + { + if ($record->published != -2) + { + return; + } + + $user = JFactory::getUser(); + // The record has been set. Check the record permissions. + return $user->authorise('open_ai_message.delete', 'com_getbible.open_ai_message.' . (int) $record->id); + } + return false; + } + + /** + * Method to test whether a record can have its state edited. + * + * @param object $record A record object. + * + * @return boolean True if allowed to change the state of the record. Defaults to the permission set in the component. + * + * @since 1.6 + */ + protected function canEditState($record) + { + $user = JFactory::getUser(); + $recordId = (!empty($record->id)) ? $record->id : 0; + + if ($recordId) + { + // The record has been set. Check the record permissions. + $permission = $user->authorise('open_ai_message.edit.state', 'com_getbible.open_ai_message.' . (int) $recordId); + if (!$permission && !is_null($permission)) + { + return false; + } + } + // In the absense of better information, revert to the component permissions. + return $user->authorise('open_ai_message.edit.state', 'com_getbible'); + } + + /** + * Method override to check if you can edit an existing record. + * + * @param array $data An array of input data. + * @param string $key The name of the key for the primary key. + * + * @return boolean + * @since 2.5 + */ + protected function allowEdit($data = array(), $key = 'id') + { + // Check specific edit permission then general edit permission. + $user = JFactory::getUser(); + + return $user->authorise('open_ai_message.edit', 'com_getbible.open_ai_message.'. ((int) isset($data[$key]) ? $data[$key] : 0)) or $user->authorise('open_ai_message.edit', 'com_getbible'); + } + + /** + * Prepare and sanitise the table data prior to saving. + * + * @param JTable $table A JTable object. + * + * @return void + * + * @since 1.6 + */ + protected function prepareTable($table) + { + $date = JFactory::getDate(); + $user = JFactory::getUser(); + + if (isset($table->name)) + { + $table->name = htmlspecialchars_decode($table->name, ENT_QUOTES); + } + + if (isset($table->alias) && empty($table->alias)) + { + $table->generateAlias(); + } + + if (empty($table->id)) + { + $table->created = $date->toSql(); + // set the user + if ($table->created_by == 0 || empty($table->created_by)) + { + $table->created_by = $user->id; + } + // Set ordering to the last item if not set + if (empty($table->ordering)) + { + $db = JFactory::getDbo(); + $query = $db->getQuery(true) + ->select('MAX(ordering)') + ->from($db->quoteName('#__getbible_open_ai_message')); + $db->setQuery($query); + $max = $db->loadResult(); + + $table->ordering = $max + 1; + } + } + else + { + $table->modified = $date->toSql(); + $table->modified_by = $user->id; + } + + if (!empty($table->id)) + { + // Increment the items version number. + $table->version++; + } + } + + /** + * Method to get the data that should be injected in the form. + * + * @return mixed The data for the form. + * + * @since 1.6 + */ + protected function loadFormData() + { + // Check the session for previously entered form data. + $data = JFactory::getApplication()->getUserState('com_getbible.edit.open_ai_message.data', array()); + + if (empty($data)) + { + $data = $this->getItem(); + // run the perprocess of the data + $this->preprocessData('com_getbible.open_ai_message', $data); + } + + return $data; + } + + /** + * Method to get the unique fields of this table. + * + * @return mixed An array of field names, boolean false if none is set. + * + * @since 3.0 + */ + protected function getUniqueFields() + { + return false; + } + + /** + * Method to delete one or more records. + * + * @param array &$pks An array of record primary keys. + * + * @return boolean True if successful, false if an error occurs. + * + * @since 12.2 + */ + public function delete(&$pks) + { + if (!parent::delete($pks)) + { + return false; + } + + return true; + } + + /** + * Method to change the published state of one or more records. + * + * @param array &$pks A list of the primary keys to change. + * @param integer $value The value of the published state. + * + * @return boolean True on success. + * + * @since 12.2 + */ + public function publish(&$pks, $value = 1) + { + if (!parent::publish($pks, $value)) + { + return false; + } + + return true; + } + + /** + * Method to perform batch operations on an item or a set of items. + * + * @param array $commands An array of commands to perform. + * @param array $pks An array of item ids. + * @param array $contexts An array of item contexts. + * + * @return boolean Returns true on success, false on failure. + * + * @since 12.2 + */ + public function batch($commands, $pks, $contexts) + { + // Sanitize ids. + $pks = array_unique($pks); + ArrayHelper::toInteger($pks); + + // Remove any values of zero. + if (array_search(0, $pks, true)) + { + unset($pks[array_search(0, $pks, true)]); + } + + if (empty($pks)) + { + $this->setError(JText::_('JGLOBAL_NO_ITEM_SELECTED')); + return false; + } + + $done = false; + + // Set some needed variables. + $this->user = JFactory::getUser(); + $this->table = $this->getTable(); + $this->tableClassName = get_class($this->table); + $this->contentType = new JUcmType; + $this->type = $this->contentType->getTypeByTable($this->tableClassName); + $this->canDo = GetbibleHelper::getActions('open_ai_message'); + $this->batchSet = true; + + if (!$this->canDo->get('core.batch')) + { + $this->setError(JText::_('JLIB_APPLICATION_ERROR_INSUFFICIENT_BATCH_INFORMATION')); + return false; + } + + if ($this->type == false) + { + $type = new JUcmType; + $this->type = $type->getTypeByAlias($this->typeAlias); + } + + $this->tagsObserver = $this->table->getObserverOfClass('JTableObserverTags'); + + if (!empty($commands['move_copy'])) + { + $cmd = ArrayHelper::getValue($commands, 'move_copy', 'c'); + + if ($cmd == 'c') + { + $result = $this->batchCopy($commands, $pks, $contexts); + + if (is_array($result)) + { + foreach ($result as $old => $new) + { + $contexts[$new] = $contexts[$old]; + } + $pks = array_values($result); + } + else + { + return false; + } + } + elseif ($cmd == 'm' && !$this->batchMove($commands, $pks, $contexts)) + { + return false; + } + + $done = true; + } + + if (!$done) + { + $this->setError(JText::_('JLIB_APPLICATION_ERROR_INSUFFICIENT_BATCH_INFORMATION')); + + return false; + } + + // Clear the cache + $this->cleanCache(); + + return true; + } + + /** + * Batch copy items to a new category or current. + * + * @param integer $values The new values. + * @param array $pks An array of row IDs. + * @param array $contexts An array of item contexts. + * + * @return mixed An array of new IDs on success, boolean false on failure. + * + * @since 12.2 + */ + protected function batchCopy($values, $pks, $contexts) + { + if (empty($this->batchSet)) + { + // Set some needed variables. + $this->user = JFactory::getUser(); + $this->table = $this->getTable(); + $this->tableClassName = get_class($this->table); + $this->canDo = GetbibleHelper::getActions('open_ai_message'); + } + + if (!$this->canDo->get('open_ai_message.create') && !$this->canDo->get('open_ai_message.batch')) + { + return false; + } + + // get list of unique fields + $uniqueFields = $this->getUniqueFields(); + // remove move_copy from array + unset($values['move_copy']); + + // make sure published is set + if (!isset($values['published'])) + { + $values['published'] = 0; + } + elseif (isset($values['published']) && !$this->canDo->get('open_ai_message.edit.state')) + { + $values['published'] = 0; + } + + $newIds = array(); + // Parent exists so let's proceed + while (!empty($pks)) + { + // Pop the first ID off the stack + $pk = array_shift($pks); + + $this->table->reset(); + + // only allow copy if user may edit this item. + if (!$this->user->authorise('open_ai_message.edit', $contexts[$pk])) + { + // Not fatal error + $this->setError(JText::sprintf('JLIB_APPLICATION_ERROR_BATCH_MOVE_ROW_NOT_FOUND', $pk)); + continue; + } + + // Check that the row actually exists + if (!$this->table->load($pk)) + { + if ($error = $this->table->getError()) + { + // Fatal error + $this->setError($error); + return false; + } + else + { + // Not fatal error + $this->setError(JText::sprintf('JLIB_APPLICATION_ERROR_BATCH_MOVE_ROW_NOT_FOUND', $pk)); + continue; + } + } + + // Only for strings + if (GetbibleHelper::checkString($this->table->role) && !is_numeric($this->table->role)) + { + $this->table->role = $this->generateUnique('role',$this->table->role); + } + + // insert all set values + if (GetbibleHelper::checkArray($values)) + { + foreach ($values as $key => $value) + { + if (strlen($value) > 0 && isset($this->table->$key)) + { + $this->table->$key = $value; + } + } + } + + // update all unique fields + if (GetbibleHelper::checkArray($uniqueFields)) + { + foreach ($uniqueFields as $uniqueField) + { + $this->table->$uniqueField = $this->generateUnique($uniqueField,$this->table->$uniqueField); + } + } + + // Reset the ID because we are making a copy + $this->table->id = 0; + + // TODO: Deal with ordering? + // $this->table->ordering = 1; + + // Check the row. + if (!$this->table->check()) + { + $this->setError($this->table->getError()); + + return false; + } + + if (!empty($this->type)) + { + $this->createTagsHelper($this->tagsObserver, $this->type, $pk, $this->typeAlias, $this->table); + } + + // Store the row. + if (!$this->table->store()) + { + $this->setError($this->table->getError()); + + return false; + } + + // Get the new item ID + $newId = $this->table->get('id'); + + // Add the new ID to the array + $newIds[$pk] = $newId; + } + + // Clean the cache + $this->cleanCache(); + + return $newIds; + } + + /** + * Batch move items to a new category + * + * @param integer $value The new category ID. + * @param array $pks An array of row IDs. + * @param array $contexts An array of item contexts. + * + * @return boolean True if successful, false otherwise and internal error is set. + * + * @since 12.2 + */ + protected function batchMove($values, $pks, $contexts) + { + if (empty($this->batchSet)) + { + // Set some needed variables. + $this->user = JFactory::getUser(); + $this->table = $this->getTable(); + $this->tableClassName = get_class($this->table); + $this->canDo = GetbibleHelper::getActions('open_ai_message'); + } + + if (!$this->canDo->get('open_ai_message.edit') && !$this->canDo->get('open_ai_message.batch')) + { + $this->setError(JText::_('JLIB_APPLICATION_ERROR_BATCH_CANNOT_EDIT')); + return false; + } + + // make sure published only updates if user has the permission. + if (isset($values['published']) && !$this->canDo->get('open_ai_message.edit.state')) + { + unset($values['published']); + } + // remove move_copy from array + unset($values['move_copy']); + + // Parent exists so we proceed + foreach ($pks as $pk) + { + if (!$this->user->authorise('open_ai_message.edit', $contexts[$pk])) + { + $this->setError(JText::_('JLIB_APPLICATION_ERROR_BATCH_CANNOT_EDIT')); + return false; + } + + // Check that the row actually exists + if (!$this->table->load($pk)) + { + if ($error = $this->table->getError()) + { + // Fatal error + $this->setError($error); + return false; + } + else + { + // Not fatal error + $this->setError(JText::sprintf('JLIB_APPLICATION_ERROR_BATCH_MOVE_ROW_NOT_FOUND', $pk)); + continue; + } + } + + // insert all set values. + if (GetbibleHelper::checkArray($values)) + { + foreach ($values as $key => $value) + { + // Do special action for access. + if ('access' === $key && strlen($value) > 0) + { + $this->table->$key = $value; + } + elseif (strlen($value) > 0 && isset($this->table->$key)) + { + $this->table->$key = $value; + } + } + } + + + // Check the row. + if (!$this->table->check()) + { + $this->setError($this->table->getError()); + + return false; + } + + if (!empty($this->type)) + { + $this->createTagsHelper($this->tagsObserver, $this->type, $pk, $this->typeAlias, $this->table); + } + + // Store the row. + if (!$this->table->store()) + { + $this->setError($this->table->getError()); + + return false; + } + } + + // Clean the cache + $this->cleanCache(); + + return true; + } + + /** + * Method to save the form data. + * + * @param array $data The form data. + * + * @return boolean True on success. + * + * @since 1.6 + */ + public function save($data) + { + $input = JFactory::getApplication()->input; + $filter = JFilterInput::getInstance(); + + // set the metadata to the Item Data + if (isset($data['metadata']) && isset($data['metadata']['author'])) + { + $data['metadata']['author'] = $filter->clean($data['metadata']['author'], 'TRIM'); + + $metadata = new JRegistry; + $metadata->loadArray($data['metadata']); + $data['metadata'] = (string) $metadata; + } + + // Set the Params Items to data + if (isset($data['params']) && is_array($data['params'])) + { + $params = new JRegistry; + $params->loadArray($data['params']); + $data['params'] = (string) $params; + } + + // Alter the unique field for save as copy + if ($input->get('task') === 'save2copy') + { + // Automatic handling of other unique fields + $uniqueFields = $this->getUniqueFields(); + if (GetbibleHelper::checkArray($uniqueFields)) + { + foreach ($uniqueFields as $uniqueField) + { + $data[$uniqueField] = $this->generateUnique($uniqueField,$data[$uniqueField]); + } + } + } + + if (parent::save($data)) + { + return true; + } + return false; + } + + /** + * Method to generate a unique value. + * + * @param string $field name. + * @param string $value data. + * + * @return string New value. + * + * @since 3.0 + */ + protected function generateUnique($field,$value) + { + + // set field value unique + $table = $this->getTable(); + + while ($table->load(array($field => $value))) + { + $value = StringHelper::increment($value); + } + + return $value; + } + + /** + * Method to change the title + * + * @param string $title The title. + * + * @return array Contains the modified title and alias. + * + */ + protected function _generateNewTitle($title) + { + + // Alter the title + $table = $this->getTable(); + + while ($table->load(array('title' => $title))) + { + $title = StringHelper::increment($title); + } + + return $title; + } +} diff --git a/admin/models/open_ai_messages.php b/admin/models/open_ai_messages.php new file mode 100644 index 0000000..2023545 --- /dev/null +++ b/admin/models/open_ai_messages.php @@ -0,0 +1,461 @@ + + @git Get Bible + @github Get Bible + @support Get Bible + @copyright Copyright (C) 2015. All Rights Reserved + @license GNU/GPL Version 2 or later - http://www.gnu.org/licenses/gpl-2.0.html + +/------------------------------------------------------------------------------------------------------*/ + +// No direct access to this file +defined('_JEXEC') or die('Restricted access'); + +use Joomla\CMS\MVC\Model\ListModel; +use Joomla\Utilities\ArrayHelper; + +/** + * Open_ai_messages List Model + */ +class GetbibleModelOpen_ai_messages extends ListModel +{ + public function __construct($config = array()) + { + if (empty($config['filter_fields'])) + { + $config['filter_fields'] = array( + 'a.id','id', + 'a.published','published', + 'a.access','access', + 'a.ordering','ordering', + 'a.created_by','created_by', + 'a.modified_by','modified_by', + 'a.role','role', + 'g.response_id','open_ai_response', + 'h.name','prompt', + 'a.source','source' + ); + } + + parent::__construct($config); + } + + /** + * Method to auto-populate the model state. + * + * Note. Calling getState in this method will result in recursion. + * + * @param string $ordering An optional ordering field. + * @param string $direction An optional direction (asc|desc). + * + * @return void + * + */ + protected function populateState($ordering = null, $direction = null) + { + $app = JFactory::getApplication(); + + // Adjust the context to support modal layouts. + if ($layout = $app->input->get('layout')) + { + $this->context .= '.' . $layout; + } + + // Check if the form was submitted + $formSubmited = $app->input->post->get('form_submited'); + + $access = $this->getUserStateFromRequest($this->context . '.filter.access', 'filter_access', 0, 'int'); + if ($formSubmited) + { + $access = $app->input->post->get('access'); + $this->setState('filter.access', $access); + } + + $published = $this->getUserStateFromRequest($this->context . '.filter.published', 'filter_published', ''); + $this->setState('filter.published', $published); + + $created_by = $this->getUserStateFromRequest($this->context . '.filter.created_by', 'filter_created_by', ''); + $this->setState('filter.created_by', $created_by); + + $created = $this->getUserStateFromRequest($this->context . '.filter.created', 'filter_created'); + $this->setState('filter.created', $created); + + $sorting = $this->getUserStateFromRequest($this->context . '.filter.sorting', 'filter_sorting', 0, 'int'); + $this->setState('filter.sorting', $sorting); + + $search = $this->getUserStateFromRequest($this->context . '.filter.search', 'filter_search'); + $this->setState('filter.search', $search); + + $role = $this->getUserStateFromRequest($this->context . '.filter.role', 'filter_role'); + if ($formSubmited) + { + $role = $app->input->post->get('role'); + $this->setState('filter.role', $role); + } + + $open_ai_response = $this->getUserStateFromRequest($this->context . '.filter.open_ai_response', 'filter_open_ai_response'); + if ($formSubmited) + { + $open_ai_response = $app->input->post->get('open_ai_response'); + $this->setState('filter.open_ai_response', $open_ai_response); + } + + $prompt = $this->getUserStateFromRequest($this->context . '.filter.prompt', 'filter_prompt'); + if ($formSubmited) + { + $prompt = $app->input->post->get('prompt'); + $this->setState('filter.prompt', $prompt); + } + + $source = $this->getUserStateFromRequest($this->context . '.filter.source', 'filter_source'); + if ($formSubmited) + { + $source = $app->input->post->get('source'); + $this->setState('filter.source', $source); + } + + // List state information. + parent::populateState($ordering, $direction); + } + + /** + * Method to get an array of data items. + * + * @return mixed An array of data items on success, false on failure. + */ + public function getItems() + { + // Check in items + $this->checkInNow(); + + // load parent items + $items = parent::getItems(); + + // Set values to display correctly. + if (GetbibleHelper::checkArray($items)) + { + // Get the user object if not set. + if (!isset($user) || !GetbibleHelper::checkObject($user)) + { + $user = JFactory::getUser(); + } + foreach ($items as $nr => &$item) + { + // Remove items the user can't access. + $access = ($user->authorise('open_ai_message.access', 'com_getbible.open_ai_message.' . (int) $item->id) && $user->authorise('open_ai_message.access', 'com_getbible')); + if (!$access) + { + unset($items[$nr]); + continue; + } + + } + } + + // set selection value to a translatable value + if (GetbibleHelper::checkArray($items)) + { + foreach ($items as $nr => &$item) + { + // convert role + $item->role = $this->selectionTranslation($item->role, 'role'); + // convert source + $item->source = $this->selectionTranslation($item->source, 'source'); + } + } + + + // return items + return $items; + } + + /** + * Method to convert selection values to translatable string. + * + * @return translatable string + */ + public function selectionTranslation($value,$name) + { + // Array of role language strings + if ($name === 'role') + { + $roleArray = array( + 'system' => 'COM_GETBIBLE_OPEN_AI_MESSAGE_SYSTEM', + 'user' => 'COM_GETBIBLE_OPEN_AI_MESSAGE_USER', + 'assistant' => 'COM_GETBIBLE_OPEN_AI_MESSAGE_ASSISTANT', + 'function' => 'COM_GETBIBLE_OPEN_AI_MESSAGE_FUNCTION' + ); + // Now check if value is found in this array + if (isset($roleArray[$value]) && GetbibleHelper::checkString($roleArray[$value])) + { + return $roleArray[$value]; + } + } + // Array of source language strings + if ($name === 'source') + { + $sourceArray = array( + 1 => 'COM_GETBIBLE_OPEN_AI_MESSAGE_PROMPT', + 2 => 'COM_GETBIBLE_OPEN_AI_MESSAGE_OPEN_AI' + ); + // Now check if value is found in this array + if (isset($sourceArray[$value]) && GetbibleHelper::checkString($sourceArray[$value])) + { + return $sourceArray[$value]; + } + } + return $value; + } + + /** + * Method to build an SQL query to load the list data. + * + * @return string An SQL query + */ + protected function getListQuery() + { + // Get the user object. + $user = JFactory::getUser(); + // Create a new query object. + $db = JFactory::getDBO(); + $query = $db->getQuery(true); + + // Select some fields + $query->select('a.*'); + + // From the getbible_item table + $query->from($db->quoteName('#__getbible_open_ai_message', 'a')); + + // From the getbible_open_ai_response table. + $query->select($db->quoteName(['g.response_id','g.id'],['open_ai_response_response_id','open_ai_response_id'])); + $query->join('LEFT', $db->quoteName('#__getbible_open_ai_response', 'g') . ' ON (' . $db->quoteName('a.open_ai_response') . ' = ' . $db->quoteName('g.response_id') . ')'); + + // From the getbible_prompt table. + $query->select($db->quoteName(['h.name','h.id'],['prompt_name','prompt_id'])); + $query->join('LEFT', $db->quoteName('#__getbible_prompt', 'h') . ' ON (' . $db->quoteName('a.prompt') . ' = ' . $db->quoteName('h.guid') . ')'); + + // Filter by published state + $published = $this->getState('filter.published'); + if (is_numeric($published)) + { + $query->where('a.published = ' . (int) $published); + } + elseif ($published === '') + { + $query->where('(a.published = 0 OR a.published = 1)'); + } + + // Join over the asset groups. + $query->select('ag.title AS access_level'); + $query->join('LEFT', '#__viewlevels AS ag ON ag.id = a.access'); + // Filter by access level. + $_access = $this->getState('filter.access'); + if ($_access && is_numeric($_access)) + { + $query->where('a.access = ' . (int) $_access); + } + elseif (GetbibleHelper::checkArray($_access)) + { + // Secure the array for the query + $_access = ArrayHelper::toInteger($_access); + // Filter by the Access Array. + $query->where('a.access IN (' . implode(',', $_access) . ')'); + } + // Implement View Level Access + if (!$user->authorise('core.options', 'com_getbible')) + { + $groups = implode(',', $user->getAuthorisedViewLevels()); + $query->where('a.access IN (' . $groups . ')'); + } + // Filter by search. + $search = $this->getState('filter.search'); + if (!empty($search)) + { + if (stripos($search, 'id:') === 0) + { + $query->where('a.id = ' . (int) substr($search, 3)); + } + else + { + $search = $db->quote('%' . $db->escape($search) . '%'); + $query->where('(a.content LIKE '.$search.')'); + } + } + + // Filter by Role. + $_role = $this->getState('filter.role'); + if (is_numeric($_role)) + { + if (is_float($_role)) + { + $query->where('a.role = ' . (float) $_role); + } + else + { + $query->where('a.role = ' . (int) $_role); + } + } + elseif (GetbibleHelper::checkString($_role)) + { + $query->where('a.role = ' . $db->quote($db->escape($_role))); + } + // Filter by Open_ai_response. + $_open_ai_response = $this->getState('filter.open_ai_response'); + if (is_numeric($_open_ai_response)) + { + if (is_float($_open_ai_response)) + { + $query->where('a.open_ai_response = ' . (float) $_open_ai_response); + } + else + { + $query->where('a.open_ai_response = ' . (int) $_open_ai_response); + } + } + elseif (GetbibleHelper::checkString($_open_ai_response)) + { + $query->where('a.open_ai_response = ' . $db->quote($db->escape($_open_ai_response))); + } + // Filter by Prompt. + $_prompt = $this->getState('filter.prompt'); + if (is_numeric($_prompt)) + { + if (is_float($_prompt)) + { + $query->where('a.prompt = ' . (float) $_prompt); + } + else + { + $query->where('a.prompt = ' . (int) $_prompt); + } + } + elseif (GetbibleHelper::checkString($_prompt)) + { + $query->where('a.prompt = ' . $db->quote($db->escape($_prompt))); + } + // Filter by Source. + $_source = $this->getState('filter.source'); + if (is_numeric($_source)) + { + if (is_float($_source)) + { + $query->where('a.source = ' . (float) $_source); + } + else + { + $query->where('a.source = ' . (int) $_source); + } + } + elseif (GetbibleHelper::checkString($_source)) + { + $query->where('a.source = ' . $db->quote($db->escape($_source))); + } + + // Add the list ordering clause. + $orderCol = $this->state->get('list.ordering', 'a.id'); + $orderDirn = $this->state->get('list.direction', 'desc'); + if ($orderCol != '') + { + $query->order($db->escape($orderCol . ' ' . $orderDirn)); + } + + return $query; + } + + /** + * Method to get a store id based on model configuration state. + * + * @return string A store id. + * + */ + protected function getStoreId($id = '') + { + // Compile the store id. + $id .= ':' . $this->getState('filter.id'); + $id .= ':' . $this->getState('filter.search'); + $id .= ':' . $this->getState('filter.published'); + // Check if the value is an array + $_access = $this->getState('filter.access'); + if (GetbibleHelper::checkArray($_access)) + { + $id .= ':' . implode(':', $_access); + } + // Check if this is only an number or string + elseif (is_numeric($_access) + || GetbibleHelper::checkString($_access)) + { + $id .= ':' . $_access; + } + $id .= ':' . $this->getState('filter.ordering'); + $id .= ':' . $this->getState('filter.created_by'); + $id .= ':' . $this->getState('filter.modified_by'); + $id .= ':' . $this->getState('filter.role'); + $id .= ':' . $this->getState('filter.open_ai_response'); + $id .= ':' . $this->getState('filter.prompt'); + $id .= ':' . $this->getState('filter.source'); + + return parent::getStoreId($id); + } + + /** + * Build an SQL query to checkin all items left checked out longer then a set time. + * + * @return a bool + * + */ + protected function checkInNow() + { + // Get set check in time + $time = JComponentHelper::getParams('com_getbible')->get('check_in'); + + if ($time) + { + + // Get a db connection. + $db = JFactory::getDbo(); + // Reset query. + $query = $db->getQuery(true); + $query->select('*'); + $query->from($db->quoteName('#__getbible_open_ai_message')); + // Only select items that are checked out. + $query->where($db->quoteName('checked_out') . '!=0'); + $db->setQuery($query, 0, 1); + $db->execute(); + if ($db->getNumRows()) + { + // Get Yesterdays date. + $date = JFactory::getDate()->modify($time)->toSql(); + // Reset query. + $query = $db->getQuery(true); + + // Fields to update. + $fields = array( + $db->quoteName('checked_out_time') . '=\'0000-00-00 00:00:00\'', + $db->quoteName('checked_out') . '=0' + ); + + // Conditions for which records should be updated. + $conditions = array( + $db->quoteName('checked_out') . '!=0', + $db->quoteName('checked_out_time') . '<\''.$date.'\'' + ); + + // Check table. + $query->update($db->quoteName('#__getbible_open_ai_message'))->set($fields)->where($conditions); + + $db->setQuery($query); + + $db->execute(); + } + } + + return false; + } +} diff --git a/admin/models/open_ai_response.php b/admin/models/open_ai_response.php new file mode 100644 index 0000000..aeb1fb3 --- /dev/null +++ b/admin/models/open_ai_response.php @@ -0,0 +1,1458 @@ + + @git Get Bible + @github Get Bible + @support Get Bible + @copyright Copyright (C) 2015. All Rights Reserved + @license GNU/GPL Version 2 or later - http://www.gnu.org/licenses/gpl-2.0.html + +/------------------------------------------------------------------------------------------------------*/ + +// No direct access to this file +defined('_JEXEC') or die('Restricted access'); + +use Joomla\CMS\MVC\Model\AdminModel; +use Joomla\Registry\Registry; +use Joomla\String\StringHelper; +use Joomla\Utilities\ArrayHelper; + +/** + * Getbible Open_ai_response Admin Model + */ +class GetbibleModelOpen_ai_response extends AdminModel +{ + /** + * The tab layout fields array. + * + * @var array + */ + protected $tabLayoutFields = array( + 'details' => array( + 'left' => array( + 'response_object', + 'response_model', + 'response_created' + ), + 'right' => array( + 'prompt_tokens', + 'completion_tokens', + 'total_tokens' + ), + 'above' => array( + 'response_id', + 'prompt' + ) + ), + 'prompt' => array( + 'left' => array( + 'max_tokens', + 'temperature', + 'top_p' + ), + 'right' => array( + 'model', + 'presence_penalty', + 'frequency_penalty', + 'n' + ) + ), + 'bible' => array( + 'left' => array( + 'abbreviation', + 'language', + 'lcsh', + 'book' + ), + 'right' => array( + 'chapter', + 'verse', + 'word', + 'selected_word' + ) + ) + ); + + /** + * @var string The prefix to use with controller messages. + * @since 1.6 + */ + protected $text_prefix = 'COM_GETBIBLE'; + + /** + * The type alias for this content type. + * + * @var string + * @since 3.2 + */ + public $typeAlias = 'com_getbible.open_ai_response'; + + /** + * Returns a Table object, always creating it + * + * @param type $type The table type to instantiate + * @param string $prefix A prefix for the table class name. Optional. + * @param array $config Configuration array for model. Optional. + * + * @return JTable A database object + * + * @since 1.6 + */ + public function getTable($type = 'open_ai_response', $prefix = 'GetbibleTable', $config = array()) + { + // add table path for when model gets used from other component + $this->addTablePath(JPATH_ADMINISTRATOR . '/components/com_getbible/tables'); + // get instance of the table + return JTable::getInstance($type, $prefix, $config); + } + + /** + * Method to get a single record. + * + * @param integer $pk The id of the primary key. + * + * @return mixed Object on success, false on failure. + * + * @since 1.6 + */ + public function getItem($pk = null) + { + if ($item = parent::getItem($pk)) + { + if (!empty($item->params) && !is_array($item->params)) + { + // Convert the params field to an array. + $registry = new Registry; + $registry->loadString($item->params); + $item->params = $registry->toArray(); + } + + if (!empty($item->metadata)) + { + // Convert the metadata field to an array. + $registry = new Registry; + $registry->loadString($item->metadata); + $item->metadata = $registry->toArray(); + } + } + $this->open_ai_responsevvvy = $item->response_id; + + return $item; + } + + /** + * Method to get list data. + * + * @return mixed An array of data items on success, false on failure. + */ + public function getVvymessage() + { + // Get the user object. + $user = JFactory::getUser(); + // Create a new query object. + $db = JFactory::getDBO(); + $query = $db->getQuery(true); + + // Select some fields + $query->select('a.*'); + + // From the getbible_open_ai_message table + $query->from($db->quoteName('#__getbible_open_ai_message', 'a')); + + // From the getbible_open_ai_response table. + $query->select($db->quoteName(['g.response_id','g.id'],['open_ai_response_response_id','open_ai_response_id'])); + $query->join('LEFT', $db->quoteName('#__getbible_open_ai_response', 'g') . ' ON (' . $db->quoteName('a.open_ai_response') . ' = ' . $db->quoteName('g.response_id') . ')'); + + // From the getbible_prompt table. + $query->select($db->quoteName(['h.name','h.id'],['prompt_name','prompt_id'])); + $query->join('LEFT', $db->quoteName('#__getbible_prompt', 'h') . ' ON (' . $db->quoteName('a.prompt') . ' = ' . $db->quoteName('h.guid') . ')'); + + // Filter by open_ai_responsevvvy global. + $open_ai_responsevvvy = $this->open_ai_responsevvvy; + if (is_numeric($open_ai_responsevvvy )) + { + $query->where('a.open_ai_response = ' . (int) $open_ai_responsevvvy ); + } + elseif (is_string($open_ai_responsevvvy)) + { + $query->where('a.open_ai_response = ' . $db->quote($open_ai_responsevvvy)); + } + else + { + $query->where('a.open_ai_response = -5'); + } + + // Join over the asset groups. + $query->select('ag.title AS access_level'); + $query->join('LEFT', '#__viewlevels AS ag ON ag.id = a.access'); + // Filter by access level. + $_access = $this->getState('filter.access'); + if ($_access && is_numeric($_access)) + { + $query->where('a.access = ' . (int) $_access); + } + elseif (GetbibleHelper::checkArray($_access)) + { + // Secure the array for the query + $_access = ArrayHelper::toInteger($_access); + // Filter by the Access Array. + $query->where('a.access IN (' . implode(',', $_access) . ')'); + } + // Implement View Level Access + if (!$user->authorise('core.options', 'com_getbible')) + { + $groups = implode(',', $user->getAuthorisedViewLevels()); + $query->where('a.access IN (' . $groups . ')'); + } + + // Order the results by ordering + $query->order('a.published ASC'); + $query->order('a.ordering ASC'); + + // Load the items + $db->setQuery($query); + $db->execute(); + if ($db->getNumRows()) + { + $items = $db->loadObjectList(); + + // Set values to display correctly. + if (GetbibleHelper::checkArray($items)) + { + // Get the user object if not set. + if (!isset($user) || !GetbibleHelper::checkObject($user)) + { + $user = JFactory::getUser(); + } + foreach ($items as $nr => &$item) + { + // Remove items the user can't access. + $access = ($user->authorise('open_ai_message.access', 'com_getbible.open_ai_message.' . (int) $item->id) && $user->authorise('open_ai_message.access', 'com_getbible')); + if (!$access) + { + unset($items[$nr]); + continue; + } + + } + } + + // set selection value to a translatable value + if (GetbibleHelper::checkArray($items)) + { + foreach ($items as $nr => &$item) + { + // convert role + $item->role = $this->selectionTranslationVvymessage($item->role, 'role'); + // convert source + $item->source = $this->selectionTranslationVvymessage($item->source, 'source'); + } + } + + return $items; + } + return false; + } + + /** + * Method to convert selection values to translatable string. + * + * @return translatable string + */ + public function selectionTranslationVvymessage($value,$name) + { + // Array of role language strings + if ($name === 'role') + { + $roleArray = array( + 'system' => 'COM_GETBIBLE_OPEN_AI_MESSAGE_SYSTEM', + 'user' => 'COM_GETBIBLE_OPEN_AI_MESSAGE_USER', + 'assistant' => 'COM_GETBIBLE_OPEN_AI_MESSAGE_ASSISTANT', + 'function' => 'COM_GETBIBLE_OPEN_AI_MESSAGE_FUNCTION' + ); + // Now check if value is found in this array + if (isset($roleArray[$value]) && GetbibleHelper::checkString($roleArray[$value])) + { + return $roleArray[$value]; + } + } + // Array of source language strings + if ($name === 'source') + { + $sourceArray = array( + 1 => 'COM_GETBIBLE_OPEN_AI_MESSAGE_PROMPT', + 2 => 'COM_GETBIBLE_OPEN_AI_MESSAGE_OPEN_AI' + ); + // Now check if value is found in this array + if (isset($sourceArray[$value]) && GetbibleHelper::checkString($sourceArray[$value])) + { + return $sourceArray[$value]; + } + } + return $value; + } + + /** + * Method to get the record form. + * + * @param array $data Data for the form. + * @param boolean $loadData True if the form is to load its own data (default case), false if not. + * @param array $options Optional array of options for the form creation. + * + * @return mixed A JForm object on success, false on failure + * + * @since 1.6 + */ + public function getForm($data = array(), $loadData = true, $options = array('control' => 'jform')) + { + // set load data option + $options['load_data'] = $loadData; + // check if xpath was set in options + $xpath = false; + if (isset($options['xpath'])) + { + $xpath = $options['xpath']; + unset($options['xpath']); + } + // check if clear form was set in options + $clear = false; + if (isset($options['clear'])) + { + $clear = $options['clear']; + unset($options['clear']); + } + + // Get the form. + $form = $this->loadForm('com_getbible.open_ai_response', 'open_ai_response', $options, $clear, $xpath); + + if (empty($form)) + { + return false; + } + + $jinput = JFactory::getApplication()->input; + + // The front end calls this model and uses a_id to avoid id clashes so we need to check for that first. + if ($jinput->get('a_id')) + { + $id = $jinput->get('a_id', 0, 'INT'); + } + // The back end uses id so we use that the rest of the time and set it to 0 by default. + else + { + $id = $jinput->get('id', 0, 'INT'); + } + + $user = JFactory::getUser(); + + // Check for existing item. + // Modify the form based on Edit State access controls. + if ($id != 0 && (!$user->authorise('open_ai_response.edit.state', 'com_getbible.open_ai_response.' . (int) $id)) + || ($id == 0 && !$user->authorise('open_ai_response.edit.state', 'com_getbible'))) + { + // Disable fields for display. + $form->setFieldAttribute('ordering', 'disabled', 'true'); + $form->setFieldAttribute('published', 'disabled', 'true'); + // Disable fields while saving. + $form->setFieldAttribute('ordering', 'filter', 'unset'); + $form->setFieldAttribute('published', 'filter', 'unset'); + } + // If this is a new item insure the greated by is set. + if (0 == $id) + { + // Set the created_by to this user + $form->setValue('created_by', null, $user->id); + } + // Modify the form based on Edit Creaded By access controls. + if ($id != 0 && (!$user->authorise('open_ai_response.edit.created_by', 'com_getbible.open_ai_response.' . (int) $id)) + || ($id == 0 && !$user->authorise('open_ai_response.edit.created_by', 'com_getbible'))) + { + // Disable fields for display. + $form->setFieldAttribute('created_by', 'disabled', 'true'); + // Disable fields for display. + $form->setFieldAttribute('created_by', 'readonly', 'true'); + // Disable fields while saving. + $form->setFieldAttribute('created_by', 'filter', 'unset'); + } + // Modify the form based on Edit Creaded Date access controls. + if ($id != 0 && (!$user->authorise('open_ai_response.edit.created', 'com_getbible.open_ai_response.' . (int) $id)) + || ($id == 0 && !$user->authorise('open_ai_response.edit.created', 'com_getbible'))) + { + // Disable fields for display. + $form->setFieldAttribute('created', 'disabled', 'true'); + // Disable fields while saving. + $form->setFieldAttribute('created', 'filter', 'unset'); + } + // Modify the form based on Edit Response Id access controls. + if ($id != 0 && (!$user->authorise('open_ai_response.edit.response_id', 'com_getbible.open_ai_response.' . (int) $id)) + || ($id == 0 && !$user->authorise('open_ai_response.edit.response_id', 'com_getbible'))) + { + // Disable fields for display. + $form->setFieldAttribute('response_id', 'disabled', 'true'); + // Disable fields for display. + $form->setFieldAttribute('response_id', 'readonly', 'true'); + // If there is no value continue. + if (!$form->getValue('response_id')) + { + // Disable fields while saving. + $form->setFieldAttribute('response_id', 'filter', 'unset'); + // Disable fields while saving. + $form->setFieldAttribute('response_id', 'required', 'false'); + } + } + // Modify the form based on Edit Prompt access controls. + if ($id != 0 && (!$user->authorise('open_ai_response.edit.prompt', 'com_getbible.open_ai_response.' . (int) $id)) + || ($id == 0 && !$user->authorise('open_ai_response.edit.prompt', 'com_getbible'))) + { + // Disable fields for display. + $form->setFieldAttribute('prompt', 'disabled', 'true'); + // Disable fields for display. + $form->setFieldAttribute('prompt', 'readonly', 'true'); + // If there is no value continue. + if (!$form->getValue('prompt')) + { + // Disable fields while saving. + $form->setFieldAttribute('prompt', 'filter', 'unset'); + // Disable fields while saving. + $form->setFieldAttribute('prompt', 'required', 'false'); + } + } + // Modify the form based on Edit Response Object access controls. + if ($id != 0 && (!$user->authorise('open_ai_response.edit.response_object', 'com_getbible.open_ai_response.' . (int) $id)) + || ($id == 0 && !$user->authorise('open_ai_response.edit.response_object', 'com_getbible'))) + { + // Disable fields for display. + $form->setFieldAttribute('response_object', 'disabled', 'true'); + // Disable fields for display. + $form->setFieldAttribute('response_object', 'readonly', 'true'); + // If there is no value continue. + if (!$form->getValue('response_object')) + { + // Disable fields while saving. + $form->setFieldAttribute('response_object', 'filter', 'unset'); + // Disable fields while saving. + $form->setFieldAttribute('response_object', 'required', 'false'); + } + } + // Modify the form based on Edit Response Model access controls. + if ($id != 0 && (!$user->authorise('open_ai_response.edit.response_model', 'com_getbible.open_ai_response.' . (int) $id)) + || ($id == 0 && !$user->authorise('open_ai_response.edit.response_model', 'com_getbible'))) + { + // Disable fields for display. + $form->setFieldAttribute('response_model', 'disabled', 'true'); + // Disable fields for display. + $form->setFieldAttribute('response_model', 'readonly', 'true'); + // If there is no value continue. + if (!$form->getValue('response_model')) + { + // Disable fields while saving. + $form->setFieldAttribute('response_model', 'filter', 'unset'); + // Disable fields while saving. + $form->setFieldAttribute('response_model', 'required', 'false'); + } + } + // Modify the form based on Edit Total Tokens access controls. + if ($id != 0 && (!$user->authorise('open_ai_response.edit.total_tokens', 'com_getbible.open_ai_response.' . (int) $id)) + || ($id == 0 && !$user->authorise('open_ai_response.edit.total_tokens', 'com_getbible'))) + { + // Disable fields for display. + $form->setFieldAttribute('total_tokens', 'disabled', 'true'); + // Disable fields for display. + $form->setFieldAttribute('total_tokens', 'readonly', 'true'); + // If there is no value continue. + if (!$form->getValue('total_tokens')) + { + // Disable fields while saving. + $form->setFieldAttribute('total_tokens', 'filter', 'unset'); + // Disable fields while saving. + $form->setFieldAttribute('total_tokens', 'required', 'false'); + } + } + // Modify the form based on Edit N access controls. + if ($id != 0 && (!$user->authorise('open_ai_response.edit.n', 'com_getbible.open_ai_response.' . (int) $id)) + || ($id == 0 && !$user->authorise('open_ai_response.edit.n', 'com_getbible'))) + { + // Disable fields for display. + $form->setFieldAttribute('n', 'disabled', 'true'); + // Disable fields for display. + $form->setFieldAttribute('n', 'readonly', 'true'); + // If there is no value continue. + if (!$form->getValue('n')) + { + // Disable fields while saving. + $form->setFieldAttribute('n', 'filter', 'unset'); + // Disable fields while saving. + $form->setFieldAttribute('n', 'required', 'false'); + } + } + // Modify the form based on Edit Frequency Penalty access controls. + if ($id != 0 && (!$user->authorise('open_ai_response.edit.frequency_penalty', 'com_getbible.open_ai_response.' . (int) $id)) + || ($id == 0 && !$user->authorise('open_ai_response.edit.frequency_penalty', 'com_getbible'))) + { + // Disable fields for display. + $form->setFieldAttribute('frequency_penalty', 'disabled', 'true'); + // Disable fields for display. + $form->setFieldAttribute('frequency_penalty', 'readonly', 'true'); + // If there is no value continue. + if (!$form->getValue('frequency_penalty')) + { + // Disable fields while saving. + $form->setFieldAttribute('frequency_penalty', 'filter', 'unset'); + // Disable fields while saving. + $form->setFieldAttribute('frequency_penalty', 'required', 'false'); + } + } + // Modify the form based on Edit Presence Penalty access controls. + if ($id != 0 && (!$user->authorise('open_ai_response.edit.presence_penalty', 'com_getbible.open_ai_response.' . (int) $id)) + || ($id == 0 && !$user->authorise('open_ai_response.edit.presence_penalty', 'com_getbible'))) + { + // Disable fields for display. + $form->setFieldAttribute('presence_penalty', 'disabled', 'true'); + // Disable fields for display. + $form->setFieldAttribute('presence_penalty', 'readonly', 'true'); + // If there is no value continue. + if (!$form->getValue('presence_penalty')) + { + // Disable fields while saving. + $form->setFieldAttribute('presence_penalty', 'filter', 'unset'); + // Disable fields while saving. + $form->setFieldAttribute('presence_penalty', 'required', 'false'); + } + } + // Modify the form based on Edit Word access controls. + if ($id != 0 && (!$user->authorise('open_ai_response.edit.word', 'com_getbible.open_ai_response.' . (int) $id)) + || ($id == 0 && !$user->authorise('open_ai_response.edit.word', 'com_getbible'))) + { + // Disable fields for display. + $form->setFieldAttribute('word', 'disabled', 'true'); + // Disable fields for display. + $form->setFieldAttribute('word', 'readonly', 'true'); + // If there is no value continue. + if (!$form->getValue('word')) + { + // Disable fields while saving. + $form->setFieldAttribute('word', 'filter', 'unset'); + // Disable fields while saving. + $form->setFieldAttribute('word', 'required', 'false'); + } + } + // Modify the form based on Edit Chapter access controls. + if ($id != 0 && (!$user->authorise('open_ai_response.edit.chapter', 'com_getbible.open_ai_response.' . (int) $id)) + || ($id == 0 && !$user->authorise('open_ai_response.edit.chapter', 'com_getbible'))) + { + // Disable fields for display. + $form->setFieldAttribute('chapter', 'disabled', 'true'); + // Disable fields for display. + $form->setFieldAttribute('chapter', 'readonly', 'true'); + // If there is no value continue. + if (!$form->getValue('chapter')) + { + // Disable fields while saving. + $form->setFieldAttribute('chapter', 'filter', 'unset'); + // Disable fields while saving. + $form->setFieldAttribute('chapter', 'required', 'false'); + } + } + // Modify the form based on Edit Lcsh access controls. + if ($id != 0 && (!$user->authorise('open_ai_response.edit.lcsh', 'com_getbible.open_ai_response.' . (int) $id)) + || ($id == 0 && !$user->authorise('open_ai_response.edit.lcsh', 'com_getbible'))) + { + // Disable fields for display. + $form->setFieldAttribute('lcsh', 'disabled', 'true'); + // Disable fields for display. + $form->setFieldAttribute('lcsh', 'readonly', 'true'); + // If there is no value continue. + if (!$form->getValue('lcsh')) + { + // Disable fields while saving. + $form->setFieldAttribute('lcsh', 'filter', 'unset'); + // Disable fields while saving. + $form->setFieldAttribute('lcsh', 'required', 'false'); + } + } + // Modify the form based on Edit Completion Tokens access controls. + if ($id != 0 && (!$user->authorise('open_ai_response.edit.completion_tokens', 'com_getbible.open_ai_response.' . (int) $id)) + || ($id == 0 && !$user->authorise('open_ai_response.edit.completion_tokens', 'com_getbible'))) + { + // Disable fields for display. + $form->setFieldAttribute('completion_tokens', 'disabled', 'true'); + // Disable fields for display. + $form->setFieldAttribute('completion_tokens', 'readonly', 'true'); + // If there is no value continue. + if (!$form->getValue('completion_tokens')) + { + // Disable fields while saving. + $form->setFieldAttribute('completion_tokens', 'filter', 'unset'); + // Disable fields while saving. + $form->setFieldAttribute('completion_tokens', 'required', 'false'); + } + } + // Modify the form based on Edit Prompt Tokens access controls. + if ($id != 0 && (!$user->authorise('open_ai_response.edit.prompt_tokens', 'com_getbible.open_ai_response.' . (int) $id)) + || ($id == 0 && !$user->authorise('open_ai_response.edit.prompt_tokens', 'com_getbible'))) + { + // Disable fields for display. + $form->setFieldAttribute('prompt_tokens', 'disabled', 'true'); + // Disable fields for display. + $form->setFieldAttribute('prompt_tokens', 'readonly', 'true'); + // If there is no value continue. + if (!$form->getValue('prompt_tokens')) + { + // Disable fields while saving. + $form->setFieldAttribute('prompt_tokens', 'filter', 'unset'); + // Disable fields while saving. + $form->setFieldAttribute('prompt_tokens', 'required', 'false'); + } + } + // Modify the form based on Edit Response Created access controls. + if ($id != 0 && (!$user->authorise('open_ai_response.edit.response_created', 'com_getbible.open_ai_response.' . (int) $id)) + || ($id == 0 && !$user->authorise('open_ai_response.edit.response_created', 'com_getbible'))) + { + // Disable fields for display. + $form->setFieldAttribute('response_created', 'disabled', 'true'); + // Disable fields for display. + $form->setFieldAttribute('response_created', 'readonly', 'true'); + // If there is no value continue. + if (!$form->getValue('response_created')) + { + // Disable fields while saving. + $form->setFieldAttribute('response_created', 'filter', 'unset'); + // Disable fields while saving. + $form->setFieldAttribute('response_created', 'required', 'false'); + } + } + // Modify the form based on Edit Abbreviation access controls. + if ($id != 0 && (!$user->authorise('open_ai_response.edit.abbreviation', 'com_getbible.open_ai_response.' . (int) $id)) + || ($id == 0 && !$user->authorise('open_ai_response.edit.abbreviation', 'com_getbible'))) + { + // Disable fields for display. + $form->setFieldAttribute('abbreviation', 'disabled', 'true'); + // Disable fields for display. + $form->setFieldAttribute('abbreviation', 'readonly', 'true'); + // If there is no value continue. + if (!$form->getValue('abbreviation')) + { + // Disable fields while saving. + $form->setFieldAttribute('abbreviation', 'filter', 'unset'); + // Disable fields while saving. + $form->setFieldAttribute('abbreviation', 'required', 'false'); + } + } + // Modify the form based on Edit Language access controls. + if ($id != 0 && (!$user->authorise('open_ai_response.edit.language', 'com_getbible.open_ai_response.' . (int) $id)) + || ($id == 0 && !$user->authorise('open_ai_response.edit.language', 'com_getbible'))) + { + // Disable fields for display. + $form->setFieldAttribute('language', 'disabled', 'true'); + // Disable fields for display. + $form->setFieldAttribute('language', 'readonly', 'true'); + // If there is no value continue. + if (!$form->getValue('language')) + { + // Disable fields while saving. + $form->setFieldAttribute('language', 'filter', 'unset'); + // Disable fields while saving. + $form->setFieldAttribute('language', 'required', 'false'); + } + } + // Modify the form based on Edit Max Tokens access controls. + if ($id != 0 && (!$user->authorise('open_ai_response.edit.max_tokens', 'com_getbible.open_ai_response.' . (int) $id)) + || ($id == 0 && !$user->authorise('open_ai_response.edit.max_tokens', 'com_getbible'))) + { + // Disable fields for display. + $form->setFieldAttribute('max_tokens', 'disabled', 'true'); + // Disable fields for display. + $form->setFieldAttribute('max_tokens', 'readonly', 'true'); + // If there is no value continue. + if (!$form->getValue('max_tokens')) + { + // Disable fields while saving. + $form->setFieldAttribute('max_tokens', 'filter', 'unset'); + // Disable fields while saving. + $form->setFieldAttribute('max_tokens', 'required', 'false'); + } + } + // Modify the form based on Edit Book access controls. + if ($id != 0 && (!$user->authorise('open_ai_response.edit.book', 'com_getbible.open_ai_response.' . (int) $id)) + || ($id == 0 && !$user->authorise('open_ai_response.edit.book', 'com_getbible'))) + { + // Disable fields for display. + $form->setFieldAttribute('book', 'disabled', 'true'); + // Disable fields for display. + $form->setFieldAttribute('book', 'readonly', 'true'); + // If there is no value continue. + if (!$form->getValue('book')) + { + // Disable fields while saving. + $form->setFieldAttribute('book', 'filter', 'unset'); + // Disable fields while saving. + $form->setFieldAttribute('book', 'required', 'false'); + } + } + // Modify the form based on Edit Temperature access controls. + if ($id != 0 && (!$user->authorise('open_ai_response.edit.temperature', 'com_getbible.open_ai_response.' . (int) $id)) + || ($id == 0 && !$user->authorise('open_ai_response.edit.temperature', 'com_getbible'))) + { + // Disable fields for display. + $form->setFieldAttribute('temperature', 'disabled', 'true'); + // Disable fields for display. + $form->setFieldAttribute('temperature', 'readonly', 'true'); + // If there is no value continue. + if (!$form->getValue('temperature')) + { + // Disable fields while saving. + $form->setFieldAttribute('temperature', 'filter', 'unset'); + // Disable fields while saving. + $form->setFieldAttribute('temperature', 'required', 'false'); + } + } + // Modify the form based on Edit Verse access controls. + if ($id != 0 && (!$user->authorise('open_ai_response.edit.verse', 'com_getbible.open_ai_response.' . (int) $id)) + || ($id == 0 && !$user->authorise('open_ai_response.edit.verse', 'com_getbible'))) + { + // Disable fields for display. + $form->setFieldAttribute('verse', 'disabled', 'true'); + // Disable fields for display. + $form->setFieldAttribute('verse', 'readonly', 'true'); + // If there is no value continue. + if (!$form->getValue('verse')) + { + // Disable fields while saving. + $form->setFieldAttribute('verse', 'filter', 'unset'); + // Disable fields while saving. + $form->setFieldAttribute('verse', 'required', 'false'); + } + } + // Modify the form based on Edit Top P access controls. + if ($id != 0 && (!$user->authorise('open_ai_response.edit.top_p', 'com_getbible.open_ai_response.' . (int) $id)) + || ($id == 0 && !$user->authorise('open_ai_response.edit.top_p', 'com_getbible'))) + { + // Disable fields for display. + $form->setFieldAttribute('top_p', 'disabled', 'true'); + // Disable fields for display. + $form->setFieldAttribute('top_p', 'readonly', 'true'); + // If there is no value continue. + if (!$form->getValue('top_p')) + { + // Disable fields while saving. + $form->setFieldAttribute('top_p', 'filter', 'unset'); + // Disable fields while saving. + $form->setFieldAttribute('top_p', 'required', 'false'); + } + } + // Modify the form based on Edit Selected Word access controls. + if ($id != 0 && (!$user->authorise('open_ai_response.edit.selected_word', 'com_getbible.open_ai_response.' . (int) $id)) + || ($id == 0 && !$user->authorise('open_ai_response.edit.selected_word', 'com_getbible'))) + { + // Disable fields for display. + $form->setFieldAttribute('selected_word', 'disabled', 'true'); + // Disable fields for display. + $form->setFieldAttribute('selected_word', 'readonly', 'true'); + // If there is no value continue. + if (!$form->getValue('selected_word')) + { + // Disable fields while saving. + $form->setFieldAttribute('selected_word', 'filter', 'unset'); + // Disable fields while saving. + $form->setFieldAttribute('selected_word', 'required', 'false'); + } + } + // Modify the form based on Edit Model access controls. + if ($id != 0 && (!$user->authorise('open_ai_response.edit.model', 'com_getbible.open_ai_response.' . (int) $id)) + || ($id == 0 && !$user->authorise('open_ai_response.edit.model', 'com_getbible'))) + { + // Disable fields for display. + $form->setFieldAttribute('model', 'disabled', 'true'); + // Disable fields for display. + $form->setFieldAttribute('model', 'readonly', 'true'); + // If there is no value continue. + if (!$form->getValue('model')) + { + // Disable fields while saving. + $form->setFieldAttribute('model', 'filter', 'unset'); + // Disable fields while saving. + $form->setFieldAttribute('model', 'required', 'false'); + } + } + // Only load these values if no id is found + if (0 == $id) + { + // Set redirected view name + $redirectedView = $jinput->get('ref', null, 'STRING'); + // Set field name (or fall back to view name) + $redirectedField = $jinput->get('field', $redirectedView, 'STRING'); + // Set redirected view id + $redirectedId = $jinput->get('refid', 0, 'INT'); + // Set field id (or fall back to redirected view id) + $redirectedValue = $jinput->get('field_id', $redirectedId, 'INT'); + if (0 != $redirectedValue && $redirectedField) + { + // Now set the local-redirected field default value + $form->setValue($redirectedField, null, $redirectedValue); + } + } + return $form; + } + + /** + * Method to get the script that have to be included on the form + * + * @return string script files + */ + public function getScript() + { + return 'media/com_getbible/js/open_ai_response.js'; + } + + /** + * Method to test whether a record can be deleted. + * + * @param object $record A record object. + * + * @return boolean True if allowed to delete the record. Defaults to the permission set in the component. + * + * @since 1.6 + */ + protected function canDelete($record) + { + if (!empty($record->id)) + { + if ($record->published != -2) + { + return; + } + + $user = JFactory::getUser(); + // The record has been set. Check the record permissions. + return $user->authorise('open_ai_response.delete', 'com_getbible.open_ai_response.' . (int) $record->id); + } + return false; + } + + /** + * Method to test whether a record can have its state edited. + * + * @param object $record A record object. + * + * @return boolean True if allowed to change the state of the record. Defaults to the permission set in the component. + * + * @since 1.6 + */ + protected function canEditState($record) + { + $user = JFactory::getUser(); + $recordId = (!empty($record->id)) ? $record->id : 0; + + if ($recordId) + { + // The record has been set. Check the record permissions. + $permission = $user->authorise('open_ai_response.edit.state', 'com_getbible.open_ai_response.' . (int) $recordId); + if (!$permission && !is_null($permission)) + { + return false; + } + } + // In the absense of better information, revert to the component permissions. + return $user->authorise('open_ai_response.edit.state', 'com_getbible'); + } + + /** + * Method override to check if you can edit an existing record. + * + * @param array $data An array of input data. + * @param string $key The name of the key for the primary key. + * + * @return boolean + * @since 2.5 + */ + protected function allowEdit($data = array(), $key = 'id') + { + // Check specific edit permission then general edit permission. + $user = JFactory::getUser(); + + return $user->authorise('open_ai_response.edit', 'com_getbible.open_ai_response.'. ((int) isset($data[$key]) ? $data[$key] : 0)) or $user->authorise('open_ai_response.edit', 'com_getbible'); + } + + /** + * Prepare and sanitise the table data prior to saving. + * + * @param JTable $table A JTable object. + * + * @return void + * + * @since 1.6 + */ + protected function prepareTable($table) + { + $date = JFactory::getDate(); + $user = JFactory::getUser(); + + if (isset($table->name)) + { + $table->name = htmlspecialchars_decode($table->name, ENT_QUOTES); + } + + if (isset($table->alias) && empty($table->alias)) + { + $table->generateAlias(); + } + + if (empty($table->id)) + { + $table->created = $date->toSql(); + // set the user + if ($table->created_by == 0 || empty($table->created_by)) + { + $table->created_by = $user->id; + } + // Set ordering to the last item if not set + if (empty($table->ordering)) + { + $db = JFactory::getDbo(); + $query = $db->getQuery(true) + ->select('MAX(ordering)') + ->from($db->quoteName('#__getbible_open_ai_response')); + $db->setQuery($query); + $max = $db->loadResult(); + + $table->ordering = $max + 1; + } + } + else + { + $table->modified = $date->toSql(); + $table->modified_by = $user->id; + } + + if (!empty($table->id)) + { + // Increment the items version number. + $table->version++; + } + } + + /** + * Method to get the data that should be injected in the form. + * + * @return mixed The data for the form. + * + * @since 1.6 + */ + protected function loadFormData() + { + // Check the session for previously entered form data. + $data = JFactory::getApplication()->getUserState('com_getbible.edit.open_ai_response.data', array()); + + if (empty($data)) + { + $data = $this->getItem(); + // run the perprocess of the data + $this->preprocessData('com_getbible.open_ai_response', $data); + } + + return $data; + } + + /** + * Method to get the unique fields of this table. + * + * @return mixed An array of field names, boolean false if none is set. + * + * @since 3.0 + */ + protected function getUniqueFields() + { + return false; + } + + /** + * Method to delete one or more records. + * + * @param array &$pks An array of record primary keys. + * + * @return boolean True if successful, false if an error occurs. + * + * @since 12.2 + */ + public function delete(&$pks) + { + if (!parent::delete($pks)) + { + return false; + } + + return true; + } + + /** + * Method to change the published state of one or more records. + * + * @param array &$pks A list of the primary keys to change. + * @param integer $value The value of the published state. + * + * @return boolean True on success. + * + * @since 12.2 + */ + public function publish(&$pks, $value = 1) + { + if (!parent::publish($pks, $value)) + { + return false; + } + + return true; + } + + /** + * Method to perform batch operations on an item or a set of items. + * + * @param array $commands An array of commands to perform. + * @param array $pks An array of item ids. + * @param array $contexts An array of item contexts. + * + * @return boolean Returns true on success, false on failure. + * + * @since 12.2 + */ + public function batch($commands, $pks, $contexts) + { + // Sanitize ids. + $pks = array_unique($pks); + ArrayHelper::toInteger($pks); + + // Remove any values of zero. + if (array_search(0, $pks, true)) + { + unset($pks[array_search(0, $pks, true)]); + } + + if (empty($pks)) + { + $this->setError(JText::_('JGLOBAL_NO_ITEM_SELECTED')); + return false; + } + + $done = false; + + // Set some needed variables. + $this->user = JFactory::getUser(); + $this->table = $this->getTable(); + $this->tableClassName = get_class($this->table); + $this->contentType = new JUcmType; + $this->type = $this->contentType->getTypeByTable($this->tableClassName); + $this->canDo = GetbibleHelper::getActions('open_ai_response'); + $this->batchSet = true; + + if (!$this->canDo->get('core.batch')) + { + $this->setError(JText::_('JLIB_APPLICATION_ERROR_INSUFFICIENT_BATCH_INFORMATION')); + return false; + } + + if ($this->type == false) + { + $type = new JUcmType; + $this->type = $type->getTypeByAlias($this->typeAlias); + } + + $this->tagsObserver = $this->table->getObserverOfClass('JTableObserverTags'); + + if (!empty($commands['move_copy'])) + { + $cmd = ArrayHelper::getValue($commands, 'move_copy', 'c'); + + if ($cmd == 'c') + { + $result = $this->batchCopy($commands, $pks, $contexts); + + if (is_array($result)) + { + foreach ($result as $old => $new) + { + $contexts[$new] = $contexts[$old]; + } + $pks = array_values($result); + } + else + { + return false; + } + } + elseif ($cmd == 'm' && !$this->batchMove($commands, $pks, $contexts)) + { + return false; + } + + $done = true; + } + + if (!$done) + { + $this->setError(JText::_('JLIB_APPLICATION_ERROR_INSUFFICIENT_BATCH_INFORMATION')); + + return false; + } + + // Clear the cache + $this->cleanCache(); + + return true; + } + + /** + * Batch copy items to a new category or current. + * + * @param integer $values The new values. + * @param array $pks An array of row IDs. + * @param array $contexts An array of item contexts. + * + * @return mixed An array of new IDs on success, boolean false on failure. + * + * @since 12.2 + */ + protected function batchCopy($values, $pks, $contexts) + { + if (empty($this->batchSet)) + { + // Set some needed variables. + $this->user = JFactory::getUser(); + $this->table = $this->getTable(); + $this->tableClassName = get_class($this->table); + $this->canDo = GetbibleHelper::getActions('open_ai_response'); + } + + if (!$this->canDo->get('open_ai_response.create') && !$this->canDo->get('open_ai_response.batch')) + { + return false; + } + + // get list of unique fields + $uniqueFields = $this->getUniqueFields(); + // remove move_copy from array + unset($values['move_copy']); + + // make sure published is set + if (!isset($values['published'])) + { + $values['published'] = 0; + } + elseif (isset($values['published']) && !$this->canDo->get('open_ai_response.edit.state')) + { + $values['published'] = 0; + } + + $newIds = array(); + // Parent exists so let's proceed + while (!empty($pks)) + { + // Pop the first ID off the stack + $pk = array_shift($pks); + + $this->table->reset(); + + // only allow copy if user may edit this item. + if (!$this->user->authorise('open_ai_response.edit', $contexts[$pk])) + { + // Not fatal error + $this->setError(JText::sprintf('JLIB_APPLICATION_ERROR_BATCH_MOVE_ROW_NOT_FOUND', $pk)); + continue; + } + + // Check that the row actually exists + if (!$this->table->load($pk)) + { + if ($error = $this->table->getError()) + { + // Fatal error + $this->setError($error); + return false; + } + else + { + // Not fatal error + $this->setError(JText::sprintf('JLIB_APPLICATION_ERROR_BATCH_MOVE_ROW_NOT_FOUND', $pk)); + continue; + } + } + + // Only for strings + if (GetbibleHelper::checkString($this->table->response_id) && !is_numeric($this->table->response_id)) + { + $this->table->response_id = $this->generateUnique('response_id',$this->table->response_id); + } + + // insert all set values + if (GetbibleHelper::checkArray($values)) + { + foreach ($values as $key => $value) + { + if (strlen($value) > 0 && isset($this->table->$key)) + { + $this->table->$key = $value; + } + } + } + + // update all unique fields + if (GetbibleHelper::checkArray($uniqueFields)) + { + foreach ($uniqueFields as $uniqueField) + { + $this->table->$uniqueField = $this->generateUnique($uniqueField,$this->table->$uniqueField); + } + } + + // Reset the ID because we are making a copy + $this->table->id = 0; + + // TODO: Deal with ordering? + // $this->table->ordering = 1; + + // Check the row. + if (!$this->table->check()) + { + $this->setError($this->table->getError()); + + return false; + } + + if (!empty($this->type)) + { + $this->createTagsHelper($this->tagsObserver, $this->type, $pk, $this->typeAlias, $this->table); + } + + // Store the row. + if (!$this->table->store()) + { + $this->setError($this->table->getError()); + + return false; + } + + // Get the new item ID + $newId = $this->table->get('id'); + + // Add the new ID to the array + $newIds[$pk] = $newId; + } + + // Clean the cache + $this->cleanCache(); + + return $newIds; + } + + /** + * Batch move items to a new category + * + * @param integer $value The new category ID. + * @param array $pks An array of row IDs. + * @param array $contexts An array of item contexts. + * + * @return boolean True if successful, false otherwise and internal error is set. + * + * @since 12.2 + */ + protected function batchMove($values, $pks, $contexts) + { + if (empty($this->batchSet)) + { + // Set some needed variables. + $this->user = JFactory::getUser(); + $this->table = $this->getTable(); + $this->tableClassName = get_class($this->table); + $this->canDo = GetbibleHelper::getActions('open_ai_response'); + } + + if (!$this->canDo->get('open_ai_response.edit') && !$this->canDo->get('open_ai_response.batch')) + { + $this->setError(JText::_('JLIB_APPLICATION_ERROR_BATCH_CANNOT_EDIT')); + return false; + } + + // make sure published only updates if user has the permission. + if (isset($values['published']) && !$this->canDo->get('open_ai_response.edit.state')) + { + unset($values['published']); + } + // remove move_copy from array + unset($values['move_copy']); + + // Parent exists so we proceed + foreach ($pks as $pk) + { + if (!$this->user->authorise('open_ai_response.edit', $contexts[$pk])) + { + $this->setError(JText::_('JLIB_APPLICATION_ERROR_BATCH_CANNOT_EDIT')); + return false; + } + + // Check that the row actually exists + if (!$this->table->load($pk)) + { + if ($error = $this->table->getError()) + { + // Fatal error + $this->setError($error); + return false; + } + else + { + // Not fatal error + $this->setError(JText::sprintf('JLIB_APPLICATION_ERROR_BATCH_MOVE_ROW_NOT_FOUND', $pk)); + continue; + } + } + + // insert all set values. + if (GetbibleHelper::checkArray($values)) + { + foreach ($values as $key => $value) + { + // Do special action for access. + if ('access' === $key && strlen($value) > 0) + { + $this->table->$key = $value; + } + elseif (strlen($value) > 0 && isset($this->table->$key)) + { + $this->table->$key = $value; + } + } + } + + + // Check the row. + if (!$this->table->check()) + { + $this->setError($this->table->getError()); + + return false; + } + + if (!empty($this->type)) + { + $this->createTagsHelper($this->tagsObserver, $this->type, $pk, $this->typeAlias, $this->table); + } + + // Store the row. + if (!$this->table->store()) + { + $this->setError($this->table->getError()); + + return false; + } + } + + // Clean the cache + $this->cleanCache(); + + return true; + } + + /** + * Method to save the form data. + * + * @param array $data The form data. + * + * @return boolean True on success. + * + * @since 1.6 + */ + public function save($data) + { + $input = JFactory::getApplication()->input; + $filter = JFilterInput::getInstance(); + + // set the metadata to the Item Data + if (isset($data['metadata']) && isset($data['metadata']['author'])) + { + $data['metadata']['author'] = $filter->clean($data['metadata']['author'], 'TRIM'); + + $metadata = new JRegistry; + $metadata->loadArray($data['metadata']); + $data['metadata'] = (string) $metadata; + } + + // Set the Params Items to data + if (isset($data['params']) && is_array($data['params'])) + { + $params = new JRegistry; + $params->loadArray($data['params']); + $data['params'] = (string) $params; + } + + // Alter the unique field for save as copy + if ($input->get('task') === 'save2copy') + { + // Automatic handling of other unique fields + $uniqueFields = $this->getUniqueFields(); + if (GetbibleHelper::checkArray($uniqueFields)) + { + foreach ($uniqueFields as $uniqueField) + { + $data[$uniqueField] = $this->generateUnique($uniqueField,$data[$uniqueField]); + } + } + } + + if (parent::save($data)) + { + return true; + } + return false; + } + + /** + * Method to generate a unique value. + * + * @param string $field name. + * @param string $value data. + * + * @return string New value. + * + * @since 3.0 + */ + protected function generateUnique($field,$value) + { + + // set field value unique + $table = $this->getTable(); + + while ($table->load(array($field => $value))) + { + $value = StringHelper::increment($value); + } + + return $value; + } + + /** + * Method to change the title + * + * @param string $title The title. + * + * @return array Contains the modified title and alias. + * + */ + protected function _generateNewTitle($title) + { + + // Alter the title + $table = $this->getTable(); + + while ($table->load(array('title' => $title))) + { + $title = StringHelper::increment($title); + } + + return $title; + } +} diff --git a/admin/models/open_ai_responses.php b/admin/models/open_ai_responses.php new file mode 100644 index 0000000..bc2fe45 --- /dev/null +++ b/admin/models/open_ai_responses.php @@ -0,0 +1,398 @@ + + @git Get Bible + @github Get Bible + @support Get Bible + @copyright Copyright (C) 2015. All Rights Reserved + @license GNU/GPL Version 2 or later - http://www.gnu.org/licenses/gpl-2.0.html + +/------------------------------------------------------------------------------------------------------*/ + +// No direct access to this file +defined('_JEXEC') or die('Restricted access'); + +use Joomla\CMS\MVC\Model\ListModel; +use Joomla\Utilities\ArrayHelper; + +/** + * Open_ai_responses List Model + */ +class GetbibleModelOpen_ai_responses extends ListModel +{ + public function __construct($config = array()) + { + if (empty($config['filter_fields'])) + { + $config['filter_fields'] = array( + 'a.id','id', + 'a.published','published', + 'a.access','access', + 'a.ordering','ordering', + 'a.created_by','created_by', + 'a.modified_by','modified_by', + 'a.response_id','response_id', + 'g.name','prompt', + 'a.response_model','response_model', + 'a.response_object','response_object', + 'a.total_tokens','total_tokens' + ); + } + + parent::__construct($config); + } + + /** + * Method to auto-populate the model state. + * + * Note. Calling getState in this method will result in recursion. + * + * @param string $ordering An optional ordering field. + * @param string $direction An optional direction (asc|desc). + * + * @return void + * + */ + protected function populateState($ordering = null, $direction = null) + { + $app = JFactory::getApplication(); + + // Adjust the context to support modal layouts. + if ($layout = $app->input->get('layout')) + { + $this->context .= '.' . $layout; + } + + // Check if the form was submitted + $formSubmited = $app->input->post->get('form_submited'); + + $access = $this->getUserStateFromRequest($this->context . '.filter.access', 'filter_access', 0, 'int'); + if ($formSubmited) + { + $access = $app->input->post->get('access'); + $this->setState('filter.access', $access); + } + + $published = $this->getUserStateFromRequest($this->context . '.filter.published', 'filter_published', ''); + $this->setState('filter.published', $published); + + $created_by = $this->getUserStateFromRequest($this->context . '.filter.created_by', 'filter_created_by', ''); + $this->setState('filter.created_by', $created_by); + + $created = $this->getUserStateFromRequest($this->context . '.filter.created', 'filter_created'); + $this->setState('filter.created', $created); + + $sorting = $this->getUserStateFromRequest($this->context . '.filter.sorting', 'filter_sorting', 0, 'int'); + $this->setState('filter.sorting', $sorting); + + $search = $this->getUserStateFromRequest($this->context . '.filter.search', 'filter_search'); + $this->setState('filter.search', $search); + + $response_id = $this->getUserStateFromRequest($this->context . '.filter.response_id', 'filter_response_id'); + if ($formSubmited) + { + $response_id = $app->input->post->get('response_id'); + $this->setState('filter.response_id', $response_id); + } + + $prompt = $this->getUserStateFromRequest($this->context . '.filter.prompt', 'filter_prompt'); + if ($formSubmited) + { + $prompt = $app->input->post->get('prompt'); + $this->setState('filter.prompt', $prompt); + } + + $response_model = $this->getUserStateFromRequest($this->context . '.filter.response_model', 'filter_response_model'); + if ($formSubmited) + { + $response_model = $app->input->post->get('response_model'); + $this->setState('filter.response_model', $response_model); + } + + $response_object = $this->getUserStateFromRequest($this->context . '.filter.response_object', 'filter_response_object'); + if ($formSubmited) + { + $response_object = $app->input->post->get('response_object'); + $this->setState('filter.response_object', $response_object); + } + + $total_tokens = $this->getUserStateFromRequest($this->context . '.filter.total_tokens', 'filter_total_tokens'); + if ($formSubmited) + { + $total_tokens = $app->input->post->get('total_tokens'); + $this->setState('filter.total_tokens', $total_tokens); + } + + // List state information. + parent::populateState($ordering, $direction); + } + + /** + * Method to get an array of data items. + * + * @return mixed An array of data items on success, false on failure. + */ + public function getItems() + { + // Check in items + $this->checkInNow(); + + // load parent items + $items = parent::getItems(); + + // Set values to display correctly. + if (GetbibleHelper::checkArray($items)) + { + // Get the user object if not set. + if (!isset($user) || !GetbibleHelper::checkObject($user)) + { + $user = JFactory::getUser(); + } + foreach ($items as $nr => &$item) + { + // Remove items the user can't access. + $access = ($user->authorise('open_ai_response.access', 'com_getbible.open_ai_response.' . (int) $item->id) && $user->authorise('open_ai_response.access', 'com_getbible')); + if (!$access) + { + unset($items[$nr]); + continue; + } + + } + } + + // return items + return $items; + } + + /** + * Method to build an SQL query to load the list data. + * + * @return string An SQL query + */ + protected function getListQuery() + { + // Get the user object. + $user = JFactory::getUser(); + // Create a new query object. + $db = JFactory::getDBO(); + $query = $db->getQuery(true); + + // Select some fields + $query->select('a.*'); + + // From the getbible_item table + $query->from($db->quoteName('#__getbible_open_ai_response', 'a')); + + // From the getbible_prompt table. + $query->select($db->quoteName(['g.name','g.id'],['prompt_name','prompt_id'])); + $query->join('LEFT', $db->quoteName('#__getbible_prompt', 'g') . ' ON (' . $db->quoteName('a.prompt') . ' = ' . $db->quoteName('g.guid') . ')'); + + // Filter by published state + $published = $this->getState('filter.published'); + if (is_numeric($published)) + { + $query->where('a.published = ' . (int) $published); + } + elseif ($published === '') + { + $query->where('(a.published = 0 OR a.published = 1)'); + } + + // Join over the asset groups. + $query->select('ag.title AS access_level'); + $query->join('LEFT', '#__viewlevels AS ag ON ag.id = a.access'); + // Filter by access level. + $_access = $this->getState('filter.access'); + if ($_access && is_numeric($_access)) + { + $query->where('a.access = ' . (int) $_access); + } + elseif (GetbibleHelper::checkArray($_access)) + { + // Secure the array for the query + $_access = ArrayHelper::toInteger($_access); + // Filter by the Access Array. + $query->where('a.access IN (' . implode(',', $_access) . ')'); + } + // Implement View Level Access + if (!$user->authorise('core.options', 'com_getbible')) + { + $groups = implode(',', $user->getAuthorisedViewLevels()); + $query->where('a.access IN (' . $groups . ')'); + } + // Filter by search. + $search = $this->getState('filter.search'); + if (!empty($search)) + { + if (stripos($search, 'id:') === 0) + { + $query->where('a.id = ' . (int) substr($search, 3)); + } + else + { + $search = $db->quote('%' . $db->escape($search) . '%'); + $query->where('(a.response_object LIKE '.$search.' OR a.response_model LIKE '.$search.')'); + } + } + + // Filter by Response_id. + $_response_id = $this->getState('filter.response_id'); + if (is_numeric($_response_id)) + { + if (is_float($_response_id)) + { + $query->where('a.response_id = ' . (float) $_response_id); + } + else + { + $query->where('a.response_id = ' . (int) $_response_id); + } + } + elseif (GetbibleHelper::checkString($_response_id)) + { + $query->where('a.response_id = ' . $db->quote($db->escape($_response_id))); + } + // Filter by Prompt. + $_prompt = $this->getState('filter.prompt'); + if (is_numeric($_prompt)) + { + if (is_float($_prompt)) + { + $query->where('a.prompt = ' . (float) $_prompt); + } + else + { + $query->where('a.prompt = ' . (int) $_prompt); + } + } + elseif (GetbibleHelper::checkString($_prompt)) + { + $query->where('a.prompt = ' . $db->quote($db->escape($_prompt))); + } + // Filter by Response_model. + $_response_model = $this->getState('filter.response_model'); + if (is_numeric($_response_model)) + { + if (is_float($_response_model)) + { + $query->where('a.response_model = ' . (float) $_response_model); + } + else + { + $query->where('a.response_model = ' . (int) $_response_model); + } + } + elseif (GetbibleHelper::checkString($_response_model)) + { + $query->where('a.response_model = ' . $db->quote($db->escape($_response_model))); + } + + // Add the list ordering clause. + $orderCol = $this->state->get('list.ordering', 'a.id'); + $orderDirn = $this->state->get('list.direction', 'desc'); + if ($orderCol != '') + { + $query->order($db->escape($orderCol . ' ' . $orderDirn)); + } + + return $query; + } + + /** + * Method to get a store id based on model configuration state. + * + * @return string A store id. + * + */ + protected function getStoreId($id = '') + { + // Compile the store id. + $id .= ':' . $this->getState('filter.id'); + $id .= ':' . $this->getState('filter.search'); + $id .= ':' . $this->getState('filter.published'); + // Check if the value is an array + $_access = $this->getState('filter.access'); + if (GetbibleHelper::checkArray($_access)) + { + $id .= ':' . implode(':', $_access); + } + // Check if this is only an number or string + elseif (is_numeric($_access) + || GetbibleHelper::checkString($_access)) + { + $id .= ':' . $_access; + } + $id .= ':' . $this->getState('filter.ordering'); + $id .= ':' . $this->getState('filter.created_by'); + $id .= ':' . $this->getState('filter.modified_by'); + $id .= ':' . $this->getState('filter.response_id'); + $id .= ':' . $this->getState('filter.prompt'); + $id .= ':' . $this->getState('filter.response_model'); + $id .= ':' . $this->getState('filter.response_object'); + $id .= ':' . $this->getState('filter.total_tokens'); + + return parent::getStoreId($id); + } + + /** + * Build an SQL query to checkin all items left checked out longer then a set time. + * + * @return a bool + * + */ + protected function checkInNow() + { + // Get set check in time + $time = JComponentHelper::getParams('com_getbible')->get('check_in'); + + if ($time) + { + + // Get a db connection. + $db = JFactory::getDbo(); + // Reset query. + $query = $db->getQuery(true); + $query->select('*'); + $query->from($db->quoteName('#__getbible_open_ai_response')); + // Only select items that are checked out. + $query->where($db->quoteName('checked_out') . '!=0'); + $db->setQuery($query, 0, 1); + $db->execute(); + if ($db->getNumRows()) + { + // Get Yesterdays date. + $date = JFactory::getDate()->modify($time)->toSql(); + // Reset query. + $query = $db->getQuery(true); + + // Fields to update. + $fields = array( + $db->quoteName('checked_out_time') . '=\'0000-00-00 00:00:00\'', + $db->quoteName('checked_out') . '=0' + ); + + // Conditions for which records should be updated. + $conditions = array( + $db->quoteName('checked_out') . '!=0', + $db->quoteName('checked_out_time') . '<\''.$date.'\'' + ); + + // Check table. + $query->update($db->quoteName('#__getbible_open_ai_response'))->set($fields)->where($conditions); + + $db->setQuery($query); + + $db->execute(); + } + } + + return false; + } +} diff --git a/admin/models/password.php b/admin/models/password.php new file mode 100644 index 0000000..10d9895 --- /dev/null +++ b/admin/models/password.php @@ -0,0 +1,1005 @@ + + @git Get Bible + @github Get Bible + @support Get Bible + @copyright Copyright (C) 2015. All Rights Reserved + @license GNU/GPL Version 2 or later - http://www.gnu.org/licenses/gpl-2.0.html + +/------------------------------------------------------------------------------------------------------*/ + +// No direct access to this file +defined('_JEXEC') or die('Restricted access'); + +use Joomla\CMS\MVC\Model\AdminModel; +use Joomla\Registry\Registry; +use Joomla\String\StringHelper; +use Joomla\Utilities\ArrayHelper; +use VDM\Joomla\Utilities\GuidHelper; +use VDM\Joomla\Utilities\GetHelper; + +/** + * Getbible Password Admin Model + */ +class GetbibleModelPassword extends AdminModel +{ + /** + * The tab layout fields array. + * + * @var array + */ + protected $tabLayoutFields = array( + 'details' => array( + 'left' => array( + 'name' + ), + 'right' => array( + 'password' + ), + 'above' => array( + 'linker' + ) + ) + ); + + /** + * @var string The prefix to use with controller messages. + * @since 1.6 + */ + protected $text_prefix = 'COM_GETBIBLE'; + + /** + * The type alias for this content type. + * + * @var string + * @since 3.2 + */ + public $typeAlias = 'com_getbible.password'; + + /** + * Returns a Table object, always creating it + * + * @param type $type The table type to instantiate + * @param string $prefix A prefix for the table class name. Optional. + * @param array $config Configuration array for model. Optional. + * + * @return JTable A database object + * + * @since 1.6 + */ + public function getTable($type = 'password', $prefix = 'GetbibleTable', $config = array()) + { + // add table path for when model gets used from other component + $this->addTablePath(JPATH_ADMINISTRATOR . '/components/com_getbible/tables'); + // get instance of the table + return JTable::getInstance($type, $prefix, $config); + } + + /** + * Method to get a single record. + * + * @param integer $pk The id of the primary key. + * + * @return mixed Object on success, false on failure. + * + * @since 1.6 + */ + public function getItem($pk = null) + { + if ($item = parent::getItem($pk)) + { + if (!empty($item->params) && !is_array($item->params)) + { + // Convert the params field to an array. + $registry = new Registry; + $registry->loadString($item->params); + $item->params = $registry->toArray(); + } + + if (!empty($item->metadata)) + { + // Convert the metadata field to an array. + $registry = new Registry; + $registry->loadString($item->metadata); + $item->metadata = $registry->toArray(); + } + } + + return $item; + } + + /** + * Method to get the record form. + * + * @param array $data Data for the form. + * @param boolean $loadData True if the form is to load its own data (default case), false if not. + * @param array $options Optional array of options for the form creation. + * + * @return mixed A JForm object on success, false on failure + * + * @since 1.6 + */ + public function getForm($data = array(), $loadData = true, $options = array('control' => 'jform')) + { + // set load data option + $options['load_data'] = $loadData; + // check if xpath was set in options + $xpath = false; + if (isset($options['xpath'])) + { + $xpath = $options['xpath']; + unset($options['xpath']); + } + // check if clear form was set in options + $clear = false; + if (isset($options['clear'])) + { + $clear = $options['clear']; + unset($options['clear']); + } + + // Get the form. + $form = $this->loadForm('com_getbible.password', 'password', $options, $clear, $xpath); + + if (empty($form)) + { + return false; + } + + $jinput = JFactory::getApplication()->input; + + // The front end calls this model and uses a_id to avoid id clashes so we need to check for that first. + if ($jinput->get('a_id')) + { + $id = $jinput->get('a_id', 0, 'INT'); + } + // The back end uses id so we use that the rest of the time and set it to 0 by default. + else + { + $id = $jinput->get('id', 0, 'INT'); + } + + $user = JFactory::getUser(); + + // Check for existing item. + // Modify the form based on Edit State access controls. + if ($id != 0 && (!$user->authorise('password.edit.state', 'com_getbible.password.' . (int) $id)) + || ($id == 0 && !$user->authorise('password.edit.state', 'com_getbible'))) + { + // Disable fields for display. + $form->setFieldAttribute('ordering', 'disabled', 'true'); + $form->setFieldAttribute('published', 'disabled', 'true'); + // Disable fields while saving. + $form->setFieldAttribute('ordering', 'filter', 'unset'); + $form->setFieldAttribute('published', 'filter', 'unset'); + } + // If this is a new item insure the greated by is set. + if (0 == $id) + { + // Set the created_by to this user + $form->setValue('created_by', null, $user->id); + } + // Modify the form based on Edit Creaded By access controls. + if ($id != 0 && (!$user->authorise('password.edit.created_by', 'com_getbible.password.' . (int) $id)) + || ($id == 0 && !$user->authorise('password.edit.created_by', 'com_getbible'))) + { + // Disable fields for display. + $form->setFieldAttribute('created_by', 'disabled', 'true'); + // Disable fields for display. + $form->setFieldAttribute('created_by', 'readonly', 'true'); + // Disable fields while saving. + $form->setFieldAttribute('created_by', 'filter', 'unset'); + } + // Modify the form based on Edit Creaded Date access controls. + if ($id != 0 && (!$user->authorise('password.edit.created', 'com_getbible.password.' . (int) $id)) + || ($id == 0 && !$user->authorise('password.edit.created', 'com_getbible'))) + { + // Disable fields for display. + $form->setFieldAttribute('created', 'disabled', 'true'); + // Disable fields while saving. + $form->setFieldAttribute('created', 'filter', 'unset'); + } + // Modify the form based on Edit Name access controls. + if ($id != 0 && (!$user->authorise('password.edit.name', 'com_getbible.password.' . (int) $id)) + || ($id == 0 && !$user->authorise('password.edit.name', 'com_getbible'))) + { + // Disable fields for display. + $form->setFieldAttribute('name', 'disabled', 'true'); + // Disable fields for display. + $form->setFieldAttribute('name', 'readonly', 'true'); + // If there is no value continue. + if (!$form->getValue('name')) + { + // Disable fields while saving. + $form->setFieldAttribute('name', 'filter', 'unset'); + // Disable fields while saving. + $form->setFieldAttribute('name', 'required', 'false'); + } + } + // Modify the form based on Edit Linker access controls. + if ($id != 0 && (!$user->authorise('password.edit.linker', 'com_getbible.password.' . (int) $id)) + || ($id == 0 && !$user->authorise('password.edit.linker', 'com_getbible'))) + { + // Disable fields for display. + $form->setFieldAttribute('linker', 'disabled', 'true'); + // Disable fields for display. + $form->setFieldAttribute('linker', 'readonly', 'true'); + // If there is no value continue. + if (!$form->getValue('linker')) + { + // Disable fields while saving. + $form->setFieldAttribute('linker', 'filter', 'unset'); + // Disable fields while saving. + $form->setFieldAttribute('linker', 'required', 'false'); + } + } + // Modify the form based on Edit Guid access controls. + if ($id != 0 && (!$user->authorise('password.edit.guid', 'com_getbible.password.' . (int) $id)) + || ($id == 0 && !$user->authorise('password.edit.guid', 'com_getbible'))) + { + // Disable fields for display. + $form->setFieldAttribute('guid', 'disabled', 'true'); + // Disable fields for display. + $form->setFieldAttribute('guid', 'readonly', 'true'); + // If there is no value continue. + if (!$form->getValue('guid')) + { + // Disable fields while saving. + $form->setFieldAttribute('guid', 'filter', 'unset'); + // Disable fields while saving. + $form->setFieldAttribute('guid', 'required', 'false'); + } + } + // Modify the form based on Edit Password access controls. + if ($id != 0 && (!$user->authorise('password.edit.password', 'com_getbible.password.' . (int) $id)) + || ($id == 0 && !$user->authorise('password.edit.password', 'com_getbible'))) + { + // Disable fields for display. + $form->setFieldAttribute('password', 'disabled', 'true'); + // Disable fields for display. + $form->setFieldAttribute('password', 'readonly', 'true'); + // If there is no value continue. + if (!$form->getValue('password')) + { + // Disable fields while saving. + $form->setFieldAttribute('password', 'filter', 'unset'); + // Disable fields while saving. + $form->setFieldAttribute('password', 'required', 'false'); + } + } + // Modify the from the form based on Password access controls. + if ($id != 0 && (!$user->authorise('password.access.password', 'com_getbible.password.' . (int) $id)) + || ($id == 0 && !$user->authorise('password.access.password', 'com_getbible'))) + { + // Remove the field + $form->removeField('password'); + } + // Modify the form based on View Password access controls. + if ($id != 0 && (!$user->authorise('password.view.password', 'com_getbible.password.' . (int) $id)) + || ($id == 0 && !$user->authorise('password.view.password', 'com_getbible'))) + { + // Make the field hidded. + $form->setFieldAttribute('password', 'type', 'hidden'); + // If there is no value continue. + if (!($val = $form->getValue('password'))) + { + // Disable fields while saving. + $form->setFieldAttribute('password', 'filter', 'unset'); + // Disable fields while saving. + $form->setFieldAttribute('password', 'required', 'false'); + // Make sure + $form->setValue('password', null, ''); + } + elseif (GetbibleHelper::checkArray($val)) + { + // We have to unset then (TODO) + // Hiddend field can not handel array value + // Even if we convert to json we get an error + $form->removeField('password'); + } + } + // Only load these values if no id is found + if (0 == $id) + { + // Set redirected view name + $redirectedView = $jinput->get('ref', null, 'STRING'); + // Set field name (or fall back to view name) + $redirectedField = $jinput->get('field', $redirectedView, 'STRING'); + // Set redirected view id + $redirectedId = $jinput->get('refid', 0, 'INT'); + // Set field id (or fall back to redirected view id) + $redirectedValue = $jinput->get('field_id', $redirectedId, 'INT'); + if (0 != $redirectedValue && $redirectedField) + { + // Now set the local-redirected field default value + $form->setValue($redirectedField, null, $redirectedValue); + } + } + + // Only load the GUID if new item (or empty) + if (0 == $id || !($val = $form->getValue('guid'))) + { + $form->setValue('guid', null, GuidHelper::get()); + } + + return $form; + } + + /** + * Method to get the script that have to be included on the form + * + * @return string script files + */ + public function getScript() + { + return 'media/com_getbible/js/password.js'; + } + + /** + * Method to test whether a record can be deleted. + * + * @param object $record A record object. + * + * @return boolean True if allowed to delete the record. Defaults to the permission set in the component. + * + * @since 1.6 + */ + protected function canDelete($record) + { + if (!empty($record->id)) + { + if ($record->published != -2) + { + return; + } + + $user = JFactory::getUser(); + // The record has been set. Check the record permissions. + return $user->authorise('password.delete', 'com_getbible.password.' . (int) $record->id); + } + return false; + } + + /** + * Method to test whether a record can have its state edited. + * + * @param object $record A record object. + * + * @return boolean True if allowed to change the state of the record. Defaults to the permission set in the component. + * + * @since 1.6 + */ + protected function canEditState($record) + { + $user = JFactory::getUser(); + $recordId = (!empty($record->id)) ? $record->id : 0; + + if ($recordId) + { + // The record has been set. Check the record permissions. + $permission = $user->authorise('password.edit.state', 'com_getbible.password.' . (int) $recordId); + if (!$permission && !is_null($permission)) + { + return false; + } + } + // In the absense of better information, revert to the component permissions. + return $user->authorise('password.edit.state', 'com_getbible'); + } + + /** + * Method override to check if you can edit an existing record. + * + * @param array $data An array of input data. + * @param string $key The name of the key for the primary key. + * + * @return boolean + * @since 2.5 + */ + protected function allowEdit($data = array(), $key = 'id') + { + // Check specific edit permission then general edit permission. + $user = JFactory::getUser(); + + return $user->authorise('password.edit', 'com_getbible.password.'. ((int) isset($data[$key]) ? $data[$key] : 0)) or $user->authorise('password.edit', 'com_getbible'); + } + + /** + * Prepare and sanitise the table data prior to saving. + * + * @param JTable $table A JTable object. + * + * @return void + * + * @since 1.6 + */ + protected function prepareTable($table) + { + $date = JFactory::getDate(); + $user = JFactory::getUser(); + + if (isset($table->name)) + { + $table->name = htmlspecialchars_decode($table->name, ENT_QUOTES); + } + + if (isset($table->alias) && empty($table->alias)) + { + $table->generateAlias(); + } + + if (empty($table->id)) + { + $table->created = $date->toSql(); + // set the user + if ($table->created_by == 0 || empty($table->created_by)) + { + $table->created_by = $user->id; + } + // Set ordering to the last item if not set + if (empty($table->ordering)) + { + $db = JFactory::getDbo(); + $query = $db->getQuery(true) + ->select('MAX(ordering)') + ->from($db->quoteName('#__getbible_password')); + $db->setQuery($query); + $max = $db->loadResult(); + + $table->ordering = $max + 1; + } + } + else + { + $table->modified = $date->toSql(); + $table->modified_by = $user->id; + } + + if (!empty($table->id)) + { + // Increment the items version number. + $table->version++; + } + } + + /** + * Method to get the data that should be injected in the form. + * + * @return mixed The data for the form. + * + * @since 1.6 + */ + protected function loadFormData() + { + // Check the session for previously entered form data. + $data = JFactory::getApplication()->getUserState('com_getbible.edit.password.data', array()); + + if (empty($data)) + { + $data = $this->getItem(); + // run the perprocess of the data + $this->preprocessData('com_getbible.password', $data); + } + + return $data; + } + + /** + * Method to get the unique fields of this table. + * + * @return mixed An array of field names, boolean false if none is set. + * + * @since 3.0 + */ + protected function getUniqueFields() + { + return array('guid'); + } + + /** + * Method to delete one or more records. + * + * @param array &$pks An array of record primary keys. + * + * @return boolean True if successful, false if an error occurs. + * + * @since 12.2 + */ + public function delete(&$pks) + { + if (!parent::delete($pks)) + { + return false; + } + + return true; + } + + /** + * Method to change the published state of one or more records. + * + * @param array &$pks A list of the primary keys to change. + * @param integer $value The value of the published state. + * + * @return boolean True on success. + * + * @since 12.2 + */ + public function publish(&$pks, $value = 1) + { + if (!parent::publish($pks, $value)) + { + return false; + } + + return true; + } + + /** + * Method to perform batch operations on an item or a set of items. + * + * @param array $commands An array of commands to perform. + * @param array $pks An array of item ids. + * @param array $contexts An array of item contexts. + * + * @return boolean Returns true on success, false on failure. + * + * @since 12.2 + */ + public function batch($commands, $pks, $contexts) + { + // Sanitize ids. + $pks = array_unique($pks); + ArrayHelper::toInteger($pks); + + // Remove any values of zero. + if (array_search(0, $pks, true)) + { + unset($pks[array_search(0, $pks, true)]); + } + + if (empty($pks)) + { + $this->setError(JText::_('JGLOBAL_NO_ITEM_SELECTED')); + return false; + } + + $done = false; + + // Set some needed variables. + $this->user = JFactory::getUser(); + $this->table = $this->getTable(); + $this->tableClassName = get_class($this->table); + $this->contentType = new JUcmType; + $this->type = $this->contentType->getTypeByTable($this->tableClassName); + $this->canDo = GetbibleHelper::getActions('password'); + $this->batchSet = true; + + if (!$this->canDo->get('core.batch')) + { + $this->setError(JText::_('JLIB_APPLICATION_ERROR_INSUFFICIENT_BATCH_INFORMATION')); + return false; + } + + if ($this->type == false) + { + $type = new JUcmType; + $this->type = $type->getTypeByAlias($this->typeAlias); + } + + $this->tagsObserver = $this->table->getObserverOfClass('JTableObserverTags'); + + if (!empty($commands['move_copy'])) + { + $cmd = ArrayHelper::getValue($commands, 'move_copy', 'c'); + + if ($cmd == 'c') + { + $result = $this->batchCopy($commands, $pks, $contexts); + + if (is_array($result)) + { + foreach ($result as $old => $new) + { + $contexts[$new] = $contexts[$old]; + } + $pks = array_values($result); + } + else + { + return false; + } + } + elseif ($cmd == 'm' && !$this->batchMove($commands, $pks, $contexts)) + { + return false; + } + + $done = true; + } + + if (!$done) + { + $this->setError(JText::_('JLIB_APPLICATION_ERROR_INSUFFICIENT_BATCH_INFORMATION')); + + return false; + } + + // Clear the cache + $this->cleanCache(); + + return true; + } + + /** + * Batch copy items to a new category or current. + * + * @param integer $values The new values. + * @param array $pks An array of row IDs. + * @param array $contexts An array of item contexts. + * + * @return mixed An array of new IDs on success, boolean false on failure. + * + * @since 12.2 + */ + protected function batchCopy($values, $pks, $contexts) + { + if (empty($this->batchSet)) + { + // Set some needed variables. + $this->user = JFactory::getUser(); + $this->table = $this->getTable(); + $this->tableClassName = get_class($this->table); + $this->canDo = GetbibleHelper::getActions('password'); + } + + if (!$this->canDo->get('password.create') && !$this->canDo->get('password.batch')) + { + return false; + } + + // get list of unique fields + $uniqueFields = $this->getUniqueFields(); + // remove move_copy from array + unset($values['move_copy']); + + // make sure published is set + if (!isset($values['published'])) + { + $values['published'] = 0; + } + elseif (isset($values['published']) && !$this->canDo->get('password.edit.state')) + { + $values['published'] = 0; + } + + $newIds = array(); + // Parent exists so let's proceed + while (!empty($pks)) + { + // Pop the first ID off the stack + $pk = array_shift($pks); + + $this->table->reset(); + + // only allow copy if user may edit this item. + if (!$this->user->authorise('password.edit', $contexts[$pk])) + { + // Not fatal error + $this->setError(JText::sprintf('JLIB_APPLICATION_ERROR_BATCH_MOVE_ROW_NOT_FOUND', $pk)); + continue; + } + + // Check that the row actually exists + if (!$this->table->load($pk)) + { + if ($error = $this->table->getError()) + { + // Fatal error + $this->setError($error); + return false; + } + else + { + // Not fatal error + $this->setError(JText::sprintf('JLIB_APPLICATION_ERROR_BATCH_MOVE_ROW_NOT_FOUND', $pk)); + continue; + } + } + + // Only for strings + if (GetbibleHelper::checkString($this->table->name) && !is_numeric($this->table->name)) + { + $this->table->name = $this->generateUnique('name',$this->table->name); + } + + // insert all set values + if (GetbibleHelper::checkArray($values)) + { + foreach ($values as $key => $value) + { + if (strlen($value) > 0 && isset($this->table->$key)) + { + $this->table->$key = $value; + } + } + } + + // update all unique fields + if (GetbibleHelper::checkArray($uniqueFields)) + { + foreach ($uniqueFields as $uniqueField) + { + $this->table->$uniqueField = $this->generateUnique($uniqueField,$this->table->$uniqueField); + } + } + + // Reset the ID because we are making a copy + $this->table->id = 0; + + // TODO: Deal with ordering? + // $this->table->ordering = 1; + + // Check the row. + if (!$this->table->check()) + { + $this->setError($this->table->getError()); + + return false; + } + + if (!empty($this->type)) + { + $this->createTagsHelper($this->tagsObserver, $this->type, $pk, $this->typeAlias, $this->table); + } + + // Store the row. + if (!$this->table->store()) + { + $this->setError($this->table->getError()); + + return false; + } + + // Get the new item ID + $newId = $this->table->get('id'); + + // Add the new ID to the array + $newIds[$pk] = $newId; + } + + // Clean the cache + $this->cleanCache(); + + return $newIds; + } + + /** + * Batch move items to a new category + * + * @param integer $value The new category ID. + * @param array $pks An array of row IDs. + * @param array $contexts An array of item contexts. + * + * @return boolean True if successful, false otherwise and internal error is set. + * + * @since 12.2 + */ + protected function batchMove($values, $pks, $contexts) + { + if (empty($this->batchSet)) + { + // Set some needed variables. + $this->user = JFactory::getUser(); + $this->table = $this->getTable(); + $this->tableClassName = get_class($this->table); + $this->canDo = GetbibleHelper::getActions('password'); + } + + if (!$this->canDo->get('password.edit') && !$this->canDo->get('password.batch')) + { + $this->setError(JText::_('JLIB_APPLICATION_ERROR_BATCH_CANNOT_EDIT')); + return false; + } + + // make sure published only updates if user has the permission. + if (isset($values['published']) && !$this->canDo->get('password.edit.state')) + { + unset($values['published']); + } + // remove move_copy from array + unset($values['move_copy']); + + // Parent exists so we proceed + foreach ($pks as $pk) + { + if (!$this->user->authorise('password.edit', $contexts[$pk])) + { + $this->setError(JText::_('JLIB_APPLICATION_ERROR_BATCH_CANNOT_EDIT')); + return false; + } + + // Check that the row actually exists + if (!$this->table->load($pk)) + { + if ($error = $this->table->getError()) + { + // Fatal error + $this->setError($error); + return false; + } + else + { + // Not fatal error + $this->setError(JText::sprintf('JLIB_APPLICATION_ERROR_BATCH_MOVE_ROW_NOT_FOUND', $pk)); + continue; + } + } + + // insert all set values. + if (GetbibleHelper::checkArray($values)) + { + foreach ($values as $key => $value) + { + // Do special action for access. + if ('access' === $key && strlen($value) > 0) + { + $this->table->$key = $value; + } + elseif (strlen($value) > 0 && isset($this->table->$key)) + { + $this->table->$key = $value; + } + } + } + + + // Check the row. + if (!$this->table->check()) + { + $this->setError($this->table->getError()); + + return false; + } + + if (!empty($this->type)) + { + $this->createTagsHelper($this->tagsObserver, $this->type, $pk, $this->typeAlias, $this->table); + } + + // Store the row. + if (!$this->table->store()) + { + $this->setError($this->table->getError()); + + return false; + } + } + + // Clean the cache + $this->cleanCache(); + + return true; + } + + /** + * Method to save the form data. + * + * @param array $data The form data. + * + * @return boolean True on success. + * + * @since 1.6 + */ + public function save($data) + { + $input = JFactory::getApplication()->input; + $filter = JFilterInput::getInstance(); + + // set the metadata to the Item Data + if (isset($data['metadata']) && isset($data['metadata']['author'])) + { + $data['metadata']['author'] = $filter->clean($data['metadata']['author'], 'TRIM'); + + $metadata = new JRegistry; + $metadata->loadArray($data['metadata']); + $data['metadata'] = (string) $metadata; + } + + + // Set the GUID if empty or not valid + if (empty($data['guid']) && $data['id'] > 0) + { + // get the existing one + $data['guid'] = (string) GetHelper::var('password', $data['id'], 'id', 'guid'); + } + + // Set the GUID if empty or not valid + while (!GuidHelper::valid($data['guid'], "password", $data['id'])) + { + // must always be set + $data['guid'] = (string) GuidHelper::get(); + } + + // Set the Params Items to data + if (isset($data['params']) && is_array($data['params'])) + { + $params = new JRegistry; + $params->loadArray($data['params']); + $data['params'] = (string) $params; + } + + // Alter the unique field for save as copy + if ($input->get('task') === 'save2copy') + { + // Automatic handling of other unique fields + $uniqueFields = $this->getUniqueFields(); + if (GetbibleHelper::checkArray($uniqueFields)) + { + foreach ($uniqueFields as $uniqueField) + { + $data[$uniqueField] = $this->generateUnique($uniqueField,$data[$uniqueField]); + } + } + } + + if (parent::save($data)) + { + return true; + } + return false; + } + + /** + * Method to generate a unique value. + * + * @param string $field name. + * @param string $value data. + * + * @return string New value. + * + * @since 3.0 + */ + protected function generateUnique($field,$value) + { + + // set field value unique + $table = $this->getTable(); + + while ($table->load(array($field => $value))) + { + $value = StringHelper::increment($value); + } + + return $value; + } + + /** + * Method to change the title + * + * @param string $title The title. + * + * @return array Contains the modified title and alias. + * + */ + protected function _generateNewTitle($title) + { + + // Alter the title + $table = $this->getTable(); + + while ($table->load(array('title' => $title))) + { + $title = StringHelper::increment($title); + } + + return $title; + } +} diff --git a/admin/models/passwords.php b/admin/models/passwords.php new file mode 100644 index 0000000..2eadcbb --- /dev/null +++ b/admin/models/passwords.php @@ -0,0 +1,354 @@ + + @git Get Bible + @github Get Bible + @support Get Bible + @copyright Copyright (C) 2015. All Rights Reserved + @license GNU/GPL Version 2 or later - http://www.gnu.org/licenses/gpl-2.0.html + +/------------------------------------------------------------------------------------------------------*/ + +// No direct access to this file +defined('_JEXEC') or die('Restricted access'); + +use Joomla\CMS\MVC\Model\ListModel; +use Joomla\Utilities\ArrayHelper; + +/** + * Passwords List Model + */ +class GetbibleModelPasswords extends ListModel +{ + public function __construct($config = array()) + { + if (empty($config['filter_fields'])) + { + $config['filter_fields'] = array( + 'a.id','id', + 'a.published','published', + 'a.access','access', + 'a.ordering','ordering', + 'a.created_by','created_by', + 'a.modified_by','modified_by', + 'a.name','name', + 'g.name','linker' + ); + } + + parent::__construct($config); + } + + /** + * Method to auto-populate the model state. + * + * Note. Calling getState in this method will result in recursion. + * + * @param string $ordering An optional ordering field. + * @param string $direction An optional direction (asc|desc). + * + * @return void + * + */ + protected function populateState($ordering = null, $direction = null) + { + $app = JFactory::getApplication(); + + // Adjust the context to support modal layouts. + if ($layout = $app->input->get('layout')) + { + $this->context .= '.' . $layout; + } + + // Check if the form was submitted + $formSubmited = $app->input->post->get('form_submited'); + + $access = $this->getUserStateFromRequest($this->context . '.filter.access', 'filter_access', 0, 'int'); + if ($formSubmited) + { + $access = $app->input->post->get('access'); + $this->setState('filter.access', $access); + } + + $published = $this->getUserStateFromRequest($this->context . '.filter.published', 'filter_published', ''); + $this->setState('filter.published', $published); + + $created_by = $this->getUserStateFromRequest($this->context . '.filter.created_by', 'filter_created_by', ''); + $this->setState('filter.created_by', $created_by); + + $created = $this->getUserStateFromRequest($this->context . '.filter.created', 'filter_created'); + $this->setState('filter.created', $created); + + $sorting = $this->getUserStateFromRequest($this->context . '.filter.sorting', 'filter_sorting', 0, 'int'); + $this->setState('filter.sorting', $sorting); + + $search = $this->getUserStateFromRequest($this->context . '.filter.search', 'filter_search'); + $this->setState('filter.search', $search); + + $name = $this->getUserStateFromRequest($this->context . '.filter.name', 'filter_name'); + if ($formSubmited) + { + $name = $app->input->post->get('name'); + $this->setState('filter.name', $name); + } + + $linker = $this->getUserStateFromRequest($this->context . '.filter.linker', 'filter_linker'); + if ($formSubmited) + { + $linker = $app->input->post->get('linker'); + $this->setState('filter.linker', $linker); + } + + // List state information. + parent::populateState($ordering, $direction); + } + + /** + * Method to get an array of data items. + * + * @return mixed An array of data items on success, false on failure. + */ + public function getItems() + { + // Check in items + $this->checkInNow(); + + // load parent items + $items = parent::getItems(); + + // Set values to display correctly. + if (GetbibleHelper::checkArray($items)) + { + // Get the user object if not set. + if (!isset($user) || !GetbibleHelper::checkObject($user)) + { + $user = JFactory::getUser(); + } + foreach ($items as $nr => &$item) + { + // Remove items the user can't access. + $access = ($user->authorise('password.access', 'com_getbible.password.' . (int) $item->id) && $user->authorise('password.access', 'com_getbible')); + if (!$access) + { + unset($items[$nr]); + continue; + } + + } + } + + // return items + return $items; + } + + /** + * Method to build an SQL query to load the list data. + * + * @return string An SQL query + */ + protected function getListQuery() + { + // Get the user object. + $user = JFactory::getUser(); + // Create a new query object. + $db = JFactory::getDBO(); + $query = $db->getQuery(true); + + // Select some fields + $query->select('a.*'); + + // From the getbible_item table + $query->from($db->quoteName('#__getbible_password', 'a')); + + // From the getbible_linker table. + $query->select($db->quoteName(['g.name','g.id'],['linker_name','linker_id'])); + $query->join('LEFT', $db->quoteName('#__getbible_linker', 'g') . ' ON (' . $db->quoteName('a.linker') . ' = ' . $db->quoteName('g.guid') . ')'); + + // Filter by published state + $published = $this->getState('filter.published'); + if (is_numeric($published)) + { + $query->where('a.published = ' . (int) $published); + } + elseif ($published === '') + { + $query->where('(a.published = 0 OR a.published = 1)'); + } + + // Join over the asset groups. + $query->select('ag.title AS access_level'); + $query->join('LEFT', '#__viewlevels AS ag ON ag.id = a.access'); + // Filter by access level. + $_access = $this->getState('filter.access'); + if ($_access && is_numeric($_access)) + { + $query->where('a.access = ' . (int) $_access); + } + elseif (GetbibleHelper::checkArray($_access)) + { + // Secure the array for the query + $_access = ArrayHelper::toInteger($_access); + // Filter by the Access Array. + $query->where('a.access IN (' . implode(',', $_access) . ')'); + } + // Implement View Level Access + if (!$user->authorise('core.options', 'com_getbible')) + { + $groups = implode(',', $user->getAuthorisedViewLevels()); + $query->where('a.access IN (' . $groups . ')'); + } + // Filter by search. + $search = $this->getState('filter.search'); + if (!empty($search)) + { + if (stripos($search, 'id:') === 0) + { + $query->where('a.id = ' . (int) substr($search, 3)); + } + else + { + $search = $db->quote('%' . $db->escape($search) . '%'); + $query->where('(a.name LIKE '.$search.' OR a.linker LIKE '.$search.' OR g.name LIKE '.$search.')'); + } + } + + // Filter by Name. + $_name = $this->getState('filter.name'); + if (is_numeric($_name)) + { + if (is_float($_name)) + { + $query->where('a.name = ' . (float) $_name); + } + else + { + $query->where('a.name = ' . (int) $_name); + } + } + elseif (GetbibleHelper::checkString($_name)) + { + $query->where('a.name = ' . $db->quote($db->escape($_name))); + } + // Filter by Linker. + $_linker = $this->getState('filter.linker'); + if (is_numeric($_linker)) + { + if (is_float($_linker)) + { + $query->where('a.linker = ' . (float) $_linker); + } + else + { + $query->where('a.linker = ' . (int) $_linker); + } + } + elseif (GetbibleHelper::checkString($_linker)) + { + $query->where('a.linker = ' . $db->quote($db->escape($_linker))); + } + + // Add the list ordering clause. + $orderCol = $this->state->get('list.ordering', 'a.id'); + $orderDirn = $this->state->get('list.direction', 'desc'); + if ($orderCol != '') + { + $query->order($db->escape($orderCol . ' ' . $orderDirn)); + } + + return $query; + } + + /** + * Method to get a store id based on model configuration state. + * + * @return string A store id. + * + */ + protected function getStoreId($id = '') + { + // Compile the store id. + $id .= ':' . $this->getState('filter.id'); + $id .= ':' . $this->getState('filter.search'); + $id .= ':' . $this->getState('filter.published'); + // Check if the value is an array + $_access = $this->getState('filter.access'); + if (GetbibleHelper::checkArray($_access)) + { + $id .= ':' . implode(':', $_access); + } + // Check if this is only an number or string + elseif (is_numeric($_access) + || GetbibleHelper::checkString($_access)) + { + $id .= ':' . $_access; + } + $id .= ':' . $this->getState('filter.ordering'); + $id .= ':' . $this->getState('filter.created_by'); + $id .= ':' . $this->getState('filter.modified_by'); + $id .= ':' . $this->getState('filter.name'); + $id .= ':' . $this->getState('filter.linker'); + + return parent::getStoreId($id); + } + + /** + * Build an SQL query to checkin all items left checked out longer then a set time. + * + * @return a bool + * + */ + protected function checkInNow() + { + // Get set check in time + $time = JComponentHelper::getParams('com_getbible')->get('check_in'); + + if ($time) + { + + // Get a db connection. + $db = JFactory::getDbo(); + // Reset query. + $query = $db->getQuery(true); + $query->select('*'); + $query->from($db->quoteName('#__getbible_password')); + // Only select items that are checked out. + $query->where($db->quoteName('checked_out') . '!=0'); + $db->setQuery($query, 0, 1); + $db->execute(); + if ($db->getNumRows()) + { + // Get Yesterdays date. + $date = JFactory::getDate()->modify($time)->toSql(); + // Reset query. + $query = $db->getQuery(true); + + // Fields to update. + $fields = array( + $db->quoteName('checked_out_time') . '=\'0000-00-00 00:00:00\'', + $db->quoteName('checked_out') . '=0' + ); + + // Conditions for which records should be updated. + $conditions = array( + $db->quoteName('checked_out') . '!=0', + $db->quoteName('checked_out_time') . '<\''.$date.'\'' + ); + + // Check table. + $query->update($db->quoteName('#__getbible_password'))->set($fields)->where($conditions); + + $db->setQuery($query); + + $db->execute(); + } + } + + return false; + } +} diff --git a/admin/models/prompt.php b/admin/models/prompt.php new file mode 100644 index 0000000..4b1ef8b --- /dev/null +++ b/admin/models/prompt.php @@ -0,0 +1,1397 @@ + + @git Get Bible + @github Get Bible + @support Get Bible + @copyright Copyright (C) 2015. All Rights Reserved + @license GNU/GPL Version 2 or later - http://www.gnu.org/licenses/gpl-2.0.html + +/------------------------------------------------------------------------------------------------------*/ + +// No direct access to this file +defined('_JEXEC') or die('Restricted access'); + +use Joomla\CMS\MVC\Model\AdminModel; +use Joomla\Registry\Registry; +use Joomla\String\StringHelper; +use Joomla\Utilities\ArrayHelper; +use VDM\Joomla\Utilities\GuidHelper; +use VDM\Joomla\Utilities\GetHelper; + +/** + * Getbible Prompt Admin Model + */ +class GetbibleModelPrompt extends AdminModel +{ + /** + * The tab layout fields array. + * + * @var array + */ + protected $tabLayoutFields = array( + 'prompt' => array( + 'left' => array( + 'integration', + 'integration_note', + 'cache_behaviour', + 'cache_persistently_expansive_caching_note', + 'cache_basic_note', + 'cache_advance_note' + ), + 'right' => array( + 'cache_capacity', + 'cache_capacity_note', + 'response_retrieval', + 'response_retrieval_note' + ), + 'fullwidth' => array( + 'openai_prompts_placeholders_basic_caching_note', + 'openai_prompts_placeholders_advanced_caching_note', + 'openai_prompts_placeholders_none_caching_note', + 'messages' + ), + 'above' => array( + 'name', + 'abbreviation' + ) + ), + 'open_ai' => array( + 'left' => array( + 'max_tokens_override', + 'max_tokens', + 'max_tokens_note', + 'temperature_override', + 'temperature', + 'temperature_note', + 'top_p_override', + 'top_p', + 'top_p_note', + 'n_override', + 'n', + 'n_note' + ), + 'right' => array( + 'token_override', + 'token', + 'ai_org_token_override', + 'org_token', + 'model', + 'openai_documentation_note', + 'presence_penalty_override', + 'presence_penalty', + 'presence_penalty_note', + 'frequency_penalty_override', + 'frequency_penalty', + 'frequency_penalty_note' + ) + ) + ); + + /** + * @var string The prefix to use with controller messages. + * @since 1.6 + */ + protected $text_prefix = 'COM_GETBIBLE'; + + /** + * The type alias for this content type. + * + * @var string + * @since 3.2 + */ + public $typeAlias = 'com_getbible.prompt'; + + /** + * Returns a Table object, always creating it + * + * @param type $type The table type to instantiate + * @param string $prefix A prefix for the table class name. Optional. + * @param array $config Configuration array for model. Optional. + * + * @return JTable A database object + * + * @since 1.6 + */ + public function getTable($type = 'prompt', $prefix = 'GetbibleTable', $config = array()) + { + // add table path for when model gets used from other component + $this->addTablePath(JPATH_ADMINISTRATOR . '/components/com_getbible/tables'); + // get instance of the table + return JTable::getInstance($type, $prefix, $config); + } + + /** + * Method to get a single record. + * + * @param integer $pk The id of the primary key. + * + * @return mixed Object on success, false on failure. + * + * @since 1.6 + */ + public function getItem($pk = null) + { + if ($item = parent::getItem($pk)) + { + if (!empty($item->params) && !is_array($item->params)) + { + // Convert the params field to an array. + $registry = new Registry; + $registry->loadString($item->params); + $item->params = $registry->toArray(); + } + + if (!empty($item->metadata)) + { + // Convert the metadata field to an array. + $registry = new Registry; + $registry->loadString($item->metadata); + $item->metadata = $registry->toArray(); + } + + if (!empty($item->messages)) + { + // Convert the messages field to an array. + $messages = new Registry; + $messages->loadString($item->messages); + $item->messages = $messages->toArray(); + } + } + + return $item; + } + + /** + * Method to get the record form. + * + * @param array $data Data for the form. + * @param boolean $loadData True if the form is to load its own data (default case), false if not. + * @param array $options Optional array of options for the form creation. + * + * @return mixed A JForm object on success, false on failure + * + * @since 1.6 + */ + public function getForm($data = array(), $loadData = true, $options = array('control' => 'jform')) + { + // set load data option + $options['load_data'] = $loadData; + // check if xpath was set in options + $xpath = false; + if (isset($options['xpath'])) + { + $xpath = $options['xpath']; + unset($options['xpath']); + } + // check if clear form was set in options + $clear = false; + if (isset($options['clear'])) + { + $clear = $options['clear']; + unset($options['clear']); + } + + // Get the form. + $form = $this->loadForm('com_getbible.prompt', 'prompt', $options, $clear, $xpath); + + if (empty($form)) + { + return false; + } + + $jinput = JFactory::getApplication()->input; + + // The front end calls this model and uses a_id to avoid id clashes so we need to check for that first. + if ($jinput->get('a_id')) + { + $id = $jinput->get('a_id', 0, 'INT'); + } + // The back end uses id so we use that the rest of the time and set it to 0 by default. + else + { + $id = $jinput->get('id', 0, 'INT'); + } + + $user = JFactory::getUser(); + + // Check for existing item. + // Modify the form based on Edit State access controls. + if ($id != 0 && (!$user->authorise('prompt.edit.state', 'com_getbible.prompt.' . (int) $id)) + || ($id == 0 && !$user->authorise('prompt.edit.state', 'com_getbible'))) + { + // Disable fields for display. + $form->setFieldAttribute('ordering', 'disabled', 'true'); + $form->setFieldAttribute('published', 'disabled', 'true'); + // Disable fields while saving. + $form->setFieldAttribute('ordering', 'filter', 'unset'); + $form->setFieldAttribute('published', 'filter', 'unset'); + } + // If this is a new item insure the greated by is set. + if (0 == $id) + { + // Set the created_by to this user + $form->setValue('created_by', null, $user->id); + } + // Modify the form based on Edit Creaded By access controls. + if ($id != 0 && (!$user->authorise('prompt.edit.created_by', 'com_getbible.prompt.' . (int) $id)) + || ($id == 0 && !$user->authorise('prompt.edit.created_by', 'com_getbible'))) + { + // Disable fields for display. + $form->setFieldAttribute('created_by', 'disabled', 'true'); + // Disable fields for display. + $form->setFieldAttribute('created_by', 'readonly', 'true'); + // Disable fields while saving. + $form->setFieldAttribute('created_by', 'filter', 'unset'); + } + // Modify the form based on Edit Creaded Date access controls. + if ($id != 0 && (!$user->authorise('prompt.edit.created', 'com_getbible.prompt.' . (int) $id)) + || ($id == 0 && !$user->authorise('prompt.edit.created', 'com_getbible'))) + { + // Disable fields for display. + $form->setFieldAttribute('created', 'disabled', 'true'); + // Disable fields while saving. + $form->setFieldAttribute('created', 'filter', 'unset'); + } + // Modify the form based on Edit Name access controls. + if ($id != 0 && (!$user->authorise('prompt.edit.name', 'com_getbible.prompt.' . (int) $id)) + || ($id == 0 && !$user->authorise('prompt.edit.name', 'com_getbible'))) + { + // Disable fields for display. + $form->setFieldAttribute('name', 'disabled', 'true'); + // Disable fields for display. + $form->setFieldAttribute('name', 'readonly', 'true'); + // If there is no value continue. + if (!$form->getValue('name')) + { + // Disable fields while saving. + $form->setFieldAttribute('name', 'filter', 'unset'); + // Disable fields while saving. + $form->setFieldAttribute('name', 'required', 'false'); + } + } + // Modify the form based on Edit Integration access controls. + if ($id != 0 && (!$user->authorise('prompt.edit.integration', 'com_getbible.prompt.' . (int) $id)) + || ($id == 0 && !$user->authorise('prompt.edit.integration', 'com_getbible'))) + { + // Disable fields for display. + $form->setFieldAttribute('integration', 'disabled', 'true'); + // Disable fields for display. + $form->setFieldAttribute('integration', 'readonly', 'true'); + // If there is no value continue. + if (!$form->getValue('integration')) + { + // Disable fields while saving. + $form->setFieldAttribute('integration', 'filter', 'unset'); + // Disable fields while saving. + $form->setFieldAttribute('integration', 'required', 'false'); + } + } + // Modify the form based on Edit Cache Behaviour access controls. + if ($id != 0 && (!$user->authorise('prompt.edit.cache_behaviour', 'com_getbible.prompt.' . (int) $id)) + || ($id == 0 && !$user->authorise('prompt.edit.cache_behaviour', 'com_getbible'))) + { + // Disable fields for display. + $form->setFieldAttribute('cache_behaviour', 'disabled', 'true'); + // Disable fields for display. + $form->setFieldAttribute('cache_behaviour', 'readonly', 'true'); + // If there is no value continue. + if (!$form->getValue('cache_behaviour')) + { + // Disable fields while saving. + $form->setFieldAttribute('cache_behaviour', 'filter', 'unset'); + // Disable fields while saving. + $form->setFieldAttribute('cache_behaviour', 'required', 'false'); + } + } + // Modify the form based on Edit Abbreviation access controls. + if ($id != 0 && (!$user->authorise('prompt.edit.abbreviation', 'com_getbible.prompt.' . (int) $id)) + || ($id == 0 && !$user->authorise('prompt.edit.abbreviation', 'com_getbible'))) + { + // Disable fields for display. + $form->setFieldAttribute('abbreviation', 'disabled', 'true'); + // Disable fields for display. + $form->setFieldAttribute('abbreviation', 'readonly', 'true'); + // If there is no value continue. + if (!$form->getValue('abbreviation')) + { + // Disable fields while saving. + $form->setFieldAttribute('abbreviation', 'filter', 'unset'); + // Disable fields while saving. + $form->setFieldAttribute('abbreviation', 'required', 'false'); + } + } + // Modify the form based on Edit Guid access controls. + if ($id != 0 && (!$user->authorise('prompt.edit.guid', 'com_getbible.prompt.' . (int) $id)) + || ($id == 0 && !$user->authorise('prompt.edit.guid', 'com_getbible'))) + { + // Disable fields for display. + $form->setFieldAttribute('guid', 'disabled', 'true'); + // Disable fields for display. + $form->setFieldAttribute('guid', 'readonly', 'true'); + // If there is no value continue. + if (!$form->getValue('guid')) + { + // Disable fields while saving. + $form->setFieldAttribute('guid', 'filter', 'unset'); + // Disable fields while saving. + $form->setFieldAttribute('guid', 'required', 'false'); + } + } + // Modify the form based on Edit Model access controls. + if ($id != 0 && (!$user->authorise('prompt.edit.model', 'com_getbible.prompt.' . (int) $id)) + || ($id == 0 && !$user->authorise('prompt.edit.model', 'com_getbible'))) + { + // Disable fields for display. + $form->setFieldAttribute('model', 'disabled', 'true'); + // Disable fields for display. + $form->setFieldAttribute('model', 'readonly', 'true'); + // If there is no value continue. + if (!$form->getValue('model')) + { + // Disable fields while saving. + $form->setFieldAttribute('model', 'filter', 'unset'); + // Disable fields while saving. + $form->setFieldAttribute('model', 'required', 'false'); + } + } + // Modify the form based on Edit Presence Penalty access controls. + if ($id != 0 && (!$user->authorise('prompt.edit.presence_penalty', 'com_getbible.prompt.' . (int) $id)) + || ($id == 0 && !$user->authorise('prompt.edit.presence_penalty', 'com_getbible'))) + { + // Disable fields for display. + $form->setFieldAttribute('presence_penalty', 'disabled', 'true'); + // Disable fields for display. + $form->setFieldAttribute('presence_penalty', 'readonly', 'true'); + // If there is no value continue. + if (!$form->getValue('presence_penalty')) + { + // Disable fields while saving. + $form->setFieldAttribute('presence_penalty', 'filter', 'unset'); + // Disable fields while saving. + $form->setFieldAttribute('presence_penalty', 'required', 'false'); + } + } + // Modify the form based on Edit Org Token access controls. + if ($id != 0 && (!$user->authorise('prompt.edit.org_token', 'com_getbible.prompt.' . (int) $id)) + || ($id == 0 && !$user->authorise('prompt.edit.org_token', 'com_getbible'))) + { + // Disable fields for display. + $form->setFieldAttribute('org_token', 'disabled', 'true'); + // Disable fields for display. + $form->setFieldAttribute('org_token', 'readonly', 'true'); + // If there is no value continue. + if (!$form->getValue('org_token')) + { + // Disable fields while saving. + $form->setFieldAttribute('org_token', 'filter', 'unset'); + // Disable fields while saving. + $form->setFieldAttribute('org_token', 'required', 'false'); + } + } + // Modify the form based on Edit Token access controls. + if ($id != 0 && (!$user->authorise('prompt.edit.token', 'com_getbible.prompt.' . (int) $id)) + || ($id == 0 && !$user->authorise('prompt.edit.token', 'com_getbible'))) + { + // Disable fields for display. + $form->setFieldAttribute('token', 'disabled', 'true'); + // Disable fields for display. + $form->setFieldAttribute('token', 'readonly', 'true'); + // If there is no value continue. + if (!$form->getValue('token')) + { + // Disable fields while saving. + $form->setFieldAttribute('token', 'filter', 'unset'); + // Disable fields while saving. + $form->setFieldAttribute('token', 'required', 'false'); + } + } + // Modify the form based on Edit N Override access controls. + if ($id != 0 && (!$user->authorise('prompt.edit.n_override', 'com_getbible.prompt.' . (int) $id)) + || ($id == 0 && !$user->authorise('prompt.edit.n_override', 'com_getbible'))) + { + // Disable fields for display. + $form->setFieldAttribute('n_override', 'disabled', 'true'); + // Disable fields for display. + $form->setFieldAttribute('n_override', 'readonly', 'true'); + // Disable radio button for display. + $class = $form->getFieldAttribute('n_override', 'class', ''); + $form->setFieldAttribute('n_override', 'class', $class.' disabled no-click'); + // If there is no value continue. + if (!$form->getValue('n_override')) + { + // Disable fields while saving. + $form->setFieldAttribute('n_override', 'filter', 'unset'); + // Disable fields while saving. + $form->setFieldAttribute('n_override', 'required', 'false'); + } + } + // Modify the form based on Edit Messages access controls. + if ($id != 0 && (!$user->authorise('prompt.edit.messages', 'com_getbible.prompt.' . (int) $id)) + || ($id == 0 && !$user->authorise('prompt.edit.messages', 'com_getbible'))) + { + // Disable fields for display. + $form->setFieldAttribute('messages', 'disabled', 'true'); + // Disable fields for display. + $form->setFieldAttribute('messages', 'readonly', 'true'); + // If there is no value continue. + if (!$form->getValue('messages')) + { + // Disable fields while saving. + $form->setFieldAttribute('messages', 'filter', 'unset'); + // Disable fields while saving. + $form->setFieldAttribute('messages', 'required', 'false'); + } + } + // Modify the form based on Edit Response Retrieval access controls. + if ($id != 0 && (!$user->authorise('prompt.edit.response_retrieval', 'com_getbible.prompt.' . (int) $id)) + || ($id == 0 && !$user->authorise('prompt.edit.response_retrieval', 'com_getbible'))) + { + // Disable fields for display. + $form->setFieldAttribute('response_retrieval', 'disabled', 'true'); + // Disable fields for display. + $form->setFieldAttribute('response_retrieval', 'readonly', 'true'); + // Disable radio button for display. + $class = $form->getFieldAttribute('response_retrieval', 'class', ''); + $form->setFieldAttribute('response_retrieval', 'class', $class.' disabled no-click'); + // If there is no value continue. + if (!$form->getValue('response_retrieval')) + { + // Disable fields while saving. + $form->setFieldAttribute('response_retrieval', 'filter', 'unset'); + // Disable fields while saving. + $form->setFieldAttribute('response_retrieval', 'required', 'false'); + } + } + // Modify the form based on Edit Frequency Penalty Override access controls. + if ($id != 0 && (!$user->authorise('prompt.edit.frequency_penalty_override', 'com_getbible.prompt.' . (int) $id)) + || ($id == 0 && !$user->authorise('prompt.edit.frequency_penalty_override', 'com_getbible'))) + { + // Disable fields for display. + $form->setFieldAttribute('frequency_penalty_override', 'disabled', 'true'); + // Disable fields for display. + $form->setFieldAttribute('frequency_penalty_override', 'readonly', 'true'); + // Disable radio button for display. + $class = $form->getFieldAttribute('frequency_penalty_override', 'class', ''); + $form->setFieldAttribute('frequency_penalty_override', 'class', $class.' disabled no-click'); + // If there is no value continue. + if (!$form->getValue('frequency_penalty_override')) + { + // Disable fields while saving. + $form->setFieldAttribute('frequency_penalty_override', 'filter', 'unset'); + // Disable fields while saving. + $form->setFieldAttribute('frequency_penalty_override', 'required', 'false'); + } + } + // Modify the form based on Edit N access controls. + if ($id != 0 && (!$user->authorise('prompt.edit.n', 'com_getbible.prompt.' . (int) $id)) + || ($id == 0 && !$user->authorise('prompt.edit.n', 'com_getbible'))) + { + // Disable fields for display. + $form->setFieldAttribute('n', 'disabled', 'true'); + // Disable fields for display. + $form->setFieldAttribute('n', 'readonly', 'true'); + // If there is no value continue. + if (!$form->getValue('n')) + { + // Disable fields while saving. + $form->setFieldAttribute('n', 'filter', 'unset'); + // Disable fields while saving. + $form->setFieldAttribute('n', 'required', 'false'); + } + } + // Modify the form based on Edit Max Tokens Override access controls. + if ($id != 0 && (!$user->authorise('prompt.edit.max_tokens_override', 'com_getbible.prompt.' . (int) $id)) + || ($id == 0 && !$user->authorise('prompt.edit.max_tokens_override', 'com_getbible'))) + { + // Disable fields for display. + $form->setFieldAttribute('max_tokens_override', 'disabled', 'true'); + // Disable fields for display. + $form->setFieldAttribute('max_tokens_override', 'readonly', 'true'); + // Disable radio button for display. + $class = $form->getFieldAttribute('max_tokens_override', 'class', ''); + $form->setFieldAttribute('max_tokens_override', 'class', $class.' disabled no-click'); + // If there is no value continue. + if (!$form->getValue('max_tokens_override')) + { + // Disable fields while saving. + $form->setFieldAttribute('max_tokens_override', 'filter', 'unset'); + // Disable fields while saving. + $form->setFieldAttribute('max_tokens_override', 'required', 'false'); + } + } + // Modify the form based on Edit Token Override access controls. + if ($id != 0 && (!$user->authorise('prompt.edit.token_override', 'com_getbible.prompt.' . (int) $id)) + || ($id == 0 && !$user->authorise('prompt.edit.token_override', 'com_getbible'))) + { + // Disable fields for display. + $form->setFieldAttribute('token_override', 'disabled', 'true'); + // Disable fields for display. + $form->setFieldAttribute('token_override', 'readonly', 'true'); + // Disable radio button for display. + $class = $form->getFieldAttribute('token_override', 'class', ''); + $form->setFieldAttribute('token_override', 'class', $class.' disabled no-click'); + // If there is no value continue. + if (!$form->getValue('token_override')) + { + // Disable fields while saving. + $form->setFieldAttribute('token_override', 'filter', 'unset'); + // Disable fields while saving. + $form->setFieldAttribute('token_override', 'required', 'false'); + } + } + // Modify the form based on Edit Max Tokens access controls. + if ($id != 0 && (!$user->authorise('prompt.edit.max_tokens', 'com_getbible.prompt.' . (int) $id)) + || ($id == 0 && !$user->authorise('prompt.edit.max_tokens', 'com_getbible'))) + { + // Disable fields for display. + $form->setFieldAttribute('max_tokens', 'disabled', 'true'); + // Disable fields for display. + $form->setFieldAttribute('max_tokens', 'readonly', 'true'); + // If there is no value continue. + if (!$form->getValue('max_tokens')) + { + // Disable fields while saving. + $form->setFieldAttribute('max_tokens', 'filter', 'unset'); + // Disable fields while saving. + $form->setFieldAttribute('max_tokens', 'required', 'false'); + } + } + // Modify the form based on Edit Ai Org Token Override access controls. + if ($id != 0 && (!$user->authorise('prompt.edit.ai_org_token_override', 'com_getbible.prompt.' . (int) $id)) + || ($id == 0 && !$user->authorise('prompt.edit.ai_org_token_override', 'com_getbible'))) + { + // Disable fields for display. + $form->setFieldAttribute('ai_org_token_override', 'disabled', 'true'); + // Disable fields for display. + $form->setFieldAttribute('ai_org_token_override', 'readonly', 'true'); + // Disable radio button for display. + $class = $form->getFieldAttribute('ai_org_token_override', 'class', ''); + $form->setFieldAttribute('ai_org_token_override', 'class', $class.' disabled no-click'); + // If there is no value continue. + if (!$form->getValue('ai_org_token_override')) + { + // Disable fields while saving. + $form->setFieldAttribute('ai_org_token_override', 'filter', 'unset'); + // Disable fields while saving. + $form->setFieldAttribute('ai_org_token_override', 'required', 'false'); + } + } + // Modify the from the form based on Temperature Override access controls. + if ($id != 0 && (!$user->authorise('prompt.access.temperature_override', 'com_getbible.prompt.' . (int) $id)) + || ($id == 0 && !$user->authorise('prompt.access.temperature_override', 'com_getbible'))) + { + // Remove the field + $form->removeField('temperature_override'); + } + // Modify the form based on Edit Presence Penalty Override access controls. + if ($id != 0 && (!$user->authorise('prompt.edit.presence_penalty_override', 'com_getbible.prompt.' . (int) $id)) + || ($id == 0 && !$user->authorise('prompt.edit.presence_penalty_override', 'com_getbible'))) + { + // Disable fields for display. + $form->setFieldAttribute('presence_penalty_override', 'disabled', 'true'); + // Disable fields for display. + $form->setFieldAttribute('presence_penalty_override', 'readonly', 'true'); + // Disable radio button for display. + $class = $form->getFieldAttribute('presence_penalty_override', 'class', ''); + $form->setFieldAttribute('presence_penalty_override', 'class', $class.' disabled no-click'); + // If there is no value continue. + if (!$form->getValue('presence_penalty_override')) + { + // Disable fields while saving. + $form->setFieldAttribute('presence_penalty_override', 'filter', 'unset'); + // Disable fields while saving. + $form->setFieldAttribute('presence_penalty_override', 'required', 'false'); + } + } + // Modify the form based on Edit Top P Override access controls. + if ($id != 0 && (!$user->authorise('prompt.edit.top_p_override', 'com_getbible.prompt.' . (int) $id)) + || ($id == 0 && !$user->authorise('prompt.edit.top_p_override', 'com_getbible'))) + { + // Disable fields for display. + $form->setFieldAttribute('top_p_override', 'disabled', 'true'); + // Disable fields for display. + $form->setFieldAttribute('top_p_override', 'readonly', 'true'); + // Disable radio button for display. + $class = $form->getFieldAttribute('top_p_override', 'class', ''); + $form->setFieldAttribute('top_p_override', 'class', $class.' disabled no-click'); + // If there is no value continue. + if (!$form->getValue('top_p_override')) + { + // Disable fields while saving. + $form->setFieldAttribute('top_p_override', 'filter', 'unset'); + // Disable fields while saving. + $form->setFieldAttribute('top_p_override', 'required', 'false'); + } + } + // Modify the form based on Edit Frequency Penalty access controls. + if ($id != 0 && (!$user->authorise('prompt.edit.frequency_penalty', 'com_getbible.prompt.' . (int) $id)) + || ($id == 0 && !$user->authorise('prompt.edit.frequency_penalty', 'com_getbible'))) + { + // Disable fields for display. + $form->setFieldAttribute('frequency_penalty', 'disabled', 'true'); + // Disable fields for display. + $form->setFieldAttribute('frequency_penalty', 'readonly', 'true'); + // If there is no value continue. + if (!$form->getValue('frequency_penalty')) + { + // Disable fields while saving. + $form->setFieldAttribute('frequency_penalty', 'filter', 'unset'); + // Disable fields while saving. + $form->setFieldAttribute('frequency_penalty', 'required', 'false'); + } + } + // Modify the form based on Edit Top P access controls. + if ($id != 0 && (!$user->authorise('prompt.edit.top_p', 'com_getbible.prompt.' . (int) $id)) + || ($id == 0 && !$user->authorise('prompt.edit.top_p', 'com_getbible'))) + { + // Disable fields for display. + $form->setFieldAttribute('top_p', 'disabled', 'true'); + // Disable fields for display. + $form->setFieldAttribute('top_p', 'readonly', 'true'); + // If there is no value continue. + if (!$form->getValue('top_p')) + { + // Disable fields while saving. + $form->setFieldAttribute('top_p', 'filter', 'unset'); + // Disable fields while saving. + $form->setFieldAttribute('top_p', 'required', 'false'); + } + } + // Modify the form based on Edit Temperature access controls. + if ($id != 0 && (!$user->authorise('prompt.edit.temperature', 'com_getbible.prompt.' . (int) $id)) + || ($id == 0 && !$user->authorise('prompt.edit.temperature', 'com_getbible'))) + { + // Disable fields for display. + $form->setFieldAttribute('temperature', 'disabled', 'true'); + // Disable fields for display. + $form->setFieldAttribute('temperature', 'readonly', 'true'); + // If there is no value continue. + if (!$form->getValue('temperature')) + { + // Disable fields while saving. + $form->setFieldAttribute('temperature', 'filter', 'unset'); + // Disable fields while saving. + $form->setFieldAttribute('temperature', 'required', 'false'); + } + } + // Only load these values if no id is found + if (0 == $id) + { + // Set redirected view name + $redirectedView = $jinput->get('ref', null, 'STRING'); + // Set field name (or fall back to view name) + $redirectedField = $jinput->get('field', $redirectedView, 'STRING'); + // Set redirected view id + $redirectedId = $jinput->get('refid', 0, 'INT'); + // Set field id (or fall back to redirected view id) + $redirectedValue = $jinput->get('field_id', $redirectedId, 'INT'); + if (0 != $redirectedValue && $redirectedField) + { + // Now set the local-redirected field default value + $form->setValue($redirectedField, null, $redirectedValue); + } + } + + // Only load the GUID if new item (or empty) + if (0 == $id || !($val = $form->getValue('guid'))) + { + $form->setValue('guid', null, GuidHelper::get()); + } + + return $form; + } + + /** + * Method to get the script that have to be included on the form + * + * @return string script files + */ + public function getScript() + { + return 'media/com_getbible/js/prompt.js'; + } + + /** + * Method to test whether a record can be deleted. + * + * @param object $record A record object. + * + * @return boolean True if allowed to delete the record. Defaults to the permission set in the component. + * + * @since 1.6 + */ + protected function canDelete($record) + { + if (!empty($record->id)) + { + if ($record->published != -2) + { + return; + } + + $user = JFactory::getUser(); + // The record has been set. Check the record permissions. + return $user->authorise('prompt.delete', 'com_getbible.prompt.' . (int) $record->id); + } + return false; + } + + /** + * Method to test whether a record can have its state edited. + * + * @param object $record A record object. + * + * @return boolean True if allowed to change the state of the record. Defaults to the permission set in the component. + * + * @since 1.6 + */ + protected function canEditState($record) + { + $user = JFactory::getUser(); + $recordId = (!empty($record->id)) ? $record->id : 0; + + if ($recordId) + { + // The record has been set. Check the record permissions. + $permission = $user->authorise('prompt.edit.state', 'com_getbible.prompt.' . (int) $recordId); + if (!$permission && !is_null($permission)) + { + return false; + } + } + // In the absense of better information, revert to the component permissions. + return $user->authorise('prompt.edit.state', 'com_getbible'); + } + + /** + * Method override to check if you can edit an existing record. + * + * @param array $data An array of input data. + * @param string $key The name of the key for the primary key. + * + * @return boolean + * @since 2.5 + */ + protected function allowEdit($data = array(), $key = 'id') + { + // Check specific edit permission then general edit permission. + $user = JFactory::getUser(); + + return $user->authorise('prompt.edit', 'com_getbible.prompt.'. ((int) isset($data[$key]) ? $data[$key] : 0)) or $user->authorise('prompt.edit', 'com_getbible'); + } + + /** + * Prepare and sanitise the table data prior to saving. + * + * @param JTable $table A JTable object. + * + * @return void + * + * @since 1.6 + */ + protected function prepareTable($table) + { + $date = JFactory::getDate(); + $user = JFactory::getUser(); + + if (isset($table->name)) + { + $table->name = htmlspecialchars_decode($table->name, ENT_QUOTES); + } + + if (isset($table->alias) && empty($table->alias)) + { + $table->generateAlias(); + } + + if (empty($table->id)) + { + $table->created = $date->toSql(); + // set the user + if ($table->created_by == 0 || empty($table->created_by)) + { + $table->created_by = $user->id; + } + // Set ordering to the last item if not set + if (empty($table->ordering)) + { + $db = JFactory::getDbo(); + $query = $db->getQuery(true) + ->select('MAX(ordering)') + ->from($db->quoteName('#__getbible_prompt')); + $db->setQuery($query); + $max = $db->loadResult(); + + $table->ordering = $max + 1; + } + } + else + { + $table->modified = $date->toSql(); + $table->modified_by = $user->id; + } + + if (!empty($table->id)) + { + // Increment the items version number. + $table->version++; + } + } + + /** + * Method to get the data that should be injected in the form. + * + * @return mixed The data for the form. + * + * @since 1.6 + */ + protected function loadFormData() + { + // Check the session for previously entered form data. + $data = JFactory::getApplication()->getUserState('com_getbible.edit.prompt.data', array()); + + if (empty($data)) + { + $data = $this->getItem(); + // run the perprocess of the data + $this->preprocessData('com_getbible.prompt', $data); + } + + return $data; + } + + /** + * Method to get the unique fields of this table. + * + * @return mixed An array of field names, boolean false if none is set. + * + * @since 3.0 + */ + protected function getUniqueFields() + { + return array('guid'); + } + + /** + * Method to delete one or more records. + * + * @param array &$pks An array of record primary keys. + * + * @return boolean True if successful, false if an error occurs. + * + * @since 12.2 + */ + public function delete(&$pks) + { + if (!parent::delete($pks)) + { + return false; + } + + return true; + } + + /** + * Method to change the published state of one or more records. + * + * @param array &$pks A list of the primary keys to change. + * @param integer $value The value of the published state. + * + * @return boolean True on success. + * + * @since 12.2 + */ + public function publish(&$pks, $value = 1) + { + if (!parent::publish($pks, $value)) + { + return false; + } + + return true; + } + + /** + * Method to perform batch operations on an item or a set of items. + * + * @param array $commands An array of commands to perform. + * @param array $pks An array of item ids. + * @param array $contexts An array of item contexts. + * + * @return boolean Returns true on success, false on failure. + * + * @since 12.2 + */ + public function batch($commands, $pks, $contexts) + { + // Sanitize ids. + $pks = array_unique($pks); + ArrayHelper::toInteger($pks); + + // Remove any values of zero. + if (array_search(0, $pks, true)) + { + unset($pks[array_search(0, $pks, true)]); + } + + if (empty($pks)) + { + $this->setError(JText::_('JGLOBAL_NO_ITEM_SELECTED')); + return false; + } + + $done = false; + + // Set some needed variables. + $this->user = JFactory::getUser(); + $this->table = $this->getTable(); + $this->tableClassName = get_class($this->table); + $this->contentType = new JUcmType; + $this->type = $this->contentType->getTypeByTable($this->tableClassName); + $this->canDo = GetbibleHelper::getActions('prompt'); + $this->batchSet = true; + + if (!$this->canDo->get('core.batch')) + { + $this->setError(JText::_('JLIB_APPLICATION_ERROR_INSUFFICIENT_BATCH_INFORMATION')); + return false; + } + + if ($this->type == false) + { + $type = new JUcmType; + $this->type = $type->getTypeByAlias($this->typeAlias); + } + + $this->tagsObserver = $this->table->getObserverOfClass('JTableObserverTags'); + + if (!empty($commands['move_copy'])) + { + $cmd = ArrayHelper::getValue($commands, 'move_copy', 'c'); + + if ($cmd == 'c') + { + $result = $this->batchCopy($commands, $pks, $contexts); + + if (is_array($result)) + { + foreach ($result as $old => $new) + { + $contexts[$new] = $contexts[$old]; + } + $pks = array_values($result); + } + else + { + return false; + } + } + elseif ($cmd == 'm' && !$this->batchMove($commands, $pks, $contexts)) + { + return false; + } + + $done = true; + } + + if (!$done) + { + $this->setError(JText::_('JLIB_APPLICATION_ERROR_INSUFFICIENT_BATCH_INFORMATION')); + + return false; + } + + // Clear the cache + $this->cleanCache(); + + return true; + } + + /** + * Batch copy items to a new category or current. + * + * @param integer $values The new values. + * @param array $pks An array of row IDs. + * @param array $contexts An array of item contexts. + * + * @return mixed An array of new IDs on success, boolean false on failure. + * + * @since 12.2 + */ + protected function batchCopy($values, $pks, $contexts) + { + if (empty($this->batchSet)) + { + // Set some needed variables. + $this->user = JFactory::getUser(); + $this->table = $this->getTable(); + $this->tableClassName = get_class($this->table); + $this->canDo = GetbibleHelper::getActions('prompt'); + } + + if (!$this->canDo->get('prompt.create') && !$this->canDo->get('prompt.batch')) + { + return false; + } + + // get list of unique fields + $uniqueFields = $this->getUniqueFields(); + // remove move_copy from array + unset($values['move_copy']); + + // make sure published is set + if (!isset($values['published'])) + { + $values['published'] = 0; + } + elseif (isset($values['published']) && !$this->canDo->get('prompt.edit.state')) + { + $values['published'] = 0; + } + + $newIds = array(); + // Parent exists so let's proceed + while (!empty($pks)) + { + // Pop the first ID off the stack + $pk = array_shift($pks); + + $this->table->reset(); + + // only allow copy if user may edit this item. + if (!$this->user->authorise('prompt.edit', $contexts[$pk])) + { + // Not fatal error + $this->setError(JText::sprintf('JLIB_APPLICATION_ERROR_BATCH_MOVE_ROW_NOT_FOUND', $pk)); + continue; + } + + // Check that the row actually exists + if (!$this->table->load($pk)) + { + if ($error = $this->table->getError()) + { + // Fatal error + $this->setError($error); + return false; + } + else + { + // Not fatal error + $this->setError(JText::sprintf('JLIB_APPLICATION_ERROR_BATCH_MOVE_ROW_NOT_FOUND', $pk)); + continue; + } + } + + // Only for strings + if (GetbibleHelper::checkString($this->table->name) && !is_numeric($this->table->name)) + { + $this->table->name = $this->generateUnique('name',$this->table->name); + } + + // insert all set values + if (GetbibleHelper::checkArray($values)) + { + foreach ($values as $key => $value) + { + if (strlen($value) > 0 && isset($this->table->$key)) + { + $this->table->$key = $value; + } + } + } + + // update all unique fields + if (GetbibleHelper::checkArray($uniqueFields)) + { + foreach ($uniqueFields as $uniqueField) + { + $this->table->$uniqueField = $this->generateUnique($uniqueField,$this->table->$uniqueField); + } + } + + // Reset the ID because we are making a copy + $this->table->id = 0; + + // TODO: Deal with ordering? + // $this->table->ordering = 1; + + // Check the row. + if (!$this->table->check()) + { + $this->setError($this->table->getError()); + + return false; + } + + if (!empty($this->type)) + { + $this->createTagsHelper($this->tagsObserver, $this->type, $pk, $this->typeAlias, $this->table); + } + + // Store the row. + if (!$this->table->store()) + { + $this->setError($this->table->getError()); + + return false; + } + + // Get the new item ID + $newId = $this->table->get('id'); + + // Add the new ID to the array + $newIds[$pk] = $newId; + } + + // Clean the cache + $this->cleanCache(); + + return $newIds; + } + + /** + * Batch move items to a new category + * + * @param integer $value The new category ID. + * @param array $pks An array of row IDs. + * @param array $contexts An array of item contexts. + * + * @return boolean True if successful, false otherwise and internal error is set. + * + * @since 12.2 + */ + protected function batchMove($values, $pks, $contexts) + { + if (empty($this->batchSet)) + { + // Set some needed variables. + $this->user = JFactory::getUser(); + $this->table = $this->getTable(); + $this->tableClassName = get_class($this->table); + $this->canDo = GetbibleHelper::getActions('prompt'); + } + + if (!$this->canDo->get('prompt.edit') && !$this->canDo->get('prompt.batch')) + { + $this->setError(JText::_('JLIB_APPLICATION_ERROR_BATCH_CANNOT_EDIT')); + return false; + } + + // make sure published only updates if user has the permission. + if (isset($values['published']) && !$this->canDo->get('prompt.edit.state')) + { + unset($values['published']); + } + // remove move_copy from array + unset($values['move_copy']); + + // Parent exists so we proceed + foreach ($pks as $pk) + { + if (!$this->user->authorise('prompt.edit', $contexts[$pk])) + { + $this->setError(JText::_('JLIB_APPLICATION_ERROR_BATCH_CANNOT_EDIT')); + return false; + } + + // Check that the row actually exists + if (!$this->table->load($pk)) + { + if ($error = $this->table->getError()) + { + // Fatal error + $this->setError($error); + return false; + } + else + { + // Not fatal error + $this->setError(JText::sprintf('JLIB_APPLICATION_ERROR_BATCH_MOVE_ROW_NOT_FOUND', $pk)); + continue; + } + } + + // insert all set values. + if (GetbibleHelper::checkArray($values)) + { + foreach ($values as $key => $value) + { + // Do special action for access. + if ('access' === $key && strlen($value) > 0) + { + $this->table->$key = $value; + } + elseif (strlen($value) > 0 && isset($this->table->$key)) + { + $this->table->$key = $value; + } + } + } + + + // Check the row. + if (!$this->table->check()) + { + $this->setError($this->table->getError()); + + return false; + } + + if (!empty($this->type)) + { + $this->createTagsHelper($this->tagsObserver, $this->type, $pk, $this->typeAlias, $this->table); + } + + // Store the row. + if (!$this->table->store()) + { + $this->setError($this->table->getError()); + + return false; + } + } + + // Clean the cache + $this->cleanCache(); + + return true; + } + + /** + * Method to save the form data. + * + * @param array $data The form data. + * + * @return boolean True on success. + * + * @since 1.6 + */ + public function save($data) + { + $input = JFactory::getApplication()->input; + $filter = JFilterInput::getInstance(); + + // set the metadata to the Item Data + if (isset($data['metadata']) && isset($data['metadata']['author'])) + { + $data['metadata']['author'] = $filter->clean($data['metadata']['author'], 'TRIM'); + + $metadata = new JRegistry; + $metadata->loadArray($data['metadata']); + $data['metadata'] = (string) $metadata; + } + + + // Set the GUID if empty or not valid + if (empty($data['guid']) && $data['id'] > 0) + { + // get the existing one + $data['guid'] = (string) GetHelper::var('prompt', $data['id'], 'id', 'guid'); + } + + // Set the GUID if empty or not valid + while (!GuidHelper::valid($data['guid'], "prompt", $data['id'])) + { + // must always be set + $data['guid'] = (string) GuidHelper::get(); + } + + // Set the messages items to data. + if (isset($data['messages']) && is_array($data['messages'])) + { + $messages = new JRegistry; + $messages->loadArray($data['messages']); + $data['messages'] = (string) $messages; + } + // Also check permission since the value may be removed due to permissions + // Then we do not want to clear it out, but simple ignore the empty messages + elseif (!isset($data['messages']) + && JFactory::getUser()->authorise('prompt.edit.messages', 'com_getbible')) + { + // Set the empty messages to data + $data['messages'] = ''; + } + + // Set the Params Items to data + if (isset($data['params']) && is_array($data['params'])) + { + $params = new JRegistry; + $params->loadArray($data['params']); + $data['params'] = (string) $params; + } + + // Alter the unique field for save as copy + if ($input->get('task') === 'save2copy') + { + // Automatic handling of other unique fields + $uniqueFields = $this->getUniqueFields(); + if (GetbibleHelper::checkArray($uniqueFields)) + { + foreach ($uniqueFields as $uniqueField) + { + $data[$uniqueField] = $this->generateUnique($uniqueField,$data[$uniqueField]); + } + } + } + + if (parent::save($data)) + { + return true; + } + return false; + } + + /** + * Method to generate a unique value. + * + * @param string $field name. + * @param string $value data. + * + * @return string New value. + * + * @since 3.0 + */ + protected function generateUnique($field,$value) + { + + // set field value unique + $table = $this->getTable(); + + while ($table->load(array($field => $value))) + { + $value = StringHelper::increment($value); + } + + return $value; + } + + /** + * Method to change the title + * + * @param string $title The title. + * + * @return array Contains the modified title and alias. + * + */ + protected function _generateNewTitle($title) + { + + // Alter the title + $table = $this->getTable(); + + while ($table->load(array('title' => $title))) + { + $title = StringHelper::increment($title); + } + + return $title; + } +} diff --git a/admin/models/prompts.php b/admin/models/prompts.php new file mode 100644 index 0000000..84776e3 --- /dev/null +++ b/admin/models/prompts.php @@ -0,0 +1,488 @@ + + @git Get Bible + @github Get Bible + @support Get Bible + @copyright Copyright (C) 2015. All Rights Reserved + @license GNU/GPL Version 2 or later - http://www.gnu.org/licenses/gpl-2.0.html + +/------------------------------------------------------------------------------------------------------*/ + +// No direct access to this file +defined('_JEXEC') or die('Restricted access'); + +use Joomla\CMS\MVC\Model\ListModel; +use Joomla\Utilities\ArrayHelper; + +/** + * Prompts List Model + */ +class GetbibleModelPrompts extends ListModel +{ + public function __construct($config = array()) + { + if (empty($config['filter_fields'])) + { + $config['filter_fields'] = array( + 'a.id','id', + 'a.published','published', + 'a.access','access', + 'a.ordering','ordering', + 'a.created_by','created_by', + 'a.modified_by','modified_by', + 'a.name','name', + 'a.cache_behaviour','cache_behaviour', + 'g.translation','abbreviation', + 'a.model','model', + 'a.integration','integration' + ); + } + + parent::__construct($config); + } + + /** + * Method to auto-populate the model state. + * + * Note. Calling getState in this method will result in recursion. + * + * @param string $ordering An optional ordering field. + * @param string $direction An optional direction (asc|desc). + * + * @return void + * + */ + protected function populateState($ordering = null, $direction = null) + { + $app = JFactory::getApplication(); + + // Adjust the context to support modal layouts. + if ($layout = $app->input->get('layout')) + { + $this->context .= '.' . $layout; + } + + // Check if the form was submitted + $formSubmited = $app->input->post->get('form_submited'); + + $access = $this->getUserStateFromRequest($this->context . '.filter.access', 'filter_access', 0, 'int'); + if ($formSubmited) + { + $access = $app->input->post->get('access'); + $this->setState('filter.access', $access); + } + + $published = $this->getUserStateFromRequest($this->context . '.filter.published', 'filter_published', ''); + $this->setState('filter.published', $published); + + $created_by = $this->getUserStateFromRequest($this->context . '.filter.created_by', 'filter_created_by', ''); + $this->setState('filter.created_by', $created_by); + + $created = $this->getUserStateFromRequest($this->context . '.filter.created', 'filter_created'); + $this->setState('filter.created', $created); + + $sorting = $this->getUserStateFromRequest($this->context . '.filter.sorting', 'filter_sorting', 0, 'int'); + $this->setState('filter.sorting', $sorting); + + $search = $this->getUserStateFromRequest($this->context . '.filter.search', 'filter_search'); + $this->setState('filter.search', $search); + + $name = $this->getUserStateFromRequest($this->context . '.filter.name', 'filter_name'); + if ($formSubmited) + { + $name = $app->input->post->get('name'); + $this->setState('filter.name', $name); + } + + $cache_behaviour = $this->getUserStateFromRequest($this->context . '.filter.cache_behaviour', 'filter_cache_behaviour'); + if ($formSubmited) + { + $cache_behaviour = $app->input->post->get('cache_behaviour'); + $this->setState('filter.cache_behaviour', $cache_behaviour); + } + + $abbreviation = $this->getUserStateFromRequest($this->context . '.filter.abbreviation', 'filter_abbreviation'); + if ($formSubmited) + { + $abbreviation = $app->input->post->get('abbreviation'); + $this->setState('filter.abbreviation', $abbreviation); + } + + $model = $this->getUserStateFromRequest($this->context . '.filter.model', 'filter_model'); + if ($formSubmited) + { + $model = $app->input->post->get('model'); + $this->setState('filter.model', $model); + } + + $integration = $this->getUserStateFromRequest($this->context . '.filter.integration', 'filter_integration'); + if ($formSubmited) + { + $integration = $app->input->post->get('integration'); + $this->setState('filter.integration', $integration); + } + + // List state information. + parent::populateState($ordering, $direction); + } + + /** + * Method to get an array of data items. + * + * @return mixed An array of data items on success, false on failure. + */ + public function getItems() + { + // Check in items + $this->checkInNow(); + + // load parent items + $items = parent::getItems(); + + // Set values to display correctly. + if (GetbibleHelper::checkArray($items)) + { + // Get the user object if not set. + if (!isset($user) || !GetbibleHelper::checkObject($user)) + { + $user = JFactory::getUser(); + } + foreach ($items as $nr => &$item) + { + // Remove items the user can't access. + $access = ($user->authorise('prompt.access', 'com_getbible.prompt.' . (int) $item->id) && $user->authorise('prompt.access', 'com_getbible')); + if (!$access) + { + unset($items[$nr]); + continue; + } + + } + } + + // set selection value to a translatable value + if (GetbibleHelper::checkArray($items)) + { + foreach ($items as $nr => &$item) + { + // convert integration + $item->integration = $this->selectionTranslation($item->integration, 'integration'); + // convert cache_behaviour + $item->cache_behaviour = $this->selectionTranslation($item->cache_behaviour, 'cache_behaviour'); + // convert model + $item->model = $this->selectionTranslation($item->model, 'model'); + } + } + + + // return items + return $items; + } + + /** + * Method to convert selection values to translatable string. + * + * @return translatable string + */ + public function selectionTranslation($value,$name) + { + // Array of integration language strings + if ($name === 'integration') + { + $integrationArray = array( + 1 => 'COM_GETBIBLE_PROMPT_WORDBASED', + 2 => 'COM_GETBIBLE_PROMPT_VERSEBASED', + 3 => 'COM_GETBIBLE_PROMPT_SELECTIONBASED' + ); + // Now check if value is found in this array + if (isset($integrationArray[$value]) && GetbibleHelper::checkString($integrationArray[$value])) + { + return $integrationArray[$value]; + } + } + // Array of cache_behaviour language strings + if ($name === 'cache_behaviour') + { + $cache_behaviourArray = array( + 0 => 'COM_GETBIBLE_PROMPT_PERSISTENTLY_EXPANSIVE_CACHING', + 1 => 'COM_GETBIBLE_PROMPT_BASIC_CACHING_WORDSLANGUAGE', + 2 => 'COM_GETBIBLE_PROMPT_ADVANCED_CACHING_VERSECONTEX' + ); + // Now check if value is found in this array + if (isset($cache_behaviourArray[$value]) && GetbibleHelper::checkString($cache_behaviourArray[$value])) + { + return $cache_behaviourArray[$value]; + } + } + // Array of model language strings + if ($name === 'model') + { + $modelArray = array( + 0 => 'COM_GETBIBLE_PROMPT_USE_GLOBAL', + 'gpt-4' => 'COM_GETBIBLE_PROMPT_GPT4', + 'gpt-4-0613' => 'COM_GETBIBLE_PROMPT_GPT40613', + 'gpt-4-32k' => 'COM_GETBIBLE_PROMPT_GPT432K', + 'gpt-4-32k-0613' => 'COM_GETBIBLE_PROMPT_GPT432K0613', + 'gpt-3.5-turbo' => 'COM_GETBIBLE_PROMPT_GPT35TURBO', + 'gpt-3.5-turbo-0613' => 'COM_GETBIBLE_PROMPT_GPT35TURBO0613', + 'gpt-3.5-turbo-16k' => 'COM_GETBIBLE_PROMPT_GPT35TURBO16K', + 'gpt-3.5-turbo-16k-0613' => 'COM_GETBIBLE_PROMPT_GPT35TURBO16K0613' + ); + // Now check if value is found in this array + if (isset($modelArray[$value]) && GetbibleHelper::checkString($modelArray[$value])) + { + return $modelArray[$value]; + } + } + return $value; + } + + /** + * Method to build an SQL query to load the list data. + * + * @return string An SQL query + */ + protected function getListQuery() + { + // Get the user object. + $user = JFactory::getUser(); + // Create a new query object. + $db = JFactory::getDBO(); + $query = $db->getQuery(true); + + // Select some fields + $query->select('a.*'); + + // From the getbible_item table + $query->from($db->quoteName('#__getbible_prompt', 'a')); + + // From the getbible_translation table. + $query->select($db->quoteName(['g.translation','g.id'],['abbreviation_translation','abbreviation_id'])); + $query->join('LEFT', $db->quoteName('#__getbible_translation', 'g') . ' ON (' . $db->quoteName('a.abbreviation') . ' = ' . $db->quoteName('g.abbreviation') . ')'); + + // Filter by published state + $published = $this->getState('filter.published'); + if (is_numeric($published)) + { + $query->where('a.published = ' . (int) $published); + } + elseif ($published === '') + { + $query->where('(a.published = 0 OR a.published = 1)'); + } + + // Join over the asset groups. + $query->select('ag.title AS access_level'); + $query->join('LEFT', '#__viewlevels AS ag ON ag.id = a.access'); + // Filter by access level. + $_access = $this->getState('filter.access'); + if ($_access && is_numeric($_access)) + { + $query->where('a.access = ' . (int) $_access); + } + elseif (GetbibleHelper::checkArray($_access)) + { + // Secure the array for the query + $_access = ArrayHelper::toInteger($_access); + // Filter by the Access Array. + $query->where('a.access IN (' . implode(',', $_access) . ')'); + } + // Implement View Level Access + if (!$user->authorise('core.options', 'com_getbible')) + { + $groups = implode(',', $user->getAuthorisedViewLevels()); + $query->where('a.access IN (' . $groups . ')'); + } + // Filter by search. + $search = $this->getState('filter.search'); + if (!empty($search)) + { + if (stripos($search, 'id:') === 0) + { + $query->where('a.id = ' . (int) substr($search, 3)); + } + else + { + $search = $db->quote('%' . $db->escape($search) . '%'); + $query->where('(a.name LIKE '.$search.' OR a.model LIKE '.$search.')'); + } + } + + // Filter by Name. + $_name = $this->getState('filter.name'); + if (is_numeric($_name)) + { + if (is_float($_name)) + { + $query->where('a.name = ' . (float) $_name); + } + else + { + $query->where('a.name = ' . (int) $_name); + } + } + elseif (GetbibleHelper::checkString($_name)) + { + $query->where('a.name = ' . $db->quote($db->escape($_name))); + } + // Filter by Cache_behaviour. + $_cache_behaviour = $this->getState('filter.cache_behaviour'); + if (is_numeric($_cache_behaviour)) + { + if (is_float($_cache_behaviour)) + { + $query->where('a.cache_behaviour = ' . (float) $_cache_behaviour); + } + else + { + $query->where('a.cache_behaviour = ' . (int) $_cache_behaviour); + } + } + elseif (GetbibleHelper::checkString($_cache_behaviour)) + { + $query->where('a.cache_behaviour = ' . $db->quote($db->escape($_cache_behaviour))); + } + // Filter by Abbreviation. + $_abbreviation = $this->getState('filter.abbreviation'); + if (is_numeric($_abbreviation)) + { + if (is_float($_abbreviation)) + { + $query->where('a.abbreviation = ' . (float) $_abbreviation); + } + else + { + $query->where('a.abbreviation = ' . (int) $_abbreviation); + } + } + elseif (GetbibleHelper::checkString($_abbreviation)) + { + $query->where('a.abbreviation = ' . $db->quote($db->escape($_abbreviation))); + } + // Filter by Model. + $_model = $this->getState('filter.model'); + if (is_numeric($_model)) + { + if (is_float($_model)) + { + $query->where('a.model = ' . (float) $_model); + } + else + { + $query->where('a.model = ' . (int) $_model); + } + } + elseif (GetbibleHelper::checkString($_model)) + { + $query->where('a.model = ' . $db->quote($db->escape($_model))); + } + + // Add the list ordering clause. + $orderCol = $this->state->get('list.ordering', 'a.id'); + $orderDirn = $this->state->get('list.direction', 'desc'); + if ($orderCol != '') + { + $query->order($db->escape($orderCol . ' ' . $orderDirn)); + } + + return $query; + } + + /** + * Method to get a store id based on model configuration state. + * + * @return string A store id. + * + */ + protected function getStoreId($id = '') + { + // Compile the store id. + $id .= ':' . $this->getState('filter.id'); + $id .= ':' . $this->getState('filter.search'); + $id .= ':' . $this->getState('filter.published'); + // Check if the value is an array + $_access = $this->getState('filter.access'); + if (GetbibleHelper::checkArray($_access)) + { + $id .= ':' . implode(':', $_access); + } + // Check if this is only an number or string + elseif (is_numeric($_access) + || GetbibleHelper::checkString($_access)) + { + $id .= ':' . $_access; + } + $id .= ':' . $this->getState('filter.ordering'); + $id .= ':' . $this->getState('filter.created_by'); + $id .= ':' . $this->getState('filter.modified_by'); + $id .= ':' . $this->getState('filter.name'); + $id .= ':' . $this->getState('filter.cache_behaviour'); + $id .= ':' . $this->getState('filter.abbreviation'); + $id .= ':' . $this->getState('filter.model'); + $id .= ':' . $this->getState('filter.integration'); + + return parent::getStoreId($id); + } + + /** + * Build an SQL query to checkin all items left checked out longer then a set time. + * + * @return a bool + * + */ + protected function checkInNow() + { + // Get set check in time + $time = JComponentHelper::getParams('com_getbible')->get('check_in'); + + if ($time) + { + + // Get a db connection. + $db = JFactory::getDbo(); + // Reset query. + $query = $db->getQuery(true); + $query->select('*'); + $query->from($db->quoteName('#__getbible_prompt')); + // Only select items that are checked out. + $query->where($db->quoteName('checked_out') . '!=0'); + $db->setQuery($query, 0, 1); + $db->execute(); + if ($db->getNumRows()) + { + // Get Yesterdays date. + $date = JFactory::getDate()->modify($time)->toSql(); + // Reset query. + $query = $db->getQuery(true); + + // Fields to update. + $fields = array( + $db->quoteName('checked_out_time') . '=\'0000-00-00 00:00:00\'', + $db->quoteName('checked_out') . '=0' + ); + + // Conditions for which records should be updated. + $conditions = array( + $db->quoteName('checked_out') . '!=0', + $db->quoteName('checked_out_time') . '<\''.$date.'\'' + ); + + // Check table. + $query->update($db->quoteName('#__getbible_prompt'))->set($fields)->where($conditions); + + $db->setQuery($query); + + $db->execute(); + } + } + + return false; + } +} diff --git a/admin/models/rules/guid.php b/admin/models/rules/guid.php new file mode 100644 index 0000000..41b1d73 --- /dev/null +++ b/admin/models/rules/guid.php @@ -0,0 +1,60 @@ + + @git Get Bible + @github Get Bible + @support Get Bible + @copyright Copyright (C) 2015. All Rights Reserved + @license GNU/GPL Version 2 or later - http://www.gnu.org/licenses/gpl-2.0.html + +/------------------------------------------------------------------------------------------------------*/ + +// No direct access to this file +defined('JPATH_PLATFORM') or die; + +use Joomla\CMS\Form\Form; +use Joomla\CMS\Form\FormRule; +use Joomla\Registry\Registry; + +/** + * Form Rule (Guid) class for the Joomla Platform. + */ +class JFormRuleGuid extends FormRule +{ + /** + * Method to test for a Globally Unique Identifier. + * + * @param \SimpleXMLElement $element The SimpleXMLElement object representing the `` tag for the form field object. + * @param mixed $value The form field value to validate. + * @param string $group The field name group control value. This acts as an array container for the field. + * For example if the field has name="foo" and the group value is set to "bar" then the + * full field name would end up being "bar[foo]". + * @param Registry $input An optional Registry object with the entire data set to validate against the entire form. + * @param Form $form The form object for which the field is being tested. + * + * @return boolean True if the value is valid, false otherwise. + * + */ + public function test(\SimpleXMLElement $element, $value, $group = null, Registry $input = null, Form $form = null) + { + $value = trim($value); + + // If the field is empty and not required, the field is valid. + $required = ((string) $element['required'] == 'true' || (string) $element['required'] == 'required'); + + if (!$required && empty($value)) + { + return true; + } + + // thanks to Lewie https://stackoverflow.com/a/1515456/1429677 + return preg_match("/^(\{)?[a-f\d]{8}(-[a-f\d]{4}){4}[a-f\d]{8}(?(1)\})$/i", $value); + } + +} diff --git a/admin/models/rules/index.html b/admin/models/rules/index.html new file mode 100644 index 0000000..fa6d84e --- /dev/null +++ b/admin/models/rules/index.html @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/admin/models/rules/int.php b/admin/models/rules/int.php new file mode 100644 index 0000000..daac7f5 --- /dev/null +++ b/admin/models/rules/int.php @@ -0,0 +1,62 @@ + + @git Get Bible + @github Get Bible + @support Get Bible + @copyright Copyright (C) 2015. All Rights Reserved + @license GNU/GPL Version 2 or later - http://www.gnu.org/licenses/gpl-2.0.html + +/------------------------------------------------------------------------------------------------------*/ + +// No direct access to this file +defined('JPATH_PLATFORM') or die; + +use Joomla\CMS\Form\Form; +use Joomla\CMS\Form\FormRule; +use Joomla\Registry\Registry; + +/** + * Form Rule (Int) class for the Joomla Platform. + */ +class JFormRuleInt extends FormRule +{ + /** + * Method to test that an integer value was added. + * + * @param \SimpleXMLElement $element The SimpleXMLElement object representing the `` tag for the form field object. + * @param mixed $value The form field value to validate. + * @param string $group The field name group control value. This acts as an array container for the field. + * For example if the field has name="foo" and the group value is set to "bar" then the + * full field name would end up being "bar[foo]". + * @param Registry $input An optional Registry object with the entire data set to validate against the entire form. + * @param Form $form The form object for which the field is being tested. + * + * @return boolean True if the value is valid integer, false otherwise. + * + */ + public function test(\SimpleXMLElement $element, $value, $group = null, Registry $input = null, Form $form = null) + { + // Check if the field is required. + $required = ((string) $element['required'] == 'true' || (string) $element['required'] == 'required'); + + // If the value is empty and the field is not required return True. + if (($value === '' || $value === null) && ! $required) + { + return true; + } + + // now validate the value to be an integer + // we need to validate a string with the integer in it + // since this is how Joomla passes the value to the test method + // so we use type coercion along with is_numeric + return is_numeric($value) && is_int(+$value); + // if you have a better idea... lets hear it. + } +} diff --git a/admin/models/rules/numbershyphens.php b/admin/models/rules/numbershyphens.php new file mode 100644 index 0000000..fd20cce --- /dev/null +++ b/admin/models/rules/numbershyphens.php @@ -0,0 +1,60 @@ + + @git Get Bible + @github Get Bible + @support Get Bible + @copyright Copyright (C) 2015. All Rights Reserved + @license GNU/GPL Version 2 or later - http://www.gnu.org/licenses/gpl-2.0.html + +/------------------------------------------------------------------------------------------------------*/ + +// No direct access to this file +defined('JPATH_PLATFORM') or die; + +use Joomla\CMS\Form\Form; +use Joomla\CMS\Form\FormRule; +use Joomla\Registry\Registry; + +/** + * Form Rule (Numbershyphens) class for the Joomla Platform. + */ +class JFormRuleNumbershyphens extends FormRule +{ + /** + * Method to test if the input is a number or a sequence of numbers separated by hyphens. + * + * @param \SimpleXMLElement $element The SimpleXMLElement object representing the `` tag for the form field object. + * @param mixed $value The form field value to validate. + * @param string $group The field name group control value. This acts as an array container for the field. + * For example if the field has name="foo" and the group value is set to "bar" then the + * full field name would end up being "bar[foo]". + * @param Registry $input An optional Registry object with the entire data set to validate against the entire form. + * @param Form $form The form object for which the field is being tested. + * + * @return boolean True if the value is valid, false otherwise. + * + * @since 1.7.0 + */ + public function test(\SimpleXMLElement $element, $value, $group = null, Registry $input = null, Form $form = null) + { + $value = trim($value); + + // If the field is empty and not required, the field is valid. + $required = ((string) $element['required'] == 'true' || (string) $element['required'] == 'required'); + + if (!$required && empty($value)) + { + return true; // we allow empty values if not required + } + + // Check if the value is a number or a sequence of numbers separated by hyphens. + return preg_match('/^(\d+-)*\d+$/', $value) === 1; + } +} diff --git a/admin/models/tag.php b/admin/models/tag.php new file mode 100644 index 0000000..d9fd24d --- /dev/null +++ b/admin/models/tag.php @@ -0,0 +1,984 @@ + + @git Get Bible + @github Get Bible + @support Get Bible + @copyright Copyright (C) 2015. All Rights Reserved + @license GNU/GPL Version 2 or later - http://www.gnu.org/licenses/gpl-2.0.html + +/------------------------------------------------------------------------------------------------------*/ + +// No direct access to this file +defined('_JEXEC') or die('Restricted access'); + +use Joomla\CMS\MVC\Model\AdminModel; +use Joomla\Registry\Registry; +use Joomla\String\StringHelper; +use Joomla\Utilities\ArrayHelper; +use VDM\Joomla\Utilities\GuidHelper; +use VDM\Joomla\Utilities\GetHelper; + +/** + * Getbible Tag Admin Model + */ +class GetbibleModelTag extends AdminModel +{ + /** + * The tab layout fields array. + * + * @var array + */ + protected $tabLayoutFields = array( + 'details' => array( + 'left' => array( + 'name' + ), + 'fullwidth' => array( + 'description' + ), + 'above' => array( + 'access', + 'linker' + ) + ) + ); + + /** + * @var string The prefix to use with controller messages. + * @since 1.6 + */ + protected $text_prefix = 'COM_GETBIBLE'; + + /** + * The type alias for this content type. + * + * @var string + * @since 3.2 + */ + public $typeAlias = 'com_getbible.tag'; + + /** + * Returns a Table object, always creating it + * + * @param type $type The table type to instantiate + * @param string $prefix A prefix for the table class name. Optional. + * @param array $config Configuration array for model. Optional. + * + * @return JTable A database object + * + * @since 1.6 + */ + public function getTable($type = 'tag', $prefix = 'GetbibleTable', $config = array()) + { + // add table path for when model gets used from other component + $this->addTablePath(JPATH_ADMINISTRATOR . '/components/com_getbible/tables'); + // get instance of the table + return JTable::getInstance($type, $prefix, $config); + } + + /** + * Method to get a single record. + * + * @param integer $pk The id of the primary key. + * + * @return mixed Object on success, false on failure. + * + * @since 1.6 + */ + public function getItem($pk = null) + { + if ($item = parent::getItem($pk)) + { + if (!empty($item->params) && !is_array($item->params)) + { + // Convert the params field to an array. + $registry = new Registry; + $registry->loadString($item->params); + $item->params = $registry->toArray(); + } + + if (!empty($item->metadata)) + { + // Convert the metadata field to an array. + $registry = new Registry; + $registry->loadString($item->metadata); + $item->metadata = $registry->toArray(); + } + } + + return $item; + } + + /** + * Method to get the record form. + * + * @param array $data Data for the form. + * @param boolean $loadData True if the form is to load its own data (default case), false if not. + * @param array $options Optional array of options for the form creation. + * + * @return mixed A JForm object on success, false on failure + * + * @since 1.6 + */ + public function getForm($data = array(), $loadData = true, $options = array('control' => 'jform')) + { + // set load data option + $options['load_data'] = $loadData; + // check if xpath was set in options + $xpath = false; + if (isset($options['xpath'])) + { + $xpath = $options['xpath']; + unset($options['xpath']); + } + // check if clear form was set in options + $clear = false; + if (isset($options['clear'])) + { + $clear = $options['clear']; + unset($options['clear']); + } + + // Get the form. + $form = $this->loadForm('com_getbible.tag', 'tag', $options, $clear, $xpath); + + if (empty($form)) + { + return false; + } + + $jinput = JFactory::getApplication()->input; + + // The front end calls this model and uses a_id to avoid id clashes so we need to check for that first. + if ($jinput->get('a_id')) + { + $id = $jinput->get('a_id', 0, 'INT'); + } + // The back end uses id so we use that the rest of the time and set it to 0 by default. + else + { + $id = $jinput->get('id', 0, 'INT'); + } + + $user = JFactory::getUser(); + + // Check for existing item. + // Modify the form based on Edit State access controls. + if ($id != 0 && (!$user->authorise('tag.edit.state', 'com_getbible.tag.' . (int) $id)) + || ($id == 0 && !$user->authorise('tag.edit.state', 'com_getbible'))) + { + // Disable fields for display. + $form->setFieldAttribute('ordering', 'disabled', 'true'); + $form->setFieldAttribute('published', 'disabled', 'true'); + // Disable fields while saving. + $form->setFieldAttribute('ordering', 'filter', 'unset'); + $form->setFieldAttribute('published', 'filter', 'unset'); + } + // If this is a new item insure the greated by is set. + if (0 == $id) + { + // Set the created_by to this user + $form->setValue('created_by', null, $user->id); + } + // Modify the form based on Edit Creaded By access controls. + if ($id != 0 && (!$user->authorise('tag.edit.created_by', 'com_getbible.tag.' . (int) $id)) + || ($id == 0 && !$user->authorise('tag.edit.created_by', 'com_getbible'))) + { + // Disable fields for display. + $form->setFieldAttribute('created_by', 'disabled', 'true'); + // Disable fields for display. + $form->setFieldAttribute('created_by', 'readonly', 'true'); + // Disable fields while saving. + $form->setFieldAttribute('created_by', 'filter', 'unset'); + } + // Modify the form based on Edit Creaded Date access controls. + if ($id != 0 && (!$user->authorise('tag.edit.created', 'com_getbible.tag.' . (int) $id)) + || ($id == 0 && !$user->authorise('tag.edit.created', 'com_getbible'))) + { + // Disable fields for display. + $form->setFieldAttribute('created', 'disabled', 'true'); + // Disable fields while saving. + $form->setFieldAttribute('created', 'filter', 'unset'); + } + // Modify the form based on Edit Access 'access' controls. + if ($id != 0 && (!$user->authorise('tag.edit.access', 'com_getbible.tag.' . (int) $id)) + || ($id == 0 && !$user->authorise('tag.edit.access', 'com_getbible'))) + { + // Disable fields for display. + $form->setFieldAttribute('access', 'disabled', 'true'); + // Disable fields while saving. + $form->setFieldAttribute('access', 'filter', 'unset'); + } + // Modify the form based on Edit Name access controls. + if ($id != 0 && (!$user->authorise('tag.edit.name', 'com_getbible.tag.' . (int) $id)) + || ($id == 0 && !$user->authorise('tag.edit.name', 'com_getbible'))) + { + // Disable fields for display. + $form->setFieldAttribute('name', 'disabled', 'true'); + // Disable fields for display. + $form->setFieldAttribute('name', 'readonly', 'true'); + // If there is no value continue. + if (!$form->getValue('name')) + { + // Disable fields while saving. + $form->setFieldAttribute('name', 'filter', 'unset'); + // Disable fields while saving. + $form->setFieldAttribute('name', 'required', 'false'); + } + } + // Modify the form based on Edit Linker access controls. + if ($id != 0 && (!$user->authorise('tag.edit.linker', 'com_getbible.tag.' . (int) $id)) + || ($id == 0 && !$user->authorise('tag.edit.linker', 'com_getbible'))) + { + // Disable fields for display. + $form->setFieldAttribute('linker', 'disabled', 'true'); + // Disable fields for display. + $form->setFieldAttribute('linker', 'readonly', 'true'); + // If there is no value continue. + if (!$form->getValue('linker')) + { + // Disable fields while saving. + $form->setFieldAttribute('linker', 'filter', 'unset'); + // Disable fields while saving. + $form->setFieldAttribute('linker', 'required', 'false'); + } + } + // Modify the form based on Edit Guid access controls. + if ($id != 0 && (!$user->authorise('tag.edit.guid', 'com_getbible.tag.' . (int) $id)) + || ($id == 0 && !$user->authorise('tag.edit.guid', 'com_getbible'))) + { + // Disable fields for display. + $form->setFieldAttribute('guid', 'disabled', 'true'); + // Disable fields for display. + $form->setFieldAttribute('guid', 'readonly', 'true'); + // If there is no value continue. + if (!$form->getValue('guid')) + { + // Disable fields while saving. + $form->setFieldAttribute('guid', 'filter', 'unset'); + // Disable fields while saving. + $form->setFieldAttribute('guid', 'required', 'false'); + } + } + // Modify the form based on Edit Description access controls. + if ($id != 0 && (!$user->authorise('tag.edit.description', 'com_getbible.tag.' . (int) $id)) + || ($id == 0 && !$user->authorise('tag.edit.description', 'com_getbible'))) + { + // Disable fields for display. + $form->setFieldAttribute('description', 'disabled', 'true'); + // Disable fields for display. + $form->setFieldAttribute('description', 'readonly', 'true'); + // If there is no value continue. + if (!$form->getValue('description')) + { + // Disable fields while saving. + $form->setFieldAttribute('description', 'filter', 'unset'); + // Disable fields while saving. + $form->setFieldAttribute('description', 'required', 'false'); + } + } + // Only load these values if no id is found + if (0 == $id) + { + // Set redirected view name + $redirectedView = $jinput->get('ref', null, 'STRING'); + // Set field name (or fall back to view name) + $redirectedField = $jinput->get('field', $redirectedView, 'STRING'); + // Set redirected view id + $redirectedId = $jinput->get('refid', 0, 'INT'); + // Set field id (or fall back to redirected view id) + $redirectedValue = $jinput->get('field_id', $redirectedId, 'INT'); + if (0 != $redirectedValue && $redirectedField) + { + // Now set the local-redirected field default value + $form->setValue($redirectedField, null, $redirectedValue); + } + } + + // Only load the GUID if new item (or empty) + if (0 == $id || !($val = $form->getValue('guid'))) + { + $form->setValue('guid', null, GuidHelper::get()); + } + + return $form; + } + + /** + * Method to get the script that have to be included on the form + * + * @return string script files + */ + public function getScript() + { + return 'media/com_getbible/js/tag.js'; + } + + /** + * Method to test whether a record can be deleted. + * + * @param object $record A record object. + * + * @return boolean True if allowed to delete the record. Defaults to the permission set in the component. + * + * @since 1.6 + */ + protected function canDelete($record) + { + if (!empty($record->id)) + { + if ($record->published != -2) + { + return; + } + + $user = JFactory::getUser(); + // The record has been set. Check the record permissions. + return $user->authorise('tag.delete', 'com_getbible.tag.' . (int) $record->id); + } + return false; + } + + /** + * Method to test whether a record can have its state edited. + * + * @param object $record A record object. + * + * @return boolean True if allowed to change the state of the record. Defaults to the permission set in the component. + * + * @since 1.6 + */ + protected function canEditState($record) + { + $user = JFactory::getUser(); + $recordId = (!empty($record->id)) ? $record->id : 0; + + if ($recordId) + { + // The record has been set. Check the record permissions. + $permission = $user->authorise('tag.edit.state', 'com_getbible.tag.' . (int) $recordId); + if (!$permission && !is_null($permission)) + { + return false; + } + } + // In the absense of better information, revert to the component permissions. + return $user->authorise('tag.edit.state', 'com_getbible'); + } + + /** + * Method override to check if you can edit an existing record. + * + * @param array $data An array of input data. + * @param string $key The name of the key for the primary key. + * + * @return boolean + * @since 2.5 + */ + protected function allowEdit($data = array(), $key = 'id') + { + // Check specific edit permission then general edit permission. + $user = JFactory::getUser(); + + return $user->authorise('tag.edit', 'com_getbible.tag.'. ((int) isset($data[$key]) ? $data[$key] : 0)) or $user->authorise('tag.edit', 'com_getbible'); + } + + /** + * Prepare and sanitise the table data prior to saving. + * + * @param JTable $table A JTable object. + * + * @return void + * + * @since 1.6 + */ + protected function prepareTable($table) + { + $date = JFactory::getDate(); + $user = JFactory::getUser(); + + if (isset($table->name)) + { + $table->name = htmlspecialchars_decode($table->name, ENT_QUOTES); + } + + if (isset($table->alias) && empty($table->alias)) + { + $table->generateAlias(); + } + + if (empty($table->id)) + { + $table->created = $date->toSql(); + // set the user + if ($table->created_by == 0 || empty($table->created_by)) + { + $table->created_by = $user->id; + } + // Set ordering to the last item if not set + if (empty($table->ordering)) + { + $db = JFactory::getDbo(); + $query = $db->getQuery(true) + ->select('MAX(ordering)') + ->from($db->quoteName('#__getbible_tag')); + $db->setQuery($query); + $max = $db->loadResult(); + + $table->ordering = $max + 1; + } + } + else + { + $table->modified = $date->toSql(); + $table->modified_by = $user->id; + } + + if (!empty($table->id)) + { + // Increment the items version number. + $table->version++; + } + } + + /** + * Method to get the data that should be injected in the form. + * + * @return mixed The data for the form. + * + * @since 1.6 + */ + protected function loadFormData() + { + // Check the session for previously entered form data. + $data = JFactory::getApplication()->getUserState('com_getbible.edit.tag.data', array()); + + if (empty($data)) + { + $data = $this->getItem(); + // run the perprocess of the data + $this->preprocessData('com_getbible.tag', $data); + } + + return $data; + } + + /** + * Method to get the unique fields of this table. + * + * @return mixed An array of field names, boolean false if none is set. + * + * @since 3.0 + */ + protected function getUniqueFields() + { + return array('guid'); + } + + /** + * Method to delete one or more records. + * + * @param array &$pks An array of record primary keys. + * + * @return boolean True if successful, false if an error occurs. + * + * @since 12.2 + */ + public function delete(&$pks) + { + if (!parent::delete($pks)) + { + return false; + } + + return true; + } + + /** + * Method to change the published state of one or more records. + * + * @param array &$pks A list of the primary keys to change. + * @param integer $value The value of the published state. + * + * @return boolean True on success. + * + * @since 12.2 + */ + public function publish(&$pks, $value = 1) + { + if (!parent::publish($pks, $value)) + { + return false; + } + + return true; + } + + /** + * Method to perform batch operations on an item or a set of items. + * + * @param array $commands An array of commands to perform. + * @param array $pks An array of item ids. + * @param array $contexts An array of item contexts. + * + * @return boolean Returns true on success, false on failure. + * + * @since 12.2 + */ + public function batch($commands, $pks, $contexts) + { + // Sanitize ids. + $pks = array_unique($pks); + ArrayHelper::toInteger($pks); + + // Remove any values of zero. + if (array_search(0, $pks, true)) + { + unset($pks[array_search(0, $pks, true)]); + } + + if (empty($pks)) + { + $this->setError(JText::_('JGLOBAL_NO_ITEM_SELECTED')); + return false; + } + + $done = false; + + // Set some needed variables. + $this->user = JFactory::getUser(); + $this->table = $this->getTable(); + $this->tableClassName = get_class($this->table); + $this->contentType = new JUcmType; + $this->type = $this->contentType->getTypeByTable($this->tableClassName); + $this->canDo = GetbibleHelper::getActions('tag'); + $this->batchSet = true; + + if (!$this->canDo->get('core.batch')) + { + $this->setError(JText::_('JLIB_APPLICATION_ERROR_INSUFFICIENT_BATCH_INFORMATION')); + return false; + } + + if ($this->type == false) + { + $type = new JUcmType; + $this->type = $type->getTypeByAlias($this->typeAlias); + } + + $this->tagsObserver = $this->table->getObserverOfClass('JTableObserverTags'); + + if (!empty($commands['move_copy'])) + { + $cmd = ArrayHelper::getValue($commands, 'move_copy', 'c'); + + if ($cmd == 'c') + { + $result = $this->batchCopy($commands, $pks, $contexts); + + if (is_array($result)) + { + foreach ($result as $old => $new) + { + $contexts[$new] = $contexts[$old]; + } + $pks = array_values($result); + } + else + { + return false; + } + } + elseif ($cmd == 'm' && !$this->batchMove($commands, $pks, $contexts)) + { + return false; + } + + $done = true; + } + + if (!$done) + { + $this->setError(JText::_('JLIB_APPLICATION_ERROR_INSUFFICIENT_BATCH_INFORMATION')); + + return false; + } + + // Clear the cache + $this->cleanCache(); + + return true; + } + + /** + * Batch copy items to a new category or current. + * + * @param integer $values The new values. + * @param array $pks An array of row IDs. + * @param array $contexts An array of item contexts. + * + * @return mixed An array of new IDs on success, boolean false on failure. + * + * @since 12.2 + */ + protected function batchCopy($values, $pks, $contexts) + { + if (empty($this->batchSet)) + { + // Set some needed variables. + $this->user = JFactory::getUser(); + $this->table = $this->getTable(); + $this->tableClassName = get_class($this->table); + $this->canDo = GetbibleHelper::getActions('tag'); + } + + if (!$this->canDo->get('tag.create') && !$this->canDo->get('tag.batch')) + { + return false; + } + + // get list of unique fields + $uniqueFields = $this->getUniqueFields(); + // remove move_copy from array + unset($values['move_copy']); + + // make sure published is set + if (!isset($values['published'])) + { + $values['published'] = 0; + } + elseif (isset($values['published']) && !$this->canDo->get('tag.edit.state')) + { + $values['published'] = 0; + } + + $newIds = array(); + // Parent exists so let's proceed + while (!empty($pks)) + { + // Pop the first ID off the stack + $pk = array_shift($pks); + + $this->table->reset(); + + // only allow copy if user may edit this item. + if (!$this->user->authorise('tag.edit', $contexts[$pk])) + { + // Not fatal error + $this->setError(JText::sprintf('JLIB_APPLICATION_ERROR_BATCH_MOVE_ROW_NOT_FOUND', $pk)); + continue; + } + + // Check that the row actually exists + if (!$this->table->load($pk)) + { + if ($error = $this->table->getError()) + { + // Fatal error + $this->setError($error); + return false; + } + else + { + // Not fatal error + $this->setError(JText::sprintf('JLIB_APPLICATION_ERROR_BATCH_MOVE_ROW_NOT_FOUND', $pk)); + continue; + } + } + + // Only for strings + if (GetbibleHelper::checkString($this->table->name) && !is_numeric($this->table->name)) + { + $this->table->name = $this->generateUnique('name',$this->table->name); + } + + // insert all set values + if (GetbibleHelper::checkArray($values)) + { + foreach ($values as $key => $value) + { + if (strlen($value) > 0 && isset($this->table->$key)) + { + $this->table->$key = $value; + } + } + } + + // update all unique fields + if (GetbibleHelper::checkArray($uniqueFields)) + { + foreach ($uniqueFields as $uniqueField) + { + $this->table->$uniqueField = $this->generateUnique($uniqueField,$this->table->$uniqueField); + } + } + + // Reset the ID because we are making a copy + $this->table->id = 0; + + // TODO: Deal with ordering? + // $this->table->ordering = 1; + + // Check the row. + if (!$this->table->check()) + { + $this->setError($this->table->getError()); + + return false; + } + + if (!empty($this->type)) + { + $this->createTagsHelper($this->tagsObserver, $this->type, $pk, $this->typeAlias, $this->table); + } + + // Store the row. + if (!$this->table->store()) + { + $this->setError($this->table->getError()); + + return false; + } + + // Get the new item ID + $newId = $this->table->get('id'); + + // Add the new ID to the array + $newIds[$pk] = $newId; + } + + // Clean the cache + $this->cleanCache(); + + return $newIds; + } + + /** + * Batch move items to a new category + * + * @param integer $value The new category ID. + * @param array $pks An array of row IDs. + * @param array $contexts An array of item contexts. + * + * @return boolean True if successful, false otherwise and internal error is set. + * + * @since 12.2 + */ + protected function batchMove($values, $pks, $contexts) + { + if (empty($this->batchSet)) + { + // Set some needed variables. + $this->user = JFactory::getUser(); + $this->table = $this->getTable(); + $this->tableClassName = get_class($this->table); + $this->canDo = GetbibleHelper::getActions('tag'); + } + + if (!$this->canDo->get('tag.edit') && !$this->canDo->get('tag.batch')) + { + $this->setError(JText::_('JLIB_APPLICATION_ERROR_BATCH_CANNOT_EDIT')); + return false; + } + + // make sure published only updates if user has the permission. + if (isset($values['published']) && !$this->canDo->get('tag.edit.state')) + { + unset($values['published']); + } + // remove move_copy from array + unset($values['move_copy']); + + // Parent exists so we proceed + foreach ($pks as $pk) + { + if (!$this->user->authorise('tag.edit', $contexts[$pk])) + { + $this->setError(JText::_('JLIB_APPLICATION_ERROR_BATCH_CANNOT_EDIT')); + return false; + } + + // Check that the row actually exists + if (!$this->table->load($pk)) + { + if ($error = $this->table->getError()) + { + // Fatal error + $this->setError($error); + return false; + } + else + { + // Not fatal error + $this->setError(JText::sprintf('JLIB_APPLICATION_ERROR_BATCH_MOVE_ROW_NOT_FOUND', $pk)); + continue; + } + } + + // insert all set values. + if (GetbibleHelper::checkArray($values)) + { + foreach ($values as $key => $value) + { + // Do special action for access. + if ('access' === $key && strlen($value) > 0) + { + $this->table->$key = $value; + } + elseif (strlen($value) > 0 && isset($this->table->$key)) + { + $this->table->$key = $value; + } + } + } + + + // Check the row. + if (!$this->table->check()) + { + $this->setError($this->table->getError()); + + return false; + } + + if (!empty($this->type)) + { + $this->createTagsHelper($this->tagsObserver, $this->type, $pk, $this->typeAlias, $this->table); + } + + // Store the row. + if (!$this->table->store()) + { + $this->setError($this->table->getError()); + + return false; + } + } + + // Clean the cache + $this->cleanCache(); + + return true; + } + + /** + * Method to save the form data. + * + * @param array $data The form data. + * + * @return boolean True on success. + * + * @since 1.6 + */ + public function save($data) + { + $input = JFactory::getApplication()->input; + $filter = JFilterInput::getInstance(); + + // set the metadata to the Item Data + if (isset($data['metadata']) && isset($data['metadata']['author'])) + { + $data['metadata']['author'] = $filter->clean($data['metadata']['author'], 'TRIM'); + + $metadata = new JRegistry; + $metadata->loadArray($data['metadata']); + $data['metadata'] = (string) $metadata; + } + + + // Set the GUID if empty or not valid + if (empty($data['guid']) && $data['id'] > 0) + { + // get the existing one + $data['guid'] = (string) GetHelper::var('tag', $data['id'], 'id', 'guid'); + } + + // Set the GUID if empty or not valid + while (!GuidHelper::valid($data['guid'], "tag", $data['id'])) + { + // must always be set + $data['guid'] = (string) GuidHelper::get(); + } + + // Set the Params Items to data + if (isset($data['params']) && is_array($data['params'])) + { + $params = new JRegistry; + $params->loadArray($data['params']); + $data['params'] = (string) $params; + } + + // Alter the unique field for save as copy + if ($input->get('task') === 'save2copy') + { + // Automatic handling of other unique fields + $uniqueFields = $this->getUniqueFields(); + if (GetbibleHelper::checkArray($uniqueFields)) + { + foreach ($uniqueFields as $uniqueField) + { + $data[$uniqueField] = $this->generateUnique($uniqueField,$data[$uniqueField]); + } + } + } + + if (parent::save($data)) + { + return true; + } + return false; + } + + /** + * Method to generate a unique value. + * + * @param string $field name. + * @param string $value data. + * + * @return string New value. + * + * @since 3.0 + */ + protected function generateUnique($field,$value) + { + + // set field value unique + $table = $this->getTable(); + + while ($table->load(array($field => $value))) + { + $value = StringHelper::increment($value); + } + + return $value; + } + + /** + * Method to change the title + * + * @param string $title The title. + * + * @return array Contains the modified title and alias. + * + */ + protected function _generateNewTitle($title) + { + + // Alter the title + $table = $this->getTable(); + + while ($table->load(array('title' => $title))) + { + $title = StringHelper::increment($title); + } + + return $title; + } +} diff --git a/admin/models/tagged_verse.php b/admin/models/tagged_verse.php new file mode 100644 index 0000000..849ba2b --- /dev/null +++ b/admin/models/tagged_verse.php @@ -0,0 +1,1010 @@ + + @git Get Bible + @github Get Bible + @support Get Bible + @copyright Copyright (C) 2015. All Rights Reserved + @license GNU/GPL Version 2 or later - http://www.gnu.org/licenses/gpl-2.0.html + +/------------------------------------------------------------------------------------------------------*/ + +// No direct access to this file +defined('_JEXEC') or die('Restricted access'); + +use Joomla\CMS\MVC\Model\AdminModel; +use Joomla\Registry\Registry; +use Joomla\String\StringHelper; +use Joomla\Utilities\ArrayHelper; +use VDM\Joomla\Utilities\GuidHelper; +use VDM\Joomla\Utilities\GetHelper; + +/** + * Getbible Tagged_verse Admin Model + */ +class GetbibleModelTagged_verse extends AdminModel +{ + /** + * The tab layout fields array. + * + * @var array + */ + protected $tabLayoutFields = array( + 'details' => array( + 'left' => array( + 'abbreviation', + 'book_nr' + ), + 'right' => array( + 'chapter', + 'verse' + ), + 'above' => array( + 'tag', + 'access', + 'linker' + ) + ) + ); + + /** + * @var string The prefix to use with controller messages. + * @since 1.6 + */ + protected $text_prefix = 'COM_GETBIBLE'; + + /** + * The type alias for this content type. + * + * @var string + * @since 3.2 + */ + public $typeAlias = 'com_getbible.tagged_verse'; + + /** + * Returns a Table object, always creating it + * + * @param type $type The table type to instantiate + * @param string $prefix A prefix for the table class name. Optional. + * @param array $config Configuration array for model. Optional. + * + * @return JTable A database object + * + * @since 1.6 + */ + public function getTable($type = 'tagged_verse', $prefix = 'GetbibleTable', $config = array()) + { + // add table path for when model gets used from other component + $this->addTablePath(JPATH_ADMINISTRATOR . '/components/com_getbible/tables'); + // get instance of the table + return JTable::getInstance($type, $prefix, $config); + } + + /** + * Method to get a single record. + * + * @param integer $pk The id of the primary key. + * + * @return mixed Object on success, false on failure. + * + * @since 1.6 + */ + public function getItem($pk = null) + { + if ($item = parent::getItem($pk)) + { + if (!empty($item->params) && !is_array($item->params)) + { + // Convert the params field to an array. + $registry = new Registry; + $registry->loadString($item->params); + $item->params = $registry->toArray(); + } + + if (!empty($item->metadata)) + { + // Convert the metadata field to an array. + $registry = new Registry; + $registry->loadString($item->metadata); + $item->metadata = $registry->toArray(); + } + } + + return $item; + } + + /** + * Method to get the record form. + * + * @param array $data Data for the form. + * @param boolean $loadData True if the form is to load its own data (default case), false if not. + * @param array $options Optional array of options for the form creation. + * + * @return mixed A JForm object on success, false on failure + * + * @since 1.6 + */ + public function getForm($data = array(), $loadData = true, $options = array('control' => 'jform')) + { + // set load data option + $options['load_data'] = $loadData; + // check if xpath was set in options + $xpath = false; + if (isset($options['xpath'])) + { + $xpath = $options['xpath']; + unset($options['xpath']); + } + // check if clear form was set in options + $clear = false; + if (isset($options['clear'])) + { + $clear = $options['clear']; + unset($options['clear']); + } + + // Get the form. + $form = $this->loadForm('com_getbible.tagged_verse', 'tagged_verse', $options, $clear, $xpath); + + if (empty($form)) + { + return false; + } + + $jinput = JFactory::getApplication()->input; + + // The front end calls this model and uses a_id to avoid id clashes so we need to check for that first. + if ($jinput->get('a_id')) + { + $id = $jinput->get('a_id', 0, 'INT'); + } + // The back end uses id so we use that the rest of the time and set it to 0 by default. + else + { + $id = $jinput->get('id', 0, 'INT'); + } + + $user = JFactory::getUser(); + + // Check for existing item. + // Modify the form based on Edit State access controls. + if ($id != 0 && (!$user->authorise('tagged_verse.edit.state', 'com_getbible.tagged_verse.' . (int) $id)) + || ($id == 0 && !$user->authorise('tagged_verse.edit.state', 'com_getbible'))) + { + // Disable fields for display. + $form->setFieldAttribute('ordering', 'disabled', 'true'); + $form->setFieldAttribute('published', 'disabled', 'true'); + // Disable fields while saving. + $form->setFieldAttribute('ordering', 'filter', 'unset'); + $form->setFieldAttribute('published', 'filter', 'unset'); + } + // If this is a new item insure the greated by is set. + if (0 == $id) + { + // Set the created_by to this user + $form->setValue('created_by', null, $user->id); + } + // Modify the form based on Edit Creaded By access controls. + if ($id != 0 && (!$user->authorise('tagged_verse.edit.created_by', 'com_getbible.tagged_verse.' . (int) $id)) + || ($id == 0 && !$user->authorise('tagged_verse.edit.created_by', 'com_getbible'))) + { + // Disable fields for display. + $form->setFieldAttribute('created_by', 'disabled', 'true'); + // Disable fields for display. + $form->setFieldAttribute('created_by', 'readonly', 'true'); + // Disable fields while saving. + $form->setFieldAttribute('created_by', 'filter', 'unset'); + } + // Modify the form based on Edit Creaded Date access controls. + if ($id != 0 && (!$user->authorise('tagged_verse.edit.created', 'com_getbible.tagged_verse.' . (int) $id)) + || ($id == 0 && !$user->authorise('tagged_verse.edit.created', 'com_getbible'))) + { + // Disable fields for display. + $form->setFieldAttribute('created', 'disabled', 'true'); + // Disable fields while saving. + $form->setFieldAttribute('created', 'filter', 'unset'); + } + // Modify the form based on Edit Access 'access' controls. + if ($id != 0 && (!$user->authorise('tagged_verse.edit.access', 'com_getbible.tagged_verse.' . (int) $id)) + || ($id == 0 && !$user->authorise('tagged_verse.edit.access', 'com_getbible'))) + { + // Disable fields for display. + $form->setFieldAttribute('access', 'disabled', 'true'); + // Disable fields while saving. + $form->setFieldAttribute('access', 'filter', 'unset'); + } + // Modify the form based on Edit Book Nr access controls. + if ($id != 0 && (!$user->authorise('tagged_verse.edit.book_nr', 'com_getbible.tagged_verse.' . (int) $id)) + || ($id == 0 && !$user->authorise('tagged_verse.edit.book_nr', 'com_getbible'))) + { + // Disable fields for display. + $form->setFieldAttribute('book_nr', 'disabled', 'true'); + // Disable fields for display. + $form->setFieldAttribute('book_nr', 'readonly', 'true'); + // If there is no value continue. + if (!$form->getValue('book_nr')) + { + // Disable fields while saving. + $form->setFieldAttribute('book_nr', 'filter', 'unset'); + // Disable fields while saving. + $form->setFieldAttribute('book_nr', 'required', 'false'); + } + } + // Modify the form based on Edit Abbreviation access controls. + if ($id != 0 && (!$user->authorise('tagged_verse.edit.abbreviation', 'com_getbible.tagged_verse.' . (int) $id)) + || ($id == 0 && !$user->authorise('tagged_verse.edit.abbreviation', 'com_getbible'))) + { + // Disable fields for display. + $form->setFieldAttribute('abbreviation', 'disabled', 'true'); + // Disable fields for display. + $form->setFieldAttribute('abbreviation', 'readonly', 'true'); + // If there is no value continue. + if (!$form->getValue('abbreviation')) + { + // Disable fields while saving. + $form->setFieldAttribute('abbreviation', 'filter', 'unset'); + // Disable fields while saving. + $form->setFieldAttribute('abbreviation', 'required', 'false'); + } + } + // Modify the form based on Edit Linker access controls. + if ($id != 0 && (!$user->authorise('tagged_verse.edit.linker', 'com_getbible.tagged_verse.' . (int) $id)) + || ($id == 0 && !$user->authorise('tagged_verse.edit.linker', 'com_getbible'))) + { + // Disable fields for display. + $form->setFieldAttribute('linker', 'disabled', 'true'); + // Disable fields for display. + $form->setFieldAttribute('linker', 'readonly', 'true'); + // If there is no value continue. + if (!$form->getValue('linker')) + { + // Disable fields while saving. + $form->setFieldAttribute('linker', 'filter', 'unset'); + // Disable fields while saving. + $form->setFieldAttribute('linker', 'required', 'false'); + } + } + // Modify the form based on Edit Tag access controls. + if ($id != 0 && (!$user->authorise('tagged_verse.edit.tag', 'com_getbible.tagged_verse.' . (int) $id)) + || ($id == 0 && !$user->authorise('tagged_verse.edit.tag', 'com_getbible'))) + { + // Disable fields for display. + $form->setFieldAttribute('tag', 'disabled', 'true'); + // Disable fields for display. + $form->setFieldAttribute('tag', 'readonly', 'true'); + // If there is no value continue. + if (!$form->getValue('tag')) + { + // Disable fields while saving. + $form->setFieldAttribute('tag', 'filter', 'unset'); + // Disable fields while saving. + $form->setFieldAttribute('tag', 'required', 'false'); + } + } + // Modify the form based on Edit Guid access controls. + if ($id != 0 && (!$user->authorise('tagged_verse.edit.guid', 'com_getbible.tagged_verse.' . (int) $id)) + || ($id == 0 && !$user->authorise('tagged_verse.edit.guid', 'com_getbible'))) + { + // Disable fields for display. + $form->setFieldAttribute('guid', 'disabled', 'true'); + // Disable fields for display. + $form->setFieldAttribute('guid', 'readonly', 'true'); + // If there is no value continue. + if (!$form->getValue('guid')) + { + // Disable fields while saving. + $form->setFieldAttribute('guid', 'filter', 'unset'); + // Disable fields while saving. + $form->setFieldAttribute('guid', 'required', 'false'); + } + } + // Modify the form based on Edit Verse access controls. + if ($id != 0 && (!$user->authorise('tagged_verse.edit.verse', 'com_getbible.tagged_verse.' . (int) $id)) + || ($id == 0 && !$user->authorise('tagged_verse.edit.verse', 'com_getbible'))) + { + // Disable fields for display. + $form->setFieldAttribute('verse', 'disabled', 'true'); + // Disable fields for display. + $form->setFieldAttribute('verse', 'readonly', 'true'); + // If there is no value continue. + if (!$form->getValue('verse')) + { + // Disable fields while saving. + $form->setFieldAttribute('verse', 'filter', 'unset'); + // Disable fields while saving. + $form->setFieldAttribute('verse', 'required', 'false'); + } + } + // Modify the form based on Edit Chapter access controls. + if ($id != 0 && (!$user->authorise('tagged_verse.edit.chapter', 'com_getbible.tagged_verse.' . (int) $id)) + || ($id == 0 && !$user->authorise('tagged_verse.edit.chapter', 'com_getbible'))) + { + // Disable fields for display. + $form->setFieldAttribute('chapter', 'disabled', 'true'); + // Disable fields for display. + $form->setFieldAttribute('chapter', 'readonly', 'true'); + // If there is no value continue. + if (!$form->getValue('chapter')) + { + // Disable fields while saving. + $form->setFieldAttribute('chapter', 'filter', 'unset'); + // Disable fields while saving. + $form->setFieldAttribute('chapter', 'required', 'false'); + } + } + // Only load these values if no id is found + if (0 == $id) + { + // Set redirected view name + $redirectedView = $jinput->get('ref', null, 'STRING'); + // Set field name (or fall back to view name) + $redirectedField = $jinput->get('field', $redirectedView, 'STRING'); + // Set redirected view id + $redirectedId = $jinput->get('refid', 0, 'INT'); + // Set field id (or fall back to redirected view id) + $redirectedValue = $jinput->get('field_id', $redirectedId, 'INT'); + if (0 != $redirectedValue && $redirectedField) + { + // Now set the local-redirected field default value + $form->setValue($redirectedField, null, $redirectedValue); + } + } + + // Only load the GUID if new item (or empty) + if (0 == $id || !($val = $form->getValue('guid'))) + { + $form->setValue('guid', null, GuidHelper::get()); + } + + return $form; + } + + /** + * Method to get the script that have to be included on the form + * + * @return string script files + */ + public function getScript() + { + return 'media/com_getbible/js/tagged_verse.js'; + } + + /** + * Method to test whether a record can be deleted. + * + * @param object $record A record object. + * + * @return boolean True if allowed to delete the record. Defaults to the permission set in the component. + * + * @since 1.6 + */ + protected function canDelete($record) + { + if (!empty($record->id)) + { + if ($record->published != -2) + { + return; + } + + $user = JFactory::getUser(); + // The record has been set. Check the record permissions. + return $user->authorise('tagged_verse.delete', 'com_getbible.tagged_verse.' . (int) $record->id); + } + return false; + } + + /** + * Method to test whether a record can have its state edited. + * + * @param object $record A record object. + * + * @return boolean True if allowed to change the state of the record. Defaults to the permission set in the component. + * + * @since 1.6 + */ + protected function canEditState($record) + { + $user = JFactory::getUser(); + $recordId = (!empty($record->id)) ? $record->id : 0; + + if ($recordId) + { + // The record has been set. Check the record permissions. + $permission = $user->authorise('tagged_verse.edit.state', 'com_getbible.tagged_verse.' . (int) $recordId); + if (!$permission && !is_null($permission)) + { + return false; + } + } + // In the absense of better information, revert to the component permissions. + return $user->authorise('tagged_verse.edit.state', 'com_getbible'); + } + + /** + * Method override to check if you can edit an existing record. + * + * @param array $data An array of input data. + * @param string $key The name of the key for the primary key. + * + * @return boolean + * @since 2.5 + */ + protected function allowEdit($data = array(), $key = 'id') + { + // Check specific edit permission then general edit permission. + $user = JFactory::getUser(); + + return $user->authorise('tagged_verse.edit', 'com_getbible.tagged_verse.'. ((int) isset($data[$key]) ? $data[$key] : 0)) or $user->authorise('tagged_verse.edit', 'com_getbible'); + } + + /** + * Prepare and sanitise the table data prior to saving. + * + * @param JTable $table A JTable object. + * + * @return void + * + * @since 1.6 + */ + protected function prepareTable($table) + { + $date = JFactory::getDate(); + $user = JFactory::getUser(); + + if (isset($table->name)) + { + $table->name = htmlspecialchars_decode($table->name, ENT_QUOTES); + } + + if (isset($table->alias) && empty($table->alias)) + { + $table->generateAlias(); + } + + if (empty($table->id)) + { + $table->created = $date->toSql(); + // set the user + if ($table->created_by == 0 || empty($table->created_by)) + { + $table->created_by = $user->id; + } + // Set ordering to the last item if not set + if (empty($table->ordering)) + { + $db = JFactory::getDbo(); + $query = $db->getQuery(true) + ->select('MAX(ordering)') + ->from($db->quoteName('#__getbible_tagged_verse')); + $db->setQuery($query); + $max = $db->loadResult(); + + $table->ordering = $max + 1; + } + } + else + { + $table->modified = $date->toSql(); + $table->modified_by = $user->id; + } + + if (!empty($table->id)) + { + // Increment the items version number. + $table->version++; + } + } + + /** + * Method to get the data that should be injected in the form. + * + * @return mixed The data for the form. + * + * @since 1.6 + */ + protected function loadFormData() + { + // Check the session for previously entered form data. + $data = JFactory::getApplication()->getUserState('com_getbible.edit.tagged_verse.data', array()); + + if (empty($data)) + { + $data = $this->getItem(); + // run the perprocess of the data + $this->preprocessData('com_getbible.tagged_verse', $data); + } + + return $data; + } + + /** + * Method to get the unique fields of this table. + * + * @return mixed An array of field names, boolean false if none is set. + * + * @since 3.0 + */ + protected function getUniqueFields() + { + return array('guid'); + } + + /** + * Method to delete one or more records. + * + * @param array &$pks An array of record primary keys. + * + * @return boolean True if successful, false if an error occurs. + * + * @since 12.2 + */ + public function delete(&$pks) + { + if (!parent::delete($pks)) + { + return false; + } + + return true; + } + + /** + * Method to change the published state of one or more records. + * + * @param array &$pks A list of the primary keys to change. + * @param integer $value The value of the published state. + * + * @return boolean True on success. + * + * @since 12.2 + */ + public function publish(&$pks, $value = 1) + { + if (!parent::publish($pks, $value)) + { + return false; + } + + return true; + } + + /** + * Method to perform batch operations on an item or a set of items. + * + * @param array $commands An array of commands to perform. + * @param array $pks An array of item ids. + * @param array $contexts An array of item contexts. + * + * @return boolean Returns true on success, false on failure. + * + * @since 12.2 + */ + public function batch($commands, $pks, $contexts) + { + // Sanitize ids. + $pks = array_unique($pks); + ArrayHelper::toInteger($pks); + + // Remove any values of zero. + if (array_search(0, $pks, true)) + { + unset($pks[array_search(0, $pks, true)]); + } + + if (empty($pks)) + { + $this->setError(JText::_('JGLOBAL_NO_ITEM_SELECTED')); + return false; + } + + $done = false; + + // Set some needed variables. + $this->user = JFactory::getUser(); + $this->table = $this->getTable(); + $this->tableClassName = get_class($this->table); + $this->contentType = new JUcmType; + $this->type = $this->contentType->getTypeByTable($this->tableClassName); + $this->canDo = GetbibleHelper::getActions('tagged_verse'); + $this->batchSet = true; + + if (!$this->canDo->get('core.batch')) + { + $this->setError(JText::_('JLIB_APPLICATION_ERROR_INSUFFICIENT_BATCH_INFORMATION')); + return false; + } + + if ($this->type == false) + { + $type = new JUcmType; + $this->type = $type->getTypeByAlias($this->typeAlias); + } + + $this->tagsObserver = $this->table->getObserverOfClass('JTableObserverTags'); + + if (!empty($commands['move_copy'])) + { + $cmd = ArrayHelper::getValue($commands, 'move_copy', 'c'); + + if ($cmd == 'c') + { + $result = $this->batchCopy($commands, $pks, $contexts); + + if (is_array($result)) + { + foreach ($result as $old => $new) + { + $contexts[$new] = $contexts[$old]; + } + $pks = array_values($result); + } + else + { + return false; + } + } + elseif ($cmd == 'm' && !$this->batchMove($commands, $pks, $contexts)) + { + return false; + } + + $done = true; + } + + if (!$done) + { + $this->setError(JText::_('JLIB_APPLICATION_ERROR_INSUFFICIENT_BATCH_INFORMATION')); + + return false; + } + + // Clear the cache + $this->cleanCache(); + + return true; + } + + /** + * Batch copy items to a new category or current. + * + * @param integer $values The new values. + * @param array $pks An array of row IDs. + * @param array $contexts An array of item contexts. + * + * @return mixed An array of new IDs on success, boolean false on failure. + * + * @since 12.2 + */ + protected function batchCopy($values, $pks, $contexts) + { + if (empty($this->batchSet)) + { + // Set some needed variables. + $this->user = JFactory::getUser(); + $this->table = $this->getTable(); + $this->tableClassName = get_class($this->table); + $this->canDo = GetbibleHelper::getActions('tagged_verse'); + } + + if (!$this->canDo->get('tagged_verse.create') && !$this->canDo->get('tagged_verse.batch')) + { + return false; + } + + // get list of unique fields + $uniqueFields = $this->getUniqueFields(); + // remove move_copy from array + unset($values['move_copy']); + + // make sure published is set + if (!isset($values['published'])) + { + $values['published'] = 0; + } + elseif (isset($values['published']) && !$this->canDo->get('tagged_verse.edit.state')) + { + $values['published'] = 0; + } + + $newIds = array(); + // Parent exists so let's proceed + while (!empty($pks)) + { + // Pop the first ID off the stack + $pk = array_shift($pks); + + $this->table->reset(); + + // only allow copy if user may edit this item. + if (!$this->user->authorise('tagged_verse.edit', $contexts[$pk])) + { + // Not fatal error + $this->setError(JText::sprintf('JLIB_APPLICATION_ERROR_BATCH_MOVE_ROW_NOT_FOUND', $pk)); + continue; + } + + // Check that the row actually exists + if (!$this->table->load($pk)) + { + if ($error = $this->table->getError()) + { + // Fatal error + $this->setError($error); + return false; + } + else + { + // Not fatal error + $this->setError(JText::sprintf('JLIB_APPLICATION_ERROR_BATCH_MOVE_ROW_NOT_FOUND', $pk)); + continue; + } + } + + // insert all set values + if (GetbibleHelper::checkArray($values)) + { + foreach ($values as $key => $value) + { + if (strlen($value) > 0 && isset($this->table->$key)) + { + $this->table->$key = $value; + } + } + } + + // update all unique fields + if (GetbibleHelper::checkArray($uniqueFields)) + { + foreach ($uniqueFields as $uniqueField) + { + $this->table->$uniqueField = $this->generateUnique($uniqueField,$this->table->$uniqueField); + } + } + + // Reset the ID because we are making a copy + $this->table->id = 0; + + // TODO: Deal with ordering? + // $this->table->ordering = 1; + + // Check the row. + if (!$this->table->check()) + { + $this->setError($this->table->getError()); + + return false; + } + + if (!empty($this->type)) + { + $this->createTagsHelper($this->tagsObserver, $this->type, $pk, $this->typeAlias, $this->table); + } + + // Store the row. + if (!$this->table->store()) + { + $this->setError($this->table->getError()); + + return false; + } + + // Get the new item ID + $newId = $this->table->get('id'); + + // Add the new ID to the array + $newIds[$pk] = $newId; + } + + // Clean the cache + $this->cleanCache(); + + return $newIds; + } + + /** + * Batch move items to a new category + * + * @param integer $value The new category ID. + * @param array $pks An array of row IDs. + * @param array $contexts An array of item contexts. + * + * @return boolean True if successful, false otherwise and internal error is set. + * + * @since 12.2 + */ + protected function batchMove($values, $pks, $contexts) + { + if (empty($this->batchSet)) + { + // Set some needed variables. + $this->user = JFactory::getUser(); + $this->table = $this->getTable(); + $this->tableClassName = get_class($this->table); + $this->canDo = GetbibleHelper::getActions('tagged_verse'); + } + + if (!$this->canDo->get('tagged_verse.edit') && !$this->canDo->get('tagged_verse.batch')) + { + $this->setError(JText::_('JLIB_APPLICATION_ERROR_BATCH_CANNOT_EDIT')); + return false; + } + + // make sure published only updates if user has the permission. + if (isset($values['published']) && !$this->canDo->get('tagged_verse.edit.state')) + { + unset($values['published']); + } + // remove move_copy from array + unset($values['move_copy']); + + // Parent exists so we proceed + foreach ($pks as $pk) + { + if (!$this->user->authorise('tagged_verse.edit', $contexts[$pk])) + { + $this->setError(JText::_('JLIB_APPLICATION_ERROR_BATCH_CANNOT_EDIT')); + return false; + } + + // Check that the row actually exists + if (!$this->table->load($pk)) + { + if ($error = $this->table->getError()) + { + // Fatal error + $this->setError($error); + return false; + } + else + { + // Not fatal error + $this->setError(JText::sprintf('JLIB_APPLICATION_ERROR_BATCH_MOVE_ROW_NOT_FOUND', $pk)); + continue; + } + } + + // insert all set values. + if (GetbibleHelper::checkArray($values)) + { + foreach ($values as $key => $value) + { + // Do special action for access. + if ('access' === $key && strlen($value) > 0) + { + $this->table->$key = $value; + } + elseif (strlen($value) > 0 && isset($this->table->$key)) + { + $this->table->$key = $value; + } + } + } + + + // Check the row. + if (!$this->table->check()) + { + $this->setError($this->table->getError()); + + return false; + } + + if (!empty($this->type)) + { + $this->createTagsHelper($this->tagsObserver, $this->type, $pk, $this->typeAlias, $this->table); + } + + // Store the row. + if (!$this->table->store()) + { + $this->setError($this->table->getError()); + + return false; + } + } + + // Clean the cache + $this->cleanCache(); + + return true; + } + + /** + * Method to save the form data. + * + * @param array $data The form data. + * + * @return boolean True on success. + * + * @since 1.6 + */ + public function save($data) + { + $input = JFactory::getApplication()->input; + $filter = JFilterInput::getInstance(); + + // set the metadata to the Item Data + if (isset($data['metadata']) && isset($data['metadata']['author'])) + { + $data['metadata']['author'] = $filter->clean($data['metadata']['author'], 'TRIM'); + + $metadata = new JRegistry; + $metadata->loadArray($data['metadata']); + $data['metadata'] = (string) $metadata; + } + + + // Set the GUID if empty or not valid + if (empty($data['guid']) && $data['id'] > 0) + { + // get the existing one + $data['guid'] = (string) GetHelper::var('tagged_verse', $data['id'], 'id', 'guid'); + } + + // Set the GUID if empty or not valid + while (!GuidHelper::valid($data['guid'], "tagged_verse", $data['id'])) + { + // must always be set + $data['guid'] = (string) GuidHelper::get(); + } + + // Set the Params Items to data + if (isset($data['params']) && is_array($data['params'])) + { + $params = new JRegistry; + $params->loadArray($data['params']); + $data['params'] = (string) $params; + } + + // Alter the unique field for save as copy + if ($input->get('task') === 'save2copy') + { + // Automatic handling of other unique fields + $uniqueFields = $this->getUniqueFields(); + if (GetbibleHelper::checkArray($uniqueFields)) + { + foreach ($uniqueFields as $uniqueField) + { + $data[$uniqueField] = $this->generateUnique($uniqueField,$data[$uniqueField]); + } + } + } + + if (parent::save($data)) + { + return true; + } + return false; + } + + /** + * Method to generate a unique value. + * + * @param string $field name. + * @param string $value data. + * + * @return string New value. + * + * @since 3.0 + */ + protected function generateUnique($field,$value) + { + + // set field value unique + $table = $this->getTable(); + + while ($table->load(array($field => $value))) + { + $value = StringHelper::increment($value); + } + + return $value; + } +} diff --git a/admin/models/tagged_verses.php b/admin/models/tagged_verses.php new file mode 100644 index 0000000..a99de09 --- /dev/null +++ b/admin/models/tagged_verses.php @@ -0,0 +1,629 @@ + + @git Get Bible + @github Get Bible + @support Get Bible + @copyright Copyright (C) 2015. All Rights Reserved + @license GNU/GPL Version 2 or later - http://www.gnu.org/licenses/gpl-2.0.html + +/------------------------------------------------------------------------------------------------------*/ + +// No direct access to this file +defined('_JEXEC') or die('Restricted access'); + +use Joomla\CMS\MVC\Model\ListModel; +use Joomla\Utilities\ArrayHelper; + +/** + * Tagged_verses List Model + */ +class GetbibleModelTagged_verses extends ListModel +{ + public function __construct($config = array()) + { + if (empty($config['filter_fields'])) + { + $config['filter_fields'] = array( + 'a.id','id', + 'a.published','published', + 'a.access','access', + 'a.ordering','ordering', + 'a.created_by','created_by', + 'a.modified_by','modified_by', + 'a.book_nr','book_nr', + 'g.translation','abbreviation', + 'h.name','linker', + 'i.name','tag', + 'a.verse','verse', + 'a.chapter','chapter' + ); + } + + parent::__construct($config); + } + + /** + * Method to auto-populate the model state. + * + * Note. Calling getState in this method will result in recursion. + * + * @param string $ordering An optional ordering field. + * @param string $direction An optional direction (asc|desc). + * + * @return void + * + */ + protected function populateState($ordering = null, $direction = null) + { + $app = JFactory::getApplication(); + + // Adjust the context to support modal layouts. + if ($layout = $app->input->get('layout')) + { + $this->context .= '.' . $layout; + } + + // Check if the form was submitted + $formSubmited = $app->input->post->get('form_submited'); + + $published = $this->getUserStateFromRequest($this->context . '.filter.published', 'filter_published', ''); + $this->setState('filter.published', $published); + + $created_by = $this->getUserStateFromRequest($this->context . '.filter.created_by', 'filter_created_by', ''); + $this->setState('filter.created_by', $created_by); + + $created = $this->getUserStateFromRequest($this->context . '.filter.created', 'filter_created'); + $this->setState('filter.created', $created); + + $sorting = $this->getUserStateFromRequest($this->context . '.filter.sorting', 'filter_sorting', 0, 'int'); + $this->setState('filter.sorting', $sorting); + + $search = $this->getUserStateFromRequest($this->context . '.filter.search', 'filter_search'); + $this->setState('filter.search', $search); + + $book_nr = $this->getUserStateFromRequest($this->context . '.filter.book_nr', 'filter_book_nr'); + if ($formSubmited) + { + $book_nr = $app->input->post->get('book_nr'); + $this->setState('filter.book_nr', $book_nr); + } + + $abbreviation = $this->getUserStateFromRequest($this->context . '.filter.abbreviation', 'filter_abbreviation'); + if ($formSubmited) + { + $abbreviation = $app->input->post->get('abbreviation'); + $this->setState('filter.abbreviation', $abbreviation); + } + + $access = $this->getUserStateFromRequest($this->context . '.filter.access', 'filter_access'); + if ($formSubmited) + { + $access = $app->input->post->get('access'); + $this->setState('filter.access', $access); + } + + $linker = $this->getUserStateFromRequest($this->context . '.filter.linker', 'filter_linker'); + if ($formSubmited) + { + $linker = $app->input->post->get('linker'); + $this->setState('filter.linker', $linker); + } + + $tag = $this->getUserStateFromRequest($this->context . '.filter.tag', 'filter_tag'); + if ($formSubmited) + { + $tag = $app->input->post->get('tag'); + $this->setState('filter.tag', $tag); + } + + $verse = $this->getUserStateFromRequest($this->context . '.filter.verse', 'filter_verse'); + if ($formSubmited) + { + $verse = $app->input->post->get('verse'); + $this->setState('filter.verse', $verse); + } + + $chapter = $this->getUserStateFromRequest($this->context . '.filter.chapter', 'filter_chapter'); + if ($formSubmited) + { + $chapter = $app->input->post->get('chapter'); + $this->setState('filter.chapter', $chapter); + } + + // List state information. + parent::populateState($ordering, $direction); + } + + /** + * Method to get an array of data items. + * + * @return mixed An array of data items on success, false on failure. + */ + public function getItems() + { + // Check in items + $this->checkInNow(); + + // load parent items + $items = parent::getItems(); + + // Set values to display correctly. + if (GetbibleHelper::checkArray($items)) + { + // Get the user object if not set. + if (!isset($user) || !GetbibleHelper::checkObject($user)) + { + $user = JFactory::getUser(); + } + foreach ($items as $nr => &$item) + { + // Remove items the user can't access. + $access = ($user->authorise('tagged_verse.access', 'com_getbible.tagged_verse.' . (int) $item->id) && $user->authorise('tagged_verse.access', 'com_getbible')); + if (!$access) + { + unset($items[$nr]); + continue; + } + + $item->book_nr = $item->book_nr . ' ' . $item->chapter . ':' . $item->verse; + } + } + + // set selection value to a translatable value + if (GetbibleHelper::checkArray($items)) + { + foreach ($items as $nr => &$item) + { + // convert access + $item->access = $this->selectionTranslation($item->access, 'access'); + } + } + + + // return items + return $items; + } + + /** + * Method to convert selection values to translatable string. + * + * @return translatable string + */ + public function selectionTranslation($value,$name) + { + // Array of access language strings + if ($name === 'access') + { + $accessArray = array( + 1 => 'COM_GETBIBLE_TAGGED_VERSE_PUBLIC', + 0 => 'COM_GETBIBLE_TAGGED_VERSE_PRIVATE' + ); + // Now check if value is found in this array + if (isset($accessArray[$value]) && GetbibleHelper::checkString($accessArray[$value])) + { + return $accessArray[$value]; + } + } + return $value; + } + + /** + * Method to build an SQL query to load the list data. + * + * @return string An SQL query + */ + protected function getListQuery() + { + // Get the user object. + $user = JFactory::getUser(); + // Create a new query object. + $db = JFactory::getDBO(); + $query = $db->getQuery(true); + + // Select some fields + $query->select('a.*'); + + // From the getbible_item table + $query->from($db->quoteName('#__getbible_tagged_verse', 'a')); + + // From the getbible_translation table. + $query->select($db->quoteName(['g.translation','g.id'],['abbreviation_translation','abbreviation_id'])); + $query->join('LEFT', $db->quoteName('#__getbible_translation', 'g') . ' ON (' . $db->quoteName('a.abbreviation') . ' = ' . $db->quoteName('g.abbreviation') . ')'); + + // From the getbible_linker table. + $query->select($db->quoteName(['h.name','h.id'],['linker_name','linker_id'])); + $query->join('LEFT', $db->quoteName('#__getbible_linker', 'h') . ' ON (' . $db->quoteName('a.linker') . ' = ' . $db->quoteName('h.guid') . ')'); + + // From the getbible_tag table. + $query->select($db->quoteName(['i.name','i.id'],['tag_name','tag_id'])); + $query->join('LEFT', $db->quoteName('#__getbible_tag', 'i') . ' ON (' . $db->quoteName('a.tag') . ' = ' . $db->quoteName('i.guid') . ')'); + + // Filter by published state + $published = $this->getState('filter.published'); + if (is_numeric($published)) + { + $query->where('a.published = ' . (int) $published); + } + elseif ($published === '') + { + $query->where('(a.published = 0 OR a.published = 1)'); + } + + // Join over the asset groups. + $query->select('ag.title AS access_level'); + $query->join('LEFT', '#__viewlevels AS ag ON ag.id = a.access'); + // Implement View Level Access + if (!$user->authorise('core.options', 'com_getbible')) + { + $groups = implode(',', $user->getAuthorisedViewLevels()); + $query->where('a.access IN (' . $groups . ')'); + } + // Filter by search. + $search = $this->getState('filter.search'); + if (!empty($search)) + { + if (stripos($search, 'id:') === 0) + { + $query->where('a.id = ' . (int) substr($search, 3)); + } + else + { + $search = $db->quote('%' . $db->escape($search) . '%'); + $query->where('(a.tag LIKE '.$search.' OR i.name LIKE '.$search.')'); + } + } + + // Filter by Book_nr. + $_book_nr = $this->getState('filter.book_nr'); + if (is_numeric($_book_nr)) + { + if (is_float($_book_nr)) + { + $query->where('a.book_nr = ' . (float) $_book_nr); + } + else + { + $query->where('a.book_nr = ' . (int) $_book_nr); + } + } + elseif (GetbibleHelper::checkString($_book_nr)) + { + $query->where('a.book_nr = ' . $db->quote($db->escape($_book_nr))); + } + elseif (GetbibleHelper::checkArray($_book_nr)) + { + // Secure the array for the query + $_book_nr = array_map( function ($val) use(&$db) { + if (is_numeric($val)) + { + if (is_float($val)) + { + return (float) $val; + } + else + { + return (int) $val; + } + } + elseif (GetbibleHelper::checkString($val)) + { + return $db->quote($db->escape($val)); + } + }, $_book_nr); + // Filter by the Book_nr Array. + $query->where('a.book_nr IN (' . implode(',', $_book_nr) . ')'); + } + // Filter by Abbreviation. + $_abbreviation = $this->getState('filter.abbreviation'); + if (is_numeric($_abbreviation)) + { + if (is_float($_abbreviation)) + { + $query->where('a.abbreviation = ' . (float) $_abbreviation); + } + else + { + $query->where('a.abbreviation = ' . (int) $_abbreviation); + } + } + elseif (GetbibleHelper::checkString($_abbreviation)) + { + $query->where('a.abbreviation = ' . $db->quote($db->escape($_abbreviation))); + } + elseif (GetbibleHelper::checkArray($_abbreviation)) + { + // Secure the array for the query + $_abbreviation = array_map( function ($val) use(&$db) { + if (is_numeric($val)) + { + if (is_float($val)) + { + return (float) $val; + } + else + { + return (int) $val; + } + } + elseif (GetbibleHelper::checkString($val)) + { + return $db->quote($db->escape($val)); + } + }, $_abbreviation); + // Filter by the Abbreviation Array. + $query->where('a.abbreviation IN (' . implode(',', $_abbreviation) . ')'); + } + // Filter by Access. + $_access = $this->getState('filter.access'); + if (is_numeric($_access)) + { + if (is_float($_access)) + { + $query->where('a.access = ' . (float) $_access); + } + else + { + $query->where('a.access = ' . (int) $_access); + } + } + elseif (GetbibleHelper::checkString($_access)) + { + $query->where('a.access = ' . $db->quote($db->escape($_access))); + } + // Filter by Linker. + $_linker = $this->getState('filter.linker'); + if (is_numeric($_linker)) + { + if (is_float($_linker)) + { + $query->where('a.linker = ' . (float) $_linker); + } + else + { + $query->where('a.linker = ' . (int) $_linker); + } + } + elseif (GetbibleHelper::checkString($_linker)) + { + $query->where('a.linker = ' . $db->quote($db->escape($_linker))); + } + // Filter by Tag. + $_tag = $this->getState('filter.tag'); + if (is_numeric($_tag)) + { + if (is_float($_tag)) + { + $query->where('a.tag = ' . (float) $_tag); + } + else + { + $query->where('a.tag = ' . (int) $_tag); + } + } + elseif (GetbibleHelper::checkString($_tag)) + { + $query->where('a.tag = ' . $db->quote($db->escape($_tag))); + } + // Filter by Verse. + $_verse = $this->getState('filter.verse'); + if (is_numeric($_verse)) + { + if (is_float($_verse)) + { + $query->where('a.verse = ' . (float) $_verse); + } + else + { + $query->where('a.verse = ' . (int) $_verse); + } + } + elseif (GetbibleHelper::checkString($_verse)) + { + $query->where('a.verse = ' . $db->quote($db->escape($_verse))); + } + elseif (GetbibleHelper::checkArray($_verse)) + { + // Secure the array for the query + $_verse = array_map( function ($val) use(&$db) { + if (is_numeric($val)) + { + if (is_float($val)) + { + return (float) $val; + } + else + { + return (int) $val; + } + } + elseif (GetbibleHelper::checkString($val)) + { + return $db->quote($db->escape($val)); + } + }, $_verse); + // Filter by the Verse Array. + $query->where('a.verse IN (' . implode(',', $_verse) . ')'); + } + // Filter by Chapter. + $_chapter = $this->getState('filter.chapter'); + if (is_numeric($_chapter)) + { + if (is_float($_chapter)) + { + $query->where('a.chapter = ' . (float) $_chapter); + } + else + { + $query->where('a.chapter = ' . (int) $_chapter); + } + } + elseif (GetbibleHelper::checkString($_chapter)) + { + $query->where('a.chapter = ' . $db->quote($db->escape($_chapter))); + } + elseif (GetbibleHelper::checkArray($_chapter)) + { + // Secure the array for the query + $_chapter = array_map( function ($val) use(&$db) { + if (is_numeric($val)) + { + if (is_float($val)) + { + return (float) $val; + } + else + { + return (int) $val; + } + } + elseif (GetbibleHelper::checkString($val)) + { + return $db->quote($db->escape($val)); + } + }, $_chapter); + // Filter by the Chapter Array. + $query->where('a.chapter IN (' . implode(',', $_chapter) . ')'); + } + + // Add the list ordering clause. + $orderCol = $this->state->get('list.ordering', 'a.id'); + $orderDirn = $this->state->get('list.direction', 'desc'); + if ($orderCol != '') + { + $query->order($db->escape($orderCol . ' ' . $orderDirn)); + } + + return $query; + } + + /** + * Method to get a store id based on model configuration state. + * + * @return string A store id. + * + */ + protected function getStoreId($id = '') + { + // Compile the store id. + $id .= ':' . $this->getState('filter.id'); + $id .= ':' . $this->getState('filter.search'); + $id .= ':' . $this->getState('filter.published'); + $id .= ':' . $this->getState('filter.ordering'); + $id .= ':' . $this->getState('filter.created_by'); + $id .= ':' . $this->getState('filter.modified_by'); + // Check if the value is an array + $_book_nr = $this->getState('filter.book_nr'); + if (GetbibleHelper::checkArray($_book_nr)) + { + $id .= ':' . implode(':', $_book_nr); + } + // Check if this is only an number or string + elseif (is_numeric($_book_nr) + || GetbibleHelper::checkString($_book_nr)) + { + $id .= ':' . $_book_nr; + } + // Check if the value is an array + $_abbreviation = $this->getState('filter.abbreviation'); + if (GetbibleHelper::checkArray($_abbreviation)) + { + $id .= ':' . implode(':', $_abbreviation); + } + // Check if this is only an number or string + elseif (is_numeric($_abbreviation) + || GetbibleHelper::checkString($_abbreviation)) + { + $id .= ':' . $_abbreviation; + } + $id .= ':' . $this->getState('filter.linker'); + $id .= ':' . $this->getState('filter.tag'); + // Check if the value is an array + $_verse = $this->getState('filter.verse'); + if (GetbibleHelper::checkArray($_verse)) + { + $id .= ':' . implode(':', $_verse); + } + // Check if this is only an number or string + elseif (is_numeric($_verse) + || GetbibleHelper::checkString($_verse)) + { + $id .= ':' . $_verse; + } + // Check if the value is an array + $_chapter = $this->getState('filter.chapter'); + if (GetbibleHelper::checkArray($_chapter)) + { + $id .= ':' . implode(':', $_chapter); + } + // Check if this is only an number or string + elseif (is_numeric($_chapter) + || GetbibleHelper::checkString($_chapter)) + { + $id .= ':' . $_chapter; + } + + return parent::getStoreId($id); + } + + /** + * Build an SQL query to checkin all items left checked out longer then a set time. + * + * @return a bool + * + */ + protected function checkInNow() + { + // Get set check in time + $time = JComponentHelper::getParams('com_getbible')->get('check_in'); + + if ($time) + { + + // Get a db connection. + $db = JFactory::getDbo(); + // Reset query. + $query = $db->getQuery(true); + $query->select('*'); + $query->from($db->quoteName('#__getbible_tagged_verse')); + // Only select items that are checked out. + $query->where($db->quoteName('checked_out') . '!=0'); + $db->setQuery($query, 0, 1); + $db->execute(); + if ($db->getNumRows()) + { + // Get Yesterdays date. + $date = JFactory::getDate()->modify($time)->toSql(); + // Reset query. + $query = $db->getQuery(true); + + // Fields to update. + $fields = array( + $db->quoteName('checked_out_time') . '=\'0000-00-00 00:00:00\'', + $db->quoteName('checked_out') . '=0' + ); + + // Conditions for which records should be updated. + $conditions = array( + $db->quoteName('checked_out') . '!=0', + $db->quoteName('checked_out_time') . '<\''.$date.'\'' + ); + + // Check table. + $query->update($db->quoteName('#__getbible_tagged_verse'))->set($fields)->where($conditions); + + $db->setQuery($query); + + $db->execute(); + } + } + + return false; + } +} diff --git a/admin/models/tags.php b/admin/models/tags.php new file mode 100644 index 0000000..c607b79 --- /dev/null +++ b/admin/models/tags.php @@ -0,0 +1,363 @@ + + @git Get Bible + @github Get Bible + @support Get Bible + @copyright Copyright (C) 2015. All Rights Reserved + @license GNU/GPL Version 2 or later - http://www.gnu.org/licenses/gpl-2.0.html + +/------------------------------------------------------------------------------------------------------*/ + +// No direct access to this file +defined('_JEXEC') or die('Restricted access'); + +use Joomla\CMS\MVC\Model\ListModel; +use Joomla\Utilities\ArrayHelper; + +/** + * Tags List Model + */ +class GetbibleModelTags extends ListModel +{ + public function __construct($config = array()) + { + if (empty($config['filter_fields'])) + { + $config['filter_fields'] = array( + 'a.id','id', + 'a.published','published', + 'a.access','access', + 'a.ordering','ordering', + 'a.created_by','created_by', + 'a.modified_by','modified_by', + 'g.name','linker', + 'a.name','name' + ); + } + + parent::__construct($config); + } + + /** + * Method to auto-populate the model state. + * + * Note. Calling getState in this method will result in recursion. + * + * @param string $ordering An optional ordering field. + * @param string $direction An optional direction (asc|desc). + * + * @return void + * + */ + protected function populateState($ordering = null, $direction = null) + { + $app = JFactory::getApplication(); + + // Adjust the context to support modal layouts. + if ($layout = $app->input->get('layout')) + { + $this->context .= '.' . $layout; + } + + // Check if the form was submitted + $formSubmited = $app->input->post->get('form_submited'); + + $published = $this->getUserStateFromRequest($this->context . '.filter.published', 'filter_published', ''); + $this->setState('filter.published', $published); + + $created_by = $this->getUserStateFromRequest($this->context . '.filter.created_by', 'filter_created_by', ''); + $this->setState('filter.created_by', $created_by); + + $created = $this->getUserStateFromRequest($this->context . '.filter.created', 'filter_created'); + $this->setState('filter.created', $created); + + $sorting = $this->getUserStateFromRequest($this->context . '.filter.sorting', 'filter_sorting', 0, 'int'); + $this->setState('filter.sorting', $sorting); + + $search = $this->getUserStateFromRequest($this->context . '.filter.search', 'filter_search'); + $this->setState('filter.search', $search); + + $linker = $this->getUserStateFromRequest($this->context . '.filter.linker', 'filter_linker'); + if ($formSubmited) + { + $linker = $app->input->post->get('linker'); + $this->setState('filter.linker', $linker); + } + + $access = $this->getUserStateFromRequest($this->context . '.filter.access', 'filter_access'); + if ($formSubmited) + { + $access = $app->input->post->get('access'); + $this->setState('filter.access', $access); + } + + $name = $this->getUserStateFromRequest($this->context . '.filter.name', 'filter_name'); + if ($formSubmited) + { + $name = $app->input->post->get('name'); + $this->setState('filter.name', $name); + } + + // List state information. + parent::populateState($ordering, $direction); + } + + /** + * Method to get an array of data items. + * + * @return mixed An array of data items on success, false on failure. + */ + public function getItems() + { + // Check in items + $this->checkInNow(); + + // load parent items + $items = parent::getItems(); + + // Set values to display correctly. + if (GetbibleHelper::checkArray($items)) + { + // Get the user object if not set. + if (!isset($user) || !GetbibleHelper::checkObject($user)) + { + $user = JFactory::getUser(); + } + foreach ($items as $nr => &$item) + { + // Remove items the user can't access. + $access = ($user->authorise('tag.access', 'com_getbible.tag.' . (int) $item->id) && $user->authorise('tag.access', 'com_getbible')); + if (!$access) + { + unset($items[$nr]); + continue; + } + + } + } + + // set selection value to a translatable value + if (GetbibleHelper::checkArray($items)) + { + foreach ($items as $nr => &$item) + { + // convert access + $item->access = $this->selectionTranslation($item->access, 'access'); + } + } + + + // return items + return $items; + } + + /** + * Method to convert selection values to translatable string. + * + * @return translatable string + */ + public function selectionTranslation($value,$name) + { + // Array of access language strings + if ($name === 'access') + { + $accessArray = array( + 1 => 'COM_GETBIBLE_TAG_PUBLIC', + 0 => 'COM_GETBIBLE_TAG_PRIVATE' + ); + // Now check if value is found in this array + if (isset($accessArray[$value]) && GetbibleHelper::checkString($accessArray[$value])) + { + return $accessArray[$value]; + } + } + return $value; + } + + /** + * Method to build an SQL query to load the list data. + * + * @return string An SQL query + */ + protected function getListQuery() + { + // Get the user object. + $user = JFactory::getUser(); + // Create a new query object. + $db = JFactory::getDBO(); + $query = $db->getQuery(true); + + // Select some fields + $query->select('a.*'); + + // From the getbible_item table + $query->from($db->quoteName('#__getbible_tag', 'a')); + + // From the getbible_linker table. + $query->select($db->quoteName(['g.name','g.id'],['linker_name','linker_id'])); + $query->join('LEFT', $db->quoteName('#__getbible_linker', 'g') . ' ON (' . $db->quoteName('a.linker') . ' = ' . $db->quoteName('g.guid') . ')'); + + // Filter by published state + $published = $this->getState('filter.published'); + if (is_numeric($published)) + { + $query->where('a.published = ' . (int) $published); + } + elseif ($published === '') + { + $query->where('(a.published = 0 OR a.published = 1)'); + } + + // Join over the asset groups. + $query->select('ag.title AS access_level'); + $query->join('LEFT', '#__viewlevels AS ag ON ag.id = a.access'); + // Implement View Level Access + if (!$user->authorise('core.options', 'com_getbible')) + { + $groups = implode(',', $user->getAuthorisedViewLevels()); + $query->where('a.access IN (' . $groups . ')'); + } + // Filter by search. + $search = $this->getState('filter.search'); + if (!empty($search)) + { + if (stripos($search, 'id:') === 0) + { + $query->where('a.id = ' . (int) substr($search, 3)); + } + else + { + $search = $db->quote('%' . $db->escape($search) . '%'); + $query->where('(a.name LIKE '.$search.' OR a.linker LIKE '.$search.' OR g.name LIKE '.$search.' OR a.description LIKE '.$search.')'); + } + } + + // Filter by Linker. + $_linker = $this->getState('filter.linker'); + if (is_numeric($_linker)) + { + if (is_float($_linker)) + { + $query->where('a.linker = ' . (float) $_linker); + } + else + { + $query->where('a.linker = ' . (int) $_linker); + } + } + elseif (GetbibleHelper::checkString($_linker)) + { + $query->where('a.linker = ' . $db->quote($db->escape($_linker))); + } + // Filter by Access. + $_access = $this->getState('filter.access'); + if (is_numeric($_access)) + { + if (is_float($_access)) + { + $query->where('a.access = ' . (float) $_access); + } + else + { + $query->where('a.access = ' . (int) $_access); + } + } + elseif (GetbibleHelper::checkString($_access)) + { + $query->where('a.access = ' . $db->quote($db->escape($_access))); + } + + // Add the list ordering clause. + $orderCol = $this->state->get('list.ordering', 'a.id'); + $orderDirn = $this->state->get('list.direction', 'desc'); + if ($orderCol != '') + { + $query->order($db->escape($orderCol . ' ' . $orderDirn)); + } + + return $query; + } + + /** + * Method to get a store id based on model configuration state. + * + * @return string A store id. + * + */ + protected function getStoreId($id = '') + { + // Compile the store id. + $id .= ':' . $this->getState('filter.id'); + $id .= ':' . $this->getState('filter.search'); + $id .= ':' . $this->getState('filter.published'); + $id .= ':' . $this->getState('filter.ordering'); + $id .= ':' . $this->getState('filter.created_by'); + $id .= ':' . $this->getState('filter.modified_by'); + $id .= ':' . $this->getState('filter.linker'); + $id .= ':' . $this->getState('filter.name'); + + return parent::getStoreId($id); + } + + /** + * Build an SQL query to checkin all items left checked out longer then a set time. + * + * @return a bool + * + */ + protected function checkInNow() + { + // Get set check in time + $time = JComponentHelper::getParams('com_getbible')->get('check_in'); + + if ($time) + { + + // Get a db connection. + $db = JFactory::getDbo(); + // Reset query. + $query = $db->getQuery(true); + $query->select('*'); + $query->from($db->quoteName('#__getbible_tag')); + // Only select items that are checked out. + $query->where($db->quoteName('checked_out') . '!=0'); + $db->setQuery($query, 0, 1); + $db->execute(); + if ($db->getNumRows()) + { + // Get Yesterdays date. + $date = JFactory::getDate()->modify($time)->toSql(); + // Reset query. + $query = $db->getQuery(true); + + // Fields to update. + $fields = array( + $db->quoteName('checked_out_time') . '=\'0000-00-00 00:00:00\'', + $db->quoteName('checked_out') . '=0' + ); + + // Conditions for which records should be updated. + $conditions = array( + $db->quoteName('checked_out') . '!=0', + $db->quoteName('checked_out_time') . '<\''.$date.'\'' + ); + + // Check table. + $query->update($db->quoteName('#__getbible_tag'))->set($fields)->where($conditions); + + $db->setQuery($query); + + $db->execute(); + } + } + + return false; + } +} diff --git a/admin/models/translation.php b/admin/models/translation.php new file mode 100644 index 0000000..b2ebca9 --- /dev/null +++ b/admin/models/translation.php @@ -0,0 +1,1214 @@ + + @git Get Bible + @github Get Bible + @support Get Bible + @copyright Copyright (C) 2015. All Rights Reserved + @license GNU/GPL Version 2 or later - http://www.gnu.org/licenses/gpl-2.0.html + +/------------------------------------------------------------------------------------------------------*/ + +// No direct access to this file +defined('_JEXEC') or die('Restricted access'); + +use Joomla\CMS\MVC\Model\AdminModel; +use Joomla\Registry\Registry; +use Joomla\String\StringHelper; +use Joomla\Utilities\ArrayHelper; + +/** + * Getbible Translation Admin Model + */ +class GetbibleModelTranslation extends AdminModel +{ + /** + * The tab layout fields array. + * + * @var array + */ + protected $tabLayoutFields = array( + 'details' => array( + 'left' => array( + 'distribution_abbreviation', + 'distribution_versification', + 'distribution_version', + 'distribution_version_date', + 'distribution_lcsh', + 'encoding', + 'sha' + ), + 'right' => array( + 'language', + 'lang', + 'distribution_sourcetype', + 'distribution_source', + 'distribution_license' + ), + 'fullwidth' => array( + 'distribution_about', + 'distribution_history' + ), + 'above' => array( + 'translation', + 'abbreviation', + 'direction' + ) + ) + ); + + /** + * @var string The prefix to use with controller messages. + * @since 1.6 + */ + protected $text_prefix = 'COM_GETBIBLE'; + + /** + * The type alias for this content type. + * + * @var string + * @since 3.2 + */ + public $typeAlias = 'com_getbible.translation'; + + /** + * Returns a Table object, always creating it + * + * @param type $type The table type to instantiate + * @param string $prefix A prefix for the table class name. Optional. + * @param array $config Configuration array for model. Optional. + * + * @return JTable A database object + * + * @since 1.6 + */ + public function getTable($type = 'translation', $prefix = 'GetbibleTable', $config = array()) + { + // add table path for when model gets used from other component + $this->addTablePath(JPATH_ADMINISTRATOR . '/components/com_getbible/tables'); + // get instance of the table + return JTable::getInstance($type, $prefix, $config); + }###ADMIN_CUSTOM_BUTTONS_METHOD### + + /** + * Method to get a single record. + * + * @param integer $pk The id of the primary key. + * + * @return mixed Object on success, false on failure. + * + * @since 1.6 + */ + public function getItem($pk = null) + { + if ($item = parent::getItem($pk)) + { + if (!empty($item->params) && !is_array($item->params)) + { + // Convert the params field to an array. + $registry = new Registry; + $registry->loadString($item->params); + $item->params = $registry->toArray(); + } + + if (!empty($item->metadata)) + { + // Convert the metadata field to an array. + $registry = new Registry; + $registry->loadString($item->metadata); + $item->metadata = $registry->toArray(); + } + + if (!empty($item->distribution_history)) + { + // Convert the distribution_history field to an array. + $distribution_history = new Registry; + $distribution_history->loadString($item->distribution_history); + $item->distribution_history = $distribution_history->toArray(); + } + } + + return $item; + } + + /** + * Method to get the record form. + * + * @param array $data Data for the form. + * @param boolean $loadData True if the form is to load its own data (default case), false if not. + * @param array $options Optional array of options for the form creation. + * + * @return mixed A JForm object on success, false on failure + * + * @since 1.6 + */ + public function getForm($data = array(), $loadData = true, $options = array('control' => 'jform')) + { + // set load data option + $options['load_data'] = $loadData; + // check if xpath was set in options + $xpath = false; + if (isset($options['xpath'])) + { + $xpath = $options['xpath']; + unset($options['xpath']); + } + // check if clear form was set in options + $clear = false; + if (isset($options['clear'])) + { + $clear = $options['clear']; + unset($options['clear']); + } + + // Get the form. + $form = $this->loadForm('com_getbible.translation', 'translation', $options, $clear, $xpath); + + if (empty($form)) + { + return false; + } + + $jinput = JFactory::getApplication()->input; + + // The front end calls this model and uses a_id to avoid id clashes so we need to check for that first. + if ($jinput->get('a_id')) + { + $id = $jinput->get('a_id', 0, 'INT'); + } + // The back end uses id so we use that the rest of the time and set it to 0 by default. + else + { + $id = $jinput->get('id', 0, 'INT'); + } + + $user = JFactory::getUser(); + + // Check for existing item. + // Modify the form based on Edit State access controls. + if ($id != 0 && (!$user->authorise('translation.edit.state', 'com_getbible.translation.' . (int) $id)) + || ($id == 0 && !$user->authorise('translation.edit.state', 'com_getbible'))) + { + // Disable fields for display. + $form->setFieldAttribute('ordering', 'disabled', 'true'); + $form->setFieldAttribute('published', 'disabled', 'true'); + // Disable fields while saving. + $form->setFieldAttribute('ordering', 'filter', 'unset'); + $form->setFieldAttribute('published', 'filter', 'unset'); + } + // If this is a new item insure the greated by is set. + if (0 == $id) + { + // Set the created_by to this user + $form->setValue('created_by', null, $user->id); + } + // Modify the form based on Edit Creaded By access controls. + if ($id != 0 && (!$user->authorise('translation.edit.created_by', 'com_getbible.translation.' . (int) $id)) + || ($id == 0 && !$user->authorise('translation.edit.created_by', 'com_getbible'))) + { + // Disable fields for display. + $form->setFieldAttribute('created_by', 'disabled', 'true'); + // Disable fields for display. + $form->setFieldAttribute('created_by', 'readonly', 'true'); + // Disable fields while saving. + $form->setFieldAttribute('created_by', 'filter', 'unset'); + } + // Modify the form based on Edit Creaded Date access controls. + if ($id != 0 && (!$user->authorise('translation.edit.created', 'com_getbible.translation.' . (int) $id)) + || ($id == 0 && !$user->authorise('translation.edit.created', 'com_getbible'))) + { + // Disable fields for display. + $form->setFieldAttribute('created', 'disabled', 'true'); + // Disable fields while saving. + $form->setFieldAttribute('created', 'filter', 'unset'); + } + // Modify the form based on Edit Translation access controls. + if ($id != 0 && (!$user->authorise('translation.edit.translation', 'com_getbible.translation.' . (int) $id)) + || ($id == 0 && !$user->authorise('translation.edit.translation', 'com_getbible'))) + { + // Disable fields for display. + $form->setFieldAttribute('translation', 'disabled', 'true'); + // Disable fields for display. + $form->setFieldAttribute('translation', 'readonly', 'true'); + // If there is no value continue. + if (!$form->getValue('translation')) + { + // Disable fields while saving. + $form->setFieldAttribute('translation', 'filter', 'unset'); + // Disable fields while saving. + $form->setFieldAttribute('translation', 'required', 'false'); + } + } + // Modify the form based on Edit Abbreviation access controls. + if ($id != 0 && (!$user->authorise('translation.edit.abbreviation', 'com_getbible.translation.' . (int) $id)) + || ($id == 0 && !$user->authorise('translation.edit.abbreviation', 'com_getbible'))) + { + // Disable fields for display. + $form->setFieldAttribute('abbreviation', 'disabled', 'true'); + // Disable fields for display. + $form->setFieldAttribute('abbreviation', 'readonly', 'true'); + // If there is no value continue. + if (!$form->getValue('abbreviation')) + { + // Disable fields while saving. + $form->setFieldAttribute('abbreviation', 'filter', 'unset'); + // Disable fields while saving. + $form->setFieldAttribute('abbreviation', 'required', 'false'); + } + } + // Modify the form based on Edit Language access controls. + if ($id != 0 && (!$user->authorise('translation.edit.language', 'com_getbible.translation.' . (int) $id)) + || ($id == 0 && !$user->authorise('translation.edit.language', 'com_getbible'))) + { + // Disable fields for display. + $form->setFieldAttribute('language', 'disabled', 'true'); + // Disable fields for display. + $form->setFieldAttribute('language', 'readonly', 'true'); + // If there is no value continue. + if (!$form->getValue('language')) + { + // Disable fields while saving. + $form->setFieldAttribute('language', 'filter', 'unset'); + // Disable fields while saving. + $form->setFieldAttribute('language', 'required', 'false'); + } + } + // Modify the form based on Edit Direction access controls. + if ($id != 0 && (!$user->authorise('translation.edit.direction', 'com_getbible.translation.' . (int) $id)) + || ($id == 0 && !$user->authorise('translation.edit.direction', 'com_getbible'))) + { + // Disable fields for display. + $form->setFieldAttribute('direction', 'disabled', 'true'); + // Disable fields for display. + $form->setFieldAttribute('direction', 'readonly', 'true'); + // Disable radio button for display. + $class = $form->getFieldAttribute('direction', 'class', ''); + $form->setFieldAttribute('direction', 'class', $class.' disabled no-click'); + // If there is no value continue. + if (!$form->getValue('direction')) + { + // Disable fields while saving. + $form->setFieldAttribute('direction', 'filter', 'unset'); + // Disable fields while saving. + $form->setFieldAttribute('direction', 'required', 'false'); + } + } + // Modify the form based on Edit Distribution History access controls. + if ($id != 0 && (!$user->authorise('translation.edit.distribution_history', 'com_getbible.translation.' . (int) $id)) + || ($id == 0 && !$user->authorise('translation.edit.distribution_history', 'com_getbible'))) + { + // Disable fields for display. + $form->setFieldAttribute('distribution_history', 'disabled', 'true'); + // Disable fields for display. + $form->setFieldAttribute('distribution_history', 'readonly', 'true'); + // If there is no value continue. + if (!$form->getValue('distribution_history')) + { + // Disable fields while saving. + $form->setFieldAttribute('distribution_history', 'filter', 'unset'); + // Disable fields while saving. + $form->setFieldAttribute('distribution_history', 'required', 'false'); + } + } + // Modify the form based on Edit Distribution About access controls. + if ($id != 0 && (!$user->authorise('translation.edit.distribution_about', 'com_getbible.translation.' . (int) $id)) + || ($id == 0 && !$user->authorise('translation.edit.distribution_about', 'com_getbible'))) + { + // Disable fields for display. + $form->setFieldAttribute('distribution_about', 'disabled', 'true'); + // Disable fields for display. + $form->setFieldAttribute('distribution_about', 'readonly', 'true'); + // If there is no value continue. + if (!$form->getValue('distribution_about')) + { + // Disable fields while saving. + $form->setFieldAttribute('distribution_about', 'filter', 'unset'); + // Disable fields while saving. + $form->setFieldAttribute('distribution_about', 'required', 'false'); + } + } + // Modify the form based on Edit Distribution License access controls. + if ($id != 0 && (!$user->authorise('translation.edit.distribution_license', 'com_getbible.translation.' . (int) $id)) + || ($id == 0 && !$user->authorise('translation.edit.distribution_license', 'com_getbible'))) + { + // Disable fields for display. + $form->setFieldAttribute('distribution_license', 'disabled', 'true'); + // Disable fields for display. + $form->setFieldAttribute('distribution_license', 'readonly', 'true'); + // If there is no value continue. + if (!$form->getValue('distribution_license')) + { + // Disable fields while saving. + $form->setFieldAttribute('distribution_license', 'filter', 'unset'); + // Disable fields while saving. + $form->setFieldAttribute('distribution_license', 'required', 'false'); + } + } + // Modify the form based on Edit Distribution Source access controls. + if ($id != 0 && (!$user->authorise('translation.edit.distribution_source', 'com_getbible.translation.' . (int) $id)) + || ($id == 0 && !$user->authorise('translation.edit.distribution_source', 'com_getbible'))) + { + // Disable fields for display. + $form->setFieldAttribute('distribution_source', 'disabled', 'true'); + // Disable fields for display. + $form->setFieldAttribute('distribution_source', 'readonly', 'true'); + // If there is no value continue. + if (!$form->getValue('distribution_source')) + { + // Disable fields while saving. + $form->setFieldAttribute('distribution_source', 'filter', 'unset'); + // Disable fields while saving. + $form->setFieldAttribute('distribution_source', 'required', 'false'); + } + } + // Modify the form based on Edit Distribution Sourcetype access controls. + if ($id != 0 && (!$user->authorise('translation.edit.distribution_sourcetype', 'com_getbible.translation.' . (int) $id)) + || ($id == 0 && !$user->authorise('translation.edit.distribution_sourcetype', 'com_getbible'))) + { + // Disable fields for display. + $form->setFieldAttribute('distribution_sourcetype', 'disabled', 'true'); + // Disable fields for display. + $form->setFieldAttribute('distribution_sourcetype', 'readonly', 'true'); + // If there is no value continue. + if (!$form->getValue('distribution_sourcetype')) + { + // Disable fields while saving. + $form->setFieldAttribute('distribution_sourcetype', 'filter', 'unset'); + // Disable fields while saving. + $form->setFieldAttribute('distribution_sourcetype', 'required', 'false'); + } + } + // Modify the form based on Edit Distribution Versification access controls. + if ($id != 0 && (!$user->authorise('translation.edit.distribution_versification', 'com_getbible.translation.' . (int) $id)) + || ($id == 0 && !$user->authorise('translation.edit.distribution_versification', 'com_getbible'))) + { + // Disable fields for display. + $form->setFieldAttribute('distribution_versification', 'disabled', 'true'); + // Disable fields for display. + $form->setFieldAttribute('distribution_versification', 'readonly', 'true'); + // If there is no value continue. + if (!$form->getValue('distribution_versification')) + { + // Disable fields while saving. + $form->setFieldAttribute('distribution_versification', 'filter', 'unset'); + // Disable fields while saving. + $form->setFieldAttribute('distribution_versification', 'required', 'false'); + } + } + // Modify the form based on Edit Sha access controls. + if ($id != 0 && (!$user->authorise('translation.edit.sha', 'com_getbible.translation.' . (int) $id)) + || ($id == 0 && !$user->authorise('translation.edit.sha', 'com_getbible'))) + { + // Disable fields for display. + $form->setFieldAttribute('sha', 'disabled', 'true'); + // Disable fields for display. + $form->setFieldAttribute('sha', 'readonly', 'true'); + // If there is no value continue. + if (!$form->getValue('sha')) + { + // Disable fields while saving. + $form->setFieldAttribute('sha', 'filter', 'unset'); + // Disable fields while saving. + $form->setFieldAttribute('sha', 'required', 'false'); + } + } + // Modify the form based on Edit Encoding access controls. + if ($id != 0 && (!$user->authorise('translation.edit.encoding', 'com_getbible.translation.' . (int) $id)) + || ($id == 0 && !$user->authorise('translation.edit.encoding', 'com_getbible'))) + { + // Disable fields for display. + $form->setFieldAttribute('encoding', 'disabled', 'true'); + // Disable fields for display. + $form->setFieldAttribute('encoding', 'readonly', 'true'); + // If there is no value continue. + if (!$form->getValue('encoding')) + { + // Disable fields while saving. + $form->setFieldAttribute('encoding', 'filter', 'unset'); + // Disable fields while saving. + $form->setFieldAttribute('encoding', 'required', 'false'); + } + } + // Modify the form based on Edit Distribution Lcsh access controls. + if ($id != 0 && (!$user->authorise('translation.edit.distribution_lcsh', 'com_getbible.translation.' . (int) $id)) + || ($id == 0 && !$user->authorise('translation.edit.distribution_lcsh', 'com_getbible'))) + { + // Disable fields for display. + $form->setFieldAttribute('distribution_lcsh', 'disabled', 'true'); + // Disable fields for display. + $form->setFieldAttribute('distribution_lcsh', 'readonly', 'true'); + // If there is no value continue. + if (!$form->getValue('distribution_lcsh')) + { + // Disable fields while saving. + $form->setFieldAttribute('distribution_lcsh', 'filter', 'unset'); + // Disable fields while saving. + $form->setFieldAttribute('distribution_lcsh', 'required', 'false'); + } + } + // Modify the form based on Edit Distribution Version Date access controls. + if ($id != 0 && (!$user->authorise('translation.edit.distribution_version_date', 'com_getbible.translation.' . (int) $id)) + || ($id == 0 && !$user->authorise('translation.edit.distribution_version_date', 'com_getbible'))) + { + // Disable fields for display. + $form->setFieldAttribute('distribution_version_date', 'disabled', 'true'); + // Disable fields for display. + $form->setFieldAttribute('distribution_version_date', 'readonly', 'true'); + // If there is no value continue. + if (!$form->getValue('distribution_version_date')) + { + // Disable fields while saving. + $form->setFieldAttribute('distribution_version_date', 'filter', 'unset'); + // Disable fields while saving. + $form->setFieldAttribute('distribution_version_date', 'required', 'false'); + } + } + // Modify the form based on Edit Distribution Version access controls. + if ($id != 0 && (!$user->authorise('translation.edit.distribution_version', 'com_getbible.translation.' . (int) $id)) + || ($id == 0 && !$user->authorise('translation.edit.distribution_version', 'com_getbible'))) + { + // Disable fields for display. + $form->setFieldAttribute('distribution_version', 'disabled', 'true'); + // Disable fields for display. + $form->setFieldAttribute('distribution_version', 'readonly', 'true'); + // If there is no value continue. + if (!$form->getValue('distribution_version')) + { + // Disable fields while saving. + $form->setFieldAttribute('distribution_version', 'filter', 'unset'); + // Disable fields while saving. + $form->setFieldAttribute('distribution_version', 'required', 'false'); + } + } + // Modify the form based on Edit Lang access controls. + if ($id != 0 && (!$user->authorise('translation.edit.lang', 'com_getbible.translation.' . (int) $id)) + || ($id == 0 && !$user->authorise('translation.edit.lang', 'com_getbible'))) + { + // Disable fields for display. + $form->setFieldAttribute('lang', 'disabled', 'true'); + // Disable fields for display. + $form->setFieldAttribute('lang', 'readonly', 'true'); + // If there is no value continue. + if (!$form->getValue('lang')) + { + // Disable fields while saving. + $form->setFieldAttribute('lang', 'filter', 'unset'); + // Disable fields while saving. + $form->setFieldAttribute('lang', 'required', 'false'); + } + } + // Modify the form based on Edit Distribution Abbreviation access controls. + if ($id != 0 && (!$user->authorise('translation.edit.distribution_abbreviation', 'com_getbible.translation.' . (int) $id)) + || ($id == 0 && !$user->authorise('translation.edit.distribution_abbreviation', 'com_getbible'))) + { + // Disable fields for display. + $form->setFieldAttribute('distribution_abbreviation', 'disabled', 'true'); + // Disable fields for display. + $form->setFieldAttribute('distribution_abbreviation', 'readonly', 'true'); + // If there is no value continue. + if (!$form->getValue('distribution_abbreviation')) + { + // Disable fields while saving. + $form->setFieldAttribute('distribution_abbreviation', 'filter', 'unset'); + // Disable fields while saving. + $form->setFieldAttribute('distribution_abbreviation', 'required', 'false'); + } + } + // Only load these values if no id is found + if (0 == $id) + { + // Set redirected view name + $redirectedView = $jinput->get('ref', null, 'STRING'); + // Set field name (or fall back to view name) + $redirectedField = $jinput->get('field', $redirectedView, 'STRING'); + // Set redirected view id + $redirectedId = $jinput->get('refid', 0, 'INT'); + // Set field id (or fall back to redirected view id) + $redirectedValue = $jinput->get('field_id', $redirectedId, 'INT'); + if (0 != $redirectedValue && $redirectedField) + { + // Now set the local-redirected field default value + $form->setValue($redirectedField, null, $redirectedValue); + } + } + return $form; + } + + /** + * Method to get the script that have to be included on the form + * + * @return string script files + */ + public function getScript() + { + return 'media/com_getbible/js/translation.js'; + } + + /** + * Method to test whether a record can be deleted. + * + * @param object $record A record object. + * + * @return boolean True if allowed to delete the record. Defaults to the permission set in the component. + * + * @since 1.6 + */ + protected function canDelete($record) + { + if (!empty($record->id)) + { + if ($record->published != -2) + { + return; + } + + $user = JFactory::getUser(); + // The record has been set. Check the record permissions. + return $user->authorise('translation.delete', 'com_getbible.translation.' . (int) $record->id); + } + return false; + } + + /** + * Method to test whether a record can have its state edited. + * + * @param object $record A record object. + * + * @return boolean True if allowed to change the state of the record. Defaults to the permission set in the component. + * + * @since 1.6 + */ + protected function canEditState($record) + { + $user = JFactory::getUser(); + $recordId = (!empty($record->id)) ? $record->id : 0; + + if ($recordId) + { + // The record has been set. Check the record permissions. + $permission = $user->authorise('translation.edit.state', 'com_getbible.translation.' . (int) $recordId); + if (!$permission && !is_null($permission)) + { + return false; + } + } + // In the absense of better information, revert to the component permissions. + return $user->authorise('translation.edit.state', 'com_getbible'); + } + + /** + * Method override to check if you can edit an existing record. + * + * @param array $data An array of input data. + * @param string $key The name of the key for the primary key. + * + * @return boolean + * @since 2.5 + */ + protected function allowEdit($data = array(), $key = 'id') + { + // Check specific edit permission then general edit permission. + $user = JFactory::getUser(); + + return $user->authorise('translation.edit', 'com_getbible.translation.'. ((int) isset($data[$key]) ? $data[$key] : 0)) or $user->authorise('translation.edit', 'com_getbible'); + } + + /** + * Prepare and sanitise the table data prior to saving. + * + * @param JTable $table A JTable object. + * + * @return void + * + * @since 1.6 + */ + protected function prepareTable($table) + { + $date = JFactory::getDate(); + $user = JFactory::getUser(); + + if (isset($table->name)) + { + $table->name = htmlspecialchars_decode($table->name, ENT_QUOTES); + } + + if (isset($table->alias) && empty($table->alias)) + { + $table->generateAlias(); + } + + if (empty($table->id)) + { + $table->created = $date->toSql(); + // set the user + if ($table->created_by == 0 || empty($table->created_by)) + { + $table->created_by = $user->id; + } + // Set ordering to the last item if not set + if (empty($table->ordering)) + { + $db = JFactory::getDbo(); + $query = $db->getQuery(true) + ->select('MAX(ordering)') + ->from($db->quoteName('#__getbible_translation')); + $db->setQuery($query); + $max = $db->loadResult(); + + $table->ordering = $max + 1; + } + } + else + { + $table->modified = $date->toSql(); + $table->modified_by = $user->id; + } + + if (!empty($table->id)) + { + // Increment the items version number. + $table->version++; + } + } + + /** + * Method to get the data that should be injected in the form. + * + * @return mixed The data for the form. + * + * @since 1.6 + */ + protected function loadFormData() + { + // Check the session for previously entered form data. + $data = JFactory::getApplication()->getUserState('com_getbible.edit.translation.data', array()); + + if (empty($data)) + { + $data = $this->getItem(); + // run the perprocess of the data + $this->preprocessData('com_getbible.translation', $data); + } + + return $data; + } + + /** + * Method to get the unique fields of this table. + * + * @return mixed An array of field names, boolean false if none is set. + * + * @since 3.0 + */ + protected function getUniqueFields() + { + return false; + } + + /** + * Method to delete one or more records. + * + * @param array &$pks An array of record primary keys. + * + * @return boolean True if successful, false if an error occurs. + * + * @since 12.2 + */ + public function delete(&$pks) + { + if (!parent::delete($pks)) + { + return false; + } + + return true; + } + + /** + * Method to change the published state of one or more records. + * + * @param array &$pks A list of the primary keys to change. + * @param integer $value The value of the published state. + * + * @return boolean True on success. + * + * @since 12.2 + */ + public function publish(&$pks, $value = 1) + { + if (!parent::publish($pks, $value)) + { + return false; + } + + return true; + } + + /** + * Method to perform batch operations on an item or a set of items. + * + * @param array $commands An array of commands to perform. + * @param array $pks An array of item ids. + * @param array $contexts An array of item contexts. + * + * @return boolean Returns true on success, false on failure. + * + * @since 12.2 + */ + public function batch($commands, $pks, $contexts) + { + // Sanitize ids. + $pks = array_unique($pks); + ArrayHelper::toInteger($pks); + + // Remove any values of zero. + if (array_search(0, $pks, true)) + { + unset($pks[array_search(0, $pks, true)]); + } + + if (empty($pks)) + { + $this->setError(JText::_('JGLOBAL_NO_ITEM_SELECTED')); + return false; + } + + $done = false; + + // Set some needed variables. + $this->user = JFactory::getUser(); + $this->table = $this->getTable(); + $this->tableClassName = get_class($this->table); + $this->contentType = new JUcmType; + $this->type = $this->contentType->getTypeByTable($this->tableClassName); + $this->canDo = GetbibleHelper::getActions('translation'); + $this->batchSet = true; + + if (!$this->canDo->get('core.batch')) + { + $this->setError(JText::_('JLIB_APPLICATION_ERROR_INSUFFICIENT_BATCH_INFORMATION')); + return false; + } + + if ($this->type == false) + { + $type = new JUcmType; + $this->type = $type->getTypeByAlias($this->typeAlias); + } + + $this->tagsObserver = $this->table->getObserverOfClass('JTableObserverTags'); + + if (!empty($commands['move_copy'])) + { + $cmd = ArrayHelper::getValue($commands, 'move_copy', 'c'); + + if ($cmd == 'c') + { + $result = $this->batchCopy($commands, $pks, $contexts); + + if (is_array($result)) + { + foreach ($result as $old => $new) + { + $contexts[$new] = $contexts[$old]; + } + $pks = array_values($result); + } + else + { + return false; + } + } + elseif ($cmd == 'm' && !$this->batchMove($commands, $pks, $contexts)) + { + return false; + } + + $done = true; + } + + if (!$done) + { + $this->setError(JText::_('JLIB_APPLICATION_ERROR_INSUFFICIENT_BATCH_INFORMATION')); + + return false; + } + + // Clear the cache + $this->cleanCache(); + + return true; + } + + /** + * Batch copy items to a new category or current. + * + * @param integer $values The new values. + * @param array $pks An array of row IDs. + * @param array $contexts An array of item contexts. + * + * @return mixed An array of new IDs on success, boolean false on failure. + * + * @since 12.2 + */ + protected function batchCopy($values, $pks, $contexts) + { + if (empty($this->batchSet)) + { + // Set some needed variables. + $this->user = JFactory::getUser(); + $this->table = $this->getTable(); + $this->tableClassName = get_class($this->table); + $this->canDo = GetbibleHelper::getActions('translation'); + } + + if (!$this->canDo->get('translation.create') && !$this->canDo->get('translation.batch')) + { + return false; + } + + // get list of unique fields + $uniqueFields = $this->getUniqueFields(); + // remove move_copy from array + unset($values['move_copy']); + + // make sure published is set + if (!isset($values['published'])) + { + $values['published'] = 0; + } + elseif (isset($values['published']) && !$this->canDo->get('translation.edit.state')) + { + $values['published'] = 0; + } + + $newIds = array(); + // Parent exists so let's proceed + while (!empty($pks)) + { + // Pop the first ID off the stack + $pk = array_shift($pks); + + $this->table->reset(); + + // only allow copy if user may edit this item. + if (!$this->user->authorise('translation.edit', $contexts[$pk])) + { + // Not fatal error + $this->setError(JText::sprintf('JLIB_APPLICATION_ERROR_BATCH_MOVE_ROW_NOT_FOUND', $pk)); + continue; + } + + // Check that the row actually exists + if (!$this->table->load($pk)) + { + if ($error = $this->table->getError()) + { + // Fatal error + $this->setError($error); + return false; + } + else + { + // Not fatal error + $this->setError(JText::sprintf('JLIB_APPLICATION_ERROR_BATCH_MOVE_ROW_NOT_FOUND', $pk)); + continue; + } + } + + // Only for strings + if (GetbibleHelper::checkString($this->table->translation) && !is_numeric($this->table->translation)) + { + $this->table->translation = $this->generateUnique('translation',$this->table->translation); + } + + // insert all set values + if (GetbibleHelper::checkArray($values)) + { + foreach ($values as $key => $value) + { + if (strlen($value) > 0 && isset($this->table->$key)) + { + $this->table->$key = $value; + } + } + } + + // update all unique fields + if (GetbibleHelper::checkArray($uniqueFields)) + { + foreach ($uniqueFields as $uniqueField) + { + $this->table->$uniqueField = $this->generateUnique($uniqueField,$this->table->$uniqueField); + } + } + + // Reset the ID because we are making a copy + $this->table->id = 0; + + // TODO: Deal with ordering? + // $this->table->ordering = 1; + + // Check the row. + if (!$this->table->check()) + { + $this->setError($this->table->getError()); + + return false; + } + + if (!empty($this->type)) + { + $this->createTagsHelper($this->tagsObserver, $this->type, $pk, $this->typeAlias, $this->table); + } + + // Store the row. + if (!$this->table->store()) + { + $this->setError($this->table->getError()); + + return false; + } + + // Get the new item ID + $newId = $this->table->get('id'); + + // Add the new ID to the array + $newIds[$pk] = $newId; + } + + // Clean the cache + $this->cleanCache(); + + return $newIds; + } + + /** + * Batch move items to a new category + * + * @param integer $value The new category ID. + * @param array $pks An array of row IDs. + * @param array $contexts An array of item contexts. + * + * @return boolean True if successful, false otherwise and internal error is set. + * + * @since 12.2 + */ + protected function batchMove($values, $pks, $contexts) + { + if (empty($this->batchSet)) + { + // Set some needed variables. + $this->user = JFactory::getUser(); + $this->table = $this->getTable(); + $this->tableClassName = get_class($this->table); + $this->canDo = GetbibleHelper::getActions('translation'); + } + + if (!$this->canDo->get('translation.edit') && !$this->canDo->get('translation.batch')) + { + $this->setError(JText::_('JLIB_APPLICATION_ERROR_BATCH_CANNOT_EDIT')); + return false; + } + + // make sure published only updates if user has the permission. + if (isset($values['published']) && !$this->canDo->get('translation.edit.state')) + { + unset($values['published']); + } + // remove move_copy from array + unset($values['move_copy']); + + // Parent exists so we proceed + foreach ($pks as $pk) + { + if (!$this->user->authorise('translation.edit', $contexts[$pk])) + { + $this->setError(JText::_('JLIB_APPLICATION_ERROR_BATCH_CANNOT_EDIT')); + return false; + } + + // Check that the row actually exists + if (!$this->table->load($pk)) + { + if ($error = $this->table->getError()) + { + // Fatal error + $this->setError($error); + return false; + } + else + { + // Not fatal error + $this->setError(JText::sprintf('JLIB_APPLICATION_ERROR_BATCH_MOVE_ROW_NOT_FOUND', $pk)); + continue; + } + } + + // insert all set values. + if (GetbibleHelper::checkArray($values)) + { + foreach ($values as $key => $value) + { + // Do special action for access. + if ('access' === $key && strlen($value) > 0) + { + $this->table->$key = $value; + } + elseif (strlen($value) > 0 && isset($this->table->$key)) + { + $this->table->$key = $value; + } + } + } + + + // Check the row. + if (!$this->table->check()) + { + $this->setError($this->table->getError()); + + return false; + } + + if (!empty($this->type)) + { + $this->createTagsHelper($this->tagsObserver, $this->type, $pk, $this->typeAlias, $this->table); + } + + // Store the row. + if (!$this->table->store()) + { + $this->setError($this->table->getError()); + + return false; + } + } + + // Clean the cache + $this->cleanCache(); + + return true; + } + + /** + * Method to save the form data. + * + * @param array $data The form data. + * + * @return boolean True on success. + * + * @since 1.6 + */ + public function save($data) + { + $input = JFactory::getApplication()->input; + $filter = JFilterInput::getInstance(); + + // set the metadata to the Item Data + if (isset($data['metadata']) && isset($data['metadata']['author'])) + { + $data['metadata']['author'] = $filter->clean($data['metadata']['author'], 'TRIM'); + + $metadata = new JRegistry; + $metadata->loadArray($data['metadata']); + $data['metadata'] = (string) $metadata; + } + + // Set the distribution_history items to data. + if (isset($data['distribution_history']) && is_array($data['distribution_history'])) + { + $distribution_history = new JRegistry; + $distribution_history->loadArray($data['distribution_history']); + $data['distribution_history'] = (string) $distribution_history; + } + // Also check permission since the value may be removed due to permissions + // Then we do not want to clear it out, but simple ignore the empty distribution_history + elseif (!isset($data['distribution_history']) + && JFactory::getUser()->authorise('translation.edit.distribution_history', 'com_getbible')) + { + // Set the empty distribution_history to data + $data['distribution_history'] = ''; + } + + // Set the Params Items to data + if (isset($data['params']) && is_array($data['params'])) + { + $params = new JRegistry; + $params->loadArray($data['params']); + $data['params'] = (string) $params; + } + + // Alter the unique field for save as copy + if ($input->get('task') === 'save2copy') + { + // Automatic handling of other unique fields + $uniqueFields = $this->getUniqueFields(); + if (GetbibleHelper::checkArray($uniqueFields)) + { + foreach ($uniqueFields as $uniqueField) + { + $data[$uniqueField] = $this->generateUnique($uniqueField,$data[$uniqueField]); + } + } + } + + if (parent::save($data)) + { + return true; + } + return false; + } + + /** + * Method to generate a unique value. + * + * @param string $field name. + * @param string $value data. + * + * @return string New value. + * + * @since 3.0 + */ + protected function generateUnique($field,$value) + { + + // set field value unique + $table = $this->getTable(); + + while ($table->load(array($field => $value))) + { + $value = StringHelper::increment($value); + } + + return $value; + } + + /** + * Method to change the title + * + * @param string $title The title. + * + * @return array Contains the modified title and alias. + * + */ + protected function _generateNewTitle($title) + { + + // Alter the title + $table = $this->getTable(); + + while ($table->load(array('title' => $title))) + { + $title = StringHelper::increment($title); + } + + return $title; + } +} diff --git a/admin/models/translations.php b/admin/models/translations.php new file mode 100644 index 0000000..7c66146 --- /dev/null +++ b/admin/models/translations.php @@ -0,0 +1,385 @@ + + @git Get Bible + @github Get Bible + @support Get Bible + @copyright Copyright (C) 2015. All Rights Reserved + @license GNU/GPL Version 2 or later - http://www.gnu.org/licenses/gpl-2.0.html + +/------------------------------------------------------------------------------------------------------*/ + +// No direct access to this file +defined('_JEXEC') or die('Restricted access'); + +use Joomla\CMS\MVC\Model\ListModel; +use Joomla\Utilities\ArrayHelper; + +/** + * Translations List Model + */ +class GetbibleModelTranslations extends ListModel +{ + public function __construct($config = array()) + { + if (empty($config['filter_fields'])) + { + $config['filter_fields'] = array( + 'a.id','id', + 'a.published','published', + 'a.access','access', + 'a.ordering','ordering', + 'a.created_by','created_by', + 'a.modified_by','modified_by', + 'a.direction','direction', + 'a.translation','translation', + 'a.abbreviation','abbreviation', + 'a.language','language' + ); + } + + parent::__construct($config); + } + + /** + * Method to auto-populate the model state. + * + * Note. Calling getState in this method will result in recursion. + * + * @param string $ordering An optional ordering field. + * @param string $direction An optional direction (asc|desc). + * + * @return void + * + */ + protected function populateState($ordering = null, $direction = null) + { + $app = JFactory::getApplication(); + + // Adjust the context to support modal layouts. + if ($layout = $app->input->get('layout')) + { + $this->context .= '.' . $layout; + } + + // Check if the form was submitted + $formSubmited = $app->input->post->get('form_submited'); + + $access = $this->getUserStateFromRequest($this->context . '.filter.access', 'filter_access', 0, 'int'); + if ($formSubmited) + { + $access = $app->input->post->get('access'); + $this->setState('filter.access', $access); + } + + $published = $this->getUserStateFromRequest($this->context . '.filter.published', 'filter_published', ''); + $this->setState('filter.published', $published); + + $created_by = $this->getUserStateFromRequest($this->context . '.filter.created_by', 'filter_created_by', ''); + $this->setState('filter.created_by', $created_by); + + $created = $this->getUserStateFromRequest($this->context . '.filter.created', 'filter_created'); + $this->setState('filter.created', $created); + + $sorting = $this->getUserStateFromRequest($this->context . '.filter.sorting', 'filter_sorting', 0, 'int'); + $this->setState('filter.sorting', $sorting); + + $search = $this->getUserStateFromRequest($this->context . '.filter.search', 'filter_search'); + $this->setState('filter.search', $search); + + $direction = $this->getUserStateFromRequest($this->context . '.filter.direction', 'filter_direction'); + if ($formSubmited) + { + $direction = $app->input->post->get('direction'); + $this->setState('filter.direction', $direction); + } + + $translation = $this->getUserStateFromRequest($this->context . '.filter.translation', 'filter_translation'); + if ($formSubmited) + { + $translation = $app->input->post->get('translation'); + $this->setState('filter.translation', $translation); + } + + $abbreviation = $this->getUserStateFromRequest($this->context . '.filter.abbreviation', 'filter_abbreviation'); + if ($formSubmited) + { + $abbreviation = $app->input->post->get('abbreviation'); + $this->setState('filter.abbreviation', $abbreviation); + } + + $language = $this->getUserStateFromRequest($this->context . '.filter.language', 'filter_language'); + if ($formSubmited) + { + $language = $app->input->post->get('language'); + $this->setState('filter.language', $language); + } + + // List state information. + parent::populateState($ordering, $direction); + } + + /** + * Method to get an array of data items. + * + * @return mixed An array of data items on success, false on failure. + */ + public function getItems() + { + // Check in items + $this->checkInNow(); + + // load parent items + $items = parent::getItems(); + + // Set values to display correctly. + if (GetbibleHelper::checkArray($items)) + { + // Get the user object if not set. + if (!isset($user) || !GetbibleHelper::checkObject($user)) + { + $user = JFactory::getUser(); + } + foreach ($items as $nr => &$item) + { + // Remove items the user can't access. + $access = ($user->authorise('translation.access', 'com_getbible.translation.' . (int) $item->id) && $user->authorise('translation.access', 'com_getbible')); + if (!$access) + { + unset($items[$nr]); + continue; + } + + } + } + + // set selection value to a translatable value + if (GetbibleHelper::checkArray($items)) + { + foreach ($items as $nr => &$item) + { + // convert direction + $item->direction = $this->selectionTranslation($item->direction, 'direction'); + } + } + + + // return items + return $items; + } + + /** + * Method to convert selection values to translatable string. + * + * @return translatable string + */ + public function selectionTranslation($value,$name) + { + // Array of direction language strings + if ($name === 'direction') + { + $directionArray = array( + 'LTR' => 'COM_GETBIBLE_TRANSLATION_SINISTRODEXTRAL_LTR', + 'RTL' => 'COM_GETBIBLE_TRANSLATION_DEXTROSINISTRAL_RTL' + ); + // Now check if value is found in this array + if (isset($directionArray[$value]) && GetbibleHelper::checkString($directionArray[$value])) + { + return $directionArray[$value]; + } + } + return $value; + } + + /** + * Method to build an SQL query to load the list data. + * + * @return string An SQL query + */ + protected function getListQuery() + { + // Get the user object. + $user = JFactory::getUser(); + // Create a new query object. + $db = JFactory::getDBO(); + $query = $db->getQuery(true); + + // Select some fields + $query->select('a.*'); + + // From the getbible_item table + $query->from($db->quoteName('#__getbible_translation', 'a')); + + // Filter by published state + $published = $this->getState('filter.published'); + if (is_numeric($published)) + { + $query->where('a.published = ' . (int) $published); + } + elseif ($published === '') + { + $query->where('(a.published = 0 OR a.published = 1)'); + } + + // Join over the asset groups. + $query->select('ag.title AS access_level'); + $query->join('LEFT', '#__viewlevels AS ag ON ag.id = a.access'); + // Filter by access level. + $_access = $this->getState('filter.access'); + if ($_access && is_numeric($_access)) + { + $query->where('a.access = ' . (int) $_access); + } + elseif (GetbibleHelper::checkArray($_access)) + { + // Secure the array for the query + $_access = ArrayHelper::toInteger($_access); + // Filter by the Access Array. + $query->where('a.access IN (' . implode(',', $_access) . ')'); + } + // Implement View Level Access + if (!$user->authorise('core.options', 'com_getbible')) + { + $groups = implode(',', $user->getAuthorisedViewLevels()); + $query->where('a.access IN (' . $groups . ')'); + } + // Filter by search. + $search = $this->getState('filter.search'); + if (!empty($search)) + { + if (stripos($search, 'id:') === 0) + { + $query->where('a.id = ' . (int) substr($search, 3)); + } + else + { + $search = $db->quote('%' . $db->escape($search) . '%'); + $query->where('(a.translation LIKE '.$search.' OR a.abbreviation LIKE '.$search.' OR a.language LIKE '.$search.' OR a.direction LIKE '.$search.' OR a.distribution_about LIKE '.$search.' OR a.distribution_license LIKE '.$search.' OR a.distribution_source LIKE '.$search.' OR a.distribution_sourcetype LIKE '.$search.' OR a.distribution_versification LIKE '.$search.' OR a.sha LIKE '.$search.' OR a.encoding LIKE '.$search.' OR a.distribution_lcsh LIKE '.$search.' OR a.distribution_version_date LIKE '.$search.' OR a.distribution_version LIKE '.$search.' OR a.lang LIKE '.$search.' OR a.distribution_abbreviation LIKE '.$search.')'); + } + } + + // Filter by Direction. + $_direction = $this->getState('filter.direction'); + if (is_numeric($_direction)) + { + if (is_float($_direction)) + { + $query->where('a.direction = ' . (float) $_direction); + } + else + { + $query->where('a.direction = ' . (int) $_direction); + } + } + elseif (GetbibleHelper::checkString($_direction)) + { + $query->where('a.direction = ' . $db->quote($db->escape($_direction))); + } + + // Add the list ordering clause. + $orderCol = $this->state->get('list.ordering', 'a.id'); + $orderDirn = $this->state->get('list.direction', 'desc'); + if ($orderCol != '') + { + $query->order($db->escape($orderCol . ' ' . $orderDirn)); + } + + return $query; + } + + /** + * Method to get a store id based on model configuration state. + * + * @return string A store id. + * + */ + protected function getStoreId($id = '') + { + // Compile the store id. + $id .= ':' . $this->getState('filter.id'); + $id .= ':' . $this->getState('filter.search'); + $id .= ':' . $this->getState('filter.published'); + // Check if the value is an array + $_access = $this->getState('filter.access'); + if (GetbibleHelper::checkArray($_access)) + { + $id .= ':' . implode(':', $_access); + } + // Check if this is only an number or string + elseif (is_numeric($_access) + || GetbibleHelper::checkString($_access)) + { + $id .= ':' . $_access; + } + $id .= ':' . $this->getState('filter.ordering'); + $id .= ':' . $this->getState('filter.created_by'); + $id .= ':' . $this->getState('filter.modified_by'); + $id .= ':' . $this->getState('filter.direction'); + $id .= ':' . $this->getState('filter.translation'); + $id .= ':' . $this->getState('filter.abbreviation'); + $id .= ':' . $this->getState('filter.language'); + + return parent::getStoreId($id); + } + + /** + * Build an SQL query to checkin all items left checked out longer then a set time. + * + * @return a bool + * + */ + protected function checkInNow() + { + // Get set check in time + $time = JComponentHelper::getParams('com_getbible')->get('check_in'); + + if ($time) + { + + // Get a db connection. + $db = JFactory::getDbo(); + // Reset query. + $query = $db->getQuery(true); + $query->select('*'); + $query->from($db->quoteName('#__getbible_translation')); + // Only select items that are checked out. + $query->where($db->quoteName('checked_out') . '!=0'); + $db->setQuery($query, 0, 1); + $db->execute(); + if ($db->getNumRows()) + { + // Get Yesterdays date. + $date = JFactory::getDate()->modify($time)->toSql(); + // Reset query. + $query = $db->getQuery(true); + + // Fields to update. + $fields = array( + $db->quoteName('checked_out_time') . '=\'0000-00-00 00:00:00\'', + $db->quoteName('checked_out') . '=0' + ); + + // Conditions for which records should be updated. + $conditions = array( + $db->quoteName('checked_out') . '!=0', + $db->quoteName('checked_out_time') . '<\''.$date.'\'' + ); + + // Check table. + $query->update($db->quoteName('#__getbible_translation'))->set($fields)->where($conditions); + + $db->setQuery($query); + + $db->execute(); + } + } + + return false; + } +} diff --git a/admin/models/verse.php b/admin/models/verse.php new file mode 100644 index 0000000..8e6759a --- /dev/null +++ b/admin/models/verse.php @@ -0,0 +1,989 @@ + + @git Get Bible + @github Get Bible + @support Get Bible + @copyright Copyright (C) 2015. All Rights Reserved + @license GNU/GPL Version 2 or later - http://www.gnu.org/licenses/gpl-2.0.html + +/------------------------------------------------------------------------------------------------------*/ + +// No direct access to this file +defined('_JEXEC') or die('Restricted access'); + +use Joomla\CMS\MVC\Model\AdminModel; +use Joomla\Registry\Registry; +use Joomla\String\StringHelper; +use Joomla\Utilities\ArrayHelper; + +/** + * Getbible Verse Admin Model + */ +class GetbibleModelVerse extends AdminModel +{ + /** + * The tab layout fields array. + * + * @var array + */ + protected $tabLayoutFields = array( + 'details' => array( + 'left' => array( + 'abbreviation' + ), + 'right' => array( + 'name' + ), + 'fullwidth' => array( + 'text' + ), + 'above' => array( + 'book_nr', + 'chapter', + 'verse' + ) + ) + ); + + /** + * @var string The prefix to use with controller messages. + * @since 1.6 + */ + protected $text_prefix = 'COM_GETBIBLE'; + + /** + * The type alias for this content type. + * + * @var string + * @since 3.2 + */ + public $typeAlias = 'com_getbible.verse'; + + /** + * Returns a Table object, always creating it + * + * @param type $type The table type to instantiate + * @param string $prefix A prefix for the table class name. Optional. + * @param array $config Configuration array for model. Optional. + * + * @return JTable A database object + * + * @since 1.6 + */ + public function getTable($type = 'verse', $prefix = 'GetbibleTable', $config = array()) + { + // add table path for when model gets used from other component + $this->addTablePath(JPATH_ADMINISTRATOR . '/components/com_getbible/tables'); + // get instance of the table + return JTable::getInstance($type, $prefix, $config); + }###ADMIN_CUSTOM_BUTTONS_METHOD### + + /** + * Method to get a single record. + * + * @param integer $pk The id of the primary key. + * + * @return mixed Object on success, false on failure. + * + * @since 1.6 + */ + public function getItem($pk = null) + { + if ($item = parent::getItem($pk)) + { + if (!empty($item->params) && !is_array($item->params)) + { + // Convert the params field to an array. + $registry = new Registry; + $registry->loadString($item->params); + $item->params = $registry->toArray(); + } + + if (!empty($item->metadata)) + { + // Convert the metadata field to an array. + $registry = new Registry; + $registry->loadString($item->metadata); + $item->metadata = $registry->toArray(); + } + } + + return $item; + } + + /** + * Method to get the record form. + * + * @param array $data Data for the form. + * @param boolean $loadData True if the form is to load its own data (default case), false if not. + * @param array $options Optional array of options for the form creation. + * + * @return mixed A JForm object on success, false on failure + * + * @since 1.6 + */ + public function getForm($data = array(), $loadData = true, $options = array('control' => 'jform')) + { + // set load data option + $options['load_data'] = $loadData; + // check if xpath was set in options + $xpath = false; + if (isset($options['xpath'])) + { + $xpath = $options['xpath']; + unset($options['xpath']); + } + // check if clear form was set in options + $clear = false; + if (isset($options['clear'])) + { + $clear = $options['clear']; + unset($options['clear']); + } + + // Get the form. + $form = $this->loadForm('com_getbible.verse', 'verse', $options, $clear, $xpath); + + if (empty($form)) + { + return false; + } + + $jinput = JFactory::getApplication()->input; + + // The front end calls this model and uses a_id to avoid id clashes so we need to check for that first. + if ($jinput->get('a_id')) + { + $id = $jinput->get('a_id', 0, 'INT'); + } + // The back end uses id so we use that the rest of the time and set it to 0 by default. + else + { + $id = $jinput->get('id', 0, 'INT'); + } + + $user = JFactory::getUser(); + + // Check for existing item. + // Modify the form based on Edit State access controls. + if ($id != 0 && (!$user->authorise('verse.edit.state', 'com_getbible.verse.' . (int) $id)) + || ($id == 0 && !$user->authorise('verse.edit.state', 'com_getbible'))) + { + // Disable fields for display. + $form->setFieldAttribute('ordering', 'disabled', 'true'); + $form->setFieldAttribute('published', 'disabled', 'true'); + // Disable fields while saving. + $form->setFieldAttribute('ordering', 'filter', 'unset'); + $form->setFieldAttribute('published', 'filter', 'unset'); + } + // If this is a new item insure the greated by is set. + if (0 == $id) + { + // Set the created_by to this user + $form->setValue('created_by', null, $user->id); + } + // Modify the form based on Edit Creaded By access controls. + if ($id != 0 && (!$user->authorise('verse.edit.created_by', 'com_getbible.verse.' . (int) $id)) + || ($id == 0 && !$user->authorise('verse.edit.created_by', 'com_getbible'))) + { + // Disable fields for display. + $form->setFieldAttribute('created_by', 'disabled', 'true'); + // Disable fields for display. + $form->setFieldAttribute('created_by', 'readonly', 'true'); + // Disable fields while saving. + $form->setFieldAttribute('created_by', 'filter', 'unset'); + } + // Modify the form based on Edit Creaded Date access controls. + if ($id != 0 && (!$user->authorise('verse.edit.created', 'com_getbible.verse.' . (int) $id)) + || ($id == 0 && !$user->authorise('verse.edit.created', 'com_getbible'))) + { + // Disable fields for display. + $form->setFieldAttribute('created', 'disabled', 'true'); + // Disable fields while saving. + $form->setFieldAttribute('created', 'filter', 'unset'); + } + // Modify the form based on Edit Book Nr access controls. + if ($id != 0 && (!$user->authorise('verse.edit.book_nr', 'com_getbible.verse.' . (int) $id)) + || ($id == 0 && !$user->authorise('verse.edit.book_nr', 'com_getbible'))) + { + // Disable fields for display. + $form->setFieldAttribute('book_nr', 'disabled', 'true'); + // Disable fields for display. + $form->setFieldAttribute('book_nr', 'readonly', 'true'); + // If there is no value continue. + if (!$form->getValue('book_nr')) + { + // Disable fields while saving. + $form->setFieldAttribute('book_nr', 'filter', 'unset'); + // Disable fields while saving. + $form->setFieldAttribute('book_nr', 'required', 'false'); + } + } + // Modify the form based on Edit Chapter access controls. + if ($id != 0 && (!$user->authorise('verse.edit.chapter', 'com_getbible.verse.' . (int) $id)) + || ($id == 0 && !$user->authorise('verse.edit.chapter', 'com_getbible'))) + { + // Disable fields for display. + $form->setFieldAttribute('chapter', 'disabled', 'true'); + // Disable fields for display. + $form->setFieldAttribute('chapter', 'readonly', 'true'); + // If there is no value continue. + if (!$form->getValue('chapter')) + { + // Disable fields while saving. + $form->setFieldAttribute('chapter', 'filter', 'unset'); + // Disable fields while saving. + $form->setFieldAttribute('chapter', 'required', 'false'); + } + } + // Modify the form based on Edit Verse access controls. + if ($id != 0 && (!$user->authorise('verse.edit.verse', 'com_getbible.verse.' . (int) $id)) + || ($id == 0 && !$user->authorise('verse.edit.verse', 'com_getbible'))) + { + // Disable fields for display. + $form->setFieldAttribute('verse', 'disabled', 'true'); + // Disable fields for display. + $form->setFieldAttribute('verse', 'readonly', 'true'); + // If there is no value continue. + if (!$form->getValue('verse')) + { + // Disable fields while saving. + $form->setFieldAttribute('verse', 'filter', 'unset'); + // Disable fields while saving. + $form->setFieldAttribute('verse', 'required', 'false'); + } + } + // Modify the form based on Edit Abbreviation access controls. + if ($id != 0 && (!$user->authorise('verse.edit.abbreviation', 'com_getbible.verse.' . (int) $id)) + || ($id == 0 && !$user->authorise('verse.edit.abbreviation', 'com_getbible'))) + { + // Disable fields for display. + $form->setFieldAttribute('abbreviation', 'disabled', 'true'); + // Disable fields for display. + $form->setFieldAttribute('abbreviation', 'readonly', 'true'); + // If there is no value continue. + if (!$form->getValue('abbreviation')) + { + // Disable fields while saving. + $form->setFieldAttribute('abbreviation', 'filter', 'unset'); + // Disable fields while saving. + $form->setFieldAttribute('abbreviation', 'required', 'false'); + } + } + // Modify the form based on Edit Text access controls. + if ($id != 0 && (!$user->authorise('verse.edit.text', 'com_getbible.verse.' . (int) $id)) + || ($id == 0 && !$user->authorise('verse.edit.text', 'com_getbible'))) + { + // Disable fields for display. + $form->setFieldAttribute('text', 'disabled', 'true'); + // Disable fields for display. + $form->setFieldAttribute('text', 'readonly', 'true'); + // If there is no value continue. + if (!$form->getValue('text')) + { + // Disable fields while saving. + $form->setFieldAttribute('text', 'filter', 'unset'); + // Disable fields while saving. + $form->setFieldAttribute('text', 'required', 'false'); + } + } + // Modify the form based on Edit Name access controls. + if ($id != 0 && (!$user->authorise('verse.edit.name', 'com_getbible.verse.' . (int) $id)) + || ($id == 0 && !$user->authorise('verse.edit.name', 'com_getbible'))) + { + // Disable fields for display. + $form->setFieldAttribute('name', 'disabled', 'true'); + // Disable fields for display. + $form->setFieldAttribute('name', 'readonly', 'true'); + // If there is no value continue. + if (!$form->getValue('name')) + { + // Disable fields while saving. + $form->setFieldAttribute('name', 'filter', 'unset'); + // Disable fields while saving. + $form->setFieldAttribute('name', 'required', 'false'); + } + } + // Only load these values if no id is found + if (0 == $id) + { + // Set redirected view name + $redirectedView = $jinput->get('ref', null, 'STRING'); + // Set field name (or fall back to view name) + $redirectedField = $jinput->get('field', $redirectedView, 'STRING'); + // Set redirected view id + $redirectedId = $jinput->get('refid', 0, 'INT'); + // Set field id (or fall back to redirected view id) + $redirectedValue = $jinput->get('field_id', $redirectedId, 'INT'); + if (0 != $redirectedValue && $redirectedField) + { + // Now set the local-redirected field default value + $form->setValue($redirectedField, null, $redirectedValue); + } + } + return $form; + } + + /** + * Method to get the script that have to be included on the form + * + * @return string script files + */ + public function getScript() + { + return 'media/com_getbible/js/verse.js'; + } + + /** + * Method to test whether a record can be deleted. + * + * @param object $record A record object. + * + * @return boolean True if allowed to delete the record. Defaults to the permission set in the component. + * + * @since 1.6 + */ + protected function canDelete($record) + { + if (!empty($record->id)) + { + if ($record->published != -2) + { + return; + } + + $user = JFactory::getUser(); + // The record has been set. Check the record permissions. + return $user->authorise('verse.delete', 'com_getbible.verse.' . (int) $record->id); + } + return false; + } + + /** + * Method to test whether a record can have its state edited. + * + * @param object $record A record object. + * + * @return boolean True if allowed to change the state of the record. Defaults to the permission set in the component. + * + * @since 1.6 + */ + protected function canEditState($record) + { + $user = JFactory::getUser(); + $recordId = (!empty($record->id)) ? $record->id : 0; + + if ($recordId) + { + // The record has been set. Check the record permissions. + $permission = $user->authorise('verse.edit.state', 'com_getbible.verse.' . (int) $recordId); + if (!$permission && !is_null($permission)) + { + return false; + } + } + // In the absense of better information, revert to the component permissions. + return $user->authorise('verse.edit.state', 'com_getbible'); + } + + /** + * Method override to check if you can edit an existing record. + * + * @param array $data An array of input data. + * @param string $key The name of the key for the primary key. + * + * @return boolean + * @since 2.5 + */ + protected function allowEdit($data = array(), $key = 'id') + { + // Check specific edit permission then general edit permission. + $user = JFactory::getUser(); + + return $user->authorise('verse.edit', 'com_getbible.verse.'. ((int) isset($data[$key]) ? $data[$key] : 0)) or $user->authorise('verse.edit', 'com_getbible'); + } + + /** + * Prepare and sanitise the table data prior to saving. + * + * @param JTable $table A JTable object. + * + * @return void + * + * @since 1.6 + */ + protected function prepareTable($table) + { + $date = JFactory::getDate(); + $user = JFactory::getUser(); + + if (isset($table->name)) + { + $table->name = htmlspecialchars_decode($table->name, ENT_QUOTES); + } + + if (isset($table->alias) && empty($table->alias)) + { + $table->generateAlias(); + } + + if (empty($table->id)) + { + $table->created = $date->toSql(); + // set the user + if ($table->created_by == 0 || empty($table->created_by)) + { + $table->created_by = $user->id; + } + // Set ordering to the last item if not set + if (empty($table->ordering)) + { + $db = JFactory::getDbo(); + $query = $db->getQuery(true) + ->select('MAX(ordering)') + ->from($db->quoteName('#__getbible_verse')); + $db->setQuery($query); + $max = $db->loadResult(); + + $table->ordering = $max + 1; + } + } + else + { + $table->modified = $date->toSql(); + $table->modified_by = $user->id; + } + + if (!empty($table->id)) + { + // Increment the items version number. + $table->version++; + } + } + + /** + * Method to get the data that should be injected in the form. + * + * @return mixed The data for the form. + * + * @since 1.6 + */ + protected function loadFormData() + { + // Check the session for previously entered form data. + $data = JFactory::getApplication()->getUserState('com_getbible.edit.verse.data', array()); + + if (empty($data)) + { + $data = $this->getItem(); + // run the perprocess of the data + $this->preprocessData('com_getbible.verse', $data); + } + + return $data; + } + + /** + * Method to get the unique fields of this table. + * + * @return mixed An array of field names, boolean false if none is set. + * + * @since 3.0 + */ + protected function getUniqueFields() + { + return false; + } + + /** + * Method to delete one or more records. + * + * @param array &$pks An array of record primary keys. + * + * @return boolean True if successful, false if an error occurs. + * + * @since 12.2 + */ + public function delete(&$pks) + { + if (!parent::delete($pks)) + { + return false; + } + + return true; + } + + /** + * Method to change the published state of one or more records. + * + * @param array &$pks A list of the primary keys to change. + * @param integer $value The value of the published state. + * + * @return boolean True on success. + * + * @since 12.2 + */ + public function publish(&$pks, $value = 1) + { + if (!parent::publish($pks, $value)) + { + return false; + } + + return true; + } + + /** + * Method to perform batch operations on an item or a set of items. + * + * @param array $commands An array of commands to perform. + * @param array $pks An array of item ids. + * @param array $contexts An array of item contexts. + * + * @return boolean Returns true on success, false on failure. + * + * @since 12.2 + */ + public function batch($commands, $pks, $contexts) + { + // Sanitize ids. + $pks = array_unique($pks); + ArrayHelper::toInteger($pks); + + // Remove any values of zero. + if (array_search(0, $pks, true)) + { + unset($pks[array_search(0, $pks, true)]); + } + + if (empty($pks)) + { + $this->setError(JText::_('JGLOBAL_NO_ITEM_SELECTED')); + return false; + } + + $done = false; + + // Set some needed variables. + $this->user = JFactory::getUser(); + $this->table = $this->getTable(); + $this->tableClassName = get_class($this->table); + $this->contentType = new JUcmType; + $this->type = $this->contentType->getTypeByTable($this->tableClassName); + $this->canDo = GetbibleHelper::getActions('verse'); + $this->batchSet = true; + + if (!$this->canDo->get('core.batch')) + { + $this->setError(JText::_('JLIB_APPLICATION_ERROR_INSUFFICIENT_BATCH_INFORMATION')); + return false; + } + + if ($this->type == false) + { + $type = new JUcmType; + $this->type = $type->getTypeByAlias($this->typeAlias); + } + + $this->tagsObserver = $this->table->getObserverOfClass('JTableObserverTags'); + + if (!empty($commands['move_copy'])) + { + $cmd = ArrayHelper::getValue($commands, 'move_copy', 'c'); + + if ($cmd == 'c') + { + $result = $this->batchCopy($commands, $pks, $contexts); + + if (is_array($result)) + { + foreach ($result as $old => $new) + { + $contexts[$new] = $contexts[$old]; + } + $pks = array_values($result); + } + else + { + return false; + } + } + elseif ($cmd == 'm' && !$this->batchMove($commands, $pks, $contexts)) + { + return false; + } + + $done = true; + } + + if (!$done) + { + $this->setError(JText::_('JLIB_APPLICATION_ERROR_INSUFFICIENT_BATCH_INFORMATION')); + + return false; + } + + // Clear the cache + $this->cleanCache(); + + return true; + } + + /** + * Batch copy items to a new category or current. + * + * @param integer $values The new values. + * @param array $pks An array of row IDs. + * @param array $contexts An array of item contexts. + * + * @return mixed An array of new IDs on success, boolean false on failure. + * + * @since 12.2 + */ + protected function batchCopy($values, $pks, $contexts) + { + if (empty($this->batchSet)) + { + // Set some needed variables. + $this->user = JFactory::getUser(); + $this->table = $this->getTable(); + $this->tableClassName = get_class($this->table); + $this->canDo = GetbibleHelper::getActions('verse'); + } + + if (!$this->canDo->get('verse.create') && !$this->canDo->get('verse.batch')) + { + return false; + } + + // get list of unique fields + $uniqueFields = $this->getUniqueFields(); + // remove move_copy from array + unset($values['move_copy']); + + // make sure published is set + if (!isset($values['published'])) + { + $values['published'] = 0; + } + elseif (isset($values['published']) && !$this->canDo->get('verse.edit.state')) + { + $values['published'] = 0; + } + + $newIds = array(); + // Parent exists so let's proceed + while (!empty($pks)) + { + // Pop the first ID off the stack + $pk = array_shift($pks); + + $this->table->reset(); + + // only allow copy if user may edit this item. + if (!$this->user->authorise('verse.edit', $contexts[$pk])) + { + // Not fatal error + $this->setError(JText::sprintf('JLIB_APPLICATION_ERROR_BATCH_MOVE_ROW_NOT_FOUND', $pk)); + continue; + } + + // Check that the row actually exists + if (!$this->table->load($pk)) + { + if ($error = $this->table->getError()) + { + // Fatal error + $this->setError($error); + return false; + } + else + { + // Not fatal error + $this->setError(JText::sprintf('JLIB_APPLICATION_ERROR_BATCH_MOVE_ROW_NOT_FOUND', $pk)); + continue; + } + } + + // Only for strings + if (GetbibleHelper::checkString($this->table->book_nr) && !is_numeric($this->table->book_nr)) + { + $this->table->book_nr = $this->generateUnique('book_nr',$this->table->book_nr); + } + + // insert all set values + if (GetbibleHelper::checkArray($values)) + { + foreach ($values as $key => $value) + { + if (strlen($value) > 0 && isset($this->table->$key)) + { + $this->table->$key = $value; + } + } + } + + // update all unique fields + if (GetbibleHelper::checkArray($uniqueFields)) + { + foreach ($uniqueFields as $uniqueField) + { + $this->table->$uniqueField = $this->generateUnique($uniqueField,$this->table->$uniqueField); + } + } + + // Reset the ID because we are making a copy + $this->table->id = 0; + + // TODO: Deal with ordering? + // $this->table->ordering = 1; + + // Check the row. + if (!$this->table->check()) + { + $this->setError($this->table->getError()); + + return false; + } + + if (!empty($this->type)) + { + $this->createTagsHelper($this->tagsObserver, $this->type, $pk, $this->typeAlias, $this->table); + } + + // Store the row. + if (!$this->table->store()) + { + $this->setError($this->table->getError()); + + return false; + } + + // Get the new item ID + $newId = $this->table->get('id'); + + // Add the new ID to the array + $newIds[$pk] = $newId; + } + + // Clean the cache + $this->cleanCache(); + + return $newIds; + } + + /** + * Batch move items to a new category + * + * @param integer $value The new category ID. + * @param array $pks An array of row IDs. + * @param array $contexts An array of item contexts. + * + * @return boolean True if successful, false otherwise and internal error is set. + * + * @since 12.2 + */ + protected function batchMove($values, $pks, $contexts) + { + if (empty($this->batchSet)) + { + // Set some needed variables. + $this->user = JFactory::getUser(); + $this->table = $this->getTable(); + $this->tableClassName = get_class($this->table); + $this->canDo = GetbibleHelper::getActions('verse'); + } + + if (!$this->canDo->get('verse.edit') && !$this->canDo->get('verse.batch')) + { + $this->setError(JText::_('JLIB_APPLICATION_ERROR_BATCH_CANNOT_EDIT')); + return false; + } + + // make sure published only updates if user has the permission. + if (isset($values['published']) && !$this->canDo->get('verse.edit.state')) + { + unset($values['published']); + } + // remove move_copy from array + unset($values['move_copy']); + + // Parent exists so we proceed + foreach ($pks as $pk) + { + if (!$this->user->authorise('verse.edit', $contexts[$pk])) + { + $this->setError(JText::_('JLIB_APPLICATION_ERROR_BATCH_CANNOT_EDIT')); + return false; + } + + // Check that the row actually exists + if (!$this->table->load($pk)) + { + if ($error = $this->table->getError()) + { + // Fatal error + $this->setError($error); + return false; + } + else + { + // Not fatal error + $this->setError(JText::sprintf('JLIB_APPLICATION_ERROR_BATCH_MOVE_ROW_NOT_FOUND', $pk)); + continue; + } + } + + // insert all set values. + if (GetbibleHelper::checkArray($values)) + { + foreach ($values as $key => $value) + { + // Do special action for access. + if ('access' === $key && strlen($value) > 0) + { + $this->table->$key = $value; + } + elseif (strlen($value) > 0 && isset($this->table->$key)) + { + $this->table->$key = $value; + } + } + } + + + // Check the row. + if (!$this->table->check()) + { + $this->setError($this->table->getError()); + + return false; + } + + if (!empty($this->type)) + { + $this->createTagsHelper($this->tagsObserver, $this->type, $pk, $this->typeAlias, $this->table); + } + + // Store the row. + if (!$this->table->store()) + { + $this->setError($this->table->getError()); + + return false; + } + } + + // Clean the cache + $this->cleanCache(); + + return true; + } + + /** + * Method to save the form data. + * + * @param array $data The form data. + * + * @return boolean True on success. + * + * @since 1.6 + */ + public function save($data) + { + $input = JFactory::getApplication()->input; + $filter = JFilterInput::getInstance(); + + // set the metadata to the Item Data + if (isset($data['metadata']) && isset($data['metadata']['author'])) + { + $data['metadata']['author'] = $filter->clean($data['metadata']['author'], 'TRIM'); + + $metadata = new JRegistry; + $metadata->loadArray($data['metadata']); + $data['metadata'] = (string) $metadata; + } + + // Set the Params Items to data + if (isset($data['params']) && is_array($data['params'])) + { + $params = new JRegistry; + $params->loadArray($data['params']); + $data['params'] = (string) $params; + } + + // Alter the unique field for save as copy + if ($input->get('task') === 'save2copy') + { + // Automatic handling of other unique fields + $uniqueFields = $this->getUniqueFields(); + if (GetbibleHelper::checkArray($uniqueFields)) + { + foreach ($uniqueFields as $uniqueField) + { + $data[$uniqueField] = $this->generateUnique($uniqueField,$data[$uniqueField]); + } + } + } + + if (parent::save($data)) + { + return true; + } + return false; + } + + /** + * Method to generate a unique value. + * + * @param string $field name. + * @param string $value data. + * + * @return string New value. + * + * @since 3.0 + */ + protected function generateUnique($field,$value) + { + + // set field value unique + $table = $this->getTable(); + + while ($table->load(array($field => $value))) + { + $value = StringHelper::increment($value); + } + + return $value; + } + + /** + * Method to change the title + * + * @param string $title The title. + * + * @return array Contains the modified title and alias. + * + */ + protected function _generateNewTitle($title) + { + + // Alter the title + $table = $this->getTable(); + + while ($table->load(array('title' => $title))) + { + $title = StringHelper::increment($title); + } + + return $title; + } +} diff --git a/admin/models/verses.php b/admin/models/verses.php new file mode 100644 index 0000000..6572849 --- /dev/null +++ b/admin/models/verses.php @@ -0,0 +1,406 @@ + + @git Get Bible + @github Get Bible + @support Get Bible + @copyright Copyright (C) 2015. All Rights Reserved + @license GNU/GPL Version 2 or later - http://www.gnu.org/licenses/gpl-2.0.html + +/------------------------------------------------------------------------------------------------------*/ + +// No direct access to this file +defined('_JEXEC') or die('Restricted access'); + +use Joomla\CMS\MVC\Model\ListModel; +use Joomla\Utilities\ArrayHelper; + +/** + * Verses List Model + */ +class GetbibleModelVerses extends ListModel +{ + public function __construct($config = array()) + { + if (empty($config['filter_fields'])) + { + $config['filter_fields'] = array( + 'a.id','id', + 'a.published','published', + 'a.access','access', + 'a.ordering','ordering', + 'a.created_by','created_by', + 'a.modified_by','modified_by', + 'a.book_nr','book_nr', + 'a.chapter','chapter', + 'a.verse','verse', + 'g.translation','abbreviation' + ); + } + + parent::__construct($config); + } + + /** + * Method to auto-populate the model state. + * + * Note. Calling getState in this method will result in recursion. + * + * @param string $ordering An optional ordering field. + * @param string $direction An optional direction (asc|desc). + * + * @return void + * + */ + protected function populateState($ordering = null, $direction = null) + { + $app = JFactory::getApplication(); + + // Adjust the context to support modal layouts. + if ($layout = $app->input->get('layout')) + { + $this->context .= '.' . $layout; + } + + // Check if the form was submitted + $formSubmited = $app->input->post->get('form_submited'); + + $access = $this->getUserStateFromRequest($this->context . '.filter.access', 'filter_access', 0, 'int'); + if ($formSubmited) + { + $access = $app->input->post->get('access'); + $this->setState('filter.access', $access); + } + + $published = $this->getUserStateFromRequest($this->context . '.filter.published', 'filter_published', ''); + $this->setState('filter.published', $published); + + $created_by = $this->getUserStateFromRequest($this->context . '.filter.created_by', 'filter_created_by', ''); + $this->setState('filter.created_by', $created_by); + + $created = $this->getUserStateFromRequest($this->context . '.filter.created', 'filter_created'); + $this->setState('filter.created', $created); + + $sorting = $this->getUserStateFromRequest($this->context . '.filter.sorting', 'filter_sorting', 0, 'int'); + $this->setState('filter.sorting', $sorting); + + $search = $this->getUserStateFromRequest($this->context . '.filter.search', 'filter_search'); + $this->setState('filter.search', $search); + + $book_nr = $this->getUserStateFromRequest($this->context . '.filter.book_nr', 'filter_book_nr'); + if ($formSubmited) + { + $book_nr = $app->input->post->get('book_nr'); + $this->setState('filter.book_nr', $book_nr); + } + + $chapter = $this->getUserStateFromRequest($this->context . '.filter.chapter', 'filter_chapter'); + if ($formSubmited) + { + $chapter = $app->input->post->get('chapter'); + $this->setState('filter.chapter', $chapter); + } + + $verse = $this->getUserStateFromRequest($this->context . '.filter.verse', 'filter_verse'); + if ($formSubmited) + { + $verse = $app->input->post->get('verse'); + $this->setState('filter.verse', $verse); + } + + $abbreviation = $this->getUserStateFromRequest($this->context . '.filter.abbreviation', 'filter_abbreviation'); + if ($formSubmited) + { + $abbreviation = $app->input->post->get('abbreviation'); + $this->setState('filter.abbreviation', $abbreviation); + } + + // List state information. + parent::populateState($ordering, $direction); + } + + /** + * Method to get an array of data items. + * + * @return mixed An array of data items on success, false on failure. + */ + public function getItems() + { + // Check in items + $this->checkInNow(); + + // load parent items + $items = parent::getItems(); + + // Set values to display correctly. + if (GetbibleHelper::checkArray($items)) + { + // Get the user object if not set. + if (!isset($user) || !GetbibleHelper::checkObject($user)) + { + $user = JFactory::getUser(); + } + foreach ($items as $nr => &$item) + { + // Remove items the user can't access. + $access = ($user->authorise('verse.access', 'com_getbible.verse.' . (int) $item->id) && $user->authorise('verse.access', 'com_getbible')); + if (!$access) + { + unset($items[$nr]); + continue; + } + + } + } + + // return items + return $items; + } + + /** + * Method to build an SQL query to load the list data. + * + * @return string An SQL query + */ + protected function getListQuery() + { + // Get the user object. + $user = JFactory::getUser(); + // Create a new query object. + $db = JFactory::getDBO(); + $query = $db->getQuery(true); + + // Select some fields + $query->select('a.*'); + + // From the getbible_item table + $query->from($db->quoteName('#__getbible_verse', 'a')); + + // From the getbible_translation table. + $query->select($db->quoteName(['g.translation','g.id'],['abbreviation_translation','abbreviation_id'])); + $query->join('LEFT', $db->quoteName('#__getbible_translation', 'g') . ' ON (' . $db->quoteName('a.abbreviation') . ' = ' . $db->quoteName('g.abbreviation') . ')'); + + // Filter by published state + $published = $this->getState('filter.published'); + if (is_numeric($published)) + { + $query->where('a.published = ' . (int) $published); + } + elseif ($published === '') + { + $query->where('(a.published = 0 OR a.published = 1)'); + } + + // Join over the asset groups. + $query->select('ag.title AS access_level'); + $query->join('LEFT', '#__viewlevels AS ag ON ag.id = a.access'); + // Filter by access level. + $_access = $this->getState('filter.access'); + if ($_access && is_numeric($_access)) + { + $query->where('a.access = ' . (int) $_access); + } + elseif (GetbibleHelper::checkArray($_access)) + { + // Secure the array for the query + $_access = ArrayHelper::toInteger($_access); + // Filter by the Access Array. + $query->where('a.access IN (' . implode(',', $_access) . ')'); + } + // Implement View Level Access + if (!$user->authorise('core.options', 'com_getbible')) + { + $groups = implode(',', $user->getAuthorisedViewLevels()); + $query->where('a.access IN (' . $groups . ')'); + } + // Filter by search. + $search = $this->getState('filter.search'); + if (!empty($search)) + { + if (stripos($search, 'id:') === 0) + { + $query->where('a.id = ' . (int) substr($search, 3)); + } + else + { + $search = $db->quote('%' . $db->escape($search) . '%'); + $query->where('(a.book_nr LIKE '.$search.' OR a.chapter LIKE '.$search.' OR a.verse LIKE '.$search.' OR a.abbreviation LIKE '.$search.' OR g.translation LIKE '.$search.' OR a.name LIKE '.$search.')'); + } + } + + // Filter by Book_nr. + $_book_nr = $this->getState('filter.book_nr'); + if (is_numeric($_book_nr)) + { + if (is_float($_book_nr)) + { + $query->where('a.book_nr = ' . (float) $_book_nr); + } + else + { + $query->where('a.book_nr = ' . (int) $_book_nr); + } + } + elseif (GetbibleHelper::checkString($_book_nr)) + { + $query->where('a.book_nr = ' . $db->quote($db->escape($_book_nr))); + } + // Filter by Chapter. + $_chapter = $this->getState('filter.chapter'); + if (is_numeric($_chapter)) + { + if (is_float($_chapter)) + { + $query->where('a.chapter = ' . (float) $_chapter); + } + else + { + $query->where('a.chapter = ' . (int) $_chapter); + } + } + elseif (GetbibleHelper::checkString($_chapter)) + { + $query->where('a.chapter = ' . $db->quote($db->escape($_chapter))); + } + // Filter by Verse. + $_verse = $this->getState('filter.verse'); + if (is_numeric($_verse)) + { + if (is_float($_verse)) + { + $query->where('a.verse = ' . (float) $_verse); + } + else + { + $query->where('a.verse = ' . (int) $_verse); + } + } + elseif (GetbibleHelper::checkString($_verse)) + { + $query->where('a.verse = ' . $db->quote($db->escape($_verse))); + } + // Filter by Abbreviation. + $_abbreviation = $this->getState('filter.abbreviation'); + if (is_numeric($_abbreviation)) + { + if (is_float($_abbreviation)) + { + $query->where('a.abbreviation = ' . (float) $_abbreviation); + } + else + { + $query->where('a.abbreviation = ' . (int) $_abbreviation); + } + } + elseif (GetbibleHelper::checkString($_abbreviation)) + { + $query->where('a.abbreviation = ' . $db->quote($db->escape($_abbreviation))); + } + + // Add the list ordering clause. + $orderCol = $this->state->get('list.ordering', 'a.id'); + $orderDirn = $this->state->get('list.direction', 'desc'); + if ($orderCol != '') + { + $query->order($db->escape($orderCol . ' ' . $orderDirn)); + } + + return $query; + } + + /** + * Method to get a store id based on model configuration state. + * + * @return string A store id. + * + */ + protected function getStoreId($id = '') + { + // Compile the store id. + $id .= ':' . $this->getState('filter.id'); + $id .= ':' . $this->getState('filter.search'); + $id .= ':' . $this->getState('filter.published'); + // Check if the value is an array + $_access = $this->getState('filter.access'); + if (GetbibleHelper::checkArray($_access)) + { + $id .= ':' . implode(':', $_access); + } + // Check if this is only an number or string + elseif (is_numeric($_access) + || GetbibleHelper::checkString($_access)) + { + $id .= ':' . $_access; + } + $id .= ':' . $this->getState('filter.ordering'); + $id .= ':' . $this->getState('filter.created_by'); + $id .= ':' . $this->getState('filter.modified_by'); + $id .= ':' . $this->getState('filter.book_nr'); + $id .= ':' . $this->getState('filter.chapter'); + $id .= ':' . $this->getState('filter.verse'); + $id .= ':' . $this->getState('filter.abbreviation'); + + return parent::getStoreId($id); + } + + /** + * Build an SQL query to checkin all items left checked out longer then a set time. + * + * @return a bool + * + */ + protected function checkInNow() + { + // Get set check in time + $time = JComponentHelper::getParams('com_getbible')->get('check_in'); + + if ($time) + { + + // Get a db connection. + $db = JFactory::getDbo(); + // Reset query. + $query = $db->getQuery(true); + $query->select('*'); + $query->from($db->quoteName('#__getbible_verse')); + // Only select items that are checked out. + $query->where($db->quoteName('checked_out') . '!=0'); + $db->setQuery($query, 0, 1); + $db->execute(); + if ($db->getNumRows()) + { + // Get Yesterdays date. + $date = JFactory::getDate()->modify($time)->toSql(); + // Reset query. + $query = $db->getQuery(true); + + // Fields to update. + $fields = array( + $db->quoteName('checked_out_time') . '=\'0000-00-00 00:00:00\'', + $db->quoteName('checked_out') . '=0' + ); + + // Conditions for which records should be updated. + $conditions = array( + $db->quoteName('checked_out') . '!=0', + $db->quoteName('checked_out_time') . '<\''.$date.'\'' + ); + + // Check table. + $query->update($db->quoteName('#__getbible_verse'))->set($fields)->where($conditions); + + $db->setQuery($query); + + $db->execute(); + } + } + + return false; + } +} diff --git a/admin/sql/index.html b/admin/sql/index.html new file mode 100644 index 0000000..fa6d84e --- /dev/null +++ b/admin/sql/index.html @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/admin/sql/install.mysql.utf8.sql b/admin/sql/install.mysql.utf8.sql new file mode 100644 index 0000000..95b0986 --- /dev/null +++ b/admin/sql/install.mysql.utf8.sql @@ -0,0 +1,446 @@ +CREATE TABLE IF NOT EXISTS `#__getbible_linker` ( + `id` INT(11) NOT NULL AUTO_INCREMENT, + `asset_id` INT(10) unsigned NOT NULL DEFAULT 0 COMMENT 'FK to the #__assets table.', + `guid` VARCHAR(36) NOT NULL DEFAULT '', + `name` VARCHAR(255) NOT NULL DEFAULT '', + `params` text NULL, + `published` TINYINT(3) NOT NULL DEFAULT 1, + `created_by` INT(10) unsigned NOT NULL DEFAULT 0, + `modified_by` INT(10) unsigned NOT NULL DEFAULT 0, + `created` DATETIME NOT NULL DEFAULT '0000-00-00 00:00:00', + `modified` DATETIME NOT NULL DEFAULT '0000-00-00 00:00:00', + `checked_out` int(11) unsigned NOT NULL DEFAULT 0, + `checked_out_time` DATETIME NOT NULL DEFAULT '0000-00-00 00:00:00', + `version` INT(10) unsigned NOT NULL DEFAULT 1, + `hits` INT(10) unsigned NOT NULL DEFAULT 0, + `access` INT(10) unsigned NOT NULL DEFAULT 0, + `ordering` INT(11) NOT NULL DEFAULT 0, + PRIMARY KEY (`id`), + KEY `idx_name` (`name`), + KEY `idx_guid` (`guid`), + KEY `idx_access` (`access`), + KEY `idx_checkout` (`checked_out`), + KEY `idx_createdby` (`created_by`), + KEY `idx_modifiedby` (`modified_by`), + KEY `idx_state` (`published`) +) ENGINE=InnoDB AUTO_INCREMENT=0 DEFAULT CHARSET=utf8mb4 DEFAULT COLLATE=utf8mb4_unicode_ci; + +CREATE TABLE IF NOT EXISTS `#__getbible_note` ( + `id` INT(11) NOT NULL AUTO_INCREMENT, + `asset_id` INT(10) unsigned NOT NULL DEFAULT 0 COMMENT 'FK to the #__assets table.', + `access` TINYINT(1) NOT NULL DEFAULT 0, + `book_nr` INT(7) NOT NULL DEFAULT 0, + `chapter` INT(7) NOT NULL DEFAULT 0, + `guid` VARCHAR(36) NOT NULL DEFAULT '', + `linker` VARCHAR(36) NOT NULL DEFAULT '', + `note` TEXT NOT NULL, + `verse` INT(7) NOT NULL DEFAULT 0, + `params` text NULL, + `published` TINYINT(3) NOT NULL DEFAULT 1, + `created_by` INT(10) unsigned NOT NULL DEFAULT 0, + `modified_by` INT(10) unsigned NOT NULL DEFAULT 0, + `created` DATETIME NOT NULL DEFAULT '0000-00-00 00:00:00', + `modified` DATETIME NOT NULL DEFAULT '0000-00-00 00:00:00', + `checked_out` int(11) unsigned NOT NULL DEFAULT 0, + `checked_out_time` DATETIME NOT NULL DEFAULT '0000-00-00 00:00:00', + `version` INT(10) unsigned NOT NULL DEFAULT 1, + `hits` INT(10) unsigned NOT NULL DEFAULT 0, + `ordering` INT(11) NOT NULL DEFAULT 0, + PRIMARY KEY (`id`), + KEY `idx_book_nr` (`book_nr`), + KEY `idx_linker` (`linker`), + KEY `idx_guid` (`guid`), + KEY `idx_verse` (`verse`), + KEY `idx_chapter` (`chapter`), + KEY `idx_access` (`access`), + KEY `idx_checkout` (`checked_out`), + KEY `idx_createdby` (`created_by`), + KEY `idx_modifiedby` (`modified_by`), + KEY `idx_state` (`published`) +) ENGINE=InnoDB AUTO_INCREMENT=0 DEFAULT CHARSET=utf8mb4 DEFAULT COLLATE=utf8mb4_unicode_ci; + +CREATE TABLE IF NOT EXISTS `#__getbible_tagged_verse` ( + `id` INT(11) NOT NULL AUTO_INCREMENT, + `asset_id` INT(10) unsigned NOT NULL DEFAULT 0 COMMENT 'FK to the #__assets table.', + `abbreviation` VARCHAR(100) NOT NULL DEFAULT '', + `access` TINYINT(1) NOT NULL DEFAULT 0, + `book_nr` INT(7) NOT NULL DEFAULT 0, + `chapter` INT(7) NOT NULL DEFAULT 0, + `guid` VARCHAR(36) NOT NULL DEFAULT '', + `linker` VARCHAR(36) NOT NULL DEFAULT '', + `tag` VARCHAR(36) NOT NULL DEFAULT '', + `verse` INT(7) NOT NULL DEFAULT 0, + `params` text NULL, + `published` TINYINT(3) NOT NULL DEFAULT 1, + `created_by` INT(10) unsigned NOT NULL DEFAULT 0, + `modified_by` INT(10) unsigned NOT NULL DEFAULT 0, + `created` DATETIME NOT NULL DEFAULT '0000-00-00 00:00:00', + `modified` DATETIME NOT NULL DEFAULT '0000-00-00 00:00:00', + `checked_out` int(11) unsigned NOT NULL DEFAULT 0, + `checked_out_time` DATETIME NOT NULL DEFAULT '0000-00-00 00:00:00', + `version` INT(10) unsigned NOT NULL DEFAULT 1, + `hits` INT(10) unsigned NOT NULL DEFAULT 0, + `ordering` INT(11) NOT NULL DEFAULT 0, + PRIMARY KEY (`id`), + KEY `idx_book_nr` (`book_nr`), + KEY `idx_abbreviation` (`abbreviation`), + KEY `idx_linker` (`linker`), + KEY `idx_tag` (`tag`), + KEY `idx_guid` (`guid`), + KEY `idx_verse` (`verse`), + KEY `idx_chapter` (`chapter`), + KEY `idx_access` (`access`), + KEY `idx_checkout` (`checked_out`), + KEY `idx_createdby` (`created_by`), + KEY `idx_modifiedby` (`modified_by`), + KEY `idx_state` (`published`) +) ENGINE=InnoDB AUTO_INCREMENT=0 DEFAULT CHARSET=utf8mb4 DEFAULT COLLATE=utf8mb4_unicode_ci; + +CREATE TABLE IF NOT EXISTS `#__getbible_prompt` ( + `id` INT(11) NOT NULL AUTO_INCREMENT, + `asset_id` INT(10) unsigned NOT NULL DEFAULT 0 COMMENT 'FK to the #__assets table.', + `abbreviation` VARCHAR(100) NOT NULL DEFAULT '', + `ai_org_token_override` TINYINT(1) NOT NULL DEFAULT 0, + `cache_behaviour` TINYINT(1) NOT NULL DEFAULT 0, + `cache_capacity` INT(11) NOT NULL DEFAULT 0, + `frequency_penalty` FLOAT(11) NOT NULL DEFAULT 0, + `frequency_penalty_override` TINYINT(1) NOT NULL DEFAULT 0, + `guid` VARCHAR(36) NOT NULL DEFAULT '', + `integration` TINYINT(1) NOT NULL DEFAULT 1, + `max_tokens` INT(11) NOT NULL DEFAULT 0, + `max_tokens_override` TINYINT(1) NOT NULL DEFAULT 0, + `messages` TEXT NOT NULL, + `model` VARCHAR(50) NOT NULL DEFAULT '', + `n` INT(7) NOT NULL DEFAULT 0, + `n_override` TINYINT(1) NOT NULL DEFAULT 0, + `name` VARCHAR(255) NOT NULL DEFAULT '', + `org_token` VARCHAR(100) NOT NULL DEFAULT '', + `presence_penalty` FLOAT(11) NOT NULL DEFAULT 0, + `presence_penalty_override` TINYINT(1) NOT NULL DEFAULT 0, + `response_retrieval` TINYINT(1) NOT NULL DEFAULT 0, + `temperature` FLOAT(11) NOT NULL DEFAULT 0, + `temperature_override` TINYINT(1) NOT NULL DEFAULT 0, + `token` VARCHAR(100) NOT NULL DEFAULT '', + `token_override` TINYINT(1) NOT NULL DEFAULT 0, + `top_p` FLOAT(11) NOT NULL DEFAULT 0, + `top_p_override` TINYINT(1) NOT NULL DEFAULT 0, + `params` text NULL, + `published` TINYINT(3) NOT NULL DEFAULT 1, + `created_by` INT(10) unsigned NOT NULL DEFAULT 0, + `modified_by` INT(10) unsigned NOT NULL DEFAULT 0, + `created` DATETIME NOT NULL DEFAULT '0000-00-00 00:00:00', + `modified` DATETIME NOT NULL DEFAULT '0000-00-00 00:00:00', + `checked_out` int(11) unsigned NOT NULL DEFAULT 0, + `checked_out_time` DATETIME NOT NULL DEFAULT '0000-00-00 00:00:00', + `version` INT(10) unsigned NOT NULL DEFAULT 1, + `hits` INT(10) unsigned NOT NULL DEFAULT 0, + `access` INT(10) unsigned NOT NULL DEFAULT 0, + `ordering` INT(11) NOT NULL DEFAULT 0, + PRIMARY KEY (`id`), + KEY `idx_name` (`name`), + KEY `idx_integration` (`integration`), + KEY `idx_cache_behaviour` (`cache_behaviour`), + KEY `idx_abbreviation` (`abbreviation`), + KEY `idx_guid` (`guid`), + KEY `idx_model` (`model`), + KEY `idx_access` (`access`), + KEY `idx_checkout` (`checked_out`), + KEY `idx_createdby` (`created_by`), + KEY `idx_modifiedby` (`modified_by`), + KEY `idx_state` (`published`) +) ENGINE=InnoDB AUTO_INCREMENT=0 DEFAULT CHARSET=utf8mb4 DEFAULT COLLATE=utf8mb4_unicode_ci; + +CREATE TABLE IF NOT EXISTS `#__getbible_open_ai_response` ( + `id` INT(11) NOT NULL AUTO_INCREMENT, + `asset_id` INT(10) unsigned NOT NULL DEFAULT 0 COMMENT 'FK to the #__assets table.', + `abbreviation` VARCHAR(100) NOT NULL DEFAULT '', + `book` INT(11) NOT NULL DEFAULT 0, + `chapter` INT(11) NOT NULL DEFAULT 0, + `completion_tokens` INT(11) NOT NULL DEFAULT 0, + `frequency_penalty` FLOAT(11) NOT NULL DEFAULT 0, + `language` VARCHAR(255) NOT NULL DEFAULT '', + `lcsh` VARCHAR(255) NOT NULL DEFAULT '', + `max_tokens` INT(11) NOT NULL DEFAULT 0, + `model` VARCHAR(50) NOT NULL DEFAULT '', + `n` INT(7) NOT NULL DEFAULT 0, + `presence_penalty` FLOAT(11) NOT NULL DEFAULT 0, + `prompt` VARCHAR(36) NOT NULL DEFAULT '', + `prompt_tokens` INT(11) NOT NULL DEFAULT 0, + `response_created` VARCHAR(255) NOT NULL DEFAULT '', + `response_id` VARCHAR(255) NOT NULL DEFAULT '', + `response_model` VARCHAR(255) NOT NULL DEFAULT '', + `response_object` VARCHAR(255) NOT NULL DEFAULT '', + `selected_word` TEXT NOT NULL, + `temperature` FLOAT(11) NOT NULL DEFAULT 0, + `top_p` FLOAT(11) NOT NULL DEFAULT 0, + `total_tokens` INT(11) NOT NULL DEFAULT 0, + `verse` VARCHAR(255) NOT NULL DEFAULT '', + `word` VARCHAR(255) NOT NULL DEFAULT '', + `params` text NULL, + `published` TINYINT(3) NOT NULL DEFAULT 1, + `created_by` INT(10) unsigned NOT NULL DEFAULT 0, + `modified_by` INT(10) unsigned NOT NULL DEFAULT 0, + `created` DATETIME NOT NULL DEFAULT '0000-00-00 00:00:00', + `modified` DATETIME NOT NULL DEFAULT '0000-00-00 00:00:00', + `checked_out` int(11) unsigned NOT NULL DEFAULT 0, + `checked_out_time` DATETIME NOT NULL DEFAULT '0000-00-00 00:00:00', + `version` INT(10) unsigned NOT NULL DEFAULT 1, + `hits` INT(10) unsigned NOT NULL DEFAULT 0, + `access` INT(10) unsigned NOT NULL DEFAULT 0, + `ordering` INT(11) NOT NULL DEFAULT 0, + PRIMARY KEY (`id`), + KEY `idx_response_id` (`response_id`), + KEY `idx_prompt` (`prompt`), + KEY `idx_response_object` (`response_object`), + KEY `idx_response_model` (`response_model`), + KEY `idx_total_tokens` (`total_tokens`), + KEY `idx_word` (`word`), + KEY `idx_chapter` (`chapter`), + KEY `idx_lcsh` (`lcsh`), + KEY `idx_completion_tokens` (`completion_tokens`), + KEY `idx_prompt_tokens` (`prompt_tokens`), + KEY `idx_response_created` (`response_created`), + KEY `idx_abbreviation` (`abbreviation`), + KEY `idx_language` (`language`), + KEY `idx_book` (`book`), + KEY `idx_verse` (`verse`), + KEY `idx_model` (`model`), + KEY `idx_access` (`access`), + KEY `idx_checkout` (`checked_out`), + KEY `idx_createdby` (`created_by`), + KEY `idx_modifiedby` (`modified_by`), + KEY `idx_state` (`published`) +) ENGINE=InnoDB AUTO_INCREMENT=0 DEFAULT CHARSET=utf8mb4 DEFAULT COLLATE=utf8mb4_unicode_ci; + +CREATE TABLE IF NOT EXISTS `#__getbible_open_ai_message` ( + `id` INT(11) NOT NULL AUTO_INCREMENT, + `asset_id` INT(10) unsigned NOT NULL DEFAULT 0 COMMENT 'FK to the #__assets table.', + `content` TEXT NOT NULL, + `index` INT(11) NOT NULL DEFAULT 0, + `name` VARCHAR(255) NOT NULL DEFAULT '', + `open_ai_response` VARCHAR(255) NOT NULL DEFAULT '', + `prompt` VARCHAR(36) NOT NULL DEFAULT '', + `role` VARCHAR(255) NOT NULL DEFAULT '', + `source` TINYINT(1) NOT NULL DEFAULT 0, + `params` text NULL, + `published` TINYINT(3) NOT NULL DEFAULT 1, + `created_by` INT(10) unsigned NOT NULL DEFAULT 0, + `modified_by` INT(10) unsigned NOT NULL DEFAULT 0, + `created` DATETIME NOT NULL DEFAULT '0000-00-00 00:00:00', + `modified` DATETIME NOT NULL DEFAULT '0000-00-00 00:00:00', + `checked_out` int(11) unsigned NOT NULL DEFAULT 0, + `checked_out_time` DATETIME NOT NULL DEFAULT '0000-00-00 00:00:00', + `version` INT(10) unsigned NOT NULL DEFAULT 1, + `hits` INT(10) unsigned NOT NULL DEFAULT 0, + `access` INT(10) unsigned NOT NULL DEFAULT 0, + `ordering` INT(11) NOT NULL DEFAULT 0, + PRIMARY KEY (`id`), + KEY `idx_role` (`role`), + KEY `idx_open_ai_response` (`open_ai_response`), + KEY `idx_prompt` (`prompt`), + KEY `idx_source` (`source`), + KEY `idx_access` (`access`), + KEY `idx_checkout` (`checked_out`), + KEY `idx_createdby` (`created_by`), + KEY `idx_modifiedby` (`modified_by`), + KEY `idx_state` (`published`) +) ENGINE=InnoDB AUTO_INCREMENT=0 DEFAULT CHARSET=utf8mb4 DEFAULT COLLATE=utf8mb4_unicode_ci; + +CREATE TABLE IF NOT EXISTS `#__getbible_password` ( + `id` INT(11) NOT NULL AUTO_INCREMENT, + `asset_id` INT(10) unsigned NOT NULL DEFAULT 0 COMMENT 'FK to the #__assets table.', + `guid` VARCHAR(36) NOT NULL DEFAULT '', + `linker` VARCHAR(36) NOT NULL DEFAULT '', + `name` VARCHAR(255) NOT NULL DEFAULT '', + `password` VARCHAR(100) NOT NULL DEFAULT '', + `params` text NULL, + `published` TINYINT(3) NOT NULL DEFAULT 1, + `created_by` INT(10) unsigned NOT NULL DEFAULT 0, + `modified_by` INT(10) unsigned NOT NULL DEFAULT 0, + `created` DATETIME NOT NULL DEFAULT '0000-00-00 00:00:00', + `modified` DATETIME NOT NULL DEFAULT '0000-00-00 00:00:00', + `checked_out` int(11) unsigned NOT NULL DEFAULT 0, + `checked_out_time` DATETIME NOT NULL DEFAULT '0000-00-00 00:00:00', + `version` INT(10) unsigned NOT NULL DEFAULT 1, + `hits` INT(10) unsigned NOT NULL DEFAULT 0, + `access` INT(10) unsigned NOT NULL DEFAULT 0, + `ordering` INT(11) NOT NULL DEFAULT 0, + PRIMARY KEY (`id`), + KEY `idx_name` (`name`), + KEY `idx_linker` (`linker`), + KEY `idx_guid` (`guid`), + KEY `idx_access` (`access`), + KEY `idx_checkout` (`checked_out`), + KEY `idx_createdby` (`created_by`), + KEY `idx_modifiedby` (`modified_by`), + KEY `idx_state` (`published`) +) ENGINE=InnoDB AUTO_INCREMENT=0 DEFAULT CHARSET=utf8mb4 DEFAULT COLLATE=utf8mb4_unicode_ci; + +CREATE TABLE IF NOT EXISTS `#__getbible_tag` ( + `id` INT(11) NOT NULL AUTO_INCREMENT, + `asset_id` INT(10) unsigned NOT NULL DEFAULT 0 COMMENT 'FK to the #__assets table.', + `access` TINYINT(1) NOT NULL DEFAULT 0, + `description` TEXT NOT NULL, + `guid` VARCHAR(36) NOT NULL DEFAULT '', + `linker` VARCHAR(36) NOT NULL DEFAULT '', + `name` VARCHAR(255) NOT NULL DEFAULT '', + `params` text NULL, + `published` TINYINT(3) NOT NULL DEFAULT 1, + `created_by` INT(10) unsigned NOT NULL DEFAULT 0, + `modified_by` INT(10) unsigned NOT NULL DEFAULT 0, + `created` DATETIME NOT NULL DEFAULT '0000-00-00 00:00:00', + `modified` DATETIME NOT NULL DEFAULT '0000-00-00 00:00:00', + `checked_out` int(11) unsigned NOT NULL DEFAULT 0, + `checked_out_time` DATETIME NOT NULL DEFAULT '0000-00-00 00:00:00', + `version` INT(10) unsigned NOT NULL DEFAULT 1, + `hits` INT(10) unsigned NOT NULL DEFAULT 0, + `ordering` INT(11) NOT NULL DEFAULT 0, + PRIMARY KEY (`id`), + KEY `idx_name` (`name`), + KEY `idx_linker` (`linker`), + KEY `idx_guid` (`guid`), + KEY `idx_access` (`access`), + KEY `idx_checkout` (`checked_out`), + KEY `idx_createdby` (`created_by`), + KEY `idx_modifiedby` (`modified_by`), + KEY `idx_state` (`published`) +) ENGINE=InnoDB AUTO_INCREMENT=0 DEFAULT CHARSET=utf8mb4 DEFAULT COLLATE=utf8mb4_unicode_ci; + +CREATE TABLE IF NOT EXISTS `#__getbible_translation` ( + `id` INT(11) NOT NULL AUTO_INCREMENT, + `asset_id` INT(10) unsigned NOT NULL DEFAULT 0 COMMENT 'FK to the #__assets table.', + `abbreviation` VARCHAR(64) NOT NULL DEFAULT '', + `direction` VARCHAR(64) NOT NULL DEFAULT '', + `distribution_abbreviation` VARCHAR(64) NOT NULL DEFAULT '', + `distribution_about` TEXT NOT NULL, + `distribution_history` TEXT NOT NULL, + `distribution_lcsh` VARCHAR(64) NOT NULL DEFAULT '', + `distribution_license` TEXT NOT NULL, + `distribution_source` VARCHAR(255) NOT NULL DEFAULT '', + `distribution_sourcetype` VARCHAR(64) NOT NULL DEFAULT '', + `distribution_versification` VARCHAR(64) NOT NULL DEFAULT '', + `distribution_version` VARCHAR(64) NOT NULL DEFAULT '', + `distribution_version_date` VARCHAR(64) NOT NULL DEFAULT '', + `encoding` VARCHAR(64) NOT NULL DEFAULT '', + `lang` VARCHAR(255) NOT NULL DEFAULT '', + `language` VARCHAR(100) NOT NULL DEFAULT '', + `sha` VARCHAR(64) NOT NULL DEFAULT '', + `translation` VARCHAR(255) NOT NULL DEFAULT '', + `params` text NULL, + `published` TINYINT(3) NOT NULL DEFAULT 1, + `created_by` INT(10) unsigned NOT NULL DEFAULT 0, + `modified_by` INT(10) unsigned NOT NULL DEFAULT 0, + `created` DATETIME NOT NULL DEFAULT '0000-00-00 00:00:00', + `modified` DATETIME NOT NULL DEFAULT '0000-00-00 00:00:00', + `checked_out` int(11) unsigned NOT NULL DEFAULT 0, + `checked_out_time` DATETIME NOT NULL DEFAULT '0000-00-00 00:00:00', + `version` INT(10) unsigned NOT NULL DEFAULT 1, + `hits` INT(10) unsigned NOT NULL DEFAULT 0, + `access` INT(10) unsigned NOT NULL DEFAULT 0, + `ordering` INT(11) NOT NULL DEFAULT 0, + PRIMARY KEY (`id`), + KEY `idx_translation` (`translation`), + KEY `idx_access` (`access`), + KEY `idx_checkout` (`checked_out`), + KEY `idx_createdby` (`created_by`), + KEY `idx_modifiedby` (`modified_by`), + KEY `idx_state` (`published`) +) ENGINE=InnoDB AUTO_INCREMENT=0 DEFAULT CHARSET=utf8mb4 DEFAULT COLLATE=utf8mb4_unicode_ci; + +CREATE TABLE IF NOT EXISTS `#__getbible_book` ( + `id` INT(11) NOT NULL AUTO_INCREMENT, + `asset_id` INT(10) unsigned NOT NULL DEFAULT 0 COMMENT 'FK to the #__assets table.', + `abbreviation` VARCHAR(100) NOT NULL DEFAULT '', + `name` VARCHAR(255) NOT NULL DEFAULT '', + `nr` INT(7) NOT NULL DEFAULT 0, + `sha` VARCHAR(64) NOT NULL DEFAULT '', + `params` text NULL, + `published` TINYINT(3) NOT NULL DEFAULT 1, + `created_by` INT(10) unsigned NOT NULL DEFAULT 0, + `modified_by` INT(10) unsigned NOT NULL DEFAULT 0, + `created` DATETIME NOT NULL DEFAULT '0000-00-00 00:00:00', + `modified` DATETIME NOT NULL DEFAULT '0000-00-00 00:00:00', + `checked_out` int(11) unsigned NOT NULL DEFAULT 0, + `checked_out_time` DATETIME NOT NULL DEFAULT '0000-00-00 00:00:00', + `version` INT(10) unsigned NOT NULL DEFAULT 1, + `hits` INT(10) unsigned NOT NULL DEFAULT 0, + `access` INT(10) unsigned NOT NULL DEFAULT 0, + `ordering` INT(11) NOT NULL DEFAULT 0, + PRIMARY KEY (`id`), + KEY `idx_name` (`name`), + KEY `idx_abbreviation` (`abbreviation`), + KEY `idx_nr` (`nr`), + KEY `idx_access` (`access`), + KEY `idx_checkout` (`checked_out`), + KEY `idx_createdby` (`created_by`), + KEY `idx_modifiedby` (`modified_by`), + KEY `idx_state` (`published`) +) ENGINE=InnoDB AUTO_INCREMENT=0 DEFAULT CHARSET=utf8mb4 DEFAULT COLLATE=utf8mb4_unicode_ci; + +CREATE TABLE IF NOT EXISTS `#__getbible_chapter` ( + `id` INT(11) NOT NULL AUTO_INCREMENT, + `asset_id` INT(10) unsigned NOT NULL DEFAULT 0 COMMENT 'FK to the #__assets table.', + `abbreviation` VARCHAR(100) NOT NULL DEFAULT '', + `book_nr` INT(7) NOT NULL DEFAULT 0, + `chapter` INT(7) NOT NULL DEFAULT 0, + `name` VARCHAR(255) NOT NULL DEFAULT '', + `sha` VARCHAR(64) NOT NULL DEFAULT '', + `params` text NULL, + `published` TINYINT(3) NOT NULL DEFAULT 1, + `created_by` INT(10) unsigned NOT NULL DEFAULT 0, + `modified_by` INT(10) unsigned NOT NULL DEFAULT 0, + `created` DATETIME NOT NULL DEFAULT '0000-00-00 00:00:00', + `modified` DATETIME NOT NULL DEFAULT '0000-00-00 00:00:00', + `checked_out` int(11) unsigned NOT NULL DEFAULT 0, + `checked_out_time` DATETIME NOT NULL DEFAULT '0000-00-00 00:00:00', + `version` INT(10) unsigned NOT NULL DEFAULT 1, + `hits` INT(10) unsigned NOT NULL DEFAULT 0, + `access` INT(10) unsigned NOT NULL DEFAULT 0, + `ordering` INT(11) NOT NULL DEFAULT 0, + PRIMARY KEY (`id`), + KEY `idx_name` (`name`), + KEY `idx_chapter` (`chapter`), + KEY `idx_book_nr` (`book_nr`), + KEY `idx_abbreviation` (`abbreviation`), + KEY `idx_access` (`access`), + KEY `idx_checkout` (`checked_out`), + KEY `idx_createdby` (`created_by`), + KEY `idx_modifiedby` (`modified_by`), + KEY `idx_state` (`published`) +) ENGINE=InnoDB AUTO_INCREMENT=0 DEFAULT CHARSET=utf8mb4 DEFAULT COLLATE=utf8mb4_unicode_ci; + +CREATE TABLE IF NOT EXISTS `#__getbible_verse` ( + `id` INT(11) NOT NULL AUTO_INCREMENT, + `asset_id` INT(10) unsigned NOT NULL DEFAULT 0 COMMENT 'FK to the #__assets table.', + `abbreviation` VARCHAR(100) NOT NULL DEFAULT '', + `book_nr` INT(7) NOT NULL DEFAULT 0, + `chapter` INT(7) NOT NULL DEFAULT 0, + `name` VARCHAR(255) NOT NULL DEFAULT '', + `text` TEXT NOT NULL, + `verse` INT(7) NOT NULL DEFAULT 0, + `params` text NULL, + `published` TINYINT(3) NOT NULL DEFAULT 1, + `created_by` INT(10) unsigned NOT NULL DEFAULT 0, + `modified_by` INT(10) unsigned NOT NULL DEFAULT 0, + `created` DATETIME NOT NULL DEFAULT '0000-00-00 00:00:00', + `modified` DATETIME NOT NULL DEFAULT '0000-00-00 00:00:00', + `checked_out` int(11) unsigned NOT NULL DEFAULT 0, + `checked_out_time` DATETIME NOT NULL DEFAULT '0000-00-00 00:00:00', + `version` INT(10) unsigned NOT NULL DEFAULT 1, + `hits` INT(10) unsigned NOT NULL DEFAULT 0, + `access` INT(10) unsigned NOT NULL DEFAULT 0, + `ordering` INT(11) NOT NULL DEFAULT 0, + PRIMARY KEY (`id`), + KEY `idx_book_nr` (`book_nr`), + KEY `idx_chapter` (`chapter`), + KEY `idx_verse` (`verse`), + KEY `idx_abbreviation` (`abbreviation`), + KEY `idx_name` (`name`), + KEY `idx_access` (`access`), + KEY `idx_checkout` (`checked_out`), + KEY `idx_createdby` (`created_by`), + KEY `idx_modifiedby` (`modified_by`), + KEY `idx_state` (`published`) +) ENGINE=InnoDB AUTO_INCREMENT=0 DEFAULT CHARSET=utf8mb4 DEFAULT COLLATE=utf8mb4_unicode_ci; + + diff --git a/admin/sql/uninstall.mysql.utf8.sql b/admin/sql/uninstall.mysql.utf8.sql new file mode 100644 index 0000000..898f828 --- /dev/null +++ b/admin/sql/uninstall.mysql.utf8.sql @@ -0,0 +1,13 @@ +DROP TABLE IF EXISTS `#__getbible_linker`; +DROP TABLE IF EXISTS `#__getbible_note`; +DROP TABLE IF EXISTS `#__getbible_tagged_verse`; +DROP TABLE IF EXISTS `#__getbible_prompt`; +DROP TABLE IF EXISTS `#__getbible_open_ai_response`; +DROP TABLE IF EXISTS `#__getbible_open_ai_message`; +DROP TABLE IF EXISTS `#__getbible_password`; +DROP TABLE IF EXISTS `#__getbible_tag`; +DROP TABLE IF EXISTS `#__getbible_translation`; +DROP TABLE IF EXISTS `#__getbible_book`; +DROP TABLE IF EXISTS `#__getbible_chapter`; +DROP TABLE IF EXISTS `#__getbible_verse`; + diff --git a/admin/sql/updates/index.html b/admin/sql/updates/index.html new file mode 100644 index 0000000..fa6d84e --- /dev/null +++ b/admin/sql/updates/index.html @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/admin/sql/updates/mysql/index.html b/admin/sql/updates/mysql/index.html new file mode 100644 index 0000000..fa6d84e --- /dev/null +++ b/admin/sql/updates/mysql/index.html @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/admin/tables/book.php b/admin/tables/book.php new file mode 100644 index 0000000..6a2e1f9 --- /dev/null +++ b/admin/tables/book.php @@ -0,0 +1,327 @@ + + @git Get Bible + @github Get Bible + @support Get Bible + @copyright Copyright (C) 2015. All Rights Reserved + @license GNU/GPL Version 2 or later - http://www.gnu.org/licenses/gpl-2.0.html + +/------------------------------------------------------------------------------------------------------*/ + +// No direct access to this file +defined('_JEXEC') or die('Restricted access'); + +use Joomla\CMS\Table\Table; +use Joomla\Registry\Registry; +use Joomla\String\StringHelper; +use Joomla\Utilities\ArrayHelper; + +/** + * Books Table class + */ +class GetbibleTableBook extends Table +{ + /** + * Ensure the params and metadata in json encoded in the bind method + * + * @var array + * @since 3.3 + */ + protected $_jsonEncode = array('params', 'metadata'); + + /** + * Constructor + * + * @param object Database connector object + */ + function __construct(&$db) + { + parent::__construct('#__getbible_book', 'id', $db); + } + + public function bind($array, $ignore = '') + { + + if (isset($array['params']) && is_array($array['params'])) + { + $registry = new JRegistry; + $registry->loadArray($array['params']); + $array['params'] = (string) $registry; + } + + if (isset($array['metadata']) && is_array($array['metadata'])) + { + $registry = new JRegistry; + $registry->loadArray($array['metadata']); + $array['metadata'] = (string) $registry; + } + + // Bind the rules. + if (isset($array['rules']) && is_array($array['rules'])) + { + $rules = new JAccessRules($array['rules']); + $this->setRules($rules); + } + return parent::bind($array, $ignore); + } + + /** + * Overload the store method for the Book table. + * + * @param boolean Toggle whether null values should be updated. + * @return boolean True on success, false on failure. + * @since 1.6 + */ + public function store($updateNulls = false) + { + $date = JFactory::getDate(); + $user = JFactory::getUser(); + + if ($this->id) + { + // Existing item + $this->modified = $date->toSql(); + $this->modified_by = $user->get('id'); + } + else + { + // New book. A book created and created_by field can be set by the user, + // so we don't touch either of these if they are set. + if (!(int) $this->created) + { + $this->created = $date->toSql(); + } + if (empty($this->created_by)) + { + $this->created_by = $user->get('id'); + } + } + + if (isset($this->alias)) + { + // Verify that the alias is unique + $table = JTable::getInstance('book', 'GetbibleTable'); + + if ($table->load(array('alias' => $this->alias)) && ($table->id != $this->id || $this->id == 0)) + { + $this->setError(JText::_('COM_GETBIBLE_BOOK_ERROR_UNIQUE_ALIAS')); + return false; + } + } + + if (isset($this->url)) + { + // Convert IDN urls to punycode + $this->url = JStringPunycode::urlToPunycode($this->url); + } + if (isset($this->website)) + { + // Convert IDN urls to punycode + $this->website = JStringPunycode::urlToPunycode($this->website); + } + + return parent::store($updateNulls); + } + + /** + * Overloaded check method to ensure data integrity. + * + * @return boolean True on success. + */ + public function check() + { + if (isset($this->alias)) + { + // Generate a valid alias + $this->generateAlias(); + + $table = JTable::getInstance('book', 'getbibleTable'); + + while ($table->load(array('alias' => $this->alias)) && ($table->id != $this->id || $this->id == 0)) + { + $this->alias = StringHelper::increment($this->alias, 'dash'); + } + } + + /* + * Clean up keywords -- eliminate extra spaces between phrases + * and cr (\r) and lf (\n) characters from string. + * Only process if not empty. + */ + if (!empty($this->metakey)) + { + // Array of characters to remove. + $bad_characters = array("\n", "\r", "\"", "<", ">"); + + // Remove bad characters. + $after_clean = StringHelper::str_ireplace($bad_characters, "", $this->metakey); + + // Create array using commas as delimiter. + $keys = explode(',', $after_clean); + $clean_keys = array(); + + foreach ($keys as $key) + { + // Ignore blank keywords. + if (trim($key)) + { + $clean_keys[] = trim($key); + } + } + + // Put array back together delimited by ", " + $this->metakey = implode(", ", $clean_keys); + } + + // Clean up description -- eliminate quotes and <> brackets + if (!empty($this->metadesc)) + { + // Only process if not empty + $bad_characters = array("\"", "<", ">"); + $this->metadesc = StringHelper::str_ireplace($bad_characters, "", $this->metadesc); + } + + // If we don't have any access rules set at this point just use an empty JAccessRules class + if (!$this->getRules()) + { + $rules = $this->getDefaultAssetValues('com_getbible.book.'.$this->id); + $this->setRules($rules); + } + + // Set ordering + if ($this->published < 0) + { + // Set ordering to 0 if state is archived or trashed + $this->ordering = 0; + } + + return true; + } + + /** + * Gets the default asset values for a component. + * + * @param $string $component The component asset name to search for + * + * @return JAccessRules The JAccessRules object for the asset + */ + protected function getDefaultAssetValues($component, $try = true) + { + // Need to find the asset id by the name of the component. + $db = JFactory::getDbo(); + $query = $db->getQuery(true) + ->select($db->quoteName('id')) + ->from($db->quoteName('#__assets')) + ->where($db->quoteName('name') . ' = ' . $db->quote($component)); + $db->setQuery($query); + $db->execute(); + if ($db->loadRowList()) + { + // asset already set so use saved rules + $assetId = (int) $db->loadResult(); + return JAccess::getAssetRules($assetId); // (TODO) instead of keeping inherited Allowed it becomes Allowed. + } + // try again + elseif ($try) + { + $try = explode('.',$component); + $result = $this->getDefaultAssetValues($try[0], false); + if ($result instanceof JAccessRules) + { + if (isset($try[1])) + { + $_result = (string) $result; + $_result = json_decode($_result); + foreach ($_result as $name => &$rule) + { + $v = explode('.', $name); + if ($try[1] !== $v[0]) + { + // remove since it is not part of this view + unset($_result->$name); + } + else + { + // clear the value since we inherit + $rule = array(); + } + } + // check if there are any view values remaining + if (count( (array) $_result)) + { + $_result = json_encode($_result); + $_result = array($_result); + // Instantiate and return the JAccessRules object for the asset rules. + $rules = new JAccessRules; + $rules->mergeCollection($_result); + + return $rules; + } + } + return $result; + } + } + return JAccess::getAssetRules(0); + } + + /** + * Method to compute the default name of the asset. + * The default name is in the form 'table_name.id' + * where id is the value of the primary key of the table. + * + * @return string + * @since 2.5 + */ + protected function _getAssetName() + { + $k = $this->_tbl_key; + return 'com_getbible.book.'.(int) $this->$k; + } + + /** + * Method to return the title to use for the asset table. + * + * @return string + * @since 2.5 + */ + protected function _getAssetTitle() + { + if (isset($this->title)) + { + return $this->title; + } + return ''; + } + + /** + * Get the parent asset id for the record + * + * @return int + * @since 2.5 + */ + protected function _getAssetParentId(JTable $table = NULL, $id = NULL) + { + $asset = JTable::getInstance('Asset'); + $asset->loadByName('com_getbible'); + + return $asset->id; + } + + /** + * This view does not actually have an alias + * + * @return bool + */ + public function generateAlias() + { + return false; + } + +} diff --git a/admin/tables/chapter.php b/admin/tables/chapter.php new file mode 100644 index 0000000..41a17bd --- /dev/null +++ b/admin/tables/chapter.php @@ -0,0 +1,327 @@ + + @git Get Bible + @github Get Bible + @support Get Bible + @copyright Copyright (C) 2015. All Rights Reserved + @license GNU/GPL Version 2 or later - http://www.gnu.org/licenses/gpl-2.0.html + +/------------------------------------------------------------------------------------------------------*/ + +// No direct access to this file +defined('_JEXEC') or die('Restricted access'); + +use Joomla\CMS\Table\Table; +use Joomla\Registry\Registry; +use Joomla\String\StringHelper; +use Joomla\Utilities\ArrayHelper; + +/** + * Chapters Table class + */ +class GetbibleTableChapter extends Table +{ + /** + * Ensure the params and metadata in json encoded in the bind method + * + * @var array + * @since 3.3 + */ + protected $_jsonEncode = array('params', 'metadata'); + + /** + * Constructor + * + * @param object Database connector object + */ + function __construct(&$db) + { + parent::__construct('#__getbible_chapter', 'id', $db); + } + + public function bind($array, $ignore = '') + { + + if (isset($array['params']) && is_array($array['params'])) + { + $registry = new JRegistry; + $registry->loadArray($array['params']); + $array['params'] = (string) $registry; + } + + if (isset($array['metadata']) && is_array($array['metadata'])) + { + $registry = new JRegistry; + $registry->loadArray($array['metadata']); + $array['metadata'] = (string) $registry; + } + + // Bind the rules. + if (isset($array['rules']) && is_array($array['rules'])) + { + $rules = new JAccessRules($array['rules']); + $this->setRules($rules); + } + return parent::bind($array, $ignore); + } + + /** + * Overload the store method for the Chapter table. + * + * @param boolean Toggle whether null values should be updated. + * @return boolean True on success, false on failure. + * @since 1.6 + */ + public function store($updateNulls = false) + { + $date = JFactory::getDate(); + $user = JFactory::getUser(); + + if ($this->id) + { + // Existing item + $this->modified = $date->toSql(); + $this->modified_by = $user->get('id'); + } + else + { + // New chapter. A chapter created and created_by field can be set by the user, + // so we don't touch either of these if they are set. + if (!(int) $this->created) + { + $this->created = $date->toSql(); + } + if (empty($this->created_by)) + { + $this->created_by = $user->get('id'); + } + } + + if (isset($this->alias)) + { + // Verify that the alias is unique + $table = JTable::getInstance('chapter', 'GetbibleTable'); + + if ($table->load(array('alias' => $this->alias)) && ($table->id != $this->id || $this->id == 0)) + { + $this->setError(JText::_('COM_GETBIBLE_CHAPTER_ERROR_UNIQUE_ALIAS')); + return false; + } + } + + if (isset($this->url)) + { + // Convert IDN urls to punycode + $this->url = JStringPunycode::urlToPunycode($this->url); + } + if (isset($this->website)) + { + // Convert IDN urls to punycode + $this->website = JStringPunycode::urlToPunycode($this->website); + } + + return parent::store($updateNulls); + } + + /** + * Overloaded check method to ensure data integrity. + * + * @return boolean True on success. + */ + public function check() + { + if (isset($this->alias)) + { + // Generate a valid alias + $this->generateAlias(); + + $table = JTable::getInstance('chapter', 'getbibleTable'); + + while ($table->load(array('alias' => $this->alias)) && ($table->id != $this->id || $this->id == 0)) + { + $this->alias = StringHelper::increment($this->alias, 'dash'); + } + } + + /* + * Clean up keywords -- eliminate extra spaces between phrases + * and cr (\r) and lf (\n) characters from string. + * Only process if not empty. + */ + if (!empty($this->metakey)) + { + // Array of characters to remove. + $bad_characters = array("\n", "\r", "\"", "<", ">"); + + // Remove bad characters. + $after_clean = StringHelper::str_ireplace($bad_characters, "", $this->metakey); + + // Create array using commas as delimiter. + $keys = explode(',', $after_clean); + $clean_keys = array(); + + foreach ($keys as $key) + { + // Ignore blank keywords. + if (trim($key)) + { + $clean_keys[] = trim($key); + } + } + + // Put array back together delimited by ", " + $this->metakey = implode(", ", $clean_keys); + } + + // Clean up description -- eliminate quotes and <> brackets + if (!empty($this->metadesc)) + { + // Only process if not empty + $bad_characters = array("\"", "<", ">"); + $this->metadesc = StringHelper::str_ireplace($bad_characters, "", $this->metadesc); + } + + // If we don't have any access rules set at this point just use an empty JAccessRules class + if (!$this->getRules()) + { + $rules = $this->getDefaultAssetValues('com_getbible.chapter.'.$this->id); + $this->setRules($rules); + } + + // Set ordering + if ($this->published < 0) + { + // Set ordering to 0 if state is archived or trashed + $this->ordering = 0; + } + + return true; + } + + /** + * Gets the default asset values for a component. + * + * @param $string $component The component asset name to search for + * + * @return JAccessRules The JAccessRules object for the asset + */ + protected function getDefaultAssetValues($component, $try = true) + { + // Need to find the asset id by the name of the component. + $db = JFactory::getDbo(); + $query = $db->getQuery(true) + ->select($db->quoteName('id')) + ->from($db->quoteName('#__assets')) + ->where($db->quoteName('name') . ' = ' . $db->quote($component)); + $db->setQuery($query); + $db->execute(); + if ($db->loadRowList()) + { + // asset already set so use saved rules + $assetId = (int) $db->loadResult(); + return JAccess::getAssetRules($assetId); // (TODO) instead of keeping inherited Allowed it becomes Allowed. + } + // try again + elseif ($try) + { + $try = explode('.',$component); + $result = $this->getDefaultAssetValues($try[0], false); + if ($result instanceof JAccessRules) + { + if (isset($try[1])) + { + $_result = (string) $result; + $_result = json_decode($_result); + foreach ($_result as $name => &$rule) + { + $v = explode('.', $name); + if ($try[1] !== $v[0]) + { + // remove since it is not part of this view + unset($_result->$name); + } + else + { + // clear the value since we inherit + $rule = array(); + } + } + // check if there are any view values remaining + if (count( (array) $_result)) + { + $_result = json_encode($_result); + $_result = array($_result); + // Instantiate and return the JAccessRules object for the asset rules. + $rules = new JAccessRules; + $rules->mergeCollection($_result); + + return $rules; + } + } + return $result; + } + } + return JAccess::getAssetRules(0); + } + + /** + * Method to compute the default name of the asset. + * The default name is in the form 'table_name.id' + * where id is the value of the primary key of the table. + * + * @return string + * @since 2.5 + */ + protected function _getAssetName() + { + $k = $this->_tbl_key; + return 'com_getbible.chapter.'.(int) $this->$k; + } + + /** + * Method to return the title to use for the asset table. + * + * @return string + * @since 2.5 + */ + protected function _getAssetTitle() + { + if (isset($this->title)) + { + return $this->title; + } + return ''; + } + + /** + * Get the parent asset id for the record + * + * @return int + * @since 2.5 + */ + protected function _getAssetParentId(JTable $table = NULL, $id = NULL) + { + $asset = JTable::getInstance('Asset'); + $asset->loadByName('com_getbible'); + + return $asset->id; + } + + /** + * This view does not actually have an alias + * + * @return bool + */ + public function generateAlias() + { + return false; + } + +} diff --git a/admin/tables/index.html b/admin/tables/index.html new file mode 100644 index 0000000..fa6d84e --- /dev/null +++ b/admin/tables/index.html @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/admin/tables/linker.php b/admin/tables/linker.php new file mode 100644 index 0000000..d9e9b66 --- /dev/null +++ b/admin/tables/linker.php @@ -0,0 +1,327 @@ + + @git Get Bible + @github Get Bible + @support Get Bible + @copyright Copyright (C) 2015. All Rights Reserved + @license GNU/GPL Version 2 or later - http://www.gnu.org/licenses/gpl-2.0.html + +/------------------------------------------------------------------------------------------------------*/ + +// No direct access to this file +defined('_JEXEC') or die('Restricted access'); + +use Joomla\CMS\Table\Table; +use Joomla\Registry\Registry; +use Joomla\String\StringHelper; +use Joomla\Utilities\ArrayHelper; + +/** + * Linkers Table class + */ +class GetbibleTableLinker extends Table +{ + /** + * Ensure the params and metadata in json encoded in the bind method + * + * @var array + * @since 3.3 + */ + protected $_jsonEncode = array('params', 'metadata'); + + /** + * Constructor + * + * @param object Database connector object + */ + function __construct(&$db) + { + parent::__construct('#__getbible_linker', 'id', $db); + } + + public function bind($array, $ignore = '') + { + + if (isset($array['params']) && is_array($array['params'])) + { + $registry = new JRegistry; + $registry->loadArray($array['params']); + $array['params'] = (string) $registry; + } + + if (isset($array['metadata']) && is_array($array['metadata'])) + { + $registry = new JRegistry; + $registry->loadArray($array['metadata']); + $array['metadata'] = (string) $registry; + } + + // Bind the rules. + if (isset($array['rules']) && is_array($array['rules'])) + { + $rules = new JAccessRules($array['rules']); + $this->setRules($rules); + } + return parent::bind($array, $ignore); + } + + /** + * Overload the store method for the Linker table. + * + * @param boolean Toggle whether null values should be updated. + * @return boolean True on success, false on failure. + * @since 1.6 + */ + public function store($updateNulls = false) + { + $date = JFactory::getDate(); + $user = JFactory::getUser(); + + if ($this->id) + { + // Existing item + $this->modified = $date->toSql(); + $this->modified_by = $user->get('id'); + } + else + { + // New linker. A linker created and created_by field can be set by the user, + // so we don't touch either of these if they are set. + if (!(int) $this->created) + { + $this->created = $date->toSql(); + } + if (empty($this->created_by)) + { + $this->created_by = $user->get('id'); + } + } + + if (isset($this->alias)) + { + // Verify that the alias is unique + $table = JTable::getInstance('linker', 'GetbibleTable'); + + if ($table->load(array('alias' => $this->alias)) && ($table->id != $this->id || $this->id == 0)) + { + $this->setError(JText::_('COM_GETBIBLE_LINKER_ERROR_UNIQUE_ALIAS')); + return false; + } + } + + if (isset($this->url)) + { + // Convert IDN urls to punycode + $this->url = JStringPunycode::urlToPunycode($this->url); + } + if (isset($this->website)) + { + // Convert IDN urls to punycode + $this->website = JStringPunycode::urlToPunycode($this->website); + } + + return parent::store($updateNulls); + } + + /** + * Overloaded check method to ensure data integrity. + * + * @return boolean True on success. + */ + public function check() + { + if (isset($this->alias)) + { + // Generate a valid alias + $this->generateAlias(); + + $table = JTable::getInstance('linker', 'getbibleTable'); + + while ($table->load(array('alias' => $this->alias)) && ($table->id != $this->id || $this->id == 0)) + { + $this->alias = StringHelper::increment($this->alias, 'dash'); + } + } + + /* + * Clean up keywords -- eliminate extra spaces between phrases + * and cr (\r) and lf (\n) characters from string. + * Only process if not empty. + */ + if (!empty($this->metakey)) + { + // Array of characters to remove. + $bad_characters = array("\n", "\r", "\"", "<", ">"); + + // Remove bad characters. + $after_clean = StringHelper::str_ireplace($bad_characters, "", $this->metakey); + + // Create array using commas as delimiter. + $keys = explode(',', $after_clean); + $clean_keys = array(); + + foreach ($keys as $key) + { + // Ignore blank keywords. + if (trim($key)) + { + $clean_keys[] = trim($key); + } + } + + // Put array back together delimited by ", " + $this->metakey = implode(", ", $clean_keys); + } + + // Clean up description -- eliminate quotes and <> brackets + if (!empty($this->metadesc)) + { + // Only process if not empty + $bad_characters = array("\"", "<", ">"); + $this->metadesc = StringHelper::str_ireplace($bad_characters, "", $this->metadesc); + } + + // If we don't have any access rules set at this point just use an empty JAccessRules class + if (!$this->getRules()) + { + $rules = $this->getDefaultAssetValues('com_getbible.linker.'.$this->id); + $this->setRules($rules); + } + + // Set ordering + if ($this->published < 0) + { + // Set ordering to 0 if state is archived or trashed + $this->ordering = 0; + } + + return true; + } + + /** + * Gets the default asset values for a component. + * + * @param $string $component The component asset name to search for + * + * @return JAccessRules The JAccessRules object for the asset + */ + protected function getDefaultAssetValues($component, $try = true) + { + // Need to find the asset id by the name of the component. + $db = JFactory::getDbo(); + $query = $db->getQuery(true) + ->select($db->quoteName('id')) + ->from($db->quoteName('#__assets')) + ->where($db->quoteName('name') . ' = ' . $db->quote($component)); + $db->setQuery($query); + $db->execute(); + if ($db->loadRowList()) + { + // asset already set so use saved rules + $assetId = (int) $db->loadResult(); + return JAccess::getAssetRules($assetId); // (TODO) instead of keeping inherited Allowed it becomes Allowed. + } + // try again + elseif ($try) + { + $try = explode('.',$component); + $result = $this->getDefaultAssetValues($try[0], false); + if ($result instanceof JAccessRules) + { + if (isset($try[1])) + { + $_result = (string) $result; + $_result = json_decode($_result); + foreach ($_result as $name => &$rule) + { + $v = explode('.', $name); + if ($try[1] !== $v[0]) + { + // remove since it is not part of this view + unset($_result->$name); + } + else + { + // clear the value since we inherit + $rule = array(); + } + } + // check if there are any view values remaining + if (count( (array) $_result)) + { + $_result = json_encode($_result); + $_result = array($_result); + // Instantiate and return the JAccessRules object for the asset rules. + $rules = new JAccessRules; + $rules->mergeCollection($_result); + + return $rules; + } + } + return $result; + } + } + return JAccess::getAssetRules(0); + } + + /** + * Method to compute the default name of the asset. + * The default name is in the form 'table_name.id' + * where id is the value of the primary key of the table. + * + * @return string + * @since 2.5 + */ + protected function _getAssetName() + { + $k = $this->_tbl_key; + return 'com_getbible.linker.'.(int) $this->$k; + } + + /** + * Method to return the title to use for the asset table. + * + * @return string + * @since 2.5 + */ + protected function _getAssetTitle() + { + if (isset($this->title)) + { + return $this->title; + } + return ''; + } + + /** + * Get the parent asset id for the record + * + * @return int + * @since 2.5 + */ + protected function _getAssetParentId(JTable $table = NULL, $id = NULL) + { + $asset = JTable::getInstance('Asset'); + $asset->loadByName('com_getbible'); + + return $asset->id; + } + + /** + * This view does not actually have an alias + * + * @return bool + */ + public function generateAlias() + { + return false; + } + +} diff --git a/admin/tables/note.php b/admin/tables/note.php new file mode 100644 index 0000000..45296be --- /dev/null +++ b/admin/tables/note.php @@ -0,0 +1,330 @@ + + @git Get Bible + @github Get Bible + @support Get Bible + @copyright Copyright (C) 2015. All Rights Reserved + @license GNU/GPL Version 2 or later - http://www.gnu.org/licenses/gpl-2.0.html + +/------------------------------------------------------------------------------------------------------*/ + +// No direct access to this file +defined('_JEXEC') or die('Restricted access'); + +use Joomla\CMS\Table\Table; +use Joomla\Registry\Registry; +use Joomla\String\StringHelper; +use Joomla\Utilities\ArrayHelper; + +/** + * Notes Table class + */ +class GetbibleTableNote extends Table +{ + /** + * Ensure the params and metadata in json encoded in the bind method + * + * @var array + * @since 3.3 + */ + protected $_jsonEncode = array('params', 'metadata'); + + /** + * Constructor + * + * @param object Database connector object + */ + function __construct(&$db) + { + parent::__construct('#__getbible_note', 'id', $db); + + // Adding History Options + JTableObserverContenthistory::createObserver($this, array('typeAlias' => 'com_getbible.note')); + } + + public function bind($array, $ignore = '') + { + + if (isset($array['params']) && is_array($array['params'])) + { + $registry = new JRegistry; + $registry->loadArray($array['params']); + $array['params'] = (string) $registry; + } + + if (isset($array['metadata']) && is_array($array['metadata'])) + { + $registry = new JRegistry; + $registry->loadArray($array['metadata']); + $array['metadata'] = (string) $registry; + } + + // Bind the rules. + if (isset($array['rules']) && is_array($array['rules'])) + { + $rules = new JAccessRules($array['rules']); + $this->setRules($rules); + } + return parent::bind($array, $ignore); + } + + /** + * Overload the store method for the Note table. + * + * @param boolean Toggle whether null values should be updated. + * @return boolean True on success, false on failure. + * @since 1.6 + */ + public function store($updateNulls = false) + { + $date = JFactory::getDate(); + $user = JFactory::getUser(); + + if ($this->id) + { + // Existing item + $this->modified = $date->toSql(); + $this->modified_by = $user->get('id'); + } + else + { + // New note. A note created and created_by field can be set by the user, + // so we don't touch either of these if they are set. + if (!(int) $this->created) + { + $this->created = $date->toSql(); + } + if (empty($this->created_by)) + { + $this->created_by = $user->get('id'); + } + } + + if (isset($this->alias)) + { + // Verify that the alias is unique + $table = JTable::getInstance('note', 'GetbibleTable'); + + if ($table->load(array('alias' => $this->alias)) && ($table->id != $this->id || $this->id == 0)) + { + $this->setError(JText::_('COM_GETBIBLE_NOTE_ERROR_UNIQUE_ALIAS')); + return false; + } + } + + if (isset($this->url)) + { + // Convert IDN urls to punycode + $this->url = JStringPunycode::urlToPunycode($this->url); + } + if (isset($this->website)) + { + // Convert IDN urls to punycode + $this->website = JStringPunycode::urlToPunycode($this->website); + } + + return parent::store($updateNulls); + } + + /** + * Overloaded check method to ensure data integrity. + * + * @return boolean True on success. + */ + public function check() + { + if (isset($this->alias)) + { + // Generate a valid alias + $this->generateAlias(); + + $table = JTable::getInstance('note', 'getbibleTable'); + + while ($table->load(array('alias' => $this->alias)) && ($table->id != $this->id || $this->id == 0)) + { + $this->alias = StringHelper::increment($this->alias, 'dash'); + } + } + + /* + * Clean up keywords -- eliminate extra spaces between phrases + * and cr (\r) and lf (\n) characters from string. + * Only process if not empty. + */ + if (!empty($this->metakey)) + { + // Array of characters to remove. + $bad_characters = array("\n", "\r", "\"", "<", ">"); + + // Remove bad characters. + $after_clean = StringHelper::str_ireplace($bad_characters, "", $this->metakey); + + // Create array using commas as delimiter. + $keys = explode(',', $after_clean); + $clean_keys = array(); + + foreach ($keys as $key) + { + // Ignore blank keywords. + if (trim($key)) + { + $clean_keys[] = trim($key); + } + } + + // Put array back together delimited by ", " + $this->metakey = implode(", ", $clean_keys); + } + + // Clean up description -- eliminate quotes and <> brackets + if (!empty($this->metadesc)) + { + // Only process if not empty + $bad_characters = array("\"", "<", ">"); + $this->metadesc = StringHelper::str_ireplace($bad_characters, "", $this->metadesc); + } + + // If we don't have any access rules set at this point just use an empty JAccessRules class + if (!$this->getRules()) + { + $rules = $this->getDefaultAssetValues('com_getbible.note.'.$this->id); + $this->setRules($rules); + } + + // Set ordering + if ($this->published < 0) + { + // Set ordering to 0 if state is archived or trashed + $this->ordering = 0; + } + + return true; + } + + /** + * Gets the default asset values for a component. + * + * @param $string $component The component asset name to search for + * + * @return JAccessRules The JAccessRules object for the asset + */ + protected function getDefaultAssetValues($component, $try = true) + { + // Need to find the asset id by the name of the component. + $db = JFactory::getDbo(); + $query = $db->getQuery(true) + ->select($db->quoteName('id')) + ->from($db->quoteName('#__assets')) + ->where($db->quoteName('name') . ' = ' . $db->quote($component)); + $db->setQuery($query); + $db->execute(); + if ($db->loadRowList()) + { + // asset already set so use saved rules + $assetId = (int) $db->loadResult(); + return JAccess::getAssetRules($assetId); // (TODO) instead of keeping inherited Allowed it becomes Allowed. + } + // try again + elseif ($try) + { + $try = explode('.',$component); + $result = $this->getDefaultAssetValues($try[0], false); + if ($result instanceof JAccessRules) + { + if (isset($try[1])) + { + $_result = (string) $result; + $_result = json_decode($_result); + foreach ($_result as $name => &$rule) + { + $v = explode('.', $name); + if ($try[1] !== $v[0]) + { + // remove since it is not part of this view + unset($_result->$name); + } + else + { + // clear the value since we inherit + $rule = array(); + } + } + // check if there are any view values remaining + if (count( (array) $_result)) + { + $_result = json_encode($_result); + $_result = array($_result); + // Instantiate and return the JAccessRules object for the asset rules. + $rules = new JAccessRules; + $rules->mergeCollection($_result); + + return $rules; + } + } + return $result; + } + } + return JAccess::getAssetRules(0); + } + + /** + * Method to compute the default name of the asset. + * The default name is in the form 'table_name.id' + * where id is the value of the primary key of the table. + * + * @return string + * @since 2.5 + */ + protected function _getAssetName() + { + $k = $this->_tbl_key; + return 'com_getbible.note.'.(int) $this->$k; + } + + /** + * Method to return the title to use for the asset table. + * + * @return string + * @since 2.5 + */ + protected function _getAssetTitle() + { + if (isset($this->title)) + { + return $this->title; + } + return ''; + } + + /** + * Get the parent asset id for the record + * + * @return int + * @since 2.5 + */ + protected function _getAssetParentId(JTable $table = NULL, $id = NULL) + { + $asset = JTable::getInstance('Asset'); + $asset->loadByName('com_getbible'); + + return $asset->id; + } + + /** + * This view does not actually have an alias + * + * @return bool + */ + public function generateAlias() + { + return false; + } + +} diff --git a/admin/tables/open_ai_message.php b/admin/tables/open_ai_message.php new file mode 100644 index 0000000..bfde711 --- /dev/null +++ b/admin/tables/open_ai_message.php @@ -0,0 +1,330 @@ + + @git Get Bible + @github Get Bible + @support Get Bible + @copyright Copyright (C) 2015. All Rights Reserved + @license GNU/GPL Version 2 or later - http://www.gnu.org/licenses/gpl-2.0.html + +/------------------------------------------------------------------------------------------------------*/ + +// No direct access to this file +defined('_JEXEC') or die('Restricted access'); + +use Joomla\CMS\Table\Table; +use Joomla\Registry\Registry; +use Joomla\String\StringHelper; +use Joomla\Utilities\ArrayHelper; + +/** + * Open_ai_messages Table class + */ +class GetbibleTableOpen_ai_message extends Table +{ + /** + * Ensure the params and metadata in json encoded in the bind method + * + * @var array + * @since 3.3 + */ + protected $_jsonEncode = array('params', 'metadata'); + + /** + * Constructor + * + * @param object Database connector object + */ + function __construct(&$db) + { + parent::__construct('#__getbible_open_ai_message', 'id', $db); + + // Adding History Options + JTableObserverContenthistory::createObserver($this, array('typeAlias' => 'com_getbible.open_ai_message')); + } + + public function bind($array, $ignore = '') + { + + if (isset($array['params']) && is_array($array['params'])) + { + $registry = new JRegistry; + $registry->loadArray($array['params']); + $array['params'] = (string) $registry; + } + + if (isset($array['metadata']) && is_array($array['metadata'])) + { + $registry = new JRegistry; + $registry->loadArray($array['metadata']); + $array['metadata'] = (string) $registry; + } + + // Bind the rules. + if (isset($array['rules']) && is_array($array['rules'])) + { + $rules = new JAccessRules($array['rules']); + $this->setRules($rules); + } + return parent::bind($array, $ignore); + } + + /** + * Overload the store method for the Open_ai_message table. + * + * @param boolean Toggle whether null values should be updated. + * @return boolean True on success, false on failure. + * @since 1.6 + */ + public function store($updateNulls = false) + { + $date = JFactory::getDate(); + $user = JFactory::getUser(); + + if ($this->id) + { + // Existing item + $this->modified = $date->toSql(); + $this->modified_by = $user->get('id'); + } + else + { + // New open_ai_message. A open_ai_message created and created_by field can be set by the user, + // so we don't touch either of these if they are set. + if (!(int) $this->created) + { + $this->created = $date->toSql(); + } + if (empty($this->created_by)) + { + $this->created_by = $user->get('id'); + } + } + + if (isset($this->alias)) + { + // Verify that the alias is unique + $table = JTable::getInstance('open_ai_message', 'GetbibleTable'); + + if ($table->load(array('alias' => $this->alias)) && ($table->id != $this->id || $this->id == 0)) + { + $this->setError(JText::_('COM_GETBIBLE_OPEN_AI_MESSAGE_ERROR_UNIQUE_ALIAS')); + return false; + } + } + + if (isset($this->url)) + { + // Convert IDN urls to punycode + $this->url = JStringPunycode::urlToPunycode($this->url); + } + if (isset($this->website)) + { + // Convert IDN urls to punycode + $this->website = JStringPunycode::urlToPunycode($this->website); + } + + return parent::store($updateNulls); + } + + /** + * Overloaded check method to ensure data integrity. + * + * @return boolean True on success. + */ + public function check() + { + if (isset($this->alias)) + { + // Generate a valid alias + $this->generateAlias(); + + $table = JTable::getInstance('open_ai_message', 'getbibleTable'); + + while ($table->load(array('alias' => $this->alias)) && ($table->id != $this->id || $this->id == 0)) + { + $this->alias = StringHelper::increment($this->alias, 'dash'); + } + } + + /* + * Clean up keywords -- eliminate extra spaces between phrases + * and cr (\r) and lf (\n) characters from string. + * Only process if not empty. + */ + if (!empty($this->metakey)) + { + // Array of characters to remove. + $bad_characters = array("\n", "\r", "\"", "<", ">"); + + // Remove bad characters. + $after_clean = StringHelper::str_ireplace($bad_characters, "", $this->metakey); + + // Create array using commas as delimiter. + $keys = explode(',', $after_clean); + $clean_keys = array(); + + foreach ($keys as $key) + { + // Ignore blank keywords. + if (trim($key)) + { + $clean_keys[] = trim($key); + } + } + + // Put array back together delimited by ", " + $this->metakey = implode(", ", $clean_keys); + } + + // Clean up description -- eliminate quotes and <> brackets + if (!empty($this->metadesc)) + { + // Only process if not empty + $bad_characters = array("\"", "<", ">"); + $this->metadesc = StringHelper::str_ireplace($bad_characters, "", $this->metadesc); + } + + // If we don't have any access rules set at this point just use an empty JAccessRules class + if (!$this->getRules()) + { + $rules = $this->getDefaultAssetValues('com_getbible.open_ai_message.'.$this->id); + $this->setRules($rules); + } + + // Set ordering + if ($this->published < 0) + { + // Set ordering to 0 if state is archived or trashed + $this->ordering = 0; + } + + return true; + } + + /** + * Gets the default asset values for a component. + * + * @param $string $component The component asset name to search for + * + * @return JAccessRules The JAccessRules object for the asset + */ + protected function getDefaultAssetValues($component, $try = true) + { + // Need to find the asset id by the name of the component. + $db = JFactory::getDbo(); + $query = $db->getQuery(true) + ->select($db->quoteName('id')) + ->from($db->quoteName('#__assets')) + ->where($db->quoteName('name') . ' = ' . $db->quote($component)); + $db->setQuery($query); + $db->execute(); + if ($db->loadRowList()) + { + // asset already set so use saved rules + $assetId = (int) $db->loadResult(); + return JAccess::getAssetRules($assetId); // (TODO) instead of keeping inherited Allowed it becomes Allowed. + } + // try again + elseif ($try) + { + $try = explode('.',$component); + $result = $this->getDefaultAssetValues($try[0], false); + if ($result instanceof JAccessRules) + { + if (isset($try[1])) + { + $_result = (string) $result; + $_result = json_decode($_result); + foreach ($_result as $name => &$rule) + { + $v = explode('.', $name); + if ($try[1] !== $v[0]) + { + // remove since it is not part of this view + unset($_result->$name); + } + else + { + // clear the value since we inherit + $rule = array(); + } + } + // check if there are any view values remaining + if (count( (array) $_result)) + { + $_result = json_encode($_result); + $_result = array($_result); + // Instantiate and return the JAccessRules object for the asset rules. + $rules = new JAccessRules; + $rules->mergeCollection($_result); + + return $rules; + } + } + return $result; + } + } + return JAccess::getAssetRules(0); + } + + /** + * Method to compute the default name of the asset. + * The default name is in the form 'table_name.id' + * where id is the value of the primary key of the table. + * + * @return string + * @since 2.5 + */ + protected function _getAssetName() + { + $k = $this->_tbl_key; + return 'com_getbible.open_ai_message.'.(int) $this->$k; + } + + /** + * Method to return the title to use for the asset table. + * + * @return string + * @since 2.5 + */ + protected function _getAssetTitle() + { + if (isset($this->title)) + { + return $this->title; + } + return ''; + } + + /** + * Get the parent asset id for the record + * + * @return int + * @since 2.5 + */ + protected function _getAssetParentId(JTable $table = NULL, $id = NULL) + { + $asset = JTable::getInstance('Asset'); + $asset->loadByName('com_getbible'); + + return $asset->id; + } + + /** + * This view does not actually have an alias + * + * @return bool + */ + public function generateAlias() + { + return false; + } + +} diff --git a/admin/tables/open_ai_response.php b/admin/tables/open_ai_response.php new file mode 100644 index 0000000..f4ec262 --- /dev/null +++ b/admin/tables/open_ai_response.php @@ -0,0 +1,330 @@ + + @git Get Bible + @github Get Bible + @support Get Bible + @copyright Copyright (C) 2015. All Rights Reserved + @license GNU/GPL Version 2 or later - http://www.gnu.org/licenses/gpl-2.0.html + +/------------------------------------------------------------------------------------------------------*/ + +// No direct access to this file +defined('_JEXEC') or die('Restricted access'); + +use Joomla\CMS\Table\Table; +use Joomla\Registry\Registry; +use Joomla\String\StringHelper; +use Joomla\Utilities\ArrayHelper; + +/** + * Open_ai_responses Table class + */ +class GetbibleTableOpen_ai_response extends Table +{ + /** + * Ensure the params and metadata in json encoded in the bind method + * + * @var array + * @since 3.3 + */ + protected $_jsonEncode = array('params', 'metadata'); + + /** + * Constructor + * + * @param object Database connector object + */ + function __construct(&$db) + { + parent::__construct('#__getbible_open_ai_response', 'id', $db); + + // Adding History Options + JTableObserverContenthistory::createObserver($this, array('typeAlias' => 'com_getbible.open_ai_response')); + } + + public function bind($array, $ignore = '') + { + + if (isset($array['params']) && is_array($array['params'])) + { + $registry = new JRegistry; + $registry->loadArray($array['params']); + $array['params'] = (string) $registry; + } + + if (isset($array['metadata']) && is_array($array['metadata'])) + { + $registry = new JRegistry; + $registry->loadArray($array['metadata']); + $array['metadata'] = (string) $registry; + } + + // Bind the rules. + if (isset($array['rules']) && is_array($array['rules'])) + { + $rules = new JAccessRules($array['rules']); + $this->setRules($rules); + } + return parent::bind($array, $ignore); + } + + /** + * Overload the store method for the Open_ai_response table. + * + * @param boolean Toggle whether null values should be updated. + * @return boolean True on success, false on failure. + * @since 1.6 + */ + public function store($updateNulls = false) + { + $date = JFactory::getDate(); + $user = JFactory::getUser(); + + if ($this->id) + { + // Existing item + $this->modified = $date->toSql(); + $this->modified_by = $user->get('id'); + } + else + { + // New open_ai_response. A open_ai_response created and created_by field can be set by the user, + // so we don't touch either of these if they are set. + if (!(int) $this->created) + { + $this->created = $date->toSql(); + } + if (empty($this->created_by)) + { + $this->created_by = $user->get('id'); + } + } + + if (isset($this->alias)) + { + // Verify that the alias is unique + $table = JTable::getInstance('open_ai_response', 'GetbibleTable'); + + if ($table->load(array('alias' => $this->alias)) && ($table->id != $this->id || $this->id == 0)) + { + $this->setError(JText::_('COM_GETBIBLE_OPEN_AI_RESPONSE_ERROR_UNIQUE_ALIAS')); + return false; + } + } + + if (isset($this->url)) + { + // Convert IDN urls to punycode + $this->url = JStringPunycode::urlToPunycode($this->url); + } + if (isset($this->website)) + { + // Convert IDN urls to punycode + $this->website = JStringPunycode::urlToPunycode($this->website); + } + + return parent::store($updateNulls); + } + + /** + * Overloaded check method to ensure data integrity. + * + * @return boolean True on success. + */ + public function check() + { + if (isset($this->alias)) + { + // Generate a valid alias + $this->generateAlias(); + + $table = JTable::getInstance('open_ai_response', 'getbibleTable'); + + while ($table->load(array('alias' => $this->alias)) && ($table->id != $this->id || $this->id == 0)) + { + $this->alias = StringHelper::increment($this->alias, 'dash'); + } + } + + /* + * Clean up keywords -- eliminate extra spaces between phrases + * and cr (\r) and lf (\n) characters from string. + * Only process if not empty. + */ + if (!empty($this->metakey)) + { + // Array of characters to remove. + $bad_characters = array("\n", "\r", "\"", "<", ">"); + + // Remove bad characters. + $after_clean = StringHelper::str_ireplace($bad_characters, "", $this->metakey); + + // Create array using commas as delimiter. + $keys = explode(',', $after_clean); + $clean_keys = array(); + + foreach ($keys as $key) + { + // Ignore blank keywords. + if (trim($key)) + { + $clean_keys[] = trim($key); + } + } + + // Put array back together delimited by ", " + $this->metakey = implode(", ", $clean_keys); + } + + // Clean up description -- eliminate quotes and <> brackets + if (!empty($this->metadesc)) + { + // Only process if not empty + $bad_characters = array("\"", "<", ">"); + $this->metadesc = StringHelper::str_ireplace($bad_characters, "", $this->metadesc); + } + + // If we don't have any access rules set at this point just use an empty JAccessRules class + if (!$this->getRules()) + { + $rules = $this->getDefaultAssetValues('com_getbible.open_ai_response.'.$this->id); + $this->setRules($rules); + } + + // Set ordering + if ($this->published < 0) + { + // Set ordering to 0 if state is archived or trashed + $this->ordering = 0; + } + + return true; + } + + /** + * Gets the default asset values for a component. + * + * @param $string $component The component asset name to search for + * + * @return JAccessRules The JAccessRules object for the asset + */ + protected function getDefaultAssetValues($component, $try = true) + { + // Need to find the asset id by the name of the component. + $db = JFactory::getDbo(); + $query = $db->getQuery(true) + ->select($db->quoteName('id')) + ->from($db->quoteName('#__assets')) + ->where($db->quoteName('name') . ' = ' . $db->quote($component)); + $db->setQuery($query); + $db->execute(); + if ($db->loadRowList()) + { + // asset already set so use saved rules + $assetId = (int) $db->loadResult(); + return JAccess::getAssetRules($assetId); // (TODO) instead of keeping inherited Allowed it becomes Allowed. + } + // try again + elseif ($try) + { + $try = explode('.',$component); + $result = $this->getDefaultAssetValues($try[0], false); + if ($result instanceof JAccessRules) + { + if (isset($try[1])) + { + $_result = (string) $result; + $_result = json_decode($_result); + foreach ($_result as $name => &$rule) + { + $v = explode('.', $name); + if ($try[1] !== $v[0]) + { + // remove since it is not part of this view + unset($_result->$name); + } + else + { + // clear the value since we inherit + $rule = array(); + } + } + // check if there are any view values remaining + if (count( (array) $_result)) + { + $_result = json_encode($_result); + $_result = array($_result); + // Instantiate and return the JAccessRules object for the asset rules. + $rules = new JAccessRules; + $rules->mergeCollection($_result); + + return $rules; + } + } + return $result; + } + } + return JAccess::getAssetRules(0); + } + + /** + * Method to compute the default name of the asset. + * The default name is in the form 'table_name.id' + * where id is the value of the primary key of the table. + * + * @return string + * @since 2.5 + */ + protected function _getAssetName() + { + $k = $this->_tbl_key; + return 'com_getbible.open_ai_response.'.(int) $this->$k; + } + + /** + * Method to return the title to use for the asset table. + * + * @return string + * @since 2.5 + */ + protected function _getAssetTitle() + { + if (isset($this->title)) + { + return $this->title; + } + return ''; + } + + /** + * Get the parent asset id for the record + * + * @return int + * @since 2.5 + */ + protected function _getAssetParentId(JTable $table = NULL, $id = NULL) + { + $asset = JTable::getInstance('Asset'); + $asset->loadByName('com_getbible'); + + return $asset->id; + } + + /** + * This view does not actually have an alias + * + * @return bool + */ + public function generateAlias() + { + return false; + } + +} diff --git a/admin/tables/password.php b/admin/tables/password.php new file mode 100644 index 0000000..1fe8aed --- /dev/null +++ b/admin/tables/password.php @@ -0,0 +1,327 @@ + + @git Get Bible + @github Get Bible + @support Get Bible + @copyright Copyright (C) 2015. All Rights Reserved + @license GNU/GPL Version 2 or later - http://www.gnu.org/licenses/gpl-2.0.html + +/------------------------------------------------------------------------------------------------------*/ + +// No direct access to this file +defined('_JEXEC') or die('Restricted access'); + +use Joomla\CMS\Table\Table; +use Joomla\Registry\Registry; +use Joomla\String\StringHelper; +use Joomla\Utilities\ArrayHelper; + +/** + * Passwords Table class + */ +class GetbibleTablePassword extends Table +{ + /** + * Ensure the params and metadata in json encoded in the bind method + * + * @var array + * @since 3.3 + */ + protected $_jsonEncode = array('params', 'metadata'); + + /** + * Constructor + * + * @param object Database connector object + */ + function __construct(&$db) + { + parent::__construct('#__getbible_password', 'id', $db); + } + + public function bind($array, $ignore = '') + { + + if (isset($array['params']) && is_array($array['params'])) + { + $registry = new JRegistry; + $registry->loadArray($array['params']); + $array['params'] = (string) $registry; + } + + if (isset($array['metadata']) && is_array($array['metadata'])) + { + $registry = new JRegistry; + $registry->loadArray($array['metadata']); + $array['metadata'] = (string) $registry; + } + + // Bind the rules. + if (isset($array['rules']) && is_array($array['rules'])) + { + $rules = new JAccessRules($array['rules']); + $this->setRules($rules); + } + return parent::bind($array, $ignore); + } + + /** + * Overload the store method for the Password table. + * + * @param boolean Toggle whether null values should be updated. + * @return boolean True on success, false on failure. + * @since 1.6 + */ + public function store($updateNulls = false) + { + $date = JFactory::getDate(); + $user = JFactory::getUser(); + + if ($this->id) + { + // Existing item + $this->modified = $date->toSql(); + $this->modified_by = $user->get('id'); + } + else + { + // New password. A password created and created_by field can be set by the user, + // so we don't touch either of these if they are set. + if (!(int) $this->created) + { + $this->created = $date->toSql(); + } + if (empty($this->created_by)) + { + $this->created_by = $user->get('id'); + } + } + + if (isset($this->alias)) + { + // Verify that the alias is unique + $table = JTable::getInstance('password', 'GetbibleTable'); + + if ($table->load(array('alias' => $this->alias)) && ($table->id != $this->id || $this->id == 0)) + { + $this->setError(JText::_('COM_GETBIBLE_PASSWORD_ERROR_UNIQUE_ALIAS')); + return false; + } + } + + if (isset($this->url)) + { + // Convert IDN urls to punycode + $this->url = JStringPunycode::urlToPunycode($this->url); + } + if (isset($this->website)) + { + // Convert IDN urls to punycode + $this->website = JStringPunycode::urlToPunycode($this->website); + } + + return parent::store($updateNulls); + } + + /** + * Overloaded check method to ensure data integrity. + * + * @return boolean True on success. + */ + public function check() + { + if (isset($this->alias)) + { + // Generate a valid alias + $this->generateAlias(); + + $table = JTable::getInstance('password', 'getbibleTable'); + + while ($table->load(array('alias' => $this->alias)) && ($table->id != $this->id || $this->id == 0)) + { + $this->alias = StringHelper::increment($this->alias, 'dash'); + } + } + + /* + * Clean up keywords -- eliminate extra spaces between phrases + * and cr (\r) and lf (\n) characters from string. + * Only process if not empty. + */ + if (!empty($this->metakey)) + { + // Array of characters to remove. + $bad_characters = array("\n", "\r", "\"", "<", ">"); + + // Remove bad characters. + $after_clean = StringHelper::str_ireplace($bad_characters, "", $this->metakey); + + // Create array using commas as delimiter. + $keys = explode(',', $after_clean); + $clean_keys = array(); + + foreach ($keys as $key) + { + // Ignore blank keywords. + if (trim($key)) + { + $clean_keys[] = trim($key); + } + } + + // Put array back together delimited by ", " + $this->metakey = implode(", ", $clean_keys); + } + + // Clean up description -- eliminate quotes and <> brackets + if (!empty($this->metadesc)) + { + // Only process if not empty + $bad_characters = array("\"", "<", ">"); + $this->metadesc = StringHelper::str_ireplace($bad_characters, "", $this->metadesc); + } + + // If we don't have any access rules set at this point just use an empty JAccessRules class + if (!$this->getRules()) + { + $rules = $this->getDefaultAssetValues('com_getbible.password.'.$this->id); + $this->setRules($rules); + } + + // Set ordering + if ($this->published < 0) + { + // Set ordering to 0 if state is archived or trashed + $this->ordering = 0; + } + + return true; + } + + /** + * Gets the default asset values for a component. + * + * @param $string $component The component asset name to search for + * + * @return JAccessRules The JAccessRules object for the asset + */ + protected function getDefaultAssetValues($component, $try = true) + { + // Need to find the asset id by the name of the component. + $db = JFactory::getDbo(); + $query = $db->getQuery(true) + ->select($db->quoteName('id')) + ->from($db->quoteName('#__assets')) + ->where($db->quoteName('name') . ' = ' . $db->quote($component)); + $db->setQuery($query); + $db->execute(); + if ($db->loadRowList()) + { + // asset already set so use saved rules + $assetId = (int) $db->loadResult(); + return JAccess::getAssetRules($assetId); // (TODO) instead of keeping inherited Allowed it becomes Allowed. + } + // try again + elseif ($try) + { + $try = explode('.',$component); + $result = $this->getDefaultAssetValues($try[0], false); + if ($result instanceof JAccessRules) + { + if (isset($try[1])) + { + $_result = (string) $result; + $_result = json_decode($_result); + foreach ($_result as $name => &$rule) + { + $v = explode('.', $name); + if ($try[1] !== $v[0]) + { + // remove since it is not part of this view + unset($_result->$name); + } + else + { + // clear the value since we inherit + $rule = array(); + } + } + // check if there are any view values remaining + if (count( (array) $_result)) + { + $_result = json_encode($_result); + $_result = array($_result); + // Instantiate and return the JAccessRules object for the asset rules. + $rules = new JAccessRules; + $rules->mergeCollection($_result); + + return $rules; + } + } + return $result; + } + } + return JAccess::getAssetRules(0); + } + + /** + * Method to compute the default name of the asset. + * The default name is in the form 'table_name.id' + * where id is the value of the primary key of the table. + * + * @return string + * @since 2.5 + */ + protected function _getAssetName() + { + $k = $this->_tbl_key; + return 'com_getbible.password.'.(int) $this->$k; + } + + /** + * Method to return the title to use for the asset table. + * + * @return string + * @since 2.5 + */ + protected function _getAssetTitle() + { + if (isset($this->title)) + { + return $this->title; + } + return ''; + } + + /** + * Get the parent asset id for the record + * + * @return int + * @since 2.5 + */ + protected function _getAssetParentId(JTable $table = NULL, $id = NULL) + { + $asset = JTable::getInstance('Asset'); + $asset->loadByName('com_getbible'); + + return $asset->id; + } + + /** + * This view does not actually have an alias + * + * @return bool + */ + public function generateAlias() + { + return false; + } + +} diff --git a/admin/tables/prompt.php b/admin/tables/prompt.php new file mode 100644 index 0000000..c1ee6ed --- /dev/null +++ b/admin/tables/prompt.php @@ -0,0 +1,330 @@ + + @git Get Bible + @github Get Bible + @support Get Bible + @copyright Copyright (C) 2015. All Rights Reserved + @license GNU/GPL Version 2 or later - http://www.gnu.org/licenses/gpl-2.0.html + +/------------------------------------------------------------------------------------------------------*/ + +// No direct access to this file +defined('_JEXEC') or die('Restricted access'); + +use Joomla\CMS\Table\Table; +use Joomla\Registry\Registry; +use Joomla\String\StringHelper; +use Joomla\Utilities\ArrayHelper; + +/** + * Prompts Table class + */ +class GetbibleTablePrompt extends Table +{ + /** + * Ensure the params and metadata in json encoded in the bind method + * + * @var array + * @since 3.3 + */ + protected $_jsonEncode = array('params', 'metadata'); + + /** + * Constructor + * + * @param object Database connector object + */ + function __construct(&$db) + { + parent::__construct('#__getbible_prompt', 'id', $db); + + // Adding History Options + JTableObserverContenthistory::createObserver($this, array('typeAlias' => 'com_getbible.prompt')); + } + + public function bind($array, $ignore = '') + { + + if (isset($array['params']) && is_array($array['params'])) + { + $registry = new JRegistry; + $registry->loadArray($array['params']); + $array['params'] = (string) $registry; + } + + if (isset($array['metadata']) && is_array($array['metadata'])) + { + $registry = new JRegistry; + $registry->loadArray($array['metadata']); + $array['metadata'] = (string) $registry; + } + + // Bind the rules. + if (isset($array['rules']) && is_array($array['rules'])) + { + $rules = new JAccessRules($array['rules']); + $this->setRules($rules); + } + return parent::bind($array, $ignore); + } + + /** + * Overload the store method for the Prompt table. + * + * @param boolean Toggle whether null values should be updated. + * @return boolean True on success, false on failure. + * @since 1.6 + */ + public function store($updateNulls = false) + { + $date = JFactory::getDate(); + $user = JFactory::getUser(); + + if ($this->id) + { + // Existing item + $this->modified = $date->toSql(); + $this->modified_by = $user->get('id'); + } + else + { + // New prompt. A prompt created and created_by field can be set by the user, + // so we don't touch either of these if they are set. + if (!(int) $this->created) + { + $this->created = $date->toSql(); + } + if (empty($this->created_by)) + { + $this->created_by = $user->get('id'); + } + } + + if (isset($this->alias)) + { + // Verify that the alias is unique + $table = JTable::getInstance('prompt', 'GetbibleTable'); + + if ($table->load(array('alias' => $this->alias)) && ($table->id != $this->id || $this->id == 0)) + { + $this->setError(JText::_('COM_GETBIBLE_PROMPT_ERROR_UNIQUE_ALIAS')); + return false; + } + } + + if (isset($this->url)) + { + // Convert IDN urls to punycode + $this->url = JStringPunycode::urlToPunycode($this->url); + } + if (isset($this->website)) + { + // Convert IDN urls to punycode + $this->website = JStringPunycode::urlToPunycode($this->website); + } + + return parent::store($updateNulls); + } + + /** + * Overloaded check method to ensure data integrity. + * + * @return boolean True on success. + */ + public function check() + { + if (isset($this->alias)) + { + // Generate a valid alias + $this->generateAlias(); + + $table = JTable::getInstance('prompt', 'getbibleTable'); + + while ($table->load(array('alias' => $this->alias)) && ($table->id != $this->id || $this->id == 0)) + { + $this->alias = StringHelper::increment($this->alias, 'dash'); + } + } + + /* + * Clean up keywords -- eliminate extra spaces between phrases + * and cr (\r) and lf (\n) characters from string. + * Only process if not empty. + */ + if (!empty($this->metakey)) + { + // Array of characters to remove. + $bad_characters = array("\n", "\r", "\"", "<", ">"); + + // Remove bad characters. + $after_clean = StringHelper::str_ireplace($bad_characters, "", $this->metakey); + + // Create array using commas as delimiter. + $keys = explode(',', $after_clean); + $clean_keys = array(); + + foreach ($keys as $key) + { + // Ignore blank keywords. + if (trim($key)) + { + $clean_keys[] = trim($key); + } + } + + // Put array back together delimited by ", " + $this->metakey = implode(", ", $clean_keys); + } + + // Clean up description -- eliminate quotes and <> brackets + if (!empty($this->metadesc)) + { + // Only process if not empty + $bad_characters = array("\"", "<", ">"); + $this->metadesc = StringHelper::str_ireplace($bad_characters, "", $this->metadesc); + } + + // If we don't have any access rules set at this point just use an empty JAccessRules class + if (!$this->getRules()) + { + $rules = $this->getDefaultAssetValues('com_getbible.prompt.'.$this->id); + $this->setRules($rules); + } + + // Set ordering + if ($this->published < 0) + { + // Set ordering to 0 if state is archived or trashed + $this->ordering = 0; + } + + return true; + } + + /** + * Gets the default asset values for a component. + * + * @param $string $component The component asset name to search for + * + * @return JAccessRules The JAccessRules object for the asset + */ + protected function getDefaultAssetValues($component, $try = true) + { + // Need to find the asset id by the name of the component. + $db = JFactory::getDbo(); + $query = $db->getQuery(true) + ->select($db->quoteName('id')) + ->from($db->quoteName('#__assets')) + ->where($db->quoteName('name') . ' = ' . $db->quote($component)); + $db->setQuery($query); + $db->execute(); + if ($db->loadRowList()) + { + // asset already set so use saved rules + $assetId = (int) $db->loadResult(); + return JAccess::getAssetRules($assetId); // (TODO) instead of keeping inherited Allowed it becomes Allowed. + } + // try again + elseif ($try) + { + $try = explode('.',$component); + $result = $this->getDefaultAssetValues($try[0], false); + if ($result instanceof JAccessRules) + { + if (isset($try[1])) + { + $_result = (string) $result; + $_result = json_decode($_result); + foreach ($_result as $name => &$rule) + { + $v = explode('.', $name); + if ($try[1] !== $v[0]) + { + // remove since it is not part of this view + unset($_result->$name); + } + else + { + // clear the value since we inherit + $rule = array(); + } + } + // check if there are any view values remaining + if (count( (array) $_result)) + { + $_result = json_encode($_result); + $_result = array($_result); + // Instantiate and return the JAccessRules object for the asset rules. + $rules = new JAccessRules; + $rules->mergeCollection($_result); + + return $rules; + } + } + return $result; + } + } + return JAccess::getAssetRules(0); + } + + /** + * Method to compute the default name of the asset. + * The default name is in the form 'table_name.id' + * where id is the value of the primary key of the table. + * + * @return string + * @since 2.5 + */ + protected function _getAssetName() + { + $k = $this->_tbl_key; + return 'com_getbible.prompt.'.(int) $this->$k; + } + + /** + * Method to return the title to use for the asset table. + * + * @return string + * @since 2.5 + */ + protected function _getAssetTitle() + { + if (isset($this->title)) + { + return $this->title; + } + return ''; + } + + /** + * Get the parent asset id for the record + * + * @return int + * @since 2.5 + */ + protected function _getAssetParentId(JTable $table = NULL, $id = NULL) + { + $asset = JTable::getInstance('Asset'); + $asset->loadByName('com_getbible'); + + return $asset->id; + } + + /** + * This view does not actually have an alias + * + * @return bool + */ + public function generateAlias() + { + return false; + } + +} diff --git a/admin/tables/tag.php b/admin/tables/tag.php new file mode 100644 index 0000000..65617a0 --- /dev/null +++ b/admin/tables/tag.php @@ -0,0 +1,330 @@ + + @git Get Bible + @github Get Bible + @support Get Bible + @copyright Copyright (C) 2015. All Rights Reserved + @license GNU/GPL Version 2 or later - http://www.gnu.org/licenses/gpl-2.0.html + +/------------------------------------------------------------------------------------------------------*/ + +// No direct access to this file +defined('_JEXEC') or die('Restricted access'); + +use Joomla\CMS\Table\Table; +use Joomla\Registry\Registry; +use Joomla\String\StringHelper; +use Joomla\Utilities\ArrayHelper; + +/** + * Tags Table class + */ +class GetbibleTableTag extends Table +{ + /** + * Ensure the params and metadata in json encoded in the bind method + * + * @var array + * @since 3.3 + */ + protected $_jsonEncode = array('params', 'metadata'); + + /** + * Constructor + * + * @param object Database connector object + */ + function __construct(&$db) + { + parent::__construct('#__getbible_tag', 'id', $db); + + // Adding History Options + JTableObserverContenthistory::createObserver($this, array('typeAlias' => 'com_getbible.tag')); + } + + public function bind($array, $ignore = '') + { + + if (isset($array['params']) && is_array($array['params'])) + { + $registry = new JRegistry; + $registry->loadArray($array['params']); + $array['params'] = (string) $registry; + } + + if (isset($array['metadata']) && is_array($array['metadata'])) + { + $registry = new JRegistry; + $registry->loadArray($array['metadata']); + $array['metadata'] = (string) $registry; + } + + // Bind the rules. + if (isset($array['rules']) && is_array($array['rules'])) + { + $rules = new JAccessRules($array['rules']); + $this->setRules($rules); + } + return parent::bind($array, $ignore); + } + + /** + * Overload the store method for the Tag table. + * + * @param boolean Toggle whether null values should be updated. + * @return boolean True on success, false on failure. + * @since 1.6 + */ + public function store($updateNulls = false) + { + $date = JFactory::getDate(); + $user = JFactory::getUser(); + + if ($this->id) + { + // Existing item + $this->modified = $date->toSql(); + $this->modified_by = $user->get('id'); + } + else + { + // New tag. A tag created and created_by field can be set by the user, + // so we don't touch either of these if they are set. + if (!(int) $this->created) + { + $this->created = $date->toSql(); + } + if (empty($this->created_by)) + { + $this->created_by = $user->get('id'); + } + } + + if (isset($this->alias)) + { + // Verify that the alias is unique + $table = JTable::getInstance('tag', 'GetbibleTable'); + + if ($table->load(array('alias' => $this->alias)) && ($table->id != $this->id || $this->id == 0)) + { + $this->setError(JText::_('COM_GETBIBLE_TAG_ERROR_UNIQUE_ALIAS')); + return false; + } + } + + if (isset($this->url)) + { + // Convert IDN urls to punycode + $this->url = JStringPunycode::urlToPunycode($this->url); + } + if (isset($this->website)) + { + // Convert IDN urls to punycode + $this->website = JStringPunycode::urlToPunycode($this->website); + } + + return parent::store($updateNulls); + } + + /** + * Overloaded check method to ensure data integrity. + * + * @return boolean True on success. + */ + public function check() + { + if (isset($this->alias)) + { + // Generate a valid alias + $this->generateAlias(); + + $table = JTable::getInstance('tag', 'getbibleTable'); + + while ($table->load(array('alias' => $this->alias)) && ($table->id != $this->id || $this->id == 0)) + { + $this->alias = StringHelper::increment($this->alias, 'dash'); + } + } + + /* + * Clean up keywords -- eliminate extra spaces between phrases + * and cr (\r) and lf (\n) characters from string. + * Only process if not empty. + */ + if (!empty($this->metakey)) + { + // Array of characters to remove. + $bad_characters = array("\n", "\r", "\"", "<", ">"); + + // Remove bad characters. + $after_clean = StringHelper::str_ireplace($bad_characters, "", $this->metakey); + + // Create array using commas as delimiter. + $keys = explode(',', $after_clean); + $clean_keys = array(); + + foreach ($keys as $key) + { + // Ignore blank keywords. + if (trim($key)) + { + $clean_keys[] = trim($key); + } + } + + // Put array back together delimited by ", " + $this->metakey = implode(", ", $clean_keys); + } + + // Clean up description -- eliminate quotes and <> brackets + if (!empty($this->metadesc)) + { + // Only process if not empty + $bad_characters = array("\"", "<", ">"); + $this->metadesc = StringHelper::str_ireplace($bad_characters, "", $this->metadesc); + } + + // If we don't have any access rules set at this point just use an empty JAccessRules class + if (!$this->getRules()) + { + $rules = $this->getDefaultAssetValues('com_getbible.tag.'.$this->id); + $this->setRules($rules); + } + + // Set ordering + if ($this->published < 0) + { + // Set ordering to 0 if state is archived or trashed + $this->ordering = 0; + } + + return true; + } + + /** + * Gets the default asset values for a component. + * + * @param $string $component The component asset name to search for + * + * @return JAccessRules The JAccessRules object for the asset + */ + protected function getDefaultAssetValues($component, $try = true) + { + // Need to find the asset id by the name of the component. + $db = JFactory::getDbo(); + $query = $db->getQuery(true) + ->select($db->quoteName('id')) + ->from($db->quoteName('#__assets')) + ->where($db->quoteName('name') . ' = ' . $db->quote($component)); + $db->setQuery($query); + $db->execute(); + if ($db->loadRowList()) + { + // asset already set so use saved rules + $assetId = (int) $db->loadResult(); + return JAccess::getAssetRules($assetId); // (TODO) instead of keeping inherited Allowed it becomes Allowed. + } + // try again + elseif ($try) + { + $try = explode('.',$component); + $result = $this->getDefaultAssetValues($try[0], false); + if ($result instanceof JAccessRules) + { + if (isset($try[1])) + { + $_result = (string) $result; + $_result = json_decode($_result); + foreach ($_result as $name => &$rule) + { + $v = explode('.', $name); + if ($try[1] !== $v[0]) + { + // remove since it is not part of this view + unset($_result->$name); + } + else + { + // clear the value since we inherit + $rule = array(); + } + } + // check if there are any view values remaining + if (count( (array) $_result)) + { + $_result = json_encode($_result); + $_result = array($_result); + // Instantiate and return the JAccessRules object for the asset rules. + $rules = new JAccessRules; + $rules->mergeCollection($_result); + + return $rules; + } + } + return $result; + } + } + return JAccess::getAssetRules(0); + } + + /** + * Method to compute the default name of the asset. + * The default name is in the form 'table_name.id' + * where id is the value of the primary key of the table. + * + * @return string + * @since 2.5 + */ + protected function _getAssetName() + { + $k = $this->_tbl_key; + return 'com_getbible.tag.'.(int) $this->$k; + } + + /** + * Method to return the title to use for the asset table. + * + * @return string + * @since 2.5 + */ + protected function _getAssetTitle() + { + if (isset($this->title)) + { + return $this->title; + } + return ''; + } + + /** + * Get the parent asset id for the record + * + * @return int + * @since 2.5 + */ + protected function _getAssetParentId(JTable $table = NULL, $id = NULL) + { + $asset = JTable::getInstance('Asset'); + $asset->loadByName('com_getbible'); + + return $asset->id; + } + + /** + * This view does not actually have an alias + * + * @return bool + */ + public function generateAlias() + { + return false; + } + +} diff --git a/admin/tables/tagged_verse.php b/admin/tables/tagged_verse.php new file mode 100644 index 0000000..5208774 --- /dev/null +++ b/admin/tables/tagged_verse.php @@ -0,0 +1,330 @@ + + @git Get Bible + @github Get Bible + @support Get Bible + @copyright Copyright (C) 2015. All Rights Reserved + @license GNU/GPL Version 2 or later - http://www.gnu.org/licenses/gpl-2.0.html + +/------------------------------------------------------------------------------------------------------*/ + +// No direct access to this file +defined('_JEXEC') or die('Restricted access'); + +use Joomla\CMS\Table\Table; +use Joomla\Registry\Registry; +use Joomla\String\StringHelper; +use Joomla\Utilities\ArrayHelper; + +/** + * Tagged_verses Table class + */ +class GetbibleTableTagged_verse extends Table +{ + /** + * Ensure the params and metadata in json encoded in the bind method + * + * @var array + * @since 3.3 + */ + protected $_jsonEncode = array('params', 'metadata'); + + /** + * Constructor + * + * @param object Database connector object + */ + function __construct(&$db) + { + parent::__construct('#__getbible_tagged_verse', 'id', $db); + + // Adding History Options + JTableObserverContenthistory::createObserver($this, array('typeAlias' => 'com_getbible.tagged_verse')); + } + + public function bind($array, $ignore = '') + { + + if (isset($array['params']) && is_array($array['params'])) + { + $registry = new JRegistry; + $registry->loadArray($array['params']); + $array['params'] = (string) $registry; + } + + if (isset($array['metadata']) && is_array($array['metadata'])) + { + $registry = new JRegistry; + $registry->loadArray($array['metadata']); + $array['metadata'] = (string) $registry; + } + + // Bind the rules. + if (isset($array['rules']) && is_array($array['rules'])) + { + $rules = new JAccessRules($array['rules']); + $this->setRules($rules); + } + return parent::bind($array, $ignore); + } + + /** + * Overload the store method for the Tagged_verse table. + * + * @param boolean Toggle whether null values should be updated. + * @return boolean True on success, false on failure. + * @since 1.6 + */ + public function store($updateNulls = false) + { + $date = JFactory::getDate(); + $user = JFactory::getUser(); + + if ($this->id) + { + // Existing item + $this->modified = $date->toSql(); + $this->modified_by = $user->get('id'); + } + else + { + // New tagged_verse. A tagged_verse created and created_by field can be set by the user, + // so we don't touch either of these if they are set. + if (!(int) $this->created) + { + $this->created = $date->toSql(); + } + if (empty($this->created_by)) + { + $this->created_by = $user->get('id'); + } + } + + if (isset($this->alias)) + { + // Verify that the alias is unique + $table = JTable::getInstance('tagged_verse', 'GetbibleTable'); + + if ($table->load(array('alias' => $this->alias)) && ($table->id != $this->id || $this->id == 0)) + { + $this->setError(JText::_('COM_GETBIBLE_TAGGED_VERSE_ERROR_UNIQUE_ALIAS')); + return false; + } + } + + if (isset($this->url)) + { + // Convert IDN urls to punycode + $this->url = JStringPunycode::urlToPunycode($this->url); + } + if (isset($this->website)) + { + // Convert IDN urls to punycode + $this->website = JStringPunycode::urlToPunycode($this->website); + } + + return parent::store($updateNulls); + } + + /** + * Overloaded check method to ensure data integrity. + * + * @return boolean True on success. + */ + public function check() + { + if (isset($this->alias)) + { + // Generate a valid alias + $this->generateAlias(); + + $table = JTable::getInstance('tagged_verse', 'getbibleTable'); + + while ($table->load(array('alias' => $this->alias)) && ($table->id != $this->id || $this->id == 0)) + { + $this->alias = StringHelper::increment($this->alias, 'dash'); + } + } + + /* + * Clean up keywords -- eliminate extra spaces between phrases + * and cr (\r) and lf (\n) characters from string. + * Only process if not empty. + */ + if (!empty($this->metakey)) + { + // Array of characters to remove. + $bad_characters = array("\n", "\r", "\"", "<", ">"); + + // Remove bad characters. + $after_clean = StringHelper::str_ireplace($bad_characters, "", $this->metakey); + + // Create array using commas as delimiter. + $keys = explode(',', $after_clean); + $clean_keys = array(); + + foreach ($keys as $key) + { + // Ignore blank keywords. + if (trim($key)) + { + $clean_keys[] = trim($key); + } + } + + // Put array back together delimited by ", " + $this->metakey = implode(", ", $clean_keys); + } + + // Clean up description -- eliminate quotes and <> brackets + if (!empty($this->metadesc)) + { + // Only process if not empty + $bad_characters = array("\"", "<", ">"); + $this->metadesc = StringHelper::str_ireplace($bad_characters, "", $this->metadesc); + } + + // If we don't have any access rules set at this point just use an empty JAccessRules class + if (!$this->getRules()) + { + $rules = $this->getDefaultAssetValues('com_getbible.tagged_verse.'.$this->id); + $this->setRules($rules); + } + + // Set ordering + if ($this->published < 0) + { + // Set ordering to 0 if state is archived or trashed + $this->ordering = 0; + } + + return true; + } + + /** + * Gets the default asset values for a component. + * + * @param $string $component The component asset name to search for + * + * @return JAccessRules The JAccessRules object for the asset + */ + protected function getDefaultAssetValues($component, $try = true) + { + // Need to find the asset id by the name of the component. + $db = JFactory::getDbo(); + $query = $db->getQuery(true) + ->select($db->quoteName('id')) + ->from($db->quoteName('#__assets')) + ->where($db->quoteName('name') . ' = ' . $db->quote($component)); + $db->setQuery($query); + $db->execute(); + if ($db->loadRowList()) + { + // asset already set so use saved rules + $assetId = (int) $db->loadResult(); + return JAccess::getAssetRules($assetId); // (TODO) instead of keeping inherited Allowed it becomes Allowed. + } + // try again + elseif ($try) + { + $try = explode('.',$component); + $result = $this->getDefaultAssetValues($try[0], false); + if ($result instanceof JAccessRules) + { + if (isset($try[1])) + { + $_result = (string) $result; + $_result = json_decode($_result); + foreach ($_result as $name => &$rule) + { + $v = explode('.', $name); + if ($try[1] !== $v[0]) + { + // remove since it is not part of this view + unset($_result->$name); + } + else + { + // clear the value since we inherit + $rule = array(); + } + } + // check if there are any view values remaining + if (count( (array) $_result)) + { + $_result = json_encode($_result); + $_result = array($_result); + // Instantiate and return the JAccessRules object for the asset rules. + $rules = new JAccessRules; + $rules->mergeCollection($_result); + + return $rules; + } + } + return $result; + } + } + return JAccess::getAssetRules(0); + } + + /** + * Method to compute the default name of the asset. + * The default name is in the form 'table_name.id' + * where id is the value of the primary key of the table. + * + * @return string + * @since 2.5 + */ + protected function _getAssetName() + { + $k = $this->_tbl_key; + return 'com_getbible.tagged_verse.'.(int) $this->$k; + } + + /** + * Method to return the title to use for the asset table. + * + * @return string + * @since 2.5 + */ + protected function _getAssetTitle() + { + if (isset($this->title)) + { + return $this->title; + } + return ''; + } + + /** + * Get the parent asset id for the record + * + * @return int + * @since 2.5 + */ + protected function _getAssetParentId(JTable $table = NULL, $id = NULL) + { + $asset = JTable::getInstance('Asset'); + $asset->loadByName('com_getbible'); + + return $asset->id; + } + + /** + * This view does not actually have an alias + * + * @return bool + */ + public function generateAlias() + { + return false; + } + +} diff --git a/admin/tables/translation.php b/admin/tables/translation.php new file mode 100644 index 0000000..6113407 --- /dev/null +++ b/admin/tables/translation.php @@ -0,0 +1,327 @@ + + @git Get Bible + @github Get Bible + @support Get Bible + @copyright Copyright (C) 2015. All Rights Reserved + @license GNU/GPL Version 2 or later - http://www.gnu.org/licenses/gpl-2.0.html + +/------------------------------------------------------------------------------------------------------*/ + +// No direct access to this file +defined('_JEXEC') or die('Restricted access'); + +use Joomla\CMS\Table\Table; +use Joomla\Registry\Registry; +use Joomla\String\StringHelper; +use Joomla\Utilities\ArrayHelper; + +/** + * Translations Table class + */ +class GetbibleTableTranslation extends Table +{ + /** + * Ensure the params and metadata in json encoded in the bind method + * + * @var array + * @since 3.3 + */ + protected $_jsonEncode = array('params', 'metadata'); + + /** + * Constructor + * + * @param object Database connector object + */ + function __construct(&$db) + { + parent::__construct('#__getbible_translation', 'id', $db); + } + + public function bind($array, $ignore = '') + { + + if (isset($array['params']) && is_array($array['params'])) + { + $registry = new JRegistry; + $registry->loadArray($array['params']); + $array['params'] = (string) $registry; + } + + if (isset($array['metadata']) && is_array($array['metadata'])) + { + $registry = new JRegistry; + $registry->loadArray($array['metadata']); + $array['metadata'] = (string) $registry; + } + + // Bind the rules. + if (isset($array['rules']) && is_array($array['rules'])) + { + $rules = new JAccessRules($array['rules']); + $this->setRules($rules); + } + return parent::bind($array, $ignore); + } + + /** + * Overload the store method for the Translation table. + * + * @param boolean Toggle whether null values should be updated. + * @return boolean True on success, false on failure. + * @since 1.6 + */ + public function store($updateNulls = false) + { + $date = JFactory::getDate(); + $user = JFactory::getUser(); + + if ($this->id) + { + // Existing item + $this->modified = $date->toSql(); + $this->modified_by = $user->get('id'); + } + else + { + // New translation. A translation created and created_by field can be set by the user, + // so we don't touch either of these if they are set. + if (!(int) $this->created) + { + $this->created = $date->toSql(); + } + if (empty($this->created_by)) + { + $this->created_by = $user->get('id'); + } + } + + if (isset($this->alias)) + { + // Verify that the alias is unique + $table = JTable::getInstance('translation', 'GetbibleTable'); + + if ($table->load(array('alias' => $this->alias)) && ($table->id != $this->id || $this->id == 0)) + { + $this->setError(JText::_('COM_GETBIBLE_TRANSLATION_ERROR_UNIQUE_ALIAS')); + return false; + } + } + + if (isset($this->url)) + { + // Convert IDN urls to punycode + $this->url = JStringPunycode::urlToPunycode($this->url); + } + if (isset($this->website)) + { + // Convert IDN urls to punycode + $this->website = JStringPunycode::urlToPunycode($this->website); + } + + return parent::store($updateNulls); + } + + /** + * Overloaded check method to ensure data integrity. + * + * @return boolean True on success. + */ + public function check() + { + if (isset($this->alias)) + { + // Generate a valid alias + $this->generateAlias(); + + $table = JTable::getInstance('translation', 'getbibleTable'); + + while ($table->load(array('alias' => $this->alias)) && ($table->id != $this->id || $this->id == 0)) + { + $this->alias = StringHelper::increment($this->alias, 'dash'); + } + } + + /* + * Clean up keywords -- eliminate extra spaces between phrases + * and cr (\r) and lf (\n) characters from string. + * Only process if not empty. + */ + if (!empty($this->metakey)) + { + // Array of characters to remove. + $bad_characters = array("\n", "\r", "\"", "<", ">"); + + // Remove bad characters. + $after_clean = StringHelper::str_ireplace($bad_characters, "", $this->metakey); + + // Create array using commas as delimiter. + $keys = explode(',', $after_clean); + $clean_keys = array(); + + foreach ($keys as $key) + { + // Ignore blank keywords. + if (trim($key)) + { + $clean_keys[] = trim($key); + } + } + + // Put array back together delimited by ", " + $this->metakey = implode(", ", $clean_keys); + } + + // Clean up description -- eliminate quotes and <> brackets + if (!empty($this->metadesc)) + { + // Only process if not empty + $bad_characters = array("\"", "<", ">"); + $this->metadesc = StringHelper::str_ireplace($bad_characters, "", $this->metadesc); + } + + // If we don't have any access rules set at this point just use an empty JAccessRules class + if (!$this->getRules()) + { + $rules = $this->getDefaultAssetValues('com_getbible.translation.'.$this->id); + $this->setRules($rules); + } + + // Set ordering + if ($this->published < 0) + { + // Set ordering to 0 if state is archived or trashed + $this->ordering = 0; + } + + return true; + } + + /** + * Gets the default asset values for a component. + * + * @param $string $component The component asset name to search for + * + * @return JAccessRules The JAccessRules object for the asset + */ + protected function getDefaultAssetValues($component, $try = true) + { + // Need to find the asset id by the name of the component. + $db = JFactory::getDbo(); + $query = $db->getQuery(true) + ->select($db->quoteName('id')) + ->from($db->quoteName('#__assets')) + ->where($db->quoteName('name') . ' = ' . $db->quote($component)); + $db->setQuery($query); + $db->execute(); + if ($db->loadRowList()) + { + // asset already set so use saved rules + $assetId = (int) $db->loadResult(); + return JAccess::getAssetRules($assetId); // (TODO) instead of keeping inherited Allowed it becomes Allowed. + } + // try again + elseif ($try) + { + $try = explode('.',$component); + $result = $this->getDefaultAssetValues($try[0], false); + if ($result instanceof JAccessRules) + { + if (isset($try[1])) + { + $_result = (string) $result; + $_result = json_decode($_result); + foreach ($_result as $name => &$rule) + { + $v = explode('.', $name); + if ($try[1] !== $v[0]) + { + // remove since it is not part of this view + unset($_result->$name); + } + else + { + // clear the value since we inherit + $rule = array(); + } + } + // check if there are any view values remaining + if (count( (array) $_result)) + { + $_result = json_encode($_result); + $_result = array($_result); + // Instantiate and return the JAccessRules object for the asset rules. + $rules = new JAccessRules; + $rules->mergeCollection($_result); + + return $rules; + } + } + return $result; + } + } + return JAccess::getAssetRules(0); + } + + /** + * Method to compute the default name of the asset. + * The default name is in the form 'table_name.id' + * where id is the value of the primary key of the table. + * + * @return string + * @since 2.5 + */ + protected function _getAssetName() + { + $k = $this->_tbl_key; + return 'com_getbible.translation.'.(int) $this->$k; + } + + /** + * Method to return the title to use for the asset table. + * + * @return string + * @since 2.5 + */ + protected function _getAssetTitle() + { + if (isset($this->title)) + { + return $this->title; + } + return ''; + } + + /** + * Get the parent asset id for the record + * + * @return int + * @since 2.5 + */ + protected function _getAssetParentId(JTable $table = NULL, $id = NULL) + { + $asset = JTable::getInstance('Asset'); + $asset->loadByName('com_getbible'); + + return $asset->id; + } + + /** + * This view does not actually have an alias + * + * @return bool + */ + public function generateAlias() + { + return false; + } + +} diff --git a/admin/tables/verse.php b/admin/tables/verse.php new file mode 100644 index 0000000..5ca405b --- /dev/null +++ b/admin/tables/verse.php @@ -0,0 +1,327 @@ + + @git Get Bible + @github Get Bible + @support Get Bible + @copyright Copyright (C) 2015. All Rights Reserved + @license GNU/GPL Version 2 or later - http://www.gnu.org/licenses/gpl-2.0.html + +/------------------------------------------------------------------------------------------------------*/ + +// No direct access to this file +defined('_JEXEC') or die('Restricted access'); + +use Joomla\CMS\Table\Table; +use Joomla\Registry\Registry; +use Joomla\String\StringHelper; +use Joomla\Utilities\ArrayHelper; + +/** + * Verses Table class + */ +class GetbibleTableVerse extends Table +{ + /** + * Ensure the params and metadata in json encoded in the bind method + * + * @var array + * @since 3.3 + */ + protected $_jsonEncode = array('params', 'metadata'); + + /** + * Constructor + * + * @param object Database connector object + */ + function __construct(&$db) + { + parent::__construct('#__getbible_verse', 'id', $db); + } + + public function bind($array, $ignore = '') + { + + if (isset($array['params']) && is_array($array['params'])) + { + $registry = new JRegistry; + $registry->loadArray($array['params']); + $array['params'] = (string) $registry; + } + + if (isset($array['metadata']) && is_array($array['metadata'])) + { + $registry = new JRegistry; + $registry->loadArray($array['metadata']); + $array['metadata'] = (string) $registry; + } + + // Bind the rules. + if (isset($array['rules']) && is_array($array['rules'])) + { + $rules = new JAccessRules($array['rules']); + $this->setRules($rules); + } + return parent::bind($array, $ignore); + } + + /** + * Overload the store method for the Verse table. + * + * @param boolean Toggle whether null values should be updated. + * @return boolean True on success, false on failure. + * @since 1.6 + */ + public function store($updateNulls = false) + { + $date = JFactory::getDate(); + $user = JFactory::getUser(); + + if ($this->id) + { + // Existing item + $this->modified = $date->toSql(); + $this->modified_by = $user->get('id'); + } + else + { + // New verse. A verse created and created_by field can be set by the user, + // so we don't touch either of these if they are set. + if (!(int) $this->created) + { + $this->created = $date->toSql(); + } + if (empty($this->created_by)) + { + $this->created_by = $user->get('id'); + } + } + + if (isset($this->alias)) + { + // Verify that the alias is unique + $table = JTable::getInstance('verse', 'GetbibleTable'); + + if ($table->load(array('alias' => $this->alias)) && ($table->id != $this->id || $this->id == 0)) + { + $this->setError(JText::_('COM_GETBIBLE_VERSE_ERROR_UNIQUE_ALIAS')); + return false; + } + } + + if (isset($this->url)) + { + // Convert IDN urls to punycode + $this->url = JStringPunycode::urlToPunycode($this->url); + } + if (isset($this->website)) + { + // Convert IDN urls to punycode + $this->website = JStringPunycode::urlToPunycode($this->website); + } + + return parent::store($updateNulls); + } + + /** + * Overloaded check method to ensure data integrity. + * + * @return boolean True on success. + */ + public function check() + { + if (isset($this->alias)) + { + // Generate a valid alias + $this->generateAlias(); + + $table = JTable::getInstance('verse', 'getbibleTable'); + + while ($table->load(array('alias' => $this->alias)) && ($table->id != $this->id || $this->id == 0)) + { + $this->alias = StringHelper::increment($this->alias, 'dash'); + } + } + + /* + * Clean up keywords -- eliminate extra spaces between phrases + * and cr (\r) and lf (\n) characters from string. + * Only process if not empty. + */ + if (!empty($this->metakey)) + { + // Array of characters to remove. + $bad_characters = array("\n", "\r", "\"", "<", ">"); + + // Remove bad characters. + $after_clean = StringHelper::str_ireplace($bad_characters, "", $this->metakey); + + // Create array using commas as delimiter. + $keys = explode(',', $after_clean); + $clean_keys = array(); + + foreach ($keys as $key) + { + // Ignore blank keywords. + if (trim($key)) + { + $clean_keys[] = trim($key); + } + } + + // Put array back together delimited by ", " + $this->metakey = implode(", ", $clean_keys); + } + + // Clean up description -- eliminate quotes and <> brackets + if (!empty($this->metadesc)) + { + // Only process if not empty + $bad_characters = array("\"", "<", ">"); + $this->metadesc = StringHelper::str_ireplace($bad_characters, "", $this->metadesc); + } + + // If we don't have any access rules set at this point just use an empty JAccessRules class + if (!$this->getRules()) + { + $rules = $this->getDefaultAssetValues('com_getbible.verse.'.$this->id); + $this->setRules($rules); + } + + // Set ordering + if ($this->published < 0) + { + // Set ordering to 0 if state is archived or trashed + $this->ordering = 0; + } + + return true; + } + + /** + * Gets the default asset values for a component. + * + * @param $string $component The component asset name to search for + * + * @return JAccessRules The JAccessRules object for the asset + */ + protected function getDefaultAssetValues($component, $try = true) + { + // Need to find the asset id by the name of the component. + $db = JFactory::getDbo(); + $query = $db->getQuery(true) + ->select($db->quoteName('id')) + ->from($db->quoteName('#__assets')) + ->where($db->quoteName('name') . ' = ' . $db->quote($component)); + $db->setQuery($query); + $db->execute(); + if ($db->loadRowList()) + { + // asset already set so use saved rules + $assetId = (int) $db->loadResult(); + return JAccess::getAssetRules($assetId); // (TODO) instead of keeping inherited Allowed it becomes Allowed. + } + // try again + elseif ($try) + { + $try = explode('.',$component); + $result = $this->getDefaultAssetValues($try[0], false); + if ($result instanceof JAccessRules) + { + if (isset($try[1])) + { + $_result = (string) $result; + $_result = json_decode($_result); + foreach ($_result as $name => &$rule) + { + $v = explode('.', $name); + if ($try[1] !== $v[0]) + { + // remove since it is not part of this view + unset($_result->$name); + } + else + { + // clear the value since we inherit + $rule = array(); + } + } + // check if there are any view values remaining + if (count( (array) $_result)) + { + $_result = json_encode($_result); + $_result = array($_result); + // Instantiate and return the JAccessRules object for the asset rules. + $rules = new JAccessRules; + $rules->mergeCollection($_result); + + return $rules; + } + } + return $result; + } + } + return JAccess::getAssetRules(0); + } + + /** + * Method to compute the default name of the asset. + * The default name is in the form 'table_name.id' + * where id is the value of the primary key of the table. + * + * @return string + * @since 2.5 + */ + protected function _getAssetName() + { + $k = $this->_tbl_key; + return 'com_getbible.verse.'.(int) $this->$k; + } + + /** + * Method to return the title to use for the asset table. + * + * @return string + * @since 2.5 + */ + protected function _getAssetTitle() + { + if (isset($this->title)) + { + return $this->title; + } + return ''; + } + + /** + * Get the parent asset id for the record + * + * @return int + * @since 2.5 + */ + protected function _getAssetParentId(JTable $table = NULL, $id = NULL) + { + $asset = JTable::getInstance('Asset'); + $asset->loadByName('com_getbible'); + + return $asset->id; + } + + /** + * This view does not actually have an alias + * + * @return bool + */ + public function generateAlias() + { + return false; + } + +} diff --git a/admin/views/book/submitbutton.js b/admin/views/book/submitbutton.js new file mode 100644 index 0000000..e9bf89d --- /dev/null +++ b/admin/views/book/submitbutton.js @@ -0,0 +1,31 @@ +/*----------------------------------------------------------------------------------| io.vdm.dev |----/ + Vast Development Method +/-------------------------------------------------------------------------------------------------------/ + + @package getBible.net + + @created 3rd December, 2015 + @author Llewellyn van der Merwe + @git Get Bible + @github Get Bible + @support Get Bible + @copyright Copyright (C) 2015. All Rights Reserved + @license GNU/GPL Version 2 or later - http://www.gnu.org/licenses/gpl-2.0.html + +/------------------------------------------------------------------------------------------------------*/ + +Joomla.submitbutton = function(task) +{ + if (task == ''){ + return false; + } else { + var action = task.split('.'); + if (action[1] == 'cancel' || action[1] == 'close' || document.formvalidator.isValid(document.getElementById("adminForm"))){ + Joomla.submitform(task, document.getElementById("adminForm")); + return true; + } else { + alert(Joomla.JText._('book, some values are not acceptable.','Some values are unacceptable')); + return false; + } + } +} \ No newline at end of file diff --git a/admin/views/book/tmpl/edit.php b/admin/views/book/tmpl/edit.php new file mode 100644 index 0000000..96da247 --- /dev/null +++ b/admin/views/book/tmpl/edit.php @@ -0,0 +1,112 @@ + + @git Get Bible + @github Get Bible + @support Get Bible + @copyright Copyright (C) 2015. All Rights Reserved + @license GNU/GPL Version 2 or later - http://www.gnu.org/licenses/gpl-2.0.html + +/------------------------------------------------------------------------------------------------------*/ + +// No direct access to this file +defined('_JEXEC') or die('Restricted access'); + +JHtml::addIncludePath(JPATH_COMPONENT.'/helpers/html'); +JHtml::_('behavior.formvalidator'); +JHtml::_('formbehavior.chosen', 'select'); +JHtml::_('behavior.keepalive'); +$componentParams = $this->params; // will be removed just use $this->params instead +?> + + diff --git a/admin/views/book/tmpl/index.html b/admin/views/book/tmpl/index.html new file mode 100644 index 0000000..fa6d84e --- /dev/null +++ b/admin/views/book/tmpl/index.html @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/admin/views/book/view.html.php b/admin/views/book/view.html.php new file mode 100644 index 0000000..7e5552e --- /dev/null +++ b/admin/views/book/view.html.php @@ -0,0 +1,130 @@ + + @git Get Bible + @github Get Bible + @support Get Bible + @copyright Copyright (C) 2015. All Rights Reserved + @license GNU/GPL Version 2 or later - http://www.gnu.org/licenses/gpl-2.0.html + +/------------------------------------------------------------------------------------------------------*/ + +// No direct access to this file +defined('_JEXEC') or die('Restricted access'); + +use Joomla\CMS\MVC\View\HtmlView; + +/** + * Book Html View class + */ +class GetbibleViewBook extends HtmlView +{ + /** + * display method of View + * @return void + */ + public function display($tpl = null) + { + // set params + $this->params = JComponentHelper::getParams('com_getbible'); + // Assign the variables + $this->form = $this->get('Form'); + $this->item = $this->get('Item'); + $this->script = $this->get('Script'); + $this->state = $this->get('State'); + // get action permissions + $this->canDo = GetbibleHelper::getActions('book', $this->item); + // get input + $jinput = JFactory::getApplication()->input; + $this->ref = $jinput->get('ref', 0, 'word'); + $this->refid = $jinput->get('refid', 0, 'int'); + $return = $jinput->get('return', null, 'base64'); + // set the referral string + $this->referral = ''; + if ($this->refid && $this->ref) + { + // return to the item that referred to this item + $this->referral = '&ref=' . (string)$this->ref . '&refid=' . (int)$this->refid; + } + elseif($this->ref) + { + // return to the list view that referred to this item + $this->referral = '&ref=' . (string)$this->ref; + } + // check return value + if (!is_null($return)) + { + // add the return value + $this->referral .= '&return=' . (string)$return; + } + + // Set the toolbar + $this->addToolBar(); + + // Check for errors. + if (count($errors = $this->get('Errors'))) + { + throw new Exception(implode("\n", $errors), 500); + } + + // Display the template + parent::display($tpl); + + // Set the document + $this->setDocument(); + } + + + /** + * Setting the toolbar + */ + protected function addToolBar() + { + JFactory::getApplication()->input->set('hidemainmenu', true); + JToolBarHelper::title(JText::_('COM_GETBIBLE_BOOK_READONLY'), 'book'); + JToolBarHelper::cancel('book.cancel', 'JTOOLBAR_CLOSE'); + } + + /** + * Escapes a value for output in a view script. + * + * @param mixed $var The output to escape. + * + * @return mixed The escaped value. + */ + public function escape($var) + { + if(strlen($var) > 30) + { + // use the helper htmlEscape method instead and shorten the string + return GetbibleHelper::htmlEscape($var, $this->_charset, true, 30); + } + // use the helper htmlEscape method instead. + return GetbibleHelper::htmlEscape($var, $this->_charset); + } + + /** + * Method to set up the document properties + * + * @return void + */ + protected function setDocument() + { + $isNew = ($this->item->id < 1); + if (!isset($this->document)) + { + $this->document = JFactory::getDocument(); + } + $this->document->setTitle(JText::_($isNew ? 'COM_GETBIBLE_BOOK_NEW' : 'COM_GETBIBLE_BOOK_EDIT')); + $this->document->addStyleSheet(JURI::root() . "administrator/components/com_getbible/assets/css/book.css", (GetbibleHelper::jVersion()->isCompatible('3.8.0')) ? array('version' => 'auto') : 'text/css'); + $this->document->addScript(JURI::root() . $this->script, (GetbibleHelper::jVersion()->isCompatible('3.8.0')) ? array('version' => 'auto') : 'text/javascript'); + $this->document->addScript(JURI::root() . "administrator/components/com_getbible/views/book/submitbutton.js", (GetbibleHelper::jVersion()->isCompatible('3.8.0')) ? array('version' => 'auto') : 'text/javascript'); + JText::script('view not acceptable. Error'); + } +} diff --git a/admin/views/books/index.html b/admin/views/books/index.html new file mode 100644 index 0000000..fa6d84e --- /dev/null +++ b/admin/views/books/index.html @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/admin/views/books/tmpl/default.php b/admin/views/books/tmpl/default.php new file mode 100644 index 0000000..f52c2a0 --- /dev/null +++ b/admin/views/books/tmpl/default.php @@ -0,0 +1,73 @@ + + @git Get Bible + @github Get Bible + @support Get Bible + @copyright Copyright (C) 2015. All Rights Reserved + @license GNU/GPL Version 2 or later - http://www.gnu.org/licenses/gpl-2.0.html + +/------------------------------------------------------------------------------------------------------*/ + +// No direct access to this file +defined('_JEXEC') or die('Restricted access'); + +JHtml::_('behavior.multiselect'); +JHtml::_('dropdown.init'); +JHtml::_('formbehavior.chosen', '.multipleAccessLevels', null, array('placeholder_text_multiple' => '- ' . JText::_('COM_GETBIBLE_FILTER_SELECT_ACCESS') . ' -')); +JHtml::_('formbehavior.chosen', 'select'); +if ($this->saveOrder) +{ + $saveOrderingUrl = 'index.php?option=com_getbible&task=books.saveOrderAjax&tmpl=component'; + JHtml::_('sortablelist.sortable', 'bookList', 'adminForm', strtolower($this->listDirn), $saveOrderingUrl); +} +?> +
+sidebar)): ?> +
+ sidebar; ?> +
+
+ +
+ + $this)); +?> +items)): ?> +
+ +
+ + + loadTemplate('head');?> + loadTemplate('foot');?> + loadTemplate('body');?> +
+ + canCreate && $this->canEdit) : ?> + JText::_('COM_GETBIBLE_BOOKS_BATCH_OPTIONS'), + 'footer' => $this->loadTemplate('batch_footer') + ), + $this->loadTemplate('batch_body') + ); ?> + + +
+ + + + diff --git a/admin/views/books/tmpl/default_batch_body.php b/admin/views/books/tmpl/default_batch_body.php new file mode 100644 index 0000000..d6441cd --- /dev/null +++ b/admin/views/books/tmpl/default_batch_body.php @@ -0,0 +1,24 @@ + + @git Get Bible + @github Get Bible + @support Get Bible + @copyright Copyright (C) 2015. All Rights Reserved + @license GNU/GPL Version 2 or later - http://www.gnu.org/licenses/gpl-2.0.html + +/------------------------------------------------------------------------------------------------------*/ + +// No direct access to this file +defined('_JEXEC') or die('Restricted access'); + +?> + +

+batchDisplay; ?> \ No newline at end of file diff --git a/admin/views/books/tmpl/default_batch_footer.php b/admin/views/books/tmpl/default_batch_footer.php new file mode 100644 index 0000000..09516d7 --- /dev/null +++ b/admin/views/books/tmpl/default_batch_footer.php @@ -0,0 +1,29 @@ + + @git Get Bible + @github Get Bible + @support Get Bible + @copyright Copyright (C) 2015. All Rights Reserved + @license GNU/GPL Version 2 or later - http://www.gnu.org/licenses/gpl-2.0.html + +/------------------------------------------------------------------------------------------------------*/ + +// No direct access to this file +defined('_JEXEC') or die('Restricted access'); + +?> + + + + \ No newline at end of file diff --git a/admin/views/books/tmpl/default_body.php b/admin/views/books/tmpl/default_body.php new file mode 100644 index 0000000..a74aa3d --- /dev/null +++ b/admin/views/books/tmpl/default_body.php @@ -0,0 +1,109 @@ + + @git Get Bible + @github Get Bible + @support Get Bible + @copyright Copyright (C) 2015. All Rights Reserved + @license GNU/GPL Version 2 or later - http://www.gnu.org/licenses/gpl-2.0.html + +/------------------------------------------------------------------------------------------------------*/ + +// No direct access to this file +defined('_JEXEC') or die('Restricted access'); + +$edit = "index.php?option=com_getbible&view=books&task=book.edit"; + +?> +items as $i => $item): ?> + user->authorise('core.manage', 'com_checkin') || $item->checked_out == $this->user->id || $item->checked_out == 0; + $userChkOut = JFactory::getUser($item->checked_out); + $canDo = GetbibleHelper::getActions('book',$item,'books'); + ?> + + + get('book.edit.state')): ?> + saveOrder) + { + $iconClass = ' inactive tip-top" hasTooltip" title="' . JHtml::tooltipText('JORDERINGDISABLED'); + } + ?> + + + + saveOrder) : ?> + + + + ⋮ + + + + get('book.edit')): ?> + checked_out) : ?> + + id); ?> + + □ + + + id); ?> + + + □ + + + +
+ get('book.edit')): ?> + escape($item->name); ?> + checked_out): ?> + name, $item->checked_out_time, 'books.', $canCheckin); ?> + + + escape($item->name); ?> + +
+ + +
+ user->authorise('translation.edit', 'com_getbible.translation.' . (int) $item->abbreviation_id)): ?> + escape($item->abbreviation_translation); ?> + + escape($item->abbreviation_translation); ?> + +
+ + + escape($item->nr); ?> + + + get('book.edit.state')) : ?> + checked_out) : ?> + + published, $i, 'books.', true, 'cb'); ?> + + published, $i, 'books.', false, 'cb'); ?> + + + published, $i, 'books.', true, 'cb'); ?> + + + published, $i, 'books.', false, 'cb'); ?> + + + + id; ?> + + + \ No newline at end of file diff --git a/admin/views/books/tmpl/default_foot.php b/admin/views/books/tmpl/default_foot.php new file mode 100644 index 0000000..38a928f --- /dev/null +++ b/admin/views/books/tmpl/default_foot.php @@ -0,0 +1,24 @@ + + @git Get Bible + @github Get Bible + @support Get Bible + @copyright Copyright (C) 2015. All Rights Reserved + @license GNU/GPL Version 2 or later - http://www.gnu.org/licenses/gpl-2.0.html + +/------------------------------------------------------------------------------------------------------*/ + +// No direct access to this file +defined('_JEXEC') or die('Restricted access'); + +?> + + pagination->getListFooter(); ?> + \ No newline at end of file diff --git a/admin/views/books/tmpl/default_head.php b/admin/views/books/tmpl/default_head.php new file mode 100644 index 0000000..c1309ee --- /dev/null +++ b/admin/views/books/tmpl/default_head.php @@ -0,0 +1,59 @@ + + @git Get Bible + @github Get Bible + @support Get Bible + @copyright Copyright (C) 2015. All Rights Reserved + @license GNU/GPL Version 2 or later - http://www.gnu.org/licenses/gpl-2.0.html + +/------------------------------------------------------------------------------------------------------*/ + +// No direct access to this file +defined('_JEXEC') or die('Restricted access'); + +?> + + canEdit&& $this->canState): ?> + + listDirn, $this->listOrder, null, 'asc', 'JGRID_HEADING_ORDERING', 'icon-menu-2'); ?> + + + + + + + ▾ + + + ■ + + + + listDirn, $this->listOrder); ?> + + + listDirn, $this->listOrder); ?> + + + listDirn, $this->listOrder); ?> + + canState): ?> + + listDirn, $this->listOrder); ?> + + + + + + + + listDirn, $this->listOrder); ?> + + \ No newline at end of file diff --git a/admin/views/books/tmpl/default_toolbar.php b/admin/views/books/tmpl/default_toolbar.php new file mode 100644 index 0000000..7aa3e61 --- /dev/null +++ b/admin/views/books/tmpl/default_toolbar.php @@ -0,0 +1,51 @@ + + @git Get Bible + @github Get Bible + @support Get Bible + @copyright Copyright (C) 2015. All Rights Reserved + @license GNU/GPL Version 2 or later - http://www.gnu.org/licenses/gpl-2.0.html + +/------------------------------------------------------------------------------------------------------*/ + +// No direct access to this file +defined('_JEXEC') or die('Restricted access'); + +?> +
+ +
+ + +
+
+ + pagination->getLimitBox(); ?> +
+
+ + +
+
+ + +
+
+
\ No newline at end of file diff --git a/admin/views/books/tmpl/index.html b/admin/views/books/tmpl/index.html new file mode 100644 index 0000000..fa6d84e --- /dev/null +++ b/admin/views/books/tmpl/index.html @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/admin/views/books/view.html.php b/admin/views/books/view.html.php new file mode 100644 index 0000000..3e030cd --- /dev/null +++ b/admin/views/books/view.html.php @@ -0,0 +1,289 @@ + + @git Get Bible + @github Get Bible + @support Get Bible + @copyright Copyright (C) 2015. All Rights Reserved + @license GNU/GPL Version 2 or later - http://www.gnu.org/licenses/gpl-2.0.html + +/------------------------------------------------------------------------------------------------------*/ + +// No direct access to this file +defined('_JEXEC') or die('Restricted access'); + +use Joomla\CMS\MVC\View\HtmlView; + +/** + * Getbible Html View class for the Books + */ +class GetbibleViewBooks extends HtmlView +{ + /** + * Books view display method + * @return void + */ + function display($tpl = null) + { + if ($this->getLayout() !== 'modal') + { + // Include helper submenu + GetbibleHelper::addSubmenu('books'); + } + + // Assign data to the view + $this->items = $this->get('Items'); + $this->pagination = $this->get('Pagination'); + $this->state = $this->get('State'); + $this->user = JFactory::getUser(); + // Load the filter form from xml. + $this->filterForm = $this->get('FilterForm'); + // Load the active filters. + $this->activeFilters = $this->get('ActiveFilters'); + // Add the list ordering clause. + $this->listOrder = $this->escape($this->state->get('list.ordering', 'a.id')); + $this->listDirn = $this->escape($this->state->get('list.direction', 'DESC')); + $this->saveOrder = $this->listOrder == 'a.ordering'; + // set the return here value + $this->return_here = urlencode(base64_encode((string) JUri::getInstance())); + // get global action permissions + $this->canDo = GetbibleHelper::getActions('book'); + $this->canEdit = $this->canDo->get('book.edit'); + $this->canState = $this->canDo->get('book.edit.state'); + $this->canCreate = $this->canDo->get('book.create'); + $this->canDelete = $this->canDo->get('book.delete'); + $this->canBatch = $this->canDo->get('core.batch'); + + // We don't need toolbar in the modal window. + if ($this->getLayout() !== 'modal') + { + $this->addToolbar(); + $this->sidebar = JHtmlSidebar::render(); + // load the batch html + if ($this->canCreate && $this->canEdit && $this->canState) + { + $this->batchDisplay = JHtmlBatch_::render(); + } + } + + // Check for errors. + if (count($errors = $this->get('Errors'))) + { + throw new Exception(implode("\n", $errors), 500); + } + + // Display the template + parent::display($tpl); + + // Set the document + $this->setDocument(); + } + + /** + * Setting the toolbar + */ + protected function addToolBar() + { + JToolBarHelper::title(JText::_('COM_GETBIBLE_BOOKS'), 'generic'); + JHtmlSidebar::setAction('index.php?option=com_getbible&view=books'); + JFormHelper::addFieldPath(JPATH_COMPONENT . '/models/fields'); + + if ($this->canCreate) + { + JToolBarHelper::addNew('book.add'); + } + + // Only load if there are items + if (GetbibleHelper::checkArray($this->items)) + { + if ($this->canEdit) + { + JToolBarHelper::editList('book.edit'); + } + + if ($this->canState) + { + JToolBarHelper::publishList('books.publish'); + JToolBarHelper::unpublishList('books.unpublish'); + JToolBarHelper::archiveList('books.archive'); + + if ($this->canDo->get('core.admin')) + { + JToolBarHelper::checkin('books.checkin'); + } + } + + // Add a batch button + if ($this->canBatch && $this->canCreate && $this->canEdit && $this->canState) + { + // Get the toolbar object instance + $bar = JToolBar::getInstance('toolbar'); + // set the batch button name + $title = JText::_('JTOOLBAR_BATCH'); + // Instantiate a new JLayoutFile instance and render the batch button + $layout = new JLayoutFile('joomla.toolbar.batch'); + // add the button to the page + $dhtml = $layout->render(array('title' => $title)); + $bar->appendButton('Custom', $dhtml, 'batch'); + } + + if ($this->state->get('filter.published') == -2 && ($this->canState && $this->canDelete)) + { + JToolbarHelper::deleteList('', 'books.delete', 'JTOOLBAR_EMPTY_TRASH'); + } + elseif ($this->canState && $this->canDelete) + { + JToolbarHelper::trash('books.trash'); + } + } + + // set help url for this view if found + $this->help_url = GetbibleHelper::getHelpUrl('books'); + if (GetbibleHelper::checkString($this->help_url)) + { + JToolbarHelper::help('COM_GETBIBLE_HELP_MANAGER', false, $this->help_url); + } + + // add the options comp button + if ($this->canDo->get('core.admin') || $this->canDo->get('core.options')) + { + JToolBarHelper::preferences('com_getbible'); + } + + // Only load published batch if state and batch is allowed + if ($this->canState && $this->canBatch) + { + JHtmlBatch_::addListSelection( + JText::_('COM_GETBIBLE_KEEP_ORIGINAL_STATE'), + 'batch[published]', + JHtml::_('select.options', JHtml::_('jgrid.publishedOptions', array('all' => false)), 'value', 'text', '', true) + ); + } + + // Only load access batch if create, edit and batch is allowed + if ($this->canBatch && $this->canCreate && $this->canEdit) + { + JHtmlBatch_::addListSelection( + JText::_('COM_GETBIBLE_KEEP_ORIGINAL_ACCESS'), + 'batch[access]', + JHtml::_('select.options', JHtml::_('access.assetgroups'), 'value', 'text') + ); + } + + // Only load Name batch if create, edit, and batch is allowed + if ($this->canBatch && $this->canCreate && $this->canEdit) + { + // Set Name Selection + $this->nameOptions = JFormHelper::loadFieldType('booksfiltername')->options; + // We do some sanitation for Name filter + if (GetbibleHelper::checkArray($this->nameOptions) && + isset($this->nameOptions[0]->value) && + !GetbibleHelper::checkString($this->nameOptions[0]->value)) + { + unset($this->nameOptions[0]); + } + // Name Batch Selection + JHtmlBatch_::addListSelection( + '- Keep Original '.JText::_('COM_GETBIBLE_BOOK_NAME_LABEL').' -', + 'batch[name]', + JHtml::_('select.options', $this->nameOptions, 'value', 'text') + ); + } + + // Only load Abbreviation Translation batch if create, edit, and batch is allowed + if ($this->canBatch && $this->canCreate && $this->canEdit) + { + // Set Abbreviation Translation Selection + $this->abbreviationTranslationOptions = JFormHelper::loadFieldType('Translations')->options; + // We do some sanitation for Abbreviation Translation filter + if (GetbibleHelper::checkArray($this->abbreviationTranslationOptions) && + isset($this->abbreviationTranslationOptions[0]->value) && + !GetbibleHelper::checkString($this->abbreviationTranslationOptions[0]->value)) + { + unset($this->abbreviationTranslationOptions[0]); + } + // Abbreviation Translation Batch Selection + JHtmlBatch_::addListSelection( + '- Keep Original '.JText::_('COM_GETBIBLE_BOOK_ABBREVIATION_LABEL').' -', + 'batch[abbreviation]', + JHtml::_('select.options', $this->abbreviationTranslationOptions, 'value', 'text') + ); + } + + // Only load Nr batch if create, edit, and batch is allowed + if ($this->canBatch && $this->canCreate && $this->canEdit) + { + // Set Nr Selection + $this->nrOptions = JFormHelper::loadFieldType('booksfilternr')->options; + // We do some sanitation for Nr filter + if (GetbibleHelper::checkArray($this->nrOptions) && + isset($this->nrOptions[0]->value) && + !GetbibleHelper::checkString($this->nrOptions[0]->value)) + { + unset($this->nrOptions[0]); + } + // Nr Batch Selection + JHtmlBatch_::addListSelection( + '- Keep Original '.JText::_('COM_GETBIBLE_BOOK_NR_LABEL').' -', + 'batch[nr]', + JHtml::_('select.options', $this->nrOptions, 'value', 'text') + ); + } + } + + /** + * Method to set up the document properties + * + * @return void + */ + protected function setDocument() + { + if (!isset($this->document)) + { + $this->document = JFactory::getDocument(); + } + $this->document->setTitle(JText::_('COM_GETBIBLE_BOOKS')); + $this->document->addStyleSheet(JURI::root() . "administrator/components/com_getbible/assets/css/books.css", (GetbibleHelper::jVersion()->isCompatible('3.8.0')) ? array('version' => 'auto') : 'text/css'); + } + + /** + * Escapes a value for output in a view script. + * + * @param mixed $var The output to escape. + * + * @return mixed The escaped value. + */ + public function escape($var) + { + if(strlen($var) > 50) + { + // use the helper htmlEscape method instead and shorten the string + return GetbibleHelper::htmlEscape($var, $this->_charset, true); + } + // use the helper htmlEscape method instead. + return GetbibleHelper::htmlEscape($var, $this->_charset); + } + + /** + * Returns an array of fields the table can be sorted by + * + * @return array Array containing the field name to sort by as the key and display text as value + */ + protected function getSortFields() + { + return array( + 'a.ordering' => JText::_('JGRID_HEADING_ORDERING'), + 'a.published' => JText::_('JSTATUS'), + 'a.name' => JText::_('COM_GETBIBLE_BOOK_NAME_LABEL'), + 'g.translation' => JText::_('COM_GETBIBLE_BOOK_ABBREVIATION_LABEL'), + 'a.nr' => JText::_('COM_GETBIBLE_BOOK_NR_LABEL'), + 'a.id' => JText::_('JGRID_HEADING_ID') + ); + } +} diff --git a/admin/views/chapter/submitbutton.js b/admin/views/chapter/submitbutton.js new file mode 100644 index 0000000..cc7923e --- /dev/null +++ b/admin/views/chapter/submitbutton.js @@ -0,0 +1,31 @@ +/*----------------------------------------------------------------------------------| io.vdm.dev |----/ + Vast Development Method +/-------------------------------------------------------------------------------------------------------/ + + @package getBible.net + + @created 3rd December, 2015 + @author Llewellyn van der Merwe + @git Get Bible + @github Get Bible + @support Get Bible + @copyright Copyright (C) 2015. All Rights Reserved + @license GNU/GPL Version 2 or later - http://www.gnu.org/licenses/gpl-2.0.html + +/------------------------------------------------------------------------------------------------------*/ + +Joomla.submitbutton = function(task) +{ + if (task == ''){ + return false; + } else { + var action = task.split('.'); + if (action[1] == 'cancel' || action[1] == 'close' || document.formvalidator.isValid(document.getElementById("adminForm"))){ + Joomla.submitform(task, document.getElementById("adminForm")); + return true; + } else { + alert(Joomla.JText._('chapter, some values are not acceptable.','Some values are unacceptable')); + return false; + } + } +} \ No newline at end of file diff --git a/admin/views/chapter/tmpl/edit.php b/admin/views/chapter/tmpl/edit.php new file mode 100644 index 0000000..fd17978 --- /dev/null +++ b/admin/views/chapter/tmpl/edit.php @@ -0,0 +1,112 @@ + + @git Get Bible + @github Get Bible + @support Get Bible + @copyright Copyright (C) 2015. All Rights Reserved + @license GNU/GPL Version 2 or later - http://www.gnu.org/licenses/gpl-2.0.html + +/------------------------------------------------------------------------------------------------------*/ + +// No direct access to this file +defined('_JEXEC') or die('Restricted access'); + +JHtml::addIncludePath(JPATH_COMPONENT.'/helpers/html'); +JHtml::_('behavior.formvalidator'); +JHtml::_('formbehavior.chosen', 'select'); +JHtml::_('behavior.keepalive'); +$componentParams = $this->params; // will be removed just use $this->params instead +?> + + diff --git a/admin/views/chapter/tmpl/index.html b/admin/views/chapter/tmpl/index.html new file mode 100644 index 0000000..fa6d84e --- /dev/null +++ b/admin/views/chapter/tmpl/index.html @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/admin/views/chapter/view.html.php b/admin/views/chapter/view.html.php new file mode 100644 index 0000000..e8f90b9 --- /dev/null +++ b/admin/views/chapter/view.html.php @@ -0,0 +1,130 @@ + + @git Get Bible + @github Get Bible + @support Get Bible + @copyright Copyright (C) 2015. All Rights Reserved + @license GNU/GPL Version 2 or later - http://www.gnu.org/licenses/gpl-2.0.html + +/------------------------------------------------------------------------------------------------------*/ + +// No direct access to this file +defined('_JEXEC') or die('Restricted access'); + +use Joomla\CMS\MVC\View\HtmlView; + +/** + * Chapter Html View class + */ +class GetbibleViewChapter extends HtmlView +{ + /** + * display method of View + * @return void + */ + public function display($tpl = null) + { + // set params + $this->params = JComponentHelper::getParams('com_getbible'); + // Assign the variables + $this->form = $this->get('Form'); + $this->item = $this->get('Item'); + $this->script = $this->get('Script'); + $this->state = $this->get('State'); + // get action permissions + $this->canDo = GetbibleHelper::getActions('chapter', $this->item); + // get input + $jinput = JFactory::getApplication()->input; + $this->ref = $jinput->get('ref', 0, 'word'); + $this->refid = $jinput->get('refid', 0, 'int'); + $return = $jinput->get('return', null, 'base64'); + // set the referral string + $this->referral = ''; + if ($this->refid && $this->ref) + { + // return to the item that referred to this item + $this->referral = '&ref=' . (string)$this->ref . '&refid=' . (int)$this->refid; + } + elseif($this->ref) + { + // return to the list view that referred to this item + $this->referral = '&ref=' . (string)$this->ref; + } + // check return value + if (!is_null($return)) + { + // add the return value + $this->referral .= '&return=' . (string)$return; + } + + // Set the toolbar + $this->addToolBar(); + + // Check for errors. + if (count($errors = $this->get('Errors'))) + { + throw new Exception(implode("\n", $errors), 500); + } + + // Display the template + parent::display($tpl); + + // Set the document + $this->setDocument(); + } + + + /** + * Setting the toolbar + */ + protected function addToolBar() + { + JFactory::getApplication()->input->set('hidemainmenu', true); + JToolBarHelper::title(JText::_('COM_GETBIBLE_CHAPTER_READONLY'), 'chapter'); + JToolBarHelper::cancel('chapter.cancel', 'JTOOLBAR_CLOSE'); + } + + /** + * Escapes a value for output in a view script. + * + * @param mixed $var The output to escape. + * + * @return mixed The escaped value. + */ + public function escape($var) + { + if(strlen($var) > 30) + { + // use the helper htmlEscape method instead and shorten the string + return GetbibleHelper::htmlEscape($var, $this->_charset, true, 30); + } + // use the helper htmlEscape method instead. + return GetbibleHelper::htmlEscape($var, $this->_charset); + } + + /** + * Method to set up the document properties + * + * @return void + */ + protected function setDocument() + { + $isNew = ($this->item->id < 1); + if (!isset($this->document)) + { + $this->document = JFactory::getDocument(); + } + $this->document->setTitle(JText::_($isNew ? 'COM_GETBIBLE_CHAPTER_NEW' : 'COM_GETBIBLE_CHAPTER_EDIT')); + $this->document->addStyleSheet(JURI::root() . "administrator/components/com_getbible/assets/css/chapter.css", (GetbibleHelper::jVersion()->isCompatible('3.8.0')) ? array('version' => 'auto') : 'text/css'); + $this->document->addScript(JURI::root() . $this->script, (GetbibleHelper::jVersion()->isCompatible('3.8.0')) ? array('version' => 'auto') : 'text/javascript'); + $this->document->addScript(JURI::root() . "administrator/components/com_getbible/views/chapter/submitbutton.js", (GetbibleHelper::jVersion()->isCompatible('3.8.0')) ? array('version' => 'auto') : 'text/javascript'); + JText::script('view not acceptable. Error'); + } +} diff --git a/admin/views/chapters/index.html b/admin/views/chapters/index.html new file mode 100644 index 0000000..fa6d84e --- /dev/null +++ b/admin/views/chapters/index.html @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/admin/views/chapters/tmpl/default.php b/admin/views/chapters/tmpl/default.php new file mode 100644 index 0000000..ca05c5c --- /dev/null +++ b/admin/views/chapters/tmpl/default.php @@ -0,0 +1,75 @@ + + @git Get Bible + @github Get Bible + @support Get Bible + @copyright Copyright (C) 2015. All Rights Reserved + @license GNU/GPL Version 2 or later - http://www.gnu.org/licenses/gpl-2.0.html + +/------------------------------------------------------------------------------------------------------*/ + +// No direct access to this file +defined('_JEXEC') or die('Restricted access'); + +JHtml::_('behavior.multiselect'); +JHtml::_('dropdown.init'); +JHtml::_('formbehavior.chosen', '.multipleChaptersfilterchapter', null, array('placeholder_text_multiple' => '- ' . JText::_('COM_GETBIBLE_FILTER_SELECT_CHAPTER') . ' -')); +JHtml::_('formbehavior.chosen', '.multipleChaptersfilterbooknr', null, array('placeholder_text_multiple' => '- ' . JText::_('COM_GETBIBLE_FILTER_SELECT_BOOK_NUMBER') . ' -')); +JHtml::_('formbehavior.chosen', '.multipleAccessLevels', null, array('placeholder_text_multiple' => '- ' . JText::_('COM_GETBIBLE_FILTER_SELECT_ACCESS') . ' -')); +JHtml::_('formbehavior.chosen', 'select'); +if ($this->saveOrder) +{ + $saveOrderingUrl = 'index.php?option=com_getbible&task=chapters.saveOrderAjax&tmpl=component'; + JHtml::_('sortablelist.sortable', 'chapterList', 'adminForm', strtolower($this->listDirn), $saveOrderingUrl); +} +?> +
+sidebar)): ?> +
+ sidebar; ?> +
+
+ +
+ + $this)); +?> +items)): ?> +
+ +
+ + + loadTemplate('head');?> + loadTemplate('foot');?> + loadTemplate('body');?> +
+ + canCreate && $this->canEdit) : ?> + JText::_('COM_GETBIBLE_CHAPTERS_BATCH_OPTIONS'), + 'footer' => $this->loadTemplate('batch_footer') + ), + $this->loadTemplate('batch_body') + ); ?> + + +
+ + + + diff --git a/admin/views/chapters/tmpl/default_batch_body.php b/admin/views/chapters/tmpl/default_batch_body.php new file mode 100644 index 0000000..bfa6966 --- /dev/null +++ b/admin/views/chapters/tmpl/default_batch_body.php @@ -0,0 +1,24 @@ + + @git Get Bible + @github Get Bible + @support Get Bible + @copyright Copyright (C) 2015. All Rights Reserved + @license GNU/GPL Version 2 or later - http://www.gnu.org/licenses/gpl-2.0.html + +/------------------------------------------------------------------------------------------------------*/ + +// No direct access to this file +defined('_JEXEC') or die('Restricted access'); + +?> + +

+batchDisplay; ?> \ No newline at end of file diff --git a/admin/views/chapters/tmpl/default_batch_footer.php b/admin/views/chapters/tmpl/default_batch_footer.php new file mode 100644 index 0000000..fc887a4 --- /dev/null +++ b/admin/views/chapters/tmpl/default_batch_footer.php @@ -0,0 +1,29 @@ + + @git Get Bible + @github Get Bible + @support Get Bible + @copyright Copyright (C) 2015. All Rights Reserved + @license GNU/GPL Version 2 or later - http://www.gnu.org/licenses/gpl-2.0.html + +/------------------------------------------------------------------------------------------------------*/ + +// No direct access to this file +defined('_JEXEC') or die('Restricted access'); + +?> + + + + \ No newline at end of file diff --git a/admin/views/chapters/tmpl/default_body.php b/admin/views/chapters/tmpl/default_body.php new file mode 100644 index 0000000..d08e1aa --- /dev/null +++ b/admin/views/chapters/tmpl/default_body.php @@ -0,0 +1,112 @@ + + @git Get Bible + @github Get Bible + @support Get Bible + @copyright Copyright (C) 2015. All Rights Reserved + @license GNU/GPL Version 2 or later - http://www.gnu.org/licenses/gpl-2.0.html + +/------------------------------------------------------------------------------------------------------*/ + +// No direct access to this file +defined('_JEXEC') or die('Restricted access'); + +$edit = "index.php?option=com_getbible&view=chapters&task=chapter.edit"; + +?> +items as $i => $item): ?> + user->authorise('core.manage', 'com_checkin') || $item->checked_out == $this->user->id || $item->checked_out == 0; + $userChkOut = JFactory::getUser($item->checked_out); + $canDo = GetbibleHelper::getActions('chapter',$item,'chapters'); + ?> + + + get('chapter.edit.state')): ?> + saveOrder) + { + $iconClass = ' inactive tip-top" hasTooltip" title="' . JHtml::tooltipText('JORDERINGDISABLED'); + } + ?> + + + + saveOrder) : ?> + + + + ⋮ + + + + get('chapter.edit')): ?> + checked_out) : ?> + + id); ?> + + □ + + + id); ?> + + + □ + + + +
+ get('chapter.edit')): ?> + escape($item->name); ?> + checked_out): ?> + name, $item->checked_out_time, 'chapters.', $canCheckin); ?> + + + escape($item->name); ?> + +
+ + + escape($item->chapter); ?> + + + escape($item->book_nr); ?> + + +
+ user->authorise('translation.edit', 'com_getbible.translation.' . (int) $item->abbreviation_id)): ?> + escape($item->abbreviation_translation); ?> + + escape($item->abbreviation_translation); ?> + +
+ + + get('chapter.edit.state')) : ?> + checked_out) : ?> + + published, $i, 'chapters.', true, 'cb'); ?> + + published, $i, 'chapters.', false, 'cb'); ?> + + + published, $i, 'chapters.', true, 'cb'); ?> + + + published, $i, 'chapters.', false, 'cb'); ?> + + + + id; ?> + + + \ No newline at end of file diff --git a/admin/views/chapters/tmpl/default_foot.php b/admin/views/chapters/tmpl/default_foot.php new file mode 100644 index 0000000..290760a --- /dev/null +++ b/admin/views/chapters/tmpl/default_foot.php @@ -0,0 +1,24 @@ + + @git Get Bible + @github Get Bible + @support Get Bible + @copyright Copyright (C) 2015. All Rights Reserved + @license GNU/GPL Version 2 or later - http://www.gnu.org/licenses/gpl-2.0.html + +/------------------------------------------------------------------------------------------------------*/ + +// No direct access to this file +defined('_JEXEC') or die('Restricted access'); + +?> + + pagination->getListFooter(); ?> + \ No newline at end of file diff --git a/admin/views/chapters/tmpl/default_head.php b/admin/views/chapters/tmpl/default_head.php new file mode 100644 index 0000000..6b1fbd2 --- /dev/null +++ b/admin/views/chapters/tmpl/default_head.php @@ -0,0 +1,62 @@ + + @git Get Bible + @github Get Bible + @support Get Bible + @copyright Copyright (C) 2015. All Rights Reserved + @license GNU/GPL Version 2 or later - http://www.gnu.org/licenses/gpl-2.0.html + +/------------------------------------------------------------------------------------------------------*/ + +// No direct access to this file +defined('_JEXEC') or die('Restricted access'); + +?> + + canEdit&& $this->canState): ?> + + listDirn, $this->listOrder, null, 'asc', 'JGRID_HEADING_ORDERING', 'icon-menu-2'); ?> + + + + + + + ▾ + + + ■ + + + + listDirn, $this->listOrder); ?> + + + listDirn, $this->listOrder); ?> + + + listDirn, $this->listOrder); ?> + + + listDirn, $this->listOrder); ?> + + canState): ?> + + listDirn, $this->listOrder); ?> + + + + + + + + listDirn, $this->listOrder); ?> + + \ No newline at end of file diff --git a/admin/views/chapters/tmpl/default_toolbar.php b/admin/views/chapters/tmpl/default_toolbar.php new file mode 100644 index 0000000..a8c1773 --- /dev/null +++ b/admin/views/chapters/tmpl/default_toolbar.php @@ -0,0 +1,51 @@ + + @git Get Bible + @github Get Bible + @support Get Bible + @copyright Copyright (C) 2015. All Rights Reserved + @license GNU/GPL Version 2 or later - http://www.gnu.org/licenses/gpl-2.0.html + +/------------------------------------------------------------------------------------------------------*/ + +// No direct access to this file +defined('_JEXEC') or die('Restricted access'); + +?> +
+ +
+ + +
+
+ + pagination->getLimitBox(); ?> +
+
+ + +
+
+ + +
+
+
\ No newline at end of file diff --git a/admin/views/chapters/tmpl/index.html b/admin/views/chapters/tmpl/index.html new file mode 100644 index 0000000..fa6d84e --- /dev/null +++ b/admin/views/chapters/tmpl/index.html @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/admin/views/chapters/view.html.php b/admin/views/chapters/view.html.php new file mode 100644 index 0000000..e079e1d --- /dev/null +++ b/admin/views/chapters/view.html.php @@ -0,0 +1,290 @@ + + @git Get Bible + @github Get Bible + @support Get Bible + @copyright Copyright (C) 2015. All Rights Reserved + @license GNU/GPL Version 2 or later - http://www.gnu.org/licenses/gpl-2.0.html + +/------------------------------------------------------------------------------------------------------*/ + +// No direct access to this file +defined('_JEXEC') or die('Restricted access'); + +use Joomla\CMS\MVC\View\HtmlView; + +/** + * Getbible Html View class for the Chapters + */ +class GetbibleViewChapters extends HtmlView +{ + /** + * Chapters view display method + * @return void + */ + function display($tpl = null) + { + if ($this->getLayout() !== 'modal') + { + // Include helper submenu + GetbibleHelper::addSubmenu('chapters'); + } + + // Assign data to the view + $this->items = $this->get('Items'); + $this->pagination = $this->get('Pagination'); + $this->state = $this->get('State'); + $this->user = JFactory::getUser(); + // Load the filter form from xml. + $this->filterForm = $this->get('FilterForm'); + // Load the active filters. + $this->activeFilters = $this->get('ActiveFilters'); + // Add the list ordering clause. + $this->listOrder = $this->escape($this->state->get('list.ordering', 'a.id')); + $this->listDirn = $this->escape($this->state->get('list.direction', 'DESC')); + $this->saveOrder = $this->listOrder == 'a.ordering'; + // set the return here value + $this->return_here = urlencode(base64_encode((string) JUri::getInstance())); + // get global action permissions + $this->canDo = GetbibleHelper::getActions('chapter'); + $this->canEdit = $this->canDo->get('chapter.edit'); + $this->canState = $this->canDo->get('chapter.edit.state'); + $this->canCreate = $this->canDo->get('chapter.create'); + $this->canDelete = $this->canDo->get('chapter.delete'); + $this->canBatch = $this->canDo->get('core.batch'); + + // We don't need toolbar in the modal window. + if ($this->getLayout() !== 'modal') + { + $this->addToolbar(); + $this->sidebar = JHtmlSidebar::render(); + // load the batch html + if ($this->canCreate && $this->canEdit && $this->canState) + { + $this->batchDisplay = JHtmlBatch_::render(); + } + } + + // Check for errors. + if (count($errors = $this->get('Errors'))) + { + throw new Exception(implode("\n", $errors), 500); + } + + // Display the template + parent::display($tpl); + + // Set the document + $this->setDocument(); + } + + /** + * Setting the toolbar + */ + protected function addToolBar() + { + JToolBarHelper::title(JText::_('COM_GETBIBLE_CHAPTERS'), 'generic'); + JHtmlSidebar::setAction('index.php?option=com_getbible&view=chapters'); + JFormHelper::addFieldPath(JPATH_COMPONENT . '/models/fields'); + + if ($this->canCreate) + { + JToolBarHelper::addNew('chapter.add'); + } + + // Only load if there are items + if (GetbibleHelper::checkArray($this->items)) + { + if ($this->canEdit) + { + JToolBarHelper::editList('chapter.edit'); + } + + if ($this->canState) + { + JToolBarHelper::publishList('chapters.publish'); + JToolBarHelper::unpublishList('chapters.unpublish'); + JToolBarHelper::archiveList('chapters.archive'); + + if ($this->canDo->get('core.admin')) + { + JToolBarHelper::checkin('chapters.checkin'); + } + } + + // Add a batch button + if ($this->canBatch && $this->canCreate && $this->canEdit && $this->canState) + { + // Get the toolbar object instance + $bar = JToolBar::getInstance('toolbar'); + // set the batch button name + $title = JText::_('JTOOLBAR_BATCH'); + // Instantiate a new JLayoutFile instance and render the batch button + $layout = new JLayoutFile('joomla.toolbar.batch'); + // add the button to the page + $dhtml = $layout->render(array('title' => $title)); + $bar->appendButton('Custom', $dhtml, 'batch'); + } + + if ($this->state->get('filter.published') == -2 && ($this->canState && $this->canDelete)) + { + JToolbarHelper::deleteList('', 'chapters.delete', 'JTOOLBAR_EMPTY_TRASH'); + } + elseif ($this->canState && $this->canDelete) + { + JToolbarHelper::trash('chapters.trash'); + } + } + + // set help url for this view if found + $this->help_url = GetbibleHelper::getHelpUrl('chapters'); + if (GetbibleHelper::checkString($this->help_url)) + { + JToolbarHelper::help('COM_GETBIBLE_HELP_MANAGER', false, $this->help_url); + } + + // add the options comp button + if ($this->canDo->get('core.admin') || $this->canDo->get('core.options')) + { + JToolBarHelper::preferences('com_getbible'); + } + + // Only load published batch if state and batch is allowed + if ($this->canState && $this->canBatch) + { + JHtmlBatch_::addListSelection( + JText::_('COM_GETBIBLE_KEEP_ORIGINAL_STATE'), + 'batch[published]', + JHtml::_('select.options', JHtml::_('jgrid.publishedOptions', array('all' => false)), 'value', 'text', '', true) + ); + } + + // Only load access batch if create, edit and batch is allowed + if ($this->canBatch && $this->canCreate && $this->canEdit) + { + JHtmlBatch_::addListSelection( + JText::_('COM_GETBIBLE_KEEP_ORIGINAL_ACCESS'), + 'batch[access]', + JHtml::_('select.options', JHtml::_('access.assetgroups'), 'value', 'text') + ); + } + + // Only load Chapter batch if create, edit, and batch is allowed + if ($this->canBatch && $this->canCreate && $this->canEdit) + { + // Set Chapter Selection + $this->chapterOptions = JFormHelper::loadFieldType('chaptersfilterchapter')->options; + // We do some sanitation for Chapter filter + if (GetbibleHelper::checkArray($this->chapterOptions) && + isset($this->chapterOptions[0]->value) && + !GetbibleHelper::checkString($this->chapterOptions[0]->value)) + { + unset($this->chapterOptions[0]); + } + // Chapter Batch Selection + JHtmlBatch_::addListSelection( + '- Keep Original '.JText::_('COM_GETBIBLE_CHAPTER_CHAPTER_LABEL').' -', + 'batch[chapter]', + JHtml::_('select.options', $this->chapterOptions, 'value', 'text') + ); + } + + // Only load Book Nr batch if create, edit, and batch is allowed + if ($this->canBatch && $this->canCreate && $this->canEdit) + { + // Set Book Nr Selection + $this->book_nrOptions = JFormHelper::loadFieldType('chaptersfilterbooknr')->options; + // We do some sanitation for Book Nr filter + if (GetbibleHelper::checkArray($this->book_nrOptions) && + isset($this->book_nrOptions[0]->value) && + !GetbibleHelper::checkString($this->book_nrOptions[0]->value)) + { + unset($this->book_nrOptions[0]); + } + // Book Nr Batch Selection + JHtmlBatch_::addListSelection( + '- Keep Original '.JText::_('COM_GETBIBLE_CHAPTER_BOOK_NR_LABEL').' -', + 'batch[book_nr]', + JHtml::_('select.options', $this->book_nrOptions, 'value', 'text') + ); + } + + // Only load Abbreviation Translation batch if create, edit, and batch is allowed + if ($this->canBatch && $this->canCreate && $this->canEdit) + { + // Set Abbreviation Translation Selection + $this->abbreviationTranslationOptions = JFormHelper::loadFieldType('Translations')->options; + // We do some sanitation for Abbreviation Translation filter + if (GetbibleHelper::checkArray($this->abbreviationTranslationOptions) && + isset($this->abbreviationTranslationOptions[0]->value) && + !GetbibleHelper::checkString($this->abbreviationTranslationOptions[0]->value)) + { + unset($this->abbreviationTranslationOptions[0]); + } + // Abbreviation Translation Batch Selection + JHtmlBatch_::addListSelection( + '- Keep Original '.JText::_('COM_GETBIBLE_CHAPTER_ABBREVIATION_LABEL').' -', + 'batch[abbreviation]', + JHtml::_('select.options', $this->abbreviationTranslationOptions, 'value', 'text') + ); + } + } + + /** + * Method to set up the document properties + * + * @return void + */ + protected function setDocument() + { + if (!isset($this->document)) + { + $this->document = JFactory::getDocument(); + } + $this->document->setTitle(JText::_('COM_GETBIBLE_CHAPTERS')); + $this->document->addStyleSheet(JURI::root() . "administrator/components/com_getbible/assets/css/chapters.css", (GetbibleHelper::jVersion()->isCompatible('3.8.0')) ? array('version' => 'auto') : 'text/css'); + } + + /** + * Escapes a value for output in a view script. + * + * @param mixed $var The output to escape. + * + * @return mixed The escaped value. + */ + public function escape($var) + { + if(strlen($var) > 50) + { + // use the helper htmlEscape method instead and shorten the string + return GetbibleHelper::htmlEscape($var, $this->_charset, true); + } + // use the helper htmlEscape method instead. + return GetbibleHelper::htmlEscape($var, $this->_charset); + } + + /** + * Returns an array of fields the table can be sorted by + * + * @return array Array containing the field name to sort by as the key and display text as value + */ + protected function getSortFields() + { + return array( + 'a.ordering' => JText::_('JGRID_HEADING_ORDERING'), + 'a.published' => JText::_('JSTATUS'), + 'a.name' => JText::_('COM_GETBIBLE_CHAPTER_NAME_LABEL'), + 'a.chapter' => JText::_('COM_GETBIBLE_CHAPTER_CHAPTER_LABEL'), + 'a.book_nr' => JText::_('COM_GETBIBLE_CHAPTER_BOOK_NR_LABEL'), + 'g.translation' => JText::_('COM_GETBIBLE_CHAPTER_ABBREVIATION_LABEL'), + 'a.id' => JText::_('JGRID_HEADING_ID') + ); + } +} diff --git a/admin/views/getbible/index.html b/admin/views/getbible/index.html new file mode 100644 index 0000000..fa6d84e --- /dev/null +++ b/admin/views/getbible/index.html @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/admin/views/getbible/tmpl/default.php b/admin/views/getbible/tmpl/default.php new file mode 100644 index 0000000..946509a --- /dev/null +++ b/admin/views/getbible/tmpl/default.php @@ -0,0 +1,85 @@ + + @git Get Bible + @github Get Bible + @support Get Bible + @copyright Copyright (C) 2015. All Rights Reserved + @license GNU/GPL Version 2 or later - http://www.gnu.org/licenses/gpl-2.0.html + +/------------------------------------------------------------------------------------------------------*/ + +// No direct access to this file +defined('_JEXEC') or die('Restricted access'); + + + +?> +
+
+ 'cpanel')); ?> + + +
+
+ 'main')); ?> + + loadTemplate('main');?> + + +
+
+ 'vdm')); ?> + + loadTemplate('vdm');?> + + +
+
+ + + +
+
+ 'wiki_one')); ?> + + loadTemplate('wiki_tutorials');?> + + +
+
+ + + +
+
+ 'notice_board_one')); ?> + + loadTemplate('notice_board_vast_development_method');?> + + +
+
+ + + +
+
+ 'readme_one')); ?> + + loadTemplate('readme_information');?> + + +
+
+ + + +
+
\ No newline at end of file diff --git a/admin/views/getbible/tmpl/default_main.php b/admin/views/getbible/tmpl/default_main.php new file mode 100644 index 0000000..4da9e6d --- /dev/null +++ b/admin/views/getbible/tmpl/default_main.php @@ -0,0 +1,36 @@ + + @git Get Bible + @github Get Bible + @support Get Bible + @copyright Copyright (C) 2015. All Rights Reserved + @license GNU/GPL Version 2 or later - http://www.gnu.org/licenses/gpl-2.0.html + +/------------------------------------------------------------------------------------------------------*/ + +// No direct access to this file +defined('_JEXEC') or die('Restricted access'); + +?> +icons['main']) && is_array($this->icons['main'])) :?> + icons['main'] as $icon): ?> + + +
+ +

+ \ No newline at end of file diff --git a/admin/views/getbible/tmpl/default_notice_board_vast_development_method.php b/admin/views/getbible/tmpl/default_notice_board_vast_development_method.php new file mode 100644 index 0000000..2a0e483 --- /dev/null +++ b/admin/views/getbible/tmpl/default_notice_board_vast_development_method.php @@ -0,0 +1,22 @@ + + @git Get Bible + @github Get Bible + @support Get Bible + @copyright Copyright (C) 2015. All Rights Reserved + @license GNU/GPL Version 2 or later - http://www.gnu.org/licenses/gpl-2.0.html + +/------------------------------------------------------------------------------------------------------*/ + +// No direct access to this file +defined('_JEXEC') or die('Restricted access'); + +?> +noticeboard; ?> diff --git a/admin/views/getbible/tmpl/default_readme_information.php b/admin/views/getbible/tmpl/default_readme_information.php new file mode 100644 index 0000000..18f25d2 --- /dev/null +++ b/admin/views/getbible/tmpl/default_readme_information.php @@ -0,0 +1,22 @@ + + @git Get Bible + @github Get Bible + @support Get Bible + @copyright Copyright (C) 2015. All Rights Reserved + @license GNU/GPL Version 2 or later - http://www.gnu.org/licenses/gpl-2.0.html + +/------------------------------------------------------------------------------------------------------*/ + +// No direct access to this file +defined('_JEXEC') or die('Restricted access'); + +?> +readme; ?> diff --git a/admin/views/getbible/tmpl/default_vdm.php b/admin/views/getbible/tmpl/default_vdm.php new file mode 100644 index 0000000..cf8cd6d --- /dev/null +++ b/admin/views/getbible/tmpl/default_vdm.php @@ -0,0 +1,44 @@ + + @git Get Bible + @github Get Bible + @support Get Bible + @copyright Copyright (C) 2015. All Rights Reserved + @license GNU/GPL Version 2 or later - http://www.gnu.org/licenses/gpl-2.0.html + +/------------------------------------------------------------------------------------------------------*/ + +// No direct access to this file +defined('_JEXEC') or die('Restricted access'); + +?> +<?php echo JText::_('COM_GETBIBLE'); ?> + +
+contributors)): ?> + contributors) > 1): ?> +

+ +

+ +
    + contributors as $contributor): ?> +
  • :
  • + +
+
+ \ No newline at end of file diff --git a/admin/views/getbible/tmpl/default_wiki_tutorials.php b/admin/views/getbible/tmpl/default_wiki_tutorials.php new file mode 100644 index 0000000..c531eb9 --- /dev/null +++ b/admin/views/getbible/tmpl/default_wiki_tutorials.php @@ -0,0 +1,22 @@ + + @git Get Bible + @github Get Bible + @support Get Bible + @copyright Copyright (C) 2015. All Rights Reserved + @license GNU/GPL Version 2 or later - http://www.gnu.org/licenses/gpl-2.0.html + +/------------------------------------------------------------------------------------------------------*/ + +// No direct access to this file +defined('_JEXEC') or die('Restricted access'); + +?> +wiki; ?> diff --git a/admin/views/getbible/tmpl/index.html b/admin/views/getbible/tmpl/index.html new file mode 100644 index 0000000..fa6d84e --- /dev/null +++ b/admin/views/getbible/tmpl/index.html @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/admin/views/getbible/view.html.php b/admin/views/getbible/view.html.php new file mode 100644 index 0000000..3be7666 --- /dev/null +++ b/admin/views/getbible/view.html.php @@ -0,0 +1,100 @@ + + @git Get Bible + @github Get Bible + @support Get Bible + @copyright Copyright (C) 2015. All Rights Reserved + @license GNU/GPL Version 2 or later - http://www.gnu.org/licenses/gpl-2.0.html + +/------------------------------------------------------------------------------------------------------*/ + +// No direct access to this file +defined('_JEXEC') or die('Restricted access'); + + + +/** + * Getbible View class + */ +class GetbibleViewGetbible extends JViewLegacy +{ + /** + * View display method + * @return void + */ + function display($tpl = null) + { + // Assign data to the view + $this->icons = $this->get('Icons'); + $this->contributors = GetbibleHelper::getContributors(); + $this->wiki = $this->get('Wiki'); + $this->noticeboard = $this->get('Noticeboard'); + $this->readme = $this->get('Readme'); + $this->version = $this->get('Version'); + + // get the manifest details of the component + $this->manifest = GetbibleHelper::manifest(); + + // Set the toolbar + $this->addToolBar(); + + // Check for errors. + if (count($errors = $this->get('Errors'))) + { + throw new Exception(implode("\n", $errors), 500); + } + + // Display the template + parent::display($tpl); + + // Set the document + $this->setDocument(); + } + + /** + * Setting the toolbar + */ + protected function addToolBar() + { + $canDo = GetbibleHelper::getActions('getbible'); + JToolBarHelper::title(JText::_('COM_GETBIBLE_DASHBOARD'), 'grid-2'); + + // set help url for this view if found + $this->help_url = GetbibleHelper::getHelpUrl('getbible'); + if (GetbibleHelper::checkString($this->help_url)) + { + JToolbarHelper::help('COM_GETBIBLE_HELP_MANAGER', false, $this->help_url); + } + + if ($canDo->get('core.admin') || $canDo->get('core.options')) + { + JToolBarHelper::preferences('com_getbible'); + } + } + + /** + * Method to set up the document properties + * + * @return void + */ + protected function setDocument() + { + $document = JFactory::getDocument(); + + // add dashboard style sheets + $document->addStyleSheet(JURI::root() . "administrator/components/com_getbible/assets/css/dashboard.css"); + + // set page title + $document->setTitle(JText::_('COM_GETBIBLE_DASHBOARD')); + + // add manifest to page JavaScript + $document->addScriptDeclaration("var manifest = jQuery.parseJSON('" . json_encode($this->manifest) . "');", "text/javascript"); + } +} diff --git a/admin/views/index.html b/admin/views/index.html new file mode 100644 index 0000000..fa6d84e --- /dev/null +++ b/admin/views/index.html @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/admin/views/linker/submitbutton.js b/admin/views/linker/submitbutton.js new file mode 100644 index 0000000..173acd2 --- /dev/null +++ b/admin/views/linker/submitbutton.js @@ -0,0 +1,31 @@ +/*----------------------------------------------------------------------------------| io.vdm.dev |----/ + Vast Development Method +/-------------------------------------------------------------------------------------------------------/ + + @package getBible.net + + @created 3rd December, 2015 + @author Llewellyn van der Merwe + @git Get Bible + @github Get Bible + @support Get Bible + @copyright Copyright (C) 2015. All Rights Reserved + @license GNU/GPL Version 2 or later - http://www.gnu.org/licenses/gpl-2.0.html + +/------------------------------------------------------------------------------------------------------*/ + +Joomla.submitbutton = function(task) +{ + if (task == ''){ + return false; + } else { + var action = task.split('.'); + if (action[1] == 'cancel' || action[1] == 'close' || document.formvalidator.isValid(document.getElementById("adminForm"))){ + Joomla.submitform(task, document.getElementById("adminForm")); + return true; + } else { + alert(Joomla.JText._('linker, some values are not acceptable.','Some values are unacceptable')); + return false; + } + } +} \ No newline at end of file diff --git a/admin/views/linker/tmpl/edit.php b/admin/views/linker/tmpl/edit.php new file mode 100644 index 0000000..793cf77 --- /dev/null +++ b/admin/views/linker/tmpl/edit.php @@ -0,0 +1,144 @@ + + @git Get Bible + @github Get Bible + @support Get Bible + @copyright Copyright (C) 2015. All Rights Reserved + @license GNU/GPL Version 2 or later - http://www.gnu.org/licenses/gpl-2.0.html + +/------------------------------------------------------------------------------------------------------*/ + +// No direct access to this file +defined('_JEXEC') or die('Restricted access'); + +JHtml::addIncludePath(JPATH_COMPONENT.'/helpers/html'); +JHtml::_('behavior.formvalidator'); +JHtml::_('formbehavior.chosen', 'select'); +JHtml::_('behavior.keepalive'); +$componentParams = $this->params; // will be removed just use $this->params instead +?> + + diff --git a/admin/views/linker/tmpl/index.html b/admin/views/linker/tmpl/index.html new file mode 100644 index 0000000..fa6d84e --- /dev/null +++ b/admin/views/linker/tmpl/index.html @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/admin/views/linker/view.html.php b/admin/views/linker/view.html.php new file mode 100644 index 0000000..4b16b25 --- /dev/null +++ b/admin/views/linker/view.html.php @@ -0,0 +1,231 @@ + + @git Get Bible + @github Get Bible + @support Get Bible + @copyright Copyright (C) 2015. All Rights Reserved + @license GNU/GPL Version 2 or later - http://www.gnu.org/licenses/gpl-2.0.html + +/------------------------------------------------------------------------------------------------------*/ + +// No direct access to this file +defined('_JEXEC') or die('Restricted access'); + +use Joomla\CMS\MVC\View\HtmlView; + +/** + * Linker Html View class + */ +class GetbibleViewLinker extends HtmlView +{ + /** + * display method of View + * @return void + */ + public function display($tpl = null) + { + // set params + $this->params = JComponentHelper::getParams('com_getbible'); + // Assign the variables + $this->form = $this->get('Form'); + $this->item = $this->get('Item'); + $this->script = $this->get('Script'); + $this->state = $this->get('State'); + // get action permissions + $this->canDo = GetbibleHelper::getActions('linker', $this->item); + // get input + $jinput = JFactory::getApplication()->input; + $this->ref = $jinput->get('ref', 0, 'word'); + $this->refid = $jinput->get('refid', 0, 'int'); + $return = $jinput->get('return', null, 'base64'); + // set the referral string + $this->referral = ''; + if ($this->refid && $this->ref) + { + // return to the item that referred to this item + $this->referral = '&ref=' . (string)$this->ref . '&refid=' . (int)$this->refid; + } + elseif($this->ref) + { + // return to the list view that referred to this item + $this->referral = '&ref=' . (string)$this->ref; + } + // check return value + if (!is_null($return)) + { + // add the return value + $this->referral .= '&return=' . (string)$return; + } + + // Get Linked view data + $this->vvvtags = $this->get('Vvvtags'); + + // Get Linked view data + $this->vvwnotes = $this->get('Vvwnotes'); + + // Get Linked view data + $this->vvxpasswords = $this->get('Vvxpasswords'); + + // Set the toolbar + $this->addToolBar(); + + // Check for errors. + if (count($errors = $this->get('Errors'))) + { + throw new Exception(implode("\n", $errors), 500); + } + + // Display the template + parent::display($tpl); + + // Set the document + $this->setDocument(); + } + + + /** + * Setting the toolbar + */ + protected function addToolBar() + { + JFactory::getApplication()->input->set('hidemainmenu', true); + $user = JFactory::getUser(); + $userId = $user->id; + $isNew = $this->item->id == 0; + + JToolbarHelper::title( JText::_($isNew ? 'COM_GETBIBLE_LINKER_NEW' : 'COM_GETBIBLE_LINKER_EDIT'), 'pencil-2 article-add'); + // Built the actions for new and existing records. + if (GetbibleHelper::checkString($this->referral)) + { + if ($this->canDo->get('linker.create') && $isNew) + { + // We can create the record. + JToolBarHelper::save('linker.save', 'JTOOLBAR_SAVE'); + } + elseif ($this->canDo->get('linker.edit')) + { + // We can save the record. + JToolBarHelper::save('linker.save', 'JTOOLBAR_SAVE'); + } + if ($isNew) + { + // Do not creat but cancel. + JToolBarHelper::cancel('linker.cancel', 'JTOOLBAR_CANCEL'); + } + else + { + // We can close it. + JToolBarHelper::cancel('linker.cancel', 'JTOOLBAR_CLOSE'); + } + } + else + { + if ($isNew) + { + // For new records, check the create permission. + if ($this->canDo->get('linker.create')) + { + JToolBarHelper::apply('linker.apply', 'JTOOLBAR_APPLY'); + JToolBarHelper::save('linker.save', 'JTOOLBAR_SAVE'); + JToolBarHelper::custom('linker.save2new', 'save-new.png', 'save-new_f2.png', 'JTOOLBAR_SAVE_AND_NEW', false); + }; + JToolBarHelper::cancel('linker.cancel', 'JTOOLBAR_CANCEL'); + } + else + { + if ($this->canDo->get('linker.edit')) + { + // We can save the new record + JToolBarHelper::apply('linker.apply', 'JTOOLBAR_APPLY'); + JToolBarHelper::save('linker.save', 'JTOOLBAR_SAVE'); + // We can save this record, but check the create permission to see + // if we can return to make a new one. + if ($this->canDo->get('linker.create')) + { + JToolBarHelper::custom('linker.save2new', 'save-new.png', 'save-new_f2.png', 'JTOOLBAR_SAVE_AND_NEW', false); + } + } + if ($this->canDo->get('linker.create')) + { + JToolBarHelper::custom('linker.save2copy', 'save-copy.png', 'save-copy_f2.png', 'JTOOLBAR_SAVE_AS_COPY', false); + } + JToolBarHelper::cancel('linker.cancel', 'JTOOLBAR_CLOSE'); + } + } + JToolbarHelper::divider(); + // set help url for this view if found + $this->help_url = GetbibleHelper::getHelpUrl('linker'); + if (GetbibleHelper::checkString($this->help_url)) + { + JToolbarHelper::help('COM_GETBIBLE_HELP_MANAGER', false, $this->help_url); + } + } + + /** + * Escapes a value for output in a view script. + * + * @param mixed $var The output to escape. + * + * @return mixed The escaped value. + */ + public function escape($var) + { + if(strlen($var) > 30) + { + // use the helper htmlEscape method instead and shorten the string + return GetbibleHelper::htmlEscape($var, $this->_charset, true, 30); + } + // use the helper htmlEscape method instead. + return GetbibleHelper::htmlEscape($var, $this->_charset); + } + + /** + * Method to set up the document properties + * + * @return void + */ + protected function setDocument() + { + $isNew = ($this->item->id < 1); + if (!isset($this->document)) + { + $this->document = JFactory::getDocument(); + } + $this->document->setTitle(JText::_($isNew ? 'COM_GETBIBLE_LINKER_NEW' : 'COM_GETBIBLE_LINKER_EDIT')); + $this->document->addStyleSheet(JURI::root() . "administrator/components/com_getbible/assets/css/linker.css", (GetbibleHelper::jVersion()->isCompatible('3.8.0')) ? array('version' => 'auto') : 'text/css'); + + // Add the CSS for Footable. + JHtml::_('stylesheet', 'media/com_getbible/footable-v2/css/footable.core.min.css', ['version' => 'auto']); + + // Use the Metro Style + if (!isset($this->fooTableStyle) || 0 == $this->fooTableStyle) + { + JHtml::_('stylesheet', 'media/com_getbible/footable-v2/css/footable.metro.min.css', ['version' => 'auto']); + } + // Use the Legacy Style. + elseif (isset($this->fooTableStyle) && 1 == $this->fooTableStyle) + { + JHtml::_('stylesheet', 'media/com_getbible/footable-v2/css/footable.standalone.min.css', ['version' => 'auto']); + } + + // Add the JavaScript for Footable + JHtml::_('script', 'media/com_getbible/footable-v2/js/footable.js', ['version' => 'auto']); + JHtml::_('script', 'media/com_getbible/footable-v2/js/footable.sort.js', ['version' => 'auto']); + JHtml::_('script', 'media/com_getbible/footable-v2/js/footable.filter.js', ['version' => 'auto']); + JHtml::_('script', 'media/com_getbible/footable-v2/js/footable.paginate.js', ['version' => 'auto']); + + $footable = "jQuery(document).ready(function() { jQuery(function () { jQuery('.footable').footable(); }); jQuery('.nav-tabs').on('click', 'li', function() { setTimeout(tableFix, 10); }); }); function tableFix() { jQuery('.footable').trigger('footable_resize'); }"; + $this->document->addScriptDeclaration($footable); + + $this->document->addScript(JURI::root() . $this->script, (GetbibleHelper::jVersion()->isCompatible('3.8.0')) ? array('version' => 'auto') : 'text/javascript'); + $this->document->addScript(JURI::root() . "administrator/components/com_getbible/views/linker/submitbutton.js", (GetbibleHelper::jVersion()->isCompatible('3.8.0')) ? array('version' => 'auto') : 'text/javascript'); + JText::script('view not acceptable. Error'); + } +} diff --git a/admin/views/linkers/index.html b/admin/views/linkers/index.html new file mode 100644 index 0000000..fa6d84e --- /dev/null +++ b/admin/views/linkers/index.html @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/admin/views/linkers/tmpl/default.php b/admin/views/linkers/tmpl/default.php new file mode 100644 index 0000000..4f1523b --- /dev/null +++ b/admin/views/linkers/tmpl/default.php @@ -0,0 +1,73 @@ + + @git Get Bible + @github Get Bible + @support Get Bible + @copyright Copyright (C) 2015. All Rights Reserved + @license GNU/GPL Version 2 or later - http://www.gnu.org/licenses/gpl-2.0.html + +/------------------------------------------------------------------------------------------------------*/ + +// No direct access to this file +defined('_JEXEC') or die('Restricted access'); + +JHtml::_('behavior.multiselect'); +JHtml::_('dropdown.init'); +JHtml::_('formbehavior.chosen', '.multipleAccessLevels', null, array('placeholder_text_multiple' => '- ' . JText::_('COM_GETBIBLE_FILTER_SELECT_ACCESS') . ' -')); +JHtml::_('formbehavior.chosen', 'select'); +if ($this->saveOrder) +{ + $saveOrderingUrl = 'index.php?option=com_getbible&task=linkers.saveOrderAjax&tmpl=component'; + JHtml::_('sortablelist.sortable', 'linkerList', 'adminForm', strtolower($this->listDirn), $saveOrderingUrl); +} +?> +
+sidebar)): ?> +
+ sidebar; ?> +
+
+ +
+ + $this)); +?> +items)): ?> +
+ +
+ + + loadTemplate('head');?> + loadTemplate('foot');?> + loadTemplate('body');?> +
+ + canCreate && $this->canEdit) : ?> + JText::_('COM_GETBIBLE_LINKERS_BATCH_OPTIONS'), + 'footer' => $this->loadTemplate('batch_footer') + ), + $this->loadTemplate('batch_body') + ); ?> + + +
+ + + + diff --git a/admin/views/linkers/tmpl/default_batch_body.php b/admin/views/linkers/tmpl/default_batch_body.php new file mode 100644 index 0000000..ae7ef3b --- /dev/null +++ b/admin/views/linkers/tmpl/default_batch_body.php @@ -0,0 +1,24 @@ + + @git Get Bible + @github Get Bible + @support Get Bible + @copyright Copyright (C) 2015. All Rights Reserved + @license GNU/GPL Version 2 or later - http://www.gnu.org/licenses/gpl-2.0.html + +/------------------------------------------------------------------------------------------------------*/ + +// No direct access to this file +defined('_JEXEC') or die('Restricted access'); + +?> + +

+batchDisplay; ?> \ No newline at end of file diff --git a/admin/views/linkers/tmpl/default_batch_footer.php b/admin/views/linkers/tmpl/default_batch_footer.php new file mode 100644 index 0000000..2880c91 --- /dev/null +++ b/admin/views/linkers/tmpl/default_batch_footer.php @@ -0,0 +1,29 @@ + + @git Get Bible + @github Get Bible + @support Get Bible + @copyright Copyright (C) 2015. All Rights Reserved + @license GNU/GPL Version 2 or later - http://www.gnu.org/licenses/gpl-2.0.html + +/------------------------------------------------------------------------------------------------------*/ + +// No direct access to this file +defined('_JEXEC') or die('Restricted access'); + +?> + + + + \ No newline at end of file diff --git a/admin/views/linkers/tmpl/default_body.php b/admin/views/linkers/tmpl/default_body.php new file mode 100644 index 0000000..068e927 --- /dev/null +++ b/admin/views/linkers/tmpl/default_body.php @@ -0,0 +1,100 @@ + + @git Get Bible + @github Get Bible + @support Get Bible + @copyright Copyright (C) 2015. All Rights Reserved + @license GNU/GPL Version 2 or later - http://www.gnu.org/licenses/gpl-2.0.html + +/------------------------------------------------------------------------------------------------------*/ + +// No direct access to this file +defined('_JEXEC') or die('Restricted access'); + +$edit = "index.php?option=com_getbible&view=linkers&task=linker.edit"; + +?> +items as $i => $item): ?> + user->authorise('core.manage', 'com_checkin') || $item->checked_out == $this->user->id || $item->checked_out == 0; + $userChkOut = JFactory::getUser($item->checked_out); + $canDo = GetbibleHelper::getActions('linker',$item,'linkers'); + ?> + + + get('linker.edit.state')): ?> + saveOrder) + { + $iconClass = ' inactive tip-top" hasTooltip" title="' . JHtml::tooltipText('JORDERINGDISABLED'); + } + ?> + + + + saveOrder) : ?> + + + + ⋮ + + + + get('linker.edit')): ?> + checked_out) : ?> + + id); ?> + + □ + + + id); ?> + + + □ + + + +
+ get('linker.edit')): ?> + escape($item->name); ?> + checked_out): ?> + name, $item->checked_out_time, 'linkers.', $canCheckin); ?> + + + escape($item->name); ?> + +
+ + + escape($item->guid); ?> + + + get('linker.edit.state')) : ?> + checked_out) : ?> + + published, $i, 'linkers.', true, 'cb'); ?> + + published, $i, 'linkers.', false, 'cb'); ?> + + + published, $i, 'linkers.', true, 'cb'); ?> + + + published, $i, 'linkers.', false, 'cb'); ?> + + + + id; ?> + + + \ No newline at end of file diff --git a/admin/views/linkers/tmpl/default_foot.php b/admin/views/linkers/tmpl/default_foot.php new file mode 100644 index 0000000..a0cf75a --- /dev/null +++ b/admin/views/linkers/tmpl/default_foot.php @@ -0,0 +1,24 @@ + + @git Get Bible + @github Get Bible + @support Get Bible + @copyright Copyright (C) 2015. All Rights Reserved + @license GNU/GPL Version 2 or later - http://www.gnu.org/licenses/gpl-2.0.html + +/------------------------------------------------------------------------------------------------------*/ + +// No direct access to this file +defined('_JEXEC') or die('Restricted access'); + +?> + + pagination->getListFooter(); ?> + \ No newline at end of file diff --git a/admin/views/linkers/tmpl/default_head.php b/admin/views/linkers/tmpl/default_head.php new file mode 100644 index 0000000..563b382 --- /dev/null +++ b/admin/views/linkers/tmpl/default_head.php @@ -0,0 +1,56 @@ + + @git Get Bible + @github Get Bible + @support Get Bible + @copyright Copyright (C) 2015. All Rights Reserved + @license GNU/GPL Version 2 or later - http://www.gnu.org/licenses/gpl-2.0.html + +/------------------------------------------------------------------------------------------------------*/ + +// No direct access to this file +defined('_JEXEC') or die('Restricted access'); + +?> + + canEdit&& $this->canState): ?> + + listDirn, $this->listOrder, null, 'asc', 'JGRID_HEADING_ORDERING', 'icon-menu-2'); ?> + + + + + + + ▾ + + + ■ + + + + listDirn, $this->listOrder); ?> + + + + + canState): ?> + + listDirn, $this->listOrder); ?> + + + + + + + + listDirn, $this->listOrder); ?> + + \ No newline at end of file diff --git a/admin/views/linkers/tmpl/default_toolbar.php b/admin/views/linkers/tmpl/default_toolbar.php new file mode 100644 index 0000000..ca55191 --- /dev/null +++ b/admin/views/linkers/tmpl/default_toolbar.php @@ -0,0 +1,51 @@ + + @git Get Bible + @github Get Bible + @support Get Bible + @copyright Copyright (C) 2015. All Rights Reserved + @license GNU/GPL Version 2 or later - http://www.gnu.org/licenses/gpl-2.0.html + +/------------------------------------------------------------------------------------------------------*/ + +// No direct access to this file +defined('_JEXEC') or die('Restricted access'); + +?> +
+ +
+ + +
+
+ + pagination->getLimitBox(); ?> +
+
+ + +
+
+ + +
+
+
\ No newline at end of file diff --git a/admin/views/linkers/tmpl/index.html b/admin/views/linkers/tmpl/index.html new file mode 100644 index 0000000..fa6d84e --- /dev/null +++ b/admin/views/linkers/tmpl/index.html @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/admin/views/linkers/view.html.php b/admin/views/linkers/view.html.php new file mode 100644 index 0000000..5e5d7c2 --- /dev/null +++ b/admin/views/linkers/view.html.php @@ -0,0 +1,247 @@ + + @git Get Bible + @github Get Bible + @support Get Bible + @copyright Copyright (C) 2015. All Rights Reserved + @license GNU/GPL Version 2 or later - http://www.gnu.org/licenses/gpl-2.0.html + +/------------------------------------------------------------------------------------------------------*/ + +// No direct access to this file +defined('_JEXEC') or die('Restricted access'); + +use Joomla\CMS\MVC\View\HtmlView; + +/** + * Getbible Html View class for the Linkers + */ +class GetbibleViewLinkers extends HtmlView +{ + /** + * Linkers view display method + * @return void + */ + function display($tpl = null) + { + if ($this->getLayout() !== 'modal') + { + // Include helper submenu + GetbibleHelper::addSubmenu('linkers'); + } + + // Assign data to the view + $this->items = $this->get('Items'); + $this->pagination = $this->get('Pagination'); + $this->state = $this->get('State'); + $this->user = JFactory::getUser(); + // Load the filter form from xml. + $this->filterForm = $this->get('FilterForm'); + // Load the active filters. + $this->activeFilters = $this->get('ActiveFilters'); + // Add the list ordering clause. + $this->listOrder = $this->escape($this->state->get('list.ordering', 'a.id')); + $this->listDirn = $this->escape($this->state->get('list.direction', 'DESC')); + $this->saveOrder = $this->listOrder == 'a.ordering'; + // set the return here value + $this->return_here = urlencode(base64_encode((string) JUri::getInstance())); + // get global action permissions + $this->canDo = GetbibleHelper::getActions('linker'); + $this->canEdit = $this->canDo->get('linker.edit'); + $this->canState = $this->canDo->get('linker.edit.state'); + $this->canCreate = $this->canDo->get('linker.create'); + $this->canDelete = $this->canDo->get('linker.delete'); + $this->canBatch = $this->canDo->get('core.batch'); + + // We don't need toolbar in the modal window. + if ($this->getLayout() !== 'modal') + { + $this->addToolbar(); + $this->sidebar = JHtmlSidebar::render(); + // load the batch html + if ($this->canCreate && $this->canEdit && $this->canState) + { + $this->batchDisplay = JHtmlBatch_::render(); + } + } + + // Check for errors. + if (count($errors = $this->get('Errors'))) + { + throw new Exception(implode("\n", $errors), 500); + } + + // Display the template + parent::display($tpl); + + // Set the document + $this->setDocument(); + } + + /** + * Setting the toolbar + */ + protected function addToolBar() + { + JToolBarHelper::title(JText::_('COM_GETBIBLE_LINKERS'), 'joomla'); + JHtmlSidebar::setAction('index.php?option=com_getbible&view=linkers'); + JFormHelper::addFieldPath(JPATH_COMPONENT . '/models/fields'); + + if ($this->canCreate) + { + JToolBarHelper::addNew('linker.add'); + } + + // Only load if there are items + if (GetbibleHelper::checkArray($this->items)) + { + if ($this->canEdit) + { + JToolBarHelper::editList('linker.edit'); + } + + if ($this->canState) + { + JToolBarHelper::publishList('linkers.publish'); + JToolBarHelper::unpublishList('linkers.unpublish'); + JToolBarHelper::archiveList('linkers.archive'); + + if ($this->canDo->get('core.admin')) + { + JToolBarHelper::checkin('linkers.checkin'); + } + } + + // Add a batch button + if ($this->canBatch && $this->canCreate && $this->canEdit && $this->canState) + { + // Get the toolbar object instance + $bar = JToolBar::getInstance('toolbar'); + // set the batch button name + $title = JText::_('JTOOLBAR_BATCH'); + // Instantiate a new JLayoutFile instance and render the batch button + $layout = new JLayoutFile('joomla.toolbar.batch'); + // add the button to the page + $dhtml = $layout->render(array('title' => $title)); + $bar->appendButton('Custom', $dhtml, 'batch'); + } + + if ($this->state->get('filter.published') == -2 && ($this->canState && $this->canDelete)) + { + JToolbarHelper::deleteList('', 'linkers.delete', 'JTOOLBAR_EMPTY_TRASH'); + } + elseif ($this->canState && $this->canDelete) + { + JToolbarHelper::trash('linkers.trash'); + } + } + + // set help url for this view if found + $this->help_url = GetbibleHelper::getHelpUrl('linkers'); + if (GetbibleHelper::checkString($this->help_url)) + { + JToolbarHelper::help('COM_GETBIBLE_HELP_MANAGER', false, $this->help_url); + } + + // add the options comp button + if ($this->canDo->get('core.admin') || $this->canDo->get('core.options')) + { + JToolBarHelper::preferences('com_getbible'); + } + + // Only load published batch if state and batch is allowed + if ($this->canState && $this->canBatch) + { + JHtmlBatch_::addListSelection( + JText::_('COM_GETBIBLE_KEEP_ORIGINAL_STATE'), + 'batch[published]', + JHtml::_('select.options', JHtml::_('jgrid.publishedOptions', array('all' => false)), 'value', 'text', '', true) + ); + } + + // Only load access batch if create, edit and batch is allowed + if ($this->canBatch && $this->canCreate && $this->canEdit) + { + JHtmlBatch_::addListSelection( + JText::_('COM_GETBIBLE_KEEP_ORIGINAL_ACCESS'), + 'batch[access]', + JHtml::_('select.options', JHtml::_('access.assetgroups'), 'value', 'text') + ); + } + + // Only load Name batch if create, edit, and batch is allowed + if ($this->canBatch && $this->canCreate && $this->canEdit) + { + // Set Name Selection + $this->nameOptions = JFormHelper::loadFieldType('linkersfiltername')->options; + // We do some sanitation for Name filter + if (GetbibleHelper::checkArray($this->nameOptions) && + isset($this->nameOptions[0]->value) && + !GetbibleHelper::checkString($this->nameOptions[0]->value)) + { + unset($this->nameOptions[0]); + } + // Name Batch Selection + JHtmlBatch_::addListSelection( + '- Keep Original '.JText::_('COM_GETBIBLE_LINKER_NAME_LABEL').' -', + 'batch[name]', + JHtml::_('select.options', $this->nameOptions, 'value', 'text') + ); + } + } + + /** + * Method to set up the document properties + * + * @return void + */ + protected function setDocument() + { + if (!isset($this->document)) + { + $this->document = JFactory::getDocument(); + } + $this->document->setTitle(JText::_('COM_GETBIBLE_LINKERS')); + $this->document->addStyleSheet(JURI::root() . "administrator/components/com_getbible/assets/css/linkers.css", (GetbibleHelper::jVersion()->isCompatible('3.8.0')) ? array('version' => 'auto') : 'text/css'); + } + + /** + * Escapes a value for output in a view script. + * + * @param mixed $var The output to escape. + * + * @return mixed The escaped value. + */ + public function escape($var) + { + if(strlen($var) > 50) + { + // use the helper htmlEscape method instead and shorten the string + return GetbibleHelper::htmlEscape($var, $this->_charset, true); + } + // use the helper htmlEscape method instead. + return GetbibleHelper::htmlEscape($var, $this->_charset); + } + + /** + * Returns an array of fields the table can be sorted by + * + * @return array Array containing the field name to sort by as the key and display text as value + */ + protected function getSortFields() + { + return array( + 'a.ordering' => JText::_('JGRID_HEADING_ORDERING'), + 'a.published' => JText::_('JSTATUS'), + 'a.name' => JText::_('COM_GETBIBLE_LINKER_NAME_LABEL'), + 'a.id' => JText::_('JGRID_HEADING_ID') + ); + } +} diff --git a/admin/views/note/submitbutton.js b/admin/views/note/submitbutton.js new file mode 100644 index 0000000..8136d65 --- /dev/null +++ b/admin/views/note/submitbutton.js @@ -0,0 +1,31 @@ +/*----------------------------------------------------------------------------------| io.vdm.dev |----/ + Vast Development Method +/-------------------------------------------------------------------------------------------------------/ + + @package getBible.net + + @created 3rd December, 2015 + @author Llewellyn van der Merwe + @git Get Bible + @github Get Bible + @support Get Bible + @copyright Copyright (C) 2015. All Rights Reserved + @license GNU/GPL Version 2 or later - http://www.gnu.org/licenses/gpl-2.0.html + +/------------------------------------------------------------------------------------------------------*/ + +Joomla.submitbutton = function(task) +{ + if (task == ''){ + return false; + } else { + var action = task.split('.'); + if (action[1] == 'cancel' || action[1] == 'close' || document.formvalidator.isValid(document.getElementById("adminForm"))){ + Joomla.submitform(task, document.getElementById("adminForm")); + return true; + } else { + alert(Joomla.JText._('note, some values are not acceptable.','Some values are unacceptable')); + return false; + } + } +} \ No newline at end of file diff --git a/admin/views/note/tmpl/edit.php b/admin/views/note/tmpl/edit.php new file mode 100644 index 0000000..cb7166b --- /dev/null +++ b/admin/views/note/tmpl/edit.php @@ -0,0 +1,112 @@ + + @git Get Bible + @github Get Bible + @support Get Bible + @copyright Copyright (C) 2015. All Rights Reserved + @license GNU/GPL Version 2 or later - http://www.gnu.org/licenses/gpl-2.0.html + +/------------------------------------------------------------------------------------------------------*/ + +// No direct access to this file +defined('_JEXEC') or die('Restricted access'); + +JHtml::addIncludePath(JPATH_COMPONENT.'/helpers/html'); +JHtml::_('behavior.formvalidator'); +JHtml::_('formbehavior.chosen', 'select'); +JHtml::_('behavior.keepalive'); +$componentParams = $this->params; // will be removed just use $this->params instead +?> + + diff --git a/admin/views/note/tmpl/index.html b/admin/views/note/tmpl/index.html new file mode 100644 index 0000000..fa6d84e --- /dev/null +++ b/admin/views/note/tmpl/index.html @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/admin/views/note/view.html.php b/admin/views/note/view.html.php new file mode 100644 index 0000000..9ade78a --- /dev/null +++ b/admin/views/note/view.html.php @@ -0,0 +1,203 @@ + + @git Get Bible + @github Get Bible + @support Get Bible + @copyright Copyright (C) 2015. All Rights Reserved + @license GNU/GPL Version 2 or later - http://www.gnu.org/licenses/gpl-2.0.html + +/------------------------------------------------------------------------------------------------------*/ + +// No direct access to this file +defined('_JEXEC') or die('Restricted access'); + +use Joomla\CMS\MVC\View\HtmlView; + +/** + * Note Html View class + */ +class GetbibleViewNote extends HtmlView +{ + /** + * display method of View + * @return void + */ + public function display($tpl = null) + { + // set params + $this->params = JComponentHelper::getParams('com_getbible'); + // Assign the variables + $this->form = $this->get('Form'); + $this->item = $this->get('Item'); + $this->script = $this->get('Script'); + $this->state = $this->get('State'); + // get action permissions + $this->canDo = GetbibleHelper::getActions('note', $this->item); + // get input + $jinput = JFactory::getApplication()->input; + $this->ref = $jinput->get('ref', 0, 'word'); + $this->refid = $jinput->get('refid', 0, 'int'); + $return = $jinput->get('return', null, 'base64'); + // set the referral string + $this->referral = ''; + if ($this->refid && $this->ref) + { + // return to the item that referred to this item + $this->referral = '&ref=' . (string)$this->ref . '&refid=' . (int)$this->refid; + } + elseif($this->ref) + { + // return to the list view that referred to this item + $this->referral = '&ref=' . (string)$this->ref; + } + // check return value + if (!is_null($return)) + { + // add the return value + $this->referral .= '&return=' . (string)$return; + } + + // Set the toolbar + $this->addToolBar(); + + // Check for errors. + if (count($errors = $this->get('Errors'))) + { + throw new Exception(implode("\n", $errors), 500); + } + + // Display the template + parent::display($tpl); + + // Set the document + $this->setDocument(); + } + + + /** + * Setting the toolbar + */ + protected function addToolBar() + { + JFactory::getApplication()->input->set('hidemainmenu', true); + $user = JFactory::getUser(); + $userId = $user->id; + $isNew = $this->item->id == 0; + + JToolbarHelper::title( JText::_($isNew ? 'COM_GETBIBLE_NOTE_NEW' : 'COM_GETBIBLE_NOTE_EDIT'), 'pencil-2 article-add'); + // Built the actions for new and existing records. + if (GetbibleHelper::checkString($this->referral)) + { + if ($this->canDo->get('note.create') && $isNew) + { + // We can create the record. + JToolBarHelper::save('note.save', 'JTOOLBAR_SAVE'); + } + elseif ($this->canDo->get('note.edit')) + { + // We can save the record. + JToolBarHelper::save('note.save', 'JTOOLBAR_SAVE'); + } + if ($isNew) + { + // Do not creat but cancel. + JToolBarHelper::cancel('note.cancel', 'JTOOLBAR_CANCEL'); + } + else + { + // We can close it. + JToolBarHelper::cancel('note.cancel', 'JTOOLBAR_CLOSE'); + } + } + else + { + if ($isNew) + { + // For new records, check the create permission. + if ($this->canDo->get('note.create')) + { + JToolBarHelper::apply('note.apply', 'JTOOLBAR_APPLY'); + JToolBarHelper::save('note.save', 'JTOOLBAR_SAVE'); + JToolBarHelper::custom('note.save2new', 'save-new.png', 'save-new_f2.png', 'JTOOLBAR_SAVE_AND_NEW', false); + }; + JToolBarHelper::cancel('note.cancel', 'JTOOLBAR_CANCEL'); + } + else + { + if ($this->canDo->get('note.edit')) + { + // We can save the new record + JToolBarHelper::apply('note.apply', 'JTOOLBAR_APPLY'); + JToolBarHelper::save('note.save', 'JTOOLBAR_SAVE'); + // We can save this record, but check the create permission to see + // if we can return to make a new one. + if ($this->canDo->get('note.create')) + { + JToolBarHelper::custom('note.save2new', 'save-new.png', 'save-new_f2.png', 'JTOOLBAR_SAVE_AND_NEW', false); + } + } + $canVersion = ($this->canDo->get('core.version') && $this->canDo->get('note.version')); + if ($this->state->params->get('save_history', 1) && $this->canDo->get('note.edit') && $canVersion) + { + JToolbarHelper::versions('com_getbible.note', $this->item->id); + } + if ($this->canDo->get('note.create')) + { + JToolBarHelper::custom('note.save2copy', 'save-copy.png', 'save-copy_f2.png', 'JTOOLBAR_SAVE_AS_COPY', false); + } + JToolBarHelper::cancel('note.cancel', 'JTOOLBAR_CLOSE'); + } + } + JToolbarHelper::divider(); + // set help url for this view if found + $this->help_url = GetbibleHelper::getHelpUrl('note'); + if (GetbibleHelper::checkString($this->help_url)) + { + JToolbarHelper::help('COM_GETBIBLE_HELP_MANAGER', false, $this->help_url); + } + } + + /** + * Escapes a value for output in a view script. + * + * @param mixed $var The output to escape. + * + * @return mixed The escaped value. + */ + public function escape($var) + { + if(strlen($var) > 30) + { + // use the helper htmlEscape method instead and shorten the string + return GetbibleHelper::htmlEscape($var, $this->_charset, true, 30); + } + // use the helper htmlEscape method instead. + return GetbibleHelper::htmlEscape($var, $this->_charset); + } + + /** + * Method to set up the document properties + * + * @return void + */ + protected function setDocument() + { + $isNew = ($this->item->id < 1); + if (!isset($this->document)) + { + $this->document = JFactory::getDocument(); + } + $this->document->setTitle(JText::_($isNew ? 'COM_GETBIBLE_NOTE_NEW' : 'COM_GETBIBLE_NOTE_EDIT')); + $this->document->addStyleSheet(JURI::root() . "administrator/components/com_getbible/assets/css/note.css", (GetbibleHelper::jVersion()->isCompatible('3.8.0')) ? array('version' => 'auto') : 'text/css'); + $this->document->addScript(JURI::root() . $this->script, (GetbibleHelper::jVersion()->isCompatible('3.8.0')) ? array('version' => 'auto') : 'text/javascript'); + $this->document->addScript(JURI::root() . "administrator/components/com_getbible/views/note/submitbutton.js", (GetbibleHelper::jVersion()->isCompatible('3.8.0')) ? array('version' => 'auto') : 'text/javascript'); + JText::script('view not acceptable. Error'); + } +} diff --git a/admin/views/notes/index.html b/admin/views/notes/index.html new file mode 100644 index 0000000..fa6d84e --- /dev/null +++ b/admin/views/notes/index.html @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/admin/views/notes/tmpl/default.php b/admin/views/notes/tmpl/default.php new file mode 100644 index 0000000..f7936a4 --- /dev/null +++ b/admin/views/notes/tmpl/default.php @@ -0,0 +1,73 @@ + + @git Get Bible + @github Get Bible + @support Get Bible + @copyright Copyright (C) 2015. All Rights Reserved + @license GNU/GPL Version 2 or later - http://www.gnu.org/licenses/gpl-2.0.html + +/------------------------------------------------------------------------------------------------------*/ + +// No direct access to this file +defined('_JEXEC') or die('Restricted access'); + +JHtml::_('behavior.multiselect'); +JHtml::_('dropdown.init'); +JHtml::_('formbehavior.chosen', '.multipleAccessLevels', null, array('placeholder_text_multiple' => '- ' . JText::_('COM_GETBIBLE_FILTER_SELECT_ACCESS') . ' -')); +JHtml::_('formbehavior.chosen', 'select'); +if ($this->saveOrder) +{ + $saveOrderingUrl = 'index.php?option=com_getbible&task=notes.saveOrderAjax&tmpl=component'; + JHtml::_('sortablelist.sortable', 'noteList', 'adminForm', strtolower($this->listDirn), $saveOrderingUrl); +} +?> +
+sidebar)): ?> +
+ sidebar; ?> +
+
+ +
+ + $this)); +?> +items)): ?> +
+ +
+ + + loadTemplate('head');?> + loadTemplate('foot');?> + loadTemplate('body');?> +
+ + canCreate && $this->canEdit) : ?> + JText::_('COM_GETBIBLE_NOTES_BATCH_OPTIONS'), + 'footer' => $this->loadTemplate('batch_footer') + ), + $this->loadTemplate('batch_body') + ); ?> + + +
+ + + + diff --git a/admin/views/notes/tmpl/default_batch_body.php b/admin/views/notes/tmpl/default_batch_body.php new file mode 100644 index 0000000..be0c120 --- /dev/null +++ b/admin/views/notes/tmpl/default_batch_body.php @@ -0,0 +1,24 @@ + + @git Get Bible + @github Get Bible + @support Get Bible + @copyright Copyright (C) 2015. All Rights Reserved + @license GNU/GPL Version 2 or later - http://www.gnu.org/licenses/gpl-2.0.html + +/------------------------------------------------------------------------------------------------------*/ + +// No direct access to this file +defined('_JEXEC') or die('Restricted access'); + +?> + +

+batchDisplay; ?> \ No newline at end of file diff --git a/admin/views/notes/tmpl/default_batch_footer.php b/admin/views/notes/tmpl/default_batch_footer.php new file mode 100644 index 0000000..df4b4d9 --- /dev/null +++ b/admin/views/notes/tmpl/default_batch_footer.php @@ -0,0 +1,29 @@ + + @git Get Bible + @github Get Bible + @support Get Bible + @copyright Copyright (C) 2015. All Rights Reserved + @license GNU/GPL Version 2 or later - http://www.gnu.org/licenses/gpl-2.0.html + +/------------------------------------------------------------------------------------------------------*/ + +// No direct access to this file +defined('_JEXEC') or die('Restricted access'); + +?> + + + + \ No newline at end of file diff --git a/admin/views/notes/tmpl/default_body.php b/admin/views/notes/tmpl/default_body.php new file mode 100644 index 0000000..3e25be6 --- /dev/null +++ b/admin/views/notes/tmpl/default_body.php @@ -0,0 +1,109 @@ + + @git Get Bible + @github Get Bible + @support Get Bible + @copyright Copyright (C) 2015. All Rights Reserved + @license GNU/GPL Version 2 or later - http://www.gnu.org/licenses/gpl-2.0.html + +/------------------------------------------------------------------------------------------------------*/ + +// No direct access to this file +defined('_JEXEC') or die('Restricted access'); + +$edit = "index.php?option=com_getbible&view=notes&task=note.edit"; + +?> +items as $i => $item): ?> + user->authorise('core.manage', 'com_checkin') || $item->checked_out == $this->user->id || $item->checked_out == 0; + $userChkOut = JFactory::getUser($item->checked_out); + $canDo = GetbibleHelper::getActions('note',$item,'notes'); + ?> + + + get('note.edit.state')): ?> + saveOrder) + { + $iconClass = ' inactive tip-top" hasTooltip" title="' . JHtml::tooltipText('JORDERINGDISABLED'); + } + ?> + + + + saveOrder) : ?> + + + + ⋮ + + + + get('note.edit')): ?> + checked_out) : ?> + + id); ?> + + □ + + + id); ?> + + + □ + + + +
+ get('note.edit')): ?> + escape($item->book_nr); ?> + checked_out): ?> + name, $item->checked_out_time, 'notes.', $canCheckin); ?> + + + escape($item->book_nr); ?> + +
+ + +
+ user->authorise('linker.edit', 'com_getbible.linker.' . (int) $item->linker_id)): ?> + escape($item->linker_name); ?> + + escape($item->linker_name); ?> + +
+ + + access); ?> + + + get('note.edit.state')) : ?> + checked_out) : ?> + + published, $i, 'notes.', true, 'cb'); ?> + + published, $i, 'notes.', false, 'cb'); ?> + + + published, $i, 'notes.', true, 'cb'); ?> + + + published, $i, 'notes.', false, 'cb'); ?> + + + + id; ?> + + + \ No newline at end of file diff --git a/admin/views/notes/tmpl/default_foot.php b/admin/views/notes/tmpl/default_foot.php new file mode 100644 index 0000000..38a928f --- /dev/null +++ b/admin/views/notes/tmpl/default_foot.php @@ -0,0 +1,24 @@ + + @git Get Bible + @github Get Bible + @support Get Bible + @copyright Copyright (C) 2015. All Rights Reserved + @license GNU/GPL Version 2 or later - http://www.gnu.org/licenses/gpl-2.0.html + +/------------------------------------------------------------------------------------------------------*/ + +// No direct access to this file +defined('_JEXEC') or die('Restricted access'); + +?> + + pagination->getListFooter(); ?> + \ No newline at end of file diff --git a/admin/views/notes/tmpl/default_head.php b/admin/views/notes/tmpl/default_head.php new file mode 100644 index 0000000..45dae8a --- /dev/null +++ b/admin/views/notes/tmpl/default_head.php @@ -0,0 +1,59 @@ + + @git Get Bible + @github Get Bible + @support Get Bible + @copyright Copyright (C) 2015. All Rights Reserved + @license GNU/GPL Version 2 or later - http://www.gnu.org/licenses/gpl-2.0.html + +/------------------------------------------------------------------------------------------------------*/ + +// No direct access to this file +defined('_JEXEC') or die('Restricted access'); + +?> + + canEdit&& $this->canState): ?> + + listDirn, $this->listOrder, null, 'asc', 'JGRID_HEADING_ORDERING', 'icon-menu-2'); ?> + + + + + + + ▾ + + + ■ + + + + listDirn, $this->listOrder); ?> + + + listDirn, $this->listOrder); ?> + + + listDirn, $this->listOrder); ?> + + canState): ?> + + listDirn, $this->listOrder); ?> + + + + + + + + listDirn, $this->listOrder); ?> + + \ No newline at end of file diff --git a/admin/views/notes/tmpl/default_toolbar.php b/admin/views/notes/tmpl/default_toolbar.php new file mode 100644 index 0000000..77747da --- /dev/null +++ b/admin/views/notes/tmpl/default_toolbar.php @@ -0,0 +1,51 @@ + + @git Get Bible + @github Get Bible + @support Get Bible + @copyright Copyright (C) 2015. All Rights Reserved + @license GNU/GPL Version 2 or later - http://www.gnu.org/licenses/gpl-2.0.html + +/------------------------------------------------------------------------------------------------------*/ + +// No direct access to this file +defined('_JEXEC') or die('Restricted access'); + +?> +
+ +
+ + +
+
+ + pagination->getLimitBox(); ?> +
+
+ + +
+
+ + +
+
+
\ No newline at end of file diff --git a/admin/views/notes/tmpl/index.html b/admin/views/notes/tmpl/index.html new file mode 100644 index 0000000..fa6d84e --- /dev/null +++ b/admin/views/notes/tmpl/index.html @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/admin/views/notes/view.html.php b/admin/views/notes/view.html.php new file mode 100644 index 0000000..db500b9 --- /dev/null +++ b/admin/views/notes/view.html.php @@ -0,0 +1,319 @@ + + @git Get Bible + @github Get Bible + @support Get Bible + @copyright Copyright (C) 2015. All Rights Reserved + @license GNU/GPL Version 2 or later - http://www.gnu.org/licenses/gpl-2.0.html + +/------------------------------------------------------------------------------------------------------*/ + +// No direct access to this file +defined('_JEXEC') or die('Restricted access'); + +use Joomla\CMS\MVC\View\HtmlView; + +/** + * Getbible Html View class for the Notes + */ +class GetbibleViewNotes extends HtmlView +{ + /** + * Notes view display method + * @return void + */ + function display($tpl = null) + { + if ($this->getLayout() !== 'modal') + { + // Include helper submenu + GetbibleHelper::addSubmenu('notes'); + } + + // Assign data to the view + $this->items = $this->get('Items'); + $this->pagination = $this->get('Pagination'); + $this->state = $this->get('State'); + $this->user = JFactory::getUser(); + // Load the filter form from xml. + $this->filterForm = $this->get('FilterForm'); + // Load the active filters. + $this->activeFilters = $this->get('ActiveFilters'); + // Add the list ordering clause. + $this->listOrder = $this->escape($this->state->get('list.ordering', 'a.id')); + $this->listDirn = $this->escape($this->state->get('list.direction', 'DESC')); + $this->saveOrder = $this->listOrder == 'a.ordering'; + // set the return here value + $this->return_here = urlencode(base64_encode((string) JUri::getInstance())); + // get global action permissions + $this->canDo = GetbibleHelper::getActions('note'); + $this->canEdit = $this->canDo->get('note.edit'); + $this->canState = $this->canDo->get('note.edit.state'); + $this->canCreate = $this->canDo->get('note.create'); + $this->canDelete = $this->canDo->get('note.delete'); + $this->canBatch = $this->canDo->get('core.batch'); + + // We don't need toolbar in the modal window. + if ($this->getLayout() !== 'modal') + { + $this->addToolbar(); + $this->sidebar = JHtmlSidebar::render(); + // load the batch html + if ($this->canCreate && $this->canEdit && $this->canState) + { + $this->batchDisplay = JHtmlBatch_::render(); + } + } + + // Check for errors. + if (count($errors = $this->get('Errors'))) + { + throw new Exception(implode("\n", $errors), 500); + } + + // Display the template + parent::display($tpl); + + // Set the document + $this->setDocument(); + } + + /** + * Setting the toolbar + */ + protected function addToolBar() + { + JToolBarHelper::title(JText::_('COM_GETBIBLE_NOTES'), 'file'); + JHtmlSidebar::setAction('index.php?option=com_getbible&view=notes'); + JFormHelper::addFieldPath(JPATH_COMPONENT . '/models/fields'); + + if ($this->canCreate) + { + JToolBarHelper::addNew('note.add'); + } + + // Only load if there are items + if (GetbibleHelper::checkArray($this->items)) + { + if ($this->canEdit) + { + JToolBarHelper::editList('note.edit'); + } + + if ($this->canState) + { + JToolBarHelper::publishList('notes.publish'); + JToolBarHelper::unpublishList('notes.unpublish'); + JToolBarHelper::archiveList('notes.archive'); + + if ($this->canDo->get('core.admin')) + { + JToolBarHelper::checkin('notes.checkin'); + } + } + + // Add a batch button + if ($this->canBatch && $this->canCreate && $this->canEdit && $this->canState) + { + // Get the toolbar object instance + $bar = JToolBar::getInstance('toolbar'); + // set the batch button name + $title = JText::_('JTOOLBAR_BATCH'); + // Instantiate a new JLayoutFile instance and render the batch button + $layout = new JLayoutFile('joomla.toolbar.batch'); + // add the button to the page + $dhtml = $layout->render(array('title' => $title)); + $bar->appendButton('Custom', $dhtml, 'batch'); + } + + if ($this->state->get('filter.published') == -2 && ($this->canState && $this->canDelete)) + { + JToolbarHelper::deleteList('', 'notes.delete', 'JTOOLBAR_EMPTY_TRASH'); + } + elseif ($this->canState && $this->canDelete) + { + JToolbarHelper::trash('notes.trash'); + } + } + + // set help url for this view if found + $this->help_url = GetbibleHelper::getHelpUrl('notes'); + if (GetbibleHelper::checkString($this->help_url)) + { + JToolbarHelper::help('COM_GETBIBLE_HELP_MANAGER', false, $this->help_url); + } + + // add the options comp button + if ($this->canDo->get('core.admin') || $this->canDo->get('core.options')) + { + JToolBarHelper::preferences('com_getbible'); + } + + // Only load published batch if state and batch is allowed + if ($this->canState && $this->canBatch) + { + JHtmlBatch_::addListSelection( + JText::_('COM_GETBIBLE_KEEP_ORIGINAL_STATE'), + 'batch[published]', + JHtml::_('select.options', JHtml::_('jgrid.publishedOptions', array('all' => false)), 'value', 'text', '', true) + ); + } + + // Only load Book Nr batch if create, edit, and batch is allowed + if ($this->canBatch && $this->canCreate && $this->canEdit) + { + // Set Book Nr Selection + $this->book_nrOptions = JFormHelper::loadFieldType('notesfilterbooknr')->options; + // We do some sanitation for Book Nr filter + if (GetbibleHelper::checkArray($this->book_nrOptions) && + isset($this->book_nrOptions[0]->value) && + !GetbibleHelper::checkString($this->book_nrOptions[0]->value)) + { + unset($this->book_nrOptions[0]); + } + // Book Nr Batch Selection + JHtmlBatch_::addListSelection( + '- Keep Original '.JText::_('COM_GETBIBLE_NOTE_BOOK_NR_LABEL').' -', + 'batch[book_nr]', + JHtml::_('select.options', $this->book_nrOptions, 'value', 'text') + ); + } + + // Only load Linker Name batch if create, edit, and batch is allowed + if ($this->canBatch && $this->canCreate && $this->canEdit) + { + // Set Linker Name Selection + $this->linkerNameOptions = JFormHelper::loadFieldType('Linkers')->options; + // We do some sanitation for Linker Name filter + if (GetbibleHelper::checkArray($this->linkerNameOptions) && + isset($this->linkerNameOptions[0]->value) && + !GetbibleHelper::checkString($this->linkerNameOptions[0]->value)) + { + unset($this->linkerNameOptions[0]); + } + // Linker Name Batch Selection + JHtmlBatch_::addListSelection( + '- Keep Original '.JText::_('COM_GETBIBLE_NOTE_LINKER_LABEL').' -', + 'batch[linker]', + JHtml::_('select.options', $this->linkerNameOptions, 'value', 'text') + ); + } + + // Only load Access batch if create, edit, and batch is allowed + if ($this->canBatch && $this->canCreate && $this->canEdit) + { + // Set Access Selection + $this->accessOptions = JFormHelper::loadFieldType('notesfilteraccess')->options; + // We do some sanitation for Access filter + if (GetbibleHelper::checkArray($this->accessOptions) && + isset($this->accessOptions[0]->value) && + !GetbibleHelper::checkString($this->accessOptions[0]->value)) + { + unset($this->accessOptions[0]); + } + // Access Batch Selection + JHtmlBatch_::addListSelection( + '- Keep Original '.JText::_('COM_GETBIBLE_NOTE_ACCESS_LABEL').' -', + 'batch[access]', + JHtml::_('select.options', $this->accessOptions, 'value', 'text') + ); + } + + // Only load Verse batch if create, edit, and batch is allowed + if ($this->canBatch && $this->canCreate && $this->canEdit) + { + // Set Verse Selection + $this->verseOptions = JFormHelper::loadFieldType('notesfilterverse')->options; + // We do some sanitation for Verse filter + if (GetbibleHelper::checkArray($this->verseOptions) && + isset($this->verseOptions[0]->value) && + !GetbibleHelper::checkString($this->verseOptions[0]->value)) + { + unset($this->verseOptions[0]); + } + // Verse Batch Selection + JHtmlBatch_::addListSelection( + '- Keep Original '.JText::_('COM_GETBIBLE_NOTE_VERSE_LABEL').' -', + 'batch[verse]', + JHtml::_('select.options', $this->verseOptions, 'value', 'text') + ); + } + + // Only load Chapter batch if create, edit, and batch is allowed + if ($this->canBatch && $this->canCreate && $this->canEdit) + { + // Set Chapter Selection + $this->chapterOptions = JFormHelper::loadFieldType('notesfilterchapter')->options; + // We do some sanitation for Chapter filter + if (GetbibleHelper::checkArray($this->chapterOptions) && + isset($this->chapterOptions[0]->value) && + !GetbibleHelper::checkString($this->chapterOptions[0]->value)) + { + unset($this->chapterOptions[0]); + } + // Chapter Batch Selection + JHtmlBatch_::addListSelection( + '- Keep Original '.JText::_('COM_GETBIBLE_NOTE_CHAPTER_LABEL').' -', + 'batch[chapter]', + JHtml::_('select.options', $this->chapterOptions, 'value', 'text') + ); + } + } + + /** + * Method to set up the document properties + * + * @return void + */ + protected function setDocument() + { + if (!isset($this->document)) + { + $this->document = JFactory::getDocument(); + } + $this->document->setTitle(JText::_('COM_GETBIBLE_NOTES')); + $this->document->addStyleSheet(JURI::root() . "administrator/components/com_getbible/assets/css/notes.css", (GetbibleHelper::jVersion()->isCompatible('3.8.0')) ? array('version' => 'auto') : 'text/css'); + } + + /** + * Escapes a value for output in a view script. + * + * @param mixed $var The output to escape. + * + * @return mixed The escaped value. + */ + public function escape($var) + { + if(strlen($var) > 50) + { + // use the helper htmlEscape method instead and shorten the string + return GetbibleHelper::htmlEscape($var, $this->_charset, true); + } + // use the helper htmlEscape method instead. + return GetbibleHelper::htmlEscape($var, $this->_charset); + } + + /** + * Returns an array of fields the table can be sorted by + * + * @return array Array containing the field name to sort by as the key and display text as value + */ + protected function getSortFields() + { + return array( + 'a.ordering' => JText::_('JGRID_HEADING_ORDERING'), + 'a.published' => JText::_('JSTATUS'), + 'a.book_nr' => JText::_('COM_GETBIBLE_NOTE_BOOK_NR_LABEL'), + 'g.name' => JText::_('COM_GETBIBLE_NOTE_LINKER_LABEL'), + 'a.access' => JText::_('COM_GETBIBLE_NOTE_ACCESS_LABEL'), + 'a.id' => JText::_('JGRID_HEADING_ID') + ); + } +} diff --git a/admin/views/open_ai_message/submitbutton.js b/admin/views/open_ai_message/submitbutton.js new file mode 100644 index 0000000..3c988c5 --- /dev/null +++ b/admin/views/open_ai_message/submitbutton.js @@ -0,0 +1,31 @@ +/*----------------------------------------------------------------------------------| io.vdm.dev |----/ + Vast Development Method +/-------------------------------------------------------------------------------------------------------/ + + @package getBible.net + + @created 3rd December, 2015 + @author Llewellyn van der Merwe + @git Get Bible + @github Get Bible + @support Get Bible + @copyright Copyright (C) 2015. All Rights Reserved + @license GNU/GPL Version 2 or later - http://www.gnu.org/licenses/gpl-2.0.html + +/------------------------------------------------------------------------------------------------------*/ + +Joomla.submitbutton = function(task) +{ + if (task == ''){ + return false; + } else { + var action = task.split('.'); + if (action[1] == 'cancel' || action[1] == 'close' || document.formvalidator.isValid(document.getElementById("adminForm"))){ + Joomla.submitform(task, document.getElementById("adminForm")); + return true; + } else { + alert(Joomla.JText._('open_ai_message, some values are not acceptable.','Some values are unacceptable')); + return false; + } + } +} \ No newline at end of file diff --git a/admin/views/open_ai_message/tmpl/edit.php b/admin/views/open_ai_message/tmpl/edit.php new file mode 100644 index 0000000..f6227cb --- /dev/null +++ b/admin/views/open_ai_message/tmpl/edit.php @@ -0,0 +1,117 @@ + + @git Get Bible + @github Get Bible + @support Get Bible + @copyright Copyright (C) 2015. All Rights Reserved + @license GNU/GPL Version 2 or later - http://www.gnu.org/licenses/gpl-2.0.html + +/------------------------------------------------------------------------------------------------------*/ + +// No direct access to this file +defined('_JEXEC') or die('Restricted access'); + +JHtml::addIncludePath(JPATH_COMPONENT.'/helpers/html'); +JHtml::_('behavior.formvalidator'); +JHtml::_('formbehavior.chosen', 'select'); +JHtml::_('behavior.keepalive'); +$componentParams = $this->params; // will be removed just use $this->params instead +?> + + diff --git a/admin/views/open_ai_message/tmpl/index.html b/admin/views/open_ai_message/tmpl/index.html new file mode 100644 index 0000000..fa6d84e --- /dev/null +++ b/admin/views/open_ai_message/tmpl/index.html @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/admin/views/open_ai_message/view.html.php b/admin/views/open_ai_message/view.html.php new file mode 100644 index 0000000..2cf015d --- /dev/null +++ b/admin/views/open_ai_message/view.html.php @@ -0,0 +1,203 @@ + + @git Get Bible + @github Get Bible + @support Get Bible + @copyright Copyright (C) 2015. All Rights Reserved + @license GNU/GPL Version 2 or later - http://www.gnu.org/licenses/gpl-2.0.html + +/------------------------------------------------------------------------------------------------------*/ + +// No direct access to this file +defined('_JEXEC') or die('Restricted access'); + +use Joomla\CMS\MVC\View\HtmlView; + +/** + * Open_ai_message Html View class + */ +class GetbibleViewOpen_ai_message extends HtmlView +{ + /** + * display method of View + * @return void + */ + public function display($tpl = null) + { + // set params + $this->params = JComponentHelper::getParams('com_getbible'); + // Assign the variables + $this->form = $this->get('Form'); + $this->item = $this->get('Item'); + $this->script = $this->get('Script'); + $this->state = $this->get('State'); + // get action permissions + $this->canDo = GetbibleHelper::getActions('open_ai_message', $this->item); + // get input + $jinput = JFactory::getApplication()->input; + $this->ref = $jinput->get('ref', 0, 'word'); + $this->refid = $jinput->get('refid', 0, 'int'); + $return = $jinput->get('return', null, 'base64'); + // set the referral string + $this->referral = ''; + if ($this->refid && $this->ref) + { + // return to the item that referred to this item + $this->referral = '&ref=' . (string)$this->ref . '&refid=' . (int)$this->refid; + } + elseif($this->ref) + { + // return to the list view that referred to this item + $this->referral = '&ref=' . (string)$this->ref; + } + // check return value + if (!is_null($return)) + { + // add the return value + $this->referral .= '&return=' . (string)$return; + } + + // Set the toolbar + $this->addToolBar(); + + // Check for errors. + if (count($errors = $this->get('Errors'))) + { + throw new Exception(implode("\n", $errors), 500); + } + + // Display the template + parent::display($tpl); + + // Set the document + $this->setDocument(); + } + + + /** + * Setting the toolbar + */ + protected function addToolBar() + { + JFactory::getApplication()->input->set('hidemainmenu', true); + $user = JFactory::getUser(); + $userId = $user->id; + $isNew = $this->item->id == 0; + + JToolbarHelper::title( JText::_($isNew ? 'COM_GETBIBLE_OPEN_AI_MESSAGE_NEW' : 'COM_GETBIBLE_OPEN_AI_MESSAGE_EDIT'), 'pencil-2 article-add'); + // Built the actions for new and existing records. + if (GetbibleHelper::checkString($this->referral)) + { + if ($this->canDo->get('open_ai_message.create') && $isNew) + { + // We can create the record. + JToolBarHelper::save('open_ai_message.save', 'JTOOLBAR_SAVE'); + } + elseif ($this->canDo->get('open_ai_message.edit')) + { + // We can save the record. + JToolBarHelper::save('open_ai_message.save', 'JTOOLBAR_SAVE'); + } + if ($isNew) + { + // Do not creat but cancel. + JToolBarHelper::cancel('open_ai_message.cancel', 'JTOOLBAR_CANCEL'); + } + else + { + // We can close it. + JToolBarHelper::cancel('open_ai_message.cancel', 'JTOOLBAR_CLOSE'); + } + } + else + { + if ($isNew) + { + // For new records, check the create permission. + if ($this->canDo->get('open_ai_message.create')) + { + JToolBarHelper::apply('open_ai_message.apply', 'JTOOLBAR_APPLY'); + JToolBarHelper::save('open_ai_message.save', 'JTOOLBAR_SAVE'); + JToolBarHelper::custom('open_ai_message.save2new', 'save-new.png', 'save-new_f2.png', 'JTOOLBAR_SAVE_AND_NEW', false); + }; + JToolBarHelper::cancel('open_ai_message.cancel', 'JTOOLBAR_CANCEL'); + } + else + { + if ($this->canDo->get('open_ai_message.edit')) + { + // We can save the new record + JToolBarHelper::apply('open_ai_message.apply', 'JTOOLBAR_APPLY'); + JToolBarHelper::save('open_ai_message.save', 'JTOOLBAR_SAVE'); + // We can save this record, but check the create permission to see + // if we can return to make a new one. + if ($this->canDo->get('open_ai_message.create')) + { + JToolBarHelper::custom('open_ai_message.save2new', 'save-new.png', 'save-new_f2.png', 'JTOOLBAR_SAVE_AND_NEW', false); + } + } + $canVersion = ($this->canDo->get('core.version') && $this->canDo->get('open_ai_message.version')); + if ($this->state->params->get('save_history', 1) && $this->canDo->get('open_ai_message.edit') && $canVersion) + { + JToolbarHelper::versions('com_getbible.open_ai_message', $this->item->id); + } + if ($this->canDo->get('open_ai_message.create')) + { + JToolBarHelper::custom('open_ai_message.save2copy', 'save-copy.png', 'save-copy_f2.png', 'JTOOLBAR_SAVE_AS_COPY', false); + } + JToolBarHelper::cancel('open_ai_message.cancel', 'JTOOLBAR_CLOSE'); + } + } + JToolbarHelper::divider(); + // set help url for this view if found + $this->help_url = GetbibleHelper::getHelpUrl('open_ai_message'); + if (GetbibleHelper::checkString($this->help_url)) + { + JToolbarHelper::help('COM_GETBIBLE_HELP_MANAGER', false, $this->help_url); + } + } + + /** + * Escapes a value for output in a view script. + * + * @param mixed $var The output to escape. + * + * @return mixed The escaped value. + */ + public function escape($var) + { + if(strlen($var) > 30) + { + // use the helper htmlEscape method instead and shorten the string + return GetbibleHelper::htmlEscape($var, $this->_charset, true, 30); + } + // use the helper htmlEscape method instead. + return GetbibleHelper::htmlEscape($var, $this->_charset); + } + + /** + * Method to set up the document properties + * + * @return void + */ + protected function setDocument() + { + $isNew = ($this->item->id < 1); + if (!isset($this->document)) + { + $this->document = JFactory::getDocument(); + } + $this->document->setTitle(JText::_($isNew ? 'COM_GETBIBLE_OPEN_AI_MESSAGE_NEW' : 'COM_GETBIBLE_OPEN_AI_MESSAGE_EDIT')); + $this->document->addStyleSheet(JURI::root() . "administrator/components/com_getbible/assets/css/open_ai_message.css", (GetbibleHelper::jVersion()->isCompatible('3.8.0')) ? array('version' => 'auto') : 'text/css'); + $this->document->addScript(JURI::root() . $this->script, (GetbibleHelper::jVersion()->isCompatible('3.8.0')) ? array('version' => 'auto') : 'text/javascript'); + $this->document->addScript(JURI::root() . "administrator/components/com_getbible/views/open_ai_message/submitbutton.js", (GetbibleHelper::jVersion()->isCompatible('3.8.0')) ? array('version' => 'auto') : 'text/javascript'); + JText::script('view not acceptable. Error'); + } +} diff --git a/admin/views/open_ai_messages/index.html b/admin/views/open_ai_messages/index.html new file mode 100644 index 0000000..fa6d84e --- /dev/null +++ b/admin/views/open_ai_messages/index.html @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/admin/views/open_ai_messages/tmpl/default.php b/admin/views/open_ai_messages/tmpl/default.php new file mode 100644 index 0000000..644446d --- /dev/null +++ b/admin/views/open_ai_messages/tmpl/default.php @@ -0,0 +1,73 @@ + + @git Get Bible + @github Get Bible + @support Get Bible + @copyright Copyright (C) 2015. All Rights Reserved + @license GNU/GPL Version 2 or later - http://www.gnu.org/licenses/gpl-2.0.html + +/------------------------------------------------------------------------------------------------------*/ + +// No direct access to this file +defined('_JEXEC') or die('Restricted access'); + +JHtml::_('behavior.multiselect'); +JHtml::_('dropdown.init'); +JHtml::_('formbehavior.chosen', '.multipleAccessLevels', null, array('placeholder_text_multiple' => '- ' . JText::_('COM_GETBIBLE_FILTER_SELECT_ACCESS') . ' -')); +JHtml::_('formbehavior.chosen', 'select'); +if ($this->saveOrder) +{ + $saveOrderingUrl = 'index.php?option=com_getbible&task=open_ai_messages.saveOrderAjax&tmpl=component'; + JHtml::_('sortablelist.sortable', 'open_ai_messageList', 'adminForm', strtolower($this->listDirn), $saveOrderingUrl); +} +?> +
+sidebar)): ?> +
+ sidebar; ?> +
+
+ +
+ + $this)); +?> +items)): ?> +
+ +
+ + + loadTemplate('head');?> + loadTemplate('foot');?> + loadTemplate('body');?> +
+ + canCreate && $this->canEdit) : ?> + JText::_('COM_GETBIBLE_OPEN_AI_MESSAGES_BATCH_OPTIONS'), + 'footer' => $this->loadTemplate('batch_footer') + ), + $this->loadTemplate('batch_body') + ); ?> + + +
+ + + + diff --git a/admin/views/open_ai_messages/tmpl/default_batch_body.php b/admin/views/open_ai_messages/tmpl/default_batch_body.php new file mode 100644 index 0000000..2214298 --- /dev/null +++ b/admin/views/open_ai_messages/tmpl/default_batch_body.php @@ -0,0 +1,24 @@ + + @git Get Bible + @github Get Bible + @support Get Bible + @copyright Copyright (C) 2015. All Rights Reserved + @license GNU/GPL Version 2 or later - http://www.gnu.org/licenses/gpl-2.0.html + +/------------------------------------------------------------------------------------------------------*/ + +// No direct access to this file +defined('_JEXEC') or die('Restricted access'); + +?> + +

+batchDisplay; ?> \ No newline at end of file diff --git a/admin/views/open_ai_messages/tmpl/default_batch_footer.php b/admin/views/open_ai_messages/tmpl/default_batch_footer.php new file mode 100644 index 0000000..14602de --- /dev/null +++ b/admin/views/open_ai_messages/tmpl/default_batch_footer.php @@ -0,0 +1,29 @@ + + @git Get Bible + @github Get Bible + @support Get Bible + @copyright Copyright (C) 2015. All Rights Reserved + @license GNU/GPL Version 2 or later - http://www.gnu.org/licenses/gpl-2.0.html + +/------------------------------------------------------------------------------------------------------*/ + +// No direct access to this file +defined('_JEXEC') or die('Restricted access'); + +?> + + + + \ No newline at end of file diff --git a/admin/views/open_ai_messages/tmpl/default_body.php b/admin/views/open_ai_messages/tmpl/default_body.php new file mode 100644 index 0000000..d7311d0 --- /dev/null +++ b/admin/views/open_ai_messages/tmpl/default_body.php @@ -0,0 +1,118 @@ + + @git Get Bible + @github Get Bible + @support Get Bible + @copyright Copyright (C) 2015. All Rights Reserved + @license GNU/GPL Version 2 or later - http://www.gnu.org/licenses/gpl-2.0.html + +/------------------------------------------------------------------------------------------------------*/ + +// No direct access to this file +defined('_JEXEC') or die('Restricted access'); + +$edit = "index.php?option=com_getbible&view=open_ai_messages&task=open_ai_message.edit"; + +?> +items as $i => $item): ?> + user->authorise('core.manage', 'com_checkin') || $item->checked_out == $this->user->id || $item->checked_out == 0; + $userChkOut = JFactory::getUser($item->checked_out); + $canDo = GetbibleHelper::getActions('open_ai_message',$item,'open_ai_messages'); + ?> + + + get('open_ai_message.edit.state')): ?> + saveOrder) + { + $iconClass = ' inactive tip-top" hasTooltip" title="' . JHtml::tooltipText('JORDERINGDISABLED'); + } + ?> + + + + saveOrder) : ?> + + + + ⋮ + + + + get('open_ai_message.edit')): ?> + checked_out) : ?> + + id); ?> + + □ + + + id); ?> + + + □ + + + +
+ get('open_ai_message.edit')): ?> + role); ?> + checked_out): ?> + name, $item->checked_out_time, 'open_ai_messages.', $canCheckin); ?> + + + role); ?> + +
+ + +
+ user->authorise('open_ai_response.edit', 'com_getbible.open_ai_response.' . (int) $item->open_ai_response_id)): ?> + escape($item->open_ai_response_response_id); ?> + + escape($item->open_ai_response_response_id); ?> + +
+ + +
+ user->authorise('prompt.edit', 'com_getbible.prompt.' . (int) $item->prompt_id)): ?> + escape($item->prompt_name); ?> + + escape($item->prompt_name); ?> + +
+ + + source); ?> + + + get('open_ai_message.edit.state')) : ?> + checked_out) : ?> + + published, $i, 'open_ai_messages.', true, 'cb'); ?> + + published, $i, 'open_ai_messages.', false, 'cb'); ?> + + + published, $i, 'open_ai_messages.', true, 'cb'); ?> + + + published, $i, 'open_ai_messages.', false, 'cb'); ?> + + + + id; ?> + + + \ No newline at end of file diff --git a/admin/views/open_ai_messages/tmpl/default_foot.php b/admin/views/open_ai_messages/tmpl/default_foot.php new file mode 100644 index 0000000..290760a --- /dev/null +++ b/admin/views/open_ai_messages/tmpl/default_foot.php @@ -0,0 +1,24 @@ + + @git Get Bible + @github Get Bible + @support Get Bible + @copyright Copyright (C) 2015. All Rights Reserved + @license GNU/GPL Version 2 or later - http://www.gnu.org/licenses/gpl-2.0.html + +/------------------------------------------------------------------------------------------------------*/ + +// No direct access to this file +defined('_JEXEC') or die('Restricted access'); + +?> + + pagination->getListFooter(); ?> + \ No newline at end of file diff --git a/admin/views/open_ai_messages/tmpl/default_head.php b/admin/views/open_ai_messages/tmpl/default_head.php new file mode 100644 index 0000000..2f4f6d4 --- /dev/null +++ b/admin/views/open_ai_messages/tmpl/default_head.php @@ -0,0 +1,62 @@ + + @git Get Bible + @github Get Bible + @support Get Bible + @copyright Copyright (C) 2015. All Rights Reserved + @license GNU/GPL Version 2 or later - http://www.gnu.org/licenses/gpl-2.0.html + +/------------------------------------------------------------------------------------------------------*/ + +// No direct access to this file +defined('_JEXEC') or die('Restricted access'); + +?> + + canEdit&& $this->canState): ?> + + listDirn, $this->listOrder, null, 'asc', 'JGRID_HEADING_ORDERING', 'icon-menu-2'); ?> + + + + + + + ▾ + + + ■ + + + + listDirn, $this->listOrder); ?> + + + listDirn, $this->listOrder); ?> + + + listDirn, $this->listOrder); ?> + + + listDirn, $this->listOrder); ?> + + canState): ?> + + listDirn, $this->listOrder); ?> + + + + + + + + listDirn, $this->listOrder); ?> + + \ No newline at end of file diff --git a/admin/views/open_ai_messages/tmpl/default_toolbar.php b/admin/views/open_ai_messages/tmpl/default_toolbar.php new file mode 100644 index 0000000..665453b --- /dev/null +++ b/admin/views/open_ai_messages/tmpl/default_toolbar.php @@ -0,0 +1,51 @@ + + @git Get Bible + @github Get Bible + @support Get Bible + @copyright Copyright (C) 2015. All Rights Reserved + @license GNU/GPL Version 2 or later - http://www.gnu.org/licenses/gpl-2.0.html + +/------------------------------------------------------------------------------------------------------*/ + +// No direct access to this file +defined('_JEXEC') or die('Restricted access'); + +?> +
+ +
+ + +
+
+ + pagination->getLimitBox(); ?> +
+
+ + +
+
+ + +
+
+
\ No newline at end of file diff --git a/admin/views/open_ai_messages/tmpl/index.html b/admin/views/open_ai_messages/tmpl/index.html new file mode 100644 index 0000000..fa6d84e --- /dev/null +++ b/admin/views/open_ai_messages/tmpl/index.html @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/admin/views/open_ai_messages/view.html.php b/admin/views/open_ai_messages/view.html.php new file mode 100644 index 0000000..51522f9 --- /dev/null +++ b/admin/views/open_ai_messages/view.html.php @@ -0,0 +1,310 @@ + + @git Get Bible + @github Get Bible + @support Get Bible + @copyright Copyright (C) 2015. All Rights Reserved + @license GNU/GPL Version 2 or later - http://www.gnu.org/licenses/gpl-2.0.html + +/------------------------------------------------------------------------------------------------------*/ + +// No direct access to this file +defined('_JEXEC') or die('Restricted access'); + +use Joomla\CMS\MVC\View\HtmlView; + +/** + * Getbible Html View class for the Open_ai_messages + */ +class GetbibleViewOpen_ai_messages extends HtmlView +{ + /** + * Open_ai_messages view display method + * @return void + */ + function display($tpl = null) + { + if ($this->getLayout() !== 'modal') + { + // Include helper submenu + GetbibleHelper::addSubmenu('open_ai_messages'); + } + + // Assign data to the view + $this->items = $this->get('Items'); + $this->pagination = $this->get('Pagination'); + $this->state = $this->get('State'); + $this->user = JFactory::getUser(); + // Load the filter form from xml. + $this->filterForm = $this->get('FilterForm'); + // Load the active filters. + $this->activeFilters = $this->get('ActiveFilters'); + // Add the list ordering clause. + $this->listOrder = $this->escape($this->state->get('list.ordering', 'a.id')); + $this->listDirn = $this->escape($this->state->get('list.direction', 'desc')); + $this->saveOrder = $this->listOrder == 'a.ordering'; + // set the return here value + $this->return_here = urlencode(base64_encode((string) JUri::getInstance())); + // get global action permissions + $this->canDo = GetbibleHelper::getActions('open_ai_message'); + $this->canEdit = $this->canDo->get('open_ai_message.edit'); + $this->canState = $this->canDo->get('open_ai_message.edit.state'); + $this->canCreate = $this->canDo->get('open_ai_message.create'); + $this->canDelete = $this->canDo->get('open_ai_message.delete'); + $this->canBatch = $this->canDo->get('core.batch'); + + // We don't need toolbar in the modal window. + if ($this->getLayout() !== 'modal') + { + $this->addToolbar(); + $this->sidebar = JHtmlSidebar::render(); + // load the batch html + if ($this->canCreate && $this->canEdit && $this->canState) + { + $this->batchDisplay = JHtmlBatch_::render(); + } + } + + // Check for errors. + if (count($errors = $this->get('Errors'))) + { + throw new Exception(implode("\n", $errors), 500); + } + + // Display the template + parent::display($tpl); + + // Set the document + $this->setDocument(); + } + + /** + * Setting the toolbar + */ + protected function addToolBar() + { + JToolBarHelper::title(JText::_('COM_GETBIBLE_OPEN_AI_MESSAGES'), 'comment'); + JHtmlSidebar::setAction('index.php?option=com_getbible&view=open_ai_messages'); + JFormHelper::addFieldPath(JPATH_COMPONENT . '/models/fields'); + + if ($this->canCreate) + { + JToolBarHelper::addNew('open_ai_message.add'); + } + + // Only load if there are items + if (GetbibleHelper::checkArray($this->items)) + { + if ($this->canEdit) + { + JToolBarHelper::editList('open_ai_message.edit'); + } + + if ($this->canState) + { + JToolBarHelper::publishList('open_ai_messages.publish'); + JToolBarHelper::unpublishList('open_ai_messages.unpublish'); + JToolBarHelper::archiveList('open_ai_messages.archive'); + + if ($this->canDo->get('core.admin')) + { + JToolBarHelper::checkin('open_ai_messages.checkin'); + } + } + + // Add a batch button + if ($this->canBatch && $this->canCreate && $this->canEdit && $this->canState) + { + // Get the toolbar object instance + $bar = JToolBar::getInstance('toolbar'); + // set the batch button name + $title = JText::_('JTOOLBAR_BATCH'); + // Instantiate a new JLayoutFile instance and render the batch button + $layout = new JLayoutFile('joomla.toolbar.batch'); + // add the button to the page + $dhtml = $layout->render(array('title' => $title)); + $bar->appendButton('Custom', $dhtml, 'batch'); + } + + if ($this->state->get('filter.published') == -2 && ($this->canState && $this->canDelete)) + { + JToolbarHelper::deleteList('', 'open_ai_messages.delete', 'JTOOLBAR_EMPTY_TRASH'); + } + elseif ($this->canState && $this->canDelete) + { + JToolbarHelper::trash('open_ai_messages.trash'); + } + } + + // set help url for this view if found + $this->help_url = GetbibleHelper::getHelpUrl('open_ai_messages'); + if (GetbibleHelper::checkString($this->help_url)) + { + JToolbarHelper::help('COM_GETBIBLE_HELP_MANAGER', false, $this->help_url); + } + + // add the options comp button + if ($this->canDo->get('core.admin') || $this->canDo->get('core.options')) + { + JToolBarHelper::preferences('com_getbible'); + } + + // Only load published batch if state and batch is allowed + if ($this->canState && $this->canBatch) + { + JHtmlBatch_::addListSelection( + JText::_('COM_GETBIBLE_KEEP_ORIGINAL_STATE'), + 'batch[published]', + JHtml::_('select.options', JHtml::_('jgrid.publishedOptions', array('all' => false)), 'value', 'text', '', true) + ); + } + + // Only load access batch if create, edit and batch is allowed + if ($this->canBatch && $this->canCreate && $this->canEdit) + { + JHtmlBatch_::addListSelection( + JText::_('COM_GETBIBLE_KEEP_ORIGINAL_ACCESS'), + 'batch[access]', + JHtml::_('select.options', JHtml::_('access.assetgroups'), 'value', 'text') + ); + } + + // Only load Role batch if create, edit, and batch is allowed + if ($this->canBatch && $this->canCreate && $this->canEdit) + { + // Set Role Selection + $this->roleOptions = JFormHelper::loadFieldType('openaimessagesfilterrole')->options; + // We do some sanitation for Role filter + if (GetbibleHelper::checkArray($this->roleOptions) && + isset($this->roleOptions[0]->value) && + !GetbibleHelper::checkString($this->roleOptions[0]->value)) + { + unset($this->roleOptions[0]); + } + // Role Batch Selection + JHtmlBatch_::addListSelection( + '- Keep Original '.JText::_('COM_GETBIBLE_OPEN_AI_MESSAGE_ROLE_LABEL').' -', + 'batch[role]', + JHtml::_('select.options', $this->roleOptions, 'value', 'text') + ); + } + + // Only load Open Ai Response Response Id batch if create, edit, and batch is allowed + if ($this->canBatch && $this->canCreate && $this->canEdit) + { + // Set Open Ai Response Response Id Selection + $this->open_ai_responseResponse_idOptions = JFormHelper::loadFieldType('Openairesponses')->options; + // We do some sanitation for Open Ai Response Response Id filter + if (GetbibleHelper::checkArray($this->open_ai_responseResponse_idOptions) && + isset($this->open_ai_responseResponse_idOptions[0]->value) && + !GetbibleHelper::checkString($this->open_ai_responseResponse_idOptions[0]->value)) + { + unset($this->open_ai_responseResponse_idOptions[0]); + } + // Open Ai Response Response Id Batch Selection + JHtmlBatch_::addListSelection( + '- Keep Original '.JText::_('COM_GETBIBLE_OPEN_AI_MESSAGE_OPEN_AI_RESPONSE_LABEL').' -', + 'batch[open_ai_response]', + JHtml::_('select.options', $this->open_ai_responseResponse_idOptions, 'value', 'text') + ); + } + + // Only load Prompt Name batch if create, edit, and batch is allowed + if ($this->canBatch && $this->canCreate && $this->canEdit) + { + // Set Prompt Name Selection + $this->promptNameOptions = JFormHelper::loadFieldType('Prompts')->options; + // We do some sanitation for Prompt Name filter + if (GetbibleHelper::checkArray($this->promptNameOptions) && + isset($this->promptNameOptions[0]->value) && + !GetbibleHelper::checkString($this->promptNameOptions[0]->value)) + { + unset($this->promptNameOptions[0]); + } + // Prompt Name Batch Selection + JHtmlBatch_::addListSelection( + '- Keep Original '.JText::_('COM_GETBIBLE_OPEN_AI_MESSAGE_PROMPT_LABEL').' -', + 'batch[prompt]', + JHtml::_('select.options', $this->promptNameOptions, 'value', 'text') + ); + } + + // Only load Source batch if create, edit, and batch is allowed + if ($this->canBatch && $this->canCreate && $this->canEdit) + { + // Set Source Selection + $this->sourceOptions = JFormHelper::loadFieldType('openaimessagesfiltersource')->options; + // We do some sanitation for Source filter + if (GetbibleHelper::checkArray($this->sourceOptions) && + isset($this->sourceOptions[0]->value) && + !GetbibleHelper::checkString($this->sourceOptions[0]->value)) + { + unset($this->sourceOptions[0]); + } + // Source Batch Selection + JHtmlBatch_::addListSelection( + '- Keep Original '.JText::_('COM_GETBIBLE_OPEN_AI_MESSAGE_SOURCE_LABEL').' -', + 'batch[source]', + JHtml::_('select.options', $this->sourceOptions, 'value', 'text') + ); + } + } + + /** + * Method to set up the document properties + * + * @return void + */ + protected function setDocument() + { + if (!isset($this->document)) + { + $this->document = JFactory::getDocument(); + } + $this->document->setTitle(JText::_('COM_GETBIBLE_OPEN_AI_MESSAGES')); + $this->document->addStyleSheet(JURI::root() . "administrator/components/com_getbible/assets/css/open_ai_messages.css", (GetbibleHelper::jVersion()->isCompatible('3.8.0')) ? array('version' => 'auto') : 'text/css'); + } + + /** + * Escapes a value for output in a view script. + * + * @param mixed $var The output to escape. + * + * @return mixed The escaped value. + */ + public function escape($var) + { + if(strlen($var) > 50) + { + // use the helper htmlEscape method instead and shorten the string + return GetbibleHelper::htmlEscape($var, $this->_charset, true); + } + // use the helper htmlEscape method instead. + return GetbibleHelper::htmlEscape($var, $this->_charset); + } + + /** + * Returns an array of fields the table can be sorted by + * + * @return array Array containing the field name to sort by as the key and display text as value + */ + protected function getSortFields() + { + return array( + 'a.ordering' => JText::_('JGRID_HEADING_ORDERING'), + 'a.published' => JText::_('JSTATUS'), + 'a.role' => JText::_('COM_GETBIBLE_OPEN_AI_MESSAGE_ROLE_LABEL'), + 'g.response_id' => JText::_('COM_GETBIBLE_OPEN_AI_MESSAGE_OPEN_AI_RESPONSE_LABEL'), + 'h.name' => JText::_('COM_GETBIBLE_OPEN_AI_MESSAGE_PROMPT_LABEL'), + 'a.source' => JText::_('COM_GETBIBLE_OPEN_AI_MESSAGE_SOURCE_LABEL'), + 'a.id' => JText::_('JGRID_HEADING_ID') + ); + } +} diff --git a/admin/views/open_ai_response/submitbutton.js b/admin/views/open_ai_response/submitbutton.js new file mode 100644 index 0000000..975edef --- /dev/null +++ b/admin/views/open_ai_response/submitbutton.js @@ -0,0 +1,31 @@ +/*----------------------------------------------------------------------------------| io.vdm.dev |----/ + Vast Development Method +/-------------------------------------------------------------------------------------------------------/ + + @package getBible.net + + @created 3rd December, 2015 + @author Llewellyn van der Merwe + @git Get Bible + @github Get Bible + @support Get Bible + @copyright Copyright (C) 2015. All Rights Reserved + @license GNU/GPL Version 2 or later - http://www.gnu.org/licenses/gpl-2.0.html + +/------------------------------------------------------------------------------------------------------*/ + +Joomla.submitbutton = function(task) +{ + if (task == ''){ + return false; + } else { + var action = task.split('.'); + if (action[1] == 'cancel' || action[1] == 'close' || document.formvalidator.isValid(document.getElementById("adminForm"))){ + Joomla.submitform(task, document.getElementById("adminForm")); + return true; + } else { + alert(Joomla.JText._('open_ai_response, some values are not acceptable.','Some values are unacceptable')); + return false; + } + } +} \ No newline at end of file diff --git a/admin/views/open_ai_response/tmpl/edit.php b/admin/views/open_ai_response/tmpl/edit.php new file mode 100644 index 0000000..012a0b8 --- /dev/null +++ b/admin/views/open_ai_response/tmpl/edit.php @@ -0,0 +1,146 @@ + + @git Get Bible + @github Get Bible + @support Get Bible + @copyright Copyright (C) 2015. All Rights Reserved + @license GNU/GPL Version 2 or later - http://www.gnu.org/licenses/gpl-2.0.html + +/------------------------------------------------------------------------------------------------------*/ + +// No direct access to this file +defined('_JEXEC') or die('Restricted access'); + +JHtml::addIncludePath(JPATH_COMPONENT.'/helpers/html'); +JHtml::_('behavior.formvalidator'); +JHtml::_('formbehavior.chosen', 'select'); +JHtml::_('behavior.keepalive'); +$componentParams = $this->params; // will be removed just use $this->params instead +?> + + diff --git a/admin/views/open_ai_response/tmpl/index.html b/admin/views/open_ai_response/tmpl/index.html new file mode 100644 index 0000000..fa6d84e --- /dev/null +++ b/admin/views/open_ai_response/tmpl/index.html @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/admin/views/open_ai_response/view.html.php b/admin/views/open_ai_response/view.html.php new file mode 100644 index 0000000..3b6db38 --- /dev/null +++ b/admin/views/open_ai_response/view.html.php @@ -0,0 +1,230 @@ + + @git Get Bible + @github Get Bible + @support Get Bible + @copyright Copyright (C) 2015. All Rights Reserved + @license GNU/GPL Version 2 or later - http://www.gnu.org/licenses/gpl-2.0.html + +/------------------------------------------------------------------------------------------------------*/ + +// No direct access to this file +defined('_JEXEC') or die('Restricted access'); + +use Joomla\CMS\MVC\View\HtmlView; + +/** + * Open_ai_response Html View class + */ +class GetbibleViewOpen_ai_response extends HtmlView +{ + /** + * display method of View + * @return void + */ + public function display($tpl = null) + { + // set params + $this->params = JComponentHelper::getParams('com_getbible'); + // Assign the variables + $this->form = $this->get('Form'); + $this->item = $this->get('Item'); + $this->script = $this->get('Script'); + $this->state = $this->get('State'); + // get action permissions + $this->canDo = GetbibleHelper::getActions('open_ai_response', $this->item); + // get input + $jinput = JFactory::getApplication()->input; + $this->ref = $jinput->get('ref', 0, 'word'); + $this->refid = $jinput->get('refid', 0, 'int'); + $return = $jinput->get('return', null, 'base64'); + // set the referral string + $this->referral = ''; + if ($this->refid && $this->ref) + { + // return to the item that referred to this item + $this->referral = '&ref=' . (string)$this->ref . '&refid=' . (int)$this->refid; + } + elseif($this->ref) + { + // return to the list view that referred to this item + $this->referral = '&ref=' . (string)$this->ref; + } + // check return value + if (!is_null($return)) + { + // add the return value + $this->referral .= '&return=' . (string)$return; + } + + // Get Linked view data + $this->vvymessage = $this->get('Vvymessage'); + + // Set the toolbar + $this->addToolBar(); + + // Check for errors. + if (count($errors = $this->get('Errors'))) + { + throw new Exception(implode("\n", $errors), 500); + } + + // Display the template + parent::display($tpl); + + // Set the document + $this->setDocument(); + } + + + /** + * Setting the toolbar + */ + protected function addToolBar() + { + JFactory::getApplication()->input->set('hidemainmenu', true); + $user = JFactory::getUser(); + $userId = $user->id; + $isNew = $this->item->id == 0; + + JToolbarHelper::title( JText::_($isNew ? 'COM_GETBIBLE_OPEN_AI_RESPONSE_NEW' : 'COM_GETBIBLE_OPEN_AI_RESPONSE_EDIT'), 'pencil-2 article-add'); + // Built the actions for new and existing records. + if (GetbibleHelper::checkString($this->referral)) + { + if ($this->canDo->get('open_ai_response.create') && $isNew) + { + // We can create the record. + JToolBarHelper::save('open_ai_response.save', 'JTOOLBAR_SAVE'); + } + elseif ($this->canDo->get('open_ai_response.edit')) + { + // We can save the record. + JToolBarHelper::save('open_ai_response.save', 'JTOOLBAR_SAVE'); + } + if ($isNew) + { + // Do not creat but cancel. + JToolBarHelper::cancel('open_ai_response.cancel', 'JTOOLBAR_CANCEL'); + } + else + { + // We can close it. + JToolBarHelper::cancel('open_ai_response.cancel', 'JTOOLBAR_CLOSE'); + } + } + else + { + if ($isNew) + { + // For new records, check the create permission. + if ($this->canDo->get('open_ai_response.create')) + { + JToolBarHelper::apply('open_ai_response.apply', 'JTOOLBAR_APPLY'); + JToolBarHelper::save('open_ai_response.save', 'JTOOLBAR_SAVE'); + JToolBarHelper::custom('open_ai_response.save2new', 'save-new.png', 'save-new_f2.png', 'JTOOLBAR_SAVE_AND_NEW', false); + }; + JToolBarHelper::cancel('open_ai_response.cancel', 'JTOOLBAR_CANCEL'); + } + else + { + if ($this->canDo->get('open_ai_response.edit')) + { + // We can save the new record + JToolBarHelper::apply('open_ai_response.apply', 'JTOOLBAR_APPLY'); + JToolBarHelper::save('open_ai_response.save', 'JTOOLBAR_SAVE'); + // We can save this record, but check the create permission to see + // if we can return to make a new one. + if ($this->canDo->get('open_ai_response.create')) + { + JToolBarHelper::custom('open_ai_response.save2new', 'save-new.png', 'save-new_f2.png', 'JTOOLBAR_SAVE_AND_NEW', false); + } + } + $canVersion = ($this->canDo->get('core.version') && $this->canDo->get('open_ai_response.version')); + if ($this->state->params->get('save_history', 1) && $this->canDo->get('open_ai_response.edit') && $canVersion) + { + JToolbarHelper::versions('com_getbible.open_ai_response', $this->item->id); + } + if ($this->canDo->get('open_ai_response.create')) + { + JToolBarHelper::custom('open_ai_response.save2copy', 'save-copy.png', 'save-copy_f2.png', 'JTOOLBAR_SAVE_AS_COPY', false); + } + JToolBarHelper::cancel('open_ai_response.cancel', 'JTOOLBAR_CLOSE'); + } + } + JToolbarHelper::divider(); + // set help url for this view if found + $this->help_url = GetbibleHelper::getHelpUrl('open_ai_response'); + if (GetbibleHelper::checkString($this->help_url)) + { + JToolbarHelper::help('COM_GETBIBLE_HELP_MANAGER', false, $this->help_url); + } + } + + /** + * Escapes a value for output in a view script. + * + * @param mixed $var The output to escape. + * + * @return mixed The escaped value. + */ + public function escape($var) + { + if(strlen($var) > 30) + { + // use the helper htmlEscape method instead and shorten the string + return GetbibleHelper::htmlEscape($var, $this->_charset, true, 30); + } + // use the helper htmlEscape method instead. + return GetbibleHelper::htmlEscape($var, $this->_charset); + } + + /** + * Method to set up the document properties + * + * @return void + */ + protected function setDocument() + { + $isNew = ($this->item->id < 1); + if (!isset($this->document)) + { + $this->document = JFactory::getDocument(); + } + $this->document->setTitle(JText::_($isNew ? 'COM_GETBIBLE_OPEN_AI_RESPONSE_NEW' : 'COM_GETBIBLE_OPEN_AI_RESPONSE_EDIT')); + $this->document->addStyleSheet(JURI::root() . "administrator/components/com_getbible/assets/css/open_ai_response.css", (GetbibleHelper::jVersion()->isCompatible('3.8.0')) ? array('version' => 'auto') : 'text/css'); + + // Add the CSS for Footable. + JHtml::_('stylesheet', 'media/com_getbible/footable-v2/css/footable.core.min.css', ['version' => 'auto']); + + // Use the Metro Style + if (!isset($this->fooTableStyle) || 0 == $this->fooTableStyle) + { + JHtml::_('stylesheet', 'media/com_getbible/footable-v2/css/footable.metro.min.css', ['version' => 'auto']); + } + // Use the Legacy Style. + elseif (isset($this->fooTableStyle) && 1 == $this->fooTableStyle) + { + JHtml::_('stylesheet', 'media/com_getbible/footable-v2/css/footable.standalone.min.css', ['version' => 'auto']); + } + + // Add the JavaScript for Footable + JHtml::_('script', 'media/com_getbible/footable-v2/js/footable.js', ['version' => 'auto']); + JHtml::_('script', 'media/com_getbible/footable-v2/js/footable.sort.js', ['version' => 'auto']); + JHtml::_('script', 'media/com_getbible/footable-v2/js/footable.filter.js', ['version' => 'auto']); + JHtml::_('script', 'media/com_getbible/footable-v2/js/footable.paginate.js', ['version' => 'auto']); + + $footable = "jQuery(document).ready(function() { jQuery(function () { jQuery('.footable').footable(); }); jQuery('.nav-tabs').on('click', 'li', function() { setTimeout(tableFix, 10); }); }); function tableFix() { jQuery('.footable').trigger('footable_resize'); }"; + $this->document->addScriptDeclaration($footable); + + $this->document->addScript(JURI::root() . $this->script, (GetbibleHelper::jVersion()->isCompatible('3.8.0')) ? array('version' => 'auto') : 'text/javascript'); + $this->document->addScript(JURI::root() . "administrator/components/com_getbible/views/open_ai_response/submitbutton.js", (GetbibleHelper::jVersion()->isCompatible('3.8.0')) ? array('version' => 'auto') : 'text/javascript'); + JText::script('view not acceptable. Error'); + } +} diff --git a/admin/views/open_ai_responses/index.html b/admin/views/open_ai_responses/index.html new file mode 100644 index 0000000..fa6d84e --- /dev/null +++ b/admin/views/open_ai_responses/index.html @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/admin/views/open_ai_responses/tmpl/default.php b/admin/views/open_ai_responses/tmpl/default.php new file mode 100644 index 0000000..8430029 --- /dev/null +++ b/admin/views/open_ai_responses/tmpl/default.php @@ -0,0 +1,73 @@ + + @git Get Bible + @github Get Bible + @support Get Bible + @copyright Copyright (C) 2015. All Rights Reserved + @license GNU/GPL Version 2 or later - http://www.gnu.org/licenses/gpl-2.0.html + +/------------------------------------------------------------------------------------------------------*/ + +// No direct access to this file +defined('_JEXEC') or die('Restricted access'); + +JHtml::_('behavior.multiselect'); +JHtml::_('dropdown.init'); +JHtml::_('formbehavior.chosen', '.multipleAccessLevels', null, array('placeholder_text_multiple' => '- ' . JText::_('COM_GETBIBLE_FILTER_SELECT_ACCESS') . ' -')); +JHtml::_('formbehavior.chosen', 'select'); +if ($this->saveOrder) +{ + $saveOrderingUrl = 'index.php?option=com_getbible&task=open_ai_responses.saveOrderAjax&tmpl=component'; + JHtml::_('sortablelist.sortable', 'open_ai_responseList', 'adminForm', strtolower($this->listDirn), $saveOrderingUrl); +} +?> +
+sidebar)): ?> +
+ sidebar; ?> +
+
+ +
+ + $this)); +?> +items)): ?> +
+ +
+ + + loadTemplate('head');?> + loadTemplate('foot');?> + loadTemplate('body');?> +
+ + canCreate && $this->canEdit) : ?> + JText::_('COM_GETBIBLE_OPEN_AI_RESPONSES_BATCH_OPTIONS'), + 'footer' => $this->loadTemplate('batch_footer') + ), + $this->loadTemplate('batch_body') + ); ?> + + +
+ + + + diff --git a/admin/views/open_ai_responses/tmpl/default_batch_body.php b/admin/views/open_ai_responses/tmpl/default_batch_body.php new file mode 100644 index 0000000..ee5919d --- /dev/null +++ b/admin/views/open_ai_responses/tmpl/default_batch_body.php @@ -0,0 +1,24 @@ + + @git Get Bible + @github Get Bible + @support Get Bible + @copyright Copyright (C) 2015. All Rights Reserved + @license GNU/GPL Version 2 or later - http://www.gnu.org/licenses/gpl-2.0.html + +/------------------------------------------------------------------------------------------------------*/ + +// No direct access to this file +defined('_JEXEC') or die('Restricted access'); + +?> + +

+batchDisplay; ?> \ No newline at end of file diff --git a/admin/views/open_ai_responses/tmpl/default_batch_footer.php b/admin/views/open_ai_responses/tmpl/default_batch_footer.php new file mode 100644 index 0000000..0cb25d3 --- /dev/null +++ b/admin/views/open_ai_responses/tmpl/default_batch_footer.php @@ -0,0 +1,29 @@ + + @git Get Bible + @github Get Bible + @support Get Bible + @copyright Copyright (C) 2015. All Rights Reserved + @license GNU/GPL Version 2 or later - http://www.gnu.org/licenses/gpl-2.0.html + +/------------------------------------------------------------------------------------------------------*/ + +// No direct access to this file +defined('_JEXEC') or die('Restricted access'); + +?> + + + + \ No newline at end of file diff --git a/admin/views/open_ai_responses/tmpl/default_body.php b/admin/views/open_ai_responses/tmpl/default_body.php new file mode 100644 index 0000000..7af3ea5 --- /dev/null +++ b/admin/views/open_ai_responses/tmpl/default_body.php @@ -0,0 +1,115 @@ + + @git Get Bible + @github Get Bible + @support Get Bible + @copyright Copyright (C) 2015. All Rights Reserved + @license GNU/GPL Version 2 or later - http://www.gnu.org/licenses/gpl-2.0.html + +/------------------------------------------------------------------------------------------------------*/ + +// No direct access to this file +defined('_JEXEC') or die('Restricted access'); + +$edit = "index.php?option=com_getbible&view=open_ai_responses&task=open_ai_response.edit"; + +?> +items as $i => $item): ?> + user->authorise('core.manage', 'com_checkin') || $item->checked_out == $this->user->id || $item->checked_out == 0; + $userChkOut = JFactory::getUser($item->checked_out); + $canDo = GetbibleHelper::getActions('open_ai_response',$item,'open_ai_responses'); + ?> + + + get('open_ai_response.edit.state')): ?> + saveOrder) + { + $iconClass = ' inactive tip-top" hasTooltip" title="' . JHtml::tooltipText('JORDERINGDISABLED'); + } + ?> + + + + saveOrder) : ?> + + + + ⋮ + + + + get('open_ai_response.edit')): ?> + checked_out) : ?> + + id); ?> + + □ + + + id); ?> + + + □ + + + +
+ get('open_ai_response.edit')): ?> + escape($item->response_id); ?> + checked_out): ?> + name, $item->checked_out_time, 'open_ai_responses.', $canCheckin); ?> + + + escape($item->response_id); ?> + +
+ + +
+ user->authorise('prompt.edit', 'com_getbible.prompt.' . (int) $item->prompt_id)): ?> + escape($item->prompt_name); ?> + + escape($item->prompt_name); ?> + +
+ + + escape($item->response_object); ?> + + + escape($item->response_model); ?> + + + escape($item->total_tokens); ?> + + + get('open_ai_response.edit.state')) : ?> + checked_out) : ?> + + published, $i, 'open_ai_responses.', true, 'cb'); ?> + + published, $i, 'open_ai_responses.', false, 'cb'); ?> + + + published, $i, 'open_ai_responses.', true, 'cb'); ?> + + + published, $i, 'open_ai_responses.', false, 'cb'); ?> + + + + id; ?> + + + \ No newline at end of file diff --git a/admin/views/open_ai_responses/tmpl/default_foot.php b/admin/views/open_ai_responses/tmpl/default_foot.php new file mode 100644 index 0000000..6df0a9f --- /dev/null +++ b/admin/views/open_ai_responses/tmpl/default_foot.php @@ -0,0 +1,24 @@ + + @git Get Bible + @github Get Bible + @support Get Bible + @copyright Copyright (C) 2015. All Rights Reserved + @license GNU/GPL Version 2 or later - http://www.gnu.org/licenses/gpl-2.0.html + +/------------------------------------------------------------------------------------------------------*/ + +// No direct access to this file +defined('_JEXEC') or die('Restricted access'); + +?> + + pagination->getListFooter(); ?> + \ No newline at end of file diff --git a/admin/views/open_ai_responses/tmpl/default_head.php b/admin/views/open_ai_responses/tmpl/default_head.php new file mode 100644 index 0000000..ca3f75d --- /dev/null +++ b/admin/views/open_ai_responses/tmpl/default_head.php @@ -0,0 +1,65 @@ + + @git Get Bible + @github Get Bible + @support Get Bible + @copyright Copyright (C) 2015. All Rights Reserved + @license GNU/GPL Version 2 or later - http://www.gnu.org/licenses/gpl-2.0.html + +/------------------------------------------------------------------------------------------------------*/ + +// No direct access to this file +defined('_JEXEC') or die('Restricted access'); + +?> + + canEdit&& $this->canState): ?> + + listDirn, $this->listOrder, null, 'asc', 'JGRID_HEADING_ORDERING', 'icon-menu-2'); ?> + + + + + + + ▾ + + + ■ + + + + listDirn, $this->listOrder); ?> + + + listDirn, $this->listOrder); ?> + + + listDirn, $this->listOrder); ?> + + + listDirn, $this->listOrder); ?> + + + listDirn, $this->listOrder); ?> + + canState): ?> + + listDirn, $this->listOrder); ?> + + + + + + + + listDirn, $this->listOrder); ?> + + \ No newline at end of file diff --git a/admin/views/open_ai_responses/tmpl/default_toolbar.php b/admin/views/open_ai_responses/tmpl/default_toolbar.php new file mode 100644 index 0000000..ef1197e --- /dev/null +++ b/admin/views/open_ai_responses/tmpl/default_toolbar.php @@ -0,0 +1,51 @@ + + @git Get Bible + @github Get Bible + @support Get Bible + @copyright Copyright (C) 2015. All Rights Reserved + @license GNU/GPL Version 2 or later - http://www.gnu.org/licenses/gpl-2.0.html + +/------------------------------------------------------------------------------------------------------*/ + +// No direct access to this file +defined('_JEXEC') or die('Restricted access'); + +?> +
+ +
+ + +
+
+ + pagination->getLimitBox(); ?> +
+
+ + +
+
+ + +
+
+
\ No newline at end of file diff --git a/admin/views/open_ai_responses/tmpl/index.html b/admin/views/open_ai_responses/tmpl/index.html new file mode 100644 index 0000000..fa6d84e --- /dev/null +++ b/admin/views/open_ai_responses/tmpl/index.html @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/admin/views/open_ai_responses/view.html.php b/admin/views/open_ai_responses/view.html.php new file mode 100644 index 0000000..4d27453 --- /dev/null +++ b/admin/views/open_ai_responses/view.html.php @@ -0,0 +1,291 @@ + + @git Get Bible + @github Get Bible + @support Get Bible + @copyright Copyright (C) 2015. All Rights Reserved + @license GNU/GPL Version 2 or later - http://www.gnu.org/licenses/gpl-2.0.html + +/------------------------------------------------------------------------------------------------------*/ + +// No direct access to this file +defined('_JEXEC') or die('Restricted access'); + +use Joomla\CMS\MVC\View\HtmlView; + +/** + * Getbible Html View class for the Open_ai_responses + */ +class GetbibleViewOpen_ai_responses extends HtmlView +{ + /** + * Open_ai_responses view display method + * @return void + */ + function display($tpl = null) + { + if ($this->getLayout() !== 'modal') + { + // Include helper submenu + GetbibleHelper::addSubmenu('open_ai_responses'); + } + + // Assign data to the view + $this->items = $this->get('Items'); + $this->pagination = $this->get('Pagination'); + $this->state = $this->get('State'); + $this->user = JFactory::getUser(); + // Load the filter form from xml. + $this->filterForm = $this->get('FilterForm'); + // Load the active filters. + $this->activeFilters = $this->get('ActiveFilters'); + // Add the list ordering clause. + $this->listOrder = $this->escape($this->state->get('list.ordering', 'a.id')); + $this->listDirn = $this->escape($this->state->get('list.direction', 'desc')); + $this->saveOrder = $this->listOrder == 'a.ordering'; + // set the return here value + $this->return_here = urlencode(base64_encode((string) JUri::getInstance())); + // get global action permissions + $this->canDo = GetbibleHelper::getActions('open_ai_response'); + $this->canEdit = $this->canDo->get('open_ai_response.edit'); + $this->canState = $this->canDo->get('open_ai_response.edit.state'); + $this->canCreate = $this->canDo->get('open_ai_response.create'); + $this->canDelete = $this->canDo->get('open_ai_response.delete'); + $this->canBatch = $this->canDo->get('core.batch'); + + // We don't need toolbar in the modal window. + if ($this->getLayout() !== 'modal') + { + $this->addToolbar(); + $this->sidebar = JHtmlSidebar::render(); + // load the batch html + if ($this->canCreate && $this->canEdit && $this->canState) + { + $this->batchDisplay = JHtmlBatch_::render(); + } + } + + // Check for errors. + if (count($errors = $this->get('Errors'))) + { + throw new Exception(implode("\n", $errors), 500); + } + + // Display the template + parent::display($tpl); + + // Set the document + $this->setDocument(); + } + + /** + * Setting the toolbar + */ + protected function addToolBar() + { + JToolBarHelper::title(JText::_('COM_GETBIBLE_OPEN_AI_RESPONSES'), 'reply'); + JHtmlSidebar::setAction('index.php?option=com_getbible&view=open_ai_responses'); + JFormHelper::addFieldPath(JPATH_COMPONENT . '/models/fields'); + + if ($this->canCreate) + { + JToolBarHelper::addNew('open_ai_response.add'); + } + + // Only load if there are items + if (GetbibleHelper::checkArray($this->items)) + { + if ($this->canEdit) + { + JToolBarHelper::editList('open_ai_response.edit'); + } + + if ($this->canState) + { + JToolBarHelper::publishList('open_ai_responses.publish'); + JToolBarHelper::unpublishList('open_ai_responses.unpublish'); + JToolBarHelper::archiveList('open_ai_responses.archive'); + + if ($this->canDo->get('core.admin')) + { + JToolBarHelper::checkin('open_ai_responses.checkin'); + } + } + + // Add a batch button + if ($this->canBatch && $this->canCreate && $this->canEdit && $this->canState) + { + // Get the toolbar object instance + $bar = JToolBar::getInstance('toolbar'); + // set the batch button name + $title = JText::_('JTOOLBAR_BATCH'); + // Instantiate a new JLayoutFile instance and render the batch button + $layout = new JLayoutFile('joomla.toolbar.batch'); + // add the button to the page + $dhtml = $layout->render(array('title' => $title)); + $bar->appendButton('Custom', $dhtml, 'batch'); + } + + if ($this->state->get('filter.published') == -2 && ($this->canState && $this->canDelete)) + { + JToolbarHelper::deleteList('', 'open_ai_responses.delete', 'JTOOLBAR_EMPTY_TRASH'); + } + elseif ($this->canState && $this->canDelete) + { + JToolbarHelper::trash('open_ai_responses.trash'); + } + } + + // set help url for this view if found + $this->help_url = GetbibleHelper::getHelpUrl('open_ai_responses'); + if (GetbibleHelper::checkString($this->help_url)) + { + JToolbarHelper::help('COM_GETBIBLE_HELP_MANAGER', false, $this->help_url); + } + + // add the options comp button + if ($this->canDo->get('core.admin') || $this->canDo->get('core.options')) + { + JToolBarHelper::preferences('com_getbible'); + } + + // Only load published batch if state and batch is allowed + if ($this->canState && $this->canBatch) + { + JHtmlBatch_::addListSelection( + JText::_('COM_GETBIBLE_KEEP_ORIGINAL_STATE'), + 'batch[published]', + JHtml::_('select.options', JHtml::_('jgrid.publishedOptions', array('all' => false)), 'value', 'text', '', true) + ); + } + + // Only load access batch if create, edit and batch is allowed + if ($this->canBatch && $this->canCreate && $this->canEdit) + { + JHtmlBatch_::addListSelection( + JText::_('COM_GETBIBLE_KEEP_ORIGINAL_ACCESS'), + 'batch[access]', + JHtml::_('select.options', JHtml::_('access.assetgroups'), 'value', 'text') + ); + } + + // Only load Response Id batch if create, edit, and batch is allowed + if ($this->canBatch && $this->canCreate && $this->canEdit) + { + // Set Response Id Selection + $this->response_idOptions = JFormHelper::loadFieldType('openairesponsesfilterresponseid')->options; + // We do some sanitation for Response Id filter + if (GetbibleHelper::checkArray($this->response_idOptions) && + isset($this->response_idOptions[0]->value) && + !GetbibleHelper::checkString($this->response_idOptions[0]->value)) + { + unset($this->response_idOptions[0]); + } + // Response Id Batch Selection + JHtmlBatch_::addListSelection( + '- Keep Original '.JText::_('COM_GETBIBLE_OPEN_AI_RESPONSE_RESPONSE_ID_LABEL').' -', + 'batch[response_id]', + JHtml::_('select.options', $this->response_idOptions, 'value', 'text') + ); + } + + // Only load Prompt Name batch if create, edit, and batch is allowed + if ($this->canBatch && $this->canCreate && $this->canEdit) + { + // Set Prompt Name Selection + $this->promptNameOptions = JFormHelper::loadFieldType('Prompts')->options; + // We do some sanitation for Prompt Name filter + if (GetbibleHelper::checkArray($this->promptNameOptions) && + isset($this->promptNameOptions[0]->value) && + !GetbibleHelper::checkString($this->promptNameOptions[0]->value)) + { + unset($this->promptNameOptions[0]); + } + // Prompt Name Batch Selection + JHtmlBatch_::addListSelection( + '- Keep Original '.JText::_('COM_GETBIBLE_OPEN_AI_RESPONSE_PROMPT_LABEL').' -', + 'batch[prompt]', + JHtml::_('select.options', $this->promptNameOptions, 'value', 'text') + ); + } + + // Only load Response Model batch if create, edit, and batch is allowed + if ($this->canBatch && $this->canCreate && $this->canEdit) + { + // Set Response Model Selection + $this->response_modelOptions = JFormHelper::loadFieldType('openairesponsesfilterresponsemodel')->options; + // We do some sanitation for Response Model filter + if (GetbibleHelper::checkArray($this->response_modelOptions) && + isset($this->response_modelOptions[0]->value) && + !GetbibleHelper::checkString($this->response_modelOptions[0]->value)) + { + unset($this->response_modelOptions[0]); + } + // Response Model Batch Selection + JHtmlBatch_::addListSelection( + '- Keep Original '.JText::_('COM_GETBIBLE_OPEN_AI_RESPONSE_RESPONSE_MODEL_LABEL').' -', + 'batch[response_model]', + JHtml::_('select.options', $this->response_modelOptions, 'value', 'text') + ); + } + } + + /** + * Method to set up the document properties + * + * @return void + */ + protected function setDocument() + { + if (!isset($this->document)) + { + $this->document = JFactory::getDocument(); + } + $this->document->setTitle(JText::_('COM_GETBIBLE_OPEN_AI_RESPONSES')); + $this->document->addStyleSheet(JURI::root() . "administrator/components/com_getbible/assets/css/open_ai_responses.css", (GetbibleHelper::jVersion()->isCompatible('3.8.0')) ? array('version' => 'auto') : 'text/css'); + } + + /** + * Escapes a value for output in a view script. + * + * @param mixed $var The output to escape. + * + * @return mixed The escaped value. + */ + public function escape($var) + { + if(strlen($var) > 50) + { + // use the helper htmlEscape method instead and shorten the string + return GetbibleHelper::htmlEscape($var, $this->_charset, true); + } + // use the helper htmlEscape method instead. + return GetbibleHelper::htmlEscape($var, $this->_charset); + } + + /** + * Returns an array of fields the table can be sorted by + * + * @return array Array containing the field name to sort by as the key and display text as value + */ + protected function getSortFields() + { + return array( + 'a.ordering' => JText::_('JGRID_HEADING_ORDERING'), + 'a.published' => JText::_('JSTATUS'), + 'a.response_id' => JText::_('COM_GETBIBLE_OPEN_AI_RESPONSE_RESPONSE_ID_LABEL'), + 'g.name' => JText::_('COM_GETBIBLE_OPEN_AI_RESPONSE_PROMPT_LABEL'), + 'a.response_object' => JText::_('COM_GETBIBLE_OPEN_AI_RESPONSE_RESPONSE_OBJECT_LABEL'), + 'a.response_model' => JText::_('COM_GETBIBLE_OPEN_AI_RESPONSE_RESPONSE_MODEL_LABEL'), + 'a.total_tokens' => JText::_('COM_GETBIBLE_OPEN_AI_RESPONSE_TOTAL_TOKENS_LABEL'), + 'a.id' => JText::_('JGRID_HEADING_ID') + ); + } +} diff --git a/admin/views/password/submitbutton.js b/admin/views/password/submitbutton.js new file mode 100644 index 0000000..91edb6e --- /dev/null +++ b/admin/views/password/submitbutton.js @@ -0,0 +1,31 @@ +/*----------------------------------------------------------------------------------| io.vdm.dev |----/ + Vast Development Method +/-------------------------------------------------------------------------------------------------------/ + + @package getBible.net + + @created 3rd December, 2015 + @author Llewellyn van der Merwe + @git Get Bible + @github Get Bible + @support Get Bible + @copyright Copyright (C) 2015. All Rights Reserved + @license GNU/GPL Version 2 or later - http://www.gnu.org/licenses/gpl-2.0.html + +/------------------------------------------------------------------------------------------------------*/ + +Joomla.submitbutton = function(task) +{ + if (task == ''){ + return false; + } else { + var action = task.split('.'); + if (action[1] == 'cancel' || action[1] == 'close' || document.formvalidator.isValid(document.getElementById("adminForm"))){ + Joomla.submitform(task, document.getElementById("adminForm")); + return true; + } else { + alert(Joomla.JText._('password, some values are not acceptable.','Some values are unacceptable')); + return false; + } + } +} \ No newline at end of file diff --git a/admin/views/password/tmpl/edit.php b/admin/views/password/tmpl/edit.php new file mode 100644 index 0000000..9cb982d --- /dev/null +++ b/admin/views/password/tmpl/edit.php @@ -0,0 +1,112 @@ + + @git Get Bible + @github Get Bible + @support Get Bible + @copyright Copyright (C) 2015. All Rights Reserved + @license GNU/GPL Version 2 or later - http://www.gnu.org/licenses/gpl-2.0.html + +/------------------------------------------------------------------------------------------------------*/ + +// No direct access to this file +defined('_JEXEC') or die('Restricted access'); + +JHtml::addIncludePath(JPATH_COMPONENT.'/helpers/html'); +JHtml::_('behavior.formvalidator'); +JHtml::_('formbehavior.chosen', 'select'); +JHtml::_('behavior.keepalive'); +$componentParams = $this->params; // will be removed just use $this->params instead +?> + + diff --git a/admin/views/password/tmpl/index.html b/admin/views/password/tmpl/index.html new file mode 100644 index 0000000..fa6d84e --- /dev/null +++ b/admin/views/password/tmpl/index.html @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/admin/views/password/view.html.php b/admin/views/password/view.html.php new file mode 100644 index 0000000..7f7bcc3 --- /dev/null +++ b/admin/views/password/view.html.php @@ -0,0 +1,198 @@ + + @git Get Bible + @github Get Bible + @support Get Bible + @copyright Copyright (C) 2015. All Rights Reserved + @license GNU/GPL Version 2 or later - http://www.gnu.org/licenses/gpl-2.0.html + +/------------------------------------------------------------------------------------------------------*/ + +// No direct access to this file +defined('_JEXEC') or die('Restricted access'); + +use Joomla\CMS\MVC\View\HtmlView; + +/** + * Password Html View class + */ +class GetbibleViewPassword extends HtmlView +{ + /** + * display method of View + * @return void + */ + public function display($tpl = null) + { + // set params + $this->params = JComponentHelper::getParams('com_getbible'); + // Assign the variables + $this->form = $this->get('Form'); + $this->item = $this->get('Item'); + $this->script = $this->get('Script'); + $this->state = $this->get('State'); + // get action permissions + $this->canDo = GetbibleHelper::getActions('password', $this->item); + // get input + $jinput = JFactory::getApplication()->input; + $this->ref = $jinput->get('ref', 0, 'word'); + $this->refid = $jinput->get('refid', 0, 'int'); + $return = $jinput->get('return', null, 'base64'); + // set the referral string + $this->referral = ''; + if ($this->refid && $this->ref) + { + // return to the item that referred to this item + $this->referral = '&ref=' . (string)$this->ref . '&refid=' . (int)$this->refid; + } + elseif($this->ref) + { + // return to the list view that referred to this item + $this->referral = '&ref=' . (string)$this->ref; + } + // check return value + if (!is_null($return)) + { + // add the return value + $this->referral .= '&return=' . (string)$return; + } + + // Set the toolbar + $this->addToolBar(); + + // Check for errors. + if (count($errors = $this->get('Errors'))) + { + throw new Exception(implode("\n", $errors), 500); + } + + // Display the template + parent::display($tpl); + + // Set the document + $this->setDocument(); + } + + + /** + * Setting the toolbar + */ + protected function addToolBar() + { + JFactory::getApplication()->input->set('hidemainmenu', true); + $user = JFactory::getUser(); + $userId = $user->id; + $isNew = $this->item->id == 0; + + JToolbarHelper::title( JText::_($isNew ? 'COM_GETBIBLE_PASSWORD_NEW' : 'COM_GETBIBLE_PASSWORD_EDIT'), 'pencil-2 article-add'); + // Built the actions for new and existing records. + if (GetbibleHelper::checkString($this->referral)) + { + if ($this->canDo->get('password.create') && $isNew) + { + // We can create the record. + JToolBarHelper::save('password.save', 'JTOOLBAR_SAVE'); + } + elseif ($this->canDo->get('password.edit')) + { + // We can save the record. + JToolBarHelper::save('password.save', 'JTOOLBAR_SAVE'); + } + if ($isNew) + { + // Do not creat but cancel. + JToolBarHelper::cancel('password.cancel', 'JTOOLBAR_CANCEL'); + } + else + { + // We can close it. + JToolBarHelper::cancel('password.cancel', 'JTOOLBAR_CLOSE'); + } + } + else + { + if ($isNew) + { + // For new records, check the create permission. + if ($this->canDo->get('password.create')) + { + JToolBarHelper::apply('password.apply', 'JTOOLBAR_APPLY'); + JToolBarHelper::save('password.save', 'JTOOLBAR_SAVE'); + JToolBarHelper::custom('password.save2new', 'save-new.png', 'save-new_f2.png', 'JTOOLBAR_SAVE_AND_NEW', false); + }; + JToolBarHelper::cancel('password.cancel', 'JTOOLBAR_CANCEL'); + } + else + { + if ($this->canDo->get('password.edit')) + { + // We can save the new record + JToolBarHelper::apply('password.apply', 'JTOOLBAR_APPLY'); + JToolBarHelper::save('password.save', 'JTOOLBAR_SAVE'); + // We can save this record, but check the create permission to see + // if we can return to make a new one. + if ($this->canDo->get('password.create')) + { + JToolBarHelper::custom('password.save2new', 'save-new.png', 'save-new_f2.png', 'JTOOLBAR_SAVE_AND_NEW', false); + } + } + if ($this->canDo->get('password.create')) + { + JToolBarHelper::custom('password.save2copy', 'save-copy.png', 'save-copy_f2.png', 'JTOOLBAR_SAVE_AS_COPY', false); + } + JToolBarHelper::cancel('password.cancel', 'JTOOLBAR_CLOSE'); + } + } + JToolbarHelper::divider(); + // set help url for this view if found + $this->help_url = GetbibleHelper::getHelpUrl('password'); + if (GetbibleHelper::checkString($this->help_url)) + { + JToolbarHelper::help('COM_GETBIBLE_HELP_MANAGER', false, $this->help_url); + } + } + + /** + * Escapes a value for output in a view script. + * + * @param mixed $var The output to escape. + * + * @return mixed The escaped value. + */ + public function escape($var) + { + if(strlen($var) > 30) + { + // use the helper htmlEscape method instead and shorten the string + return GetbibleHelper::htmlEscape($var, $this->_charset, true, 30); + } + // use the helper htmlEscape method instead. + return GetbibleHelper::htmlEscape($var, $this->_charset); + } + + /** + * Method to set up the document properties + * + * @return void + */ + protected function setDocument() + { + $isNew = ($this->item->id < 1); + if (!isset($this->document)) + { + $this->document = JFactory::getDocument(); + } + $this->document->setTitle(JText::_($isNew ? 'COM_GETBIBLE_PASSWORD_NEW' : 'COM_GETBIBLE_PASSWORD_EDIT')); + $this->document->addStyleSheet(JURI::root() . "administrator/components/com_getbible/assets/css/password.css", (GetbibleHelper::jVersion()->isCompatible('3.8.0')) ? array('version' => 'auto') : 'text/css'); + $this->document->addScript(JURI::root() . $this->script, (GetbibleHelper::jVersion()->isCompatible('3.8.0')) ? array('version' => 'auto') : 'text/javascript'); + $this->document->addScript(JURI::root() . "administrator/components/com_getbible/views/password/submitbutton.js", (GetbibleHelper::jVersion()->isCompatible('3.8.0')) ? array('version' => 'auto') : 'text/javascript'); + JText::script('view not acceptable. Error'); + } +} diff --git a/admin/views/passwords/index.html b/admin/views/passwords/index.html new file mode 100644 index 0000000..fa6d84e --- /dev/null +++ b/admin/views/passwords/index.html @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/admin/views/passwords/tmpl/default.php b/admin/views/passwords/tmpl/default.php new file mode 100644 index 0000000..b1d8fbf --- /dev/null +++ b/admin/views/passwords/tmpl/default.php @@ -0,0 +1,73 @@ + + @git Get Bible + @github Get Bible + @support Get Bible + @copyright Copyright (C) 2015. All Rights Reserved + @license GNU/GPL Version 2 or later - http://www.gnu.org/licenses/gpl-2.0.html + +/------------------------------------------------------------------------------------------------------*/ + +// No direct access to this file +defined('_JEXEC') or die('Restricted access'); + +JHtml::_('behavior.multiselect'); +JHtml::_('dropdown.init'); +JHtml::_('formbehavior.chosen', '.multipleAccessLevels', null, array('placeholder_text_multiple' => '- ' . JText::_('COM_GETBIBLE_FILTER_SELECT_ACCESS') . ' -')); +JHtml::_('formbehavior.chosen', 'select'); +if ($this->saveOrder) +{ + $saveOrderingUrl = 'index.php?option=com_getbible&task=passwords.saveOrderAjax&tmpl=component'; + JHtml::_('sortablelist.sortable', 'passwordList', 'adminForm', strtolower($this->listDirn), $saveOrderingUrl); +} +?> +
+sidebar)): ?> +
+ sidebar; ?> +
+
+ +
+ + $this)); +?> +items)): ?> +
+ +
+ + + loadTemplate('head');?> + loadTemplate('foot');?> + loadTemplate('body');?> +
+ + canCreate && $this->canEdit) : ?> + JText::_('COM_GETBIBLE_PASSWORDS_BATCH_OPTIONS'), + 'footer' => $this->loadTemplate('batch_footer') + ), + $this->loadTemplate('batch_body') + ); ?> + + +
+ + + + diff --git a/admin/views/passwords/tmpl/default_batch_body.php b/admin/views/passwords/tmpl/default_batch_body.php new file mode 100644 index 0000000..663a506 --- /dev/null +++ b/admin/views/passwords/tmpl/default_batch_body.php @@ -0,0 +1,24 @@ + + @git Get Bible + @github Get Bible + @support Get Bible + @copyright Copyright (C) 2015. All Rights Reserved + @license GNU/GPL Version 2 or later - http://www.gnu.org/licenses/gpl-2.0.html + +/------------------------------------------------------------------------------------------------------*/ + +// No direct access to this file +defined('_JEXEC') or die('Restricted access'); + +?> + +

+batchDisplay; ?> \ No newline at end of file diff --git a/admin/views/passwords/tmpl/default_batch_footer.php b/admin/views/passwords/tmpl/default_batch_footer.php new file mode 100644 index 0000000..4a2e171 --- /dev/null +++ b/admin/views/passwords/tmpl/default_batch_footer.php @@ -0,0 +1,29 @@ + + @git Get Bible + @github Get Bible + @support Get Bible + @copyright Copyright (C) 2015. All Rights Reserved + @license GNU/GPL Version 2 or later - http://www.gnu.org/licenses/gpl-2.0.html + +/------------------------------------------------------------------------------------------------------*/ + +// No direct access to this file +defined('_JEXEC') or die('Restricted access'); + +?> + + + + \ No newline at end of file diff --git a/admin/views/passwords/tmpl/default_body.php b/admin/views/passwords/tmpl/default_body.php new file mode 100644 index 0000000..10b389e --- /dev/null +++ b/admin/views/passwords/tmpl/default_body.php @@ -0,0 +1,109 @@ + + @git Get Bible + @github Get Bible + @support Get Bible + @copyright Copyright (C) 2015. All Rights Reserved + @license GNU/GPL Version 2 or later - http://www.gnu.org/licenses/gpl-2.0.html + +/------------------------------------------------------------------------------------------------------*/ + +// No direct access to this file +defined('_JEXEC') or die('Restricted access'); + +$edit = "index.php?option=com_getbible&view=passwords&task=password.edit"; + +?> +items as $i => $item): ?> + user->authorise('core.manage', 'com_checkin') || $item->checked_out == $this->user->id || $item->checked_out == 0; + $userChkOut = JFactory::getUser($item->checked_out); + $canDo = GetbibleHelper::getActions('password',$item,'passwords'); + ?> + + + get('password.edit.state')): ?> + saveOrder) + { + $iconClass = ' inactive tip-top" hasTooltip" title="' . JHtml::tooltipText('JORDERINGDISABLED'); + } + ?> + + + + saveOrder) : ?> + + + + ⋮ + + + + get('password.edit')): ?> + checked_out) : ?> + + id); ?> + + □ + + + id); ?> + + + □ + + + +
+ get('password.edit')): ?> + escape($item->name); ?> + checked_out): ?> + name, $item->checked_out_time, 'passwords.', $canCheckin); ?> + + + escape($item->name); ?> + +
+ + +
+ user->authorise('linker.edit', 'com_getbible.linker.' . (int) $item->linker_id)): ?> + escape($item->linker_name); ?> + + escape($item->linker_name); ?> + +
+ + + escape($item->guid); ?> + + + get('password.edit.state')) : ?> + checked_out) : ?> + + published, $i, 'passwords.', true, 'cb'); ?> + + published, $i, 'passwords.', false, 'cb'); ?> + + + published, $i, 'passwords.', true, 'cb'); ?> + + + published, $i, 'passwords.', false, 'cb'); ?> + + + + id; ?> + + + \ No newline at end of file diff --git a/admin/views/passwords/tmpl/default_foot.php b/admin/views/passwords/tmpl/default_foot.php new file mode 100644 index 0000000..38a928f --- /dev/null +++ b/admin/views/passwords/tmpl/default_foot.php @@ -0,0 +1,24 @@ + + @git Get Bible + @github Get Bible + @support Get Bible + @copyright Copyright (C) 2015. All Rights Reserved + @license GNU/GPL Version 2 or later - http://www.gnu.org/licenses/gpl-2.0.html + +/------------------------------------------------------------------------------------------------------*/ + +// No direct access to this file +defined('_JEXEC') or die('Restricted access'); + +?> + + pagination->getListFooter(); ?> + \ No newline at end of file diff --git a/admin/views/passwords/tmpl/default_head.php b/admin/views/passwords/tmpl/default_head.php new file mode 100644 index 0000000..bcb6663 --- /dev/null +++ b/admin/views/passwords/tmpl/default_head.php @@ -0,0 +1,59 @@ + + @git Get Bible + @github Get Bible + @support Get Bible + @copyright Copyright (C) 2015. All Rights Reserved + @license GNU/GPL Version 2 or later - http://www.gnu.org/licenses/gpl-2.0.html + +/------------------------------------------------------------------------------------------------------*/ + +// No direct access to this file +defined('_JEXEC') or die('Restricted access'); + +?> + + canEdit&& $this->canState): ?> + + listDirn, $this->listOrder, null, 'asc', 'JGRID_HEADING_ORDERING', 'icon-menu-2'); ?> + + + + + + + ▾ + + + ■ + + + + listDirn, $this->listOrder); ?> + + + listDirn, $this->listOrder); ?> + + + + + canState): ?> + + listDirn, $this->listOrder); ?> + + + + + + + + listDirn, $this->listOrder); ?> + + \ No newline at end of file diff --git a/admin/views/passwords/tmpl/default_toolbar.php b/admin/views/passwords/tmpl/default_toolbar.php new file mode 100644 index 0000000..19b66e6 --- /dev/null +++ b/admin/views/passwords/tmpl/default_toolbar.php @@ -0,0 +1,51 @@ + + @git Get Bible + @github Get Bible + @support Get Bible + @copyright Copyright (C) 2015. All Rights Reserved + @license GNU/GPL Version 2 or later - http://www.gnu.org/licenses/gpl-2.0.html + +/------------------------------------------------------------------------------------------------------*/ + +// No direct access to this file +defined('_JEXEC') or die('Restricted access'); + +?> +
+ +
+ + +
+
+ + pagination->getLimitBox(); ?> +
+
+ + +
+
+ + +
+
+
\ No newline at end of file diff --git a/admin/views/passwords/tmpl/index.html b/admin/views/passwords/tmpl/index.html new file mode 100644 index 0000000..fa6d84e --- /dev/null +++ b/admin/views/passwords/tmpl/index.html @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/admin/views/passwords/view.html.php b/admin/views/passwords/view.html.php new file mode 100644 index 0000000..acaf415 --- /dev/null +++ b/admin/views/passwords/view.html.php @@ -0,0 +1,268 @@ + + @git Get Bible + @github Get Bible + @support Get Bible + @copyright Copyright (C) 2015. All Rights Reserved + @license GNU/GPL Version 2 or later - http://www.gnu.org/licenses/gpl-2.0.html + +/------------------------------------------------------------------------------------------------------*/ + +// No direct access to this file +defined('_JEXEC') or die('Restricted access'); + +use Joomla\CMS\MVC\View\HtmlView; + +/** + * Getbible Html View class for the Passwords + */ +class GetbibleViewPasswords extends HtmlView +{ + /** + * Passwords view display method + * @return void + */ + function display($tpl = null) + { + if ($this->getLayout() !== 'modal') + { + // Include helper submenu + GetbibleHelper::addSubmenu('passwords'); + } + + // Assign data to the view + $this->items = $this->get('Items'); + $this->pagination = $this->get('Pagination'); + $this->state = $this->get('State'); + $this->user = JFactory::getUser(); + // Load the filter form from xml. + $this->filterForm = $this->get('FilterForm'); + // Load the active filters. + $this->activeFilters = $this->get('ActiveFilters'); + // Add the list ordering clause. + $this->listOrder = $this->escape($this->state->get('list.ordering', 'a.id')); + $this->listDirn = $this->escape($this->state->get('list.direction', 'DESC')); + $this->saveOrder = $this->listOrder == 'a.ordering'; + // set the return here value + $this->return_here = urlencode(base64_encode((string) JUri::getInstance())); + // get global action permissions + $this->canDo = GetbibleHelper::getActions('password'); + $this->canEdit = $this->canDo->get('password.edit'); + $this->canState = $this->canDo->get('password.edit.state'); + $this->canCreate = $this->canDo->get('password.create'); + $this->canDelete = $this->canDo->get('password.delete'); + $this->canBatch = $this->canDo->get('core.batch'); + + // We don't need toolbar in the modal window. + if ($this->getLayout() !== 'modal') + { + $this->addToolbar(); + $this->sidebar = JHtmlSidebar::render(); + // load the batch html + if ($this->canCreate && $this->canEdit && $this->canState) + { + $this->batchDisplay = JHtmlBatch_::render(); + } + } + + // Check for errors. + if (count($errors = $this->get('Errors'))) + { + throw new Exception(implode("\n", $errors), 500); + } + + // Display the template + parent::display($tpl); + + // Set the document + $this->setDocument(); + } + + /** + * Setting the toolbar + */ + protected function addToolBar() + { + JToolBarHelper::title(JText::_('COM_GETBIBLE_PASSWORDS'), 'lock'); + JHtmlSidebar::setAction('index.php?option=com_getbible&view=passwords'); + JFormHelper::addFieldPath(JPATH_COMPONENT . '/models/fields'); + + if ($this->canCreate) + { + JToolBarHelper::addNew('password.add'); + } + + // Only load if there are items + if (GetbibleHelper::checkArray($this->items)) + { + if ($this->canEdit) + { + JToolBarHelper::editList('password.edit'); + } + + if ($this->canState) + { + JToolBarHelper::publishList('passwords.publish'); + JToolBarHelper::unpublishList('passwords.unpublish'); + JToolBarHelper::archiveList('passwords.archive'); + + if ($this->canDo->get('core.admin')) + { + JToolBarHelper::checkin('passwords.checkin'); + } + } + + // Add a batch button + if ($this->canBatch && $this->canCreate && $this->canEdit && $this->canState) + { + // Get the toolbar object instance + $bar = JToolBar::getInstance('toolbar'); + // set the batch button name + $title = JText::_('JTOOLBAR_BATCH'); + // Instantiate a new JLayoutFile instance and render the batch button + $layout = new JLayoutFile('joomla.toolbar.batch'); + // add the button to the page + $dhtml = $layout->render(array('title' => $title)); + $bar->appendButton('Custom', $dhtml, 'batch'); + } + + if ($this->state->get('filter.published') == -2 && ($this->canState && $this->canDelete)) + { + JToolbarHelper::deleteList('', 'passwords.delete', 'JTOOLBAR_EMPTY_TRASH'); + } + elseif ($this->canState && $this->canDelete) + { + JToolbarHelper::trash('passwords.trash'); + } + } + + // set help url for this view if found + $this->help_url = GetbibleHelper::getHelpUrl('passwords'); + if (GetbibleHelper::checkString($this->help_url)) + { + JToolbarHelper::help('COM_GETBIBLE_HELP_MANAGER', false, $this->help_url); + } + + // add the options comp button + if ($this->canDo->get('core.admin') || $this->canDo->get('core.options')) + { + JToolBarHelper::preferences('com_getbible'); + } + + // Only load published batch if state and batch is allowed + if ($this->canState && $this->canBatch) + { + JHtmlBatch_::addListSelection( + JText::_('COM_GETBIBLE_KEEP_ORIGINAL_STATE'), + 'batch[published]', + JHtml::_('select.options', JHtml::_('jgrid.publishedOptions', array('all' => false)), 'value', 'text', '', true) + ); + } + + // Only load access batch if create, edit and batch is allowed + if ($this->canBatch && $this->canCreate && $this->canEdit) + { + JHtmlBatch_::addListSelection( + JText::_('COM_GETBIBLE_KEEP_ORIGINAL_ACCESS'), + 'batch[access]', + JHtml::_('select.options', JHtml::_('access.assetgroups'), 'value', 'text') + ); + } + + // Only load Name batch if create, edit, and batch is allowed + if ($this->canBatch && $this->canCreate && $this->canEdit) + { + // Set Name Selection + $this->nameOptions = JFormHelper::loadFieldType('passwordsfiltername')->options; + // We do some sanitation for Name filter + if (GetbibleHelper::checkArray($this->nameOptions) && + isset($this->nameOptions[0]->value) && + !GetbibleHelper::checkString($this->nameOptions[0]->value)) + { + unset($this->nameOptions[0]); + } + // Name Batch Selection + JHtmlBatch_::addListSelection( + '- Keep Original '.JText::_('COM_GETBIBLE_PASSWORD_NAME_LABEL').' -', + 'batch[name]', + JHtml::_('select.options', $this->nameOptions, 'value', 'text') + ); + } + + // Only load Linker Name batch if create, edit, and batch is allowed + if ($this->canBatch && $this->canCreate && $this->canEdit) + { + // Set Linker Name Selection + $this->linkerNameOptions = JFormHelper::loadFieldType('Linkers')->options; + // We do some sanitation for Linker Name filter + if (GetbibleHelper::checkArray($this->linkerNameOptions) && + isset($this->linkerNameOptions[0]->value) && + !GetbibleHelper::checkString($this->linkerNameOptions[0]->value)) + { + unset($this->linkerNameOptions[0]); + } + // Linker Name Batch Selection + JHtmlBatch_::addListSelection( + '- Keep Original '.JText::_('COM_GETBIBLE_PASSWORD_LINKER_LABEL').' -', + 'batch[linker]', + JHtml::_('select.options', $this->linkerNameOptions, 'value', 'text') + ); + } + } + + /** + * Method to set up the document properties + * + * @return void + */ + protected function setDocument() + { + if (!isset($this->document)) + { + $this->document = JFactory::getDocument(); + } + $this->document->setTitle(JText::_('COM_GETBIBLE_PASSWORDS')); + $this->document->addStyleSheet(JURI::root() . "administrator/components/com_getbible/assets/css/passwords.css", (GetbibleHelper::jVersion()->isCompatible('3.8.0')) ? array('version' => 'auto') : 'text/css'); + } + + /** + * Escapes a value for output in a view script. + * + * @param mixed $var The output to escape. + * + * @return mixed The escaped value. + */ + public function escape($var) + { + if(strlen($var) > 50) + { + // use the helper htmlEscape method instead and shorten the string + return GetbibleHelper::htmlEscape($var, $this->_charset, true); + } + // use the helper htmlEscape method instead. + return GetbibleHelper::htmlEscape($var, $this->_charset); + } + + /** + * Returns an array of fields the table can be sorted by + * + * @return array Array containing the field name to sort by as the key and display text as value + */ + protected function getSortFields() + { + return array( + 'a.ordering' => JText::_('JGRID_HEADING_ORDERING'), + 'a.published' => JText::_('JSTATUS'), + 'a.name' => JText::_('COM_GETBIBLE_PASSWORD_NAME_LABEL'), + 'g.name' => JText::_('COM_GETBIBLE_PASSWORD_LINKER_LABEL'), + 'a.id' => JText::_('JGRID_HEADING_ID') + ); + } +} diff --git a/admin/views/prompt/submitbutton.js b/admin/views/prompt/submitbutton.js new file mode 100644 index 0000000..1a18fec --- /dev/null +++ b/admin/views/prompt/submitbutton.js @@ -0,0 +1,31 @@ +/*----------------------------------------------------------------------------------| io.vdm.dev |----/ + Vast Development Method +/-------------------------------------------------------------------------------------------------------/ + + @package getBible.net + + @created 3rd December, 2015 + @author Llewellyn van der Merwe + @git Get Bible + @github Get Bible + @support Get Bible + @copyright Copyright (C) 2015. All Rights Reserved + @license GNU/GPL Version 2 or later - http://www.gnu.org/licenses/gpl-2.0.html + +/------------------------------------------------------------------------------------------------------*/ + +Joomla.submitbutton = function(task) +{ + if (task == ''){ + return false; + } else { + var action = task.split('.'); + if (action[1] == 'cancel' || action[1] == 'close' || document.formvalidator.isValid(document.getElementById("adminForm"))){ + Joomla.submitform(task, document.getElementById("adminForm")); + return true; + } else { + alert(Joomla.JText._('prompt, some values are not acceptable.','Some values are unacceptable')); + return false; + } + } +} \ No newline at end of file diff --git a/admin/views/prompt/tmpl/edit.php b/admin/views/prompt/tmpl/edit.php new file mode 100644 index 0000000..bbd2658 --- /dev/null +++ b/admin/views/prompt/tmpl/edit.php @@ -0,0 +1,138 @@ + + @git Get Bible + @github Get Bible + @support Get Bible + @copyright Copyright (C) 2015. All Rights Reserved + @license GNU/GPL Version 2 or later - http://www.gnu.org/licenses/gpl-2.0.html + +/------------------------------------------------------------------------------------------------------*/ + +// No direct access to this file +defined('_JEXEC') or die('Restricted access'); + +JHtml::addIncludePath(JPATH_COMPONENT.'/helpers/html'); +JHtml::_('behavior.formvalidator'); +JHtml::_('formbehavior.chosen', 'select'); +JHtml::_('behavior.keepalive'); +$componentParams = $this->params; // will be removed just use $this->params instead +?> + + + + diff --git a/admin/views/prompt/tmpl/index.html b/admin/views/prompt/tmpl/index.html new file mode 100644 index 0000000..fa6d84e --- /dev/null +++ b/admin/views/prompt/tmpl/index.html @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/admin/views/prompt/view.html.php b/admin/views/prompt/view.html.php new file mode 100644 index 0000000..c49ac31 --- /dev/null +++ b/admin/views/prompt/view.html.php @@ -0,0 +1,203 @@ + + @git Get Bible + @github Get Bible + @support Get Bible + @copyright Copyright (C) 2015. All Rights Reserved + @license GNU/GPL Version 2 or later - http://www.gnu.org/licenses/gpl-2.0.html + +/------------------------------------------------------------------------------------------------------*/ + +// No direct access to this file +defined('_JEXEC') or die('Restricted access'); + +use Joomla\CMS\MVC\View\HtmlView; + +/** + * Prompt Html View class + */ +class GetbibleViewPrompt extends HtmlView +{ + /** + * display method of View + * @return void + */ + public function display($tpl = null) + { + // set params + $this->params = JComponentHelper::getParams('com_getbible'); + // Assign the variables + $this->form = $this->get('Form'); + $this->item = $this->get('Item'); + $this->script = $this->get('Script'); + $this->state = $this->get('State'); + // get action permissions + $this->canDo = GetbibleHelper::getActions('prompt', $this->item); + // get input + $jinput = JFactory::getApplication()->input; + $this->ref = $jinput->get('ref', 0, 'word'); + $this->refid = $jinput->get('refid', 0, 'int'); + $return = $jinput->get('return', null, 'base64'); + // set the referral string + $this->referral = ''; + if ($this->refid && $this->ref) + { + // return to the item that referred to this item + $this->referral = '&ref=' . (string)$this->ref . '&refid=' . (int)$this->refid; + } + elseif($this->ref) + { + // return to the list view that referred to this item + $this->referral = '&ref=' . (string)$this->ref; + } + // check return value + if (!is_null($return)) + { + // add the return value + $this->referral .= '&return=' . (string)$return; + } + + // Set the toolbar + $this->addToolBar(); + + // Check for errors. + if (count($errors = $this->get('Errors'))) + { + throw new Exception(implode("\n", $errors), 500); + } + + // Display the template + parent::display($tpl); + + // Set the document + $this->setDocument(); + } + + + /** + * Setting the toolbar + */ + protected function addToolBar() + { + JFactory::getApplication()->input->set('hidemainmenu', true); + $user = JFactory::getUser(); + $userId = $user->id; + $isNew = $this->item->id == 0; + + JToolbarHelper::title( JText::_($isNew ? 'COM_GETBIBLE_PROMPT_NEW' : 'COM_GETBIBLE_PROMPT_EDIT'), 'pencil-2 article-add'); + // Built the actions for new and existing records. + if (GetbibleHelper::checkString($this->referral)) + { + if ($this->canDo->get('prompt.create') && $isNew) + { + // We can create the record. + JToolBarHelper::save('prompt.save', 'JTOOLBAR_SAVE'); + } + elseif ($this->canDo->get('prompt.edit')) + { + // We can save the record. + JToolBarHelper::save('prompt.save', 'JTOOLBAR_SAVE'); + } + if ($isNew) + { + // Do not creat but cancel. + JToolBarHelper::cancel('prompt.cancel', 'JTOOLBAR_CANCEL'); + } + else + { + // We can close it. + JToolBarHelper::cancel('prompt.cancel', 'JTOOLBAR_CLOSE'); + } + } + else + { + if ($isNew) + { + // For new records, check the create permission. + if ($this->canDo->get('prompt.create')) + { + JToolBarHelper::apply('prompt.apply', 'JTOOLBAR_APPLY'); + JToolBarHelper::save('prompt.save', 'JTOOLBAR_SAVE'); + JToolBarHelper::custom('prompt.save2new', 'save-new.png', 'save-new_f2.png', 'JTOOLBAR_SAVE_AND_NEW', false); + }; + JToolBarHelper::cancel('prompt.cancel', 'JTOOLBAR_CANCEL'); + } + else + { + if ($this->canDo->get('prompt.edit')) + { + // We can save the new record + JToolBarHelper::apply('prompt.apply', 'JTOOLBAR_APPLY'); + JToolBarHelper::save('prompt.save', 'JTOOLBAR_SAVE'); + // We can save this record, but check the create permission to see + // if we can return to make a new one. + if ($this->canDo->get('prompt.create')) + { + JToolBarHelper::custom('prompt.save2new', 'save-new.png', 'save-new_f2.png', 'JTOOLBAR_SAVE_AND_NEW', false); + } + } + $canVersion = ($this->canDo->get('core.version') && $this->canDo->get('prompt.version')); + if ($this->state->params->get('save_history', 1) && $this->canDo->get('prompt.edit') && $canVersion) + { + JToolbarHelper::versions('com_getbible.prompt', $this->item->id); + } + if ($this->canDo->get('prompt.create')) + { + JToolBarHelper::custom('prompt.save2copy', 'save-copy.png', 'save-copy_f2.png', 'JTOOLBAR_SAVE_AS_COPY', false); + } + JToolBarHelper::cancel('prompt.cancel', 'JTOOLBAR_CLOSE'); + } + } + JToolbarHelper::divider(); + // set help url for this view if found + $this->help_url = GetbibleHelper::getHelpUrl('prompt'); + if (GetbibleHelper::checkString($this->help_url)) + { + JToolbarHelper::help('COM_GETBIBLE_HELP_MANAGER', false, $this->help_url); + } + } + + /** + * Escapes a value for output in a view script. + * + * @param mixed $var The output to escape. + * + * @return mixed The escaped value. + */ + public function escape($var) + { + if(strlen($var) > 30) + { + // use the helper htmlEscape method instead and shorten the string + return GetbibleHelper::htmlEscape($var, $this->_charset, true, 30); + } + // use the helper htmlEscape method instead. + return GetbibleHelper::htmlEscape($var, $this->_charset); + } + + /** + * Method to set up the document properties + * + * @return void + */ + protected function setDocument() + { + $isNew = ($this->item->id < 1); + if (!isset($this->document)) + { + $this->document = JFactory::getDocument(); + } + $this->document->setTitle(JText::_($isNew ? 'COM_GETBIBLE_PROMPT_NEW' : 'COM_GETBIBLE_PROMPT_EDIT')); + $this->document->addStyleSheet(JURI::root() . "administrator/components/com_getbible/assets/css/prompt.css", (GetbibleHelper::jVersion()->isCompatible('3.8.0')) ? array('version' => 'auto') : 'text/css'); + $this->document->addScript(JURI::root() . $this->script, (GetbibleHelper::jVersion()->isCompatible('3.8.0')) ? array('version' => 'auto') : 'text/javascript'); + $this->document->addScript(JURI::root() . "administrator/components/com_getbible/views/prompt/submitbutton.js", (GetbibleHelper::jVersion()->isCompatible('3.8.0')) ? array('version' => 'auto') : 'text/javascript'); + JText::script('view not acceptable. Error'); + } +} diff --git a/admin/views/prompts/index.html b/admin/views/prompts/index.html new file mode 100644 index 0000000..fa6d84e --- /dev/null +++ b/admin/views/prompts/index.html @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/admin/views/prompts/tmpl/default.php b/admin/views/prompts/tmpl/default.php new file mode 100644 index 0000000..7e39a33 --- /dev/null +++ b/admin/views/prompts/tmpl/default.php @@ -0,0 +1,73 @@ + + @git Get Bible + @github Get Bible + @support Get Bible + @copyright Copyright (C) 2015. All Rights Reserved + @license GNU/GPL Version 2 or later - http://www.gnu.org/licenses/gpl-2.0.html + +/------------------------------------------------------------------------------------------------------*/ + +// No direct access to this file +defined('_JEXEC') or die('Restricted access'); + +JHtml::_('behavior.multiselect'); +JHtml::_('dropdown.init'); +JHtml::_('formbehavior.chosen', '.multipleAccessLevels', null, array('placeholder_text_multiple' => '- ' . JText::_('COM_GETBIBLE_FILTER_SELECT_ACCESS') . ' -')); +JHtml::_('formbehavior.chosen', 'select'); +if ($this->saveOrder) +{ + $saveOrderingUrl = 'index.php?option=com_getbible&task=prompts.saveOrderAjax&tmpl=component'; + JHtml::_('sortablelist.sortable', 'promptList', 'adminForm', strtolower($this->listDirn), $saveOrderingUrl); +} +?> +
+sidebar)): ?> +
+ sidebar; ?> +
+
+ +
+ + $this)); +?> +items)): ?> +
+ +
+ + + loadTemplate('head');?> + loadTemplate('foot');?> + loadTemplate('body');?> +
+ + canCreate && $this->canEdit) : ?> + JText::_('COM_GETBIBLE_PROMPTS_BATCH_OPTIONS'), + 'footer' => $this->loadTemplate('batch_footer') + ), + $this->loadTemplate('batch_body') + ); ?> + + +
+ + + + diff --git a/admin/views/prompts/tmpl/default_batch_body.php b/admin/views/prompts/tmpl/default_batch_body.php new file mode 100644 index 0000000..4500a22 --- /dev/null +++ b/admin/views/prompts/tmpl/default_batch_body.php @@ -0,0 +1,24 @@ + + @git Get Bible + @github Get Bible + @support Get Bible + @copyright Copyright (C) 2015. All Rights Reserved + @license GNU/GPL Version 2 or later - http://www.gnu.org/licenses/gpl-2.0.html + +/------------------------------------------------------------------------------------------------------*/ + +// No direct access to this file +defined('_JEXEC') or die('Restricted access'); + +?> + +

+batchDisplay; ?> \ No newline at end of file diff --git a/admin/views/prompts/tmpl/default_batch_footer.php b/admin/views/prompts/tmpl/default_batch_footer.php new file mode 100644 index 0000000..8147c5a --- /dev/null +++ b/admin/views/prompts/tmpl/default_batch_footer.php @@ -0,0 +1,29 @@ + + @git Get Bible + @github Get Bible + @support Get Bible + @copyright Copyright (C) 2015. All Rights Reserved + @license GNU/GPL Version 2 or later - http://www.gnu.org/licenses/gpl-2.0.html + +/------------------------------------------------------------------------------------------------------*/ + +// No direct access to this file +defined('_JEXEC') or die('Restricted access'); + +?> + + + + \ No newline at end of file diff --git a/admin/views/prompts/tmpl/default_body.php b/admin/views/prompts/tmpl/default_body.php new file mode 100644 index 0000000..8b99045 --- /dev/null +++ b/admin/views/prompts/tmpl/default_body.php @@ -0,0 +1,112 @@ + + @git Get Bible + @github Get Bible + @support Get Bible + @copyright Copyright (C) 2015. All Rights Reserved + @license GNU/GPL Version 2 or later - http://www.gnu.org/licenses/gpl-2.0.html + +/------------------------------------------------------------------------------------------------------*/ + +// No direct access to this file +defined('_JEXEC') or die('Restricted access'); + +$edit = "index.php?option=com_getbible&view=prompts&task=prompt.edit"; + +?> +items as $i => $item): ?> + user->authorise('core.manage', 'com_checkin') || $item->checked_out == $this->user->id || $item->checked_out == 0; + $userChkOut = JFactory::getUser($item->checked_out); + $canDo = GetbibleHelper::getActions('prompt',$item,'prompts'); + ?> + + + get('prompt.edit.state')): ?> + saveOrder) + { + $iconClass = ' inactive tip-top" hasTooltip" title="' . JHtml::tooltipText('JORDERINGDISABLED'); + } + ?> + + + + saveOrder) : ?> + + + + ⋮ + + + + get('prompt.edit')): ?> + checked_out) : ?> + + id); ?> + + □ + + + id); ?> + + + □ + + + +
+ get('prompt.edit')): ?> + escape($item->name); ?> + checked_out): ?> + name, $item->checked_out_time, 'prompts.', $canCheckin); ?> + + + escape($item->name); ?> + +
+ + + integration); ?> + + + cache_behaviour); ?> + + + escape($item->abbreviation_translation); ?> + + + escape($item->guid); ?> + + + model); ?> + + + get('prompt.edit.state')) : ?> + checked_out) : ?> + + published, $i, 'prompts.', true, 'cb'); ?> + + published, $i, 'prompts.', false, 'cb'); ?> + + + published, $i, 'prompts.', true, 'cb'); ?> + + + published, $i, 'prompts.', false, 'cb'); ?> + + + + id; ?> + + + \ No newline at end of file diff --git a/admin/views/prompts/tmpl/default_foot.php b/admin/views/prompts/tmpl/default_foot.php new file mode 100644 index 0000000..085e186 --- /dev/null +++ b/admin/views/prompts/tmpl/default_foot.php @@ -0,0 +1,24 @@ + + @git Get Bible + @github Get Bible + @support Get Bible + @copyright Copyright (C) 2015. All Rights Reserved + @license GNU/GPL Version 2 or later - http://www.gnu.org/licenses/gpl-2.0.html + +/------------------------------------------------------------------------------------------------------*/ + +// No direct access to this file +defined('_JEXEC') or die('Restricted access'); + +?> + + pagination->getListFooter(); ?> + \ No newline at end of file diff --git a/admin/views/prompts/tmpl/default_head.php b/admin/views/prompts/tmpl/default_head.php new file mode 100644 index 0000000..e10490e --- /dev/null +++ b/admin/views/prompts/tmpl/default_head.php @@ -0,0 +1,68 @@ + + @git Get Bible + @github Get Bible + @support Get Bible + @copyright Copyright (C) 2015. All Rights Reserved + @license GNU/GPL Version 2 or later - http://www.gnu.org/licenses/gpl-2.0.html + +/------------------------------------------------------------------------------------------------------*/ + +// No direct access to this file +defined('_JEXEC') or die('Restricted access'); + +?> + + canEdit&& $this->canState): ?> + + listDirn, $this->listOrder, null, 'asc', 'JGRID_HEADING_ORDERING', 'icon-menu-2'); ?> + + + + + + + ▾ + + + ■ + + + + listDirn, $this->listOrder); ?> + + + listDirn, $this->listOrder); ?> + + + listDirn, $this->listOrder); ?> + + + + + + + + + listDirn, $this->listOrder); ?> + + canState): ?> + + listDirn, $this->listOrder); ?> + + + + + + + + listDirn, $this->listOrder); ?> + + \ No newline at end of file diff --git a/admin/views/prompts/tmpl/default_toolbar.php b/admin/views/prompts/tmpl/default_toolbar.php new file mode 100644 index 0000000..8bf8855 --- /dev/null +++ b/admin/views/prompts/tmpl/default_toolbar.php @@ -0,0 +1,51 @@ + + @git Get Bible + @github Get Bible + @support Get Bible + @copyright Copyright (C) 2015. All Rights Reserved + @license GNU/GPL Version 2 or later - http://www.gnu.org/licenses/gpl-2.0.html + +/------------------------------------------------------------------------------------------------------*/ + +// No direct access to this file +defined('_JEXEC') or die('Restricted access'); + +?> +
+ +
+ + +
+
+ + pagination->getLimitBox(); ?> +
+
+ + +
+
+ + +
+
+
\ No newline at end of file diff --git a/admin/views/prompts/tmpl/index.html b/admin/views/prompts/tmpl/index.html new file mode 100644 index 0000000..fa6d84e --- /dev/null +++ b/admin/views/prompts/tmpl/index.html @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/admin/views/prompts/view.html.php b/admin/views/prompts/view.html.php new file mode 100644 index 0000000..7b36b74 --- /dev/null +++ b/admin/views/prompts/view.html.php @@ -0,0 +1,310 @@ + + @git Get Bible + @github Get Bible + @support Get Bible + @copyright Copyright (C) 2015. All Rights Reserved + @license GNU/GPL Version 2 or later - http://www.gnu.org/licenses/gpl-2.0.html + +/------------------------------------------------------------------------------------------------------*/ + +// No direct access to this file +defined('_JEXEC') or die('Restricted access'); + +use Joomla\CMS\MVC\View\HtmlView; + +/** + * Getbible Html View class for the Prompts + */ +class GetbibleViewPrompts extends HtmlView +{ + /** + * Prompts view display method + * @return void + */ + function display($tpl = null) + { + if ($this->getLayout() !== 'modal') + { + // Include helper submenu + GetbibleHelper::addSubmenu('prompts'); + } + + // Assign data to the view + $this->items = $this->get('Items'); + $this->pagination = $this->get('Pagination'); + $this->state = $this->get('State'); + $this->user = JFactory::getUser(); + // Load the filter form from xml. + $this->filterForm = $this->get('FilterForm'); + // Load the active filters. + $this->activeFilters = $this->get('ActiveFilters'); + // Add the list ordering clause. + $this->listOrder = $this->escape($this->state->get('list.ordering', 'a.id')); + $this->listDirn = $this->escape($this->state->get('list.direction', 'desc')); + $this->saveOrder = $this->listOrder == 'a.ordering'; + // set the return here value + $this->return_here = urlencode(base64_encode((string) JUri::getInstance())); + // get global action permissions + $this->canDo = GetbibleHelper::getActions('prompt'); + $this->canEdit = $this->canDo->get('prompt.edit'); + $this->canState = $this->canDo->get('prompt.edit.state'); + $this->canCreate = $this->canDo->get('prompt.create'); + $this->canDelete = $this->canDo->get('prompt.delete'); + $this->canBatch = $this->canDo->get('core.batch'); + + // We don't need toolbar in the modal window. + if ($this->getLayout() !== 'modal') + { + $this->addToolbar(); + $this->sidebar = JHtmlSidebar::render(); + // load the batch html + if ($this->canCreate && $this->canEdit && $this->canState) + { + $this->batchDisplay = JHtmlBatch_::render(); + } + } + + // Check for errors. + if (count($errors = $this->get('Errors'))) + { + throw new Exception(implode("\n", $errors), 500); + } + + // Display the template + parent::display($tpl); + + // Set the document + $this->setDocument(); + } + + /** + * Setting the toolbar + */ + protected function addToolBar() + { + JToolBarHelper::title(JText::_('COM_GETBIBLE_PROMPTS'), 'featured'); + JHtmlSidebar::setAction('index.php?option=com_getbible&view=prompts'); + JFormHelper::addFieldPath(JPATH_COMPONENT . '/models/fields'); + + if ($this->canCreate) + { + JToolBarHelper::addNew('prompt.add'); + } + + // Only load if there are items + if (GetbibleHelper::checkArray($this->items)) + { + if ($this->canEdit) + { + JToolBarHelper::editList('prompt.edit'); + } + + if ($this->canState) + { + JToolBarHelper::publishList('prompts.publish'); + JToolBarHelper::unpublishList('prompts.unpublish'); + JToolBarHelper::archiveList('prompts.archive'); + + if ($this->canDo->get('core.admin')) + { + JToolBarHelper::checkin('prompts.checkin'); + } + } + + // Add a batch button + if ($this->canBatch && $this->canCreate && $this->canEdit && $this->canState) + { + // Get the toolbar object instance + $bar = JToolBar::getInstance('toolbar'); + // set the batch button name + $title = JText::_('JTOOLBAR_BATCH'); + // Instantiate a new JLayoutFile instance and render the batch button + $layout = new JLayoutFile('joomla.toolbar.batch'); + // add the button to the page + $dhtml = $layout->render(array('title' => $title)); + $bar->appendButton('Custom', $dhtml, 'batch'); + } + + if ($this->state->get('filter.published') == -2 && ($this->canState && $this->canDelete)) + { + JToolbarHelper::deleteList('', 'prompts.delete', 'JTOOLBAR_EMPTY_TRASH'); + } + elseif ($this->canState && $this->canDelete) + { + JToolbarHelper::trash('prompts.trash'); + } + } + + // set help url for this view if found + $this->help_url = GetbibleHelper::getHelpUrl('prompts'); + if (GetbibleHelper::checkString($this->help_url)) + { + JToolbarHelper::help('COM_GETBIBLE_HELP_MANAGER', false, $this->help_url); + } + + // add the options comp button + if ($this->canDo->get('core.admin') || $this->canDo->get('core.options')) + { + JToolBarHelper::preferences('com_getbible'); + } + + // Only load published batch if state and batch is allowed + if ($this->canState && $this->canBatch) + { + JHtmlBatch_::addListSelection( + JText::_('COM_GETBIBLE_KEEP_ORIGINAL_STATE'), + 'batch[published]', + JHtml::_('select.options', JHtml::_('jgrid.publishedOptions', array('all' => false)), 'value', 'text', '', true) + ); + } + + // Only load access batch if create, edit and batch is allowed + if ($this->canBatch && $this->canCreate && $this->canEdit) + { + JHtmlBatch_::addListSelection( + JText::_('COM_GETBIBLE_KEEP_ORIGINAL_ACCESS'), + 'batch[access]', + JHtml::_('select.options', JHtml::_('access.assetgroups'), 'value', 'text') + ); + } + + // Only load Name batch if create, edit, and batch is allowed + if ($this->canBatch && $this->canCreate && $this->canEdit) + { + // Set Name Selection + $this->nameOptions = JFormHelper::loadFieldType('promptsfiltername')->options; + // We do some sanitation for Name filter + if (GetbibleHelper::checkArray($this->nameOptions) && + isset($this->nameOptions[0]->value) && + !GetbibleHelper::checkString($this->nameOptions[0]->value)) + { + unset($this->nameOptions[0]); + } + // Name Batch Selection + JHtmlBatch_::addListSelection( + '- Keep Original '.JText::_('COM_GETBIBLE_PROMPT_NAME_LABEL').' -', + 'batch[name]', + JHtml::_('select.options', $this->nameOptions, 'value', 'text') + ); + } + + // Only load Cache Behaviour batch if create, edit, and batch is allowed + if ($this->canBatch && $this->canCreate && $this->canEdit) + { + // Set Cache Behaviour Selection + $this->cache_behaviourOptions = JFormHelper::loadFieldType('promptsfiltercachebehaviour')->options; + // We do some sanitation for Cache Behaviour filter + if (GetbibleHelper::checkArray($this->cache_behaviourOptions) && + isset($this->cache_behaviourOptions[0]->value) && + !GetbibleHelper::checkString($this->cache_behaviourOptions[0]->value)) + { + unset($this->cache_behaviourOptions[0]); + } + // Cache Behaviour Batch Selection + JHtmlBatch_::addListSelection( + '- Keep Original '.JText::_('COM_GETBIBLE_PROMPT_CACHE_BEHAVIOUR_LABEL').' -', + 'batch[cache_behaviour]', + JHtml::_('select.options', $this->cache_behaviourOptions, 'value', 'text') + ); + } + + // Only load Abbreviation Translation batch if create, edit, and batch is allowed + if ($this->canBatch && $this->canCreate && $this->canEdit) + { + // Set Abbreviation Translation Selection + $this->abbreviationTranslationOptions = JFormHelper::loadFieldType('Targettranslations')->options; + // We do some sanitation for Abbreviation Translation filter + if (GetbibleHelper::checkArray($this->abbreviationTranslationOptions) && + isset($this->abbreviationTranslationOptions[0]->value) && + !GetbibleHelper::checkString($this->abbreviationTranslationOptions[0]->value)) + { + unset($this->abbreviationTranslationOptions[0]); + } + // Abbreviation Translation Batch Selection + JHtmlBatch_::addListSelection( + '- Keep Original '.JText::_('COM_GETBIBLE_PROMPT_ABBREVIATION_LABEL').' -', + 'batch[abbreviation]', + JHtml::_('select.options', $this->abbreviationTranslationOptions, 'value', 'text') + ); + } + + // Only load Model batch if create, edit, and batch is allowed + if ($this->canBatch && $this->canCreate && $this->canEdit) + { + // Set Model Selection + $this->modelOptions = JFormHelper::loadFieldType('promptsfiltermodel')->options; + // We do some sanitation for Model filter + if (GetbibleHelper::checkArray($this->modelOptions) && + isset($this->modelOptions[0]->value) && + !GetbibleHelper::checkString($this->modelOptions[0]->value)) + { + unset($this->modelOptions[0]); + } + // Model Batch Selection + JHtmlBatch_::addListSelection( + '- Keep Original '.JText::_('COM_GETBIBLE_PROMPT_MODEL_LABEL').' -', + 'batch[model]', + JHtml::_('select.options', $this->modelOptions, 'value', 'text') + ); + } + } + + /** + * Method to set up the document properties + * + * @return void + */ + protected function setDocument() + { + if (!isset($this->document)) + { + $this->document = JFactory::getDocument(); + } + $this->document->setTitle(JText::_('COM_GETBIBLE_PROMPTS')); + $this->document->addStyleSheet(JURI::root() . "administrator/components/com_getbible/assets/css/prompts.css", (GetbibleHelper::jVersion()->isCompatible('3.8.0')) ? array('version' => 'auto') : 'text/css'); + } + + /** + * Escapes a value for output in a view script. + * + * @param mixed $var The output to escape. + * + * @return mixed The escaped value. + */ + public function escape($var) + { + if(strlen($var) > 50) + { + // use the helper htmlEscape method instead and shorten the string + return GetbibleHelper::htmlEscape($var, $this->_charset, true); + } + // use the helper htmlEscape method instead. + return GetbibleHelper::htmlEscape($var, $this->_charset); + } + + /** + * Returns an array of fields the table can be sorted by + * + * @return array Array containing the field name to sort by as the key and display text as value + */ + protected function getSortFields() + { + return array( + 'a.ordering' => JText::_('JGRID_HEADING_ORDERING'), + 'a.published' => JText::_('JSTATUS'), + 'a.name' => JText::_('COM_GETBIBLE_PROMPT_NAME_LABEL'), + 'a.integration' => JText::_('COM_GETBIBLE_PROMPT_INTEGRATION_LABEL'), + 'a.cache_behaviour' => JText::_('COM_GETBIBLE_PROMPT_CACHE_BEHAVIOUR_LABEL'), + 'a.model' => JText::_('COM_GETBIBLE_PROMPT_MODEL_LABEL'), + 'a.id' => JText::_('JGRID_HEADING_ID') + ); + } +} diff --git a/admin/views/tag/submitbutton.js b/admin/views/tag/submitbutton.js new file mode 100644 index 0000000..a9ad492 --- /dev/null +++ b/admin/views/tag/submitbutton.js @@ -0,0 +1,31 @@ +/*----------------------------------------------------------------------------------| io.vdm.dev |----/ + Vast Development Method +/-------------------------------------------------------------------------------------------------------/ + + @package getBible.net + + @created 3rd December, 2015 + @author Llewellyn van der Merwe + @git Get Bible + @github Get Bible + @support Get Bible + @copyright Copyright (C) 2015. All Rights Reserved + @license GNU/GPL Version 2 or later - http://www.gnu.org/licenses/gpl-2.0.html + +/------------------------------------------------------------------------------------------------------*/ + +Joomla.submitbutton = function(task) +{ + if (task == ''){ + return false; + } else { + var action = task.split('.'); + if (action[1] == 'cancel' || action[1] == 'close' || document.formvalidator.isValid(document.getElementById("adminForm"))){ + Joomla.submitform(task, document.getElementById("adminForm")); + return true; + } else { + alert(Joomla.JText._('tag, some values are not acceptable.','Some values are unacceptable')); + return false; + } + } +} \ No newline at end of file diff --git a/admin/views/tag/tmpl/edit.php b/admin/views/tag/tmpl/edit.php new file mode 100644 index 0000000..fa4b3c6 --- /dev/null +++ b/admin/views/tag/tmpl/edit.php @@ -0,0 +1,114 @@ + + @git Get Bible + @github Get Bible + @support Get Bible + @copyright Copyright (C) 2015. All Rights Reserved + @license GNU/GPL Version 2 or later - http://www.gnu.org/licenses/gpl-2.0.html + +/------------------------------------------------------------------------------------------------------*/ + +// No direct access to this file +defined('_JEXEC') or die('Restricted access'); + +JHtml::addIncludePath(JPATH_COMPONENT.'/helpers/html'); +JHtml::_('behavior.formvalidator'); +JHtml::_('formbehavior.chosen', 'select'); +JHtml::_('behavior.keepalive'); +$componentParams = $this->params; // will be removed just use $this->params instead +?> + + diff --git a/admin/views/tag/tmpl/index.html b/admin/views/tag/tmpl/index.html new file mode 100644 index 0000000..fa6d84e --- /dev/null +++ b/admin/views/tag/tmpl/index.html @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/admin/views/tag/view.html.php b/admin/views/tag/view.html.php new file mode 100644 index 0000000..89aea34 --- /dev/null +++ b/admin/views/tag/view.html.php @@ -0,0 +1,203 @@ + + @git Get Bible + @github Get Bible + @support Get Bible + @copyright Copyright (C) 2015. All Rights Reserved + @license GNU/GPL Version 2 or later - http://www.gnu.org/licenses/gpl-2.0.html + +/------------------------------------------------------------------------------------------------------*/ + +// No direct access to this file +defined('_JEXEC') or die('Restricted access'); + +use Joomla\CMS\MVC\View\HtmlView; + +/** + * Tag Html View class + */ +class GetbibleViewTag extends HtmlView +{ + /** + * display method of View + * @return void + */ + public function display($tpl = null) + { + // set params + $this->params = JComponentHelper::getParams('com_getbible'); + // Assign the variables + $this->form = $this->get('Form'); + $this->item = $this->get('Item'); + $this->script = $this->get('Script'); + $this->state = $this->get('State'); + // get action permissions + $this->canDo = GetbibleHelper::getActions('tag', $this->item); + // get input + $jinput = JFactory::getApplication()->input; + $this->ref = $jinput->get('ref', 0, 'word'); + $this->refid = $jinput->get('refid', 0, 'int'); + $return = $jinput->get('return', null, 'base64'); + // set the referral string + $this->referral = ''; + if ($this->refid && $this->ref) + { + // return to the item that referred to this item + $this->referral = '&ref=' . (string)$this->ref . '&refid=' . (int)$this->refid; + } + elseif($this->ref) + { + // return to the list view that referred to this item + $this->referral = '&ref=' . (string)$this->ref; + } + // check return value + if (!is_null($return)) + { + // add the return value + $this->referral .= '&return=' . (string)$return; + } + + // Set the toolbar + $this->addToolBar(); + + // Check for errors. + if (count($errors = $this->get('Errors'))) + { + throw new Exception(implode("\n", $errors), 500); + } + + // Display the template + parent::display($tpl); + + // Set the document + $this->setDocument(); + } + + + /** + * Setting the toolbar + */ + protected function addToolBar() + { + JFactory::getApplication()->input->set('hidemainmenu', true); + $user = JFactory::getUser(); + $userId = $user->id; + $isNew = $this->item->id == 0; + + JToolbarHelper::title( JText::_($isNew ? 'COM_GETBIBLE_TAG_NEW' : 'COM_GETBIBLE_TAG_EDIT'), 'pencil-2 article-add'); + // Built the actions for new and existing records. + if (GetbibleHelper::checkString($this->referral)) + { + if ($this->canDo->get('tag.create') && $isNew) + { + // We can create the record. + JToolBarHelper::save('tag.save', 'JTOOLBAR_SAVE'); + } + elseif ($this->canDo->get('tag.edit')) + { + // We can save the record. + JToolBarHelper::save('tag.save', 'JTOOLBAR_SAVE'); + } + if ($isNew) + { + // Do not creat but cancel. + JToolBarHelper::cancel('tag.cancel', 'JTOOLBAR_CANCEL'); + } + else + { + // We can close it. + JToolBarHelper::cancel('tag.cancel', 'JTOOLBAR_CLOSE'); + } + } + else + { + if ($isNew) + { + // For new records, check the create permission. + if ($this->canDo->get('tag.create')) + { + JToolBarHelper::apply('tag.apply', 'JTOOLBAR_APPLY'); + JToolBarHelper::save('tag.save', 'JTOOLBAR_SAVE'); + JToolBarHelper::custom('tag.save2new', 'save-new.png', 'save-new_f2.png', 'JTOOLBAR_SAVE_AND_NEW', false); + }; + JToolBarHelper::cancel('tag.cancel', 'JTOOLBAR_CANCEL'); + } + else + { + if ($this->canDo->get('tag.edit')) + { + // We can save the new record + JToolBarHelper::apply('tag.apply', 'JTOOLBAR_APPLY'); + JToolBarHelper::save('tag.save', 'JTOOLBAR_SAVE'); + // We can save this record, but check the create permission to see + // if we can return to make a new one. + if ($this->canDo->get('tag.create')) + { + JToolBarHelper::custom('tag.save2new', 'save-new.png', 'save-new_f2.png', 'JTOOLBAR_SAVE_AND_NEW', false); + } + } + $canVersion = ($this->canDo->get('core.version') && $this->canDo->get('tag.version')); + if ($this->state->params->get('save_history', 1) && $this->canDo->get('tag.edit') && $canVersion) + { + JToolbarHelper::versions('com_getbible.tag', $this->item->id); + } + if ($this->canDo->get('tag.create')) + { + JToolBarHelper::custom('tag.save2copy', 'save-copy.png', 'save-copy_f2.png', 'JTOOLBAR_SAVE_AS_COPY', false); + } + JToolBarHelper::cancel('tag.cancel', 'JTOOLBAR_CLOSE'); + } + } + JToolbarHelper::divider(); + // set help url for this view if found + $this->help_url = GetbibleHelper::getHelpUrl('tag'); + if (GetbibleHelper::checkString($this->help_url)) + { + JToolbarHelper::help('COM_GETBIBLE_HELP_MANAGER', false, $this->help_url); + } + } + + /** + * Escapes a value for output in a view script. + * + * @param mixed $var The output to escape. + * + * @return mixed The escaped value. + */ + public function escape($var) + { + if(strlen($var) > 30) + { + // use the helper htmlEscape method instead and shorten the string + return GetbibleHelper::htmlEscape($var, $this->_charset, true, 30); + } + // use the helper htmlEscape method instead. + return GetbibleHelper::htmlEscape($var, $this->_charset); + } + + /** + * Method to set up the document properties + * + * @return void + */ + protected function setDocument() + { + $isNew = ($this->item->id < 1); + if (!isset($this->document)) + { + $this->document = JFactory::getDocument(); + } + $this->document->setTitle(JText::_($isNew ? 'COM_GETBIBLE_TAG_NEW' : 'COM_GETBIBLE_TAG_EDIT')); + $this->document->addStyleSheet(JURI::root() . "administrator/components/com_getbible/assets/css/tag.css", (GetbibleHelper::jVersion()->isCompatible('3.8.0')) ? array('version' => 'auto') : 'text/css'); + $this->document->addScript(JURI::root() . $this->script, (GetbibleHelper::jVersion()->isCompatible('3.8.0')) ? array('version' => 'auto') : 'text/javascript'); + $this->document->addScript(JURI::root() . "administrator/components/com_getbible/views/tag/submitbutton.js", (GetbibleHelper::jVersion()->isCompatible('3.8.0')) ? array('version' => 'auto') : 'text/javascript'); + JText::script('view not acceptable. Error'); + } +} diff --git a/admin/views/tagged_verse/submitbutton.js b/admin/views/tagged_verse/submitbutton.js new file mode 100644 index 0000000..2c6c846 --- /dev/null +++ b/admin/views/tagged_verse/submitbutton.js @@ -0,0 +1,31 @@ +/*----------------------------------------------------------------------------------| io.vdm.dev |----/ + Vast Development Method +/-------------------------------------------------------------------------------------------------------/ + + @package getBible.net + + @created 3rd December, 2015 + @author Llewellyn van der Merwe + @git Get Bible + @github Get Bible + @support Get Bible + @copyright Copyright (C) 2015. All Rights Reserved + @license GNU/GPL Version 2 or later - http://www.gnu.org/licenses/gpl-2.0.html + +/------------------------------------------------------------------------------------------------------*/ + +Joomla.submitbutton = function(task) +{ + if (task == ''){ + return false; + } else { + var action = task.split('.'); + if (action[1] == 'cancel' || action[1] == 'close' || document.formvalidator.isValid(document.getElementById("adminForm"))){ + Joomla.submitform(task, document.getElementById("adminForm")); + return true; + } else { + alert(Joomla.JText._('tagged_verse, some values are not acceptable.','Some values are unacceptable')); + return false; + } + } +} \ No newline at end of file diff --git a/admin/views/tagged_verse/tmpl/edit.php b/admin/views/tagged_verse/tmpl/edit.php new file mode 100644 index 0000000..6b28f81 --- /dev/null +++ b/admin/views/tagged_verse/tmpl/edit.php @@ -0,0 +1,112 @@ + + @git Get Bible + @github Get Bible + @support Get Bible + @copyright Copyright (C) 2015. All Rights Reserved + @license GNU/GPL Version 2 or later - http://www.gnu.org/licenses/gpl-2.0.html + +/------------------------------------------------------------------------------------------------------*/ + +// No direct access to this file +defined('_JEXEC') or die('Restricted access'); + +JHtml::addIncludePath(JPATH_COMPONENT.'/helpers/html'); +JHtml::_('behavior.formvalidator'); +JHtml::_('formbehavior.chosen', 'select'); +JHtml::_('behavior.keepalive'); +$componentParams = $this->params; // will be removed just use $this->params instead +?> + + diff --git a/admin/views/tagged_verse/tmpl/index.html b/admin/views/tagged_verse/tmpl/index.html new file mode 100644 index 0000000..fa6d84e --- /dev/null +++ b/admin/views/tagged_verse/tmpl/index.html @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/admin/views/tagged_verse/view.html.php b/admin/views/tagged_verse/view.html.php new file mode 100644 index 0000000..fd4f1f1 --- /dev/null +++ b/admin/views/tagged_verse/view.html.php @@ -0,0 +1,203 @@ + + @git Get Bible + @github Get Bible + @support Get Bible + @copyright Copyright (C) 2015. All Rights Reserved + @license GNU/GPL Version 2 or later - http://www.gnu.org/licenses/gpl-2.0.html + +/------------------------------------------------------------------------------------------------------*/ + +// No direct access to this file +defined('_JEXEC') or die('Restricted access'); + +use Joomla\CMS\MVC\View\HtmlView; + +/** + * Tagged_verse Html View class + */ +class GetbibleViewTagged_verse extends HtmlView +{ + /** + * display method of View + * @return void + */ + public function display($tpl = null) + { + // set params + $this->params = JComponentHelper::getParams('com_getbible'); + // Assign the variables + $this->form = $this->get('Form'); + $this->item = $this->get('Item'); + $this->script = $this->get('Script'); + $this->state = $this->get('State'); + // get action permissions + $this->canDo = GetbibleHelper::getActions('tagged_verse', $this->item); + // get input + $jinput = JFactory::getApplication()->input; + $this->ref = $jinput->get('ref', 0, 'word'); + $this->refid = $jinput->get('refid', 0, 'int'); + $return = $jinput->get('return', null, 'base64'); + // set the referral string + $this->referral = ''; + if ($this->refid && $this->ref) + { + // return to the item that referred to this item + $this->referral = '&ref=' . (string)$this->ref . '&refid=' . (int)$this->refid; + } + elseif($this->ref) + { + // return to the list view that referred to this item + $this->referral = '&ref=' . (string)$this->ref; + } + // check return value + if (!is_null($return)) + { + // add the return value + $this->referral .= '&return=' . (string)$return; + } + + // Set the toolbar + $this->addToolBar(); + + // Check for errors. + if (count($errors = $this->get('Errors'))) + { + throw new Exception(implode("\n", $errors), 500); + } + + // Display the template + parent::display($tpl); + + // Set the document + $this->setDocument(); + } + + + /** + * Setting the toolbar + */ + protected function addToolBar() + { + JFactory::getApplication()->input->set('hidemainmenu', true); + $user = JFactory::getUser(); + $userId = $user->id; + $isNew = $this->item->id == 0; + + JToolbarHelper::title( JText::_($isNew ? 'COM_GETBIBLE_TAGGED_VERSE_NEW' : 'COM_GETBIBLE_TAGGED_VERSE_EDIT'), 'pencil-2 article-add'); + // Built the actions for new and existing records. + if (GetbibleHelper::checkString($this->referral)) + { + if ($this->canDo->get('tagged_verse.create') && $isNew) + { + // We can create the record. + JToolBarHelper::save('tagged_verse.save', 'JTOOLBAR_SAVE'); + } + elseif ($this->canDo->get('tagged_verse.edit')) + { + // We can save the record. + JToolBarHelper::save('tagged_verse.save', 'JTOOLBAR_SAVE'); + } + if ($isNew) + { + // Do not creat but cancel. + JToolBarHelper::cancel('tagged_verse.cancel', 'JTOOLBAR_CANCEL'); + } + else + { + // We can close it. + JToolBarHelper::cancel('tagged_verse.cancel', 'JTOOLBAR_CLOSE'); + } + } + else + { + if ($isNew) + { + // For new records, check the create permission. + if ($this->canDo->get('tagged_verse.create')) + { + JToolBarHelper::apply('tagged_verse.apply', 'JTOOLBAR_APPLY'); + JToolBarHelper::save('tagged_verse.save', 'JTOOLBAR_SAVE'); + JToolBarHelper::custom('tagged_verse.save2new', 'save-new.png', 'save-new_f2.png', 'JTOOLBAR_SAVE_AND_NEW', false); + }; + JToolBarHelper::cancel('tagged_verse.cancel', 'JTOOLBAR_CANCEL'); + } + else + { + if ($this->canDo->get('tagged_verse.edit')) + { + // We can save the new record + JToolBarHelper::apply('tagged_verse.apply', 'JTOOLBAR_APPLY'); + JToolBarHelper::save('tagged_verse.save', 'JTOOLBAR_SAVE'); + // We can save this record, but check the create permission to see + // if we can return to make a new one. + if ($this->canDo->get('tagged_verse.create')) + { + JToolBarHelper::custom('tagged_verse.save2new', 'save-new.png', 'save-new_f2.png', 'JTOOLBAR_SAVE_AND_NEW', false); + } + } + $canVersion = ($this->canDo->get('core.version') && $this->canDo->get('tagged_verse.version')); + if ($this->state->params->get('save_history', 1) && $this->canDo->get('tagged_verse.edit') && $canVersion) + { + JToolbarHelper::versions('com_getbible.tagged_verse', $this->item->id); + } + if ($this->canDo->get('tagged_verse.create')) + { + JToolBarHelper::custom('tagged_verse.save2copy', 'save-copy.png', 'save-copy_f2.png', 'JTOOLBAR_SAVE_AS_COPY', false); + } + JToolBarHelper::cancel('tagged_verse.cancel', 'JTOOLBAR_CLOSE'); + } + } + JToolbarHelper::divider(); + // set help url for this view if found + $this->help_url = GetbibleHelper::getHelpUrl('tagged_verse'); + if (GetbibleHelper::checkString($this->help_url)) + { + JToolbarHelper::help('COM_GETBIBLE_HELP_MANAGER', false, $this->help_url); + } + } + + /** + * Escapes a value for output in a view script. + * + * @param mixed $var The output to escape. + * + * @return mixed The escaped value. + */ + public function escape($var) + { + if(strlen($var) > 30) + { + // use the helper htmlEscape method instead and shorten the string + return GetbibleHelper::htmlEscape($var, $this->_charset, true, 30); + } + // use the helper htmlEscape method instead. + return GetbibleHelper::htmlEscape($var, $this->_charset); + } + + /** + * Method to set up the document properties + * + * @return void + */ + protected function setDocument() + { + $isNew = ($this->item->id < 1); + if (!isset($this->document)) + { + $this->document = JFactory::getDocument(); + } + $this->document->setTitle(JText::_($isNew ? 'COM_GETBIBLE_TAGGED_VERSE_NEW' : 'COM_GETBIBLE_TAGGED_VERSE_EDIT')); + $this->document->addStyleSheet(JURI::root() . "administrator/components/com_getbible/assets/css/tagged_verse.css", (GetbibleHelper::jVersion()->isCompatible('3.8.0')) ? array('version' => 'auto') : 'text/css'); + $this->document->addScript(JURI::root() . $this->script, (GetbibleHelper::jVersion()->isCompatible('3.8.0')) ? array('version' => 'auto') : 'text/javascript'); + $this->document->addScript(JURI::root() . "administrator/components/com_getbible/views/tagged_verse/submitbutton.js", (GetbibleHelper::jVersion()->isCompatible('3.8.0')) ? array('version' => 'auto') : 'text/javascript'); + JText::script('view not acceptable. Error'); + } +} diff --git a/admin/views/tagged_verses/index.html b/admin/views/tagged_verses/index.html new file mode 100644 index 0000000..fa6d84e --- /dev/null +++ b/admin/views/tagged_verses/index.html @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/admin/views/tagged_verses/tmpl/default.php b/admin/views/tagged_verses/tmpl/default.php new file mode 100644 index 0000000..8eced20 --- /dev/null +++ b/admin/views/tagged_verses/tmpl/default.php @@ -0,0 +1,77 @@ + + @git Get Bible + @github Get Bible + @support Get Bible + @copyright Copyright (C) 2015. All Rights Reserved + @license GNU/GPL Version 2 or later - http://www.gnu.org/licenses/gpl-2.0.html + +/------------------------------------------------------------------------------------------------------*/ + +// No direct access to this file +defined('_JEXEC') or die('Restricted access'); + +JHtml::_('behavior.multiselect'); +JHtml::_('dropdown.init'); +JHtml::_('formbehavior.chosen', '.multipleTaggedversesfilterbooknr', null, array('placeholder_text_multiple' => '- ' . JText::_('COM_GETBIBLE_FILTER_SELECT_BOOK_NUMBER') . ' -')); +JHtml::_('formbehavior.chosen', '.multipleTranslations', null, array('placeholder_text_multiple' => '- ' . JText::_('COM_GETBIBLE_FILTER_SELECT_TRANSLATION') . ' -')); +JHtml::_('formbehavior.chosen', '.multipleTaggedversesfilterverse', null, array('placeholder_text_multiple' => '- ' . JText::_('COM_GETBIBLE_FILTER_SELECT_VERSE') . ' -')); +JHtml::_('formbehavior.chosen', '.multipleTaggedversesfilterchapter', null, array('placeholder_text_multiple' => '- ' . JText::_('COM_GETBIBLE_FILTER_SELECT_CHAPTER') . ' -')); +JHtml::_('formbehavior.chosen', '.multipleAccessLevels', null, array('placeholder_text_multiple' => '- ' . JText::_('COM_GETBIBLE_FILTER_SELECT_ACCESS') . ' -')); +JHtml::_('formbehavior.chosen', 'select'); +if ($this->saveOrder) +{ + $saveOrderingUrl = 'index.php?option=com_getbible&task=tagged_verses.saveOrderAjax&tmpl=component'; + JHtml::_('sortablelist.sortable', 'tagged_verseList', 'adminForm', strtolower($this->listDirn), $saveOrderingUrl); +} +?> +
+sidebar)): ?> +
+ sidebar; ?> +
+
+ +
+ + $this)); +?> +items)): ?> +
+ +
+ + + loadTemplate('head');?> + loadTemplate('foot');?> + loadTemplate('body');?> +
+ + canCreate && $this->canEdit) : ?> + JText::_('COM_GETBIBLE_TAGGED_VERSES_BATCH_OPTIONS'), + 'footer' => $this->loadTemplate('batch_footer') + ), + $this->loadTemplate('batch_body') + ); ?> + + +
+ + + + diff --git a/admin/views/tagged_verses/tmpl/default_batch_body.php b/admin/views/tagged_verses/tmpl/default_batch_body.php new file mode 100644 index 0000000..3a1f5dd --- /dev/null +++ b/admin/views/tagged_verses/tmpl/default_batch_body.php @@ -0,0 +1,24 @@ + + @git Get Bible + @github Get Bible + @support Get Bible + @copyright Copyright (C) 2015. All Rights Reserved + @license GNU/GPL Version 2 or later - http://www.gnu.org/licenses/gpl-2.0.html + +/------------------------------------------------------------------------------------------------------*/ + +// No direct access to this file +defined('_JEXEC') or die('Restricted access'); + +?> + +

+batchDisplay; ?> \ No newline at end of file diff --git a/admin/views/tagged_verses/tmpl/default_batch_footer.php b/admin/views/tagged_verses/tmpl/default_batch_footer.php new file mode 100644 index 0000000..3623df3 --- /dev/null +++ b/admin/views/tagged_verses/tmpl/default_batch_footer.php @@ -0,0 +1,29 @@ + + @git Get Bible + @github Get Bible + @support Get Bible + @copyright Copyright (C) 2015. All Rights Reserved + @license GNU/GPL Version 2 or later - http://www.gnu.org/licenses/gpl-2.0.html + +/------------------------------------------------------------------------------------------------------*/ + +// No direct access to this file +defined('_JEXEC') or die('Restricted access'); + +?> + + + + \ No newline at end of file diff --git a/admin/views/tagged_verses/tmpl/default_body.php b/admin/views/tagged_verses/tmpl/default_body.php new file mode 100644 index 0000000..406a8c1 --- /dev/null +++ b/admin/views/tagged_verses/tmpl/default_body.php @@ -0,0 +1,127 @@ + + @git Get Bible + @github Get Bible + @support Get Bible + @copyright Copyright (C) 2015. All Rights Reserved + @license GNU/GPL Version 2 or later - http://www.gnu.org/licenses/gpl-2.0.html + +/------------------------------------------------------------------------------------------------------*/ + +// No direct access to this file +defined('_JEXEC') or die('Restricted access'); + +$edit = "index.php?option=com_getbible&view=tagged_verses&task=tagged_verse.edit"; + +?> +items as $i => $item): ?> + user->authorise('core.manage', 'com_checkin') || $item->checked_out == $this->user->id || $item->checked_out == 0; + $userChkOut = JFactory::getUser($item->checked_out); + $canDo = GetbibleHelper::getActions('tagged_verse',$item,'tagged_verses'); + ?> + + + get('tagged_verse.edit.state')): ?> + saveOrder) + { + $iconClass = ' inactive tip-top" hasTooltip" title="' . JHtml::tooltipText('JORDERINGDISABLED'); + } + ?> + + + + saveOrder) : ?> + + + + ⋮ + + + + get('tagged_verse.edit')): ?> + checked_out) : ?> + + id); ?> + + □ + + + id); ?> + + + □ + + + +
+ get('tagged_verse.edit')): ?> + escape($item->book_nr); ?> + checked_out): ?> + name, $item->checked_out_time, 'tagged_verses.', $canCheckin); ?> + + + escape($item->book_nr); ?> + +
+ + +
+ user->authorise('translation.edit', 'com_getbible.translation.' . (int) $item->abbreviation_id)): ?> + escape($item->abbreviation_translation); ?> + + escape($item->abbreviation_translation); ?> + +
+ + + access); ?> + + +
+ user->authorise('linker.edit', 'com_getbible.linker.' . (int) $item->linker_id)): ?> + escape($item->linker_name); ?> + + escape($item->linker_name); ?> + +
+ + +
+ user->authorise('tag.edit', 'com_getbible.tag.' . (int) $item->tag_id)): ?> + escape($item->tag_name); ?> + + escape($item->tag_name); ?> + +
+ + + get('tagged_verse.edit.state')) : ?> + checked_out) : ?> + + published, $i, 'tagged_verses.', true, 'cb'); ?> + + published, $i, 'tagged_verses.', false, 'cb'); ?> + + + published, $i, 'tagged_verses.', true, 'cb'); ?> + + + published, $i, 'tagged_verses.', false, 'cb'); ?> + + + + id; ?> + + + \ No newline at end of file diff --git a/admin/views/tagged_verses/tmpl/default_foot.php b/admin/views/tagged_verses/tmpl/default_foot.php new file mode 100644 index 0000000..6df0a9f --- /dev/null +++ b/admin/views/tagged_verses/tmpl/default_foot.php @@ -0,0 +1,24 @@ + + @git Get Bible + @github Get Bible + @support Get Bible + @copyright Copyright (C) 2015. All Rights Reserved + @license GNU/GPL Version 2 or later - http://www.gnu.org/licenses/gpl-2.0.html + +/------------------------------------------------------------------------------------------------------*/ + +// No direct access to this file +defined('_JEXEC') or die('Restricted access'); + +?> + + pagination->getListFooter(); ?> + \ No newline at end of file diff --git a/admin/views/tagged_verses/tmpl/default_head.php b/admin/views/tagged_verses/tmpl/default_head.php new file mode 100644 index 0000000..b103017 --- /dev/null +++ b/admin/views/tagged_verses/tmpl/default_head.php @@ -0,0 +1,65 @@ + + @git Get Bible + @github Get Bible + @support Get Bible + @copyright Copyright (C) 2015. All Rights Reserved + @license GNU/GPL Version 2 or later - http://www.gnu.org/licenses/gpl-2.0.html + +/------------------------------------------------------------------------------------------------------*/ + +// No direct access to this file +defined('_JEXEC') or die('Restricted access'); + +?> + + canEdit&& $this->canState): ?> + + listDirn, $this->listOrder, null, 'asc', 'JGRID_HEADING_ORDERING', 'icon-menu-2'); ?> + + + + + + + ▾ + + + ■ + + + + listDirn, $this->listOrder); ?> + + + listDirn, $this->listOrder); ?> + + + listDirn, $this->listOrder); ?> + + + listDirn, $this->listOrder); ?> + + + listDirn, $this->listOrder); ?> + + canState): ?> + + listDirn, $this->listOrder); ?> + + + + + + + + listDirn, $this->listOrder); ?> + + \ No newline at end of file diff --git a/admin/views/tagged_verses/tmpl/default_toolbar.php b/admin/views/tagged_verses/tmpl/default_toolbar.php new file mode 100644 index 0000000..8c2066c --- /dev/null +++ b/admin/views/tagged_verses/tmpl/default_toolbar.php @@ -0,0 +1,51 @@ + + @git Get Bible + @github Get Bible + @support Get Bible + @copyright Copyright (C) 2015. All Rights Reserved + @license GNU/GPL Version 2 or later - http://www.gnu.org/licenses/gpl-2.0.html + +/------------------------------------------------------------------------------------------------------*/ + +// No direct access to this file +defined('_JEXEC') or die('Restricted access'); + +?> +
+ +
+ + +
+
+ + pagination->getLimitBox(); ?> +
+
+ + +
+
+ + +
+
+
\ No newline at end of file diff --git a/admin/views/tagged_verses/tmpl/index.html b/admin/views/tagged_verses/tmpl/index.html new file mode 100644 index 0000000..fa6d84e --- /dev/null +++ b/admin/views/tagged_verses/tmpl/index.html @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/admin/views/tagged_verses/view.html.php b/admin/views/tagged_verses/view.html.php new file mode 100644 index 0000000..995bf5b --- /dev/null +++ b/admin/views/tagged_verses/view.html.php @@ -0,0 +1,361 @@ + + @git Get Bible + @github Get Bible + @support Get Bible + @copyright Copyright (C) 2015. All Rights Reserved + @license GNU/GPL Version 2 or later - http://www.gnu.org/licenses/gpl-2.0.html + +/------------------------------------------------------------------------------------------------------*/ + +// No direct access to this file +defined('_JEXEC') or die('Restricted access'); + +use Joomla\CMS\MVC\View\HtmlView; + +/** + * Getbible Html View class for the Tagged_verses + */ +class GetbibleViewTagged_verses extends HtmlView +{ + /** + * Tagged_verses view display method + * @return void + */ + function display($tpl = null) + { + if ($this->getLayout() !== 'modal') + { + // Include helper submenu + GetbibleHelper::addSubmenu('tagged_verses'); + } + + // Assign data to the view + $this->items = $this->get('Items'); + $this->pagination = $this->get('Pagination'); + $this->state = $this->get('State'); + $this->user = JFactory::getUser(); + // Load the filter form from xml. + $this->filterForm = $this->get('FilterForm'); + // Load the active filters. + $this->activeFilters = $this->get('ActiveFilters'); + // Add the list ordering clause. + $this->listOrder = $this->escape($this->state->get('list.ordering', 'a.id')); + $this->listDirn = $this->escape($this->state->get('list.direction', 'DESC')); + $this->saveOrder = $this->listOrder == 'a.ordering'; + // set the return here value + $this->return_here = urlencode(base64_encode((string) JUri::getInstance())); + // get global action permissions + $this->canDo = GetbibleHelper::getActions('tagged_verse'); + $this->canEdit = $this->canDo->get('tagged_verse.edit'); + $this->canState = $this->canDo->get('tagged_verse.edit.state'); + $this->canCreate = $this->canDo->get('tagged_verse.create'); + $this->canDelete = $this->canDo->get('tagged_verse.delete'); + $this->canBatch = $this->canDo->get('core.batch'); + + // We don't need toolbar in the modal window. + if ($this->getLayout() !== 'modal') + { + $this->addToolbar(); + $this->sidebar = JHtmlSidebar::render(); + // load the batch html + if ($this->canCreate && $this->canEdit && $this->canState) + { + $this->batchDisplay = JHtmlBatch_::render(); + } + } + + // Check for errors. + if (count($errors = $this->get('Errors'))) + { + throw new Exception(implode("\n", $errors), 500); + } + + // Display the template + parent::display($tpl); + + // Set the document + $this->setDocument(); + } + + /** + * Setting the toolbar + */ + protected function addToolBar() + { + JToolBarHelper::title(JText::_('COM_GETBIBLE_TAGGED_VERSES'), 'tags-2'); + JHtmlSidebar::setAction('index.php?option=com_getbible&view=tagged_verses'); + JFormHelper::addFieldPath(JPATH_COMPONENT . '/models/fields'); + + if ($this->canCreate) + { + JToolBarHelper::addNew('tagged_verse.add'); + } + + // Only load if there are items + if (GetbibleHelper::checkArray($this->items)) + { + if ($this->canEdit) + { + JToolBarHelper::editList('tagged_verse.edit'); + } + + if ($this->canState) + { + JToolBarHelper::publishList('tagged_verses.publish'); + JToolBarHelper::unpublishList('tagged_verses.unpublish'); + JToolBarHelper::archiveList('tagged_verses.archive'); + + if ($this->canDo->get('core.admin')) + { + JToolBarHelper::checkin('tagged_verses.checkin'); + } + } + + // Add a batch button + if ($this->canBatch && $this->canCreate && $this->canEdit && $this->canState) + { + // Get the toolbar object instance + $bar = JToolBar::getInstance('toolbar'); + // set the batch button name + $title = JText::_('JTOOLBAR_BATCH'); + // Instantiate a new JLayoutFile instance and render the batch button + $layout = new JLayoutFile('joomla.toolbar.batch'); + // add the button to the page + $dhtml = $layout->render(array('title' => $title)); + $bar->appendButton('Custom', $dhtml, 'batch'); + } + + if ($this->state->get('filter.published') == -2 && ($this->canState && $this->canDelete)) + { + JToolbarHelper::deleteList('', 'tagged_verses.delete', 'JTOOLBAR_EMPTY_TRASH'); + } + elseif ($this->canState && $this->canDelete) + { + JToolbarHelper::trash('tagged_verses.trash'); + } + } + + // set help url for this view if found + $this->help_url = GetbibleHelper::getHelpUrl('tagged_verses'); + if (GetbibleHelper::checkString($this->help_url)) + { + JToolbarHelper::help('COM_GETBIBLE_HELP_MANAGER', false, $this->help_url); + } + + // add the options comp button + if ($this->canDo->get('core.admin') || $this->canDo->get('core.options')) + { + JToolBarHelper::preferences('com_getbible'); + } + + // Only load published batch if state and batch is allowed + if ($this->canState && $this->canBatch) + { + JHtmlBatch_::addListSelection( + JText::_('COM_GETBIBLE_KEEP_ORIGINAL_STATE'), + 'batch[published]', + JHtml::_('select.options', JHtml::_('jgrid.publishedOptions', array('all' => false)), 'value', 'text', '', true) + ); + } + + // Only load Book Nr batch if create, edit, and batch is allowed + if ($this->canBatch && $this->canCreate && $this->canEdit) + { + // Set Book Nr Selection + $this->book_nrOptions = JFormHelper::loadFieldType('taggedversesfilterbooknr')->options; + // We do some sanitation for Book Nr filter + if (GetbibleHelper::checkArray($this->book_nrOptions) && + isset($this->book_nrOptions[0]->value) && + !GetbibleHelper::checkString($this->book_nrOptions[0]->value)) + { + unset($this->book_nrOptions[0]); + } + // Book Nr Batch Selection + JHtmlBatch_::addListSelection( + '- Keep Original '.JText::_('COM_GETBIBLE_TAGGED_VERSE_BOOK_NR_LABEL').' -', + 'batch[book_nr]', + JHtml::_('select.options', $this->book_nrOptions, 'value', 'text') + ); + } + + // Only load Abbreviation Translation batch if create, edit, and batch is allowed + if ($this->canBatch && $this->canCreate && $this->canEdit) + { + // Set Abbreviation Translation Selection + $this->abbreviationTranslationOptions = JFormHelper::loadFieldType('Translations')->options; + // We do some sanitation for Abbreviation Translation filter + if (GetbibleHelper::checkArray($this->abbreviationTranslationOptions) && + isset($this->abbreviationTranslationOptions[0]->value) && + !GetbibleHelper::checkString($this->abbreviationTranslationOptions[0]->value)) + { + unset($this->abbreviationTranslationOptions[0]); + } + // Abbreviation Translation Batch Selection + JHtmlBatch_::addListSelection( + '- Keep Original '.JText::_('COM_GETBIBLE_TAGGED_VERSE_ABBREVIATION_LABEL').' -', + 'batch[abbreviation]', + JHtml::_('select.options', $this->abbreviationTranslationOptions, 'value', 'text') + ); + } + + // Only load Access batch if create, edit, and batch is allowed + if ($this->canBatch && $this->canCreate && $this->canEdit) + { + // Set Access Selection + $this->accessOptions = JFormHelper::loadFieldType('taggedversesfilteraccess')->options; + // We do some sanitation for Access filter + if (GetbibleHelper::checkArray($this->accessOptions) && + isset($this->accessOptions[0]->value) && + !GetbibleHelper::checkString($this->accessOptions[0]->value)) + { + unset($this->accessOptions[0]); + } + // Access Batch Selection + JHtmlBatch_::addListSelection( + '- Keep Original '.JText::_('COM_GETBIBLE_TAGGED_VERSE_ACCESS_LABEL').' -', + 'batch[access]', + JHtml::_('select.options', $this->accessOptions, 'value', 'text') + ); + } + + // Only load Linker Name batch if create, edit, and batch is allowed + if ($this->canBatch && $this->canCreate && $this->canEdit) + { + // Set Linker Name Selection + $this->linkerNameOptions = JFormHelper::loadFieldType('Linkers')->options; + // We do some sanitation for Linker Name filter + if (GetbibleHelper::checkArray($this->linkerNameOptions) && + isset($this->linkerNameOptions[0]->value) && + !GetbibleHelper::checkString($this->linkerNameOptions[0]->value)) + { + unset($this->linkerNameOptions[0]); + } + // Linker Name Batch Selection + JHtmlBatch_::addListSelection( + '- Keep Original '.JText::_('COM_GETBIBLE_TAGGED_VERSE_LINKER_LABEL').' -', + 'batch[linker]', + JHtml::_('select.options', $this->linkerNameOptions, 'value', 'text') + ); + } + + // Only load Tag Name batch if create, edit, and batch is allowed + if ($this->canBatch && $this->canCreate && $this->canEdit) + { + // Set Tag Name Selection + $this->tagNameOptions = JFormHelper::loadFieldType('Tagers')->options; + // We do some sanitation for Tag Name filter + if (GetbibleHelper::checkArray($this->tagNameOptions) && + isset($this->tagNameOptions[0]->value) && + !GetbibleHelper::checkString($this->tagNameOptions[0]->value)) + { + unset($this->tagNameOptions[0]); + } + // Tag Name Batch Selection + JHtmlBatch_::addListSelection( + '- Keep Original '.JText::_('COM_GETBIBLE_TAGGED_VERSE_TAG_LABEL').' -', + 'batch[tag]', + JHtml::_('select.options', $this->tagNameOptions, 'value', 'text') + ); + } + + // Only load Verse batch if create, edit, and batch is allowed + if ($this->canBatch && $this->canCreate && $this->canEdit) + { + // Set Verse Selection + $this->verseOptions = JFormHelper::loadFieldType('taggedversesfilterverse')->options; + // We do some sanitation for Verse filter + if (GetbibleHelper::checkArray($this->verseOptions) && + isset($this->verseOptions[0]->value) && + !GetbibleHelper::checkString($this->verseOptions[0]->value)) + { + unset($this->verseOptions[0]); + } + // Verse Batch Selection + JHtmlBatch_::addListSelection( + '- Keep Original '.JText::_('COM_GETBIBLE_TAGGED_VERSE_VERSE_LABEL').' -', + 'batch[verse]', + JHtml::_('select.options', $this->verseOptions, 'value', 'text') + ); + } + + // Only load Chapter batch if create, edit, and batch is allowed + if ($this->canBatch && $this->canCreate && $this->canEdit) + { + // Set Chapter Selection + $this->chapterOptions = JFormHelper::loadFieldType('taggedversesfilterchapter')->options; + // We do some sanitation for Chapter filter + if (GetbibleHelper::checkArray($this->chapterOptions) && + isset($this->chapterOptions[0]->value) && + !GetbibleHelper::checkString($this->chapterOptions[0]->value)) + { + unset($this->chapterOptions[0]); + } + // Chapter Batch Selection + JHtmlBatch_::addListSelection( + '- Keep Original '.JText::_('COM_GETBIBLE_TAGGED_VERSE_CHAPTER_LABEL').' -', + 'batch[chapter]', + JHtml::_('select.options', $this->chapterOptions, 'value', 'text') + ); + } + } + + /** + * Method to set up the document properties + * + * @return void + */ + protected function setDocument() + { + if (!isset($this->document)) + { + $this->document = JFactory::getDocument(); + } + $this->document->setTitle(JText::_('COM_GETBIBLE_TAGGED_VERSES')); + $this->document->addStyleSheet(JURI::root() . "administrator/components/com_getbible/assets/css/tagged_verses.css", (GetbibleHelper::jVersion()->isCompatible('3.8.0')) ? array('version' => 'auto') : 'text/css'); + } + + /** + * Escapes a value for output in a view script. + * + * @param mixed $var The output to escape. + * + * @return mixed The escaped value. + */ + public function escape($var) + { + if(strlen($var) > 50) + { + // use the helper htmlEscape method instead and shorten the string + return GetbibleHelper::htmlEscape($var, $this->_charset, true); + } + // use the helper htmlEscape method instead. + return GetbibleHelper::htmlEscape($var, $this->_charset); + } + + /** + * Returns an array of fields the table can be sorted by + * + * @return array Array containing the field name to sort by as the key and display text as value + */ + protected function getSortFields() + { + return array( + 'a.ordering' => JText::_('JGRID_HEADING_ORDERING'), + 'a.published' => JText::_('JSTATUS'), + 'a.book_nr' => JText::_('COM_GETBIBLE_TAGGED_VERSE_BOOK_NR_LABEL'), + 'g.translation' => JText::_('COM_GETBIBLE_TAGGED_VERSE_ABBREVIATION_LABEL'), + 'a.access' => JText::_('COM_GETBIBLE_TAGGED_VERSE_ACCESS_LABEL'), + 'h.name' => JText::_('COM_GETBIBLE_TAGGED_VERSE_LINKER_LABEL'), + 'i.name' => JText::_('COM_GETBIBLE_TAGGED_VERSE_TAG_LABEL'), + 'a.id' => JText::_('JGRID_HEADING_ID') + ); + } +} diff --git a/admin/views/tags/index.html b/admin/views/tags/index.html new file mode 100644 index 0000000..fa6d84e --- /dev/null +++ b/admin/views/tags/index.html @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/admin/views/tags/tmpl/default.php b/admin/views/tags/tmpl/default.php new file mode 100644 index 0000000..3a30519 --- /dev/null +++ b/admin/views/tags/tmpl/default.php @@ -0,0 +1,73 @@ + + @git Get Bible + @github Get Bible + @support Get Bible + @copyright Copyright (C) 2015. All Rights Reserved + @license GNU/GPL Version 2 or later - http://www.gnu.org/licenses/gpl-2.0.html + +/------------------------------------------------------------------------------------------------------*/ + +// No direct access to this file +defined('_JEXEC') or die('Restricted access'); + +JHtml::_('behavior.multiselect'); +JHtml::_('dropdown.init'); +JHtml::_('formbehavior.chosen', '.multipleAccessLevels', null, array('placeholder_text_multiple' => '- ' . JText::_('COM_GETBIBLE_FILTER_SELECT_ACCESS') . ' -')); +JHtml::_('formbehavior.chosen', 'select'); +if ($this->saveOrder) +{ + $saveOrderingUrl = 'index.php?option=com_getbible&task=tags.saveOrderAjax&tmpl=component'; + JHtml::_('sortablelist.sortable', 'tagList', 'adminForm', strtolower($this->listDirn), $saveOrderingUrl); +} +?> +
+sidebar)): ?> +
+ sidebar; ?> +
+
+ +
+ + $this)); +?> +items)): ?> +
+ +
+ + + loadTemplate('head');?> + loadTemplate('foot');?> + loadTemplate('body');?> +
+ + canCreate && $this->canEdit) : ?> + JText::_('COM_GETBIBLE_TAGS_BATCH_OPTIONS'), + 'footer' => $this->loadTemplate('batch_footer') + ), + $this->loadTemplate('batch_body') + ); ?> + + +
+ + + + diff --git a/admin/views/tags/tmpl/default_batch_body.php b/admin/views/tags/tmpl/default_batch_body.php new file mode 100644 index 0000000..54607fe --- /dev/null +++ b/admin/views/tags/tmpl/default_batch_body.php @@ -0,0 +1,24 @@ + + @git Get Bible + @github Get Bible + @support Get Bible + @copyright Copyright (C) 2015. All Rights Reserved + @license GNU/GPL Version 2 or later - http://www.gnu.org/licenses/gpl-2.0.html + +/------------------------------------------------------------------------------------------------------*/ + +// No direct access to this file +defined('_JEXEC') or die('Restricted access'); + +?> + +

+batchDisplay; ?> \ No newline at end of file diff --git a/admin/views/tags/tmpl/default_batch_footer.php b/admin/views/tags/tmpl/default_batch_footer.php new file mode 100644 index 0000000..7457dae --- /dev/null +++ b/admin/views/tags/tmpl/default_batch_footer.php @@ -0,0 +1,29 @@ + + @git Get Bible + @github Get Bible + @support Get Bible + @copyright Copyright (C) 2015. All Rights Reserved + @license GNU/GPL Version 2 or later - http://www.gnu.org/licenses/gpl-2.0.html + +/------------------------------------------------------------------------------------------------------*/ + +// No direct access to this file +defined('_JEXEC') or die('Restricted access'); + +?> + + + + \ No newline at end of file diff --git a/admin/views/tags/tmpl/default_body.php b/admin/views/tags/tmpl/default_body.php new file mode 100644 index 0000000..0561b2f --- /dev/null +++ b/admin/views/tags/tmpl/default_body.php @@ -0,0 +1,103 @@ + + @git Get Bible + @github Get Bible + @support Get Bible + @copyright Copyright (C) 2015. All Rights Reserved + @license GNU/GPL Version 2 or later - http://www.gnu.org/licenses/gpl-2.0.html + +/------------------------------------------------------------------------------------------------------*/ + +// No direct access to this file +defined('_JEXEC') or die('Restricted access'); + +$edit = "index.php?option=com_getbible&view=tags&task=tag.edit"; + +?> +items as $i => $item): ?> + user->authorise('core.manage', 'com_checkin') || $item->checked_out == $this->user->id || $item->checked_out == 0; + $userChkOut = JFactory::getUser($item->checked_out); + $canDo = GetbibleHelper::getActions('tag',$item,'tags'); + ?> + + + get('tag.edit.state')): ?> + saveOrder) + { + $iconClass = ' inactive tip-top" hasTooltip" title="' . JHtml::tooltipText('JORDERINGDISABLED'); + } + ?> + + + + saveOrder) : ?> + + + + ⋮ + + + + get('tag.edit')): ?> + checked_out) : ?> + + id); ?> + + □ + + + id); ?> + + + □ + + + +
+ get('tag.edit')): ?> + escape($item->name); ?> + checked_out): ?> + name, $item->checked_out_time, 'tags.', $canCheckin); ?> + + + escape($item->name); ?> + +
+ + + escape($item->linker_name); ?> + + + access); ?> + + + get('tag.edit.state')) : ?> + checked_out) : ?> + + published, $i, 'tags.', true, 'cb'); ?> + + published, $i, 'tags.', false, 'cb'); ?> + + + published, $i, 'tags.', true, 'cb'); ?> + + + published, $i, 'tags.', false, 'cb'); ?> + + + + id; ?> + + + \ No newline at end of file diff --git a/admin/views/tags/tmpl/default_foot.php b/admin/views/tags/tmpl/default_foot.php new file mode 100644 index 0000000..38a928f --- /dev/null +++ b/admin/views/tags/tmpl/default_foot.php @@ -0,0 +1,24 @@ + + @git Get Bible + @github Get Bible + @support Get Bible + @copyright Copyright (C) 2015. All Rights Reserved + @license GNU/GPL Version 2 or later - http://www.gnu.org/licenses/gpl-2.0.html + +/------------------------------------------------------------------------------------------------------*/ + +// No direct access to this file +defined('_JEXEC') or die('Restricted access'); + +?> + + pagination->getListFooter(); ?> + \ No newline at end of file diff --git a/admin/views/tags/tmpl/default_head.php b/admin/views/tags/tmpl/default_head.php new file mode 100644 index 0000000..e7da840 --- /dev/null +++ b/admin/views/tags/tmpl/default_head.php @@ -0,0 +1,59 @@ + + @git Get Bible + @github Get Bible + @support Get Bible + @copyright Copyright (C) 2015. All Rights Reserved + @license GNU/GPL Version 2 or later - http://www.gnu.org/licenses/gpl-2.0.html + +/------------------------------------------------------------------------------------------------------*/ + +// No direct access to this file +defined('_JEXEC') or die('Restricted access'); + +?> + + canEdit&& $this->canState): ?> + + listDirn, $this->listOrder, null, 'asc', 'JGRID_HEADING_ORDERING', 'icon-menu-2'); ?> + + + + + + + ▾ + + + ■ + + + + listDirn, $this->listOrder); ?> + + + listDirn, $this->listOrder); ?> + + + listDirn, $this->listOrder); ?> + + canState): ?> + + listDirn, $this->listOrder); ?> + + + + + + + + listDirn, $this->listOrder); ?> + + \ No newline at end of file diff --git a/admin/views/tags/tmpl/default_toolbar.php b/admin/views/tags/tmpl/default_toolbar.php new file mode 100644 index 0000000..09fdafc --- /dev/null +++ b/admin/views/tags/tmpl/default_toolbar.php @@ -0,0 +1,51 @@ + + @git Get Bible + @github Get Bible + @support Get Bible + @copyright Copyright (C) 2015. All Rights Reserved + @license GNU/GPL Version 2 or later - http://www.gnu.org/licenses/gpl-2.0.html + +/------------------------------------------------------------------------------------------------------*/ + +// No direct access to this file +defined('_JEXEC') or die('Restricted access'); + +?> +
+ +
+ + +
+
+ + pagination->getLimitBox(); ?> +
+
+ + +
+
+ + +
+
+
\ No newline at end of file diff --git a/admin/views/tags/tmpl/index.html b/admin/views/tags/tmpl/index.html new file mode 100644 index 0000000..fa6d84e --- /dev/null +++ b/admin/views/tags/tmpl/index.html @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/admin/views/tags/view.html.php b/admin/views/tags/view.html.php new file mode 100644 index 0000000..1903692 --- /dev/null +++ b/admin/views/tags/view.html.php @@ -0,0 +1,259 @@ + + @git Get Bible + @github Get Bible + @support Get Bible + @copyright Copyright (C) 2015. All Rights Reserved + @license GNU/GPL Version 2 or later - http://www.gnu.org/licenses/gpl-2.0.html + +/------------------------------------------------------------------------------------------------------*/ + +// No direct access to this file +defined('_JEXEC') or die('Restricted access'); + +use Joomla\CMS\MVC\View\HtmlView; + +/** + * Getbible Html View class for the Tags + */ +class GetbibleViewTags extends HtmlView +{ + /** + * Tags view display method + * @return void + */ + function display($tpl = null) + { + if ($this->getLayout() !== 'modal') + { + // Include helper submenu + GetbibleHelper::addSubmenu('tags'); + } + + // Assign data to the view + $this->items = $this->get('Items'); + $this->pagination = $this->get('Pagination'); + $this->state = $this->get('State'); + $this->user = JFactory::getUser(); + // Load the filter form from xml. + $this->filterForm = $this->get('FilterForm'); + // Load the active filters. + $this->activeFilters = $this->get('ActiveFilters'); + // Add the list ordering clause. + $this->listOrder = $this->escape($this->state->get('list.ordering', 'a.id')); + $this->listDirn = $this->escape($this->state->get('list.direction', 'DESC')); + $this->saveOrder = $this->listOrder == 'a.ordering'; + // set the return here value + $this->return_here = urlencode(base64_encode((string) JUri::getInstance())); + // get global action permissions + $this->canDo = GetbibleHelper::getActions('tag'); + $this->canEdit = $this->canDo->get('tag.edit'); + $this->canState = $this->canDo->get('tag.edit.state'); + $this->canCreate = $this->canDo->get('tag.create'); + $this->canDelete = $this->canDo->get('tag.delete'); + $this->canBatch = $this->canDo->get('core.batch'); + + // We don't need toolbar in the modal window. + if ($this->getLayout() !== 'modal') + { + $this->addToolbar(); + $this->sidebar = JHtmlSidebar::render(); + // load the batch html + if ($this->canCreate && $this->canEdit && $this->canState) + { + $this->batchDisplay = JHtmlBatch_::render(); + } + } + + // Check for errors. + if (count($errors = $this->get('Errors'))) + { + throw new Exception(implode("\n", $errors), 500); + } + + // Display the template + parent::display($tpl); + + // Set the document + $this->setDocument(); + } + + /** + * Setting the toolbar + */ + protected function addToolBar() + { + JToolBarHelper::title(JText::_('COM_GETBIBLE_TAGS'), 'tags'); + JHtmlSidebar::setAction('index.php?option=com_getbible&view=tags'); + JFormHelper::addFieldPath(JPATH_COMPONENT . '/models/fields'); + + if ($this->canCreate) + { + JToolBarHelper::addNew('tag.add'); + } + + // Only load if there are items + if (GetbibleHelper::checkArray($this->items)) + { + if ($this->canEdit) + { + JToolBarHelper::editList('tag.edit'); + } + + if ($this->canState) + { + JToolBarHelper::publishList('tags.publish'); + JToolBarHelper::unpublishList('tags.unpublish'); + JToolBarHelper::archiveList('tags.archive'); + + if ($this->canDo->get('core.admin')) + { + JToolBarHelper::checkin('tags.checkin'); + } + } + + // Add a batch button + if ($this->canBatch && $this->canCreate && $this->canEdit && $this->canState) + { + // Get the toolbar object instance + $bar = JToolBar::getInstance('toolbar'); + // set the batch button name + $title = JText::_('JTOOLBAR_BATCH'); + // Instantiate a new JLayoutFile instance and render the batch button + $layout = new JLayoutFile('joomla.toolbar.batch'); + // add the button to the page + $dhtml = $layout->render(array('title' => $title)); + $bar->appendButton('Custom', $dhtml, 'batch'); + } + + if ($this->state->get('filter.published') == -2 && ($this->canState && $this->canDelete)) + { + JToolbarHelper::deleteList('', 'tags.delete', 'JTOOLBAR_EMPTY_TRASH'); + } + elseif ($this->canState && $this->canDelete) + { + JToolbarHelper::trash('tags.trash'); + } + } + + // set help url for this view if found + $this->help_url = GetbibleHelper::getHelpUrl('tags'); + if (GetbibleHelper::checkString($this->help_url)) + { + JToolbarHelper::help('COM_GETBIBLE_HELP_MANAGER', false, $this->help_url); + } + + // add the options comp button + if ($this->canDo->get('core.admin') || $this->canDo->get('core.options')) + { + JToolBarHelper::preferences('com_getbible'); + } + + // Only load published batch if state and batch is allowed + if ($this->canState && $this->canBatch) + { + JHtmlBatch_::addListSelection( + JText::_('COM_GETBIBLE_KEEP_ORIGINAL_STATE'), + 'batch[published]', + JHtml::_('select.options', JHtml::_('jgrid.publishedOptions', array('all' => false)), 'value', 'text', '', true) + ); + } + + // Only load Linker Name batch if create, edit, and batch is allowed + if ($this->canBatch && $this->canCreate && $this->canEdit) + { + // Set Linker Name Selection + $this->linkerNameOptions = JFormHelper::loadFieldType('Linkers')->options; + // We do some sanitation for Linker Name filter + if (GetbibleHelper::checkArray($this->linkerNameOptions) && + isset($this->linkerNameOptions[0]->value) && + !GetbibleHelper::checkString($this->linkerNameOptions[0]->value)) + { + unset($this->linkerNameOptions[0]); + } + // Linker Name Batch Selection + JHtmlBatch_::addListSelection( + '- Keep Original '.JText::_('COM_GETBIBLE_TAG_LINKER_LABEL').' -', + 'batch[linker]', + JHtml::_('select.options', $this->linkerNameOptions, 'value', 'text') + ); + } + + // Only load Access batch if create, edit, and batch is allowed + if ($this->canBatch && $this->canCreate && $this->canEdit) + { + // Set Access Selection + $this->accessOptions = JFormHelper::loadFieldType('tagsfilteraccess')->options; + // We do some sanitation for Access filter + if (GetbibleHelper::checkArray($this->accessOptions) && + isset($this->accessOptions[0]->value) && + !GetbibleHelper::checkString($this->accessOptions[0]->value)) + { + unset($this->accessOptions[0]); + } + // Access Batch Selection + JHtmlBatch_::addListSelection( + '- Keep Original '.JText::_('COM_GETBIBLE_TAG_ACCESS_LABEL').' -', + 'batch[access]', + JHtml::_('select.options', $this->accessOptions, 'value', 'text') + ); + } + } + + /** + * Method to set up the document properties + * + * @return void + */ + protected function setDocument() + { + if (!isset($this->document)) + { + $this->document = JFactory::getDocument(); + } + $this->document->setTitle(JText::_('COM_GETBIBLE_TAGS')); + $this->document->addStyleSheet(JURI::root() . "administrator/components/com_getbible/assets/css/tags.css", (GetbibleHelper::jVersion()->isCompatible('3.8.0')) ? array('version' => 'auto') : 'text/css'); + } + + /** + * Escapes a value for output in a view script. + * + * @param mixed $var The output to escape. + * + * @return mixed The escaped value. + */ + public function escape($var) + { + if(strlen($var) > 50) + { + // use the helper htmlEscape method instead and shorten the string + return GetbibleHelper::htmlEscape($var, $this->_charset, true); + } + // use the helper htmlEscape method instead. + return GetbibleHelper::htmlEscape($var, $this->_charset); + } + + /** + * Returns an array of fields the table can be sorted by + * + * @return array Array containing the field name to sort by as the key and display text as value + */ + protected function getSortFields() + { + return array( + 'a.ordering' => JText::_('JGRID_HEADING_ORDERING'), + 'a.published' => JText::_('JSTATUS'), + 'a.name' => JText::_('COM_GETBIBLE_TAG_NAME_LABEL'), + 'g.name' => JText::_('COM_GETBIBLE_TAG_LINKER_LABEL'), + 'a.access' => JText::_('COM_GETBIBLE_TAG_ACCESS_LABEL'), + 'a.id' => JText::_('JGRID_HEADING_ID') + ); + } +} diff --git a/admin/views/translation/submitbutton.js b/admin/views/translation/submitbutton.js new file mode 100644 index 0000000..2db2bd4 --- /dev/null +++ b/admin/views/translation/submitbutton.js @@ -0,0 +1,31 @@ +/*----------------------------------------------------------------------------------| io.vdm.dev |----/ + Vast Development Method +/-------------------------------------------------------------------------------------------------------/ + + @package getBible.net + + @created 3rd December, 2015 + @author Llewellyn van der Merwe + @git Get Bible + @github Get Bible + @support Get Bible + @copyright Copyright (C) 2015. All Rights Reserved + @license GNU/GPL Version 2 or later - http://www.gnu.org/licenses/gpl-2.0.html + +/------------------------------------------------------------------------------------------------------*/ + +Joomla.submitbutton = function(task) +{ + if (task == ''){ + return false; + } else { + var action = task.split('.'); + if (action[1] == 'cancel' || action[1] == 'close' || document.formvalidator.isValid(document.getElementById("adminForm"))){ + Joomla.submitform(task, document.getElementById("adminForm")); + return true; + } else { + alert(Joomla.JText._('translation, some values are not acceptable.','Some values are unacceptable')); + return false; + } + } +} \ No newline at end of file diff --git a/admin/views/translation/tmpl/edit.php b/admin/views/translation/tmpl/edit.php new file mode 100644 index 0000000..e3eaf7b --- /dev/null +++ b/admin/views/translation/tmpl/edit.php @@ -0,0 +1,117 @@ + + @git Get Bible + @github Get Bible + @support Get Bible + @copyright Copyright (C) 2015. All Rights Reserved + @license GNU/GPL Version 2 or later - http://www.gnu.org/licenses/gpl-2.0.html + +/------------------------------------------------------------------------------------------------------*/ + +// No direct access to this file +defined('_JEXEC') or die('Restricted access'); + +JHtml::addIncludePath(JPATH_COMPONENT.'/helpers/html'); +JHtml::_('behavior.formvalidator'); +JHtml::_('formbehavior.chosen', 'select'); +JHtml::_('behavior.keepalive'); +$componentParams = $this->params; // will be removed just use $this->params instead +?> + + diff --git a/admin/views/translation/tmpl/index.html b/admin/views/translation/tmpl/index.html new file mode 100644 index 0000000..fa6d84e --- /dev/null +++ b/admin/views/translation/tmpl/index.html @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/admin/views/translation/view.html.php b/admin/views/translation/view.html.php new file mode 100644 index 0000000..2e1ac67 --- /dev/null +++ b/admin/views/translation/view.html.php @@ -0,0 +1,132 @@ + + @git Get Bible + @github Get Bible + @support Get Bible + @copyright Copyright (C) 2015. All Rights Reserved + @license GNU/GPL Version 2 or later - http://www.gnu.org/licenses/gpl-2.0.html + +/------------------------------------------------------------------------------------------------------*/ + +// No direct access to this file +defined('_JEXEC') or die('Restricted access'); + +use Joomla\CMS\MVC\View\HtmlView; + +/** + * Translation Html View class + */ +class GetbibleViewTranslation extends HtmlView +{ + /** + * display method of View + * @return void + */ + public function display($tpl = null) + { + // set params + $this->params = JComponentHelper::getParams('com_getbible'); + // Assign the variables + $this->form = $this->get('Form'); + $this->item = $this->get('Item'); + $this->script = $this->get('Script'); + $this->state = $this->get('State'); + // get action permissions + $this->canDo = GetbibleHelper::getActions('translation', $this->item); + // get input + $jinput = JFactory::getApplication()->input; + $this->ref = $jinput->get('ref', 0, 'word'); + $this->refid = $jinput->get('refid', 0, 'int'); + $return = $jinput->get('return', null, 'base64'); + // set the referral string + $this->referral = ''; + if ($this->refid && $this->ref) + { + // return to the item that referred to this item + $this->referral = '&ref=' . (string)$this->ref . '&refid=' . (int)$this->refid; + } + elseif($this->ref) + { + // return to the list view that referred to this item + $this->referral = '&ref=' . (string)$this->ref; + } + // check return value + if (!is_null($return)) + { + // add the return value + $this->referral .= '&return=' . (string)$return; + } + + // Set the toolbar + $this->addToolBar(); + + // Check for errors. + if (count($errors = $this->get('Errors'))) + { + throw new Exception(implode("\n", $errors), 500); + } + + // Display the template + parent::display($tpl); + + // Set the document + $this->setDocument(); + } + + + /** + * Setting the toolbar + */ + protected function addToolBar() + { + JFactory::getApplication()->input->set('hidemainmenu', true); + JToolBarHelper::title(JText::_('COM_GETBIBLE_TRANSLATION_READONLY'), 'translation'); + JToolBarHelper::cancel('translation.cancel', 'JTOOLBAR_CLOSE'); + } + + /** + * Escapes a value for output in a view script. + * + * @param mixed $var The output to escape. + * + * @return mixed The escaped value. + */ + public function escape($var) + { + if(strlen($var) > 30) + { + // use the helper htmlEscape method instead and shorten the string + return GetbibleHelper::htmlEscape($var, $this->_charset, true, 30); + } + // use the helper htmlEscape method instead. + return GetbibleHelper::htmlEscape($var, $this->_charset); + } + + /** + * Method to set up the document properties + * + * @return void + */ + protected function setDocument() + { + $isNew = ($this->item->id < 1); + if (!isset($this->document)) + { + $this->document = JFactory::getDocument(); + } + $this->document->setTitle(JText::_($isNew ? 'COM_GETBIBLE_TRANSLATION_NEW' : 'COM_GETBIBLE_TRANSLATION_EDIT')); + $this->document->addStyleSheet(JURI::root() . "administrator/components/com_getbible/assets/css/translation.css", (GetbibleHelper::jVersion()->isCompatible('3.8.0')) ? array('version' => 'auto') : 'text/css'); + // Add Ajax Token + $this->document->addScriptDeclaration("var token = '".JSession::getFormToken()."';"); + $this->document->addScript(JURI::root() . $this->script, (GetbibleHelper::jVersion()->isCompatible('3.8.0')) ? array('version' => 'auto') : 'text/javascript'); + $this->document->addScript(JURI::root() . "administrator/components/com_getbible/views/translation/submitbutton.js", (GetbibleHelper::jVersion()->isCompatible('3.8.0')) ? array('version' => 'auto') : 'text/javascript'); + JText::script('view not acceptable. Error'); + } +} diff --git a/admin/views/translations/index.html b/admin/views/translations/index.html new file mode 100644 index 0000000..fa6d84e --- /dev/null +++ b/admin/views/translations/index.html @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/admin/views/translations/tmpl/default.php b/admin/views/translations/tmpl/default.php new file mode 100644 index 0000000..2739932 --- /dev/null +++ b/admin/views/translations/tmpl/default.php @@ -0,0 +1,73 @@ + + @git Get Bible + @github Get Bible + @support Get Bible + @copyright Copyright (C) 2015. All Rights Reserved + @license GNU/GPL Version 2 or later - http://www.gnu.org/licenses/gpl-2.0.html + +/------------------------------------------------------------------------------------------------------*/ + +// No direct access to this file +defined('_JEXEC') or die('Restricted access'); + +JHtml::_('behavior.multiselect'); +JHtml::_('dropdown.init'); +JHtml::_('formbehavior.chosen', '.multipleAccessLevels', null, array('placeholder_text_multiple' => '- ' . JText::_('COM_GETBIBLE_FILTER_SELECT_ACCESS') . ' -')); +JHtml::_('formbehavior.chosen', 'select'); +if ($this->saveOrder) +{ + $saveOrderingUrl = 'index.php?option=com_getbible&task=translations.saveOrderAjax&tmpl=component'; + JHtml::_('sortablelist.sortable', 'translationList', 'adminForm', strtolower($this->listDirn), $saveOrderingUrl); +} +?> +
+sidebar)): ?> +
+ sidebar; ?> +
+
+ +
+ + $this)); +?> +items)): ?> +
+ +
+ + + loadTemplate('head');?> + loadTemplate('foot');?> + loadTemplate('body');?> +
+ + canCreate && $this->canEdit) : ?> + JText::_('COM_GETBIBLE_TRANSLATIONS_BATCH_OPTIONS'), + 'footer' => $this->loadTemplate('batch_footer') + ), + $this->loadTemplate('batch_body') + ); ?> + + +
+ + + + diff --git a/admin/views/translations/tmpl/default_batch_body.php b/admin/views/translations/tmpl/default_batch_body.php new file mode 100644 index 0000000..4bc956e --- /dev/null +++ b/admin/views/translations/tmpl/default_batch_body.php @@ -0,0 +1,24 @@ + + @git Get Bible + @github Get Bible + @support Get Bible + @copyright Copyright (C) 2015. All Rights Reserved + @license GNU/GPL Version 2 or later - http://www.gnu.org/licenses/gpl-2.0.html + +/------------------------------------------------------------------------------------------------------*/ + +// No direct access to this file +defined('_JEXEC') or die('Restricted access'); + +?> + +

+batchDisplay; ?> \ No newline at end of file diff --git a/admin/views/translations/tmpl/default_batch_footer.php b/admin/views/translations/tmpl/default_batch_footer.php new file mode 100644 index 0000000..53b2349 --- /dev/null +++ b/admin/views/translations/tmpl/default_batch_footer.php @@ -0,0 +1,29 @@ + + @git Get Bible + @github Get Bible + @support Get Bible + @copyright Copyright (C) 2015. All Rights Reserved + @license GNU/GPL Version 2 or later - http://www.gnu.org/licenses/gpl-2.0.html + +/------------------------------------------------------------------------------------------------------*/ + +// No direct access to this file +defined('_JEXEC') or die('Restricted access'); + +?> + + + + \ No newline at end of file diff --git a/admin/views/translations/tmpl/default_body.php b/admin/views/translations/tmpl/default_body.php new file mode 100644 index 0000000..c04ab83 --- /dev/null +++ b/admin/views/translations/tmpl/default_body.php @@ -0,0 +1,106 @@ + + @git Get Bible + @github Get Bible + @support Get Bible + @copyright Copyright (C) 2015. All Rights Reserved + @license GNU/GPL Version 2 or later - http://www.gnu.org/licenses/gpl-2.0.html + +/------------------------------------------------------------------------------------------------------*/ + +// No direct access to this file +defined('_JEXEC') or die('Restricted access'); + +$edit = "index.php?option=com_getbible&view=translations&task=translation.edit"; + +?> +items as $i => $item): ?> + user->authorise('core.manage', 'com_checkin') || $item->checked_out == $this->user->id || $item->checked_out == 0; + $userChkOut = JFactory::getUser($item->checked_out); + $canDo = GetbibleHelper::getActions('translation',$item,'translations'); + ?> + + + get('translation.edit.state')): ?> + saveOrder) + { + $iconClass = ' inactive tip-top" hasTooltip" title="' . JHtml::tooltipText('JORDERINGDISABLED'); + } + ?> + + + + saveOrder) : ?> + + + + ⋮ + + + + get('translation.edit')): ?> + checked_out) : ?> + + id); ?> + + □ + + + id); ?> + + + □ + + + +
+ get('translation.edit')): ?> + escape($item->translation); ?> + checked_out): ?> + name, $item->checked_out_time, 'translations.', $canCheckin); ?> + + + escape($item->translation); ?> + +
+ + + escape($item->abbreviation); ?> + + + escape($item->language); ?> + + + direction); ?> + + + get('translation.edit.state')) : ?> + checked_out) : ?> + + published, $i, 'translations.', true, 'cb'); ?> + + published, $i, 'translations.', false, 'cb'); ?> + + + published, $i, 'translations.', true, 'cb'); ?> + + + published, $i, 'translations.', false, 'cb'); ?> + + + + id; ?> + + + \ No newline at end of file diff --git a/admin/views/translations/tmpl/default_foot.php b/admin/views/translations/tmpl/default_foot.php new file mode 100644 index 0000000..290760a --- /dev/null +++ b/admin/views/translations/tmpl/default_foot.php @@ -0,0 +1,24 @@ + + @git Get Bible + @github Get Bible + @support Get Bible + @copyright Copyright (C) 2015. All Rights Reserved + @license GNU/GPL Version 2 or later - http://www.gnu.org/licenses/gpl-2.0.html + +/------------------------------------------------------------------------------------------------------*/ + +// No direct access to this file +defined('_JEXEC') or die('Restricted access'); + +?> + + pagination->getListFooter(); ?> + \ No newline at end of file diff --git a/admin/views/translations/tmpl/default_head.php b/admin/views/translations/tmpl/default_head.php new file mode 100644 index 0000000..003c884 --- /dev/null +++ b/admin/views/translations/tmpl/default_head.php @@ -0,0 +1,62 @@ + + @git Get Bible + @github Get Bible + @support Get Bible + @copyright Copyright (C) 2015. All Rights Reserved + @license GNU/GPL Version 2 or later - http://www.gnu.org/licenses/gpl-2.0.html + +/------------------------------------------------------------------------------------------------------*/ + +// No direct access to this file +defined('_JEXEC') or die('Restricted access'); + +?> + + canEdit&& $this->canState): ?> + + listDirn, $this->listOrder, null, 'asc', 'JGRID_HEADING_ORDERING', 'icon-menu-2'); ?> + + + + + + + ▾ + + + ■ + + + + listDirn, $this->listOrder); ?> + + + listDirn, $this->listOrder); ?> + + + listDirn, $this->listOrder); ?> + + + listDirn, $this->listOrder); ?> + + canState): ?> + + listDirn, $this->listOrder); ?> + + + + + + + + listDirn, $this->listOrder); ?> + + \ No newline at end of file diff --git a/admin/views/translations/tmpl/default_toolbar.php b/admin/views/translations/tmpl/default_toolbar.php new file mode 100644 index 0000000..50bd491 --- /dev/null +++ b/admin/views/translations/tmpl/default_toolbar.php @@ -0,0 +1,51 @@ + + @git Get Bible + @github Get Bible + @support Get Bible + @copyright Copyright (C) 2015. All Rights Reserved + @license GNU/GPL Version 2 or later - http://www.gnu.org/licenses/gpl-2.0.html + +/------------------------------------------------------------------------------------------------------*/ + +// No direct access to this file +defined('_JEXEC') or die('Restricted access'); + +?> +
+ +
+ + +
+
+ + pagination->getLimitBox(); ?> +
+
+ + +
+
+ + +
+
+
\ No newline at end of file diff --git a/admin/views/translations/tmpl/index.html b/admin/views/translations/tmpl/index.html new file mode 100644 index 0000000..fa6d84e --- /dev/null +++ b/admin/views/translations/tmpl/index.html @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/admin/views/translations/view.html.php b/admin/views/translations/view.html.php new file mode 100644 index 0000000..f937f6d --- /dev/null +++ b/admin/views/translations/view.html.php @@ -0,0 +1,250 @@ + + @git Get Bible + @github Get Bible + @support Get Bible + @copyright Copyright (C) 2015. All Rights Reserved + @license GNU/GPL Version 2 or later - http://www.gnu.org/licenses/gpl-2.0.html + +/------------------------------------------------------------------------------------------------------*/ + +// No direct access to this file +defined('_JEXEC') or die('Restricted access'); + +use Joomla\CMS\MVC\View\HtmlView; + +/** + * Getbible Html View class for the Translations + */ +class GetbibleViewTranslations extends HtmlView +{ + /** + * Translations view display method + * @return void + */ + function display($tpl = null) + { + if ($this->getLayout() !== 'modal') + { + // Include helper submenu + GetbibleHelper::addSubmenu('translations'); + } + + // Assign data to the view + $this->items = $this->get('Items'); + $this->pagination = $this->get('Pagination'); + $this->state = $this->get('State'); + $this->user = JFactory::getUser(); + // Load the filter form from xml. + $this->filterForm = $this->get('FilterForm'); + // Load the active filters. + $this->activeFilters = $this->get('ActiveFilters'); + // Add the list ordering clause. + $this->listOrder = $this->escape($this->state->get('list.ordering', 'a.id')); + $this->listDirn = $this->escape($this->state->get('list.direction', 'DESC')); + $this->saveOrder = $this->listOrder == 'a.ordering'; + // set the return here value + $this->return_here = urlencode(base64_encode((string) JUri::getInstance())); + // get global action permissions + $this->canDo = GetbibleHelper::getActions('translation'); + $this->canEdit = $this->canDo->get('translation.edit'); + $this->canState = $this->canDo->get('translation.edit.state'); + $this->canCreate = $this->canDo->get('translation.create'); + $this->canDelete = $this->canDo->get('translation.delete'); + $this->canBatch = $this->canDo->get('core.batch'); + + // We don't need toolbar in the modal window. + if ($this->getLayout() !== 'modal') + { + $this->addToolbar(); + $this->sidebar = JHtmlSidebar::render(); + // load the batch html + if ($this->canCreate && $this->canEdit && $this->canState) + { + $this->batchDisplay = JHtmlBatch_::render(); + } + } + + // Check for errors. + if (count($errors = $this->get('Errors'))) + { + throw new Exception(implode("\n", $errors), 500); + } + + // Display the template + parent::display($tpl); + + // Set the document + $this->setDocument(); + } + + /** + * Setting the toolbar + */ + protected function addToolBar() + { + JToolBarHelper::title(JText::_('COM_GETBIBLE_TRANSLATIONS'), 'book'); + JHtmlSidebar::setAction('index.php?option=com_getbible&view=translations'); + JFormHelper::addFieldPath(JPATH_COMPONENT . '/models/fields'); + + if ($this->canCreate) + { + JToolBarHelper::addNew('translation.add'); + } + + // Only load if there are items + if (GetbibleHelper::checkArray($this->items)) + { + if ($this->canEdit) + { + JToolBarHelper::editList('translation.edit'); + } + + if ($this->canState) + { + JToolBarHelper::publishList('translations.publish'); + JToolBarHelper::unpublishList('translations.unpublish'); + JToolBarHelper::archiveList('translations.archive'); + + if ($this->canDo->get('core.admin')) + { + JToolBarHelper::checkin('translations.checkin'); + } + } + + // Add a batch button + if ($this->canBatch && $this->canCreate && $this->canEdit && $this->canState) + { + // Get the toolbar object instance + $bar = JToolBar::getInstance('toolbar'); + // set the batch button name + $title = JText::_('JTOOLBAR_BATCH'); + // Instantiate a new JLayoutFile instance and render the batch button + $layout = new JLayoutFile('joomla.toolbar.batch'); + // add the button to the page + $dhtml = $layout->render(array('title' => $title)); + $bar->appendButton('Custom', $dhtml, 'batch'); + } + + if ($this->state->get('filter.published') == -2 && ($this->canState && $this->canDelete)) + { + JToolbarHelper::deleteList('', 'translations.delete', 'JTOOLBAR_EMPTY_TRASH'); + } + elseif ($this->canState && $this->canDelete) + { + JToolbarHelper::trash('translations.trash'); + } + } + + // set help url for this view if found + $this->help_url = GetbibleHelper::getHelpUrl('translations'); + if (GetbibleHelper::checkString($this->help_url)) + { + JToolbarHelper::help('COM_GETBIBLE_HELP_MANAGER', false, $this->help_url); + } + + // add the options comp button + if ($this->canDo->get('core.admin') || $this->canDo->get('core.options')) + { + JToolBarHelper::preferences('com_getbible'); + } + + // Only load published batch if state and batch is allowed + if ($this->canState && $this->canBatch) + { + JHtmlBatch_::addListSelection( + JText::_('COM_GETBIBLE_KEEP_ORIGINAL_STATE'), + 'batch[published]', + JHtml::_('select.options', JHtml::_('jgrid.publishedOptions', array('all' => false)), 'value', 'text', '', true) + ); + } + + // Only load access batch if create, edit and batch is allowed + if ($this->canBatch && $this->canCreate && $this->canEdit) + { + JHtmlBatch_::addListSelection( + JText::_('COM_GETBIBLE_KEEP_ORIGINAL_ACCESS'), + 'batch[access]', + JHtml::_('select.options', JHtml::_('access.assetgroups'), 'value', 'text') + ); + } + + // Only load Direction batch if create, edit, and batch is allowed + if ($this->canBatch && $this->canCreate && $this->canEdit) + { + // Set Direction Selection + $this->directionOptions = JFormHelper::loadFieldType('translationsfilterdirection')->options; + // We do some sanitation for Direction filter + if (GetbibleHelper::checkArray($this->directionOptions) && + isset($this->directionOptions[0]->value) && + !GetbibleHelper::checkString($this->directionOptions[0]->value)) + { + unset($this->directionOptions[0]); + } + // Direction Batch Selection + JHtmlBatch_::addListSelection( + '- Keep Original '.JText::_('COM_GETBIBLE_TRANSLATION_DIRECTION_LABEL').' -', + 'batch[direction]', + JHtml::_('select.options', $this->directionOptions, 'value', 'text') + ); + } + } + + /** + * Method to set up the document properties + * + * @return void + */ + protected function setDocument() + { + if (!isset($this->document)) + { + $this->document = JFactory::getDocument(); + } + $this->document->setTitle(JText::_('COM_GETBIBLE_TRANSLATIONS')); + $this->document->addStyleSheet(JURI::root() . "administrator/components/com_getbible/assets/css/translations.css", (GetbibleHelper::jVersion()->isCompatible('3.8.0')) ? array('version' => 'auto') : 'text/css'); + } + + /** + * Escapes a value for output in a view script. + * + * @param mixed $var The output to escape. + * + * @return mixed The escaped value. + */ + public function escape($var) + { + if(strlen($var) > 50) + { + // use the helper htmlEscape method instead and shorten the string + return GetbibleHelper::htmlEscape($var, $this->_charset, true); + } + // use the helper htmlEscape method instead. + return GetbibleHelper::htmlEscape($var, $this->_charset); + } + + /** + * Returns an array of fields the table can be sorted by + * + * @return array Array containing the field name to sort by as the key and display text as value + */ + protected function getSortFields() + { + return array( + 'a.ordering' => JText::_('JGRID_HEADING_ORDERING'), + 'a.published' => JText::_('JSTATUS'), + 'a.translation' => JText::_('COM_GETBIBLE_TRANSLATION_TRANSLATION_LABEL'), + 'a.abbreviation' => JText::_('COM_GETBIBLE_TRANSLATION_ABBREVIATION_LABEL'), + 'a.language' => JText::_('COM_GETBIBLE_TRANSLATION_LANGUAGE_LABEL'), + 'a.direction' => JText::_('COM_GETBIBLE_TRANSLATION_DIRECTION_LABEL'), + 'a.id' => JText::_('JGRID_HEADING_ID') + ); + } +} diff --git a/admin/views/verse/submitbutton.js b/admin/views/verse/submitbutton.js new file mode 100644 index 0000000..82b9203 --- /dev/null +++ b/admin/views/verse/submitbutton.js @@ -0,0 +1,31 @@ +/*----------------------------------------------------------------------------------| io.vdm.dev |----/ + Vast Development Method +/-------------------------------------------------------------------------------------------------------/ + + @package getBible.net + + @created 3rd December, 2015 + @author Llewellyn van der Merwe + @git Get Bible + @github Get Bible + @support Get Bible + @copyright Copyright (C) 2015. All Rights Reserved + @license GNU/GPL Version 2 or later - http://www.gnu.org/licenses/gpl-2.0.html + +/------------------------------------------------------------------------------------------------------*/ + +Joomla.submitbutton = function(task) +{ + if (task == ''){ + return false; + } else { + var action = task.split('.'); + if (action[1] == 'cancel' || action[1] == 'close' || document.formvalidator.isValid(document.getElementById("adminForm"))){ + Joomla.submitform(task, document.getElementById("adminForm")); + return true; + } else { + alert(Joomla.JText._('verse, some values are not acceptable.','Some values are unacceptable')); + return false; + } + } +} \ No newline at end of file diff --git a/admin/views/verse/tmpl/edit.php b/admin/views/verse/tmpl/edit.php new file mode 100644 index 0000000..9600416 --- /dev/null +++ b/admin/views/verse/tmpl/edit.php @@ -0,0 +1,117 @@ + + @git Get Bible + @github Get Bible + @support Get Bible + @copyright Copyright (C) 2015. All Rights Reserved + @license GNU/GPL Version 2 or later - http://www.gnu.org/licenses/gpl-2.0.html + +/------------------------------------------------------------------------------------------------------*/ + +// No direct access to this file +defined('_JEXEC') or die('Restricted access'); + +JHtml::addIncludePath(JPATH_COMPONENT.'/helpers/html'); +JHtml::_('behavior.formvalidator'); +JHtml::_('formbehavior.chosen', 'select'); +JHtml::_('behavior.keepalive'); +$componentParams = $this->params; // will be removed just use $this->params instead +?> + + diff --git a/admin/views/verse/tmpl/index.html b/admin/views/verse/tmpl/index.html new file mode 100644 index 0000000..fa6d84e --- /dev/null +++ b/admin/views/verse/tmpl/index.html @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/admin/views/verse/view.html.php b/admin/views/verse/view.html.php new file mode 100644 index 0000000..09a6322 --- /dev/null +++ b/admin/views/verse/view.html.php @@ -0,0 +1,130 @@ + + @git Get Bible + @github Get Bible + @support Get Bible + @copyright Copyright (C) 2015. All Rights Reserved + @license GNU/GPL Version 2 or later - http://www.gnu.org/licenses/gpl-2.0.html + +/------------------------------------------------------------------------------------------------------*/ + +// No direct access to this file +defined('_JEXEC') or die('Restricted access'); + +use Joomla\CMS\MVC\View\HtmlView; + +/** + * Verse Html View class + */ +class GetbibleViewVerse extends HtmlView +{ + /** + * display method of View + * @return void + */ + public function display($tpl = null) + { + // set params + $this->params = JComponentHelper::getParams('com_getbible'); + // Assign the variables + $this->form = $this->get('Form'); + $this->item = $this->get('Item'); + $this->script = $this->get('Script'); + $this->state = $this->get('State'); + // get action permissions + $this->canDo = GetbibleHelper::getActions('verse', $this->item); + // get input + $jinput = JFactory::getApplication()->input; + $this->ref = $jinput->get('ref', 0, 'word'); + $this->refid = $jinput->get('refid', 0, 'int'); + $return = $jinput->get('return', null, 'base64'); + // set the referral string + $this->referral = ''; + if ($this->refid && $this->ref) + { + // return to the item that referred to this item + $this->referral = '&ref=' . (string)$this->ref . '&refid=' . (int)$this->refid; + } + elseif($this->ref) + { + // return to the list view that referred to this item + $this->referral = '&ref=' . (string)$this->ref; + } + // check return value + if (!is_null($return)) + { + // add the return value + $this->referral .= '&return=' . (string)$return; + } + + // Set the toolbar + $this->addToolBar(); + + // Check for errors. + if (count($errors = $this->get('Errors'))) + { + throw new Exception(implode("\n", $errors), 500); + } + + // Display the template + parent::display($tpl); + + // Set the document + $this->setDocument(); + } + + + /** + * Setting the toolbar + */ + protected function addToolBar() + { + JFactory::getApplication()->input->set('hidemainmenu', true); + JToolBarHelper::title(JText::_('COM_GETBIBLE_VERSE_READONLY'), 'verse'); + JToolBarHelper::cancel('verse.cancel', 'JTOOLBAR_CLOSE'); + } + + /** + * Escapes a value for output in a view script. + * + * @param mixed $var The output to escape. + * + * @return mixed The escaped value. + */ + public function escape($var) + { + if(strlen($var) > 30) + { + // use the helper htmlEscape method instead and shorten the string + return GetbibleHelper::htmlEscape($var, $this->_charset, true, 30); + } + // use the helper htmlEscape method instead. + return GetbibleHelper::htmlEscape($var, $this->_charset); + } + + /** + * Method to set up the document properties + * + * @return void + */ + protected function setDocument() + { + $isNew = ($this->item->id < 1); + if (!isset($this->document)) + { + $this->document = JFactory::getDocument(); + } + $this->document->setTitle(JText::_($isNew ? 'COM_GETBIBLE_VERSE_NEW' : 'COM_GETBIBLE_VERSE_EDIT')); + $this->document->addStyleSheet(JURI::root() . "administrator/components/com_getbible/assets/css/verse.css", (GetbibleHelper::jVersion()->isCompatible('3.8.0')) ? array('version' => 'auto') : 'text/css'); + $this->document->addScript(JURI::root() . $this->script, (GetbibleHelper::jVersion()->isCompatible('3.8.0')) ? array('version' => 'auto') : 'text/javascript'); + $this->document->addScript(JURI::root() . "administrator/components/com_getbible/views/verse/submitbutton.js", (GetbibleHelper::jVersion()->isCompatible('3.8.0')) ? array('version' => 'auto') : 'text/javascript'); + JText::script('view not acceptable. Error'); + } +} diff --git a/admin/views/verses/index.html b/admin/views/verses/index.html new file mode 100644 index 0000000..fa6d84e --- /dev/null +++ b/admin/views/verses/index.html @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/admin/views/verses/tmpl/default.php b/admin/views/verses/tmpl/default.php new file mode 100644 index 0000000..bb29d6c --- /dev/null +++ b/admin/views/verses/tmpl/default.php @@ -0,0 +1,73 @@ + + @git Get Bible + @github Get Bible + @support Get Bible + @copyright Copyright (C) 2015. All Rights Reserved + @license GNU/GPL Version 2 or later - http://www.gnu.org/licenses/gpl-2.0.html + +/------------------------------------------------------------------------------------------------------*/ + +// No direct access to this file +defined('_JEXEC') or die('Restricted access'); + +JHtml::_('behavior.multiselect'); +JHtml::_('dropdown.init'); +JHtml::_('formbehavior.chosen', '.multipleAccessLevels', null, array('placeholder_text_multiple' => '- ' . JText::_('COM_GETBIBLE_FILTER_SELECT_ACCESS') . ' -')); +JHtml::_('formbehavior.chosen', 'select'); +if ($this->saveOrder) +{ + $saveOrderingUrl = 'index.php?option=com_getbible&task=verses.saveOrderAjax&tmpl=component'; + JHtml::_('sortablelist.sortable', 'verseList', 'adminForm', strtolower($this->listDirn), $saveOrderingUrl); +} +?> +
+sidebar)): ?> +
+ sidebar; ?> +
+
+ +
+ + $this)); +?> +items)): ?> +
+ +
+ + + loadTemplate('head');?> + loadTemplate('foot');?> + loadTemplate('body');?> +
+ + canCreate && $this->canEdit) : ?> + JText::_('COM_GETBIBLE_VERSES_BATCH_OPTIONS'), + 'footer' => $this->loadTemplate('batch_footer') + ), + $this->loadTemplate('batch_body') + ); ?> + + +
+ + + + diff --git a/admin/views/verses/tmpl/default_batch_body.php b/admin/views/verses/tmpl/default_batch_body.php new file mode 100644 index 0000000..7cc9e9e --- /dev/null +++ b/admin/views/verses/tmpl/default_batch_body.php @@ -0,0 +1,24 @@ + + @git Get Bible + @github Get Bible + @support Get Bible + @copyright Copyright (C) 2015. All Rights Reserved + @license GNU/GPL Version 2 or later - http://www.gnu.org/licenses/gpl-2.0.html + +/------------------------------------------------------------------------------------------------------*/ + +// No direct access to this file +defined('_JEXEC') or die('Restricted access'); + +?> + +

+batchDisplay; ?> \ No newline at end of file diff --git a/admin/views/verses/tmpl/default_batch_footer.php b/admin/views/verses/tmpl/default_batch_footer.php new file mode 100644 index 0000000..aa9022b --- /dev/null +++ b/admin/views/verses/tmpl/default_batch_footer.php @@ -0,0 +1,29 @@ + + @git Get Bible + @github Get Bible + @support Get Bible + @copyright Copyright (C) 2015. All Rights Reserved + @license GNU/GPL Version 2 or later - http://www.gnu.org/licenses/gpl-2.0.html + +/------------------------------------------------------------------------------------------------------*/ + +// No direct access to this file +defined('_JEXEC') or die('Restricted access'); + +?> + + + + \ No newline at end of file diff --git a/admin/views/verses/tmpl/default_body.php b/admin/views/verses/tmpl/default_body.php new file mode 100644 index 0000000..7574671 --- /dev/null +++ b/admin/views/verses/tmpl/default_body.php @@ -0,0 +1,112 @@ + + @git Get Bible + @github Get Bible + @support Get Bible + @copyright Copyright (C) 2015. All Rights Reserved + @license GNU/GPL Version 2 or later - http://www.gnu.org/licenses/gpl-2.0.html + +/------------------------------------------------------------------------------------------------------*/ + +// No direct access to this file +defined('_JEXEC') or die('Restricted access'); + +$edit = "index.php?option=com_getbible&view=verses&task=verse.edit"; + +?> +items as $i => $item): ?> + user->authorise('core.manage', 'com_checkin') || $item->checked_out == $this->user->id || $item->checked_out == 0; + $userChkOut = JFactory::getUser($item->checked_out); + $canDo = GetbibleHelper::getActions('verse',$item,'verses'); + ?> + + + get('verse.edit.state')): ?> + saveOrder) + { + $iconClass = ' inactive tip-top" hasTooltip" title="' . JHtml::tooltipText('JORDERINGDISABLED'); + } + ?> + + + + saveOrder) : ?> + + + + ⋮ + + + + get('verse.edit')): ?> + checked_out) : ?> + + id); ?> + + □ + + + id); ?> + + + □ + + + +
+ get('verse.edit')): ?> + escape($item->book_nr); ?> + checked_out): ?> + name, $item->checked_out_time, 'verses.', $canCheckin); ?> + + + escape($item->book_nr); ?> + +
+ + + escape($item->chapter); ?> + + + escape($item->verse); ?> + + +
+ user->authorise('translation.edit', 'com_getbible.translation.' . (int) $item->abbreviation_id)): ?> + escape($item->abbreviation_translation); ?> + + escape($item->abbreviation_translation); ?> + +
+ + + get('verse.edit.state')) : ?> + checked_out) : ?> + + published, $i, 'verses.', true, 'cb'); ?> + + published, $i, 'verses.', false, 'cb'); ?> + + + published, $i, 'verses.', true, 'cb'); ?> + + + published, $i, 'verses.', false, 'cb'); ?> + + + + id; ?> + + + \ No newline at end of file diff --git a/admin/views/verses/tmpl/default_foot.php b/admin/views/verses/tmpl/default_foot.php new file mode 100644 index 0000000..290760a --- /dev/null +++ b/admin/views/verses/tmpl/default_foot.php @@ -0,0 +1,24 @@ + + @git Get Bible + @github Get Bible + @support Get Bible + @copyright Copyright (C) 2015. All Rights Reserved + @license GNU/GPL Version 2 or later - http://www.gnu.org/licenses/gpl-2.0.html + +/------------------------------------------------------------------------------------------------------*/ + +// No direct access to this file +defined('_JEXEC') or die('Restricted access'); + +?> + + pagination->getListFooter(); ?> + \ No newline at end of file diff --git a/admin/views/verses/tmpl/default_head.php b/admin/views/verses/tmpl/default_head.php new file mode 100644 index 0000000..fe2a643 --- /dev/null +++ b/admin/views/verses/tmpl/default_head.php @@ -0,0 +1,62 @@ + + @git Get Bible + @github Get Bible + @support Get Bible + @copyright Copyright (C) 2015. All Rights Reserved + @license GNU/GPL Version 2 or later - http://www.gnu.org/licenses/gpl-2.0.html + +/------------------------------------------------------------------------------------------------------*/ + +// No direct access to this file +defined('_JEXEC') or die('Restricted access'); + +?> + + canEdit&& $this->canState): ?> + + listDirn, $this->listOrder, null, 'asc', 'JGRID_HEADING_ORDERING', 'icon-menu-2'); ?> + + + + + + + ▾ + + + ■ + + + + listDirn, $this->listOrder); ?> + + + listDirn, $this->listOrder); ?> + + + listDirn, $this->listOrder); ?> + + + listDirn, $this->listOrder); ?> + + canState): ?> + + listDirn, $this->listOrder); ?> + + + + + + + + listDirn, $this->listOrder); ?> + + \ No newline at end of file diff --git a/admin/views/verses/tmpl/default_toolbar.php b/admin/views/verses/tmpl/default_toolbar.php new file mode 100644 index 0000000..cc28bb4 --- /dev/null +++ b/admin/views/verses/tmpl/default_toolbar.php @@ -0,0 +1,51 @@ + + @git Get Bible + @github Get Bible + @support Get Bible + @copyright Copyright (C) 2015. All Rights Reserved + @license GNU/GPL Version 2 or later - http://www.gnu.org/licenses/gpl-2.0.html + +/------------------------------------------------------------------------------------------------------*/ + +// No direct access to this file +defined('_JEXEC') or die('Restricted access'); + +?> +
+ +
+ + +
+
+ + pagination->getLimitBox(); ?> +
+
+ + +
+
+ + +
+
+
\ No newline at end of file diff --git a/admin/views/verses/tmpl/index.html b/admin/views/verses/tmpl/index.html new file mode 100644 index 0000000..fa6d84e --- /dev/null +++ b/admin/views/verses/tmpl/index.html @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/admin/views/verses/view.html.php b/admin/views/verses/view.html.php new file mode 100644 index 0000000..c55b187 --- /dev/null +++ b/admin/views/verses/view.html.php @@ -0,0 +1,310 @@ + + @git Get Bible + @github Get Bible + @support Get Bible + @copyright Copyright (C) 2015. All Rights Reserved + @license GNU/GPL Version 2 or later - http://www.gnu.org/licenses/gpl-2.0.html + +/------------------------------------------------------------------------------------------------------*/ + +// No direct access to this file +defined('_JEXEC') or die('Restricted access'); + +use Joomla\CMS\MVC\View\HtmlView; + +/** + * Getbible Html View class for the Verses + */ +class GetbibleViewVerses extends HtmlView +{ + /** + * Verses view display method + * @return void + */ + function display($tpl = null) + { + if ($this->getLayout() !== 'modal') + { + // Include helper submenu + GetbibleHelper::addSubmenu('verses'); + } + + // Assign data to the view + $this->items = $this->get('Items'); + $this->pagination = $this->get('Pagination'); + $this->state = $this->get('State'); + $this->user = JFactory::getUser(); + // Load the filter form from xml. + $this->filterForm = $this->get('FilterForm'); + // Load the active filters. + $this->activeFilters = $this->get('ActiveFilters'); + // Add the list ordering clause. + $this->listOrder = $this->escape($this->state->get('list.ordering', 'a.id')); + $this->listDirn = $this->escape($this->state->get('list.direction', 'DESC')); + $this->saveOrder = $this->listOrder == 'a.ordering'; + // set the return here value + $this->return_here = urlencode(base64_encode((string) JUri::getInstance())); + // get global action permissions + $this->canDo = GetbibleHelper::getActions('verse'); + $this->canEdit = $this->canDo->get('verse.edit'); + $this->canState = $this->canDo->get('verse.edit.state'); + $this->canCreate = $this->canDo->get('verse.create'); + $this->canDelete = $this->canDo->get('verse.delete'); + $this->canBatch = $this->canDo->get('core.batch'); + + // We don't need toolbar in the modal window. + if ($this->getLayout() !== 'modal') + { + $this->addToolbar(); + $this->sidebar = JHtmlSidebar::render(); + // load the batch html + if ($this->canCreate && $this->canEdit && $this->canState) + { + $this->batchDisplay = JHtmlBatch_::render(); + } + } + + // Check for errors. + if (count($errors = $this->get('Errors'))) + { + throw new Exception(implode("\n", $errors), 500); + } + + // Display the template + parent::display($tpl); + + // Set the document + $this->setDocument(); + } + + /** + * Setting the toolbar + */ + protected function addToolBar() + { + JToolBarHelper::title(JText::_('COM_GETBIBLE_VERSES'), 'generic'); + JHtmlSidebar::setAction('index.php?option=com_getbible&view=verses'); + JFormHelper::addFieldPath(JPATH_COMPONENT . '/models/fields'); + + if ($this->canCreate) + { + JToolBarHelper::addNew('verse.add'); + } + + // Only load if there are items + if (GetbibleHelper::checkArray($this->items)) + { + if ($this->canEdit) + { + JToolBarHelper::editList('verse.edit'); + } + + if ($this->canState) + { + JToolBarHelper::publishList('verses.publish'); + JToolBarHelper::unpublishList('verses.unpublish'); + JToolBarHelper::archiveList('verses.archive'); + + if ($this->canDo->get('core.admin')) + { + JToolBarHelper::checkin('verses.checkin'); + } + } + + // Add a batch button + if ($this->canBatch && $this->canCreate && $this->canEdit && $this->canState) + { + // Get the toolbar object instance + $bar = JToolBar::getInstance('toolbar'); + // set the batch button name + $title = JText::_('JTOOLBAR_BATCH'); + // Instantiate a new JLayoutFile instance and render the batch button + $layout = new JLayoutFile('joomla.toolbar.batch'); + // add the button to the page + $dhtml = $layout->render(array('title' => $title)); + $bar->appendButton('Custom', $dhtml, 'batch'); + } + + if ($this->state->get('filter.published') == -2 && ($this->canState && $this->canDelete)) + { + JToolbarHelper::deleteList('', 'verses.delete', 'JTOOLBAR_EMPTY_TRASH'); + } + elseif ($this->canState && $this->canDelete) + { + JToolbarHelper::trash('verses.trash'); + } + } + + // set help url for this view if found + $this->help_url = GetbibleHelper::getHelpUrl('verses'); + if (GetbibleHelper::checkString($this->help_url)) + { + JToolbarHelper::help('COM_GETBIBLE_HELP_MANAGER', false, $this->help_url); + } + + // add the options comp button + if ($this->canDo->get('core.admin') || $this->canDo->get('core.options')) + { + JToolBarHelper::preferences('com_getbible'); + } + + // Only load published batch if state and batch is allowed + if ($this->canState && $this->canBatch) + { + JHtmlBatch_::addListSelection( + JText::_('COM_GETBIBLE_KEEP_ORIGINAL_STATE'), + 'batch[published]', + JHtml::_('select.options', JHtml::_('jgrid.publishedOptions', array('all' => false)), 'value', 'text', '', true) + ); + } + + // Only load access batch if create, edit and batch is allowed + if ($this->canBatch && $this->canCreate && $this->canEdit) + { + JHtmlBatch_::addListSelection( + JText::_('COM_GETBIBLE_KEEP_ORIGINAL_ACCESS'), + 'batch[access]', + JHtml::_('select.options', JHtml::_('access.assetgroups'), 'value', 'text') + ); + } + + // Only load Book Nr batch if create, edit, and batch is allowed + if ($this->canBatch && $this->canCreate && $this->canEdit) + { + // Set Book Nr Selection + $this->book_nrOptions = JFormHelper::loadFieldType('versesfilterbooknr')->options; + // We do some sanitation for Book Nr filter + if (GetbibleHelper::checkArray($this->book_nrOptions) && + isset($this->book_nrOptions[0]->value) && + !GetbibleHelper::checkString($this->book_nrOptions[0]->value)) + { + unset($this->book_nrOptions[0]); + } + // Book Nr Batch Selection + JHtmlBatch_::addListSelection( + '- Keep Original '.JText::_('COM_GETBIBLE_VERSE_BOOK_NR_LABEL').' -', + 'batch[book_nr]', + JHtml::_('select.options', $this->book_nrOptions, 'value', 'text') + ); + } + + // Only load Chapter batch if create, edit, and batch is allowed + if ($this->canBatch && $this->canCreate && $this->canEdit) + { + // Set Chapter Selection + $this->chapterOptions = JFormHelper::loadFieldType('versesfilterchapter')->options; + // We do some sanitation for Chapter filter + if (GetbibleHelper::checkArray($this->chapterOptions) && + isset($this->chapterOptions[0]->value) && + !GetbibleHelper::checkString($this->chapterOptions[0]->value)) + { + unset($this->chapterOptions[0]); + } + // Chapter Batch Selection + JHtmlBatch_::addListSelection( + '- Keep Original '.JText::_('COM_GETBIBLE_VERSE_CHAPTER_LABEL').' -', + 'batch[chapter]', + JHtml::_('select.options', $this->chapterOptions, 'value', 'text') + ); + } + + // Only load Verse batch if create, edit, and batch is allowed + if ($this->canBatch && $this->canCreate && $this->canEdit) + { + // Set Verse Selection + $this->verseOptions = JFormHelper::loadFieldType('versesfilterverse')->options; + // We do some sanitation for Verse filter + if (GetbibleHelper::checkArray($this->verseOptions) && + isset($this->verseOptions[0]->value) && + !GetbibleHelper::checkString($this->verseOptions[0]->value)) + { + unset($this->verseOptions[0]); + } + // Verse Batch Selection + JHtmlBatch_::addListSelection( + '- Keep Original '.JText::_('COM_GETBIBLE_VERSE_VERSE_LABEL').' -', + 'batch[verse]', + JHtml::_('select.options', $this->verseOptions, 'value', 'text') + ); + } + + // Only load Abbreviation Translation batch if create, edit, and batch is allowed + if ($this->canBatch && $this->canCreate && $this->canEdit) + { + // Set Abbreviation Translation Selection + $this->abbreviationTranslationOptions = JFormHelper::loadFieldType('Translations')->options; + // We do some sanitation for Abbreviation Translation filter + if (GetbibleHelper::checkArray($this->abbreviationTranslationOptions) && + isset($this->abbreviationTranslationOptions[0]->value) && + !GetbibleHelper::checkString($this->abbreviationTranslationOptions[0]->value)) + { + unset($this->abbreviationTranslationOptions[0]); + } + // Abbreviation Translation Batch Selection + JHtmlBatch_::addListSelection( + '- Keep Original '.JText::_('COM_GETBIBLE_VERSE_ABBREVIATION_LABEL').' -', + 'batch[abbreviation]', + JHtml::_('select.options', $this->abbreviationTranslationOptions, 'value', 'text') + ); + } + } + + /** + * Method to set up the document properties + * + * @return void + */ + protected function setDocument() + { + if (!isset($this->document)) + { + $this->document = JFactory::getDocument(); + } + $this->document->setTitle(JText::_('COM_GETBIBLE_VERSES')); + $this->document->addStyleSheet(JURI::root() . "administrator/components/com_getbible/assets/css/verses.css", (GetbibleHelper::jVersion()->isCompatible('3.8.0')) ? array('version' => 'auto') : 'text/css'); + } + + /** + * Escapes a value for output in a view script. + * + * @param mixed $var The output to escape. + * + * @return mixed The escaped value. + */ + public function escape($var) + { + if(strlen($var) > 50) + { + // use the helper htmlEscape method instead and shorten the string + return GetbibleHelper::htmlEscape($var, $this->_charset, true); + } + // use the helper htmlEscape method instead. + return GetbibleHelper::htmlEscape($var, $this->_charset); + } + + /** + * Returns an array of fields the table can be sorted by + * + * @return array Array containing the field name to sort by as the key and display text as value + */ + protected function getSortFields() + { + return array( + 'a.ordering' => JText::_('JGRID_HEADING_ORDERING'), + 'a.published' => JText::_('JSTATUS'), + 'a.book_nr' => JText::_('COM_GETBIBLE_VERSE_BOOK_NR_LABEL'), + 'a.chapter' => JText::_('COM_GETBIBLE_VERSE_CHAPTER_LABEL'), + 'a.verse' => JText::_('COM_GETBIBLE_VERSE_VERSE_LABEL'), + 'g.translation' => JText::_('COM_GETBIBLE_VERSE_ABBREVIATION_LABEL'), + 'a.id' => JText::_('JGRID_HEADING_ID') + ); + } +} diff --git a/getbible.xml b/getbible.xml new file mode 100644 index 0000000..bec23c9 --- /dev/null +++ b/getbible.xml @@ -0,0 +1,120 @@ + + + COM_GETBIBLE + 26th July, 2023 + Llewellyn van der Merwe + joomla@vdm.io + https://getbible.net + Copyright (C) 2015. All Rights Reserved + GNU/GPL Version 2 or later - http://www.gnu.org/licenses/gpl-2.0.html + 2.0.1 + Get Bible (v.2.0.1) +
+

Welcome to the next level of scripture engagement - The Bible for Joomla! Our purpose is to bring the Word of God to every person, in their native language, entirely free. This isn't just a typical extension; it's a groundbreaking tool developed to span language divides and deliver a rich, customizable Bible study experience to users worldwide. + +With an impressive array of 80 translations, our Joomla extension allows people from all corners of the globe to read, comprehend, and meditate on the Holy Scriptures in their preferred language. Moreover, we offer the unique opportunity for individuals to host the Bible on their own website, further extending the reach of the Word. + +We've integrated robust features such as note-taking, tagging, and a search function, to enhance your interaction with the Scriptures. This allows users to immerse themselves in the text, crafting a personal journey through the Bible that can be revisited in future sessions. Furthermore, our innovative linker system assigns each visitor a unique identifier (GUID) - no login required. This means you can create notes, select favorite verses, and even share sessions, while maintaining control over your personalized content. + +A distinctive feature of our application is the integration with OpenAI. This advanced capability allows website owners to create custom prompts to interact with OpenAI using text from any translation. This function allows you to ask questions, gain clarity, and deepen your understanding of the Scriptures in an engaging and user-friendly manner. + +In essence, The Bible for Joomla is designed to transform how the Word of God is shared, studied, and comprehended. Its comprehensive features, combined with a user-friendly interface, make it an essential tool for individuals, churches, and website owners alike. Join us on this journey of faith as we make the wisdom and guidance of the Scriptures accessible to all, one verse, one language, and one website at a time.

+

Created by Llewellyn van der Merwe
Development started 3rd December, 2015

+ ]]>
+ + + + + sql/install.mysql.utf8.sql + + + + + + + sql/uninstall.mysql.utf8.sql + + + + + script.php + + + index.html + js + css + images + nouislider + datatable + uikit-v3 + + + + + + sql/updates/mysql/ + + + + + controller.php + index.html + router.php + getbible.php + router.php + assets + helpers + controllers + models + views + layouts + + + + language/en-GB/en-GB.com_getbible.ini + language/en-GB/en-GB.com_getbible.sys.ini + + + + COM_GETBIBLE_MENU + + + COM_GETBIBLE_MENU_LINKERS + COM_GETBIBLE_MENU_NOTES + COM_GETBIBLE_MENU_TAGGED_VERSES + COM_GETBIBLE_MENU_PROMPTS + COM_GETBIBLE_MENU_OPEN_AI_RESPONSES + COM_GETBIBLE_MENU_TAGS + COM_GETBIBLE_MENU_TRANSLATIONS + COM_GETBIBLE_MENU_BOOKS + COM_GETBIBLE_MENU_CHAPTERS + COM_GETBIBLE_MENU_VERSES + + + access.xml + config.xml + controller.php + index.html + getbible.php + README.txt + assets + controllers + helpers + models + sql + tables + views + layouts + + + + language/en-GB/en-GB.com_getbible.ini + language/en-GB/en-GB.com_getbible.sys.ini + + + + + https://git.vdm.dev/getBible/joomla-component/raw/branch/master/update_server.xml + +
\ No newline at end of file diff --git a/index.html b/index.html new file mode 100644 index 0000000..fa6d84e --- /dev/null +++ b/index.html @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/libraries/jcb_powers/.htaccess b/libraries/jcb_powers/.htaccess new file mode 100644 index 0000000..9afb1a1 --- /dev/null +++ b/libraries/jcb_powers/.htaccess @@ -0,0 +1,9 @@ +# Apache 2.4+ + + Require all denied + + +# Apache 2.0-2.2 + + Deny from all + diff --git a/libraries/jcb_powers/VDM.Joomla.GetBible/index.html b/libraries/jcb_powers/VDM.Joomla.GetBible/index.html new file mode 100644 index 0000000..fa6d84e --- /dev/null +++ b/libraries/jcb_powers/VDM.Joomla.GetBible/index.html @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/libraries/jcb_powers/VDM.Joomla.GetBible/src/AI.php b/libraries/jcb_powers/VDM.Joomla.GetBible/src/AI.php new file mode 100644 index 0000000..927d809 --- /dev/null +++ b/libraries/jcb_powers/VDM.Joomla.GetBible/src/AI.php @@ -0,0 +1,104 @@ + + * @git GetBible + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ + +namespace VDM\Joomla\GetBible; + + +use VDM\Joomla\GetBible\Openai\Config; +use VDM\Joomla\GetBible\Data\Response; +use VDM\Joomla\GetBible\AI\Engineer; + + +/** + * The GetBible AI + * + * @since 2.0.1 + */ +final class AI +{ + /** + * The Config class + * + * @var Config + * @since 2.0.1 + */ + protected Config $config; + + /** + * The Response class + * + * @var Response + * @since 2.0.1 + */ + protected Response $response; + + /** + * The Engineer class + * + * @var Engineer + * @since 2.0.1 + */ + protected Engineer $engineer; + + /** + * Constructor + * + * @param Config $config The response object. + * @param Response $response The response object. + * @param Engineer $engineer The engineer object. + * + * @since 2.0.1 + */ + public function __construct(Config $config, Response $response, Engineer $engineer) + { + $this->config = $config; + $this->response = $response; + $this->engineer = $engineer; + } + + /** + * Get the Open AI response + * + * @return array|null Array of response messages + * @since 2.0.1 + */ + public function get(): ?array + { + // If Open AI isn't enabled in the config, we return null right away. + if (!$this->config->get('enable_open_ai')) + { + return null; + } + + // If we have enough responses already, return them. + $response = $this->response->get(); + if ($this->response->isEnough()) + { + return $response; + } + + // If there is no existing response and engineer has any response, return it. + if (empty($response)) + { + return $this->engineer->get(); + } + + // If there are existing responses, we append the first response from the engineer (if any). + $_response = $this->engineer->get(); + if (!empty($_response)) + { + $response[] = $_response[0]; + } + + return $response; + } +} + diff --git a/libraries/jcb_powers/VDM.Joomla.GetBible/src/AI/Engineer.php b/libraries/jcb_powers/VDM.Joomla.GetBible/src/AI/Engineer.php new file mode 100644 index 0000000..4aa4dbb --- /dev/null +++ b/libraries/jcb_powers/VDM.Joomla.GetBible/src/AI/Engineer.php @@ -0,0 +1,308 @@ + + * @git GetBible + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ + +namespace VDM\Joomla\GetBible\AI; + + +use VDM\Joomla\GetBible\Data\Scripture; +use VDM\Joomla\GetBible\Data\Prompt; +use VDM\Joomla\GetBible\Data\Placeholders; +use VDM\Joomla\Openai\Chat; +use VDM\Joomla\GetBible\Database\Insert; + + +/** + * The GetBible AI Engineer + * + * @since 2.0.1 + */ +final class Engineer +{ + /** + * The Scripture class + * + * @var Scripture + * @since 2.0.1 + */ + protected Scripture $scripture; + + /** + * The Prompt class + * + * @var Prompt + * @since 2.0.1 + */ + protected Prompt $prompt; + + /** + * The Placeholders class + * + * @var Placeholders + * @since 2.0.1 + */ + protected Placeholders $placeholders; + + /** + * The Chat class + * + * @var Chat + * @since 2.0.1 + */ + protected Chat $chat; + + /** + * The Insert class + * + * @var Insert + * @since 2.0.1 + */ + protected Insert $insert; + + /** + * The request messages + * + * @var array|null + * @since 2.0.1 + */ + protected ?array $messages = null; + + /** + * The response object + * + * @var object|null + * @since 2.0.1 + */ + protected ?object $response = null; + + /** + * Constructor + * + * @param Scripture $scripture The scripture object. + * @param Prompt $prompt The prompt object. + * @param Placeholders $placeholders The placeholders object. + * @param Chat $chat The chat object. + * @param Insert $insert The insert object. + * + * @since 2.0.1 + */ + public function __construct( + Scripture $scripture, + Prompt $prompt, + Placeholders $placeholders, + Chat $chat, + Insert $insert) + { + $this->scripture = $scripture; + $this->prompt = $prompt; + $this->placeholders = $placeholders; + $this->chat = $chat; + $this->insert = $insert; + } + + /** + * Return the current data state + * + * @return array|null True on success + * @since 2.0.1 + */ + public function get(): ?array + { + if ($this->getResponse() && $this->modelMessages() && $this->modelResponse() + && $this->saveResponse() && $this->saveMessages()) + { + // add this response's messages + $this->response->messages = $this->messages ?? ''; + + return [ + $this->response + ]; + } + + return null; + } + + /** + * Save the messages + * + * @return bool True on success + * @since 2.0.1 + */ + private function saveMessages(): bool + { + return $this->insert->items($this->messages, 'open_ai_message'); + } + + /** + * Save the response + * + * @return bool True on success + * @since 2.0.1 + */ + private function saveResponse(): bool + { + return $this->insert->item($this->response, 'open_ai_response'); + } + + /** + * Prep the response data + * + * @return bool True on success + * @since 2.0.1 + */ + private function modelResponse(): bool + { + if ($this->response) + { + $data = new \stdClass(); + // Bible link + $data->abbreviation = $this->scripture->get('translation_abbreviation', ''); + $data->language = $this->scripture->get('translation_language', ''); + $data->lcsh = $this->scripture->get('translation_lcsh', ''); + $data->book = $this->scripture->get('book_number', ''); + $data->chapter = $this->scripture->get('chapter_number', ''); + $data->verse = $this->scripture->get('verse_number', ''); + $data->word = $this->scripture->get('selected_word_number', ''); + $data->selected_word = $this->scripture->get('selected_word_text', ''); + // Prompt data + $data->prompt = $this->prompt->getGuid(); + $data->model = $this->prompt->getModel(); + $data->max_tokens = $this->prompt->getMaxTokens(); + $data->temperature = $this->prompt->getTemperature(); + $data->top_p = $this->prompt->getTopP(); + $data->presence_penalty = $this->prompt->getPresencePenalty(); + $data->frequency_penalty = $this->prompt->getFrequencyPenalty(); + $data->n = ''; + // Response data + $data->response_id = $this->response->id ?? ''; + $data->response_object = $this->response->object ?? ''; + $data->response_model = $this->response->model ?? ''; + $data->response_created = $this->response->created ?? ''; + $data->prompt_tokens = $this->response->usage->prompt_tokens ?? ''; + $data->completion_tokens = $this->response->usage->completion_tokens ?? ''; + $data->total_tokens = $this->response->usage->total_tokens ?? ''; + + $this->response = $data; + + return true; + } + + return false; + } + + /** + * Prep the messages + * + * @return bool True on success + * @since 2.0.1 + */ + private function modelMessages(): bool + { + if (isset($this->response->choices) && + is_array($this->response->choices) && + $this->response->choices !== []) + { + // set some global keys + $open_ai_response = $this->response->id ?? ''; + $prompt = $this->prompt->getGuid(); + // if Persistently we archive this response + $cache_type = $this->prompt->getCacheBehaviour(); + $state = ($cache_type == 0) ? 2 : 1; + + // update the system messages + $index = (int) 0 - count($this->messages); + foreach ($this->messages as $n => &$message) + { + $message->prompt = $prompt; + $message->open_ai_response = $open_ai_response; + $message->source = 1; // prompt as source + $message->index = $index; + $message->published = $state; + + $index++; + } + + // now add the response messages + foreach ($this->response->choices as $choice) + { + $choice->message->prompt = $prompt; + $choice->message->open_ai_response = $open_ai_response; + $choice->message->source = 2; // open AI as source + $choice->message->index = $choice->index; + $choice->message->name = 'getBible-Open-AI'; + $choice->message->published = $state; + + $this->messages[] = $choice->message; + } + + // we remove it from the response object + unset($this->response->choices); + + return true; + } + + return false; + } + + /** + * Get the Open AI response + * + * @return bool True on success + * @since 2.0.1 + */ + private function getResponse(): bool + { + if (($this->messages = $this->getMessages()) !== null) + { + $this->response = $this->chat->create( + $this->prompt->getModel(), + $this->messages, + $this->prompt->getMaxTokens(), + $this->prompt->getTemperature(), + $this->prompt->getTopP(), + $this->prompt->getN(), + null, + null, + $this->prompt->getPresencePenalty(), + $this->prompt->getFrequencyPenalty(), + null + ); + + return true; + } + + return false; + } + + /** + * Get the ready to use prompt messages + * + * @return array|null Array of prompt messages + * @since 2.0.1 + */ + private function getMessages(): ?array + { + if (($placeholders = $this->placeholders->get()) !== null && + ($messages = $this->prompt->getMessages()) !== null) + { + return array_map(function ($message) use($placeholders) { + $message->content = str_replace( + array_keys($placeholders), + array_values($placeholders), + $message->content + ); + return $message; + }, $messages); + } + + return null; + } +} + diff --git a/libraries/jcb_powers/VDM.Joomla.GetBible/src/AI/index.html b/libraries/jcb_powers/VDM.Joomla.GetBible/src/AI/index.html new file mode 100644 index 0000000..fa6d84e --- /dev/null +++ b/libraries/jcb_powers/VDM.Joomla.GetBible/src/AI/index.html @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/libraries/jcb_powers/VDM.Joomla.GetBible/src/Abstraction/Api.php b/libraries/jcb_powers/VDM.Joomla.GetBible/src/Abstraction/Api.php new file mode 100644 index 0000000..c2b23ca --- /dev/null +++ b/libraries/jcb_powers/VDM.Joomla.GetBible/src/Abstraction/Api.php @@ -0,0 +1,67 @@ + + * @git GetBible + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ + +namespace VDM\Joomla\GetBible\Abstraction; + + +use VDM\Joomla\GetBible\Utilities\Http; +use VDM\Joomla\GetBible\Utilities\Uri; +use VDM\Joomla\GetBible\Utilities\Response; + + +/** + * The GetBible Api + * + * @since 2.0.1 + */ +abstract class Api +{ + /** + * The Http class + * + * @var Http + * @since 2.0.1 + */ + protected Http $http; + + /** + * The Uri class + * + * @var Uri + * @since 2.0.1 + */ + protected Uri $uri; + + /** + * The Response class + * + * @var Response + * @since 2.0.1 + */ + protected Response $response; + + /** + * Constructor. + * + * @param Http $http The http class. + * @param Uri $uri The uri class. + * @param Response $response The response class. + * + * @since 2.0.1 + **/ + public function __construct(Http $http, Uri $uri, Response $response) + { + $this->http = $http; + $this->uri = $uri; + $this->response = $response; + } +} + diff --git a/libraries/jcb_powers/VDM.Joomla.GetBible/src/Abstraction/index.html b/libraries/jcb_powers/VDM.Joomla.GetBible/src/Abstraction/index.html new file mode 100644 index 0000000..fa6d84e --- /dev/null +++ b/libraries/jcb_powers/VDM.Joomla.GetBible/src/Abstraction/index.html @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/libraries/jcb_powers/VDM.Joomla.GetBible/src/Api/Books.php b/libraries/jcb_powers/VDM.Joomla.GetBible/src/Api/Books.php new file mode 100644 index 0000000..12a36ca --- /dev/null +++ b/libraries/jcb_powers/VDM.Joomla.GetBible/src/Api/Books.php @@ -0,0 +1,96 @@ + + * @git GetBible + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ + +namespace VDM\Joomla\GetBible\Api; + + +use VDM\Joomla\GetBible\Abstraction\Api; + + +/** + * The GetBible Books + * + * @since 2.0.1 + */ +final class Books extends Api +{ + /** + * Get the books in a translation + * + * @param string $translation The translation. + * + * @return object|null The response object or null if an error occurs. + * @since 2.0.1 + */ + public function get(string $translation = 'kjv'): ?object + { + return $this->response->get( + $this->http->get( + $this->uri->get($translation . '.json') + ) + ); + } + + /** + * List the books in a translation + * + * @param string $translation The translation. + * + * @return object|null The response object or null if an error occurs. + * @since 2.0.1 + */ + public function list(string $translation = 'kjv'): ?object + { + return $this->response->get( + $this->http->get( + $this->uri->get($translation . '/books.json') + ) + ); + } + + /** + * List the books checksums in a translation + * + * @param string $translation The translation. + * + * @return object|null The response object or null if an error occurs. + * @since 2.0.1 + */ + public function checksum(string $translation = 'kjv'): ?object + { + return $this->response->get( + $this->http->get( + $this->uri->get($translation . '/checksum.json') + ) + ); + } + + /** + * Get the book's checksums in a translation + * + * @param string $translation The translation. + * @param int $book The book number. + * + * @return string|null The response checksums or null if an error occurs. + * @since 2.0.1 + */ + public function sha(string $translation, int $book): ?string + { + return trim( + $this->response->get( + $this->http->get( + $this->uri->get($translation . '/' . $book . '.sha') + ) + ) + ); + } +} + diff --git a/libraries/jcb_powers/VDM.Joomla.GetBible/src/Api/Chapters.php b/libraries/jcb_powers/VDM.Joomla.GetBible/src/Api/Chapters.php new file mode 100644 index 0000000..0e9d06e --- /dev/null +++ b/libraries/jcb_powers/VDM.Joomla.GetBible/src/Api/Chapters.php @@ -0,0 +1,100 @@ + + * @git GetBible + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ + +namespace VDM\Joomla\GetBible\Api; + + +use VDM\Joomla\GetBible\Abstraction\Api; + + +/** + * The GetBible Book Chapters + * + * @since 2.0.1 + */ +final class Chapters extends Api +{ + /** + * Get the chapters in a book in a translation + * + * @param string $translation The translation. + * @param int $book The book number. + * + * @return object|null The response object or null if an error occurs. + * @since 2.0.1 + */ + public function get(string $translation, int $book): ?object + { + return $this->response->get( + $this->http->get( + $this->uri->get($translation . '/' . $book . '.json') + ) + ); + } + + /** + * List the chapters of a book in a translation + * + * @param string $translation The translation. + * @param int $book The book number. + * + * @return object|null The response object or null if an error occurs. + * @since 2.0.1 + */ + public function list( string $translation, int $book): ?object + { + return $this->response->get( + $this->http->get( + $this->uri->get($translation . '/' . $book . '/chapters.json') + ) + ); + } + + /** + * List the chapters checksums of a book in a translation + * + * @param string $translation The translation. + * @param int $book The book number. + * + * @return object|null The response object or null if an error occurs. + * @since 2.0.1 + */ + public function checksum(string $translation, int $book): ?object + { + return $this->response->get( + $this->http->get( + $this->uri->get($translation . '/' . $book . '/checksum.json') + ) + ); + } + + /** + * Get the chapter's checksums of a book in a translation + * + * @param string $translation The translation. + * @param int $book The book number. + * @param int $chapter The chapter number. + * + * @return string|null The response checksum or null if an error occurs. + * @since 2.0.1 + */ + public function sha(string $translation, int $book, int $chapter): ?string + { + return trim( + $this->response->get( + $this->http->get( + $this->uri->get($translation . '/' . $book . '/' . $chapter . '.sha') + ) + ) + ); + } +} + diff --git a/libraries/jcb_powers/VDM.Joomla.GetBible/src/Api/Translations.php b/libraries/jcb_powers/VDM.Joomla.GetBible/src/Api/Translations.php new file mode 100644 index 0000000..4ff0648 --- /dev/null +++ b/libraries/jcb_powers/VDM.Joomla.GetBible/src/Api/Translations.php @@ -0,0 +1,74 @@ + + * @git GetBible + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ + +namespace VDM\Joomla\GetBible\Api; + + +use VDM\Joomla\GetBible\Abstraction\Api; + + +/** + * The GetBible Translations + * + * @since 2.0.1 + */ +final class Translations extends Api +{ + /** + * List the translations + * + * @return object|null The response object or null if an error occurs. + * @since 2.0.1 + */ + public function list(): ?object + { + return $this->response->get( + $this->http->get( + $this->uri->get('translations.json') + ) + ); + } + + /** + * List the translations checksums + * + * @return object|null The response object or null if an error occurs. + * @since 2.0.1 + */ + public function checksum(): ?object + { + return $this->response->get( + $this->http->get( + $this->uri->get('checksum.json') + ) + ); + } + + /** + * Get the translation's checksums + * + * @param string $translation The translation. + * + * @return string|null The response checksum or null if an error occurs. + * @since 2.0.1 + */ + public function sha(string $translation = 'kjv'): ?string + { + return trim( + $this->response->get( + $this->http->get( + $this->uri->get($translation . '.sha') + ) + ) + ); + } +} + diff --git a/libraries/jcb_powers/VDM.Joomla.GetBible/src/Api/Verses.php b/libraries/jcb_powers/VDM.Joomla.GetBible/src/Api/Verses.php new file mode 100644 index 0000000..8110f72 --- /dev/null +++ b/libraries/jcb_powers/VDM.Joomla.GetBible/src/Api/Verses.php @@ -0,0 +1,44 @@ + + * @git GetBible + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ + +namespace VDM\Joomla\GetBible\Api; + + +use VDM\Joomla\GetBible\Abstraction\Api; + + +/** + * The GetBible Book Chapter Verses + * + * @since 2.0.1 + */ +final class Verses extends Api +{ + /** + * Get the verses of chapter in a book in a translation + * + * @param string $translation The translation. + * @param int $book The book number. + * @param int $chapter The chapter number. + * + * @return object|null The response object or null if an error occurs. + * @since 2.0.1 + */ + public function get(string $translation, int $book, int $chapter): ?object + { + return $this->response->get( + $this->http->get( + $this->uri->get($translation . '/' . $book . '/' . $chapter . '.json') + ) + ); + } +} + diff --git a/libraries/jcb_powers/VDM.Joomla.GetBible/src/Api/index.html b/libraries/jcb_powers/VDM.Joomla.GetBible/src/Api/index.html new file mode 100644 index 0000000..fa6d84e --- /dev/null +++ b/libraries/jcb_powers/VDM.Joomla.GetBible/src/Api/index.html @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/libraries/jcb_powers/VDM.Joomla.GetBible/src/Config.php b/libraries/jcb_powers/VDM.Joomla.GetBible/src/Config.php new file mode 100644 index 0000000..1221c33 --- /dev/null +++ b/libraries/jcb_powers/VDM.Joomla.GetBible/src/Config.php @@ -0,0 +1,81 @@ + + * @git GetBible + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ + +namespace VDM\Joomla\GetBible; + + +use VDM\Joomla\Utilities\Component\Helper; +use VDM\Joomla\Abstraction\BaseConfig; + + +/** + * GetBible Configurations + * + * @since 2.0.1 + */ +class Config extends BaseConfig +{ + /** + * get Bible API url + * + * @return string The API Endpoint + * @since 2.0.1 + */ + protected function getEndpoint(): ?string + { + return $this->schema . '://' . $this->domain . '/' . $this->version . '/'; + } + + /** + * get Bible API Schema + * + * @return string The Get Bible Schema + * @since 2.0.1 + */ + protected function getSchema(): ?string + { + return 'https'; + } + + /** + * get Bible API domain + * + * @return string The Get Bible Domain + * @since 2.0.1 + */ + protected function getDomain(): ?string + { + return 'api.getbible.net'; + } + + /** + * get Bible version + * + * @return string The Get Bible Version + * @since 2.0.1 + */ + protected function getVersion(): ?string + { + return 'v2'; + } + + /** + * get Daily Scripture URL + * + * @return string The Get Daily Scripture URL + * @since 2.0.1 + */ + protected function getDailyscriptureurl(): ?string + { + return 'https://raw.githubusercontent.com/trueChristian/daily-scripture/master/README.today'; + } +} + diff --git a/libraries/jcb_powers/VDM.Joomla.GetBible/src/DailyScripture.php b/libraries/jcb_powers/VDM.Joomla.GetBible/src/DailyScripture.php new file mode 100644 index 0000000..46cf947 --- /dev/null +++ b/libraries/jcb_powers/VDM.Joomla.GetBible/src/DailyScripture.php @@ -0,0 +1,244 @@ + + * @git GetBible + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ + +namespace VDM\Joomla\GetBible; + + +use VDM\Joomla\GetBible\Config; +use VDM\Joomla\GetBible\Utilities\Http; +use VDM\Joomla\GetBible\Database\Load; + + +/** + * The GetBible Daily Scripture + * + * @since 2.0.1 + */ +final class DailyScripture +{ + /** + * The book number + * + * @var string|null + * @since 2.0.1 + */ + protected ?int $book = null; + + /** + * The chapter number + * + * @var int|null + * @since 2.0.1 + */ + protected ?int $chapter = null; + + /** + * The verses string + * + * @var string|null + * @since 2.0.1 + */ + protected ?string $verses = null; + + /** + * The reference string + * + * @var string|null + * @since 2.0.1 + */ + protected ?string $reference = null; + + /** + * The load object + * + * @var Load + * @since 2.0.1 + */ + protected Load $load; + + /** + * The active verse + * + * @var string + * @since 2.0.1 + */ + protected string $active = ''; + + /** + * Constructor + * + * @param Config $config The config object. + * @param Http $http The http object. + * @param Load $load The load object. + * + * @since 2.0.1 + */ + public function __construct(Config $config, Http $http, Load $load) + { + $response = $http->get($config->daily_scripture_url); + + // make sure we got the correct response + if ($response->code == 200 && isset($response->body) && is_string($response->body)) + { + $this->reference = $response->body; + + $this->parse($this->reference); + } + + $this->load = $load; + } + + /** + * method to validate if this is still the daily verse + * + * @return bool true if it is daily + * @since 2.0.1 + */ + public function isDaily(): bool + { + return (strcasecmp($this->active, $this->reference) == 0); + } + + /** + * An option to load another reference + * + * @param string $reference The scriptural reference. + * + * @since 2.0.1 + */ + public function load(string $reference) + { + // convert book name to book number + if (($name = $this->extract($reference)) !== null) + { + if (($number = $this->load->value( + ['name' => $name], 'nr', 'book')) === null) + { + // the book number could not be found + return; + } + + $reference = $this->replace($reference, $name, $number); + } + + $this->parse($reference); + + if ($this->book === null) + { + $this->parse($this->reference); + } + } + + /** + * Get the book number from the reference + * + * @return int|null Book number + * @since 2.0.1 + */ + public function book(): ?int + { + return $this->book; + } + + /** + * Get the chapter from the reference + * + * @return int|null Chapter number + * @since 2.0.1 + */ + public function chapter(): ?int + { + return $this->chapter; + } + + /** + * Get the verses from the reference + * + * @return string|null Verses + * @since 2.0.1 + */ + public function verses(): ?string + { + return $this->verses; + } + + /** + * Parse the scriptural reference + * + * @param string $reference The scriptural reference. + * + * @since 2.0.1 + */ + private function parse(string $reference) + { + $this->active = $reference; + $parts = explode(' ', $reference); + + $this->book = (isset($parts[0]) && is_numeric($parts[0])) ? intval($parts[0]) : null; + $chapterVerses = isset($parts[1]) ? explode(':', $parts[1]) : [null, null]; + + $this->chapter = (isset($chapterVerses[0]) && is_numeric($chapterVerses[0])) ? intval($chapterVerses[0]) : null; + $this->verses = isset($chapterVerses[1]) ? trim($chapterVerses[1]) : null; + } + + /** + * Extract the book name from the reference + * + * @return string|null Book name + * @since 2.0.1 + */ + private function extract(string $reference): ?string + { + // Use regex to match and remove chapter:verse and their variations (if they exist) from the end of the string + // This new regex considers Unicode word boundaries + $bookName = preg_replace('/\b\d+(:(\d+([,-]\d+)*)?\b)*$/u', '', $reference); + + // If there's no match or the remaining string is empty or numeric, return null + // The is_numeric check has been adjusted to work for Unicode strings + if (mb_strlen(trim($bookName)) === 0 || preg_match('/^\d+$/u', $bookName)) + { + return null; + } + + return trim($bookName); + } + + /** + * Replace the book name with a number in the reference + * + * @param string $reference Original reference + * @param string $name Book name + * @param int $number Book number + * + * @return string New reference with the book number instead of the name + * @since 2.0.1 + */ + private function replace(string $reference, string $name, int $number): string + { + return $this->mb_str_replace($name, "$number", $reference); + } + + /** + * Build in str_replace that will work with all languages + * + * @param string $search The search phrase/word + * @param string $replace The replace phrase/word + * @param string $subject The string to update + * + * @return string New updated string + * @since 2.0.1 + */ + private function mb_str_replace(string $search, string $replace, string $subject): string + { + return mb_ereg_replace(preg_quote($search), $replace, $subject); + } +} + diff --git a/libraries/jcb_powers/VDM.Joomla.GetBible/src/Data/Book.php b/libraries/jcb_powers/VDM.Joomla.GetBible/src/Data/Book.php new file mode 100644 index 0000000..da5d4f8 --- /dev/null +++ b/libraries/jcb_powers/VDM.Joomla.GetBible/src/Data/Book.php @@ -0,0 +1,156 @@ + + * @git GetBible + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ + +namespace VDM\Joomla\GetBible\Data; + + +use VDM\Joomla\GetBible\Database\Load; +use VDM\Joomla\GetBible\Openai\Config; + + +/** + * The GetBible Book Data + * + * @since 2.0.1 + */ +final class Book +{ + /** + * The Load class + * + * @var Load + * @since 2.0.1 + */ + protected Load $load; + + /** + * The Config class + * + * @var Config + * @since 2.0.1 + */ + protected Config $config; + + /** + * The books + * + * @var array + * @since 2.0.1 + */ + protected array $books = []; + + /** + * Constructor + * + * @param Load $load The load object. + * @param Config $config The config object. + * + * @since 2.0.1 + */ + public function __construct(Load $load, Config $config) + { + $this->load = $load; + $this->config = $config; + } + + /** + * Get the book number + * + * @return string The book number + * @since 2.0.1 + */ + public function getNumber(): string + { + $book = $this->get(); + return $book ? $book->nr ?? '' : ''; + } + + /** + * Get the book name + * + * @return string The book name + * @since 2.0.1 + */ + public function getName(): string + { + $book = $this->get(); + return $book ? $book->name ?? '' : ''; + } + + /** + * Get the book + * + * @return object|null True on success + * @since 2.0.1 + */ + private function get(): ?object + { + $abbreviation = $this->config->get('translation'); + $book = $this->config->get('book'); + + if (empty($abbreviation) || empty($book)) + { + return null; + } + + $cacheKey = $this->generateCacheKey($abbreviation, $book); + + if (isset($this->books[$cacheKey])) + { + return $this->books[$cacheKey]; + } + + return $this->loadBookData($abbreviation, $book); + } + + /** + * Loads the book data from the database and updates the cache + * + * @param string $abbreviation The translation abbreviation. + * @param int $book The book number. + * + * @return object|null The loaded book data, or null if not found or an error occurred. + * @since 2.0.1 + */ + private function loadBookData(string $abbreviation, int $book): ?object + { + $data = $this->load->item( + ['abbreviation' => $abbreviation, 'nr' => $book], + 'book' + ); + + if (!is_object($data)) + { + return null; + } + + $cacheKey = $this->generateCacheKey($abbreviation, $book); + + $this->books[$cacheKey] = $data; + + return $this->books[$cacheKey]; + } + + /** + * Generates a cache key based on the abbreviation, and book + * + * @param string $abbreviation The translation abbreviation. + * @param int $book The book number. + * + * @return string The generated cache key. + * @since 2.0.1 + */ + private function generateCacheKey(string $abbreviation, int $book): string + { + return $abbreviation . $book; + } +} + diff --git a/libraries/jcb_powers/VDM.Joomla.GetBible/src/Data/Chapter.php b/libraries/jcb_powers/VDM.Joomla.GetBible/src/Data/Chapter.php new file mode 100644 index 0000000..04e899a --- /dev/null +++ b/libraries/jcb_powers/VDM.Joomla.GetBible/src/Data/Chapter.php @@ -0,0 +1,214 @@ + + * @git GetBible + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ + +namespace VDM\Joomla\GetBible\Data; + + +use VDM\Joomla\GetBible\Database\Load; +use VDM\Joomla\GetBible\Openai\Config; + + +/** + * The GetBible Chapter Data + * + * @since 2.0.1 + */ +final class Chapter +{ + /** + * The Load class + * + * @var Load + * @since 2.0.1 + */ + protected Load $load; + + /** + * The Config class + * + * @var Config + * @since 2.0.1 + */ + protected Config $config; + + /** + * The chapters + * + * @var array + * @since 2.0.1 + */ + protected array $chapters = []; + + /** + * Constructor + * + * @param Load $load The load object. + * @param Config $config The config object. + * + * @since 2.0.1 + */ + public function __construct(Load $load, Config $config) + { + $this->load = $load; + $this->config = $config; + } + + /** + * Get the chapter number + * + * @return string The chapter number + * @since 2.0.1 + */ + public function getNumber(): string + { + $chapter = $this->get(); + return $chapter ? $chapter->chapter ?? '' : ''; + } + + /** + * Get the chapter name + * + * @return string The chapter name + * @since 2.0.1 + */ + public function getName(): string + { + $chapter = $this->get(); + return $chapter ? $chapter->name ?? '' : ''; + } + + /** + * Get the chapter text + * + * @return string The chapter text + * @since 2.0.1 + */ + public function getText(): string + { + $chapter = $this->get(); + return $chapter ? $chapter->text ?? '' : ''; + } + + /** + * Get the chapter verses + * + * @return array|null The chapter verses + * @since 2.0.1 + */ + public function getVerses(): ?array + { + $chapter = $this->get(); + return $chapter ? $chapter->verses ?? null : null; + } + + /** + * Get the chapter + * + * @return object|null True on success + * @since 2.0.1 + */ + private function get(): ?object + { + $abbreviation = $this->config->get('translation'); + $book = $this->config->get('book'); + $chapter = $this->config->get('chapter'); + + if (empty($abbreviation) || empty($book) || empty($chapter)) + { + return null; + } + + $cacheKey = $this->generateCacheKey($abbreviation, $book, $chapter); + + if (isset($this->chapters[$cacheKey])) + { + return $this->chapters[$cacheKey]; + } + + return $this->loadChapterData($abbreviation, (int) $book, (int) $chapter); + } + + /** + * Loads the chapter data from the database and updates the cache + * + * @param string $abbreviation The translation abbreviation. + * @param int $book The book number. + * @param int $chapter The chapter number. + * + * @return object|null The loaded chapter data, or null if not found or an error occurred. + * @since 2.0.1 + */ + private function loadChapterData(string $abbreviation, int $book, int $chapter): ?object + { + $data = $this->load->item( + ['abbreviation' => $abbreviation, 'book_nr' => $book, 'chapter' => $chapter, 'published' => 1], + 'chapter' + ); + + if (!is_object($data)) + { + return null; + } + + $data->verses = $this->load->items( + ['abbreviation' => $abbreviation, 'book_nr' => $book, 'chapter' => $chapter, 'published' => 1], + 'verse' + ); + + if ($data->verses === null || !is_array($data->verses) || $data->verses === []) + { + return null; + } + + $cacheKey = $this->generateCacheKey($abbreviation, $book, $chapter); + + $data->text = $this->convertVersesToText($data->verses); + + $this->chapters[$cacheKey] = $data; + + return $this->chapters[$cacheKey]; + } + + /** + * Convert verses to text + * + * @param array $verses The chapter verses. + * + * @return string The verses in text. + * @since 2.0.1 + */ + private function convertVersesToText(array $verses): string + { + $text = []; + foreach ($verses as $verse) + { + $text[] = trim($verse->verse) . ' ' . trim($verse->text); + } + + return implode(' ', $text); + } + + /** + * Generates a cache key based on the abbreviation, book, and chapter + * + * @param string $abbreviation The translation abbreviation. + * @param int $book The book number. + * @param int $chapter The chapter number. + * + * @return string The generated cache key. + * @since 2.0.1 + */ + private function generateCacheKey(string $abbreviation, int $book, int $chapter): string + { + return $abbreviation . '_' . $book . '_' . $chapter; + } +} + diff --git a/libraries/jcb_powers/VDM.Joomla.GetBible/src/Data/Placeholders.php b/libraries/jcb_powers/VDM.Joomla.GetBible/src/Data/Placeholders.php new file mode 100644 index 0000000..fdc0e91 --- /dev/null +++ b/libraries/jcb_powers/VDM.Joomla.GetBible/src/Data/Placeholders.php @@ -0,0 +1,151 @@ + + * @git GetBible + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ + +namespace VDM\Joomla\GetBible\Data; + + +use VDM\Joomla\GetBible\Data\Scripture; +use VDM\Joomla\GetBible\Data\Prompt; + + +/** + * The GetBible Prompt Placeholders + * + * @since 2.0.1 + */ +final class Placeholders +{ + /** + * The Scripture class + * + * @var Scripture + * @since 2.0.1 + */ + protected Scripture $scripture; + + /** + * The Prompt class + * + * @var Prompt + * @since 2.0.1 + */ + protected Prompt $prompt; + + /** + * Constructor + * + * @param Scripture $scripture The scripture object. + * @param Prompt $prompt The prompt object. + * + * @since 2.0.1 + */ + public function __construct( + Scripture $scripture, + Prompt $prompt) + { + $this->scripture = $scripture; + $this->prompt = $prompt; + } + + /** + * Get the Open AI response + * + * @return array Array of response messages + * @since 2.0.1 + */ + public function get(): array + { + $integration = $this->prompt->getIntegration(); + $cache_behaviour = $this->prompt->getCacheBehaviour(); + + if ($integration === null || $cache_behaviour === null) + { + return []; + } + + if (($integration == 1 || $integration == 3) && ($cache_behaviour == 0 || $cache_behaviour == 2)) + { + return $this->all(); + } + elseif ($integration == 2 && ($cache_behaviour == 0 || $cache_behaviour == 2)) + { + return $this->without(); + } + + return $this->words(); + } + + /** + * Get All Placeholders + * + * @return array Array of Placeholders + * @since 2.0.1 + */ + private function all(): array + { + return [ + '[translation_name]' => $this->scripture->get('translation_name', ''), + '[translation_language]' => $this->scripture->get('translation_language', ''), + '[translation_lcsh]' => $this->scripture->get('translation_lcsh', ''), + '[translation_abbreviation]' => $this->scripture->get('translation_abbreviation', ''), + '[book_number]' => $this->scripture->get('book_number', ''), + '[book_name]' => $this->scripture->get('book_name', ''), + '[chapter_number]' => $this->scripture->get('chapter_number', ''), + '[chapter_name]' => $this->scripture->get('chapter_name', ''), + '[chapter_text]' => $this->scripture->get('chapter_text', ''), + '[verse_number]' => $this->scripture->get('verse_number', ''), + '[verse_name]' => $this->scripture->get('verse_name', ''), + '[verse_text]' => $this->scripture->get('verse_text', ''), + '[selected_word_number]' => $this->scripture->get('selected_word_number', ''), + '[selected_word_text]' => $this->scripture->get('selected_word_text', '') + ]; + } + + /** + * Get All Placeholders without words + * + * @return array Array of Placeholders + * @since 2.0.1 + */ + private function without(): array + { + return [ + '[translation_name]' => $this->scripture->get('translation_name', ''), + '[translation_language]' => $this->scripture->get('translation_language', ''), + '[translation_lcsh]' => $this->scripture->get('translation_lcsh', ''), + '[translation_abbreviation]' => $this->scripture->get('translation_abbreviation', ''), + '[book_number]' => $this->scripture->get('book_number', ''), + '[book_name]' => $this->scripture->get('book_name', ''), + '[chapter_number]' => $this->scripture->get('chapter_number', ''), + '[chapter_name]' => $this->scripture->get('chapter_name', ''), + '[chapter_text]' => $this->scripture->get('chapter_text', ''), + '[verse_number]' => $this->scripture->get('verse_number', ''), + '[verse_name]' => $this->scripture->get('verse_name', ''), + '[verse_text]' => $this->scripture->get('verse_text', '') + ]; + } + + /** + * Get Words Placeholders + * + * @return array Array of Placeholders + * @since 2.0.1 + */ + private function words(): array + { + return [ + '[translation_language]' => $this->scripture->get('translation_language', ''), + '[translation_lcsh]' => $this->scripture->get('translation_lcsh', ''), + '[selected_word_text]' => $this->scripture->get('selected_word_text', '') + ]; + } +} + diff --git a/libraries/jcb_powers/VDM.Joomla.GetBible/src/Data/Prompt.php b/libraries/jcb_powers/VDM.Joomla.GetBible/src/Data/Prompt.php new file mode 100644 index 0000000..cde1a2b --- /dev/null +++ b/libraries/jcb_powers/VDM.Joomla.GetBible/src/Data/Prompt.php @@ -0,0 +1,327 @@ + + * @git GetBible + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ + +namespace VDM\Joomla\GetBible\Data; + + +use VDM\Joomla\GetBible\Database\Load; +use VDM\Joomla\GetBible\Openai\Config; + + +/** + * The GetBible Prompt Data + * + * @since 2.0.1 + */ +final class Prompt +{ + /** + * The Load class + * + * @var Load + * @since 2.0.1 + */ + protected Load $load; + + /** + * The Config class + * + * @var Config + * @since 2.0.1 + */ + protected Config $config; + + /** + * The prompts + * + * @var array + * @since 2.0.1 + */ + protected array $prompts = []; + + /** + * Constructor + * + * @param Load $load The load object. + * @param Config $config The config object. + * + * @since 2.0.1 + */ + public function __construct(Load $load, Config $config) + { + $this->load = $load; + $this->config = $config; + } + + /** + * Get prompt guid + * + * @return string The global unique id + * @since 2.0.1 + */ + public function getGuid(): string + { + $prompt = $this->get(); + return $prompt ? $prompt->guid ?? '' : ''; + } + + /** + * Get open ai token + * + * @return string|null The token + * @since 2.0.1 + */ + public function getToken(): ?string + { + $default = $this->config->get('token'); + $prompt = $this->get(); + + if (!$prompt || !isset($prompt->token_override) || + $prompt->token_override != 1) + { + return $default; + } + + return $prompt->token ?? $default; + } + + /** + * Get open ai organisation token + * + * @return string|null The token + * @since 2.0.1 + */ + public function getOrgToken(): ?string + { + $default = $this->config->get('org_token'); + $prompt = $this->get(); + + if (!$prompt || !isset($prompt->ai_org_token_override) || + $prompt->ai_org_token_override != 1) + { + return $default; + } + + return $prompt->org_token ?? $default; + } + + /** + * Get open ai model name + * + * @return string|null The model name + * @since 2.0.1 + */ + public function getModel(): ?string + { + $default = $this->config->get('model'); + $prompt = $this->get(); + + return $prompt ? $prompt->model ?? $default : $default; + } + + /** + * Get the max tokens + * + * @return int|null The max tokens + * @since 2.0.1 + */ + public function getMaxTokens(): ?int + { + $default = $this->config->get('max_tokens'); + $prompt = $this->get(); + + if (!$prompt || !isset($prompt->max_tokens_override) || + $prompt->max_tokens_override != 1) + { + return $default; + } + + return $prompt->max_tokens ?? $default; + } + + /** + * Get the temperature + * + * @return float|null The temperature + * @since 2.0.1 + */ + public function getTemperature(): ?float + { + $default = $this->config->get('temperature'); + $prompt = $this->get(); + + if (!$prompt || !isset($prompt->temperature_override) || + $prompt->temperature_override != 1) + { + return $default; + } + + return $prompt->temperature ?? $default; + } + + /** + * Get the top p + * + * @return float|null The top p + * @since 2.0.1 + */ + public function getTopP(): ?float + { + $default = $this->config->get('top_p'); + $prompt = $this->get(); + + if (!$prompt || !isset($prompt->top_p_override) || + $prompt->top_p_override != 1) + { + return $default; + } + + return $prompt->top_p ?? $default; + } + + /** + * Get the number of results + * + * @return int|null The number of results + * @since 2.0.1 + */ + public function getN(): ?int + { + $default = $this->config->get('n'); + $prompt = $this->get(); + + if (!$prompt || !isset($prompt->n_override) || + $prompt->n_override != 1) + { + return $default; + } + + return $prompt->n ?? $default; + } + + /** + * Get presence penalty + * + * @return float|null The presence penalty + * @since 2.0.1 + */ + public function getPresencePenalty(): ?float + { + $default = $this->config->get('presence_penalty'); + $prompt = $this->get(); + + if (!$prompt || !isset($prompt->presence_penalty_override) || + $prompt->presence_penalty_override != 1) + { + return $default; + } + + return $prompt->presence_penalty ?? $default; + } + + /** + * Get frequency penalty + * + * @return float|null The frequency penalty + * @since 2.0.1 + */ + public function getFrequencyPenalty(): ?float + { + $default = $this->config->get('frequency_penalty'); + $prompt = $this->get(); + + if (!$prompt || !isset($prompt->frequency_penalty_override) || + $prompt->frequency_penalty_override != 1) + { + return $default; + } + + return $prompt->frequency_penalty ?? $default; + } + + /** + * Get the integration + * + * @return int|null 1 = Word-Based, 2 = Verse-Based, 3 = Selection-Based + * @since 2.0.1 + */ + public function getIntegration(): ?int + { + $prompt = $this->get(); + return $prompt ? $prompt->integration ?? null : null; + } + + /** + * Get the cache behaviour + * + * @return int|null 0 = Persistently, 2 = Basic, 3 = Advanced + * @since 2.0.1 + */ + public function getCacheBehaviour(): ?int + { + $prompt = $this->get(); + return $prompt ? $prompt->cache_behaviour ?? null : null; + } + + /** + * Get the cache capacity + * + * @return int The number to cache + * @since 2.0.1 + */ + public function getCacheCapacity(): int + { + $prompt = $this->get(); + return $prompt ? $prompt->cache_capacity ?? 1 : 1; + } + + /** + * Get the prompt messages + * + * @return array|null The array of massage + * @since 2.0.1 + */ + public function getMessages(): ?array + { + $prompt = $this->get(); + return $prompt ? $prompt->messages ?? null : null; + } + + /** + * Get the prompt + * + * @return object|null True on success + * @since 2.0.1 + */ + protected function get(): ?object + { + // get from cache if not found + $guid = $this->config->get('prompt'); + + if (empty($guid)) + { + return null; + } + + if (!isset($this->prompts[$guid])) + { + $this->prompts[$guid] = $this->load->item(['guid' => $guid, 'published' => 1], 'prompt'); + + if ($this->prompts[$guid] && isset($this->prompts[$guid]->messages) && is_object($this->prompts[$guid]->messages)) + { + $this->prompts[$guid]->messages = array_values((array) $this->prompts[$guid]->messages); + } + } + + return $this->prompts[$guid]; + } +} + diff --git a/libraries/jcb_powers/VDM.Joomla.GetBible/src/Data/Response.php b/libraries/jcb_powers/VDM.Joomla.GetBible/src/Data/Response.php new file mode 100644 index 0000000..eacc4d5 --- /dev/null +++ b/libraries/jcb_powers/VDM.Joomla.GetBible/src/Data/Response.php @@ -0,0 +1,200 @@ + + * @git GetBible + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ + +namespace VDM\Joomla\GetBible\Data; + + +use VDM\Joomla\GetBible\Data\Scripture; +use VDM\Joomla\GetBible\Data\Prompt; +use VDM\Joomla\GetBible\Database\Load; +use VDM\Joomla\GetBible\Openai\Config; + + +/** + * The GetBible Response Data + * + * @since 2.0.1 + */ +final class Response +{ + /** + * The Scripture class + * + * @var Scripture + * @since 2.0.1 + */ + protected Scripture $scripture; + + /** + * The Prompt class + * + * @var Prompt + * @since 2.0.1 + */ + protected Prompt $prompt; + + /** + * The Load class + * + * @var Load + * @since 2.0.1 + */ + protected Load $load; + + /** + * The Config class + * + * @var Config + * @since 2.0.1 + */ + protected Config $config; + + /** + * The responses + * + * @var array + * @since 2.0.1 + */ + protected array $responses = []; + + /** + * The total responses + * + * @var int + * @since 2.0.1 + */ + protected int $total = 0; + + /** + * Constructor + * + * @param Scripture $scripture The scripture object. + * @param Prompt $prompt The prompt object. + * @param Load $load The load object. + * @param Config $config The config object. + * + * @since 2.0.1 + */ + public function __construct( + Scripture $scripture, + Prompt $prompt, + Load $load, + Config $config) + { + $this->scripture = $scripture; + $this->prompt = $prompt; + $this->load = $load; + $this->config = $config; + } + + /** + * Get the responses + * + * @return array|null True on success + * @since 2.0.1 + */ + public function get(): ?array + { + // get the cache behaviour + $cache = $this->prompt->getCacheBehaviour(); + + if (empty($cache) || ($cache != 1 && $cache != 2)) + { + return null; + } + + // load the prompt GUID + $guid = $this->config->get('prompt'); + + if ($guid === null) + { + return null; + } + + if (!isset($this->responses[$guid])) + { + $this->responses[$guid] = null; + + $query = ['prompt' => $guid, 'published' => 1]; + + // Basic Caching - Words/Language + if ($cache == 1) + { + // any empty string so cause no value to be returned + $query['language'] = $this->scripture->get('translation_language', 'none__found'); + $query['selected_word'] = $this->scripture->get('selected_word_text', 'none__found'); + } + // Advanced Caching - Verse/Contex + else + { + // any empty string so cause no value to be returned + $query['abbreviation'] = $this->scripture->get('translation_abbreviation', 'none__found'); + $query['book'] = $this->scripture->get('book_number', 'none__found'); + $query['chapter'] = $this->scripture->get('chapter_number', 'none__found'); + $query['verse'] = $this->scripture->get('verse_number', 'none__found'); + + // get the integration + $integration = $this->prompt->getIntegration(); + if ($integration == 1 || $integration == 3) + { + $query['word'] = $this->scripture->get('selected_word_number', 'none__found'); + } + } + $bucket = $this->load->items($query, 'open_ai_response'); + + if (is_array($bucket) && $bucket !== []) + { + foreach($bucket as $nr => &$response) + { + $response->messages = $this->load->items([ + 'prompt' => $guid, + 'open_ai_response' => $response->response_id, + 'published' => 1 + ], 'open_ai_message'); + } + + $this->responses[$guid] = $bucket; + } + } + + return $this->responses[$guid]; + } + + /** + * is there enough response messages + * + * @return bool true if there is enough messages + * @since 2.0.1 + */ + public function isEnough(): bool + { + return ($this->getTotal() >= $this->prompt->getCacheCapacity()); + } + + /** + * Get the total responses in cache + * + * @return int Number responses from OpenAI + * @since 2.0.1 + */ + public function getTotal(): int + { + if ($this->total > 0 || ($responses = $this->get()) === null) + { + return $this->total; + } + + $this->total = count((array) $responses); + + return $this->total; + } +} + diff --git a/libraries/jcb_powers/VDM.Joomla.GetBible/src/Data/Scripture.php b/libraries/jcb_powers/VDM.Joomla.GetBible/src/Data/Scripture.php new file mode 100644 index 0000000..904363c --- /dev/null +++ b/libraries/jcb_powers/VDM.Joomla.GetBible/src/Data/Scripture.php @@ -0,0 +1,154 @@ + + * @git GetBible + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ + +namespace VDM\Joomla\GetBible\Data; + + +use VDM\Joomla\GetBible\Data\Translation; +use VDM\Joomla\GetBible\Data\Book; +use VDM\Joomla\GetBible\Data\Chapter; +use VDM\Joomla\GetBible\Data\Verse; +use VDM\Joomla\GetBible\Data\Word; + + +/** + * The GetBible Scripture + * + * @since 2.0.1 + */ +final class Scripture +{ + /** + * The Translation class + * + * @var Translation + * @since 2.0.1 + */ + protected Translation $translation; + + /** + * The Book class + * + * @var Book + * @since 2.0.1 + */ + protected Book $book; + + /** + * The Chapter class + * + * @var Chapter + * @since 2.0.1 + */ + protected Chapter $chapter; + + /** + * The Verse class + * + * @var Verse + * @since 2.0.1 + */ + protected Verse $verse; + + /** + * The Word class + * + * @var Word + * @since 2.0.1 + */ + protected Word $word; + + /** + * The Scripture object + * + * @var object + * @since 2.0.1 + */ + protected ?object $scripture; + + /** + * Constructor + * + * @param Translation $translation The translation object. + * @param Book $book The book object. + * @param Chapter $chapter The chapter object. + * @param Verse $verse The verse object. + * @param Word $word The word object. + * + * @since 2.0.1 + */ + public function __construct( + Translation $translation, + Book $book, + Chapter $chapter, + Verse $verse, + Word $word) + { + $this->translation = $translation; + $this->book = $book; + $this->chapter = $chapter; + $this->verse = $verse; + $this->word = $word; + } + + /** + * Get the Open AI response + * + * @param string $key The value key. + * @param mixed $default The default value. + * + * @return mixed Scripture Values + * @since 2.0.1 + */ + public function get(string $key, $default = null) + { + if (empty($this->scripture)) + { + $this->scripture = $this->getScripture(); + } + + return $this->scripture->{$key} ?? $default; + } + + /** + * Get all related scripture values + * + * @return object Object of Scripture Values + * @since 2.0.1 + */ + private function getScripture(): object + { + /** + * do not change these keys !!! + * this is an easy mapping + * so called bad practice + * that we use to simplify + * access to these values + */ + return (object) [ + 'translation_name' => $this->translation->getName(), + 'translation_language' => $this->translation->getLanguage(), + 'translation_lcsh' => $this->translation->getLcsh(), + 'translation_abbreviation' => $this->translation->getAbbreviation(), + 'book_number' => $this->book->getNumber(), + 'book_name' => $this->book->getName(), + 'chapter_number' => $this->chapter->getNumber(), + 'chapter_name' => $this->chapter->getName(), + 'chapter_text' => $this->chapter->getText(), + 'verse_number' => $this->verse->getNumber(), + 'verse_name' => $this->verse->getName(), + 'verse_text' => $this->verse->getText(), + 'selected_word_number' => $this->word->getNumber(), + 'selected_word_text' => $this->word->getText() + ]; + } +} + diff --git a/libraries/jcb_powers/VDM.Joomla.GetBible/src/Data/Translation.php b/libraries/jcb_powers/VDM.Joomla.GetBible/src/Data/Translation.php new file mode 100644 index 0000000..193a72b --- /dev/null +++ b/libraries/jcb_powers/VDM.Joomla.GetBible/src/Data/Translation.php @@ -0,0 +1,140 @@ + + * @git GetBible + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ + +namespace VDM\Joomla\GetBible\Data; + + +use VDM\Joomla\GetBible\Database\Load; +use VDM\Joomla\GetBible\Openai\Config; + + +/** + * The GetBible Translation Data + * + * @since 2.0.1 + */ +final class Translation +{ + /** + * The Load class + * + * @var Load + * @since 2.0.1 + */ + protected Load $load; + + /** + * The Config class + * + * @var Config + * @since 2.0.1 + */ + protected Config $config; + + /** + * The translations + * + * @var array + * @since 2.0.1 + */ + protected array $translations = []; + + /** + * Constructor + * + * @param Load $load The load object. + * @param Config $config The config object. + * + * @since 2.0.1 + */ + public function __construct(Load $load, Config $config) + { + $this->load = $load; + $this->config = $config; + } + + /** + * Get the translation name + * + * @return string The translation name + * @since 2.0.1 + */ + public function getName(): string + { + $translation = $this->get(); + return $translation ? $translation->translation ?? '' : ''; + } + + /** + * Get the translation language + * + * @return string The translation language + * @since 2.0.1 + */ + public function getLanguage(): string + { + $translation = $this->get(); + $lang = trim(preg_replace('/Bible\.?/', '', $this->getLcsh())); + return $translation ? $translation->language ?? $lang : ''; + } + + /** + * Get the translation distribution lcsh + * + * @return string The translation lcsh + * @since 2.0.1 + */ + public function getLcsh(): string + { + $translation = $this->get(); + return $translation ? $translation->distribution_lcsh ?? '' : ''; + } + + /** + * Get the translation abbreviation + * + * @return string The translation abbreviation + * @since 2.0.1 + */ + public function getAbbreviation(): string + { + $translation = $this->get(); + return $translation ? $translation->abbreviation ?? '' : ''; + } + + /** + * Get the translation + * + * @return object|null True on success + * @since 2.0.1 + */ + public function get(): ?object + { + // get selected translation abbreviation + $abbreviation = $this->config->get('translation'); + + if (empty($abbreviation)) + { + return null; + } + + if (!isset($this->translations[$abbreviation])) + { + $this->translations[$abbreviation] = $this->load->item( + ['abbreviation' => $abbreviation, 'published' => 1], + 'translation' + ); + } + + return $this->translations[$abbreviation]; + } +} + diff --git a/libraries/jcb_powers/VDM.Joomla.GetBible/src/Data/Verse.php b/libraries/jcb_powers/VDM.Joomla.GetBible/src/Data/Verse.php new file mode 100644 index 0000000..4ef1905 --- /dev/null +++ b/libraries/jcb_powers/VDM.Joomla.GetBible/src/Data/Verse.php @@ -0,0 +1,453 @@ + + * @git GetBible + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ + +namespace VDM\Joomla\GetBible\Data; + + +use VDM\Joomla\GetBible\Data\Chapter; +use VDM\Joomla\GetBible\Openai\Config; +use VDM\Joomla\GetBible\Data\Prompt; +use VDM\Joomla\GetBible\Utilities\StringHelper; + + +/** + * The GetBible Verse Data + * + * @since 2.0.1 + */ +final class Verse +{ + /** + * The Chapter class + * + * @var Chapter + * @since 2.0.1 + */ + protected Chapter $chapter; + + /** + * The Config class + * + * @var Config + * @since 2.0.1 + */ + protected Config $config; + + /** + * The Prompt class + * + * @var Prompt + * @since 2.0.1 + */ + protected Prompt $prompt; + + /** + * The StringHelper class + * + * @var StringHelper + * @since 2.0.1 + */ + protected StringHelper $stringHelper; + + /** + * The verses + * + * @var array + * @since 2.0.1 + */ + protected array $verses = []; + + /** + * Constructor + * + * @param Chapter $chapter The chapter object. + * @param Config $config The config object. + * @param Prompt $prompt The prompt object. + * @param StringHelper $stringHelper The string helper object. + * + * @since 2.0.1 + */ + public function __construct(Chapter $chapter, Config $config, Prompt $prompt, StringHelper $stringHelper) + { + $this->chapter = $chapter; + $this->config = $config; + $this->prompt = $prompt; + $this->stringHelper = $stringHelper; + } + + /** + * Get the verse number/s + * + * @return string The verse number/s + * @since 2.0.1 + */ + public function getNumber(): string + { + $verse = $this->get(); + return $verse ? $verse->number ?? '' : ''; + } + + /** + * Get the verse name + * + * @return string The verse name + * @since 2.0.1 + */ + public function getName(): string + { + $verse = $this->get(); + return $verse ? $verse->name ?? '' : ''; + } + + /** + * Get the verse text + * + * @return string The verse text + * @since 2.0.1 + */ + public function getText(): string + { + $verse = $this->get(); + return $verse ? $verse->text ?? '' : ''; + } + + /** + * Get the verse array + * + * @return array|null The verse array + * @since 2.0.1 + */ + public function getVerse(): ?array + { + $verse = $this->get(); + return $verse ? $verse->verse ?? null : null; + } + + /** + * Get the valid verse numbers + * + * @return array|null The verse number array + * @since 2.0.1 + */ + public function getValid(): ?array + { + $verse = $this->get(); + return $verse ? $verse->valid ?? null : null; + } + + /** + * Get the verse + * + * @return object|null True on success + * @since 2.0.1 + */ + private function get(): ?object + { + $abbreviation = $this->config->get('translation'); + $book = $this->config->get('book'); + $chapter = $this->config->get('chapter'); + $verse = $this->config->get('verse'); + + if (empty($abbreviation) || empty($book) || empty($chapter) || empty($verse)) + { + return null; + } + + $cacheKey = $this->generateCacheKey($abbreviation, $book, $chapter, $verse); + + if (isset($this->verses[$cacheKey])) + { + return $this->verses[$cacheKey]; + } + + return $this->loadVerseData($cacheKey, $verse); + } + + /** + * Loads the verse data + * + * @param string $cacheKey The cache key. + * @param string $verses The selected verses. + * + * @return object|null The loaded verse data, or null if not found or an error occurred. + * @since 2.0.1 + */ + private function loadVerseData(string $cacheKey, string $verses): ?object + { + $chapter = $this->chapter->getVerses(); + + if (empty($chapter)) + { + $this->verses[$cacheKey] = null; + + return null; + } + + $data = new \stdClass(); + + $data->range = $this->selectedVersesRange($verses); + + $data->number = $this->validateSelectedVersesNumbers($data->range, $chapter); + + $chapter_name = $this->chapter->getName(); + + if (empty($data->number) || empty($chapter_name)) + { + $this->verses[$cacheKey] = null; + + return null; + } + + $data->name = $chapter_name . ':' . $data->number; + + $data->text = $this->getVersesString($data->range, $chapter); + + $data->verse = $this->getVersesArray($data->range, $chapter); + + if (empty($data->text) || empty($data->verse)) + { + $this->verses[$cacheKey] = null; + + return null; + } + + $data->valid = $this->validVerseNumbers($data->range); + + $this->verses[$cacheKey] = $data; + + return $this->verses[$cacheKey]; + } + + /** + * Get the range of verses selected + * + * @param string $verses The selected verses + * + * @return array The the raw selected verses + * @since 2.0.1 + */ + private function selectedVersesRange(string $verses): array + { + $bucket = []; + + if (strpos($verses, '-') !== false) + { + $_verses = $this->splitAndTrim($verses); + + $min_verse = min($_verses); + $max_verse = max($_verses); + + $bucket[] = $min_verse; + if ($min_verse != $max_verse && $this->prompt->getIntegration() == 2) + { + $bucket[] = $max_verse; + } + } + else + { + $bucket[] = trim($verses); + } + + return $bucket; + } + + /** + * Split string by '-' and trim each element. + * + * @param string $str The string to be split. + * + * @return array The splitted and trimmed array. + * @since 2.0.1 + */ + private function splitAndTrim(string $str): array + { + if (strpos($str, '-') !== false) + { + $array = array_map('trim', explode('-', $str)); + + sort($array); + + return $array; + } + + return [trim($str)]; + } + + /** + * Validate that these verse numbers exist in chapter + * + * @param array $verses The selected verse numbers + * @param array $chapter The chapter verses + * + * @return string|null The the valid verse numbers or empty string + * @since 2.0.1 + */ + private function validateSelectedVersesNumbers(array &$verses, array $chapter): ?string + { + $valid = []; + + foreach ($chapter as $verse) + { + if (isset($verses[0]) && $verse->verse == $verses[0]) + { + $valid[0] = $verses[0]; + } + elseif (isset($verses[1]) && $verse->verse == $verses[1]) + { + $valid[1] = $verses[1]; + } + } + + if ($valid !== []) + { + // update the verse array to its valid state + $verses = $valid; + + return implode('-', $valid); + } + + $verses = []; + + return null; + } + + /** + * Get the verses selected as text string + * + * @param array $verses The valid selected verse numbers + * @param array $chapter The chapter verses + * + * @return string|null The selected verses as a string + * @since 2.0.1 + */ + private function getVersesString(array $verses, array $chapter): ?string + { + $text = []; + + $add = false; + + foreach ($chapter as $verse) + { + if ($verse->verse == $verses[0]) + { + $add = true; + } + elseif (!isset($verses[1])) + { + $add = false; + } + + if ($add) + { + $text[] = trim($verse->verse) . ' ' . trim($verse->text); + } + + if (isset($verses[1]) && $verse->verse == $verses[1]) + { + $add = false; + } + } + + if (empty($text)) + { + return null; + } + + return implode(' ', $text); + } + + /** + * Get the verses selected as multidimensional array + * + * @param array $verses The valid selected verse numbers + * @param array $chapter The chapter verses + * + * @return array|null The selected verses as an array + * @since 2.0.1 + */ + private function getVersesArray(array $verses, array $chapter): ?array + { + $text = []; + + $add = false; + + foreach ($chapter as $verse) + { + if ($verse->verse == $verses[0]) + { + $add = true; + } + elseif (!isset($verses[1])) + { + $add = false; + } + + if ($add) + { + $text[$verse->verse] = $this->stringHelper->splitToWords(trim($verse->text), false); + } + + if (isset($verses[1]) && $verse->verse == $verses[1]) + { + $add = false; + } + } + + if (empty($text)) + { + return null; + } + + return $text; + } + + /** + * Get all valid verse numbers + * + * @param array $verses The verse range + * + * @return array|null The the valid verses + * @since 2.0.1 + */ + private function validVerseNumbers(array $range): ?array + { + if(count($range) == 1) + { + return $range; + } + elseif(count($range) == 2) + { + // sort the array in ascending order to make sure the range goes from lower to higher + sort($range); + + return range($range[0], $range[1]); + } + + return null; + } + + /** + * Generates a cache key based on the abbreviation, book, chapter, and verses + * + * @param string $abbreviation The translation abbreviation. + * @param int $book The book number. + * @param int $chapter The chapter number. + * @param string $verses The selected verses. + * + * @return string The generated cache key. + * @since 2.0.1 + */ + private function generateCacheKey($abbreviation, $book, int $chapter, string $verses): string + { + return $abbreviation . '_' . $book . '_' . $chapter . '_' . $verses; + } +} + diff --git a/libraries/jcb_powers/VDM.Joomla.GetBible/src/Data/Word.php b/libraries/jcb_powers/VDM.Joomla.GetBible/src/Data/Word.php new file mode 100644 index 0000000..0c80681 --- /dev/null +++ b/libraries/jcb_powers/VDM.Joomla.GetBible/src/Data/Word.php @@ -0,0 +1,391 @@ + + * @git GetBible + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ + +namespace VDM\Joomla\GetBible\Data; + + +use VDM\Joomla\GetBible\Data\Verse; +use VDM\Joomla\GetBible\Openai\Config; +use VDM\Joomla\GetBible\Data\Prompt; + + +/** + * The GetBible Word Data + * + * @since 2.0.1 + */ +final class Word +{ + /** + * The Verse class + * + * @var Verse + * @since 2.0.1 + */ + protected Verse $verse; + + /** + * The Config class + * + * @var Config + * @since 2.0.1 + */ + protected Config $config; + + /** + * The Prompt class + * + * @var Prompt + * @since 2.0.1 + */ + protected Prompt $prompt; + + /** + * The words + * + * @var array + * @since 2.0.1 + */ + protected array $words = []; + + /** + * The check if words are sequential + * + * @var array + * @since 2.0.1 + */ + protected array $sequential = []; + + /** + * The active verses + * + * @var array|null + * @since 2.0.1 + */ + protected ?array $verses = null; + + /** + * The valid verse numbers + * + * @var array|null + * @since 2.0.1 + */ + protected ?array $valid = null; + + /** + * Constructor + * + * @param Verse $verse The verse object. + * @param Config $config The config object. + * @param Prompt $prompt The prompt object. + * + * @since 2.0.1 + */ + public function __construct(Verse $verse, Config $config, Prompt $prompt) + { + $this->verse = $verse; + $this->config = $config; + $this->prompt = $prompt; + } + + /** + * Get the word number/s + * + * @return string The word number/s + * @since 2.0.1 + */ + public function getNumber(): string + { + $word = $this->get(); + return $word ? $word->number ?? '' : ''; + } + + /** + * Get the word text + * + * @return string The verse text + * @since 2.0.1 + */ + public function getText(): string + { + $word = $this->get(); + return $word ? $word->text ?? '' : ''; + } + + /** + * Get the words + * + * @return object|null True on success + * @since 2.0.1 + */ + private function get(): ?object + { + $abbreviation = $this->config->get('translation'); + $book = $this->config->get('book'); + $chapter = $this->config->get('chapter'); + $verse = $this->config->get('verse'); + $words = $this->config->get('words'); + + if (empty($abbreviation) || empty($book) || empty($chapter) || empty($verse) || empty($words)) + { + return null; + } + + $cacheKey = $this->generateCacheKey($abbreviation, $book, $chapter, $verse, $words); + + if (isset($this->words[$cacheKey])) + { + return $this->words[$cacheKey]; + } + + return $this->loadWordData($cacheKey, $verse, $words); + } + + /** + * Loads the word data + * + * @param string $cacheKey The cache key. + * @param string $verses The selected verses. + * @param string $words The selected words. + * + * @return object|null The loaded word data, or null if not found or an error occurred. + * @since 2.0.1 + */ + private function loadWordData(string $cacheKey, string $verses, string $words): ?object + { + $this->valid = $this->verse->getValid(); + $this->verses = $this->verse->getVerse(); + + if (empty($this->verses) || empty($this->valid)) + { + $this->words[$cacheKey] = null; + + return null; + } + + $data = new \stdClass(); + + $data->number_array = $this->selectedWordNumbers($verses, $words); + + if (empty($data->number_array)) + { + $this->words[$cacheKey] = null; + + return null; + } + + $data->number = $this->selectedWordNumbersToString($data->number_array); + + $data->text_array = $this->selectedWord($data->number_array); + + if (empty($data->text_array)) + { + $this->words[$cacheKey] = null; + + return null; + } + + $data->text = $this->selectedWordToString($data->text_array); + + $this->words[$cacheKey] = $data; + + return $this->words[$cacheKey]; + } + + /** + * Build word number array from verse and words. + * + * @param string $verse The verse selected. + * @param string $words The words words. + * + * @return array The word number array. + * @since 2.0.1 + */ + private function selectedWordNumbers(string $verse, string $words): array + { + $verse = $this->splitAndTrim($verse); + $words = $this->splitAndTrim($words); + + $array = []; + $integration = $this->prompt->getIntegration(); + $this->sequential = []; + + foreach ($verse as $key => $verse) + { + if (isset($words[$key]) && in_array($verse, $this->valid) && + $this->isValidWordNumber($verse, $words[$key])) + { + $array[$verse][] = $words[$key]; + if ($integration == 1) + { + break; + } + } + } + + return $array; + } + + /** + * Converts word number array to string. + * + * @param array $wordNumberArray The word number array. + * + * @return string The word number string. + * @since 2.0.1 + */ + private function selectedWordNumbersToString(array $wordNumberArray): string + { + $word_number = []; + + if (count($wordNumberArray) == 1) + { + $word_number[] = implode(',', array_values($wordNumberArray)[0]); + } + else + { + foreach ($wordNumberArray as $verse => $words) + { + $word_number[] = $verse . ':' . implode(',', $words); + } + } + + return implode(';', $word_number); + } + + /** + * Build word array from verse and words. + * + * @param array $words The words array. + * + * @return array The word array. + * @since 2.0.1 + */ + private function selectedWord(array $words): array + { + $word_array = []; + foreach ($words as $verse => $word_numbers) + { + foreach ($word_numbers as $word) + { + if (isset($this->verses[$verse][$word])) + { + $word_array[$verse][] = $this->verses[$verse][$word]; + } + } + } + + return $word_array; + } + + /** + * Converts word array to string. + * + * @param array $wordArray The word array. + * + * @return string The word string. + * @since 2.0.1 + */ + private function selectedWordToString(array $wordArray): string + { + $word_number = []; + + foreach ($wordArray as $verse => $words) + { + $word_number[] = implode(' ', $words); + } + + return implode(' ', $word_number); + } + + /** + * Split string by '-' and trim each element. + * + * @param string $str The string to be split. + * + * @return array The splitted and trimmed array. + * @since 2.0.1 + */ + private function splitAndTrim(string $str): array + { + if (strpos($str, '-') !== false) + { + $array = array_map('trim', explode('-', $str)); + + sort($array); + + return $array; + } + + return [trim($str)]; + } + + /** + * Check if a word exist in a verse + * + * @param int $verseNumber The verse number. + * @param int $wordNumber The word number. + * + * @return bool True on success + * @since 2.0.1 + */ + private function isValidWordNumber(int $verseNumber, int $wordNumber): bool + { + // we add the next word number to check sequential selection of words + $this->sequential[$verseNumber][$wordNumber] = $wordNumber; + if (count($this->sequential[$verseNumber]) > 1 && !$this->isSequential($this->sequential[$verseNumber])) + { + return false; + } + + return isset($this->verses[$verseNumber][$wordNumber]); + } + + /** + * Check if an array values is sequential. + * + * @param array $arr The number array. + * + * @return bool true if sequential + * @since 2.0.1 + */ + private function isSequential(array $arr): bool + { + $arr = array_values($arr); // Reset keys + for ($i = 0, $len = count($arr) - 1; $i < $len; $i++) + { + if ($arr[$i] + 1 !== $arr[$i + 1]) + { + return false; + } + } + + return true; + } + + /** + * Generates a cache key based on the abbreviation, book, chapter, verses, and words + * + * @param string $abbreviation The translation abbreviation. + * @param int $book The book number. + * @param int $chapter The chapter number. + * @param string $verses The selected verses. + * @param string $words The selected words. + * + * @return string The generated cache key. + * @since 2.0.1 + */ + private function generateCacheKey($abbreviation, $book, int $chapter, string $verses, string $words): string + { + return $abbreviation . '_' . $book . '_' . $chapter . '_' . $verses . '_' . $words; + } +} + diff --git a/libraries/jcb_powers/VDM.Joomla.GetBible/src/Data/index.html b/libraries/jcb_powers/VDM.Joomla.GetBible/src/Data/index.html new file mode 100644 index 0000000..fa6d84e --- /dev/null +++ b/libraries/jcb_powers/VDM.Joomla.GetBible/src/Data/index.html @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/libraries/jcb_powers/VDM.Joomla.GetBible/src/Database/Insert.php b/libraries/jcb_powers/VDM.Joomla.GetBible/src/Database/Insert.php new file mode 100644 index 0000000..010bac0 --- /dev/null +++ b/libraries/jcb_powers/VDM.Joomla.GetBible/src/Database/Insert.php @@ -0,0 +1,161 @@ + + * @git GetBible + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ + +namespace VDM\Joomla\GetBible\Database; + + +use VDM\Joomla\GetBible\Model\Upsert as Model; +use VDM\Joomla\Database\Insert as Database; + + +/** + * GetBible Database Insert + * + * @since 2.0.1 + */ +final class Insert +{ + /** + * Model + * + * @var Model + * @since 2.0.1 + */ + protected Model $model; + + /** + * Database + * + * @var Database + * @since 2.0.1 + */ + protected Database $database; + + /** + * Constructor + * + * @param Model $model The set model object. + * @param Database $database The insert database object. + * + * @since 2.0.1 + */ + public function __construct(Model $model, Database $database) + { + $this->model = $model; + $this->database = $database; + } + + /** + * Insert a value to a given table + * Example: $this->value(Value, 'value_key', 'table_name'); + * + * @param mixed $value The field value + * @param string $field The field key + * @param string $table Target table + * + * @return bool + * @since 2.0.1 + */ + public function value($value, string $field, string $table): bool + { + // build the array + $item = []; + $item[$field] = $value; + + // Insert the column of this table + return $this->row($item, $table); + } + + /** + * Insert single row with multiple values to a given table + * Example: $this->item(Array, 'table_name'); + * + * @param array $item The item to save + * @param string $table Target table + * + * @return bool + * @since 2.0.1 + */ + public function row(array $item, string $table): bool + { + // check if array could be modelled + if (($item = $this->model->row($item, $table)) !== null) + { + // Insert the column of this table + return $this->database->row($item, $table); + } + return false; + } + + /** + * Insert multiple rows to a given table + * Example: $this->items(Array, 'table_name'); + * + * @param array|null $items The items updated in database (array of arrays) + * @param string $table Target table + * + * @return bool + * @since 2.0.1 + */ + public function rows(?array $items, string $table): bool + { + // check if arrays could be modelled + if (($items = $this->model->rows($items, $table)) !== null) + { + // Insert the column of this table + return $this->database->rows($items, $table); + } + return false; + } + + /** + * Insert single item with multiple values to a given table + * Example: $this->item(Object, 'table_name'); + * + * @param object $item The item to save + * @param string $table Target table + * + * @return bool + * @since 2.0.1 + */ + public function item(object $item, string $table): bool + { + // check if object could be modelled + if (($item = $this->model->item($item, $table)) !== null) + { + // Insert the column of this table. + return $this->database->item($item, $table); + } + return false; + } + + /** + * Insert multiple items to a given table + * Example: $this->items(Array, 'table_name'); + * + * @param array|null $items The items updated in database (array of objects) + * @param string $table Target table + * + * @return bool + * @since 2.0.1 + */ + public function items(?array $items, string $table): bool + { + // check if object could be modelled + if (($items = $this->model->items($items, $table)) !== null) + { + // Insert the column of this table. + return $this->database->items($items, $table); + } + return false; + } +} + diff --git a/libraries/jcb_powers/VDM.Joomla.GetBible/src/Database/Load.php b/libraries/jcb_powers/VDM.Joomla.GetBible/src/Database/Load.php new file mode 100644 index 0000000..86ba1ee --- /dev/null +++ b/libraries/jcb_powers/VDM.Joomla.GetBible/src/Database/Load.php @@ -0,0 +1,262 @@ + + * @git GetBible + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ + +namespace VDM\Joomla\GetBible\Database; + + +use VDM\Joomla\GetBible\Table; +use VDM\Joomla\GetBible\Model\Load as Model; +use VDM\Joomla\Database\Load as Database; + + +/** + * GetBible Database Load + * + * @since 2.0.1 + */ +final class Load +{ + /** + * Search Table + * + * @var Table + * @since 2.0.1 + */ + protected Table $table; + + /** + * Model Load + * + * @var Model + * @since 2.0.1 + */ + protected Model $model; + + /** + * Database Load + * + * @var Database + * @since 2.0.1 + */ + protected Database $load; + + /** + * Constructor + * + * @param Table $table The core table object. + * @param Model $model The model object. + * @param Database $load The database object. + * + * @since 2.0.1 + */ + public function __construct(Table $table, Model $model, Database $load) + { + $this->table = $table; + $this->model = $model; + $this->load = $load; + } + + /** + * Get a value from a given table + * Example: $this->value( + * [ + * 'abbreviation' => 'kjv', + * 'book_nr' => 62, + * 'chapter' => 3, + * 'verse' => 16 + * ], 'value_key', 'table_name' + * ); + * + * @param array $keys The item keys + * @param string $field The field key + * @param string $table The table + * + * @return mixed + * @since 2.0.1 + */ + public function value(array $keys, string $field, string $table) + { + // check if this is a valid table + if ($this->table->exist($table, $field)) + { + return $this->model->value( + $this->load->value( + ["a.${field}" => $field], + ['a' => $table], + $this->prefix($keys) + ), + $field, + $table + ); + } + + return null; + } + + /** + * Get the max value based on a filtered result from a given table + * Example: $this->max( + * [ + * 'abbreviation' => 'kjv', + * 'book_nr' => 62, + * 'chapter' => 3, + * 'verse' => 16 + * ], 'value_key', 'table_name' + * ); + * + * @param array $filter The filter keys + * @param string $field The field key + * @param string $table The table + * + * @return int|null + * @since 2.0.1 + */ + public function max(array $filter, string $field, string $table): ?int + { + // check if this is a valid table + if ($this->table->exist($table, $field)) + { + return $this->load->max( + $field, + ['a' => $table], + $this->prefix($filter) + ); + } + + return null; + } + + /** + * Count the number of items based on filter result from a given table + * Example: $this->count( + * [ + * 'abbreviation' => 'kjv', + * 'book_nr' => 62, + * 'chapter' => 3, + * 'verse' => 16 + * ], 'table_name' + * ); + * + * @param array $filter The filter keys + * @param string $table The table + * + * @return int|null + * @since 2.0.1 + */ + public function count(array $filter, string $table): ?int + { + // check if this is a valid table + if ($this->table->exist($table)) + { + return $this->load->count( + ['a' => $table], + $this->prefix($filter) + ); + } + + return null; + } + + /** + * Get values from a given table + * Example: $this->item( + * [ + * 'abbriviation' => 'kjv', + * 'book_nr' => 62, + * 'chapter' => 3, + * 'verse' => 16 + * ], 'table_name' + * ); + * + * @param array $keys The item keys + * @param string $table The table + * + * @return object|null + * @since 2.0.1 + */ + public function item(array $keys, string $table): ?object + { + // check if this is a valid table + if ($this->table->exist($table)) + { + return $this->model->item( + $this->load->item( + ['all' => 'a.*'], + ['a' => $table], + $this->prefix($keys) + ), + $table + ); + } + + return null; + } + + /** + * Get values from a given table + * Example: $this->items( + * [ + * 'abbriviation' => [ + * 'operator' => 'IN', + * 'value' => ['kjv', 'aov'] + * ], + * 'book_nr' => 62, + * 'chapter' => 3, + * 'verse' => [ + * 'operator' => 'IN', + * 'value' => [16, 17, 18] + * ] + * ], 'table_name' + * ); + * Example: $this->items($ids, 'table_name'); + * + * @param array $keys The item keys + * @param string $table The table + * + * @return array|null + * @since 2.0.1 + */ + public function items(array $keys, string $table): ?array + { + // check if this is a valid table + if ($this->table->exist($table)) + { + return $this->model->items( + $this->load->items( + ['all' => 'a.*'], ['a' => $table], $this->prefix($keys) + ), + $table + ); + } + + return null; + } + + /** + * Add prefix to the keys + * + * @param array $keys The query keys + * + * @return array + * @since 2.0.1 + */ + private function prefix(array &$keys): array + { + // update the key values + $bucket = []; + foreach ($keys as $k => $v) + { + $bucket['a.' . $k] = $v; + } + return $bucket; + } +} + diff --git a/libraries/jcb_powers/VDM.Joomla.GetBible/src/Database/Update.php b/libraries/jcb_powers/VDM.Joomla.GetBible/src/Database/Update.php new file mode 100644 index 0000000..dfa4101 --- /dev/null +++ b/libraries/jcb_powers/VDM.Joomla.GetBible/src/Database/Update.php @@ -0,0 +1,168 @@ + + * @git GetBible + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ + +namespace VDM\Joomla\GetBible\Database; + + +use VDM\Joomla\GetBible\Model\Upsert as Model; +use VDM\Joomla\Database\Update as Database; + + +/** + * The GetBible Database Update + * + * @since 2.0.1 + */ +final class Update +{ + /** + * Model + * + * @var Model + * @since 2.0.1 + */ + protected Model $model; + + /** + * Database + * + * @var Database + * @since 2.0.1 + */ + protected Database $database; + + /** + * Constructor + * + * @param Model $model The set model object. + * @param Database $database The update database object. + * + * @since 2.0.1 + */ + public function __construct(Model $model, Database $database) + { + $this->model = $model; + $this->database = $database; + } + + /** + * Update a value to a given table + * Example: $this->value(Value, 'value_key', 'id', 'table_name'); + * + * @param mixed $value The field value + * @param string $field The field key + * @param string $keyValue The key value + * @param string $key The key name + * @param string $table Target table + * + * @return bool + * @since 2.0.1 + */ + public function value($value, string $field, string $keyValue, string $key, string $table): bool + { + // build the array + $item = []; + $item[$key] = $keyValue; + $item[$field] = $value; + + // Update the column of this table using guid as the primary key. + return $this->row($item, $key, $table); + } + + /** + * Update single row with multiple values to a given table + * Example: $this->item(Array, 'id', 'table_name'); + * + * @param array $item The item to save + * @param string $key The key name + * @param string $table Target table + * + * @return bool + * @since 2.0.1 + */ + public function row(array $item, string $key, string $table): bool + { + // check if object could be modelled + if (($item = $this->model->row($item, $table)) !== null) + { + // Update the column of this table using $key as the primary key. + return $this->database->row($item, $key, $table); + } + return false; + } + + /** + * Update multiple rows to a given table + * Example: $this->items(Array, 'id', 'table_name'); + * + * @param array|null $items The items updated in database (array of arrays) + * @param string $key The key name + * @param string $table Target table + * + * @return bool + * @since 2.0.1 + */ + public function rows(?array $items, string $key, string $table): bool + { + // check if object could be modelled + if (($items = $this->model->rows($items, $table)) !== null) + { + // Update the column of this table using $key as the primary key. + return $this->database->rows($items, $key, $table); + } + return false; + } + + /** + * Update single item with multiple values to a given table + * Example: $this->item(Object, 'id', 'table_name'); + * + * @param object $item The item to save + * @param string $key The key name + * @param string $table Target table + * + * @return bool + * @since 2.0.1 + */ + public function item(object $item, string $key, string $table): bool + { + // check if object could be modelled + if (($item = $this->model->item($item, $table)) !== null) + { + // Update the column of this table using $key as the primary key. + return $this->database->item($item, $key, $table); + } + return false; + } + + /** + * Update multiple items to a given table + * Example: $this->items(Array, 'id', 'table_name'); + * + * @param array|null $items The items updated in database (array of objects) + * @param string $key The key name + * @param string $table Target table + * + * @return bool + * @since 2.0.1 + */ + public function items(?array $items, string $key, string $table): bool + { + // check if object could be modelled + if (($items = $this->model->items($items, $table)) !== null) + { + // Update the column of this table using $key as the primary key. + return $this->database->items($items, $key, $table); + } + return false; + } +} + diff --git a/libraries/jcb_powers/VDM.Joomla.GetBible/src/Database/index.html b/libraries/jcb_powers/VDM.Joomla.GetBible/src/Database/index.html new file mode 100644 index 0000000..fa6d84e --- /dev/null +++ b/libraries/jcb_powers/VDM.Joomla.GetBible/src/Database/index.html @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/libraries/jcb_powers/VDM.Joomla.GetBible/src/Factory.php b/libraries/jcb_powers/VDM.Joomla.GetBible/src/Factory.php new file mode 100644 index 0000000..4bdbfb9 --- /dev/null +++ b/libraries/jcb_powers/VDM.Joomla.GetBible/src/Factory.php @@ -0,0 +1,84 @@ + + * @git GetBible + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ + +namespace VDM\Joomla\GetBible; + + +use Joomla\DI\Container; +use VDM\Joomla\GetBible\Service\Api; +use VDM\Joomla\GetBible\Service\Utilities; +use VDM\Joomla\GetBible\Service\App; +use VDM\Joomla\GetBible\Service\Model; +use VDM\Joomla\GetBible\Service\Database; +use VDM\Joomla\Interfaces\FactoryInterface; + + +/** + * GetBible Factory + * + * @since 2.0.1 + */ +abstract class Factory implements FactoryInterface +{ + /** + * Global Package Container + * + * @var Container + * @since 2.0.1 + **/ + protected static $container = null; + + /** + * Get any class from the package container + * + * @param string $key The container class key + * + * @return Mixed + * @since 2.0.1 + */ + public static function _($key) + { + return self::getContainer()->get($key); + } + + /** + * Get the global package container + * + * @return Container + * @since 2.0.1 + */ + public static function getContainer(): Container + { + if (!self::$container) + { + self::$container = self::createContainer(); + } + + return self::$container; + } + + /** + * Create a container object + * + * @return Container + * @since 2.0.1 + */ + protected static function createContainer(): Container + { + return (new Container()) + ->registerServiceProvider(new Utilities()) + ->registerServiceProvider(new Api()) + ->registerServiceProvider(new App()) + ->registerServiceProvider(new Model()) + ->registerServiceProvider(new Database()); + } +} + diff --git a/libraries/jcb_powers/VDM.Joomla.GetBible/src/Linker.php b/libraries/jcb_powers/VDM.Joomla.GetBible/src/Linker.php new file mode 100644 index 0000000..ec68777 --- /dev/null +++ b/libraries/jcb_powers/VDM.Joomla.GetBible/src/Linker.php @@ -0,0 +1,424 @@ + + * @git GetBible + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ + +namespace VDM\Joomla\GetBible; + + +use Joomla\CMS\User\UserHelper; +use Joomla\CMS\Language\Text; +use VDM\Joomla\GetBible\Database\Load; +use VDM\Joomla\GetBible\Database\Insert; +use VDM\Joomla\GetBible\Database\Update; +use VDM\Joomla\GetBible\Utilities\SessionHelper as Session; +use VDM\Joomla\Utilities\GuidHelper; + + +/** + * The GetBible Linker + * + * @since 2.0.1 + */ +final class Linker +{ + /** + * The Load class + * + * @var Load + * @since 2.0.1 + */ + protected Load $load; + + /** + * The Insert class + * + * @var Insert + * @since 2.0.1 + */ + protected Insert $insert; + + /** + * The Update class + * + * @var Update + * @since 2.0.1 + */ + protected Update $update; + + /** + * The Session class + * + * @var Session + * @since 2.0.1 + */ + protected Session $session; + + /** + * The Share His Word Trigger + * + * @var bool + * @since 2.0.1 + */ + protected bool $trigger = false; + + /** + * Constructor + * + * @param Load $load The load object. + * @param Insert $insert The insert object. + * @param Update $update The update object. + * @param Session $session The session object. + * + * @since 2.0.1 + */ + public function __construct( + Load $load, + Insert $insert, + Update $update, + Session $session) + { + $this->load = $load; + $this->insert = $insert; + $this->update = $update; + $this->session = $session; + } + + /** + * The Share His Word Trigger + * + * @return bool True on success + * @since 2.0.1 + **/ + public function share(): bool + { + return $this->trigger; + } + + /** + * Get Linker that has Access + * + * @return string|null Linker GUID that has access + * @since 2.0.1 + **/ + public function get(): ?string + { + if (($linker = $this->session->get('getbible_active_linker_guid', null)) === null) + { + return null; + } + + if (($access = $this->session->get("getbible_active_{$linker}", null)) === null + || $access !== 'valid_access') + { + return null; + } + + return $linker; + } + + /** + * Get active Linker + * + * @param bool $setup The setup switch + * + * @return string|null Linker GUID that has access + * @since 2.0.1 + **/ + public function active(bool $setup = true): ?string + { + if (($linker = $this->session->get('getbible_active_linker_guid', null)) !== null) + { + return $linker; + } + + if ($setup) + { + $guid = (string) GuidHelper::get(); + $this->session->set('getbible_active_linker_guid', $guid); + + return $guid; + } + + return null; + } + + /** + * Check if a Linker is valid active linker + * + * @param string $linker The linker GUID value + * + * @return bool True if active valid linker + * @since 2.0.1 + **/ + public function valid(string $linker): bool + { + // is only valid if this linker has an active password + if (GuidHelper::valid($linker) && ($password_name = $this->load->value( + ['linker' => $linker, 'published' => 1], + 'name', 'password' + )) !== null) + { + return true; + } + + return false; + } + + /** + * The Share His Word Trigger + * + * @param string $linker The linker GUID value + * + * @return bool True on success + * @since 2.0.1 + **/ + public function trigger(string $linker): bool + { + if (!$this->set($linker)) + { + return false; + } + + $this->trigger = true; + + return true; + } + + /** + * Set Active Linker + * + * @param string $linker The linker GUID value + * + * @return bool True on success + * @since 2.0.1 + **/ + public function set(string $linker): bool + { + if (!GuidHelper::valid($linker)) + { + return false; + } + + $this->session->set('getbible_active_linker_guid', $linker); + + return true; + } + + /** + * Set Access + * + * @param string $linker The linker GUID value + * @param string $pass The linker pass value + * @param string|null $oldPass The linker old pass value + * + * @return array|null The success or error details + * @since 2.0.1 + **/ + public function access(string $linker, string $pass, ?string $oldPass): ?array + { + // trim all empty space + $pass = trim($pass); + + // password to short + if (strlen($pass) <= 3) + { + return [ + 'error' => Text::_('COM_GETBIBLE_PASSWORD_TO_SHORT_USE_A_LONGER_PASSWORD') + ]; + } + // linker not valid GUID + elseif (!GuidHelper::valid($linker)) + { + return [ + 'error' => Text::_('COM_GETBIBLE_INVALID_SESSION_KEY_VALUE') + ]; + } + + // get linker + if (($_linker = $this->load->item(['guid' => $linker],'linker')) !== null) + { + // publish the linker if needed + if ($_linker->published != 1 && $this->update->value(1, 'published', $_linker->id, 'id', 'linker')) + { + return [ + 'error' => Text::_('COM_GETBIBLE_ACCESS_ALREADY_EXIST_BUT_COULD_NOT_BE_REACTIVATED') + ]; + } + + if (!empty($oldPass)) + { + + $oldPass = trim($oldPass); + + if (($guid = $this->getPassGuid($linker, $oldPass)) === null) + { + return [ + 'error' => Text::_('COM_GETBIBLE_INCORRECT_FAVOURITE_VERSE_SELECTED') + ]; + } + + if (!$this->setPassword($linker, $pass)) + { + return [ + 'error' => Text::_('COM_GETBIBLE_FAVOURITE_VERSE_COULD_NOT_BE_CHANGED') + ]; + } + + // unpublished the old pass word only if new password was set + $this->update->value(-2, 'published', $guid, 'guid', 'password'); + } + elseif (!$this->hasAccess($linker, $pass)) + { + return [ + 'error' => Text::_('COM_GETBIBLE_INCORRECT_FAVOURITE_VERSE_SELECTED') + ]; + } + } + elseif (!$this->setLinker($linker)) + { + return [ + 'error' => Text::_('COM_GETBIBLE_SESSION_KEY_COULD_NOT_BE_STORED') + ]; + } + elseif (!$this->setPassword($linker, $pass)) + { + return [ + 'error' => Text::_('COM_GETBIBLE_FAVOURITE_VERSE_COULD_NOT_BE_STORED') + ]; + } + elseif (($_linker = $this->load->item(['guid' => $linker],'linker')) === null) + { + return null; + } + + $_linker->published = 1; + $_linker->success = Text::_('COM_GETBIBLE_FAVOURITE_VERSE_SUCCESSFULLY_SET'); + + // add to session + $this->session->set('getbible_active_linker_guid', $linker); + $this->session->set("getbible_active_{$linker}", 'valid_access'); + + return (array) $_linker; + } + + /** + * Has Access + * + * @param string $linker The linker GUID value + * @param string $pass The linker pass value + * + * @return bool True on success + * @since 2.0.1 + **/ + private function hasAccess(string $linker, string $pass): bool + { + if (($password = $this->getPassword($linker, $pass)) !== null) + { + return true; + } + + return false; + } + + /** + * Get Password GUID + * + * @param string $linker The linker GUID value + * @param string $pass The linker pass value + * + * @return string|null The GUID on success + * @since 2.0.1 + **/ + private function getPassGuid(string $linker, string $pass): ?string + { + if (($password = $this->getPassword($linker, $pass)) !== null) + { + return $password->guid; + } + + return null; + } + + /** + * Get Password + * + * @param string $linker The linker GUID value + * @param string $pass The linker pass value + * + * @return object|null The GUID on success + * @since 2.0.1 + **/ + private function getPassword(string $linker, string $pass): ?object + { + if (strlen($pass) > 3 && ($passwords = $this->load->items( + ['linker' => $linker, 'published' => 1], + 'password' + )) !== null) + { + foreach ($passwords as $password) + { + if (UserHelper::verifyPassword($pass, $password->password)) + { + return $password; + } + } + } + + return null; + } + + /** + * Set Linker + * + * @param string $linker The linker GUID value + * + * @return bool True on success + * @since 2.0.1 + **/ + private function setLinker(string $linker): bool + { + return $this->insert->row([ + 'name' => 'Default-Name', + 'guid' => $linker + ], 'linker'); + } + + /** + * Set Password + * + * @param string $linker The linker GUID value + * @param string $pass The linker pass value + * + * @return bool True on success + * @since 2.0.1 + **/ + private function setPassword(string $linker, string $pass): bool + { + if (strlen($pass) <= 3) + { + return false; + } + + $guid = (string) GuidHelper::get(); + while (!GuidHelper::valid($guid, 'password', 0, 'getbible')) + { + // must always be set + $guid = (string) GuidHelper::get(); + } + + return $this->insert->row([ + 'name' => 'Favourite-Verse', + 'linker' => $linker, + 'password' => UserHelper::hashPassword($pass), + 'guid' => $guid + ], 'password'); + } +} + diff --git a/libraries/jcb_powers/VDM.Joomla.GetBible/src/Loader.php b/libraries/jcb_powers/VDM.Joomla.GetBible/src/Loader.php new file mode 100644 index 0000000..1598913 --- /dev/null +++ b/libraries/jcb_powers/VDM.Joomla.GetBible/src/Loader.php @@ -0,0 +1,83 @@ + + * @git GetBible + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ + +namespace VDM\Joomla\GetBible; + + +use Joomla\Registry\Registry; +use VDM\Joomla\GetBible\Database\Load; +use VDM\Joomla\GetBible\Watcher; + + +/** + * The GetBible Loader of Scripture in Content + * + * @since 2.0.1 + */ +final class Loader +{ + /** + * The Load class + * + * @var Load + * @since 2.0.1 + */ + protected Load $load; + + /** + * The Watcher class + * + * @var Watcher + * @since 2.0.1 + */ + protected Watcher $watcher; + + /** + * The Plugin Params class + * + * @var Registry + * @since 2.0.1 + */ + protected Registry $plugin; + + /** + * Constructor + * + * @param Load $load The load object. + * @param Watcher $watcher The watcher object. + * + * @since 2.0.1 + */ + public function __construct( + Load $load, + Watcher $watcher) + { + $this->load = $load; + $this->watcher = $watcher; + } + + /** + * The setting of Scripture into Content starts here + * + * @param object &$row The article object. Note $article->text is also available + * @param Registry $plugin The plugin params + * + * @return void + * @since 2.0.1 + */ + public function set(&$row, Registry $plugin): bool + { + $this->plugin = $plugin; + + return; + } +} + diff --git a/libraries/jcb_powers/VDM.Joomla.GetBible/src/Model/Load.php b/libraries/jcb_powers/VDM.Joomla.GetBible/src/Model/Load.php new file mode 100644 index 0000000..802f489 --- /dev/null +++ b/libraries/jcb_powers/VDM.Joomla.GetBible/src/Model/Load.php @@ -0,0 +1,160 @@ + + * @git GetBible + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ + +namespace VDM\Joomla\GetBible\Model; + + +use VDM\Joomla\Abstraction\BaseConfig as Config; +use VDM\Joomla\GetBible\Table; +use VDM\Joomla\Utilities\StringHelper; +use VDM\Joomla\Utilities\ArrayHelper; +use VDM\Joomla\Utilities\ObjectHelper; +use VDM\Joomla\Interfaces\ModelInterface; +use VDM\Joomla\Abstraction\Model; + + +/** + * The GetBible Model to Load + * + * @since 2.0.1 + */ +final class Load extends Model implements ModelInterface +{ + /** + * GetBible Config + * + * @var Config + * @since 2.0.1 + */ + protected Config $config; + + /** + * Constructor + * + * @param Config $config The getBible config object. + * @param Table $table The getBible table object. + * + * @since 2.0.1 + */ + public function __construct(Config $config, Table $table) + { + parent::__construct($table); + + $this->config = $config; + } + + /** + * Model the value + * Example: $this->value(value, 'field_key', 'table_name'); + * + * @param mixed $value The value to model + * @param string $field The field key + * @param string|null $table The table + * + * @return mixed + * @since 2.0.1 + */ + public function value($value, string $field, ?string $table = null) + { + // set the table name + if (empty($table)) + { + $table = $this->getTable(); + } + + // check if this is a valid table + if (($store = $this->table->get($table, $field, 'store')) !== null) + { + // open the value based on the store method + switch($store) + { + case 'json': + $value = json_decode($value); + break; + } + + // Model Distribution History + if ($table === 'translation' && $field === 'distribution_history') + { + $value = $this->modelDistributionHistory($value); + } + } + + return $value; + } + + /** + * Validate before the value is modelled + * + * @param mixed $value The field value + * @param string|null $field The field key + * @param string|null $table The table + * + * @return bool + * @since 2.0.1 + */ + protected function validateBefore(&$value, ?string $field = null, ?string $table = null): bool + { + // only strings or numbers allowed + if (StringHelper::check($value) || is_numeric($value)) + { + return true; + } + // remove empty values + return false; + } + + /** + * Validate after the value is modelled + * + * @param mixed $value The field value + * @param string|null $field The field key + * @param string|null $table The table + * + * @return bool + * @since 2.0.1 + */ + protected function validateAfter(&$value, ?string $field = null, ?string $table = null): bool + { + // check values + if (StringHelper::check($value) || ArrayHelper::check($value, true) || ObjectHelper::check($value) || is_numeric($value)) + { + return true; + } + // remove empty values + return false; + } + + /** + * Get the current active table + * + * @return string + * @since 2.0.1 + */ + protected function getTable(): string + { + return $this->config->table_name; + } + + /** + * Model Distribution History + * + * @param mixed $value The value to model + * + * @return mixed + * @since 2.0.1 + */ + public function modelDistributionHistory($value) + { + return $value; + } +} + diff --git a/libraries/jcb_powers/VDM.Joomla.GetBible/src/Model/Upsert.php b/libraries/jcb_powers/VDM.Joomla.GetBible/src/Model/Upsert.php new file mode 100644 index 0000000..5c53ea3 --- /dev/null +++ b/libraries/jcb_powers/VDM.Joomla.GetBible/src/Model/Upsert.php @@ -0,0 +1,159 @@ + + * @git GetBible + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ + +namespace VDM\Joomla\GetBible\Model; + + +use VDM\Joomla\Abstraction\BaseConfig as Config; +use VDM\Joomla\GetBible\Table; +use VDM\Joomla\Utilities\ObjectHelper; +use VDM\Joomla\Interfaces\ModelInterface; +use VDM\Joomla\Abstraction\Model; + + +/** + * The GetBible Model for both Update and Insert + * + * @since 2.0.1 + */ +final class Upsert extends Model implements ModelInterface +{ + /** + * GetBible Config + * + * @var Config + * @since 2.0.1 + */ + protected Config $config; + + /** + * Constructor + * + * @param Config $config The getBible config object. + * @param Table $table The getBible table object. + * + * @since 2.0.1 + */ + public function __construct(Config $config, Table $table) + { + parent::__construct($table); + + $this->config = $config; + } + + /** + * Model the value + * Example: $this->value(value, 'field_key', 'table_name'); + * + * @param mixed $value The value to model + * @param string $field The field key + * @param string|null $table The table + * + * @return mixed + * @since 2.0.1 + */ + public function value($value, string $field, ?string $table = null) + { + // set the table name + if (empty($table)) + { + $table = $this->getTable(); + } + + // check if this is a valid table + if (($store = $this->table->get($table, $field, 'store')) !== null) + { + // Model Distribution History + if ($table === 'translation' && $field === 'distribution_history') + { + $value = $this->modelDistributionHistory($value); + } + + // open the value based on the store method + switch($store) + { + case 'json': + $value = json_encode($value, JSON_FORCE_OBJECT); + break; + } + } + + return $value; + } + + /** + * Validate before the value is modelled + * + * @param mixed $value The field value + * @param string|null $field The field key + * @param string|null $table The table + * + * @return bool + * @since 2.0.1 + */ + protected function validateBefore(&$value, ?string $field = null, ?string $table = null): bool + { + // add all values + return true; + } + + /** + * Validate after the value is modelled + * + * @param mixed $value The field value + * @param string|null $field The field key + * @param string|null $table The table + * + * @return bool + * @since 2.0.1 + */ + protected function validateAfter(&$value, ?string $field = null, ?string $table = null): bool + { + // add all values + return true; + } + + /** + * Get the current active table + * + * @return string + * @since 2.0.1 + */ + protected function getTable(): string + { + return $this->config->table_name; + } + + /** + * Model Distribution History + * + * @param mixed $value The value to model + * + * @return mixed + * @since 2.0.1 + */ + public function modelDistributionHistory($value) + { + if (ObjectHelper::check($value)) + { + $n = 0; + $bucket = []; + foreach ($value as $version => $description) + { + $bucket["distribution_history$n"] = ['version' => $version, 'description' => $description]; + $n++; + } + return $bucket; + } + return ''; + } +} + diff --git a/libraries/jcb_powers/VDM.Joomla.GetBible/src/Model/index.html b/libraries/jcb_powers/VDM.Joomla.GetBible/src/Model/index.html new file mode 100644 index 0000000..fa6d84e --- /dev/null +++ b/libraries/jcb_powers/VDM.Joomla.GetBible/src/Model/index.html @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/libraries/jcb_powers/VDM.Joomla.GetBible/src/Note.php b/libraries/jcb_powers/VDM.Joomla.GetBible/src/Note.php new file mode 100644 index 0000000..b51a050 --- /dev/null +++ b/libraries/jcb_powers/VDM.Joomla.GetBible/src/Note.php @@ -0,0 +1,241 @@ + + * @git GetBible + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ + +namespace VDM\Joomla\GetBible; + + +use Joomla\CMS\Language\Text; +use VDM\Joomla\GetBible\Database\Load; +use VDM\Joomla\GetBible\Database\Insert; +use VDM\Joomla\GetBible\Database\Update; +use VDM\Joomla\GetBible\Linker; +use VDM\Joomla\Utilities\GuidHelper; + + +/** + * The GetBible Note + * + * @since 2.0.1 + */ +final class Note +{ + /** + * The Load class + * + * @var Load + * @since 2.0.1 + */ + protected Load $load; + + /** + * The Insert class + * + * @var Insert + * @since 2.0.1 + */ + protected Insert $insert; + + /** + * The Update class + * + * @var Update + * @since 2.0.1 + */ + protected Update $update; + + /** + * The Linker class + * + * @var Linker + * @since 2.0.1 + */ + protected Linker $linker; + + /** + * Constructor + * + * @param Load $load The load object. + * @param Insert $insert The insert object. + * @param Update $update The update object. + * @param Linker $linker The linker object. + * + * @since 2.0.1 + */ + public function __construct( + Load $load, + Insert $insert, + Update $update, + Linker $linker) + { + $this->load = $load; + $this->insert = $insert; + $this->update = $update; + $this->linker = $linker; + } + + /** + * Set a note + * + * @param int $book The book in which the note is made + * @param int $chapter The chapter in which the note is made + * @param int $verse The verse where the note is made + * @param string|null $note The note being made + * + * @return array|null Array of the note values on success + * @since 2.0.1 + **/ + public function set( + int $book, + int $chapter, + int $verse, + ?string $note + ): ?array + { + // make sure the linker has access + if (($linker = $this->linker->get()) === null) + { + return [ + 'error' => Text::_("COM_GETBIBLE_WITHOUT_SELECTING_THE_CORRECT_FAVOURITE_VERSE_YOU_CANT_PERFORM_THE_INITIAL_ACTION"), + 'access_required' => true + ]; + } + + // get note if it exists + if (($_note = $this->get($linker, $book, $chapter, $verse)) !== null) + { + // publish if not published + if ($_note->published != 1 && !$this->update->value(1, 'published', $_note->id, 'id', 'note')) + { + return [ + 'error' => Text::_('COM_GETBIBLE_NOTE_ALREADY_EXIST_BUT_COULD_NOT_BE_REACTIVATED') + ]; + } + + // update the note if needed + if ((!isset($_note->note) || $_note->note !== $note) && !$this->update->value($note, 'note', $_note->id, 'id', 'note')) + { + return [ + 'error' => Text::_('COM_GETBIBLE_NOTE_ALREADY_EXIST_BUT_COULD_NOT_UPDATE_THE_NOTE_TEXT') + ]; + } + + $_note->published = 1; + $_note->note = $note; + $_note->success = Text::_('COM_GETBIBLE_THE_NOTE_WAS_SUCCESSFULLY_UPDATED'); + return (array) $_note; + } + // create a new tag + elseif ($this->create($linker, $book, $chapter, $verse, $note) + && ($_note = $this->get($linker, $book, $chapter, $verse)) !== null) + { + $_note->success = Text::_('COM_GETBIBLE_THE_NOTE_WAS_SUCCESSFULLY_CREATED'); + return (array) $_note; + } + + return null; + } + + /** + * Delete a note + * + * @param string $note The note GUID value + * + * @return bool True on success + * @since 2.0.1 + **/ + public function delete(string $note): bool + { + // make sure the linker has access + if (($linker = $this->linker->get()) === null) + { + return false; + } + + // make sure the linker has access to delete this tag + if (($id = $this->load->value(['guid' => $note, 'linker' => $linker], 'id', 'note')) !== null && $id > 0) + { + return $this->update->value(-2, 'published', $id, 'id', 'note'); + } + + return false; + } + + /** + * Get a note + * + * @param string $linker The linker GUID value + * @param int $book The book in which the note is made + * @param int $chapter The chapter in which the note is made + * @param int $verse The verse where the note is made + * + * @return object|null Object of the note values on success + * @since 2.0.1 + **/ + private function get( + string $linker, + int $book, + int $chapter, + int $verse + ): ?object + { + // get note if it exist + if (($note = $this->load->item([ + 'linker' => $linker, + 'book_nr' => $book, + 'chapter' => $chapter, + 'verse' => $verse + ], 'note')) !== null) + { + return $note; + } + + return null; + } + + /** + * Create a note + * + * @param string $linker The linker GUID value + * @param int $book The book in which the note is made + * @param int $chapter The chapter in which the note is made + * @param int $verse The verse where the note is made + * @param string|null $note The note being created (allow empty notes) + * + * @return bool True on success + * @since 2.0.1 + **/ + private function create( + string $linker, + int $book, + int $chapter, + int $verse, + ?string $note + ): bool + { + $guid = (string) GuidHelper::get(); + while (!GuidHelper::valid($guid, 'note', 0, 'getbible')) + { + // must always be set + $guid = (string) GuidHelper::get(); + } + + return $this->insert->row([ + 'note' => $note ?? '', + 'access' => 0, + 'linker' => $linker, + 'book_nr' => $book, + 'chapter' => $chapter, + 'verse' => $verse, + 'guid' => $guid + ], 'note'); + } +} + diff --git a/libraries/jcb_powers/VDM.Joomla.GetBible/src/Openai.php b/libraries/jcb_powers/VDM.Joomla.GetBible/src/Openai.php new file mode 100644 index 0000000..8cc9fe9 --- /dev/null +++ b/libraries/jcb_powers/VDM.Joomla.GetBible/src/Openai.php @@ -0,0 +1,86 @@ + + * @git GetBible + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ + +namespace VDM\Joomla\GetBible; + + +use Joomla\DI\Container; +use VDM\Joomla\GetBible\Service\Openai as Api; +use VDM\Joomla\Openai\Service\Utilities; +use VDM\Joomla\GetBible\Service\Data; +use VDM\Joomla\GetBible\Service\AI; +use VDM\Joomla\GetBible\Service\Model; +use VDM\Joomla\GetBible\Service\Database; +use VDM\Joomla\Interfaces\FactoryInterface; + + +/** + * Openai Factory + * + * @since 3.2.0 + */ +abstract class Openai implements FactoryInterface +{ + /** + * Global Package Container + * + * @var Container + * @since 3.2.0 + **/ + protected static $container = null; + + /** + * Get any class from the package container + * + * @param string $key The container class key + * + * @return Mixed + * @since 3.2.0 + */ + public static function _($key) + { + return self::getContainer()->get($key); + } + + /** + * Get the global package container + * + * @return Container + * @since 3.2.0 + */ + public static function getContainer(): Container + { + if (!self::$container) + { + self::$container = self::createContainer(); + } + + return self::$container; + } + + /** + * Create a container object + * + * @return Container + * @since 3.2.0 + */ + protected static function createContainer(): Container + { + return (new Container()) + ->registerServiceProvider(new Api()) + ->registerServiceProvider(new Utilities()) + ->registerServiceProvider(new Data()) + ->registerServiceProvider(new AI()) + ->registerServiceProvider(new Model()) + ->registerServiceProvider(new Database()); + } +} + diff --git a/libraries/jcb_powers/VDM.Joomla.GetBible/src/Openai/Config.php b/libraries/jcb_powers/VDM.Joomla.GetBible/src/Openai/Config.php new file mode 100644 index 0000000..1c95a39 --- /dev/null +++ b/libraries/jcb_powers/VDM.Joomla.GetBible/src/Openai/Config.php @@ -0,0 +1,305 @@ + + * @git GetBible + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ + +namespace VDM\Joomla\GetBible\Openai; + + +use Joomla\CMS\Factory as JoomlaFactory; +use Joomla\Registry\Registry as JoomlaRegistry; +use Joomla\Input\Input; +use VDM\Joomla\Utilities\Component\Helper; +use VDM\Joomla\Abstraction\BaseConfig; + + +/** + * GetBible Openai Configurations + * + * @since 2.0.1 + */ +class Config extends BaseConfig +{ + /** + * Hold a JInput object for easier access to the input variables. + * + * @var Input + * @since 3.2.0 + */ + protected Input $input; + + /** + * The Params + * + * @var JoomlaRegistry + * @since 3.2.0 + */ + protected JoomlaRegistry $params; + + /** + * Constructor + * + * @param Input|null $input Input + * @param JoomlaRegistry|null $params The component parameters + * + * @throws \Exception + * @since 3.2.0 + */ + public function __construct(?Input $input = null, ?JoomlaRegistry $params = null) + { + $this->input = $input ?: JoomlaFactory::getApplication()->input; + $this->params = $params ?: Helper::getParams('com_getbible'); + + // run parent constructor + parent::__construct(); + } + + /** + * get Prompt GUID + * + * @return string|null The translation abbreviation + * @since 2.0.1 + */ + protected function getPrompt(): ?string + { + return $this->input->getString('guid'); + } + + /** + * get Translation Abbreviation + * + * @return string|null The translation abbreviation + * @since 2.0.1 + */ + protected function getTranslation(): ?string + { + return $this->input->getString('t') ?? $this->input->getString('version') ?? $this->input->getString('translation'); + } + + /** + * get Book Number + * + * @return int|null The book number + * @since 2.0.1 + */ + protected function getBook(): ?int + { + return $this->input->getInt('book'); + } + + /** + * get Chapter Number + * + * @return int|null The chapter number + * @since 2.0.1 + */ + protected function getChapter(): ?int + { + return $this->input->getInt('chapter'); + } + + /** + * get Verse Number/s + * + * @return string|null The verse number/s + * @since 2.0.1 + */ + protected function getVerse(): ?string + { + return $this->input->getString('verse'); + } + + /** + * get Words Number/s + * + * @return string|null The word number/s + * @since 2.0.1 + */ + protected function getWords(): ?string + { + return $this->input->getString('words'); + } + + /** + * get Enable Open AI + * + * @return bool The switch to enable open AI + * @since 2.0.1 + */ + protected function getEnableopenai(): bool + { + if ($this->params->get('enable_open_ai', 0) == 1) + { + return true; + } + + return false; + } + + /** + * get Enable Open AI Organisation + * + * @return bool The switch to enable open AI Organisation + * @since 2.0.1 + */ + protected function getEnableopenaiorg(): bool + { + if ($this->params->get('enable_open_ai_org', 0) == 1) + { + return true; + } + + return false; + } + + /** + * get User Token + * + * @return string|null The token + * @since 2.0.1 + */ + protected function getToken(): ?string + { + if (!$this->enable_open_ai) + { + return null; + } + + return $this->params->get('openai_token'); + } + + /** + * get Org Token + * + * @return string|null The org token + * @since 2.0.1 + */ + protected function getOrgToken(): ?string + { + if (!$this->enable_open_ai || !$this->enable_open_ai_org) + { + return null; + } + + return $this->params->get('openai_org_token'); + } + + /** + * get Open AI Model name + * + * @return string|null The model name + * @since 2.0.1 + */ + protected function getModel(): ?string + { + if (!$this->enable_open_ai) + {die; + return null; + } + + return $this->params->get('openai_model'); + } + + /** + * get Max Tokens + * + * @return int|null The max tokens + * @since 2.0.1 + */ + protected function getMaxtokens(): ?int + { + if (!$this->enable_open_ai) + { + return null; + } + + return (int) $this->params->get('openai_max_tokens', 300); + } + + /** + * get Temperature + * + * @return float|null The temperature + * @since 2.0.1 + */ + protected function getTemperature(): ?float + { + if (!$this->enable_open_ai) + { + return null; + } + + return (float) $this->params->get('openai_temperature', 1); + } + + /** + * get Top P + * + * @return float|null The top p + * @since 2.0.1 + */ + protected function getTopp(): ?float + { + if (!$this->enable_open_ai) + { + return null; + } + + return (float) $this->params->get('openai_top_p', 1); + } + + /** + * get N (number of results) + * + * @return int|null The number of results + * @since 2.0.1 + */ + protected function getN(): ?int + { + if (!$this->enable_open_ai) + { + return null; + } + + return (int) $this->params->get('openai_n', 1); + } + + /** + * get Presence Penalty + * + * @return float|null The presence penalty + * @since 2.0.1 + */ + protected function getPresencepenalty(): ?float + { + if (!$this->enable_open_ai) + { + return null; + } + + return (float) $this->params->get('openai_presence_penalty', 0); + } + + /** + * get Frequency Penalty + * + * @return float|null The frequency penalty + * @since 2.0.1 + */ + protected function getFrequencypenalty(): ?float + { + if (!$this->enable_open_ai) + { + return null; + } + + return (float) $this->params->get('openai_frequency_penalty', 0); + } +} + diff --git a/libraries/jcb_powers/VDM.Joomla.GetBible/src/Openai/index.html b/libraries/jcb_powers/VDM.Joomla.GetBible/src/Openai/index.html new file mode 100644 index 0000000..fa6d84e --- /dev/null +++ b/libraries/jcb_powers/VDM.Joomla.GetBible/src/Openai/index.html @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/libraries/jcb_powers/VDM.Joomla.GetBible/src/Search.php b/libraries/jcb_powers/VDM.Joomla.GetBible/src/Search.php new file mode 100644 index 0000000..7483592 --- /dev/null +++ b/libraries/jcb_powers/VDM.Joomla.GetBible/src/Search.php @@ -0,0 +1,23 @@ + + * @git GetBible + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ + +namespace VDM\Joomla\GetBible; + + +/** + * The GetBible Search + * + * @since 2.0.1 + */ +final class Search +{ +} + diff --git a/libraries/jcb_powers/VDM.Joomla.GetBible/src/Service/AI.php b/libraries/jcb_powers/VDM.Joomla.GetBible/src/Service/AI.php new file mode 100644 index 0000000..c53cb08 --- /dev/null +++ b/libraries/jcb_powers/VDM.Joomla.GetBible/src/Service/AI.php @@ -0,0 +1,81 @@ + + * @git GetBible + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ + +namespace VDM\Joomla\GetBible\Service; + + +use Joomla\DI\Container; +use Joomla\DI\ServiceProviderInterface; +use VDM\Joomla\GetBible\AI as GetBible; +use VDM\Joomla\GetBible\AI\Engineer; + + +/** + * The GetBible AI Service + * + * @since 3.2.0 + */ +class AI implements ServiceProviderInterface +{ + /** + * Registers the service provider with a DI container. + * + * @param Container $container The DI container. + * + * @return void + * @since 3.2.0 + */ + public function register(Container $container) + { + $container->alias(GetBible::class, 'GetBible.AI') + ->share('GetBible.AI', [$this, 'getAI'], true); + + $container->alias(Engineer::class, 'GetBible.AI.Engineer') + ->share('GetBible.AI.Engineer', [$this, 'getEngineer'], true); + } + + /** + * Get the GetBible AI class + * + * @param Container $container The DI container. + * + * @return GetBible + * @since 3.2.0 + */ + public function getAI(Container $container): GetBible + { + return new GetBible( + $container->get('GetBible.Config'), + $container->get('GetBible.Response'), + $container->get('GetBible.AI.Engineer') + ); + } + + /** + * Get the Engineer AI class + * + * @param Container $container The DI container. + * + * @return Engineer + * @since 3.2.0 + */ + public function getEngineer(Container $container): Engineer + { + return new Engineer( + $container->get('GetBible.Scripture'), + $container->get('GetBible.Prompt'), + $container->get('GetBible.Placeholders'), + $container->get('Openai.Chat'), + $container->get('GetBible.Insert') + ); + } +} + diff --git a/libraries/jcb_powers/VDM.Joomla.GetBible/src/Service/Api.php b/libraries/jcb_powers/VDM.Joomla.GetBible/src/Service/Api.php new file mode 100644 index 0000000..b08eb75 --- /dev/null +++ b/libraries/jcb_powers/VDM.Joomla.GetBible/src/Service/Api.php @@ -0,0 +1,121 @@ + + * @git GetBible + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ + +namespace VDM\Joomla\GetBible\Service; + + +use Joomla\DI\Container; +use Joomla\DI\ServiceProviderInterface; +use VDM\Joomla\GetBible\Api\Translations; +use VDM\Joomla\GetBible\Api\Books; +use VDM\Joomla\GetBible\Api\Chapters; +use VDM\Joomla\GetBible\Api\Verses; + + +/** + * The GetBible Api Service + * + * @since 2.0.1 + */ +class Api implements ServiceProviderInterface +{ + /** + * Registers the service provider with a DI container. + * + * @param Container $container The DI container. + * + * @return void + * @since 2.0.1 + */ + public function register(Container $container) + { + $container->alias(Translations::class, 'GetBible.Api.Translations') + ->share('GetBible.Api.Translations', [$this, 'getTranslations'], true); + + $container->alias(Books::class, 'GetBible.Api.Books') + ->share('GetBible.Api.Books', [$this, 'getBooks'], true); + + $container->alias(Chapters::class, 'GetBible.Api.Chapters') + ->share('GetBible.Api.Chapters', [$this, 'getChapters'], true); + + $container->alias(Verses::class, 'GetBible.Api.Verses') + ->share('GetBible.Api.Verses', [$this, 'getVerses'], true); + } + + /** + * Get the Translations class + * + * @param Container $container The DI container. + * + * @return Translations + * @since 3.2.0 + */ + public function getTranslations(Container $container): Translations + { + return new Translations( + $container->get('GetBible.Utilities.Http'), + $container->get('GetBible.Utilities.Uri'), + $container->get('GetBible.Utilities.Response') + ); + } + + /** + * Get the Books class + * + * @param Container $container The DI container. + * + * @return Books + * @since 3.2.0 + */ + public function getBooks(Container $container): Books + { + return new Books( + $container->get('GetBible.Utilities.Http'), + $container->get('GetBible.Utilities.Uri'), + $container->get('GetBible.Utilities.Response') + ); + } + + /** + * Get the Chapters class + * + * @param Container $container The DI container. + * + * @return Chapters + * @since 3.2.0 + */ + public function getChapters(Container $container): Chapters + { + return new Chapters( + $container->get('GetBible.Utilities.Http'), + $container->get('GetBible.Utilities.Uri'), + $container->get('GetBible.Utilities.Response') + ); + } + + /** + * Get the Verses class + * + * @param Container $container The DI container. + * + * @return Verses + * @since 3.2.0 + */ + public function getVerses(Container $container): Verses + { + return new Verses( + $container->get('GetBible.Utilities.Http'), + $container->get('GetBible.Utilities.Uri'), + $container->get('GetBible.Utilities.Response') + ); + } +} + diff --git a/libraries/jcb_powers/VDM.Joomla.GetBible/src/Service/App.php b/libraries/jcb_powers/VDM.Joomla.GetBible/src/Service/App.php new file mode 100644 index 0000000..012f390 --- /dev/null +++ b/libraries/jcb_powers/VDM.Joomla.GetBible/src/Service/App.php @@ -0,0 +1,259 @@ + + * @git GetBible + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ + +namespace VDM\Joomla\GetBible\Service; + + +use Joomla\DI\Container; +use Joomla\DI\ServiceProviderInterface; +use VDM\Joomla\GetBible\Config; +use VDM\Joomla\GetBible\Table; +use VDM\Joomla\GetBible\DailyScripture; +use VDM\Joomla\GetBible\Search; +use VDM\Joomla\GetBible\Watcher; +use VDM\Joomla\GetBible\Loader; +use VDM\Joomla\GetBible\Linker; +use VDM\Joomla\GetBible\Note; +use VDM\Joomla\GetBible\Tag; +use VDM\Joomla\GetBible\Tagged; +use VDM\Joomla\GetBible\Tagged\Paragraphs; + + +/** + * The GetBible App Service + * + * @since 2.0.1 + */ +class App implements ServiceProviderInterface +{ + /** + * Registers the service provider with a DI container. + * + * @param Container $container The DI container. + * + * @return void + * @since 2.0.1 + */ + public function register(Container $container) + { + $container->alias(Config::class, 'GetBible.Config') + ->share('GetBible.Config', [$this, 'getConfig'], true); + + $container->alias(Table::class, 'GetBible.Table') + ->share('GetBible.Table', [$this, 'getTable'], true); + + $container->alias(DailyScripture::class, 'DailyScripture') + ->share('DailyScripture', [$this, 'getDailyScripture'], true); + + $container->alias(Search::class, 'GetBible.Search') + ->share('GetBible.Search', [$this, 'getSearch'], true); + + $container->alias(Watcher::class, 'GetBible.Watcher') + ->share('GetBible.Watcher', [$this, 'getWatcher'], true); + + $container->alias(Loader::class, 'GetBible.Loader') + ->share('GetBible.Loader', [$this, 'getLoader'], true); + + $container->alias(Linker::class, 'GetBible.Linker') + ->share('GetBible.Linker', [$this, 'getLinker'], true); + + $container->alias(Note::class, 'GetBible.Note') + ->share('GetBible.Note', [$this, 'getNote'], true); + + $container->alias(Tag::class, 'GetBible.Tag') + ->share('GetBible.Tag', [$this, 'getTag'], true); + + $container->alias(Tagged::class, 'GetBible.Tagged') + ->share('GetBible.Tagged', [$this, 'getTagged'], true); + + $container->alias(Paragraphs::class, 'GetBible.Tagged.Paragraphs') + ->share('GetBible.Tagged.Paragraphs', [$this, 'getTaggedParagraphs'], true); + } + + /** + * Get the Config class + * + * @param Container $container The DI container. + * + * @return Config + * @since 2.0.1 + */ + public function getConfig(Container $container): Config + { + return new Config(); + } + + /** + * Get the Table class + * + * @param Container $container The DI container. + * + * @return Table + * @since 2.0.1 + */ + public function getTable(Container $container): Table + { + return new Table(); + } + + /** + * Get the Daily Scripture class + * + * @param Container $container The DI container. + * + * @return DailyScripture + * @since 2.0.1 + */ + public function getDailyScripture(Container $container): DailyScripture + { + return new DailyScripture( + $container->get('GetBible.Config'), + $container->get('GetBible.Utilities.Http'), + $container->get('GetBible.Load') + ); + } + + /** + * Get the Search class + * + * @param Container $container The DI container. + * + * @return Search + * @since 2.0.1 + */ + public function getSearch(Container $container): Search + { + return new Search(); + } + + /** + * Get the Watcher class + * + * @param Container $container The DI container. + * + * @return Watcher + * @since 2.0.1 + */ + public function getWatcher(Container $container): Watcher + { + return new Watcher( + $container->get('GetBible.Load'), + $container->get('GetBible.Insert'), + $container->get('GetBible.Update'), + $container->get('GetBible.Api.Translations'), + $container->get('GetBible.Api.Books'), + $container->get('GetBible.Api.Chapters'), + $container->get('GetBible.Api.Verses') + ); + } + + /** + * Get the Loader class + * + * @param Container $container The DI container. + * + * @return Loader + * @since 2.0.1 + */ + public function getLoader(Container $container): Loader + { + return new Loader( + $container->get('GetBible.Load'), + $container->get('GetBible.Watcher') + ); + } + + /** + * Get the Linker class + * + * @param Container $container The DI container. + * + * @return Linker + * @since 2.0.1 + */ + public function getLinker(Container $container): Linker + { + return new Linker( + $container->get('GetBible.Load'), + $container->get('GetBible.Insert'), + $container->get('GetBible.Update'), + $container->get('GetBible.Utilities.Session') + ); + } + + /** + * Get the Note class + * + * @param Container $container The DI container. + * + * @return Note + * @since 2.0.1 + */ + public function getNote(Container $container): Note + { + return new Note( + $container->get('GetBible.Load'), + $container->get('GetBible.Insert'), + $container->get('GetBible.Update'), + $container->get('GetBible.Linker') + ); + } + + /** + * Get the Tag class + * + * @param Container $container The DI container. + * + * @return Tag + * @since 2.0.1 + */ + public function getTag(Container $container): Tag + { + return new Tag( + $container->get('GetBible.Load'), + $container->get('GetBible.Insert'), + $container->get('GetBible.Update'), + $container->get('GetBible.Linker') + ); + } + + /** + * Get the Tagged class + * + * @param Container $container The DI container. + * + * @return Tagged + * @since 2.0.1 + */ + public function getTagged(Container $container): Tagged + { + return new Tagged( + $container->get('GetBible.Load'), + $container->get('GetBible.Insert'), + $container->get('GetBible.Update'), + $container->get('GetBible.Linker') + ); + } + + /** + * Get the Paragraphs class + * + * @param Container $container The DI container. + * + * @return Paragraphs + * @since 2.0.1 + */ + public function getTaggedParagraphs(Container $container): Paragraphs + { + return new Paragraphs(); + } +} + diff --git a/libraries/jcb_powers/VDM.Joomla.GetBible/src/Service/Data.php b/libraries/jcb_powers/VDM.Joomla.GetBible/src/Service/Data.php new file mode 100644 index 0000000..20eca16 --- /dev/null +++ b/libraries/jcb_powers/VDM.Joomla.GetBible/src/Service/Data.php @@ -0,0 +1,276 @@ + + * @git GetBible + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ + +namespace VDM\Joomla\GetBible\Service; + + +use Joomla\DI\Container; +use Joomla\DI\ServiceProviderInterface; +use VDM\Joomla\GetBible\Openai\Config; +use VDM\Joomla\GetBible\Table; +use VDM\Joomla\GetBible\Utilities\StringHelper; +use VDM\Joomla\GetBible\Data\Scripture; +use VDM\Joomla\GetBible\Data\Translation; +use VDM\Joomla\GetBible\Data\Book; +use VDM\Joomla\GetBible\Data\Chapter; +use VDM\Joomla\GetBible\Data\Verse; +use VDM\Joomla\GetBible\Data\Word; +use VDM\Joomla\GetBible\Data\Prompt; +use VDM\Joomla\GetBible\Data\Placeholders; +use VDM\Joomla\GetBible\Data\Response; + + +/** + * The GetBible Data Service + * + * @since 3.2.0 + */ +class Data implements ServiceProviderInterface +{ + /** + * Registers the service provider with a DI container. + * + * @param Container $container The DI container. + * + * @return void + * @since 3.2.0 + */ + public function register(Container $container) + { + $container->alias(Config::class, 'GetBible.Config') + ->share('GetBible.Config', [$this, 'getConfig'], true); + + $container->alias(Table::class, 'GetBible.Table') + ->share('GetBible.Table', [$this, 'getTable'], true); + + $container->alias(StringHelper::class, 'GetBible.Utilities.String') + ->share('GetBible.Utilities.String', [$this, 'getString'], true); + + $container->alias(Prompt::class, 'GetBible.Prompt') + ->share('GetBible.Prompt', [$this, 'getPrompt'], true); + + $container->alias(Scripture::class, 'GetBible.Scripture') + ->share('GetBible.Scripture', [$this, 'getScripture'], true); + + $container->alias(Translation::class, 'GetBible.Translation') + ->share('GetBible.Translation', [$this, 'getTranslation'], true); + + $container->alias(Book::class, 'GetBible.Book') + ->share('GetBible.Book', [$this, 'getBook'], true); + + $container->alias(Chapter::class, 'GetBible.Chapter') + ->share('GetBible.Chapter', [$this, 'getChapter'], true); + + $container->alias(Verse::class, 'GetBible.Verse') + ->share('GetBible.Verse', [$this, 'getVerse'], true); + + $container->alias(Word::class, 'GetBible.Word') + ->share('GetBible.Word', [$this, 'getWord'], true); + + $container->alias(Placeholders::class, 'GetBible.Placeholders') + ->share('GetBible.Placeholders', [$this, 'getPlaceholders'], true); + + $container->alias(Response::class, 'GetBible.Response') + ->share('GetBible.Response', [$this, 'getResponse'], true); + } + + /** + * Get the Config class + * + * @param Container $container The DI container. + * + * @return Config + * @since 2.0.1 + */ + public function getConfig(Container $container): Config + { + return new Config(); + } + + /** + * Get the Table class + * + * @param Container $container The DI container. + * + * @return Table + * @since 2.0.1 + */ + public function getTable(Container $container): Table + { + return new Table(); + } + + /** + * Get the String Helper class + * + * @param Container $container The DI container. + * + * @return StringHelper + * @since 3.2.0 + */ + public function getString(Container $container): StringHelper + { + return new StringHelper(); + } + + /** + * Get the Prompt class + * + * @param Container $container The DI container. + * + * @return Prompt + * @since 3.2.0 + */ + public function getPrompt(Container $container): Prompt + { + return new Prompt( + $container->get('GetBible.Load'), + $container->get('GetBible.Config') + ); + } + + /** + * Get the Scripture class + * + * @param Container $container The DI container. + * + * @return Scripture + * @since 3.2.0 + */ + public function getScripture(Container $container): Scripture + { + return new Scripture( + $container->get('GetBible.Translation'), + $container->get('GetBible.Book'), + $container->get('GetBible.Chapter'), + $container->get('GetBible.Verse'), + $container->get('GetBible.Word'), + ); + } + + /** + * Get the Translation class + * + * @param Container $container The DI container. + * + * @return Translation + * @since 3.2.0 + */ + public function getTranslation(Container $container): Translation + { + return new Translation( + $container->get('GetBible.Load'), + $container->get('GetBible.Config') + ); + } + + /** + * Get the Book class + * + * @param Container $container The DI container. + * + * @return Book + * @since 3.2.0 + */ + public function getBook(Container $container): Book + { + return new Book( + $container->get('GetBible.Load'), + $container->get('GetBible.Config') + ); + } + + /** + * Get the Chapter class + * + * @param Container $container The DI container. + * + * @return Chapter + * @since 3.2.0 + */ + public function getChapter(Container $container): Chapter + { + return new Chapter( + $container->get('GetBible.Load'), + $container->get('GetBible.Config') + ); + } + + /** + * Get the Verse class + * + * @param Container $container The DI container. + * + * @return Verse + * @since 3.2.0 + */ + public function getVerse(Container $container): Verse + { + return new Verse( + $container->get('GetBible.Chapter'), + $container->get('GetBible.Config'), + $container->get('GetBible.Prompt'), + $container->get('GetBible.Utilities.String') + ); + } + + /** + * Get the Word class + * + * @param Container $container The DI container. + * + * @return Word + * @since 3.2.0 + */ + public function getWord(Container $container): Word + { + return new Word( + $container->get('GetBible.Verse'), + $container->get('GetBible.Config'), + $container->get('GetBible.Prompt') + ); + } + + /** + * Get the Placeholders class + * + * @param Container $container The DI container. + * + * @return Placeholders + * @since 3.2.0 + */ + public function getPlaceholders(Container $container): Placeholders + { + return new Placeholders( + $container->get('GetBible.Scripture'), + $container->get('GetBible.Prompt') + ); + } + + /** + * Get the Response class + * + * @param Container $container The DI container. + * + * @return Response + * @since 3.2.0 + */ + public function getResponse(Container $container): Response + { + return new Response( + $container->get('GetBible.Scripture'), + $container->get('GetBible.Prompt'), + $container->get('GetBible.Load'), + $container->get('GetBible.Config') + ); + } +} + diff --git a/libraries/jcb_powers/VDM.Joomla.GetBible/src/Service/Database.php b/libraries/jcb_powers/VDM.Joomla.GetBible/src/Service/Database.php new file mode 100644 index 0000000..b1a7039 --- /dev/null +++ b/libraries/jcb_powers/VDM.Joomla.GetBible/src/Service/Database.php @@ -0,0 +1,149 @@ + + * @git GetBible + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ + +namespace VDM\Joomla\GetBible\Service; + + +use Joomla\DI\Container; +use Joomla\DI\ServiceProviderInterface; +use VDM\Joomla\Database\Insert as BaseInsert; +use VDM\Joomla\Database\Update as BaseUpdate; +use VDM\Joomla\Database\Load as BaseLoad; +use VDM\Joomla\GetBible\Database\Insert; +use VDM\Joomla\GetBible\Database\Load; +use VDM\Joomla\GetBible\Database\Update; + + +/** + * The GetBible Database Service + * + * @since 2.0.1 + */ +class Database implements ServiceProviderInterface +{ + /** + * Registers the service provider with a DI container. + * + * @param Container $container The DI container. + * + * @return void + * @since 2.0.1 + */ + public function register(Container $container) + { + $container->alias(BaseInsert::class, 'DB.Insert') + ->share('DB.Insert', [$this, 'getBaseInsert'], true); + + $container->alias(BaseUpdate::class, 'DB.Update') + ->share('DB.Update', [$this, 'getBaseUpdate'], true); + + $container->alias(BaseLoad::class, 'DB.Load') + ->share('DB.Load', [$this, 'getBaseLoad'], true); + + $container->alias(Insert::class, 'GetBible.Insert') + ->share('GetBible.Insert', [$this, 'getInsert'], true); + + $container->alias(Update::class, 'GetBible.Update') + ->share('GetBible.Update', [$this, 'getUpdate'], true); + + $container->alias(Load::class, 'GetBible.Load') + ->share('GetBible.Load', [$this, 'getLoad'], true); + } + + /** + * Get the BaseUpdate class + * + * @param Container $container The DI container. + * + * @return BaseUpdate + * @since 2.0.1 + */ + public function getBaseUpdate(Container $container): BaseUpdate + { + return new BaseUpdate(); + } + + /** + * Get the BaseInsert class + * + * @param Container $container The DI container. + * + * @return BaseInsert + * @since 2.0.1 + */ + public function getBaseInsert(Container $container): BaseInsert + { + return new BaseInsert(); + } + + /** + * Get the BaseLoad class + * + * @param Container $container The DI container. + * + * @return BaseLoad + * @since 2.0.1 + */ + public function getBaseLoad(Container $container): BaseLoad + { + return new BaseLoad(); + } + + /** + * Get the Insert class + * + * @param Container $container The DI container. + * + * @return Insert + * @since 2.0.1 + */ + public function getInsert(Container $container): Insert + { + return new Insert( + $container->get('GetBible.Model.Upsert'), + $container->get('DB.Insert') + ); + } + + /** + * Get the Update class + * + * @param Container $container The DI container. + * + * @return Update + * @since 2.0.1 + */ + public function getUpdate(Container $container): Update + { + return new Update( + $container->get('GetBible.Model.Upsert'), + $container->get('DB.Update') + ); + } + + /** + * Get the Table class + * + * @param Container $container The DI container. + * + * @return Load + * @since 2.0.1 + */ + public function getLoad(Container $container): Load + { + return new Load( + $container->get('GetBible.Table'), + $container->get('GetBible.Model.Load'), + $container->get('DB.Load') + ); + } +} + diff --git a/libraries/jcb_powers/VDM.Joomla.GetBible/src/Service/Model.php b/libraries/jcb_powers/VDM.Joomla.GetBible/src/Service/Model.php new file mode 100644 index 0000000..2fd9db7 --- /dev/null +++ b/libraries/jcb_powers/VDM.Joomla.GetBible/src/Service/Model.php @@ -0,0 +1,77 @@ + + * @git GetBible + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ + +namespace VDM\Joomla\GetBible\Service; + + +use Joomla\DI\Container; +use Joomla\DI\ServiceProviderInterface; +use VDM\Joomla\GetBible\Model\Upsert; +use VDM\Joomla\GetBible\Model\Load; + + +/** + * The GetBible Model Service + * + * @since 2.0.1 + */ +class Model implements ServiceProviderInterface +{ + /** + * Registers the service provider with a DI container. + * + * @param Container $container The DI container. + * + * @return void + * @since 2.0.1 + */ + public function register(Container $container) + { + $container->alias(Upsert::class, 'GetBible.Model.Upsert') + ->share('GetBible.Model.Upsert', [$this, 'getUpsert'], true); + + $container->alias(Load::class, 'GetBible.Model.Load') + ->share('GetBible.Model.Load', [$this, 'getLoad'], true); + } + + /** + * Get the Upsert class + * + * @param Container $container The DI container. + * + * @return Upsert + * @since 2.0.1 + */ + public function getUpsert(Container $container): Upsert + { + return new Upsert( + $container->get('GetBible.Config'), + $container->get('GetBible.Table') + ); + } + + /** + * Get the Load class + * + * @param Container $container The DI container. + * + * @return Load + * @since 2.0.1 + */ + public function getLoad(Container $container): Load + { + return new Load( + $container->get('GetBible.Config'), + $container->get('GetBible.Table') + ); + } +} + diff --git a/libraries/jcb_powers/VDM.Joomla.GetBible/src/Service/Openai.php b/libraries/jcb_powers/VDM.Joomla.GetBible/src/Service/Openai.php new file mode 100644 index 0000000..e33a1b5 --- /dev/null +++ b/libraries/jcb_powers/VDM.Joomla.GetBible/src/Service/Openai.php @@ -0,0 +1,121 @@ + + * @git GetBible + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ + +namespace VDM\Joomla\GetBible\Service; + + +use Joomla\DI\Container; +use Joomla\DI\ServiceProviderInterface; +use VDM\Joomla\Openai\Chat; +use VDM\Joomla\Openai\Completions; +use VDM\Joomla\Openai\Models; +use VDM\Joomla\Openai\Moderate; + + +/** + * The Openai Api Service + * + * @since 3.2.0 + */ +class Openai implements ServiceProviderInterface +{ + /** + * Registers the service provider with a DI container. + * + * @param Container $container The DI container. + * + * @return void + * @since 3.2.0 + */ + public function register(Container $container) + { + $container->alias(Chat::class, 'Openai.Chat') + ->share('Openai.Chat', [$this, 'getChat'], true); + + $container->alias(Completions::class, 'Openai.Completions') + ->share('Openai.Completions', [$this, 'getCompletions'], true); + + $container->alias(Models::class, 'Openai.Models') + ->share('Openai.Models', [$this, 'getModels'], true); + + $container->alias(Moderate::class, 'Openai.Moderate') + ->share('Openai.Moderate', [$this, 'getModerate'], true); + } + + /** + * Get the Chat class + * + * @param Container $container The DI container. + * + * @return Chat + * @since 3.2.0 + */ + public function getChat(Container $container): Chat + { + return new Chat( + $container->get('Openai.Utilities.Http'), + $container->get('Openai.Utilities.Uri'), + $container->get('Openai.Utilities.Response') + ); + } + + /** + * Get the Completions class + * + * @param Container $container The DI container. + * + * @return Completions + * @since 3.2.0 + */ + public function getCompletions(Container $container): Completions + { + return new Completions( + $container->get('Openai.Utilities.Http'), + $container->get('Openai.Utilities.Uri'), + $container->get('Openai.Utilities.Response') + ); + } + + /** + * Get the Models class + * + * @param Container $container The DI container. + * + * @return Models + * @since 3.2.0 + */ + public function getModels(Container $container): Models + { + return new Models( + $container->get('Openai.Utilities.Http'), + $container->get('Openai.Utilities.Uri'), + $container->get('Openai.Utilities.Response') + ); + } + + /** + * Get the Moderate class + * + * @param Container $container The DI container. + * + * @return Moderate + * @since 3.2.0 + */ + public function getModerate(Container $container): Moderate + { + return new Moderate( + $container->get('Openai.Utilities.Http'), + $container->get('Openai.Utilities.Uri'), + $container->get('Openai.Utilities.Response') + ); + } +} + diff --git a/libraries/jcb_powers/VDM.Joomla.GetBible/src/Service/Utilities.php b/libraries/jcb_powers/VDM.Joomla.GetBible/src/Service/Utilities.php new file mode 100644 index 0000000..74a87e2 --- /dev/null +++ b/libraries/jcb_powers/VDM.Joomla.GetBible/src/Service/Utilities.php @@ -0,0 +1,124 @@ + + * @git GetBible + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ + +namespace VDM\Joomla\GetBible\Service; + + +use Joomla\DI\Container; +use Joomla\DI\ServiceProviderInterface; +use VDM\Joomla\GetBible\Utilities\Uri; +use VDM\Joomla\GetBible\Utilities\Response; +use VDM\Joomla\GetBible\Utilities\Http; +use VDM\Joomla\GetBible\Utilities\StringHelper; +use VDM\Joomla\GetBible\Utilities\SessionHelper; + + +/** + * The GetBible Utilities Service + * + * @since 3.2.0 + */ +class Utilities implements ServiceProviderInterface +{ + /** + * Registers the service provider with a DI container. + * + * @param Container $container The DI container. + * + * @return void + * @since 3.2.0 + */ + public function register(Container $container) + { + $container->alias(Uri::class, 'GetBible.Utilities.Uri') + ->share('GetBible.Utilities.Uri', [$this, 'getUri'], true); + + $container->alias(Response::class, 'GetBible.Utilities.Response') + ->share('GetBible.Utilities.Response', [$this, 'getResponse'], true); + + $container->alias(Http::class, 'GetBible.Utilities.Http') + ->share('GetBible.Utilities.Http', [$this, 'getHttp'], true); + + $container->alias(StringHelper::class, 'GetBible.Utilities.String') + ->share('GetBible.Utilities.String', [$this, 'getString'], true); + + $container->alias(SessionHelper::class, 'GetBible.Utilities.Session') + ->share('GetBible.Utilities.Session', [$this, 'getSession'], true); + } + + /** + * Get the Uri class + * + * @param Container $container The DI container. + * + * @return Uri + * @since 3.2.0 + */ + public function getUri(Container $container): Uri + { + return new Uri( + $container->get('GetBible.Config') + ); + } + + /** + * Get the Response class + * + * @param Container $container The DI container. + * + * @return Response + * @since 3.2.0 + */ + public function getResponse(Container $container): Response + { + return new Response(); + } + + /** + * Get the Http class + * + * @param Container $container The DI container. + * + * @return Http + * @since 3.2.0 + */ + public function getHttp(Container $container): Http + { + return new Http(); + } + + /** + * Get the String Helper class + * + * @param Container $container The DI container. + * + * @return StringHelper + * @since 3.2.0 + */ + public function getString(Container $container): StringHelper + { + return new StringHelper(); + } + + /** + * Get the Session Helper class + * + * @param Container $container The DI container. + * + * @return SessionHelper + * @since 3.2.0 + */ + public function getSession(Container $container): SessionHelper + { + return new SessionHelper(); + } +} + diff --git a/libraries/jcb_powers/VDM.Joomla.GetBible/src/Service/index.html b/libraries/jcb_powers/VDM.Joomla.GetBible/src/Service/index.html new file mode 100644 index 0000000..fa6d84e --- /dev/null +++ b/libraries/jcb_powers/VDM.Joomla.GetBible/src/Service/index.html @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/libraries/jcb_powers/VDM.Joomla.GetBible/src/Table.php b/libraries/jcb_powers/VDM.Joomla.GetBible/src/Table.php new file mode 100644 index 0000000..7184cc5 --- /dev/null +++ b/libraries/jcb_powers/VDM.Joomla.GetBible/src/Table.php @@ -0,0 +1,1076 @@ + + * @git GetBible + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ + +namespace VDM\Joomla\GetBible; + + +use VDM\Joomla\Interfaces\Tableinterface; +use VDM\Joomla\Abstraction\BaseTable; + + +/** + * GetBible Tables + * + * @since 2.0.1 + */ +class Table extends BaseTable implements Tableinterface +{ + /** + * All areas/views/tables with their field details + * + * @var array + * @since 2.0.1 + **/ + protected array $tables = [ + 'linker' => [ + 'name' => [ + 'name' => 'name', + 'label' => 'COM_GETBIBLE_LINKER_NAME_LABEL', + 'type' => 'text', + 'title' => true, + 'list' => 'linkers', + 'store' => NULL, + 'tab_name' => 'Details', + ], + 'guid' => [ + 'name' => 'guid', + 'label' => 'COM_GETBIBLE_LINKER_GUID_LABEL', + 'type' => 'text', + 'title' => false, + 'list' => 'linkers', + 'store' => NULL, + 'tab_name' => 'publishing', + ], + ], + 'note' => [ + 'book_nr' => [ + 'name' => 'book_nr', + 'label' => 'COM_GETBIBLE_NOTE_BOOK_NR_LABEL', + 'type' => 'number', + 'title' => false, + 'list' => 'notes', + 'store' => NULL, + 'tab_name' => 'Details', + ], + 'linker' => [ + 'name' => 'linker', + 'label' => 'COM_GETBIBLE_NOTE_LINKER_LABEL', + 'type' => 'linkers', + 'title' => false, + 'list' => 'notes', + 'store' => NULL, + 'tab_name' => 'Details', + ], + 'access' => [ + 'name' => 'access', + 'label' => 'COM_GETBIBLE_NOTE_ACCESS_LABEL', + 'type' => 'radio', + 'title' => false, + 'list' => 'notes', + 'store' => NULL, + 'tab_name' => 'Details', + ], + 'guid' => [ + 'name' => 'guid', + 'label' => 'COM_GETBIBLE_NOTE_GUID_LABEL', + 'type' => 'text', + 'title' => false, + 'list' => 'notes', + 'store' => NULL, + 'tab_name' => 'publishing', + ], + 'note' => [ + 'name' => 'note', + 'label' => 'COM_GETBIBLE_NOTE_NOTE_LABEL', + 'type' => 'textarea', + 'title' => false, + 'list' => 'notes', + 'store' => NULL, + 'tab_name' => 'Details', + ], + 'verse' => [ + 'name' => 'verse', + 'label' => 'COM_GETBIBLE_NOTE_VERSE_LABEL', + 'type' => 'number', + 'title' => false, + 'list' => 'notes', + 'store' => NULL, + 'tab_name' => 'Details', + ], + 'chapter' => [ + 'name' => 'chapter', + 'label' => 'COM_GETBIBLE_NOTE_CHAPTER_LABEL', + 'type' => 'number', + 'title' => false, + 'list' => 'notes', + 'store' => NULL, + 'tab_name' => 'Details', + ], + ], + 'tagged_verse' => [ + 'book_nr' => [ + 'name' => 'book_nr', + 'label' => 'COM_GETBIBLE_TAGGED_VERSE_BOOK_NR_LABEL', + 'type' => 'number', + 'title' => false, + 'list' => 'tagged_verses', + 'store' => NULL, + 'tab_name' => 'Details', + ], + 'abbreviation' => [ + 'name' => 'abbreviation', + 'label' => 'COM_GETBIBLE_TAGGED_VERSE_ABBREVIATION_LABEL', + 'type' => 'translations', + 'title' => false, + 'list' => 'tagged_verses', + 'store' => NULL, + 'tab_name' => 'Details', + ], + 'access' => [ + 'name' => 'access', + 'label' => 'COM_GETBIBLE_TAGGED_VERSE_ACCESS_LABEL', + 'type' => 'radio', + 'title' => false, + 'list' => 'tagged_verses', + 'store' => NULL, + 'tab_name' => 'Details', + ], + 'linker' => [ + 'name' => 'linker', + 'label' => 'COM_GETBIBLE_TAGGED_VERSE_LINKER_LABEL', + 'type' => 'linkers', + 'title' => false, + 'list' => 'tagged_verses', + 'store' => NULL, + 'tab_name' => 'Details', + ], + 'tag' => [ + 'name' => 'tag', + 'label' => 'COM_GETBIBLE_TAGGED_VERSE_TAG_LABEL', + 'type' => 'tagers', + 'title' => false, + 'list' => 'tagged_verses', + 'store' => NULL, + 'tab_name' => 'Details', + ], + 'guid' => [ + 'name' => 'guid', + 'label' => 'COM_GETBIBLE_TAGGED_VERSE_GUID_LABEL', + 'type' => 'text', + 'title' => false, + 'list' => 'tagged_verses', + 'store' => NULL, + 'tab_name' => 'publishing', + ], + 'verse' => [ + 'name' => 'verse', + 'label' => 'COM_GETBIBLE_TAGGED_VERSE_VERSE_LABEL', + 'type' => 'number', + 'title' => false, + 'list' => 'tagged_verses', + 'store' => NULL, + 'tab_name' => 'Details', + ], + 'chapter' => [ + 'name' => 'chapter', + 'label' => 'COM_GETBIBLE_TAGGED_VERSE_CHAPTER_LABEL', + 'type' => 'number', + 'title' => false, + 'list' => 'tagged_verses', + 'store' => NULL, + 'tab_name' => 'Details', + ], + ], + 'prompt' => [ + 'name' => [ + 'name' => 'name', + 'label' => 'COM_GETBIBLE_PROMPT_NAME_LABEL', + 'type' => 'text', + 'title' => true, + 'list' => 'prompts', + 'store' => NULL, + 'tab_name' => 'Prompt', + ], + 'integration' => [ + 'name' => 'integration', + 'label' => 'COM_GETBIBLE_PROMPT_INTEGRATION_LABEL', + 'type' => 'list', + 'title' => false, + 'list' => 'prompts', + 'store' => NULL, + 'tab_name' => 'Prompt', + ], + 'cache_behaviour' => [ + 'name' => 'cache_behaviour', + 'label' => 'COM_GETBIBLE_PROMPT_CACHE_BEHAVIOUR_LABEL', + 'type' => 'list', + 'title' => false, + 'list' => 'prompts', + 'store' => NULL, + 'tab_name' => 'Prompt', + ], + 'abbreviation' => [ + 'name' => 'abbreviation', + 'label' => 'COM_GETBIBLE_PROMPT_ABBREVIATION_LABEL', + 'type' => 'targettranslations', + 'title' => false, + 'list' => 'prompts', + 'store' => NULL, + 'tab_name' => 'Prompt', + ], + 'guid' => [ + 'name' => 'guid', + 'label' => 'COM_GETBIBLE_PROMPT_GUID_LABEL', + 'type' => 'text', + 'title' => false, + 'list' => 'prompts', + 'store' => NULL, + 'tab_name' => 'publishing', + ], + 'model' => [ + 'name' => 'model', + 'label' => 'COM_GETBIBLE_PROMPT_MODEL_LABEL', + 'type' => 'list', + 'title' => false, + 'list' => 'prompts', + 'store' => NULL, + 'tab_name' => 'Open AI', + ], + 'presence_penalty' => [ + 'name' => 'presence_penalty', + 'label' => 'COM_GETBIBLE_PROMPT_PRESENCE_PENALTY_LABEL', + 'type' => 'number', + 'title' => false, + 'list' => 'prompts', + 'store' => NULL, + 'tab_name' => 'Open AI', + ], + 'org_token' => [ + 'name' => 'org_token', + 'label' => 'COM_GETBIBLE_PROMPT_ORG_TOKEN_LABEL', + 'type' => 'password', + 'title' => false, + 'list' => 'prompts', + 'store' => NULL, + 'tab_name' => 'Open AI', + ], + 'token' => [ + 'name' => 'token', + 'label' => 'COM_GETBIBLE_PROMPT_TOKEN_LABEL', + 'type' => 'password', + 'title' => false, + 'list' => 'prompts', + 'store' => NULL, + 'tab_name' => 'Open AI', + ], + 'n_override' => [ + 'name' => 'n_override', + 'label' => 'COM_GETBIBLE_PROMPT_N_OVERRIDE_LABEL', + 'type' => 'radio', + 'title' => false, + 'list' => 'prompts', + 'store' => NULL, + 'tab_name' => 'Open AI', + ], + 'cache_capacity' => [ + 'name' => 'cache_capacity', + 'label' => 'COM_GETBIBLE_PROMPT_CACHE_CAPACITY_LABEL', + 'type' => 'number', + 'title' => false, + 'list' => 'prompts', + 'store' => NULL, + 'tab_name' => 'Prompt', + ], + 'messages' => [ + 'name' => 'messages', + 'label' => 'COM_GETBIBLE_PROMPT_MESSAGES_LABEL', + 'type' => 'subform', + 'title' => false, + 'list' => 'prompts', + 'store' => 'json', + 'tab_name' => 'Prompt', + ], + 'response_retrieval' => [ + 'name' => 'response_retrieval', + 'label' => 'COM_GETBIBLE_PROMPT_RESPONSE_RETRIEVAL_LABEL', + 'type' => 'radio', + 'title' => false, + 'list' => 'prompts', + 'store' => NULL, + 'tab_name' => 'Prompt', + ], + 'frequency_penalty_override' => [ + 'name' => 'frequency_penalty_override', + 'label' => 'COM_GETBIBLE_PROMPT_FREQUENCY_PENALTY_OVERRIDE_LABEL', + 'type' => 'radio', + 'title' => false, + 'list' => 'prompts', + 'store' => NULL, + 'tab_name' => 'Open AI', + ], + 'n' => [ + 'name' => 'n', + 'label' => 'COM_GETBIBLE_PROMPT_N_LABEL', + 'type' => 'number', + 'title' => false, + 'list' => 'prompts', + 'store' => NULL, + 'tab_name' => 'Open AI', + ], + 'max_tokens_override' => [ + 'name' => 'max_tokens_override', + 'label' => 'COM_GETBIBLE_PROMPT_MAX_TOKENS_OVERRIDE_LABEL', + 'type' => 'radio', + 'title' => false, + 'list' => 'prompts', + 'store' => NULL, + 'tab_name' => 'Open AI', + ], + 'token_override' => [ + 'name' => 'token_override', + 'label' => 'COM_GETBIBLE_PROMPT_TOKEN_OVERRIDE_LABEL', + 'type' => 'radio', + 'title' => false, + 'list' => 'prompts', + 'store' => NULL, + 'tab_name' => 'Open AI', + ], + 'max_tokens' => [ + 'name' => 'max_tokens', + 'label' => 'COM_GETBIBLE_PROMPT_MAX_TOKENS_LABEL', + 'type' => 'number', + 'title' => false, + 'list' => 'prompts', + 'store' => NULL, + 'tab_name' => 'Open AI', + ], + 'ai_org_token_override' => [ + 'name' => 'ai_org_token_override', + 'label' => 'COM_GETBIBLE_PROMPT_AI_ORG_TOKEN_OVERRIDE_LABEL', + 'type' => 'radio', + 'title' => false, + 'list' => 'prompts', + 'store' => NULL, + 'tab_name' => 'Open AI', + ], + 'temperature_override' => [ + 'name' => 'temperature_override', + 'label' => 'COM_GETBIBLE_PROMPT_TEMPERATURE_OVERRIDE_LABEL', + 'type' => 'radio', + 'title' => false, + 'list' => 'prompts', + 'store' => NULL, + 'tab_name' => 'Open AI', + ], + 'presence_penalty_override' => [ + 'name' => 'presence_penalty_override', + 'label' => 'COM_GETBIBLE_PROMPT_PRESENCE_PENALTY_OVERRIDE_LABEL', + 'type' => 'radio', + 'title' => false, + 'list' => 'prompts', + 'store' => NULL, + 'tab_name' => 'Open AI', + ], + 'top_p_override' => [ + 'name' => 'top_p_override', + 'label' => 'COM_GETBIBLE_PROMPT_TOP_P_OVERRIDE_LABEL', + 'type' => 'radio', + 'title' => false, + 'list' => 'prompts', + 'store' => NULL, + 'tab_name' => 'Open AI', + ], + 'frequency_penalty' => [ + 'name' => 'frequency_penalty', + 'label' => 'COM_GETBIBLE_PROMPT_FREQUENCY_PENALTY_LABEL', + 'type' => 'number', + 'title' => false, + 'list' => 'prompts', + 'store' => NULL, + 'tab_name' => 'Open AI', + ], + 'top_p' => [ + 'name' => 'top_p', + 'label' => 'COM_GETBIBLE_PROMPT_TOP_P_LABEL', + 'type' => 'number', + 'title' => false, + 'list' => 'prompts', + 'store' => NULL, + 'tab_name' => 'Open AI', + ], + 'temperature' => [ + 'name' => 'temperature', + 'label' => 'COM_GETBIBLE_PROMPT_TEMPERATURE_LABEL', + 'type' => 'number', + 'title' => false, + 'list' => 'prompts', + 'store' => NULL, + 'tab_name' => 'Open AI', + ], + ], + 'open_ai_response' => [ + 'response_id' => [ + 'name' => 'response_id', + 'label' => 'COM_GETBIBLE_OPEN_AI_RESPONSE_RESPONSE_ID_LABEL', + 'type' => 'text', + 'title' => true, + 'list' => 'open_ai_responses', + 'store' => NULL, + 'tab_name' => 'Details', + ], + 'prompt' => [ + 'name' => 'prompt', + 'label' => 'COM_GETBIBLE_OPEN_AI_RESPONSE_PROMPT_LABEL', + 'type' => 'prompts', + 'title' => false, + 'list' => 'open_ai_responses', + 'store' => NULL, + 'tab_name' => 'Details', + ], + 'response_object' => [ + 'name' => 'response_object', + 'label' => 'COM_GETBIBLE_OPEN_AI_RESPONSE_RESPONSE_OBJECT_LABEL', + 'type' => 'text', + 'title' => false, + 'list' => 'open_ai_responses', + 'store' => NULL, + 'tab_name' => 'Details', + ], + 'response_model' => [ + 'name' => 'response_model', + 'label' => 'COM_GETBIBLE_OPEN_AI_RESPONSE_RESPONSE_MODEL_LABEL', + 'type' => 'text', + 'title' => false, + 'list' => 'open_ai_responses', + 'store' => NULL, + 'tab_name' => 'Details', + ], + 'total_tokens' => [ + 'name' => 'total_tokens', + 'label' => 'COM_GETBIBLE_OPEN_AI_RESPONSE_TOTAL_TOKENS_LABEL', + 'type' => 'number', + 'title' => false, + 'list' => 'open_ai_responses', + 'store' => NULL, + 'tab_name' => 'Details', + ], + 'n' => [ + 'name' => 'n', + 'label' => 'COM_GETBIBLE_OPEN_AI_RESPONSE_N_LABEL', + 'type' => 'number', + 'title' => false, + 'list' => 'open_ai_responses', + 'store' => NULL, + 'tab_name' => 'Prompt', + ], + 'frequency_penalty' => [ + 'name' => 'frequency_penalty', + 'label' => 'COM_GETBIBLE_OPEN_AI_RESPONSE_FREQUENCY_PENALTY_LABEL', + 'type' => 'number', + 'title' => false, + 'list' => 'open_ai_responses', + 'store' => NULL, + 'tab_name' => 'Prompt', + ], + 'presence_penalty' => [ + 'name' => 'presence_penalty', + 'label' => 'COM_GETBIBLE_OPEN_AI_RESPONSE_PRESENCE_PENALTY_LABEL', + 'type' => 'number', + 'title' => false, + 'list' => 'open_ai_responses', + 'store' => NULL, + 'tab_name' => 'Prompt', + ], + 'word' => [ + 'name' => 'word', + 'label' => 'COM_GETBIBLE_OPEN_AI_RESPONSE_WORD_LABEL', + 'type' => 'text', + 'title' => false, + 'list' => 'open_ai_responses', + 'store' => NULL, + 'tab_name' => 'Bible', + ], + 'chapter' => [ + 'name' => 'chapter', + 'label' => 'COM_GETBIBLE_OPEN_AI_RESPONSE_CHAPTER_LABEL', + 'type' => 'text', + 'title' => false, + 'list' => 'open_ai_responses', + 'store' => NULL, + 'tab_name' => 'Bible', + ], + 'lcsh' => [ + 'name' => 'lcsh', + 'label' => 'COM_GETBIBLE_OPEN_AI_RESPONSE_LCSH_LABEL', + 'type' => 'text', + 'title' => false, + 'list' => 'open_ai_responses', + 'store' => NULL, + 'tab_name' => 'Bible', + ], + 'completion_tokens' => [ + 'name' => 'completion_tokens', + 'label' => 'COM_GETBIBLE_OPEN_AI_RESPONSE_COMPLETION_TOKENS_LABEL', + 'type' => 'number', + 'title' => false, + 'list' => 'open_ai_responses', + 'store' => NULL, + 'tab_name' => 'Details', + ], + 'prompt_tokens' => [ + 'name' => 'prompt_tokens', + 'label' => 'COM_GETBIBLE_OPEN_AI_RESPONSE_PROMPT_TOKENS_LABEL', + 'type' => 'number', + 'title' => false, + 'list' => 'open_ai_responses', + 'store' => NULL, + 'tab_name' => 'Details', + ], + 'response_created' => [ + 'name' => 'response_created', + 'label' => 'COM_GETBIBLE_OPEN_AI_RESPONSE_RESPONSE_CREATED_LABEL', + 'type' => 'text', + 'title' => false, + 'list' => 'open_ai_responses', + 'store' => NULL, + 'tab_name' => 'Details', + ], + 'abbreviation' => [ + 'name' => 'abbreviation', + 'label' => 'COM_GETBIBLE_OPEN_AI_RESPONSE_ABBREVIATION_LABEL', + 'type' => 'targettranslations', + 'title' => false, + 'list' => 'open_ai_responses', + 'store' => NULL, + 'tab_name' => 'Bible', + ], + 'language' => [ + 'name' => 'language', + 'label' => 'COM_GETBIBLE_OPEN_AI_RESPONSE_LANGUAGE_LABEL', + 'type' => 'text', + 'title' => false, + 'list' => 'open_ai_responses', + 'store' => NULL, + 'tab_name' => 'Bible', + ], + 'max_tokens' => [ + 'name' => 'max_tokens', + 'label' => 'COM_GETBIBLE_OPEN_AI_RESPONSE_MAX_TOKENS_LABEL', + 'type' => 'number', + 'title' => false, + 'list' => 'open_ai_responses', + 'store' => NULL, + 'tab_name' => 'Prompt', + ], + 'book' => [ + 'name' => 'book', + 'label' => 'COM_GETBIBLE_OPEN_AI_RESPONSE_BOOK_LABEL', + 'type' => 'text', + 'title' => false, + 'list' => 'open_ai_responses', + 'store' => NULL, + 'tab_name' => 'Bible', + ], + 'temperature' => [ + 'name' => 'temperature', + 'label' => 'COM_GETBIBLE_OPEN_AI_RESPONSE_TEMPERATURE_LABEL', + 'type' => 'number', + 'title' => false, + 'list' => 'open_ai_responses', + 'store' => NULL, + 'tab_name' => 'Prompt', + ], + 'verse' => [ + 'name' => 'verse', + 'label' => 'COM_GETBIBLE_OPEN_AI_RESPONSE_VERSE_LABEL', + 'type' => 'text', + 'title' => false, + 'list' => 'open_ai_responses', + 'store' => NULL, + 'tab_name' => 'Bible', + ], + 'top_p' => [ + 'name' => 'top_p', + 'label' => 'COM_GETBIBLE_OPEN_AI_RESPONSE_TOP_P_LABEL', + 'type' => 'number', + 'title' => false, + 'list' => 'open_ai_responses', + 'store' => NULL, + 'tab_name' => 'Prompt', + ], + 'selected_word' => [ + 'name' => 'selected_word', + 'label' => 'COM_GETBIBLE_OPEN_AI_RESPONSE_SELECTED_WORD_LABEL', + 'type' => 'text', + 'title' => false, + 'list' => 'open_ai_responses', + 'store' => NULL, + 'tab_name' => 'Bible', + ], + 'model' => [ + 'name' => 'model', + 'label' => 'COM_GETBIBLE_OPEN_AI_RESPONSE_MODEL_LABEL', + 'type' => 'list', + 'title' => false, + 'list' => 'open_ai_responses', + 'store' => NULL, + 'tab_name' => 'Prompt', + ], + ], + 'open_ai_message' => [ + 'role' => [ + 'name' => 'role', + 'label' => 'COM_GETBIBLE_OPEN_AI_MESSAGE_ROLE_LABEL', + 'type' => 'list', + 'title' => true, + 'list' => 'open_ai_messages', + 'store' => NULL, + 'tab_name' => 'Message', + ], + 'open_ai_response' => [ + 'name' => 'open_ai_response', + 'label' => 'COM_GETBIBLE_OPEN_AI_MESSAGE_OPEN_AI_RESPONSE_LABEL', + 'type' => 'openairesponses', + 'title' => false, + 'list' => 'open_ai_messages', + 'store' => NULL, + 'tab_name' => 'Message', + ], + 'prompt' => [ + 'name' => 'prompt', + 'label' => 'COM_GETBIBLE_OPEN_AI_MESSAGE_PROMPT_LABEL', + 'type' => 'prompts', + 'title' => false, + 'list' => 'open_ai_messages', + 'store' => NULL, + 'tab_name' => 'Message', + ], + 'source' => [ + 'name' => 'source', + 'label' => 'COM_GETBIBLE_OPEN_AI_MESSAGE_SOURCE_LABEL', + 'type' => 'radio', + 'title' => false, + 'list' => 'open_ai_messages', + 'store' => NULL, + 'tab_name' => 'Message', + ], + 'content' => [ + 'name' => 'content', + 'label' => 'COM_GETBIBLE_OPEN_AI_MESSAGE_CONTENT_LABEL', + 'type' => 'textarea', + 'title' => false, + 'list' => 'open_ai_messages', + 'store' => NULL, + 'tab_name' => 'Message', + ], + 'name' => [ + 'name' => 'name', + 'label' => 'COM_GETBIBLE_OPEN_AI_MESSAGE_NAME_LABEL', + 'type' => 'text', + 'title' => false, + 'list' => 'open_ai_messages', + 'store' => NULL, + 'tab_name' => 'Message', + ], + 'index' => [ + 'name' => 'index', + 'label' => 'COM_GETBIBLE_OPEN_AI_MESSAGE_INDEX_LABEL', + 'type' => 'number', + 'title' => false, + 'list' => 'open_ai_messages', + 'store' => NULL, + 'tab_name' => 'Message', + ], + ], + 'password' => [ + 'name' => [ + 'name' => 'name', + 'label' => 'COM_GETBIBLE_PASSWORD_NAME_LABEL', + 'type' => 'text', + 'title' => true, + 'list' => 'passwords', + 'store' => NULL, + 'tab_name' => 'Details', + ], + 'linker' => [ + 'name' => 'linker', + 'label' => 'COM_GETBIBLE_PASSWORD_LINKER_LABEL', + 'type' => 'linkers', + 'title' => false, + 'list' => 'passwords', + 'store' => NULL, + 'tab_name' => 'Details', + ], + 'guid' => [ + 'name' => 'guid', + 'label' => 'COM_GETBIBLE_PASSWORD_GUID_LABEL', + 'type' => 'text', + 'title' => false, + 'list' => 'passwords', + 'store' => NULL, + 'tab_name' => 'publishing', + ], + 'password' => [ + 'name' => 'password', + 'label' => 'COM_GETBIBLE_PASSWORD_PASSWORD_LABEL', + 'type' => 'password', + 'title' => false, + 'list' => 'passwords', + 'store' => NULL, + 'tab_name' => 'Details', + ], + ], + 'tag' => [ + 'name' => [ + 'name' => 'name', + 'label' => 'COM_GETBIBLE_TAG_NAME_LABEL', + 'type' => 'text', + 'title' => true, + 'list' => 'tags', + 'store' => NULL, + 'tab_name' => 'Details', + ], + 'linker' => [ + 'name' => 'linker', + 'label' => 'COM_GETBIBLE_TAG_LINKER_LABEL', + 'type' => 'linkers', + 'title' => false, + 'list' => 'tags', + 'store' => NULL, + 'tab_name' => 'Details', + ], + 'access' => [ + 'name' => 'access', + 'label' => 'COM_GETBIBLE_TAG_ACCESS_LABEL', + 'type' => 'radio', + 'title' => false, + 'list' => 'tags', + 'store' => NULL, + 'tab_name' => 'Details', + ], + 'guid' => [ + 'name' => 'guid', + 'label' => 'COM_GETBIBLE_TAG_GUID_LABEL', + 'type' => 'text', + 'title' => false, + 'list' => 'tags', + 'store' => NULL, + 'tab_name' => 'publishing', + ], + 'description' => [ + 'name' => 'description', + 'label' => 'COM_GETBIBLE_TAG_DESCRIPTION_LABEL', + 'type' => 'textarea', + 'title' => false, + 'list' => 'tags', + 'store' => NULL, + 'tab_name' => 'Details', + ], + ], + 'translation' => [ + 'translation' => [ + 'name' => 'translation', + 'label' => 'COM_GETBIBLE_TRANSLATION_TRANSLATION_LABEL', + 'type' => 'text', + 'title' => true, + 'list' => 'translations', + 'store' => NULL, + 'tab_name' => 'Details', + ], + 'abbreviation' => [ + 'name' => 'abbreviation', + 'label' => 'COM_GETBIBLE_TRANSLATION_ABBREVIATION_LABEL', + 'type' => 'text', + 'title' => false, + 'list' => 'translations', + 'store' => NULL, + 'tab_name' => 'Details', + ], + 'language' => [ + 'name' => 'language', + 'label' => 'COM_GETBIBLE_TRANSLATION_LANGUAGE_LABEL', + 'type' => 'text', + 'title' => false, + 'list' => 'translations', + 'store' => NULL, + 'tab_name' => 'Details', + ], + 'direction' => [ + 'name' => 'direction', + 'label' => 'COM_GETBIBLE_TRANSLATION_DIRECTION_LABEL', + 'type' => 'radio', + 'title' => false, + 'list' => 'translations', + 'store' => NULL, + 'tab_name' => 'Details', + ], + 'distribution_history' => [ + 'name' => 'distribution_history', + 'label' => 'COM_GETBIBLE_TRANSLATION_DISTRIBUTION_HISTORY_LABEL', + 'type' => 'subform', + 'title' => false, + 'list' => 'translations', + 'store' => 'json', + 'tab_name' => 'Details', + ], + 'distribution_about' => [ + 'name' => 'distribution_about', + 'label' => 'COM_GETBIBLE_TRANSLATION_DISTRIBUTION_ABOUT_LABEL', + 'type' => 'textarea', + 'title' => false, + 'list' => 'translations', + 'store' => NULL, + 'tab_name' => 'Details', + ], + 'distribution_license' => [ + 'name' => 'distribution_license', + 'label' => 'COM_GETBIBLE_TRANSLATION_DISTRIBUTION_LICENSE_LABEL', + 'type' => 'textarea', + 'title' => false, + 'list' => 'translations', + 'store' => NULL, + 'tab_name' => 'Details', + ], + 'distribution_source' => [ + 'name' => 'distribution_source', + 'label' => 'COM_GETBIBLE_TRANSLATION_DISTRIBUTION_SOURCE_LABEL', + 'type' => 'text', + 'title' => false, + 'list' => 'translations', + 'store' => NULL, + 'tab_name' => 'Details', + ], + 'distribution_sourcetype' => [ + 'name' => 'distribution_sourcetype', + 'label' => 'COM_GETBIBLE_TRANSLATION_DISTRIBUTION_SOURCETYPE_LABEL', + 'type' => 'text', + 'title' => false, + 'list' => 'translations', + 'store' => NULL, + 'tab_name' => 'Details', + ], + 'distribution_versification' => [ + 'name' => 'distribution_versification', + 'label' => 'COM_GETBIBLE_TRANSLATION_DISTRIBUTION_VERSIFICATION_LABEL', + 'type' => 'text', + 'title' => false, + 'list' => 'translations', + 'store' => NULL, + 'tab_name' => 'Details', + ], + 'sha' => [ + 'name' => 'sha', + 'label' => 'COM_GETBIBLE_TRANSLATION_SHA_LABEL', + 'type' => 'text', + 'title' => false, + 'list' => 'translations', + 'store' => NULL, + 'tab_name' => 'Details', + ], + 'encoding' => [ + 'name' => 'encoding', + 'label' => 'COM_GETBIBLE_TRANSLATION_ENCODING_LABEL', + 'type' => 'text', + 'title' => false, + 'list' => 'translations', + 'store' => NULL, + 'tab_name' => 'Details', + ], + 'distribution_lcsh' => [ + 'name' => 'distribution_lcsh', + 'label' => 'COM_GETBIBLE_TRANSLATION_DISTRIBUTION_LCSH_LABEL', + 'type' => 'text', + 'title' => false, + 'list' => 'translations', + 'store' => NULL, + 'tab_name' => 'Details', + ], + 'distribution_version_date' => [ + 'name' => 'distribution_version_date', + 'label' => 'COM_GETBIBLE_TRANSLATION_DISTRIBUTION_VERSION_DATE_LABEL', + 'type' => 'text', + 'title' => false, + 'list' => 'translations', + 'store' => NULL, + 'tab_name' => 'Details', + ], + 'distribution_version' => [ + 'name' => 'distribution_version', + 'label' => 'COM_GETBIBLE_TRANSLATION_DISTRIBUTION_VERSION_LABEL', + 'type' => 'text', + 'title' => false, + 'list' => 'translations', + 'store' => NULL, + 'tab_name' => 'Details', + ], + 'lang' => [ + 'name' => 'lang', + 'label' => 'COM_GETBIBLE_TRANSLATION_LANG_LABEL', + 'type' => 'text', + 'title' => false, + 'list' => 'translations', + 'store' => NULL, + 'tab_name' => 'Details', + ], + 'distribution_abbreviation' => [ + 'name' => 'distribution_abbreviation', + 'label' => 'COM_GETBIBLE_TRANSLATION_DISTRIBUTION_ABBREVIATION_LABEL', + 'type' => 'text', + 'title' => false, + 'list' => 'translations', + 'store' => NULL, + 'tab_name' => 'Details', + ], + ], + 'book' => [ + 'name' => [ + 'name' => 'name', + 'label' => 'COM_GETBIBLE_BOOK_NAME_LABEL', + 'type' => 'text', + 'title' => true, + 'list' => 'books', + 'store' => NULL, + 'tab_name' => 'Details', + ], + 'abbreviation' => [ + 'name' => 'abbreviation', + 'label' => 'COM_GETBIBLE_BOOK_ABBREVIATION_LABEL', + 'type' => 'translations', + 'title' => false, + 'list' => 'books', + 'store' => NULL, + 'tab_name' => 'Details', + ], + 'nr' => [ + 'name' => 'nr', + 'label' => 'COM_GETBIBLE_BOOK_NR_LABEL', + 'type' => 'number', + 'title' => false, + 'list' => 'books', + 'store' => NULL, + 'tab_name' => 'Details', + ], + 'sha' => [ + 'name' => 'sha', + 'label' => 'COM_GETBIBLE_BOOK_SHA_LABEL', + 'type' => 'text', + 'title' => false, + 'list' => 'books', + 'store' => NULL, + 'tab_name' => 'Details', + ], + ], + 'chapter' => [ + 'name' => [ + 'name' => 'name', + 'label' => 'COM_GETBIBLE_CHAPTER_NAME_LABEL', + 'type' => 'text', + 'title' => true, + 'list' => 'chapters', + 'store' => NULL, + 'tab_name' => 'Details', + ], + 'chapter' => [ + 'name' => 'chapter', + 'label' => 'COM_GETBIBLE_CHAPTER_CHAPTER_LABEL', + 'type' => 'number', + 'title' => false, + 'list' => 'chapters', + 'store' => NULL, + 'tab_name' => 'Details', + ], + 'book_nr' => [ + 'name' => 'book_nr', + 'label' => 'COM_GETBIBLE_CHAPTER_BOOK_NR_LABEL', + 'type' => 'number', + 'title' => false, + 'list' => 'chapters', + 'store' => NULL, + 'tab_name' => 'Details', + ], + 'abbreviation' => [ + 'name' => 'abbreviation', + 'label' => 'COM_GETBIBLE_CHAPTER_ABBREVIATION_LABEL', + 'type' => 'translations', + 'title' => false, + 'list' => 'chapters', + 'store' => NULL, + 'tab_name' => 'Details', + ], + 'sha' => [ + 'name' => 'sha', + 'label' => 'COM_GETBIBLE_CHAPTER_SHA_LABEL', + 'type' => 'text', + 'title' => false, + 'list' => 'chapters', + 'store' => NULL, + 'tab_name' => 'Details', + ], + ], + 'verse' => [ + 'book_nr' => [ + 'name' => 'book_nr', + 'label' => 'COM_GETBIBLE_VERSE_BOOK_NR_LABEL', + 'type' => 'number', + 'title' => true, + 'list' => 'verses', + 'store' => NULL, + 'tab_name' => 'Details', + ], + 'chapter' => [ + 'name' => 'chapter', + 'label' => 'COM_GETBIBLE_VERSE_CHAPTER_LABEL', + 'type' => 'number', + 'title' => false, + 'list' => 'verses', + 'store' => NULL, + 'tab_name' => 'Details', + ], + 'verse' => [ + 'name' => 'verse', + 'label' => 'COM_GETBIBLE_VERSE_VERSE_LABEL', + 'type' => 'number', + 'title' => false, + 'list' => 'verses', + 'store' => NULL, + 'tab_name' => 'Details', + ], + 'abbreviation' => [ + 'name' => 'abbreviation', + 'label' => 'COM_GETBIBLE_VERSE_ABBREVIATION_LABEL', + 'type' => 'translations', + 'title' => false, + 'list' => 'verses', + 'store' => NULL, + 'tab_name' => 'Details', + ], + 'text' => [ + 'name' => 'text', + 'label' => 'COM_GETBIBLE_VERSE_TEXT_LABEL', + 'type' => 'textarea', + 'title' => false, + 'list' => 'verses', + 'store' => NULL, + 'tab_name' => 'Details', + ], + 'name' => [ + 'name' => 'name', + 'label' => 'COM_GETBIBLE_VERSE_NAME_LABEL', + 'type' => 'text', + 'title' => false, + 'list' => 'verses', + 'store' => NULL, + 'tab_name' => 'Details', + ], + ], + ]; +} + diff --git a/libraries/jcb_powers/VDM.Joomla.GetBible/src/Tag.php b/libraries/jcb_powers/VDM.Joomla.GetBible/src/Tag.php new file mode 100644 index 0000000..b2fb49a --- /dev/null +++ b/libraries/jcb_powers/VDM.Joomla.GetBible/src/Tag.php @@ -0,0 +1,209 @@ + + * @git GetBible + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ + +namespace VDM\Joomla\GetBible; + + +use Joomla\CMS\Language\Text; +use VDM\Joomla\GetBible\Database\Load; +use VDM\Joomla\GetBible\Database\Insert; +use VDM\Joomla\GetBible\Database\Update; +use VDM\Joomla\GetBible\Linker; +use VDM\Joomla\Utilities\GuidHelper; + + +/** + * The GetBible Tag + * + * @since 2.0.1 + */ +final class Tag +{ + /** + * The Load class + * + * @var Load + * @since 2.0.1 + */ + protected Load $load; + + /** + * The Insert class + * + * @var Insert + * @since 2.0.1 + */ + protected Insert $insert; + + /** + * The Update class + * + * @var Update + * @since 2.0.1 + */ + protected Update $update; + + /** + * The Linker class + * + * @var Linker + * @since 2.0.1 + */ + protected Linker $linker; + + /** + * Constructor + * + * @param Load $load The load object. + * @param Insert $insert The insert object. + * @param Update $update The update object. + * @param Linker $linker The linker object. + * + * @since 2.0.1 + */ + public function __construct( + Load $load, + Insert $insert, + Update $update, + Linker $linker) + { + $this->load = $load; + $this->insert = $insert; + $this->update = $update; + $this->linker = $linker; + } + + /** + * Set a tag + * + * @param string $name The tag name being created + * + * @return array|null Array of the tag values on success + * @since 2.0.1 + **/ + public function set(string $name): ?array + { + // make sure the linker has access + if (($linker = $this->linker->get()) === null) + { + return [ + 'error' => Text::_("COM_GETBIBLE_WITHOUT_SELECTING_THE_CORRECT_FAVOURITE_VERSE_YOU_CANT_PERFORM_THE_INITIAL_ACTION"), + 'access_required' => true + ]; + } + + // get tag if it exist + if (($tag = $this->get($linker, $name)) !== null) + { + // publish if not published + if ($tag->published != 1 && !$this->update->value(1, 'published', $tag->id, 'id', 'tag')) + { + return [ + 'error' => Text::_('COM_GETBIBLE_TAG_ALREADY_EXIST_BUT_COULD_NOT_BE_REACTIVATED') + ]; + } + + $tag->published = 1; + $tag->success = Text::_('COM_GETBIBLE_THE_TAG_WAS_SUCCESSFULLY_SET'); + return (array) $tag; + } + // create a new tag + elseif ($this->create($linker, $name) + && ($tag = $this->get($linker, $name)) !== null) + { + $tag->success = Text::_('COM_GETBIBLE_THE_TAG_WAS_SUCCESSFULLY_SET'); + return (array) $tag; + } + + return null; + } + + /** + * Delete a tag + * + * @param string $tag The tagged verse GUID value + * + * @return bool True on success + * @since 2.0.1 + **/ + public function delete(string $tag): bool + { + // make sure the linker has access + if (($linker = $this->linker->get()) === null) + { + return false; + } + + // make sure the linker has access to delete this tag + if (($id = $this->load->value(['guid' => $tag, 'linker' => $linker], 'id', 'tag')) !== null && $id > 0) + { + return $this->update->value(-2, 'published', $id, 'id', 'tag'); + } + + return false; + } + + /** + * Get a tag + * + * @param string $linker The linker GUID value + * @param string $name The tag name + * + * @return array|null Array of the tagged verse values on success + * @since 2.0.1 + **/ + private function get( + string $linker, + string $name + ): ?array + { + // get tag if it exist + if (($tag = $this->load->item([ + 'linker' => $linker, + 'name' => $name + ], 'tag')) !== null) + { + return $tag; + } + + return null; + } + + /** + * Create a Tag + * + * @param string $linker The linker GUID value + * @param string $name The tag name + * + * @return bool True on success + * @since 2.0.1 + **/ + private function create( + string $linker, + string $name + ): bool + { + $guid = (string) GuidHelper::get(); + while (!GuidHelper::valid($guid, 'tag', 0, 'getbible')) + { + // must always be set + $guid = (string) GuidHelper::get(); + } + + return $this->insert->row([ + 'access' => 0, + 'linker' => $linker, + 'name' => $name, + 'guid' => $guid + ], 'tag'); + } +} + diff --git a/libraries/jcb_powers/VDM.Joomla.GetBible/src/Tagged.php b/libraries/jcb_powers/VDM.Joomla.GetBible/src/Tagged.php new file mode 100644 index 0000000..41f9deb --- /dev/null +++ b/libraries/jcb_powers/VDM.Joomla.GetBible/src/Tagged.php @@ -0,0 +1,364 @@ + + * @git GetBible + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ + +namespace VDM\Joomla\GetBible; + + +use Joomla\Registry\Registry; +use Joomla\CMS\Language\Text; +use Joomla\CMS\Application\CMSApplication; +use Joomla\CMS\Factory; +use VDM\Joomla\GetBible\Database\Load; +use VDM\Joomla\GetBible\Database\Insert; +use VDM\Joomla\GetBible\Database\Update; +use VDM\Joomla\GetBible\Linker; +use VDM\Joomla\Utilities\GuidHelper; +use VDM\Joomla\Utilities\Component\Helper; + + +/** + * The GetBible Tagged + * + * @since 2.0.1 + */ +final class Tagged +{ + /** + * The Load class + * + * @var Load + * @since 2.0.1 + */ + protected Load $load; + + /** + * The Insert class + * + * @var Insert + * @since 2.0.1 + */ + protected Insert $insert; + + /** + * The Update class + * + * @var Update + * @since 2.0.1 + */ + protected Update $update; + + /** + * The Linker class + * + * @var Linker + * @since 2.0.1 + */ + protected Linker $linker; + + /** + * The Registry class + * + * @var Registry + * @since 2.0.1 + */ + protected Registry $params; + + /** + * Application object. + * + * @var CMSApplication + * @since 3.2.0 + **/ + protected CMSApplication $app; + + /** + * Constructor + * + * @param Load $load The load object. + * @param Insert $insert The insert object. + * @param Update $update The update object. + * @param Linker $linker The linker object. + * @param Registry|null $params The params object. + * @param CMSApplication|null $app The app object. + * + * @since 2.0.1 + */ + public function __construct( + Load $load, + Insert $insert, + Update $update, + Linker $linker, + ?Registry $params = null, + ?CMSApplication $app = null) + { + $this->load = $load; + $this->insert = $insert; + $this->update = $update; + $this->linker = $linker; + $this->params = $params ?: Helper::getParams('com_getbible'); + $this->app = $app ?: Factory::getApplication(); + } + + /** + * Set a tagged verse + * + * @param string $translation The translation in which the note is made + * @param int $book The book in which the note is made + * @param int $chapter The chapter in which the note is made + * @param int $verse The verse where the note is made + * @param string $tag The tag being added + * + * @return array|null Array of the tagged values on success + * @since 2.0.1 + **/ + public function set( + string $translation, + int $book, + int $chapter, + int $verse, + string $tag + ): ?array + { + // make sure the linker has access + if (($linker = $this->linker->get()) === null) + { + return [ + 'error' => Text::_("COM_GETBIBLE_WITHOUT_SELECTING_THE_CORRECT_FAVOURITE_VERSE_YOU_CANT_PERFORM_THE_INITIAL_ACTION"), + 'access_required' => true + ]; + } + + // make sure the tag is active + if (($published = GuidHelper::item($tag, 'tag', 'a.published', 'getbible')) === null + || $published != 1) + { + return [ + 'error' => Text::_('COM_GETBIBLE_THE_TAG_SELECTED_IS_NOT_ACTIVE_PLEASE_SELECT_AN_ACTIVE_TAG') + ]; + } + + // get tagged verse if it exist + if (($tagged = $this->get($linker, $book, $chapter, $verse, $tag)) !== null) + { + // publish if not published + if ($tagged->published != 1 && !$this->update->value(1, 'published', $tagged->id, 'id', 'tagged_verse')) + { + return [ + 'error' => Text::_('COM_GETBIBLE_TAGGED_VERSE_ALREADY_EXIST_BUT_COULD_NOT_BE_REACTIVATED') + ]; + } + + $tagged->published = 1; + $tagged->success = Text::_('COM_GETBIBLE_THE_VERSE_WAS_SUCCESSFULLY_TAGGED'); + return (array) $tagged; + } + // create a new tagged verse + elseif ($this->create($linker, $translation, $book, $chapter, $verse, $tag) + && ($tagged = $this->get($linker, $book, $chapter, $verse, $tag)) !== null) + { + $tagged->success = Text::_('COM_GETBIBLE_THE_VERSE_WAS_SUCCESSFULLY_TAGGED'); + return (array) $tagged; + } + + return null; + } + + /** + * Delete a tagged verse + * + * @param string $tagged The tagged verse GUID value + * + * @return array|null True on success + * @since 2.0.1 + **/ + public function delete( + string $tagged + ): ?array + { + // make sure the linker has access + if (($linker = $this->linker->get()) === null) + { + return [ + 'error' => Text::_("COM_GETBIBLE_WITHOUT_SELECTING_THE_CORRECT_FAVOURITE_VERSE_YOU_CANT_PERFORM_THE_INITIAL_ACTION"), + 'access_required' => true + ]; + } + + // make sure the linker has access to delete this tag + if (($id = $this->load->value(['linker' => $linker, 'guid' => $tagged], 'id', 'tagged_verse')) !== null && $id > 0 + && $this->update->value(-2, 'published', $id, 'id', 'tagged_verse')) + { + return [ + 'success' => Text::_('COM_GETBIBLE_THE_TAG_WAS_SUCCESSFULLY_REMOVED_FROM_THE_VERSE') + ]; + } + + // lets check if this is a systems tag + if (($_tagged = $this->getByGuid($tagged)) !== null && $_tagged->access == 1) + { + if ($this->params->get('allow_untagging') == 1 + && $this->createForLinker($linker, $_tagged, -2)) + { + return [ + 'success' => Text::_('COM_GETBIBLE_THE_TAG_WAS_SUCCESSFULLY_REMOVED_FROM_THE_VERSE') + ]; + } + + return [ + 'notice' => Text::sprintf("COM_GETBIBLE_THIS_IS_A_GLOBAL_TAG_SET_BY_US_AT_BSB_FOR_YOUR_CONVENIENCE_WE_HOLD_THE_PRIVILEGE_TO_MODIFY_THESE_TAGS_IF_YOU_BELIEVE_ITS_SET_IN_ERROR_KINDLY_INFORM_US", $this->app->get('sitename')) + ]; + } + + return [ + 'error' => Text::_('COM_GETBIBLE_THIS_TAG_COULD_NOT_BE_REMOVED') + ]; + } + + /** + * Get a tagged verse + * + * @param string $guid The tagged verse GUID value + * + * @return object|null Object of the tagged verse values on success + * @since 2.0.1 + **/ + private function getByGuid(string $guid): ?object + { + // get tagged verse if it exist + if (($tagged = $this->load->item(['guid' => $guid], 'tagged_verse')) !== null) + { + return $tagged; + } + + return null; + } + + /** + * Get a tagged verse + * + * @param string $linker The linker GUID value + * @param int $book The book in which the note is made + * @param int $chapter The chapter in which the note is made + * @param int $verse The verse where the note is made + * @param string $tag The tag being added + * + * @return object|null Object of the tagged verse values on success + * @since 2.0.1 + **/ + private function get( + string $linker, + int $book, + int $chapter, + int $verse, + string $tag + ): ?object + { + // get tagged verse if it exist + if (($tagged = $this->load->item([ + 'linker' => $linker, + 'book_nr' => $book, + 'chapter' => $chapter, + 'verse' => $verse, + 'tag' => $tag + ], 'tagged_verse')) !== null) + { + $tagged->name = $this->load->value([ + 'guid' => $tag + ], 'name', 'tag'); + + $tagged->description = $this->load->value([ + 'guid' => $tag + ], 'description', 'tag'); + + return $tagged; + } + + return null; + } + + /** + * Create a Tagged verse + * + * @param string $linker The linker GUID value + * @param string $translation The translation in which the note is made + * @param int $book The book in which the note is made + * @param int $chapter The chapter in which the note is made + * @param int $verse The verse where the note is made + * @param string $tag The tag being added + * + * @return bool True on success + * @since 2.0.1 + **/ + private function create( + string $linker, + string $translation, + int $book, + int $chapter, + int $verse, + string $tag + ): bool + { + $guid = (string) GuidHelper::get(); + while (!GuidHelper::valid($guid, 'tagged_verse', 0, 'getbible')) + { + // must always be set + $guid = (string) GuidHelper::get(); + } + + return $this->insert->row([ + 'tag' => $tag, + 'access' => 0, + 'linker' => $linker, + 'abbreviation' => $translation, + 'book_nr' => $book, + 'chapter' => $chapter, + 'verse' => $verse, + 'guid' => $guid + ], 'tagged_verse'); + } + + /** + * Create a Tagged verse for a linker using a system tagged verse + * + * @param string $linker The linker GUID value + * @param object $tagged The system tagged verse + * @param int $published The new tagged verse state [default trashed = -2] + * + * @return bool True on success + * @since 2.0.1 + **/ + private function createForLinker( + string $linker, + object $tagged, + int $published = -2 + ): bool + { + $guid = (string) GuidHelper::get(); + while (!GuidHelper::valid($guid, 'tagged_verse', 0, 'getbible')) + { + // must always be set + $guid = (string) GuidHelper::get(); + } + + return $this->insert->row([ + 'tag' => $tagged->tag, + 'access' => 0, + 'linker' => $linker, + 'abbreviation' => $tagged->abbreviation, + 'book_nr' => $tagged->book_nr, + 'chapter' => $tagged->chapter, + 'verse' => $tagged->verse, + 'guid' => $guid, + 'published' => $published + ], 'tagged_verse'); + } +} + diff --git a/libraries/jcb_powers/VDM.Joomla.GetBible/src/Tagged/Paragraphs.php b/libraries/jcb_powers/VDM.Joomla.GetBible/src/Tagged/Paragraphs.php new file mode 100644 index 0000000..9b46749 --- /dev/null +++ b/libraries/jcb_powers/VDM.Joomla.GetBible/src/Tagged/Paragraphs.php @@ -0,0 +1,275 @@ + + * @git GetBible + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ + +namespace VDM\Joomla\GetBible\Tagged; + + +use Joomla\CMS\Router\Route; + + +/** + * The GetBible Tagged Paragraphs + * + * @since 2.0.1 + */ +final class Paragraphs +{ + /** + * The Previous Book number + * + * @var int + * @since 2.0.1 + */ + private int $previousBook = 0; + + /** + * The Previous Chapter number + * + * @var int + * @since 2.0.1 + */ + private int $previousChapter = 0; + + /** + * The Previous Verse number + * + * @var int + * @since 2.0.1 + */ + private int $previousVerse = 0; + + /** + * The Current Group number + * + * @var int + * @since 2.0.1 + */ + private int $group = 0; + + /** + * The paragraphs being build + * + * @var array + * @since 2.0.1 + */ + private array $paragraphs = []; + + /** + * Main function to get sorted paragraphs. + * + * @param array $items The items to be sorted into paragraphs. + * @param string $translation The translation to be used. + * + * @return array The sorted paragraphs. + * @since 2.0.1 + */ + public function get(array $items, string $translation = 'kjv'): array + { + $this->resetProperties(); + + // sort the items by book, chapter, and verse + usort($items, function ($a, $b) { + if ($a->book_nr != $b->book_nr) { + return $a->book_nr - $b->book_nr; + } + if ($a->chapter != $b->chapter) { + return $a->chapter - $b->chapter; + } + return $a->verse - $b->verse; + }); + + $this->sortIntoParagraphs($items); + $this->setUrls($translation); + + return $this->paragraphs; + } + + /** + * Reset properties before getting paragraphs + * + * @return void + * @since 2.0.1 + */ + private function resetProperties(): void + { + $this->previousBook = 0; + $this->previousChapter = 0; + $this->previousVerse = 0; + $this->group = 0; + $this->paragraphs = []; + } + + /** + * Sort items into paragraphs. + * + * @param array $items The items to be sorted into paragraphs. + * + * @return void + * @since 2.0.1 + */ + private function sortIntoParagraphs($items): void + { + foreach ($items as $item) + { + if ($this->isNotSequential($item)) + { + $this->group++; + } + + $key = $this->getKey($item); + + if (empty($this->paragraphs[$key])) + { + $this->setDetails($item, $key); + } + + $this->addVerse($item, $key); + + $this->updatePrevious($item); + } + } + + /** + * Check if a verse is not sequential. + * + * @param object $item The verse to be checked. + * + * @return bool Whether the verse is not sequential. + * @since 2.0.1 + */ + private function isNotSequential(object $item): bool + { + return $this->previousVerse > 0 + && ((int) $item->book_nr > $this->previousBook + || (int) $item->chapter > $this->previousChapter + || (int) $item->verse > $this->previousVerse + 1); + } + + /** + * Generate a key based on the verse item. + * + * @param object $item The verse item. + * + * @return string The generated key. + * @since 2.0.1 + */ + private function getKey(object $item): string + { + return $item->book_nr . '_' . $item->chapter . '_' . $this->group; + } + + /** + * Set details for a verse. + * + * @param object $item The verse item. + * @param string $key The key for the paragraph. + * + * @return void + * @since 2.0.1 + */ + private function setDetails(object $item, string $key): void + { + $this->paragraphs[$key]['name'] = $item->name . ' ' . $item->chapter; + $this->paragraphs[$key]['book'] = $item->name; + $this->paragraphs[$key]['data_book'] = preg_replace('/[^\p{L}\p{N}\s]/u', '', $item->name); + $this->paragraphs[$key]['chapter'] = $item->chapter; + } + + /** + * Add a verse to the paragraphs. + * + * @param object $item The verse item. + * @param string $key The key for the paragraph. + * + * @return void + * @since 2.0.1 + */ + private function addVerse(object $item, string $key): void + { + $this->paragraphs[$key]['verses'][$item->verse] = ['number' => $item->verse, 'text' => $item->text]; + } + + /** + * Update the previous verse, book, and chapter to the current one. + * + * @param object $item The current verse item. + * + * @return void + * @since 2.0.1 + */ + private function updatePrevious(object $item): void + { + $this->previousVerse = (int) $item->verse; + $this->previousBook = (int) $item->book_nr; + $this->previousChapter = (int) $item->chapter; + } + + /** + * Set URLs for the paragraphs. + * + * @param string $translation The translation to be used. + * + * @return void + * @since 2.0.1 + */ + private function setUrls(string $translation): void + { + if ($this->paragraphs !== []) + { + foreach ($this->paragraphs as $chapter => &$paragraph) + { + $this->setVerseAndName($paragraph); + $this->setUrl($paragraph, $translation); + } + } + } + + /** + * Set verse and name for a paragraph. + * + * @param array $paragraph The paragraph to be updated. + * + * @return void + * @since 2.0.1 + */ + private function setVerseAndName(array &$paragraph): void + { + $verse = array_keys($paragraph['verses']); + $first = reset($verse); + $last = end($verse); + + if ($first == $last) + { + $paragraph['name'] .= ':' . $first; + $paragraph['verse'] = $first; + } + else + { + $paragraph['name'] .= ':' . $first . '-' . $last; + $paragraph['verse'] = $first . '-' . $last; + } + } + + /** + * Set URL for a paragraph. + * + * @param array $paragraph The paragraph to be updated. + * @param string $translation The translation to be used. + * + * @return void + * @since 2.0.1 + */ + private function setUrl(array &$paragraph, string $translation): void + { + $paragraph['url'] = Route::_('index.php?option=com_getbible&view=app&t=' . $translation . '&ref=' . $paragraph['book'] . '&chapter=' . $paragraph['chapter'] . '&verse=' . $paragraph['verse']); + } +} + diff --git a/libraries/jcb_powers/VDM.Joomla.GetBible/src/Tagged/index.html b/libraries/jcb_powers/VDM.Joomla.GetBible/src/Tagged/index.html new file mode 100644 index 0000000..fa6d84e --- /dev/null +++ b/libraries/jcb_powers/VDM.Joomla.GetBible/src/Tagged/index.html @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/libraries/jcb_powers/VDM.Joomla.GetBible/src/Utilities/Http.php b/libraries/jcb_powers/VDM.Joomla.GetBible/src/Utilities/Http.php new file mode 100644 index 0000000..52c3cd4 --- /dev/null +++ b/libraries/jcb_powers/VDM.Joomla.GetBible/src/Utilities/Http.php @@ -0,0 +1,48 @@ + + * @git GetBible + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ + +namespace VDM\Joomla\GetBible\Utilities; + + +use Joomla\CMS\Http\Http as JoomlaHttp; +use Joomla\Registry\Registry; + + +/** + * The GetBible Http + * + * @since 2.0.1 + */ +final class Http extends JoomlaHttp +{ + /** + * Constructor. + * + * @since 2.0.1 + * @throws \InvalidArgumentException + **/ + public function __construct() + { + // setup config + $config = [ + 'userAgent' => 'JoomlaGetBible/2.0', + 'headers' => [ + 'Content-Type' => 'application/json' + ] + ]; + + $options = new Registry($config); + + // run parent constructor + parent::__construct($options); + } +} + diff --git a/libraries/jcb_powers/VDM.Joomla.GetBible/src/Utilities/Response.php b/libraries/jcb_powers/VDM.Joomla.GetBible/src/Utilities/Response.php new file mode 100644 index 0000000..4264c8a --- /dev/null +++ b/libraries/jcb_powers/VDM.Joomla.GetBible/src/Utilities/Response.php @@ -0,0 +1,123 @@ + + * @git GetBible + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ + +namespace VDM\Joomla\GetBible\Utilities; + + +use Joomla\CMS\Http\Response as JoomlaResponse; +use VDM\Joomla\Utilities\JsonHelper; +use VDM\Joomla\Utilities\StringHelper; + + +/** + * The GetBible Response + * + * @since 2.0.1 + */ +final class Response +{ + /** + * Process the response and decode it. + * + * @param JoomlaResponse $response The response. + * @param integer $expectedCode The expected "good" code. + * @param mixed $default The default if body not have length + * + * @return mixed + * + * @since 2.0.1 + * @throws \DomainException + **/ + public function get(JoomlaResponse $response, int $expectedCode = 200, $default = null) + { + // Validate the response code. + if ($response->code != $expectedCode) + { + // Decode the error response and throw an exception. + $message = $this->error($response); + + // Throw an exception with the GetBible error message and code. + throw new \DomainException($message, $response->code); + } + + return $this->getBody($response, $default); + } + + /** + * Return the body from the response + * + * @param JoomlaResponse $response The response. + * @param mixed $default The default if body not have length + * + * @return mixed + * @since 2.0.1 + **/ + protected function getBody(JoomlaResponse $response, $default = null) + { + // check that we have a body + if (isset($response->body) && StringHelper::check($response->body)) + { + // if it's JSON, decode it + if (JsonHelper::check($response->body)) + { + return json_decode((string) $response->body); + } + + // if it's XML, convert it to an object + libxml_use_internal_errors(true); + $xml = simplexml_load_string($response->body); + if ($xml !== false) + { + return $xml; + } + + // if it's neither JSON nor XML, return as is + return $response->body; + } + + return $default; + } + + /** + * Get the error message from the GetBible API response + * + * @param JoomlaResponse $response The response. + * + * @return string + * @since 2.0.1 + **/ + protected function error(JoomlaResponse $response): string + { + // do we have a json string + if (isset($response->body) && JsonHelper::check($response->body)) + { + $error = json_decode($response->body); + } + else + { + return 'Invalid or empty response body.'; + } + + // check if GetBible returned an error object + if (isset($error->Error)) + { + // error object found, extract message and code + $errorMessage = isset($error->Error->Message) ? $error->Error->Message : 'Unknown error.'; + $errorCode = isset($error->Error->Code) ? $error->Error->Code : 'Unknown error code.'; + + // return formatted error message + return 'Wasabi Error: ' . $errorMessage . ' Code: ' . $errorCode; + } + + return 'No error information found in response.'; + } +} + diff --git a/libraries/jcb_powers/VDM.Joomla.GetBible/src/Utilities/SessionHelper.php b/libraries/jcb_powers/VDM.Joomla.GetBible/src/Utilities/SessionHelper.php new file mode 100644 index 0000000..cf010ee --- /dev/null +++ b/libraries/jcb_powers/VDM.Joomla.GetBible/src/Utilities/SessionHelper.php @@ -0,0 +1,76 @@ + + * @git GetBible + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ + +namespace VDM\Joomla\GetBible\Utilities; + + +use Joomla\CMS\Factory as JoomlaFactory; +use Joomla\CMS\Session\Session; +use VDM\Joomla\Utilities\GuidHelper; + + +/** + * The GetBible Session Helper + * - Just for easy set and get + * + * @since 2.0.1 + */ +final class SessionHelper +{ + /** + * The Session + * + * @var Session + * @since 3.2.0 + */ + protected Session $session; + + /** + * Constructor + * + * @param Session|null $session The Joomla session. + * + * @since 3.2.0 + */ + public function __construct(?Session $session = null) + { + $this->session = $session ?: JoomlaFactory::getSession(); + } + + /** + * Get data from the session store + * + * @param string $name Name of a variable + * @param mixed $default Default value of a variable if not set + * + * @return mixed Value of a variable + * @since 2.1.0 + */ + public function get(string $name, $default = null) + { + return $this->session->get($name, $default); + } + + /** + * Set data into the session store. + * + * @param string $name Name of a variable. + * @param mixed $value Value of a variable. + * + * @return mixed Old value of a variable. + * @since 2.1.0 + */ + public function set($name, $value = null) + { + return $this->session->set($name, $value); + } +} + diff --git a/libraries/jcb_powers/VDM.Joomla.GetBible/src/Utilities/StringHelper.php b/libraries/jcb_powers/VDM.Joomla.GetBible/src/Utilities/StringHelper.php new file mode 100644 index 0000000..faad516 --- /dev/null +++ b/libraries/jcb_powers/VDM.Joomla.GetBible/src/Utilities/StringHelper.php @@ -0,0 +1,120 @@ + + * @git GetBible + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ + +namespace VDM\Joomla\GetBible\Utilities; + + +/** + * The GetBible String Helper + * + * @since 2.0.1 + */ +final class StringHelper +{ + /** + * Return an array of words + * + * @param string $text The actual sentence + * + * @return array An array of words + */ + public function split(string $text): array + { + if ($this->isCJK($text)) + { + // Split by characters for languages that don't use spaces + $words = (array) preg_split('//u', $text, -1, PREG_SPLIT_NO_EMPTY); + } + elseif (strpos($text, ' ') !== false) + { + // Split by spaces for languages that use them + $words = (array) preg_split('/(\s+)/u', $text, -1, PREG_SPLIT_DELIM_CAPTURE); + } + else + { + $words = [$text]; + } + + return $words; + } + + /** + * Return an array of only words + * + * @param string $text The actual sentence + * @param bool $punctuation Switch to keep or remove punctuation + * + * @return array An array of words + */ + public function splitToWords(string $text, bool $punctuation = true): array + { + $words = array_filter($this->split($text), function($word) { + $plain_word = preg_replace('/[^\p{L}\p{N}\s]/u', '', $word); + if ($this->hasLength($plain_word)) { + return true; + } return false; + }); + + if ($words === []) + { + return $words; + } + + // remove punctuation + if (!$punctuation) + { + $words = array_map(function($word) { + return preg_replace('/[^\p{L}\p{N}\s]/u', '', $word); + }, $words); + } + + // make the array 1 based + // so that the key 1 is the first word + array_unshift($words, null); + unset($words[0]); + + return $words; + } + + /** + * Checks if a string contains characters typically used in East Asian languages (Chinese, Japanese, Korean) + * These languages do not typically use word boundaries in the same way as languages written in Latin script + * + * @param string $text The string to be checked for CJK characters + * + * @return bool True if the string contains at least one CJK character, false otherwise + */ + public function isCJK(string $text): bool + { + if (preg_match('/[\x{4E00}-\x{9FFF}\x{3040}-\x{309F}\x{30A0}-\x{30FF}\x{AC00}-\x{D7AF}]/u', $text)) + { + return true; + } + return false; + } + + /** + * Make sure a string has a length + * + * @param string $word The actual string to check + * + * @return bool True if its a string with characters. + */ + public function hasLength(string $word): bool + { + // Trim the string + $trimmed = trim($word); + + // Return true if the trimmed string is not empty, false otherwise + return !empty($trimmed); + } +} + diff --git a/libraries/jcb_powers/VDM.Joomla.GetBible/src/Utilities/Uri.php b/libraries/jcb_powers/VDM.Joomla.GetBible/src/Utilities/Uri.php new file mode 100644 index 0000000..094555e --- /dev/null +++ b/libraries/jcb_powers/VDM.Joomla.GetBible/src/Utilities/Uri.php @@ -0,0 +1,63 @@ + + * @git GetBible + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ + +namespace VDM\Joomla\GetBible\Utilities; + + +use Joomla\Uri\Uri as JoomlaUri; +use VDM\Joomla\GetBible\Config; + + +/** + * The GetBible Uri + * + * @since 2.0.1 + */ +final class Uri +{ + /** + * The Config class + * + * @var Config + * @since 2.0.1 + */ + protected Config $config; + + /** + * Constructor + * + * @param Config $config The config class. + * + * @since 2.0.1 + **/ + public function __construct(Config $config) + { + // set the API config + $this->config = $config; + } + + /** + * Method to build and return a full request URL for the request. + * + * @param string $path URL to inflect + * + * @return JoomlaUri + * @since 2.0.1 + **/ + public function get(string $path): JoomlaUri + { + // Get a new Uri object focusing the api url and given path. + $uri = new JoomlaUri($this->config->endpoint . $path); + + return $uri; + } +} + diff --git a/libraries/jcb_powers/VDM.Joomla.GetBible/src/Utilities/index.html b/libraries/jcb_powers/VDM.Joomla.GetBible/src/Utilities/index.html new file mode 100644 index 0000000..fa6d84e --- /dev/null +++ b/libraries/jcb_powers/VDM.Joomla.GetBible/src/Utilities/index.html @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/libraries/jcb_powers/VDM.Joomla.GetBible/src/Watcher.php b/libraries/jcb_powers/VDM.Joomla.GetBible/src/Watcher.php new file mode 100644 index 0000000..4c65a1b --- /dev/null +++ b/libraries/jcb_powers/VDM.Joomla.GetBible/src/Watcher.php @@ -0,0 +1,693 @@ + + * @git GetBible + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ + +namespace VDM\Joomla\GetBible; + + +use Joomla\CMS\Date\Date; +use VDM\Joomla\GetBible\Database\Load; +use VDM\Joomla\GetBible\Database\Insert; +use VDM\Joomla\GetBible\Database\Update; +use VDM\Joomla\GetBible\Api\Translations; +use VDM\Joomla\GetBible\Api\Books; +use VDM\Joomla\GetBible\Api\Chapters; +use VDM\Joomla\GetBible\Api\Verses; + + +/** + * The GetBible Watcher + * + * @since 2.0.1 + */ +final class Watcher +{ + /** + * The Load class + * + * @var Load + * @since 2.0.1 + */ + protected Load $load; + + /** + * The Insert class + * + * @var Insert + * @since 2.0.1 + */ + protected Insert $insert; + + /** + * The Update class + * + * @var Update + * @since 2.0.1 + */ + protected Update $update; + + /** + * The Translations class + * + * @var Translations + * @since 2.0.1 + */ + protected Translations $translations; + + /** + * The Books class + * + * @var Books + * @since 2.0.1 + */ + protected Books $books; + + /** + * The Chapters class + * + * @var Chapters + * @since 2.0.1 + */ + protected Chapters $chapters; + + /** + * The Verses class + * + * @var Verses + * @since 2.0.1 + */ + protected Verses $verses; + + /** + * The fresh load switch + * + * @var bool + * @since 2.0.1 + */ + protected bool $fresh = false; + + /** + * The sql date of today + * + * @var string + * @since 2.0.1 + */ + protected string $today; + + /** + * The target verse + * + * @var object|null + * @since 2.0.1 + */ + protected ?object $verse; + + /** + * Constructor + * + * @param Load $load The load object. + * @param Insert $insert The insert object. + * @param Update $update The update object. + * @param Translations $translations The translations API object. + * @param Books $books The books API object. + * @param Chapters $chapters The chapters API object. + * @param Verses $verses The verses API object. + * + * @since 2.0.1 + */ + public function __construct( + Load $load, + Insert $insert, + Update $update, + Translations $translations, + Books $books, + Chapters $chapters, + Verses $verses) + { + $this->load = $load; + $this->insert = $insert; + $this->update = $update; + $this->translations = $translations; + $this->books = $books; + $this->chapters = $chapters; + $this->verses = $verses; + + // just in-case we set a date + $this->today = (new Date())->toSql(); + } + + /** + * The see if new chapters was installed, and therefore new + * + * @return bool true if is new + * @since 2.0.1 + */ + public function isNew(): bool + { + return $this->fresh; + } + + /** + * Check if a translation has enough verses + * + * @param string $translation The translation. + * + * @return bool + * @since 2.0.1 + */ + public function enoughVerses(string $translation = 'kjv'): bool + { + $total = $this->totalVerses($translation); + + if ($total < 10000) + { + return false; + } + + return true; + } + + /** + * Get the total number of verses in the database of a given translation + * + * @param string $translation The translation. + * + * @return int|null + * @since 2.0.1 + */ + public function totalVerses(string $translation = 'kjv'): ?int + { + return $this->load->count( + ['abbreviation' => $translation], 'verse' + ); + } + + /** + * Watching that the local Database and API is in sync + * + * @param string $translation The translation. + * @param int $book The book number. + * @param int $chapter The chapter number. + * + * @return bool True on success + * @since 2.0.1 + */ + public function api(string $translation, int $book, int $chapter): bool + { + // does the translation exist + if ($this->translation($translation) === null) + { + return false; + } + + // does the book exist + if ($this->book($translation, $book) === null) + { + return false; + } + + // does the chapter exist, and get hash value + if (($hash = $this->chapter($translation, $book, $chapter)) === null) + { + return false; + } + + // load the verses if not found + if ($this->verses($translation, $book, $chapter)) + { + if ($this->isNew() || $this->hold()) + { + return true; + } + + // get API chapter hash value + $api_hash = $this->chapters->sha($translation, $book, $chapter); + + // confirm chapter hash has not changed + if (hash_equals($hash, $api_hash)) + { + return $this->bump(); + } + + if ($this->update($translation, $book, $chapter)) + { + // now update the hash of this chapter + return $this->updateHash($translation, $book, $chapter, $api_hash); + } + } + + return false; + } + + /** + * Get the next chapter + * + * @param string $translation The translation. + * @param int $book The book number. + * @param int $chapter The chapter number. + * @param bool $force The switch to force the getting. + * + * @return int|null Number if there is a next, else null + * @since 2.0.1 + */ + public function getNextChapter(string $translation, int $book, int $chapter, bool $force = false): ?int + { + // we load the next chapter + $next = $chapter + 1; + // check if this books has this next chapter + if (($force || !$this->isNew()) && $this->load->value( + ['abbreviation' => $translation, 'book_nr' => $book, 'chapter' => $next], + 'sha', 'chapter' + )) + { + return $next; + } + + return null; + } + + /** + * Get the previous chapter + * + * @param int $chapter The chapter number. + * @param bool $force The switch to force the getting. + * + * @return int|null Number if there is a previous, else null + * @since 2.0.1 + */ + public function getPreviousChapter(int $chapter, bool $force = false): ?int + { + // we load the previous chapter + $previous = $chapter - 1; + if (($force || !$this->isNew()) && $previous > 0) + { + return $previous; + } + + return null; + } + + /** + * Get the last chapter of a book + * + * @param string $translation The translation. + * @param int $book The book number. + * + * @return int|null Number if there is a previous, else null + * @since 2.0.1 + */ + public function getLastChapter(string $translation, int $book): ?int + { + // we load the last chapter + return $this->load->max( + ['abbreviation' => $translation, 'book_nr' => $book], + 'chapter', 'chapter' + ); + } + + /** + * Get the next book + * + * @param string $translation The translation. + * @param int $book The book number. + * @param int $try The number of tries + * + * @return int|null Number if there is a next, else null + * @since 2.0.1 + */ + public function getNextBook(string $translation, int $book, int $try = 0): ?int + { + // we load the next chapter + $next = $book + 1; + + // if we already looked over 90 + if ($next >= 90) + { + $next = 1; + } + + // check if this book exist + if ($this->load->value( + ['abbreviation' => $translation, 'nr' => $next], + 'sha', 'book' + )) + { + return $next; + } + + $try++; + + // could not be found :( + if ($try >= 180) + { + return null; + } + + return $this->getNextBook($translation, $next, $try); + } + + /** + * Get the previous book + * + * @param string $translation The translation. + * @param int $book The book number. + * @param int $try The number of tries + * + * @return int|null Number if there is a previous, else null + * @since 2.0.1 + */ + public function getPreviousBook(string $translation, int $book, int $try = 0): ?int + { + // we load the previous book + $previous = $book - 1; + + // if we already looked over 90 + if ($previous <= 0) + { + $previous = 90; + } + + // check if this book exist + if ($this->load->value( + ['abbreviation' => $translation, 'nr' => $previous], + 'sha', 'book' + )) + { + return $previous; + } + + $try++; + + // could not be found :( + if ($try >= 180) + { + return null; + } + + return $this->getPreviousBook($translation, $previous, $try); + } + + /** + * Get Translation Hash Value + * + * @param string $translation The translation. + * + * @return string|null The sha of the translation + * @since 2.0.1 + */ + private function translation(string $translation): ?string + { + // check local value + if (($translation_sha = $this->load->value(['abbreviation' => $translation], 'sha', 'translation')) !== null) + { + return $translation_sha; + } + + // get all the translations + $translations = $this->translations->list(); + + // check return data + if (!isset($translations->{$translation}) || !isset($translations->{$translation}->sha)) + { + return null; + } + + // add them to the database + $this->insert->items((array) $translations, 'translation'); + + return $translations->{$translation}->sha; + } + + /** + * Get Book Hash Value + * + * @param string $translation The translation. + * @param int $book The book number. + * + * @return string|null The sha of the book + * @since 2.0.1 + */ + private function book(string $translation, int $book): ?string + { + // check local value + if (($book_sha = $this->load->value(['abbreviation' => $translation, 'nr' => $book], 'sha', 'book')) !== null) + { + return $book_sha; + } + + // get all the books + $books = $this->books->list($translation); + + // check return data + if (!isset($books->{$book}) || !isset($books->{$book}->sha)) + { + return null; + } + + // add them to the database + $this->insert->items((array) $books, 'book'); + + return $books->{$book}->sha; + } + + /** + * Get Chapter Hash Value + * + * @param string $translation The translation. + * @param int $book The book number. + * @param int $chapter The chapter number. + * + * @return string|null The sha of the chapter + * @since 2.0.1 + */ + private function chapter(string $translation, int $book, int $chapter): ?string + { + // check local value + if (($chapter_sha = $this->load->value( + ['abbreviation' => $translation, 'book_nr' => $book, 'chapter' => $chapter], + 'sha', 'chapter' + )) !== null) + { + return $chapter_sha; + } + + // get all the books + $chapters = $this->chapters->list($translation, $book); + + // check return data + if (!isset($chapters->{$chapter}) || !isset($chapters->{$chapter}->sha)) + { + return null; + } + + // add them to the database + $this->insert->items((array) $chapters, 'chapter'); + + return $chapters->{$chapter}->sha; + } + + /** + * Load verses if not in local database + * + * @param string $translation The translation. + * @param int $book The book number. + * @param int $chapter The chapter number. + * + * @return bool True if in local database + * @since 2.0.1 + */ + private function verses(string $translation, int $book, int $chapter): bool + { + // check local value + if (($this->verse = $this->load->item( + ['abbreviation' => $translation, 'book_nr' => $book, 'chapter' => $chapter, 'verse' => 1], + 'verse' + )) !== null) + { + return true; + } + + // get all the verses + if (($verses = $this->verses->get($translation, $book, $chapter)) === null) + { + return false; + } + + // dynamic update all verse objects + $insert = ['book_nr' => $book, 'abbreviation' => $translation]; + array_walk($verses->verses, function ($item, $key) use ($insert) { + foreach ($insert as $k => $v) { $item->$k = $v; } + }); + + $this->fresh = true; + + // add them to the database + return $this->insert->items((array) $verses->verses, 'verse'); + } + + /** + * Trigger the update of the verses of a translation-book-chapter + * + * @param string $translation The translation. + * @param int $book The book number. + * @param int $chapter The chapter number. + * + * @return bool True if update was a success + * @since 2.0.1 + */ + private function update(string $translation, int $book, int $chapter): bool + { + // load all the verses from the local database + if (($verses = $this->load->items( + ['abbreviation' => $translation, 'book_nr' => $book, 'chapter' => $chapter], + 'verse' + )) !== null) + { + // get verses from the API + if (($api = $this->verses->get($translation, $book, $chapter)) === null) + { + return false; + } + + $update = []; + $insert = []; + + // dynamic update all verse objects + foreach ($api->verses as $verse) + { + // check if the verse exist + if (($object = $this->getVerse((int) $verse->verse, $verses)) !== null) + { + $verse->id = $object->id; + $verse->created = $this->today; + $update[] = $verse; + } + else + { + $insert[] = $verse; + } + } + + // check if we have values to insert + if ($insert !== []) + { + $this->insert->items($insert, 'verse'); + } + + // update the local verses + if ($update !== [] && $this->update->items($update, 'id', 'verse')) + { + return true; + } + } + + return false; + } + + /** + * Get a verse text from the API array of verses + * + * @param int $number The verse number. + * @param array $verses The api verses + * + * @return object|null The verse string + * @since 2.0.1 + */ + private function getVerse(int $number, array &$verses): ?object + { + foreach ($verses as $verse) + { + if ($verse->verse === $number) + { + return $verse; + } + } + + return null; + } + + /** + * Trigger the update of a chapter hash value + * + * @param string $translation The translation. + * @param int $book The book number. + * @param int $chapter The chapter number. + * @param string $hash The API chapter hash value. + * + * @return bool True if update was a success + * @since 2.0.1 + */ + private function updateHash(string $translation, int $book, int $chapter, string $hash): bool + { + // load the chapter + if (($item = $this->load->item( + ['abbreviation' => $translation, 'book_nr' => $book, 'chapter' => $chapter], + 'chapter' + )) !== null) + { + $update = []; + $update['id'] = $item->id; + $update['sha'] = $hash; + $update['created'] = $this->today; + + // update the local chapter + return $this->update->row($update, 'id', 'chapter'); + } + + return false; + } + + /** + * Check if its time to match the API hash + * + * @return bool false if its time to check for an update + * @since 2.0.1 + */ + private function hold(): bool + { + // Create DateTime objects from the strings + try { + $today = new \DateTime($this->today); + $created = new \DateTime($this->verse->created); + } catch (\Exception $e) { + return false; + } + + // Calculate the difference + $interval = $today->diff($created); + + // Check if the interval is more than 1 month + if ($interval->m >= 1 || $interval->y >= 1) + { + return false; // More than a month, it's time to check for an update + } + else + { + return true; // Within the last month, hold off on the update check + } + } + + /** + * Bump the checking time + * + * @return bool true when the update was a success + * @since 2.0.1 + */ + private function bump(): bool + { + $update = []; + $update['id'] = $this->verse->id; + $update['created'] = $this->today; + + // update the local verse + return $this->update->row($update, 'id', 'verse'); + } +} + diff --git a/libraries/jcb_powers/VDM.Joomla.GetBible/src/index.html b/libraries/jcb_powers/VDM.Joomla.GetBible/src/index.html new file mode 100644 index 0000000..fa6d84e --- /dev/null +++ b/libraries/jcb_powers/VDM.Joomla.GetBible/src/index.html @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/libraries/jcb_powers/VDM.Joomla.Gitea/index.html b/libraries/jcb_powers/VDM.Joomla.Gitea/index.html new file mode 100644 index 0000000..fa6d84e --- /dev/null +++ b/libraries/jcb_powers/VDM.Joomla.Gitea/index.html @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/libraries/jcb_powers/VDM.Joomla.Gitea/src/Abstraction/Api.php b/libraries/jcb_powers/VDM.Joomla.Gitea/src/Abstraction/Api.php new file mode 100644 index 0000000..7f76657 --- /dev/null +++ b/libraries/jcb_powers/VDM.Joomla.Gitea/src/Abstraction/Api.php @@ -0,0 +1,83 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ + +namespace VDM\Joomla\Gitea\Abstraction; + + +use VDM\Joomla\Gitea\Utilities\Http; +use VDM\Joomla\Gitea\Utilities\Uri; +use VDM\Joomla\Gitea\Utilities\Response; + + +/** + * The Gitea Api + * + * @since 3.2.0 + */ +abstract class Api +{ + /** + * The Http class + * + * @var Http + * @since 3.2.0 + */ + protected Http $http; + + /** + * The Uri class + * + * @var Uri + * @since 3.2.0 + */ + protected Uri $uri; + + /** + * The Response class + * + * @var Response + * @since 3.2.0 + */ + protected Response $response; + + /** + * Constructor. + * + * @param Http $http The http class. + * @param Uri $uri The uri class. + * @param Response $response The response class. + * + * @since 3.2.0 + **/ + public function __construct(Http $http, Uri $uri, Response $response) + { + $this->http = $http; + $this->uri = $uri; + $this->response = $response; + } + + /** + * Load/Reload API. + * + * @param string $url The url. + * @param token $token The token. + * + * @return void + * @since 3.2.0 + **/ + public function load_(string $url, string $token) + { + $this->uri->setUrl($url); + $this->http->setToken($token); + } + +} + diff --git a/libraries/jcb_powers/VDM.Joomla.Gitea/src/Abstraction/index.html b/libraries/jcb_powers/VDM.Joomla.Gitea/src/Abstraction/index.html new file mode 100644 index 0000000..fa6d84e --- /dev/null +++ b/libraries/jcb_powers/VDM.Joomla.Gitea/src/Abstraction/index.html @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/libraries/jcb_powers/VDM.Joomla.Gitea/src/Admin/Cron.php b/libraries/jcb_powers/VDM.Joomla.Gitea/src/Admin/Cron.php new file mode 100644 index 0000000..04031c2 --- /dev/null +++ b/libraries/jcb_powers/VDM.Joomla.Gitea/src/Admin/Cron.php @@ -0,0 +1,72 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ + +namespace VDM\Joomla\Gitea\Admin; + + +use VDM\Joomla\Gitea\Abstraction\Api; + + +/** + * The Gitea Admin Cron + * + * @since 3.2.0 + */ +class Cron extends Api +{ + /** + * List cron tasks. + * + * @param int $page Page number of results to return (1-based). + * @param int $limit Page size of results. + * + * @return array|null + * @since 3.2.0 + **/ + public function list(int $page = 1, int $limit = 10): ?array + { + // Build the request path. + $path = "/admin/cron"; + + // Set the query parameters. + $uri = $this->uri->get($path); + $uri->setVar('page', $page); + $uri->setVar('limit', $limit); + + // Send the get request. + return $this->response->get( + $this->http->get($uri) + ); + } + + /** + * Run cron task. + * + * @param string $task The cron task to run. + * + * @return string + * @since 3.2.0 + **/ + public function run(string $task): string + { + // Build the request path. + $path = "/admin/cron/{$task}"; + + // Send the post request. + return $this->response->get( + $this->http->post( + $this->uri->get($path) + ), 204, 'success' + ); + } + +} + diff --git a/libraries/jcb_powers/VDM.Joomla.Gitea/src/Admin/Organizations.php b/libraries/jcb_powers/VDM.Joomla.Gitea/src/Admin/Organizations.php new file mode 100644 index 0000000..df1e6b4 --- /dev/null +++ b/libraries/jcb_powers/VDM.Joomla.Gitea/src/Admin/Organizations.php @@ -0,0 +1,51 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ + +namespace VDM\Joomla\Gitea\Admin; + + +use VDM\Joomla\Gitea\Abstraction\Api; + + +/** + * The Gitea Admin Organizations + * + * @since 3.2.0 + */ +class Organizations extends Api +{ + /** + * List all organizations. + * + * @param int $page Page number of results to return (1-based). + * @param int $limit Page size of results. + * + * @return array|null + * @since 3.2.0 + **/ + public function list(int $page = 1, int $limit = 10): ?array + { + // Build the request path. + $path = "/admin/orgs"; + + // Set the query parameters. + $uri = $this->uri->get($path); + $uri->setVar('page', $page); + $uri->setVar('limit', $limit); + + // Send the get request. + return $this->response->get( + $this->http->get($uri) + ); + } + +} + diff --git a/libraries/jcb_powers/VDM.Joomla.Gitea/src/Admin/Unadopted.php b/libraries/jcb_powers/VDM.Joomla.Gitea/src/Admin/Unadopted.php new file mode 100644 index 0000000..c73cf3e --- /dev/null +++ b/libraries/jcb_powers/VDM.Joomla.Gitea/src/Admin/Unadopted.php @@ -0,0 +1,101 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ + +namespace VDM\Joomla\Gitea\Admin; + + +use VDM\Joomla\Gitea\Abstraction\Api; + + +/** + * The Gitea Admin Unadopted + * + * @since 3.2.0 + */ +class Unadopted extends Api +{ + /** + * List unadopted repositories. + * + * @param int $page Page number of results to return (1-based). + * @param int $limit Page size of results. + * @param string $pattern Pattern of repositories to search for. + * + * @return array|null + * @since 3.2.0 + **/ + public function list(int $page = 1, int $limit = 10, string $pattern = ''): ?array + { + // Build the request path. + $path = "/admin/unadopted"; + + // Set the query parameters. + $uri = $this->uri->get($path); + $uri->setVar('page', $page); + $uri->setVar('limit', $limit); + + if (!empty($pattern)) + { + $uri->setVar('pattern', $pattern); + } + + // Send the get request. + return $this->response->get( + $this->http->get($uri) + ); + } + + /** + * Adopt unadopted files as a repository. + * + * @param string $owner The owner name. + * @param string $repo The repository name. + * + * @return string + * @since 3.2.0 + **/ + public function adopt(string $owner, string $repo): string + { + // Build the request path. + $path = "/admin/unadopted/{$owner}/{$repo}"; + + // Send the post request. + return $this->response->get( + $this->http->post( + $this->uri->get($path), '' + ), 204, 'success' + ); + } + + /** + * Delete unadopted files. + * + * @param string $owner The owner name. + * @param string $repo The repository name. + * + * @return string + * @since 3.2.0 + **/ + public function delete(string $owner, string $repo): string + { + // Build the request path. + $path = "/admin/unadopted/{$owner}/{$repo}"; + + // Send the delete request. + return $this->response->get( + $this->http->delete( + $this->uri->get($path) + ), 204, 'success' + ); + } + +} + diff --git a/libraries/jcb_powers/VDM.Joomla.Gitea/src/Admin/Users.php b/libraries/jcb_powers/VDM.Joomla.Gitea/src/Admin/Users.php new file mode 100644 index 0000000..47ec3e5 --- /dev/null +++ b/libraries/jcb_powers/VDM.Joomla.Gitea/src/Admin/Users.php @@ -0,0 +1,207 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ + +namespace VDM\Joomla\Gitea\Admin; + + +use VDM\Joomla\Gitea\Abstraction\Api; + + +/** + * The Gitea Admin Users + * + * @since 3.2.0 + */ +class Users extends Api +{ + /** + * List all users. + * + * @param int $page Page number of results to return (1-based). + * @param int $limit Page size of results. + * + * @return array|null + * @since 3.2.0 + **/ + public function list(int $page = 1, int $limit = 10): ?array + { + // Build the request path. + $path = "/admin/users"; + + // build the URL + $url = $this->uri->get($path); + $url->setVar('page', $page); + $url->setVar('limit', $limit); + + // Send the get request. + return $this->response->get( + $this->http->get($url) + ); + } + + /** + * Create a user with extended options. + * + * @param string $loginName The user's login name. + * @param string $email The user's email address. + * @param string $password The user's password. + * @param string|null $username The username. + * @param string|null $fullName The user's full name (optional). + * @param bool|null $mustChangePassword User must change password on next login (optional). + * @param bool|null $restricted Restrict the user (optional). + * @param bool|null $sendNotify Send a notification email to the user (optional). + * @param int|null $sourceId Source ID (optional). + * @param string|null $visibility The user's visibility (optional). + * + * @return object|null + * @since 3.2.0 + **/ + public function create( + string $loginName, + string $email, + string $password, + string $username, + ?string $fullName = null, + ?bool $mustChangePassword = null, + ?bool $restricted = null, + ?bool $sendNotify = null, + ?int $sourceId = null, + ?string $visibility = null + ): ?object + { + // Build the request path. + $path = "/admin/users"; + + // Set the user data. + $data = new \stdClass(); + $data->login_name = $loginName; + $data->email = $email; + $data->password = $password; + $data->username = $username; + $data->full_name = $fullName; + $data->must_change_password = $mustChangePassword; + $data->restricted = $restricted; + $data->send_notify = $sendNotify; + $data->source_id = $sourceId; + $data->visibility = $visibility; + + // Send the post request. + return $this->response->get( + $this->http->post( + $this->uri->get($path), json_encode($data) + ), 201 + ); + } + + /** + * Delete a user. + * + * @param string $username The user's display name. + * + * @return string + * @since 3.2.0 + **/ + public function delete(string $username): string + { + // Build the request path. + $path = "/admin/users/{$username}"; + + // Send the delete request. + return $this->response->get( + $this->http->delete( + $this->uri->get($path) + ), 204, 'success' + ); + } + + /** + * Edit an existing user. + * + * @param string $username The user's display name. + * @param string $loginName The user's login name. + * @param int $sourceId The user's source ID. + * @param bool $active Optional. Is the user active? Default: false. + * @param bool $admin Optional. Is the user an admin? Default: false. + * @param bool $allowCreateOrganization Optional. Can the user create an organization? Default: false. + * @param bool $allowGitHook Optional. Can the user create Git hooks? Default: false. + * @param bool $allowImportLocal Optional. Can the user import local repositories? Default: false. + * @param string $description Optional. The user's description. Default: ''. + * @param string $email Optional. The user's email address. Default: ''. + * @param string $fullName Optional. The user's full name. Default: ''. + * @param string $location Optional. The user's location. Default: ''. + * @param int $maxRepoCreation Optional. Maximum repositories the user can create. Default: 0. + * @param bool $mustChangePassword Optional. Must the user change their password? Default: false. + * @param string $password Optional. The user's password. Default: ''. + * @param bool $prohibitLogin Optional. Is the user's login prohibited? Default: false. + * @param bool $restricted Optional. Is the user restricted? Default: false. + * @param string $visibility Optional. The user's visibility setting. Default: ''. + * @param string $website Optional. The user's website. Default: ''. + * + * @return object|null + * @since 3.2.0 + **/ + public function edit( + string $username, + string $loginName, + int $sourceId, + bool $active = false, + bool $admin = false, + bool $allowCreateOrganization = false, + bool $allowGitHook = false, + bool $allowImportLocal = false, + string $description = '', + string $email = '', + string $fullName = '', + string $location = '', + int $maxRepoCreation = 0, + bool $mustChangePassword = false, + string $password = '', + bool $prohibitLogin = false, + bool $restricted = false, + string $visibility = '', + string $website = '' + ): ?object + { + // Build the request path. + $path = "/admin/users/{$username}"; + + // Set the data. + $data = [ + 'login_name' => $loginName, + 'source_id' => $sourceId, + 'active' => $active, + 'admin' => $admin, + 'allow_create_organization' => $allowCreateOrganization, + 'allow_git_hook' => $allowGitHook, + 'allow_import_local' => $allowImportLocal, + 'description' => $description, + 'email' => $email, + 'full_name' => $fullName, + 'location' => $location, + 'max_repo_creation' => $maxRepoCreation, + 'must_change_password' => $mustChangePassword, + 'password' => $password, + 'prohibit_login' => $prohibitLogin, + 'restricted' => $restricted, + 'visibility' => $visibility, + 'website' => $website + ]; + + // Send the patch request. + return $this->response->get( + $this->http->patch( + $this->uri->get($path), json_encode($data) + ) + ); + } + +} + diff --git a/libraries/jcb_powers/VDM.Joomla.Gitea/src/Admin/Users/Keys.php b/libraries/jcb_powers/VDM.Joomla.Gitea/src/Admin/Users/Keys.php new file mode 100644 index 0000000..bea01de --- /dev/null +++ b/libraries/jcb_powers/VDM.Joomla.Gitea/src/Admin/Users/Keys.php @@ -0,0 +1,86 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ + +namespace VDM\Joomla\Gitea\Admin\Users; + + +use VDM\Joomla\Gitea\Abstraction\Api; + + +/** + * The Gitea Admin Users Keys + * + * @since 3.2.0 + */ +class Keys extends Api +{ + /** + * Add a public key on behalf of a user. + * + * @param string $userName The user's display name. + * @param string $publicKey The public key to add. + * @param string $keyTitle Title of the key to add. + * @param bool $readOnly Whether the key has only read access or read/write (optional). + * @param string|null $description Description of the key (optional). + * + * @return object|null + * @since 3.2.0 + **/ + public function add( + string $userName, + string $publicKey, + string $keyTitle, + bool $readOnly = false, + ?string $description = null + ): ?object + { + // Build the request path. + $path = "/admin/users/{$userName}/keys"; + + // Set the key data. + $data = new \stdClass(); + $data->key = $publicKey; + $data->title = $keyTitle; + $data->read_only = $readOnly; + $data->description = $description; + + // Send the post request. + return $this->response->get( + $this->http->post( + $this->uri->get($path), json_encode($data) + ), 201 + ); + } + + /** + * Delete a user's public key. + * + * @param string $username The user's display name. + * @param int $id The public key ID. + * + * @return string + * @since 3.2.0 + **/ + public function delete(string $username, int $id): string + { + // Build the request path. + $path = "/admin/users/{$username}/keys/{$id}"; + + // Send the delete request. + return $this->response->get( + $this->http->delete( + $this->uri->get($path) + ), 204, 'success' + ); + } + +} + diff --git a/libraries/jcb_powers/VDM.Joomla.Gitea/src/Admin/Users/Organization.php b/libraries/jcb_powers/VDM.Joomla.Gitea/src/Admin/Users/Organization.php new file mode 100644 index 0000000..ec1843f --- /dev/null +++ b/libraries/jcb_powers/VDM.Joomla.Gitea/src/Admin/Users/Organization.php @@ -0,0 +1,70 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ + +namespace VDM\Joomla\Gitea\Admin\Users; + + +use VDM\Joomla\Gitea\Abstraction\Api; + + +/** + * The Gitea Admin Users Organization + * + * @since 3.2.0 + */ +class Organization extends Api +{ + /** + * Create an organization on behalf of a user. + * + * @param string $username The user's display name. + * @param string $fullName The organization full name. + * @param string|null $description The organization description (optional). + * @param string|null $location The organization location (optional). + * @param bool $repoAdminChangeTeamAccess Whether repo admin can change team access (optional). + * @param string $visibility The organization visibility (optional). + * @param string|null $website The organization website (optional). + * + * @return object|null + * @since 3.2.0 + **/ + public function create( + string $username, + string $fullName, + ?string $description = null, + ?string $location = null, + bool $repoAdminChangeTeamAccess = false, + string $visibility = 'public', + ?string $website = null + ): ?object + { + // Build the request path. + $path = "/admin/users/{$username}/orgs"; + + // Set the organization data. + $data = new \stdClass(); + $data->full_name = $fullName; + $data->description = $description; + $data->location = $location; + $data->repo_admin_change_team_access = $repoAdminChangeTeamAccess; + $data->visibility = $visibility; + $data->website = $website; + + // Send the post request. + return $this->response->get( + $this->http->post( + $this->uri->get($path), json_encode($data) + ), 201 + ); + } + +} + diff --git a/libraries/jcb_powers/VDM.Joomla.Gitea/src/Admin/Users/Repository.php b/libraries/jcb_powers/VDM.Joomla.Gitea/src/Admin/Users/Repository.php new file mode 100644 index 0000000..bfade26 --- /dev/null +++ b/libraries/jcb_powers/VDM.Joomla.Gitea/src/Admin/Users/Repository.php @@ -0,0 +1,85 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ + +namespace VDM\Joomla\Gitea\Admin\Users; + + +use VDM\Joomla\Gitea\Abstraction\Api; + + +/** + * The Gitea Admin Users Repository + * + * @since 3.2.0 + */ +class Repository extends Api +{ + /** + * Create a repository on behalf of a user. + * + * @param string $username The user's display name. + * @param string $repoName The repository name. + * @param string|null $description The repository description (optional). + * @param bool $auto_init Whether the repository should be auto-initialized? (optional). + * @param string|null $default_branch Default branch of the repository (optional). + * @param string|null $gitignores Gitignores to use (optional). + * @param string|null $issue_labels Label-Set to use (optional). + * @param string|null $license License to use (optional). + * @param bool $private Whether the repository is private (optional). + * @param string|null $readme Readme of the repository to create (optional). + * @param bool $template Whether the repository is template (optional). + * @param string|null $trust_model TrustModel of the repository (optional). + * + * @return object|null + * @since 3.2.0 + **/ + public function create( + string $username, + string $repoName, + ?string $description = null, + bool $auto_init = false, + ?string $default_branch = null, + ?string $gitignores = null, + ?string $issue_labels = null, + ?string $license = null, + bool $private = false, + ?string $readme = null, + bool $template = false, + ?string $trust_model = null + ): ?object + { + // Build the request path. + $path = "/admin/users/{$username}/repos"; + + // Set the repository data. + $data = new \stdClass(); + $data->name = $repoName; + $data->description = $description; + $data->auto_init = $auto_init; + $data->default_branch = $default_branch; + $data->gitignores = $gitignores; + $data->issue_labels = $issue_labels; + $data->license = $license; + $data->private = $private; + $data->readme = $readme; + $data->template = $template; + $data->trust_model = $trust_model; + + // Send the post request. + return $this->response->get( + $this->http->post( + $this->uri->get($path), json_encode($data) + ), 201 + ); + } + +} + diff --git a/libraries/jcb_powers/VDM.Joomla.Gitea/src/Admin/Users/index.html b/libraries/jcb_powers/VDM.Joomla.Gitea/src/Admin/Users/index.html new file mode 100644 index 0000000..fa6d84e --- /dev/null +++ b/libraries/jcb_powers/VDM.Joomla.Gitea/src/Admin/Users/index.html @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/libraries/jcb_powers/VDM.Joomla.Gitea/src/Admin/index.html b/libraries/jcb_powers/VDM.Joomla.Gitea/src/Admin/index.html new file mode 100644 index 0000000..fa6d84e --- /dev/null +++ b/libraries/jcb_powers/VDM.Joomla.Gitea/src/Admin/index.html @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/libraries/jcb_powers/VDM.Joomla.Gitea/src/Factory.php b/libraries/jcb_powers/VDM.Joomla.Gitea/src/Factory.php new file mode 100644 index 0000000..78918e8 --- /dev/null +++ b/libraries/jcb_powers/VDM.Joomla.Gitea/src/Factory.php @@ -0,0 +1,97 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ + +namespace VDM\Joomla\Gitea; + + +use Joomla\DI\Container; +use VDM\Joomla\Gitea\Service\Utilities; +use VDM\Joomla\Gitea\Service\Jcb; +use VDM\Joomla\Gitea\Service\Settings; +use VDM\Joomla\Gitea\Service\Organization; +use VDM\Joomla\Gitea\Service\User; +use VDM\Joomla\Gitea\Service\Repository; +use VDM\Joomla\Gitea\Service\Package; +use VDM\Joomla\Gitea\Service\Issue; +use VDM\Joomla\Gitea\Service\Notifications; +use VDM\Joomla\Gitea\Service\Miscellaneous; +use VDM\Joomla\Gitea\Service\Admin; +use VDM\Joomla\Interfaces\FactoryInterface; + + +/** + * Gitea Factory + * + * @since 3.2.0 + */ +abstract class Factory implements FactoryInterface +{ + /** + * Global Package Container + * + * @var Container + * @since 3.2.0 + **/ + protected static $container = null; + + /** + * Get any class from the package container + * + * @param string $key The container class key + * + * @return Mixed + * @since 3.2.0 + */ + public static function _($key) + { + return self::getContainer()->get($key); + } + + /** + * Get the global package container + * + * @return Container + * @since 3.2.0 + */ + public static function getContainer(): Container + { + if (!self::$container) + { + self::$container = self::createContainer(); + } + + return self::$container; + } + + /** + * Create a container object + * + * @return Container + * @since 3.2.0 + */ + protected static function createContainer(): Container + { + return (new Container()) + ->registerServiceProvider(new Utilities()) + ->registerServiceProvider(new Jcb()) + ->registerServiceProvider(new Settings()) + ->registerServiceProvider(new Organization()) + ->registerServiceProvider(new User()) + ->registerServiceProvider(new Repository()) + ->registerServiceProvider(new Package()) + ->registerServiceProvider(new Issue()) + ->registerServiceProvider(new Notifications()) + ->registerServiceProvider(new Miscellaneous()) + ->registerServiceProvider(new Admin()); + } + +} + diff --git a/libraries/jcb_powers/VDM.Joomla.Gitea/src/Issue.php b/libraries/jcb_powers/VDM.Joomla.Gitea/src/Issue.php new file mode 100644 index 0000000..bfeb418 --- /dev/null +++ b/libraries/jcb_powers/VDM.Joomla.Gitea/src/Issue.php @@ -0,0 +1,406 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ + +namespace VDM\Joomla\Gitea; + + +use VDM\Joomla\Gitea\Abstraction\Api; + + +/** + * The Gitea Issue + * + * @since 3.2.0 + */ +class Issue extends Api +{ + /** + * List a repository's issues. + * + * @param string $owner The owner name. + * @param string $repo The repo name. + * @param string $state The state of the issues to get, defaults to 'open'. + * @param int $page The page to get, defaults to null. + * @param int $limit The number of issues per page, defaults to null. + * @param string|null $labels Comma-separated list of labels, defaults to null. + * @param string|null $q The search string, defaults to null. + * @param string|null $type The type to filter by (issues/pulls), defaults to null. + * @param string|null $milestones Comma-separated list of milestone names or IDs, defaults to null. + * @param string|null $since Only show items updated after the given time, defaults to null. + * @param string|null $before Only show items updated before the given time, defaults to null. + * @param string|null $createdBy Only show items created by the given user, defaults to null. + * @param string|null $assignedBy Only show items assigned to the given user, defaults to null. + * @param string|null $mentionedBy Only show items where the given user is mentioned, defaults to null. + * + * @return array|null + * @since 3.2.0 + **/ + public function list( + string $owner, + string $repo, + string $state = 'open', + int $page = 1, + int $limit = 10, + ?string $labels = null, + ?string $q = null, + ?string $type = null, + ?string $milestones = null, + ?string $since = null, + ?string $before = null, + ?string $createdBy = null, + ?string $assignedBy = null, + ?string $mentionedBy = null + ): ?array + { + // Build the request path. + $path = "/repos/{$owner}/{$repo}/issues"; + + // Build the URI. + $uri = $this->uri->get($path); + + // Set the query parameters + $uri->setVar('state', $state); + $uri->setVar('page', $page); + $uri->setVar('limit', $limit); + $uri->setVar('labels', $labels); + $uri->setVar('q', $q); + $uri->setVar('type', $type); + $uri->setVar('milestones', $milestones); + $uri->setVar('since', $since); + $uri->setVar('before', $before); + $uri->setVar('created_by', $createdBy); + $uri->setVar('assigned_by', $assignedBy); + $uri->setVar('mentioned_by', $mentionedBy); + + // Send the get request. + return $this->response->get( + $this->http->get($uri) + ); + } + + /** + * Get an issue. + * + * @param string $owner The owner name. + * @param string $repo The repo name. + * @param int $index The issue index. + * + * @return object|null + * @since 3.2.0 + **/ + public function get(string $owner, string $repo, int $index): ?object + { + // Build the request path. + $path = "/repos/{$owner}/{$repo}/issues/{$index}"; + + // Send the get request. + return $this->response->get( + $this->http->get( + $this->uri->get($path) + ) + ); + } + + /** + * Create an issue. If using deadline only the date will be taken into account, and time of day ignored. + * + * @param string $owner The owner name. + * @param string $repo The repo name. + * @param string $issueTitle The issue title. + * @param array|null $assignees The array of assignees, defaults to null. + * @param string|null $issueBody The issue body, defaults to null. + * @param bool|null $closed If the issue is closed, defaults to null. + * @param string|null $dueDate The deadline for the issue, format: "YYYY-MM-DD", defaults to null. + * @param array|null $labelIds The array of label IDs to attach to the issue, defaults to null. + * @param int|null $milestoneId The milestone ID, defaults to null. + * + * @return object|null + * @since 3.2.0 + **/ + public function create( + string $owner, + string $repo, + string $issueTitle, + ?array $assignees = null, + ?string $issueBody = null, + ?bool $closed = null, + ?string $dueDate = null, + ?array $labelIds = null, + ?int $milestoneId = null + ): ?object + { + // Build the request path. + $path = "/repos/{$owner}/{$repo}/issues"; + + // Build the request data. + $data = new \stdClass(); + $data->title = $issueTitle; + $data->body = $issueBody; + $data->assignees = $assignees; + $data->closed = $closed; + $data->due_date = $dueDate; + $data->labels = $labelIds; + $data->milestone = $milestoneId; + + // Send the post request. + return $this->response->get( + $this->http->post( + $this->uri->get($path), json_encode($data) + ) + ); + } + + /** + * Search for issues across the repositories that the user has access to. + * + * @param string $q Search query. + * @param int $page Page number (default 1). + * @param int $limit Page size (default 10, max 50). + * @param string|null $state Issue state (default open). + * @param string|null $labels Label filter, comma-separated. + * @param string|null $milestones Milestone filter, comma-separated. + * @param int|null $priorityRepoId Repository to prioritize in the results. + * @param string|null $type Filter by type (issues/pulls). + * @param string|null $since Only show notifications updated after the given time (RFC 3339 format). + * @param string|null $before Only show notifications updated before the given time (RFC 3339 format). + * @param bool|null $assigned Filter assigned to you (default false). + * @param bool|null $created Filter created by you (default false). + * @param bool|null $mentioned Filter mentioning you (default false). + * @param bool|null $reviewRequested Filter pulls requesting your review (default false). + * @param string|null $owner Filter by owner. + * @param string|null $team Filter by team (requires organization owner parameter). + * + * @return array|null + * @since 3.2.0 + **/ + public function search( + string $q, + int $page = 1, + int $limit = 10, + ?string $state = 'open', + ?string $labels = null, + ?string $milestones = null, + ?int $priorityRepoId = null, + ?string $type = null, + ?string $since = null, + ?string $before = null, + ?bool $assigned = null, + ?bool $created = null, + ?bool $mentioned = null, + ?bool $reviewRequested = null, + ?string $owner = null, + ?string $team = null + ): ?array + { + // Build the request path. + $path = "/repos/issues/search"; + + // Set the URL parameters. + $uri = $this->uri->get($path); + $uri->setVar('q', $q); + $uri->setVar('page', $page); + $uri->setVar('limit', $limit); + $uri->setVar('state', $state); + + if ($labels !== null) + { + $uri->setVar('labels', $labels); + } + + if ($milestones !== null) + { + $uri->setVar('milestones', $milestones); + } + + if ($priorityRepoId !== null) + { + $uri->setVar('priority_repo_id', $priorityRepoId); + } + + if ($type !== null) + { + $uri->setVar('type', $type); + } + + if ($since !== null) + { + $uri->setVar('since', $since); + } + + if ($before !== null) + { + $uri->setVar('before', $before); + } + + if ($assigned !== null) + { + $uri->setVar('assigned', $assigned); + } + + if ($created !== null) + { + $uri->setVar('created', $created); + } + + if ($mentioned !== null) + { + $uri->setVar('mentioned', $mentioned); + } + + if ($reviewRequested !== null) + { + $uri->setVar('review_requested', $reviewRequested); + } + + if ($owner !== null) + { + $uri->setVar('owner', $owner); + } + + if ($team !== null) + { + $uri->setVar('team', $team); + } + + // Send the get request. + return $this->response->get( + $this->http->get($uri) + ); + } + + /** + * Edit an issue. + * + * @param string $owner The owner name. + * @param string $repo The repo name. + * @param int $index The issue index. + * @param string|null $assignee The assignee, defaults to null. + * @param array|null $assignees The assignees, defaults to null. + * @param string|null $body The issue body, defaults to null. + * @param string|null $dueDate The due date, defaults to null. + * @param int|null $milestone The milestone, defaults to null. + * @param string|null $ref The reference, defaults to null. + * @param string|null $state The issue state, defaults to null. + * @param string|null $title The issue title, defaults to null. + * @param bool|null $unsetDueDate The flag to unset due date, defaults to null. + * + * @return object|null + * @since 3.2.0 + **/ + public function edit( + string $owner, + string $repo, + int $index, + ?string $assignee = null, + ?array $assignees = null, + ?string $body = null, + ?string $dueDate = null, + ?int $milestone = null, + ?string $ref = null, + ?string $state = null, + ?string $title = null, + ?bool $unsetDueDate = null + ): ?object + { + // Build the request path. + $path = "/repos/{$owner}/{$repo}/issues/{$index}"; + + // Prepare the issue data. + $editIssueData = new \stdClass(); + + if ($assignee !== null || $assignees !== null) + { + $editIssueData->assignee = new \stdClass(); + + if ($assignee !== null) + { + $editIssueData->assignee->name = $assignee; + } + + if ($assignees !== null) + { + $editIssueData->assignee->names = $assignees; + } + } + + if ($body !== null) + { + $editIssueData->body = $body; + } + + if ($dueDate !== null || $unsetDueDate !== null) + { + $editIssueData->dueDate = new \stdClass(); + + if ($dueDate !== null) + { + $editIssueData->dueDate->date = $dueDate; + } + + if ($unsetDueDate !== null) + { + $editIssueData->dueDate->unset = $unsetDueDate; + } + } + + if ($milestone !== null) + { + $editIssueData->milestone = $milestone; + } + + if ($ref !== null) + { + $editIssueData->ref = $ref; + } + + if ($state !== null) + { + $editIssueData->state = $state; + } + + if ($title !== null) + { + $editIssueData->title = $title; + } + + // Send the patch request. + return $this->response->get( + $this->http->patch( + $this->uri->get($path), json_encode($editIssueData) + ) + ); + } + + /** + * Delete an issue. + * + * @param string $owner The owner name. + * @param string $repo The repo name. + * @param int $index The issue index. + * + * @return string + * @since 3.2.0 + **/ + public function delete(string $owner, string $repo, int $index): string + { + // Build the request path. + $path = "/repos/{$owner}/{$repo}/issues/{$index}"; + + // Send the delete request. + return $this->response->get( + $this->http->delete( + $this->uri->get($path) + ), 204, 'success' + ); + } + +} + diff --git a/libraries/jcb_powers/VDM.Joomla.Gitea/src/Issue/Comments.php b/libraries/jcb_powers/VDM.Joomla.Gitea/src/Issue/Comments.php new file mode 100644 index 0000000..c244035 --- /dev/null +++ b/libraries/jcb_powers/VDM.Joomla.Gitea/src/Issue/Comments.php @@ -0,0 +1,176 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ + +namespace VDM\Joomla\Gitea\Issue; + + +use VDM\Joomla\Gitea\Abstraction\Api; + + +/** + * The Gitea Issue Comments + * + * @since 3.2.0 + */ +class Comments extends Api +{ + /** + * List all comments on an issue. + * + * @param string $owner The owner name. + * @param string $repo The repo name. + * @param int $index The issue index. + * @param int $page The page number to get, defaults to 1. + * @param int $limit The number of comments per page, defaults to 10. + * @param string|null $since The date-time since when to get comments, defaults to null. + * @param string|null $before The date-time before when to get comments, defaults to null. + * + * @return array|null + * @since 3.2.0 + **/ + public function list( + string $owner, + string $repo, + int $index, + int $page = 1, + int $limit = 10, + ?string $since = null, + ?string $before = null + ): ?array + { + // Build the request path. + $path = "/repos/{$owner}/{$repo}/issues/{$index}/comments"; + + // Build the URI. + $uri = $this->uri->get($path); + $uri->setVar('page', $page); + $uri->setVar('limit', $limit); + + // Set the 'since' and 'before' parameters if not null. + if ($since !== null) + { + $uri->setVar('since', $since); + } + if ($before !== null) + { + $uri->setVar('before', $before); + } + + // Send the get request. + return $this->response->get( + $this->http->get($uri) + ); + } + + /** + * Get a comment. + * + * @param string $owner The owner name. + * @param string $repo The repo name. + * @param int $commentId The comment ID. + * + * @return object|null + * @since 3.2.0 + **/ + public function get(string $owner, string $repo, int $commentId): ?object + { + // Build the request path. + $path = "/repos/{$owner}/{$repo}/issues/comments/{$commentId}"; + + // Send the get request. + return $this->response->get( + $this->http->get( + $this->uri->get($path) + ) + ); + } + + /** + * Delete a comment. + * + * @param string $owner The owner name. + * @param string $repo The repo name. + * @param int $commentId The comment ID. + * + * @return string + * @since 3.2.0 + **/ + public function delete(string $owner, string $repo, int $commentId): string + { + // Build the request path. + $path = "/repos/{$owner}/{$repo}/issues/comments/{$commentId}"; + + // Send the delete request. + return $this->response->get( + $this->http->delete( + $this->uri->get($path) + ), 204, 'success' + ); + } + + /** + * Edit a comment. + * + * @param string $owner The owner name. + * @param string $repo The repo name. + * @param int $commentId The comment ID. + * @param string $commentBody The new comment body. + * + * @return object|null + * @since 3.2.0 + **/ + public function edit(string $owner, string $repo, int $commentId, string $commentBody): ?object + { + // Build the request path. + $path = "/repos/{$owner}/{$repo}/issues/comments/{$commentId}"; + + // Build the request data. + $data = new \stdClass(); + $data->body = $commentBody; + + // Send the patch request. + return $this->response->get( + $this->http->patch( + $this->uri->get($path), json_encode($data) + ) + ); + } + + /** + * Add a comment to an issue. + * + * @param string $owner The owner name. + * @param string $repo The repo name. + * @param int $issueIndex The issue index. + * @param string $commentBody The comment body. + * + * @return object|null + * @since 3.2.0 + **/ + public function add(string $owner, string $repo, int $issueIndex, string $commentBody): ?object + { + // Build the request path. + $path = "/repos/{$owner}/{$repo}/issues/{$issueIndex}/comments"; + + // Build the request data. + $data = new \stdClass(); + $data->body = $commentBody; + + // Send the post request. + return $this->response->get( + $this->http->post( + $this->uri->get($path), json_encode($data) + ), 201 + ); + } + +} + diff --git a/libraries/jcb_powers/VDM.Joomla.Gitea/src/Issue/Deadline.php b/libraries/jcb_powers/VDM.Joomla.Gitea/src/Issue/Deadline.php new file mode 100644 index 0000000..6c13d07 --- /dev/null +++ b/libraries/jcb_powers/VDM.Joomla.Gitea/src/Issue/Deadline.php @@ -0,0 +1,54 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ + +namespace VDM\Joomla\Gitea\Issue; + + +use VDM\Joomla\Gitea\Abstraction\Api; + + +/** + * The Gitea Issue Deadline + * + * @since 3.2.0 + */ +class Deadline extends Api +{ + /** + * Set an issue deadline. + * + * @param string $owner The owner name. + * @param string $repo The repo name. + * @param int $index The issue index. + * @param string|null $dueDate The deadline date string in the format YYYY-MM-DD or null to delete the deadline. + * + * @return object + * @since 3.2.0 + **/ + public function set(string $owner, string $repo, int $index, ?string $dueDate): object + { + // Build the request path. + $path = "/repos/{$owner}/{$repo}/issues/{$index}/deadline"; + + // Build the request data. + $data = new \stdClass(); + $data->due_date = $dueDate; + + // Send the post request. + return $this->response->get( + $this->http->post( + $this->uri->get($path), json_encode($data) + ) + ); + } + +} + diff --git a/libraries/jcb_powers/VDM.Joomla.Gitea/src/Issue/Labels.php b/libraries/jcb_powers/VDM.Joomla.Gitea/src/Issue/Labels.php new file mode 100644 index 0000000..fda80dc --- /dev/null +++ b/libraries/jcb_powers/VDM.Joomla.Gitea/src/Issue/Labels.php @@ -0,0 +1,181 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ + +namespace VDM\Joomla\Gitea\Issue; + + +use VDM\Joomla\Gitea\Abstraction\Api; + + +/** + * The Gitea Issue Labels + * + * @since 3.2.0 + */ +class Labels extends Api +{ + /** + * Get all of a repository's labels. + * + * @param string $owner The owner name. + * @param string $repo The repo name. + * @param int $page The page number of results to return (1-based). + * @param int $limit The page size of results. + * + * @return array|null + * @since 3.2.0 + **/ + public function list(string $owner, string $repo, int $page = 1, int $limit = 10): ?array + { + // Build the request path. + $path = "/repos/{$owner}/{$repo}/labels"; + + // Get the URI object with the request path. + $uri = $this->uri->get($path); + + // Add the page and limit query parameters if provided. + $uri->setVar('page', $page); + $uri->setVar('limit', $limit); + + // Send the get request. + return $this->response->get( + $this->http->get($uri) + ); + } + + /** + * Get an issue's labels. + * + * @param string $owner The owner name. + * @param string $repo The repo name. + * @param int $index The issue index. + * + * @return array|null + * @since 3.2.0 + **/ + public function get(string $owner, string $repo, int $index): ?array + { + // Build the request path. + $path = "/repos/{$owner}/{$repo}/issues/{$index}/labels"; + + // Send the get request. + return $this->response->get( + $this->http->get( + $this->uri->get($path) + ) + ); + } + + /** + * Replace an issue's labels. + * + * @param string $owner The owner name. + * @param string $repo The repo name. + * @param int $index The issue index. + * @param array $labels An array of labels to replace the current issue labels. + * + * @return object + * @since 3.2.0 + **/ + public function replace(string $owner, string $repo, int $index, array $labels): object + { + // Build the request path. + $path = "/repos/{$owner}/{$repo}/issues/{$index}/labels"; + + // Build the request data. + $data = new \stdClass(); + $data->labels = $labels; + + // Send the put request. + return $this->response->get( + $this->http->put( + $this->uri->get($path), json_encode($data) + ) + ); + } + + /** + * Add a label to an issue. + * + * @param string $owner The owner name. + * @param string $repo The repo name. + * @param int $index The issue index. + * @param array $labels An array of label IDs to add. + * + * @return array|null + * @since 3.2.0 + **/ + public function add(string $owner, string $repo, int $index, array $labels): ?array + { + // Build the request path. + $path = "/repos/{$owner}/{$repo}/issues/{$index}/labels"; + + // Build the request data. + $data = new \stdClass(); + $data->labels = $labels; + + // Send the post request. + return $this->response->get( + $this->http->post( + $this->uri->get($path), json_encode($data) + ) + ); + } + + /** + * Remove a label from an issue. + * + * @param string $owner The owner name. + * @param string $repo The repo name. + * @param int $index The issue index. + * @param int $labelId The ID of the label to remove. + * + * @return string + * @since 3.2.0 + **/ + public function remove(string $owner, string $repo, int $index, int $labelId): string + { + // Build the request path. + $path = "/repos/{$owner}/{$repo}/issues/{$index}/labels/{$labelId}"; + + // Send the delete request. + return $this->response->get( + $this->http->delete( + $this->uri->get($path) + ), 204, 'success' + ); + } + + /** + * Remove all labels from an issue. + * + * @param string $owner The owner name. + * @param string $repo The repo name. + * @param int $index The issue index. + * + * @return string + * @since 3.2.0 + **/ + public function clear(string $owner, string $repo, int $index): string + { + // Build the request path. + $path = "/repos/{$owner}/{$repo}/issues/{$index}/labels"; + + // Send the delete request. + return $this->response->get( + $this->http->delete( + $this->uri->get($path) + ), 204, 'success' + ); + } + +} + diff --git a/libraries/jcb_powers/VDM.Joomla.Gitea/src/Issue/Milestones.php b/libraries/jcb_powers/VDM.Joomla.Gitea/src/Issue/Milestones.php new file mode 100644 index 0000000..5178a73 --- /dev/null +++ b/libraries/jcb_powers/VDM.Joomla.Gitea/src/Issue/Milestones.php @@ -0,0 +1,230 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ + +namespace VDM\Joomla\Gitea\Issue; + + +use VDM\Joomla\Gitea\Abstraction\Api; + + +/** + * The Gitea Issue Milestones + * + * @since 3.2.0 + */ +class Milestones extends Api +{ + /** + * Create a milestone. + * + * @param string $owner The owner name. + * @param string $repo The repo name. + * @param string $title The title of the milestone. + * @param string|null $description Optional. The description of the milestone. + * @param string|null $dueOn Optional. The due date of the milestone. + * @param string|null $state Optional. The state of the milestone. Default is 'open'. + * + * @return object|null + * @since 3.2.0 + **/ + public function create( + string $owner, + string $repo, + string $title, + ?string $description = null, + ?string $dueOn = null, + ?string $state = 'open' + ): ?object + { + // Set the lines data + $data = new \stdClass(); + + // Set all the required data. + $data->title = $title; + + // Set all the optional data that has been provided. + if ($description !== null) + { + $data->description = $description; + } + if ($dueOn !== null) + { + $data->due_on = $dueOn; + } + if ($state !== null) + { + $data->state = $state; + } + + // Build the request path. + $path = "/repos/{$owner}/{$repo}/milestones"; + + // Send the post request. + return $this->response->get( + $this->http->post( + $this->uri->get($path), + json_encode($data) + ), 201 + ); + } + + /** + * Get all of a repository's opened milestones. + * + * @param string $owner The owner name. + * @param string $repo The repo name. + * @param string|null $state Optional. Milestone state. Recognized values are open, closed, and all. Defaults to "open". + * @param string|null $name Optional. Filter by milestone name. + * @param int|null $page Optional. Page number of results to return (1-based). + * @param int|null $limit Optional. Page size of results. + * + * @return array|null + * @since 3.2.0 + **/ + public function list( + string $owner, + string $repo, + ?string $state = 'open', + ?string $name = null, + ?int $page = null, + ?int $limit = null + ): ?array + { + // Build the request path. + $path = "/repos/{$owner}/{$repo}/milestones"; + + // Build the URI. + $uri = $this->uri->get($path); + $uri->setVar('state', $state); + if ($name !== null) + { + $uri->setVar('name', $name); + } + if ($page !== null) + { + $uri->setVar('page', $page); + } + if ($limit !== null) + { + $uri->setVar('limit', $limit); + } + + // Send the get request. + return $this->response->get( + $this->http->get($uri) + ); + } + + /** + * Get a milestone. + * + * @param string $owner The owner name. + * @param string $repo The repo name. + * @param string $milestoneId The ID of the milestone. + * + * @return object|null + * @since 3.2.0 + **/ + public function get(string $owner, string $repo, string $milestoneId): ?object + { + // Build the request path. + $path = "/repos/{$owner}/{$repo}/milestones/{$milestoneId}"; + + // Send the get request. + return $this->response->get( + $this->http->get( + $this->uri->get($path) + ) + ); + } + + /** + * Delete a milestone. + * + * @param string $owner The owner name. + * @param string $repo The repo name. + * @param string $milestoneId The ID of the milestone to delete. + * + * @return string + * @since 3.2.0 + **/ + public function delete(string $owner, string $repo, string $milestoneId): string + { + // Build the request path. + $path = "/repos/{$owner}/{$repo}/milestones/{$milestoneId}"; + + // Send the delete request. + return $this->response->get( + $this->http->delete( + $this->uri->get($path) + ), 204, 'success' + ); + } + + /** + * Update a milestone. + * + * @param string $owner The owner name. + * @param string $repo The repo name. + * @param string $milestoneId The ID of the milestone to update. + * @param string $title Optional. The new title of the milestone. + * @param string $description Optional. The new description of the milestone. + * @param string $dueOn Optional. The new due date of the milestone. + * @param string $state Optional. The new state of the milestone. + * + * @return object|null + * @since 3.2.0 + **/ + public function update( + string $owner, + string $repo, + string $milestoneId, + string $title = null, + string $description = null, + string $dueOn = null, + string $state = null + ): ?object + { + // Set the lines data + $data = new \stdClass(); + + // Set all the optional data that has been provided. + if ($title !== null) + { + $data->title = $title; + } + if ($description !== null) + { + $data->description = $description; + } + if ($dueOn !== null) + { + $data->due_on = $dueOn; + } + if ($state !== null) + { + $data->state = $state; + } + + // Build the request path. + $path = "/repos/{$owner}/{$repo}/milestones/{$milestoneId}"; + + // Send the patch request. + return $this->response->get( + $this->http->patch( + $this->uri->get($path), + json_encode($data) + ) + ); + } + +} + diff --git a/libraries/jcb_powers/VDM.Joomla.Gitea/src/Issue/Reactions.php b/libraries/jcb_powers/VDM.Joomla.Gitea/src/Issue/Reactions.php new file mode 100644 index 0000000..7595295 --- /dev/null +++ b/libraries/jcb_powers/VDM.Joomla.Gitea/src/Issue/Reactions.php @@ -0,0 +1,110 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ + +namespace VDM\Joomla\Gitea\Issue; + + +use VDM\Joomla\Gitea\Abstraction\Api; + + +/** + * The Gitea Issue Reactions + * + * @since 3.2.0 + */ +class Reactions extends Api +{ + /** + * Get a list reactions of an issue. + * + * @param string $owner The owner name. + * @param string $repo The repo name. + * @param int $index The issue index. + * @param int $page The page to get, defaults to 1. + * @param int $limit The number of reactions per page, defaults to 10. + * + * @return array|null + * @since 3.2.0 + **/ + public function list(string $owner, string $repo, int $index, int $page = 1, int $limit = 10): ?array + { + // Build the request path. + $path = "/repos/{$owner}/{$repo}/issues/{$index}/reactions"; + + // Build the URI. + $uri = $this->uri->get($path); + + // Set the URI variables. + $uri->setVar('page', $page); + $uri->setVar('limit', $limit); + + // Send the get request. + return $this->response->get( + $this->http->get($uri) + ); + } + + /** + * Add a reaction to an issue. + * + * @param string $owner The owner name. + * @param string $repo The repo name. + * @param int $index The issue index. + * @param string $content The name of the reaction to add. + * + * @return object|null + * @since 3.2.0 + **/ + public function add(string $owner, string $repo, int $index, string $content): ?object + { + // Build the request path. + $path = "/repos/{$owner}/{$repo}/issues/{$index}/reactions"; + + // Build the request data. + $data = new \stdClass(); + $data->content = $content; + + // Send the post request. + return $this->response->get( + $this->http->post( + $this->uri->get($path), json_encode($data) + ) + ); + } + + /** + * Remove a reaction from an issue. + * + * @param string $owner The owner name. + * @param string $repo The repo name. + * @param int $index The issue index. + * @param string $content The name of the reaction to remove. + * + * @return string + * @since 3.2.0 + **/ + public function remove(string $owner, string $repo, int $index, string $content): string + { + // Build the request path. + $path = "/repos/{$owner}/{$repo}/issues/{$index}/reactions"; + + // Build the URI. + $uri = $this->uri->get($path); + $uri->setVar('content', $content); + + // Send the delete request. + return $this->response->get( + $this->http->delete($uri), 200, 'success' + ); + } + +} + diff --git a/libraries/jcb_powers/VDM.Joomla.Gitea/src/Issue/Reactions/Comment.php b/libraries/jcb_powers/VDM.Joomla.Gitea/src/Issue/Reactions/Comment.php new file mode 100644 index 0000000..0f2ca78 --- /dev/null +++ b/libraries/jcb_powers/VDM.Joomla.Gitea/src/Issue/Reactions/Comment.php @@ -0,0 +1,103 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ + +namespace VDM\Joomla\Gitea\Issue\Reactions; + + +use VDM\Joomla\Gitea\Abstraction\Api; + + +/** + * The Gitea Issue Reactions Comment + * + * @since 3.2.0 + */ +class Comment extends Api +{ + /** + * Get a list of reactions from a comment of an issue. + * + * @param string $owner The owner name. + * @param string $repo The repo name. + * @param int $commentId The comment ID. + * + * @return array|null + * @since 3.2.0 + **/ + public function list(string $owner, string $repo, int $commentId): ?array + { + // Build the request path. + $path = "/repos/{$owner}/{$repo}/issues/comments/{$commentId}/reactions"; + + // Send the get request. + return $this->response->get( + $this->http->get( + $this->uri->get($path) + ) + ); + } + + /** + * Add a reaction to a comment of an issue. + * + * @param string $owner The owner name. + * @param string $repo The repo name. + * @param int $commentId The comment ID. + * @param string $content The reaction to add, e.g. "+1". + * + * @return object|null + * @since 3.2.0 + **/ + public function add(string $owner, string $repo, int $commentId, string $content): ?object + { + // Build the request path. + $path = "/repos/{$owner}/{$repo}/issues/comments/{$commentId}/reactions"; + + // Build the request data. + $data = new \stdClass(); + $data->content = $content; + + // Send the post request. + return $this->response->get( + $this->http->post( + $this->uri->get($path), json_encode($data) + ) + ); + } + + /** + * Remove a reaction from a comment of an issue. + * + * @param string $owner The owner name. + * @param string $repo The repo name. + * @param int $commentId The comment ID. + * @param string $content The reaction to remove, e.g. "+1". + * + * @return string + * @since 3.2.0 + **/ + public function remove(string $owner, string $repo, int $commentId, string $content): string + { + // Build the request path. + $path = "/repos/{$owner}/{$repo}/issues/comments/{$commentId}/reactions"; + + // Build the URI. + $uri = $this->uri->get($path); + $uri->setVar('content', $content); + + // Send the delete request. + return $this->response->get( + $this->http->delete($uri), 200, 'success' + ); + } + +} + diff --git a/libraries/jcb_powers/VDM.Joomla.Gitea/src/Issue/Reactions/index.html b/libraries/jcb_powers/VDM.Joomla.Gitea/src/Issue/Reactions/index.html new file mode 100644 index 0000000..fa6d84e --- /dev/null +++ b/libraries/jcb_powers/VDM.Joomla.Gitea/src/Issue/Reactions/index.html @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/libraries/jcb_powers/VDM.Joomla.Gitea/src/Issue/Repository/Comments.php b/libraries/jcb_powers/VDM.Joomla.Gitea/src/Issue/Repository/Comments.php new file mode 100644 index 0000000..3ca83fc --- /dev/null +++ b/libraries/jcb_powers/VDM.Joomla.Gitea/src/Issue/Repository/Comments.php @@ -0,0 +1,67 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ + +namespace VDM\Joomla\Gitea\Issue\Repository; + + +use VDM\Joomla\Gitea\Abstraction\Api; + + +/** + * The Gitea Issue Repository Comments + * + * @since 3.2.0 + */ +class Comments extends Api +{ + /** + * List all comments in a repository. + * + * @param string $owner The owner name. + * @param string $repo The repo name. + * @param int $page The page to get, defaults to 1. + * @param int $limit The number of comments per page, defaults to 10. + * @param string|null $since The date-time string to filter updated comments since, defaults to null. + * @param string|null $before The date-time string to filter updated comments before, defaults to null. + * + * @return array|null + * @since 3.2.0 + **/ + public function list(string $owner, string $repo, int $page = 1, int $limit = 10, ?string $since = null, ?string $before = null): ?array + { + // Build the request path. + $path = "/repos/{$owner}/{$repo}/issues/comments"; + + // Build the URI. + $uri = $this->uri->get($path); + + // Set the URI variables. + $uri->setVar('page', $page); + $uri->setVar('limit', $limit); + + if ($since !== null) + { + $uri->setVar('since', $since); + } + + if ($before !== null) + { + $uri->setVar('before', $before); + } + + // Send the get request. + return $this->response->get( + $this->http->get($uri) + ); + } + +} + diff --git a/libraries/jcb_powers/VDM.Joomla.Gitea/src/Issue/Repository/index.html b/libraries/jcb_powers/VDM.Joomla.Gitea/src/Issue/Repository/index.html new file mode 100644 index 0000000..fa6d84e --- /dev/null +++ b/libraries/jcb_powers/VDM.Joomla.Gitea/src/Issue/Repository/index.html @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/libraries/jcb_powers/VDM.Joomla.Gitea/src/Issue/Stopwatch.php b/libraries/jcb_powers/VDM.Joomla.Gitea/src/Issue/Stopwatch.php new file mode 100644 index 0000000..6745416 --- /dev/null +++ b/libraries/jcb_powers/VDM.Joomla.Gitea/src/Issue/Stopwatch.php @@ -0,0 +1,95 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ + +namespace VDM\Joomla\Gitea\Issue; + + +use VDM\Joomla\Gitea\Abstraction\Api; + + +/** + * The Gitea Issue Stopwatch + * + * @since 3.2.0 + */ +class Stopwatch extends Api +{ + /** + * Start stopwatch on an issue. + * + * @param string $owner The owner name. + * @param string $repo The repo name. + * @param int $index The issue index. + * + * @return string + * @since 3.2.0 + **/ + public function start(string $owner, string $repo, int $index): string + { + // Build the request path. + $path = "/repos/{$owner}/{$repo}/issues/{$index}/stopwatch/start"; + + // Send the post request. + return $this->response->get( + $this->http->post( + $this->uri->get($path), '' + ), 201, 'success' + ); + } + + /** + * Stop an issue's existing stopwatch. + * + * @param string $owner The owner name. + * @param string $repo The repo name. + * @param int $index The issue index. + * + * @return string + * @since 3.2.0 + **/ + public function stop(string $owner, string $repo, int $index): string + { + // Build the request path. + $path = "/repos/{$owner}/{$repo}/issues/{$index}/stopwatch/stop"; + + // Send the post request. + return $this->response->get( + $this->http->post( + $this->uri->get($path), '' + ), 201, 'success' + ); + } + + /** + * Delete an issue's existing stopwatch. + * + * @param string $owner The owner name. + * @param string $repo The repo name. + * @param int $index The issue index. + * + * @return string + * @since 3.2.0 + **/ + public function delete(string $owner, string $repo, int $index): string + { + // Build the request path. + $path = "/repos/{$owner}/{$repo}/issues/{$index}/stopwatch/delete"; + + // Send the delete request. + return $this->response->get( + $this->http->delete( + $this->uri->get($path) + ), 204, 'success' + ); + } + +} + diff --git a/libraries/jcb_powers/VDM.Joomla.Gitea/src/Issue/Subscriptions.php b/libraries/jcb_powers/VDM.Joomla.Gitea/src/Issue/Subscriptions.php new file mode 100644 index 0000000..c29bfb6 --- /dev/null +++ b/libraries/jcb_powers/VDM.Joomla.Gitea/src/Issue/Subscriptions.php @@ -0,0 +1,137 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ + +namespace VDM\Joomla\Gitea\Issue; + + +use VDM\Joomla\Gitea\Abstraction\Api; + + +/** + * The Gitea Issue Subscriptions + * + * @since 3.2.0 + */ +class Subscriptions extends Api +{ + /** + * Get users who subscribed on an issue. + * + * @param string $owner The owner name. + * @param string $repo The repo name. + * @param int $index The issue index. + * @param int|null $page Optional. Page number of results to return (1-based). + * @param int|null $limit Optional. Page size of results. + * + * @return object|null + * @since 3.2.0 + **/ + public function get( + string $owner, + string $repo, + int $index, + ?int $page = null, + ?int $limit = null + ): ?object + { + // Build the request path. + $path = "/repos/{$owner}/{$repo}/issues/{$index}/subscriptions"; + + // Set the query parameters. + $uri = $this->uri->get($path); + if ($page !== null) + { + $uri->setVar('page', $page); + } + if ($limit !== null) + { + $uri->setVar('limit', $limit); + } + + // Send the get request. + return $this->response->get( + $this->http->get($uri) + ); + } + + /** + * Check if user is subscribed to an issue. + * + * @param string $owner The owner name. + * @param string $repo The repo name. + * @param int $index The issue index. + * + * @return object|null + * @since 3.2.0 + **/ + public function check(string $owner, string $repo, int $index): ?object + { + // Build the request path. + $path = "/repos/{$owner}/{$repo}/issues/{$index}/subscriptions/check"; + + // Send the get request. + return $this->response->get( + $this->http->get( + $this->uri->get($path) + ) + ); + } + + /** + * Subscribe user to issue. + * + * @param string $owner The owner name. + * @param string $repo The repo name. + * @param int $index The issue index. + * @param string $user The username to subscribe. + * + * @return string + * @since 3.2.0 + **/ + public function subscribe(string $owner, string $repo, int $index, string $user): string + { + // Build the request path. + $path = "/repos/{$owner}/{$repo}/issues/{$index}/subscriptions/{$user}"; + + // Send the put request. + return $this->response->get_( + $this->http->put( + $this->uri->get($path), '' + ), [200 => 'already subscribed', 201 => 'success'] + ); + } + + /** + * Unsubscribe user from issue. + * + * @param string $owner The owner name. + * @param string $repo The repo name. + * @param int $index The issue index. + * @param string $user The username to unsubscribe. + * + * @return string + * @since 3.2.0 + **/ + public function unsubscribe(string $owner, string $repo, int $index, string $user): string + { + // Build the request path. + $path = "/repos/{$owner}/{$repo}/issues/{$index}/subscriptions/{$user}"; + + // Send the delete request. + return $this->response->get_( + $this->http->delete( + $this->uri->get($path) + ), [200 => 'already unsubscribed', 201 => 'success'] + ); + } + +} + diff --git a/libraries/jcb_powers/VDM.Joomla.Gitea/src/Issue/Timeline.php b/libraries/jcb_powers/VDM.Joomla.Gitea/src/Issue/Timeline.php new file mode 100644 index 0000000..4c54937 --- /dev/null +++ b/libraries/jcb_powers/VDM.Joomla.Gitea/src/Issue/Timeline.php @@ -0,0 +1,78 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ + +namespace VDM\Joomla\Gitea\Issue; + + +use VDM\Joomla\Gitea\Abstraction\Api; + + +/** + * The Gitea Issue Timeline + * + * @since 3.2.0 + */ +class Timeline extends Api +{ + /** + * List all comments and events on an issue. + * + * @param string $owner The owner name. + * @param string $repo The repo name. + * @param int $index The issue index. + * @param string|null $since Optional. If provided, only comments updated since the specified time are returned. + * @param int|null $page Optional. Page number of results to return (1-based). + * @param int|null $limit Optional. Page size of results. + * @param string|null $before Optional. If provided, only comments updated before the provided time are returned. + * + * @return array|null + * @since 3.2.0 + **/ + public function get( + string $owner, + string $repo, + int $index, + ?string $since = null, + ?int $page = null, + ?int $limit = null, + ?string $before = null + ): ?array + { + // Build the request path. + $path = "/repos/{$owner}/{$repo}/issues/{$index}/timeline"; + + // Set the query parameters. + $uri = $this->uri->get($path); + if ($since !== null) + { + $uri->setVar('since', $since); + } + if ($page !== null) + { + $uri->setVar('page', $page); + } + if ($limit !== null) + { + $uri->setVar('limit', $limit); + } + if ($before !== null) + { + $uri->setVar('before', $before); + } + + // Send the get request. + return $this->response->get( + $this->http->get($uri) + ); + } + +} + diff --git a/libraries/jcb_powers/VDM.Joomla.Gitea/src/Issue/Times.php b/libraries/jcb_powers/VDM.Joomla.Gitea/src/Issue/Times.php new file mode 100644 index 0000000..7c33c2a --- /dev/null +++ b/libraries/jcb_powers/VDM.Joomla.Gitea/src/Issue/Times.php @@ -0,0 +1,179 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ + +namespace VDM\Joomla\Gitea\Issue; + + +use VDM\Joomla\Gitea\Abstraction\Api; + + +/** + * The Gitea Issue Times + * + * @since 3.2.0 + */ +class Times extends Api +{ + /** + * List an issue's tracked times. + * + * @param string $owner The owner name. + * @param string $repo The repo name. + * @param int $index The issue index. + * @param string $user Optional. Filter by user. + * @param string $since Optional. Show times updated after the given time. + * @param string $before Optional. Show times updated before the given time. + * @param int $page Optional. Page number of results to return (1-based). + * @param int $limit Optional. Page size of results. + * + * @return array|null + * @since 3.2.0 + **/ + public function list( + string $owner, + string $repo, + int $index, + string $user = null, + string $since = null, + string $before = null, + int $page = null, + int $limit = null + ): ?array + { + // Build the request path. + $path = "/repos/{$owner}/{$repo}/issues/{$index}/times"; + + // Prepare the query parameters. + $uri = $this->uri->get($path); + if ($user !== null) + { + $uri->setVar('user', $user); + } + if ($since !== null) + { + $uri->setVar('since', $since); + } + if ($before !== null) + { + $uri->setVar('before', $before); + } + if ($page !== null) + { + $uri->setVar('page', $page); + } + if ($limit !== null) + { + $uri->setVar('limit', $limit); + } + + // Send the get request with the query parameters. + return $this->response->get( + $this->http->get($uri) + ); + } + + /** + * Add tracked time to an issue. + * + * @param string $owner The owner name. + * @param string $repo The repo name. + * @param int $index The issue index. + * @param int $time The tracked time in seconds. + * @param string $created Optional. The date and time of the tracked time in RFC 3339 format. + * @param string $userName Optional. User who spent the time. + * + * @return object|null + * @since 3.2.0 + **/ + public function add( + string $owner, + string $repo, + int $index, + int $time, + string $created = null, + string $userName = null + ): ?object + { + // Set the lines data + $data = new \stdClass(); + + // Set all the needed data. + $data->time = $time; + if ($created !== null) + { + $data->created = $created; + } + if ($userName !== null) + { + $data->user_name = $userName; + } + + // Build the request path. + $path = "/repos/{$owner}/{$repo}/issues/{$index}/times"; + + // Send the post request. + return $this->response->get( + $this->http->post( + $this->uri->get($path), + json_encode($data) + ) + ); + } + + /** + * Reset a tracked time of an issue. + * + * @param string $owner The owner name. + * @param string $repo The repo name. + * @param int $index The issue index. + * + * @return string + * @since 3.2.0 + **/ + public function reset(string $owner, string $repo, int $index): string + { + // Build the request path. + $path = "/repos/{$owner}/{$repo}/issues/{$index}/times"; + + // Send the delete request. + return $this->response->get( + $this->http->delete( + $this->uri->get($path) + ), 204, 'success' + ); + } + + /** + * Delete specific tracked time. + * + * @param string $owner The owner name. + * @param string $repo The repo name. + * @param int $index The issue index. + * @param int $id The ID of the tracked time to delete. + * + * @return string + * @since 3.2.0 + **/ + public function delete(string $owner, string $repo, int $index, int $id): string + { + // Build the request path. + $path = "/repos/{$owner}/{$repo}/issues/{$index}/times/{$id}"; + + // Send the delete request. + return $this->response->get( + $this->http->delete( + $this->uri->get($path) + ), 204, 'success' + ); + } + +} + diff --git a/libraries/jcb_powers/VDM.Joomla.Gitea/src/Issue/index.html b/libraries/jcb_powers/VDM.Joomla.Gitea/src/Issue/index.html new file mode 100644 index 0000000..fa6d84e --- /dev/null +++ b/libraries/jcb_powers/VDM.Joomla.Gitea/src/Issue/index.html @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/libraries/jcb_powers/VDM.Joomla.Gitea/src/Labels.php b/libraries/jcb_powers/VDM.Joomla.Gitea/src/Labels.php new file mode 100644 index 0000000..43f2c9f --- /dev/null +++ b/libraries/jcb_powers/VDM.Joomla.Gitea/src/Labels.php @@ -0,0 +1,162 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ + +namespace VDM\Joomla\Gitea; + + +use VDM\Joomla\Gitea\Abstraction\Api; + + +/** + * The Gitea Labels + * + * @since 3.2.0 + */ +class Labels extends Api +{ + /** + * Create a label. + * + * @param string $owner The owner name. + * @param string $repo The repo name. + * @param string $labelName The name of the label. + * @param string $labelColor The color of the label, in hexadecimal format with the leading '#'. + * @param string $labelDescription Optional. The description of the label. + * + * @return object|null + * @since 3.2.0 + **/ + public function create(string $owner, string $repo, string $labelName, string $labelColor, string $labelDescription = ''): ?object + { + // Set the lines data + $data = new \stdClass(); + + // Set all the needed data. + $data->name = $labelName; + $data->color = $labelColor; + if (!empty($labelDescription)) + { + $data->description = $labelDescription; + } + + // Build the request path. + $path = "/repos/{$owner}/{$repo}/labels"; + + // Send the post request. + return $this->response->get( + $this->http->post( + $this->uri->get($path), + json_encode($data) + ), 201 + ); + } + + /** + * Get a single label. + * + * @param string $owner The owner name. + * @param string $repo The repo name. + * @param string $id The ID of the label to retrieve. + * + * @return object|null + * @since 3.2.0 + **/ + public function get(string $owner, string $repo, string $id): ?object + { + // Build the request path. + $path = "/repos/{$owner}/{$repo}/labels/{$id}"; + + // Send the get request. + return $this->response->get( + $this->http->get( + $this->uri->get($path) + ) + ); + } + + /** + * Delete a label. + * + * @param string $owner The owner name. + * @param string $repo The repo name. + * @param string $id The ID of the label to delete. + * + * @return string + * @since 3.2.0 + **/ + public function delete(string $owner, string $repo, string $id): string + { + // Build the request path. + $path = "/repos/{$owner}/{$repo}/labels/{$id}"; + + // Send the delete request. + return $this->response->get( + $this->http->delete( + $this->uri->get($path) + ), 204, 'success' + ); + } + + /** + * Update a label. + * + * @param string $owner The owner name. + * @param string $repo The repo name. + * @param string $id The ID of the label to update. + * @param string $labelName Optional. The new name of the label. + * @param string $labelColor Optional. The new color of the label, in hexadecimal format without the leading '#'. + * @param string $labelDescription Optional. The new description of the label. + * + * @return object|null + * @since 3.2.0 + **/ + public function update( + string $owner, + string $repo, + string $id, + string $labelName = '', + string $labelColor = '', + string $labelDescription = '' + ): ?object + { + // Set the lines data + $data = new \stdClass(); + + // Set all the optional data that has been provided. + if (!empty($labelName)) + { + $data->name = $labelName; + } + + if (!empty($labelColor)) + { + $data->color = $labelColor; + } + + if (!empty($labelDescription)) + { + $data->description = $labelDescription; + } + + // Build the request path. + $path = "/repos/{$owner}/{$repo}/labels/{$id}"; + + // Send the patch request. + return $this->response->get( + $this->http->patch( + $this->uri->get($path), + json_encode($data) + ) + ); + } + +} + diff --git a/libraries/jcb_powers/VDM.Joomla.Gitea/src/Miscellaneous/Activitypub.php b/libraries/jcb_powers/VDM.Joomla.Gitea/src/Miscellaneous/Activitypub.php new file mode 100644 index 0000000..78c6d27 --- /dev/null +++ b/libraries/jcb_powers/VDM.Joomla.Gitea/src/Miscellaneous/Activitypub.php @@ -0,0 +1,69 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ + +namespace VDM\Joomla\Gitea\Miscellaneous; + + +use VDM\Joomla\Gitea\Abstraction\Api; + + +/** + * The Gitea Miscellaneous Activitypub + * + * @since 3.2.0 + */ +class Activitypub extends Api +{ + /** + * Returns the Person actor for a user. + * + * @param string $username The user's username. + * + * @return object|null + * @since 3.2.0 + **/ + public function get(string $username): ?object + { + // Build the request path. + $path = "/activitypub/user/{$username}"; + + // Send the GET request. + return $this->response->get( + $this->http->get( + $this->uri->get($path) + ) + ); + } + + /** + * Send to the user's inbox. + * + * @param string $username The user's username. + * @param object $postData The post data. + * + * @return string + * @since 3.2.0 + **/ + public function send(string $username, object $postData): string + { + // Build the request path. + $path = "/activitypub/user/{$username}/inbox"; + + // Send the POST request. + return $this->response->get( + $this->http->post( + $this->uri->get($path), json_encode($postData) + ), 204, 'success' + ); + } + +} + diff --git a/libraries/jcb_powers/VDM.Joomla.Gitea/src/Miscellaneous/Gpg.php b/libraries/jcb_powers/VDM.Joomla.Gitea/src/Miscellaneous/Gpg.php new file mode 100644 index 0000000..5a92c54 --- /dev/null +++ b/libraries/jcb_powers/VDM.Joomla.Gitea/src/Miscellaneous/Gpg.php @@ -0,0 +1,45 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ + +namespace VDM\Joomla\Gitea\Miscellaneous; + + +use VDM\Joomla\Gitea\Abstraction\Api; + + +/** + * The Gitea Miscellaneous Gpg + * + * @since 3.2.0 + */ +class Gpg extends Api +{ + /** + * Get default signing-key.gpg. + * + * @return string|null + * @since 3.2.0 + **/ + public function get(): ?string + { + // Build the request path. + $path = "/signing-key.gpg"; + + // Send the get request. + return $this->response->get( + $this->http->get( + $this->uri->get($path) + ) + ); + } + +} + diff --git a/libraries/jcb_powers/VDM.Joomla.Gitea/src/Miscellaneous/Markdown.php b/libraries/jcb_powers/VDM.Joomla.Gitea/src/Miscellaneous/Markdown.php new file mode 100644 index 0000000..f6f54e5 --- /dev/null +++ b/libraries/jcb_powers/VDM.Joomla.Gitea/src/Miscellaneous/Markdown.php @@ -0,0 +1,87 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ + +namespace VDM\Joomla\Gitea\Miscellaneous; + + +use VDM\Joomla\Gitea\Abstraction\Api; + + +/** + * The Gitea Miscellaneous Markdown + * + * @since 3.2.0 + */ +class Markdown extends Api +{ + /** + * Render a markdown document as HTML. + * + * @param string $markdownText The markdown text to render. + * @param bool $isWikiPage Is it a wiki page? + * @param string $context Context to render. + * @param string $mode Mode to render. + * + * @return string|null + * @since 3.2.0 + **/ + public function render( + string $markdownText, + bool $isWikiPage = false, + string $context = 'string', + string $mode = 'string' + ): ?string + { + // Build the request path. + $path = "/markdown"; + + // Set the markdown data. + $data = new \stdClass(); + $data->Text = $markdownText; + $data->Wiki = $isWikiPage; + $data->Context = $context; + $data->Mode = $mode; + + // Send the post request. + return $this->response->get( + $this->http->post( + $this->uri->get($path), + json_encode($data), + ['accept' => 'text/html'] + ) + ); + } + + /** + * Render raw markdown as HTML. + * + * @param string $rawMarkdown The raw markdown text to render. + * + * @return string|null + * @since 3.2.0 + **/ + public function raw(string $rawMarkdown): ?string + { + // Build the request path. + $path = "/markdown/raw"; + + // Send the post request. + return $this->response->get( + $this->http->post( + $this->uri->get($path), + $rawMarkdown, + ['Content-Type' => 'text/plain', 'accept' => 'text/html'] + ) + ); + } + +} + diff --git a/libraries/jcb_powers/VDM.Joomla.Gitea/src/Miscellaneous/NodeInfo.php b/libraries/jcb_powers/VDM.Joomla.Gitea/src/Miscellaneous/NodeInfo.php new file mode 100644 index 0000000..fe714b2 --- /dev/null +++ b/libraries/jcb_powers/VDM.Joomla.Gitea/src/Miscellaneous/NodeInfo.php @@ -0,0 +1,45 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ + +namespace VDM\Joomla\Gitea\Miscellaneous; + + +use VDM\Joomla\Gitea\Abstraction\Api; + + +/** + * The Gitea Miscellaneous NodeInfo + * + * @since 3.2.0 + */ +class NodeInfo extends Api +{ + /** + * Returns the nodeinfo of the Gitea application. + * + * @return object|null + * @since 3.2.0 + **/ + public function get(): ?object + { + // Build the request path. + $path = "/nodeinfo"; + + // Send the get request. + return $this->response->get( + $this->http->get( + $this->uri->get($path) + ) + ); + } + +} + diff --git a/libraries/jcb_powers/VDM.Joomla.Gitea/src/Miscellaneous/Version.php b/libraries/jcb_powers/VDM.Joomla.Gitea/src/Miscellaneous/Version.php new file mode 100644 index 0000000..696db50 --- /dev/null +++ b/libraries/jcb_powers/VDM.Joomla.Gitea/src/Miscellaneous/Version.php @@ -0,0 +1,45 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ + +namespace VDM\Joomla\Gitea\Miscellaneous; + + +use VDM\Joomla\Gitea\Abstraction\Api; + + +/** + * The Gitea Miscellaneous Version + * + * @since 3.2.0 + */ +class Version extends Api +{ + /** + * Returns the version of the Gitea application. + * + * @return object|null + * @since 3.2.0 + **/ + public function get(): ?object + { + // Build the request path. + $path = "/version"; + + // Send the get request. + return $this->response->get( + $this->http->get( + $this->uri->get($path) + ) + ); + } + +} + diff --git a/libraries/jcb_powers/VDM.Joomla.Gitea/src/Miscellaneous/index.html b/libraries/jcb_powers/VDM.Joomla.Gitea/src/Miscellaneous/index.html new file mode 100644 index 0000000..fa6d84e --- /dev/null +++ b/libraries/jcb_powers/VDM.Joomla.Gitea/src/Miscellaneous/index.html @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/libraries/jcb_powers/VDM.Joomla.Gitea/src/Notifications.php b/libraries/jcb_powers/VDM.Joomla.Gitea/src/Notifications.php new file mode 100644 index 0000000..ffe33a8 --- /dev/null +++ b/libraries/jcb_powers/VDM.Joomla.Gitea/src/Notifications.php @@ -0,0 +1,149 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ + +namespace VDM\Joomla\Gitea; + + +use VDM\Joomla\Gitea\Abstraction\Api; + + +/** + * The Gitea Notifications + * + * @since 3.2.0 + */ +class Notifications extends Api +{ + /** + * List user's notification threads. + * + * @param bool|null $all Show notifications marked as read (optional). + * @param array|null $statusTypes Show notifications with the provided status types (optional). + * @param array|null $subjectType Filter notifications by subject type (optional). + * @param string|null $since Show notifications updated after the given time (optional). + * @param string|null $before Show notifications updated before the given time (optional). + * @param int $page Page number of results to return (optional). + * @param int $limit Page size of results (optional). + * + * @return array|null + * @since 3.2.0 + **/ + public function list( + ?bool $all = null, + ?array $statusTypes = null, + ?array $subjectType = null, + ?string $since = null, + ?string $before = null, + int $page = 1, + int $limit = 10 + ): ?array + { + // Build the request path. + $path = "/notifications"; + + // Configure the URI with query parameters. + $uri = $this->uri->get($path); + if ($all !== null) + { + $uri->setVar('all', $all); + } + if ($statusTypes !== null) + { + $uri->setVar('status-types', implode(',', $statusTypes)); + } + if ($subjectType !== null) + { + $uri->setVar('subject-type', implode(',', $subjectType)); + } + if ($since !== null) + { + $uri->setVar('since', $since); + } + if ($before !== null) + { + $uri->setVar('before', $before); + } + $uri->setVar('page', $page); + $uri->setVar('limit', $limit); + + // Send the get request. + return $this->response->get( + $this->http->get($uri) + ); + } + + /** + * Mark notification threads as read, pinned, or unread. + * + * @param string|null $lastReadAt Describes the last point that notifications were checked (optional). + * @param bool|null $all If true, mark all notifications on this repo (optional). + * @param array|null $statusTypes Mark notifications with the provided status types (optional). + * @param string|null $toStatus Status to mark notifications as (optional). + * + * @return array|null + * @since 3.2.0 + **/ + public function update( + ?string $lastReadAt = null, + ?bool $all = null, + ?array $statusTypes = null, + ?string $toStatus = null + ): ?array + { + // Build the request path. + $path = "/notifications"; + + // Configure the URI with query parameters. + $uri = $this->uri->get($path); + if ($lastReadAt !== null) + { + $uri->setVar('last_read_at', $lastReadAt); + } + if ($all !== null) + { + $uri->setVar('all', $all); + } + if ($statusTypes !== null) + { + $uri->setVar('status-types', implode(',', $statusTypes)); + } + if ($toStatus !== null) + { + $uri->setVar('to-status', $toStatus); + } + + // Send the put request. + return $this->response->get( + $this->http->put($uri, ''), 205 + ); + } + + /** + * Check if unread notifications exist. + * + * @return object|null + * @since 3.2.0 + **/ + public function check(): ?object + { + // Build the request path. + $path = "/notifications/new"; + + // Send the get request. + return $this->response->get( + $this->http->get( + $this->uri->get($path) + ) + ); + } + +} + diff --git a/libraries/jcb_powers/VDM.Joomla.Gitea/src/Notifications/Repository.php b/libraries/jcb_powers/VDM.Joomla.Gitea/src/Notifications/Repository.php new file mode 100644 index 0000000..4520391 --- /dev/null +++ b/libraries/jcb_powers/VDM.Joomla.Gitea/src/Notifications/Repository.php @@ -0,0 +1,144 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ + +namespace VDM\Joomla\Gitea\Notifications; + + +use VDM\Joomla\Gitea\Abstraction\Api; + + +/** + * The Gitea Notifications Repository + * + * @since 3.2.0 + */ +class Repository extends Api +{ + /** + * List user's notification threads on a specific repo. + * + * @param string $owner The owner name. + * @param string $repo The repository name. + * @param bool $all Show notifications marked as read. + * @param array $statusTypes Show notifications with the provided status types. + * @param array $subjectTypes Filter notifications by subject type. + * @param string $since Show notifications updated after the given time. + * @param string $before Show notifications updated before the given time. + * @param int $page Page number of results to return (1-based). + * @param int $limit Page size of results. + * + * @return array|null + * @since 3.2.0 + **/ + public function get( + string $owner, + string $repo, + bool $all = false, + array $statusTypes = [], + array $subjectTypes = [], + string $since = '', + string $before = '', + int $page = 1, + int $limit = 10 + ): ?array + { + // Build the request path. + $path = "/repos/{$owner}/{$repo}/notifications"; + + // Configure the URI with query parameters. + $uri = $this->uri->get($path); + + if ($all) + { + $uri->setVar('all', $all); + } + + if (!empty($statusTypes)) + { + $uri->setVar('status-types', implode(',', $statusTypes)); + } + + if (!empty($subjectTypes)) + { + $uri->setVar('subject-type', implode(',', $subjectTypes)); + } + + if (!empty($since)) + { + $uri->setVar('since', $since); + } + + if (!empty($before)) + { + $uri->setVar('before', $before); + } + + $uri->setVar('page', $page); + $uri->setVar('limit', $limit); + + // Send the get request. + return $this->response->get( + $this->http->get($uri) + ); + } + + /** + * Mark notification threads as read, pinned, or unread on a specific repo. + * + * @param string $owner The owner name. + * @param string $repo The repository name. + * @param bool|null $all Mark all notifications on this repo (optional). + * @param array|null $statusTypes Mark notifications with the provided status types (optional). + * @param string|null $toStatus Status to mark notifications as (optional). + * @param string|null $lastReadAt Last point that notifications were checked (optional). + * + * @return array|null + * @since 3.2.0 + **/ + public function update( + string $owner, + string $repo, + ?bool $all = null, + ?array $statusTypes = null, + ?string $toStatus = null, + ?string $lastReadAt = null + ): ?array + { + // Build the request path. + $path = "/repos/{$owner}/{$repo}/notifications"; + + // Configure the URI with query parameters. + $uri = $this->uri->get($path); + if ($all !== null) + { + $uri->setVar('all', $all); + } + if ($statusTypes !== null) + { + $uri->setVar('status-types', implode(',', $statusTypes)); + } + if ($toStatus !== null) + { + $uri->setVar('to-status', $toStatus); + } + if ($lastReadAt !== null) + { + $uri->setVar('last_read_at', $lastReadAt); + } + + // Send the put request. + return $this->response->get( + $this->http->put($uri, ''), 205 + ); + } + +} + diff --git a/libraries/jcb_powers/VDM.Joomla.Gitea/src/Notifications/Thread.php b/libraries/jcb_powers/VDM.Joomla.Gitea/src/Notifications/Thread.php new file mode 100644 index 0000000..ae8daaa --- /dev/null +++ b/libraries/jcb_powers/VDM.Joomla.Gitea/src/Notifications/Thread.php @@ -0,0 +1,96 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ + +namespace VDM\Joomla\Gitea\Notifications; + + +use VDM\Joomla\Gitea\Abstraction\Api; + + +/** + * The Gitea Notifications Thread + * + * @since 3.2.0 + */ +class Thread extends Api +{ + /** + * Get notification thread by ID. + * + * @param int $id The notification thread ID. + * + * @return object|null + * @since 3.2.0 + **/ + public function get(int $id): ?object + { + // Build the request path. + $path = "/notifications/threads/{$id}"; + + // Get the URI with the path. + $uri = $this->uri->get($path); + + // Send the get request. + return $this->response->get( + $this->http->get($uri) + ); + } + + /** + * Mark notification threads as read, pinned, or unread by ID. + * + * @param int $id The notification thread ID. + * @param string|null $lastReadAt Last point that notifications were checked (optional). + * @param bool|null $all Mark all notifications on this repo (optional). + * @param array|null $statusTypes Mark notifications with the provided status types (optional). + * @param string|null $toStatus Status to mark notifications as (optional). + * + * @return object|null + * @since 3.2.0 + **/ + public function mark( + int $id, + ?string $lastReadAt = null, + ?bool $all = null, + ?array $statusTypes = null, + ?string $toStatus = null + ): ?object + { + // Build the request path. + $path = "/notifications/threads/{$id}"; + + // Configure the URI with query parameters. + $uri = $this->uri->get($path); + if ($lastReadAt !== null) + { + $uri->setVar('last_read_at', $lastReadAt); + } + if ($all !== null) + { + $uri->setVar('all', $all); + } + if ($statusTypes !== null) + { + $uri->setVar('status-types', implode(',', $statusTypes)); + } + if ($toStatus !== null) + { + $uri->setVar('to-status', $toStatus); + } + + // Send the put request. + return $this->response->get( + $this->http->put($uri, ''), 205 + ); + } + +} + diff --git a/libraries/jcb_powers/VDM.Joomla.Gitea/src/Notifications/index.html b/libraries/jcb_powers/VDM.Joomla.Gitea/src/Notifications/index.html new file mode 100644 index 0000000..fa6d84e --- /dev/null +++ b/libraries/jcb_powers/VDM.Joomla.Gitea/src/Notifications/index.html @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/libraries/jcb_powers/VDM.Joomla.Gitea/src/Organization.php b/libraries/jcb_powers/VDM.Joomla.Gitea/src/Organization.php new file mode 100644 index 0000000..0e7255c --- /dev/null +++ b/libraries/jcb_powers/VDM.Joomla.Gitea/src/Organization.php @@ -0,0 +1,209 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ + +namespace VDM\Joomla\Gitea; + + +use VDM\Joomla\Gitea\Abstraction\Api; + + +/** + * The Gitea Organization + * + * @since 3.2.0 + */ +class Organization extends Api +{ + /** + * Create an organization. + * + * @param string $login Required. The organization's username. + * @param string $fullName Required. The full name of the organization. + * @param string $email Required. The email of the organization. + * @param string $description Optional. The description of the organization. + * @param bool $repoAdmin Optional. Whether the user has repository admin access. + * @param bool $teamAdmin Optional. Whether the user has team admin access. + * + * @return object|null + * @since 3.2.0 + **/ + public function create( + string $login, + string $fullName, + string $email, + string $description = '', + bool $repoAdmin = false, + bool $teamAdmin = false + ): ?object + { + // Set the lines data + $data = new \stdClass(); + $data->username = $login; + $data->full_name = $fullName; + $data->email = $email; + $data->description = $description; + $data->repo_admin_change_team_access = $repoAdmin; + $data->team_admin_change_team_access = $teamAdmin; + + // Build the request path. + $path = '/orgs'; + + // Send the post request. + return $this->response->get( + $this->http->post( + $this->uri->get($path), + json_encode($data) + ), 201 + ); + } + + /** + * Get an organization. + * + * @param string $org The organization name. + * + * @return object|null + * @since 3.2.0 + **/ + public function get(string $org): ?object + { + // Build the request path. + $path = "/orgs/{$org}"; + + // Send the get request. + return $this->response->get( + $this->http->get( + $this->uri->get($path) + ) + ); + } + + /** + * Get a list of organizations. + * + * @param int $page Page number of results to return (1-based). + * @param int $limit Page size of results. + * + * @return array|null + * @since 3.2.0 + **/ + public function list( + int $page = 1, + int $limit = 10 + ): ?array + { + // Build the request path. + $path = '/orgs'; + + // Get the URI and set query parameters. + $uri = $this->uri->get($path); + $uri->setVar('page', $page); + $uri->setVar('limit', $limit); + + // Send the get request. + return $this->response->get( + $this->http->get($uri) + ); + } + + /** + * Delete an organization. + * + * @param string $org The organization name. + * + * @return string + * @since 3.2.0 + **/ + public function delete(string $org): string + { + // Build the request path. + $path = "/orgs/{$org}"; + + // Send the delete request. + return $this->response->get( + $this->http->delete( + $this->uri->get($path) + ), 204, 'success' + ); + } + + /** + * Edit an organization. + * + * @param string $org The organization name. + * @param string $fullName Optional. The full name of the organization. + * @param string $location Optional. The location of the organization. + * @param string $description Optional. The description of the organization. + * @param bool $repoAdmin Optional. Whether the user has repository admin access. + * @param string $visibility Optional. The visibility of the organization (public, limited, or private). + * @param string $website Optional. The website of the organization. + * + * @return object|null + * @since 3.2.0 + **/ + public function edit( + string $org, + ?string $fullName = null, + ?string $email = null, + ?string $location = null, + ?string $description = null, + ?bool $repoAdmin = null, + ?string $visibility = null, + ?string $website = null + ): ?object + { + // Set the lines data + $data = new \stdClass(); + + if ($fullName !== null) + { + $data->full_name = $fullName; + } + + if ($location !== null) + { + $data->location = $location; + } + + if ($description !== null) + { + $data->description = $description; + } + + if ($repoAdmin !== null) + { + $data->repo_admin_change_team_access = $repoAdmin; + } + + if ($visibility !== null) + { + $data->visibility = $visibility; + } + + if ($website !== null) + { + $data->website = $website; + } + + // Build the request path. + $path = "/orgs/{$org}"; + + // Send the patch request. + return $this->response->get( + $this->http->patch( + $this->uri->get($path), + json_encode($data) + ) + ); + } + +} + diff --git a/libraries/jcb_powers/VDM.Joomla.Gitea/src/Organization/Hooks.php b/libraries/jcb_powers/VDM.Joomla.Gitea/src/Organization/Hooks.php new file mode 100644 index 0000000..981c065 --- /dev/null +++ b/libraries/jcb_powers/VDM.Joomla.Gitea/src/Organization/Hooks.php @@ -0,0 +1,200 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ + +namespace VDM\Joomla\Gitea\Organization; + + +use VDM\Joomla\Gitea\Abstraction\Api; + + +/** + * The Gitea Repository Organization Hooks + * + * @since 3.2.0 + */ +class Hooks extends Api +{ + /** + * List an organization's webhooks. + * + * @param string $orgName The organization name. + * @param int $page Page number of results to return (1-based). + * @param int $limit Page size of results. + * + * @return array|null + * @since 3.2.0 + **/ + public function list( + string $orgName, + int $page = 1, + int $limit = 10 + ): ?array + { + // Build the request path. + $path = "/orgs/{$orgName}/hooks"; + + // Get the URI and set query parameters. + $uri = $this->uri->get($path); + $uri->setVar('page', $page); + $uri->setVar('limit', $limit); + + // Send the get request. + return $this->response->get( + $this->http->get($uri) + ); + } + + /** + * Create a hook for an organization. + * + * @param string $org The organization name. + * @param string $type The type of hook (e.g. "gitea", "slack", "discord", etc.). + * @param string $url The URL of the hook. + * @param string $secret Optional. The secret for the hook. + * @param bool $events Optional. The events that trigger the hook. + * @param bool $active Optional. Whether the hook is active. + * + * @return object|null + * @since 3.2.0 + **/ + public function create( + string $org, + string $type, + string $url, + string $secret = '', + bool $events = true, + bool $active = true + ): ?object + { + // Set the lines data + $data = new \stdClass(); + $data->type = $type; + $data->config = new \stdClass(); + $data->config->url = $url; + $data->config->secret = $secret; + $data->events = []; + $data->active = $active; + + // Build the request path. + $path = "/orgs/{$org}/hooks"; + + // Send the post request. + return $this->response->get( + $this->http->post( + $this->uri->get($path), + json_encode($data) + ), 201 + ); + } + + /** + * Get a hook for an organization. + * + * @param string $org The organization name. + * @param int $id The ID of the hook. + * + * @return object|null + * @since 3.2.0 + **/ + public function get(string $org, int $id): ?object + { + // Build the request path. + $path = "/orgs/{$org}/hooks/{$id}"; + + // Send the get request. + return $this->response->get( + $this->http->get( + $this->uri->get($path) + ) + ); + } + + /** + * Delete a hook for an organization. + * + * @param string $org The organization name. + * @param int $id The hook ID. + * + * @return string + * @since 3.2.0 + **/ + public function delete(string $org, int $id): string + { + // Build the request path. + $path = "/orgs/{$org}/hooks/{$id}"; + + // Send the DELETE request. + return $this->response->get( + $this->http->delete( + $this->uri->get($path) + ), 204, 'success' + ); + } + + /** + * Update a hook for an organization. + * + * @param string $orgName The organization name. + * @param int $hookId The ID of the hook. + * @param bool|null $active Optional. Whether the hook is active. + * @param string|null $branchFilter Optional. Branch filter for the hook. + * @param array|null $config Optional. Configuration for the hook. + * @param array|null $events Optional. Events for the hook. + * + * @return object|null + * @since 3.2.0 + **/ + public function update( + string $orgName, + int $hookId, + ?bool $active = null, + ?string $branchFilter = null, + ?array $config = null, + ?array $events = null + ): ?object + { + // Set the lines data + $data = new \stdClass(); + + if ($active !== null) + { + $data->active = $active; + } + + if ($branchFilter !== null) + { + $data->branch_filter = $branchFilter; + } + + if ($config !== null) + { + $data->config = (object) $config; + } + + if ($events !== null) + { + $data->events = $events; + } + + // Build the request path. + $path = "/orgs/{$orgName}/hooks/{$hookId}"; + + // Send the patch request. + return $this->response->get( + $this->http->patch( + $this->uri->get($path), + json_encode($data) + ) + ); + } + +} + diff --git a/libraries/jcb_powers/VDM.Joomla.Gitea/src/Organization/Labels.php b/libraries/jcb_powers/VDM.Joomla.Gitea/src/Organization/Labels.php new file mode 100644 index 0000000..0836501 --- /dev/null +++ b/libraries/jcb_powers/VDM.Joomla.Gitea/src/Organization/Labels.php @@ -0,0 +1,183 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ + +namespace VDM\Joomla\Gitea\Organization; + + +use VDM\Joomla\Gitea\Abstraction\Api; + + +/** + * The Gitea Organization Labels + * + * @since 3.2.0 + */ +class Labels extends Api +{ + /** + * List an organization's labels. + * + * @param string $orgName The organization name. + * @param int $pageNum Page number of results to return (1-based). + * @param int $pageSize Page size of results. + * + * @return array|null + * @since 3.2.0 + **/ + public function list( + string $orgName, + int $pageNum = 1, + int $pageSize = 10 + ): ?array + { + // Build the request path. + $path = "/orgs/{$orgName}/labels"; + + // Build the URL + $url = $this->uri->get($path); + $url->setVar('page', $pageNum); + $url->setVar('limit', $pageSize); + + // Send the get request. + return $this->response->get( + $this->http->get($url) + ); + } + + /** + * Create a label for an organization. + * + * @param string $org The organization name. + * @param string $name The name of the label. + * @param string $color The color of the label. + * @param string $description Optional. The description of the label. + * + * @return object|null + * @since 3.2.0 + **/ + public function create( + string $org, + string $name, + string $color, + string $description = '' + ): ?object + { + // Set the lines data + $data = new \stdClass(); + $data->name = $name; + $data->color = $color; + $data->description = $description; + + // Build the request path. + $path = "/orgs/{$org}/labels"; + + // Send the post request. + return $this->response->get( + $this->http->post( + $this->uri->get($path), + json_encode($data) + ), 201 + ); + } + + /** + * Get a single label for an organization. + * + * @param string $org The organization name. + * @param int $id The ID of the label. + * + * @return object|null + * @since 3.2.0 + **/ + public function get(string $org, int $id): ?object + { + // Build the request path. + $path = "/orgs/{$org}/labels/{$id}"; + + // Send the get request. + return $this->response->get( + $this->http->get( + $this->uri->get($path) + ) + ); + } + + /** + * Delete a label for an organization. + * + * @param string $org The organization name. + * @param int $id The ID of the label. + * + * @return string + * @since 3.2.0 + **/ + public function delete(string $org, int $id): string + { + // Build the request path. + $path = "/orgs/{$org}/labels/{$id}"; + + // Send the delete request. + return $this->response->get( + $this->http->delete( + $this->uri->get($path) + ), 204, 'success' + ); + } + + /** + * Update a label for an organization. + * + * @param string $org The organization name. + * @param int $id The ID of the label. + * @param string $name Optional. The name of the label. + * @param string $color Optional. The color of the label. + * @param string $description Optional. The description of the label. + * + * @return object|null + * @since 3.2.0 + **/ + public function update( + string $org, + int $id, + string $name = '', + string $color = '', + string $description = '' + ): ?object + { + // Set the lines data + $data = new \stdClass(); + + if ($name) { + $data->name = $name; + } + + if ($color) { + $data->color = $color; + } + + if ($description) { + $data->description = $description; + } + + // Build the request path. + $path = "/orgs/{$org}/labels/{$id}"; + + // Send the patch request. + return $this->response->get( + $this->http->patch( + $this->uri->get($path), + json_encode($data) + ) + ); + } + +} + diff --git a/libraries/jcb_powers/VDM.Joomla.Gitea/src/Organization/Members.php b/libraries/jcb_powers/VDM.Joomla.Gitea/src/Organization/Members.php new file mode 100644 index 0000000..97bf82b --- /dev/null +++ b/libraries/jcb_powers/VDM.Joomla.Gitea/src/Organization/Members.php @@ -0,0 +1,100 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ + +namespace VDM\Joomla\Gitea\Organization; + + +use VDM\Joomla\Gitea\Abstraction\Api; + + +/** + * The Gitea Organization Members + * + * @since 3.2.0 + */ +class Members extends Api +{ + /** + * Get a list of members of an organization. + * + * @param string $orgName The organization name. + * @param int $page The page number. + * @param int $limit The number of members per page. + * + * @return array|null The organization members. + * @since 3.2.0 + */ + public function list( + string $orgName, + int $page = 1, + int $limit = 10 + ): ?array + { + // Build the request path. + $path = "/orgs/{$orgName}/members"; + + // Get the URI and set query parameters. + $uri = $this->uri->get($path); + $uri->setVar('page', $page); + $uri->setVar('limit', $limit); + + // Send the request. + return $this->response->get( + $this->http->get($uri) + ); + } + + /** + * Check if a user is a member of an organization. + * + * @param string $org The organization name. + * @param string $username The username. + * + * @return string Whether the user is a member of the organization. + * @since 3.2.0 + */ + public function check(string $org, string $username): string + { + // Build the request path. + $path = "/orgs/{$org}/members/{$username}"; + + // Send the request. + return $this->response->get( + $this->http->get( + $this->uri->get($path) + ), 204, 'success' + ); + } + + /** + * Remove a member from an organization. + * + * @param string $org The organization name. + * @param string $username The username of the user to remove. + * + * @return string Whether the user was successfully removed from the organization. + * @since 3.2.0 + */ + public function remove(string $org, string $username): string + { + // Build the request path. + $path = "/orgs/{$org}/members/{$username}"; + + // Send the request. + return $this->response->get( + $this->http->delete( + $this->uri->get($path) + ), 204, 'success' + ); + } + +} + diff --git a/libraries/jcb_powers/VDM.Joomla.Gitea/src/Organization/PublicMembers.php b/libraries/jcb_powers/VDM.Joomla.Gitea/src/Organization/PublicMembers.php new file mode 100644 index 0000000..c828532 --- /dev/null +++ b/libraries/jcb_powers/VDM.Joomla.Gitea/src/Organization/PublicMembers.php @@ -0,0 +1,119 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ + +namespace VDM\Joomla\Gitea\Organization; + + +use VDM\Joomla\Gitea\Abstraction\Api; + + +/** + * The Gitea Organization Public Members + * + * @since 3.2.0 + */ +class PublicMembers extends Api +{ + /** + * List an organization's public members. + * + * @param string $orgName The organization name. + * @param int $page Page number of results to return (1-based). + * @param int $limit Page size of results. + * + * @return array|null + * @since 3.2.0 + **/ + public function list(string $orgName, int $page = 1, int $limit = 10): ?array + { + // Build the request path. + $path = "/orgs/{$orgName}/public_members"; + + // Configure the request URI. + $uri = $this->uri->get($path); + $uri->setVar('page', $page); + $uri->setVar('limit', $limit); + + // Send the get request. + return $this->response->get( + $this->http->get($uri) + ); + } + + + /** + * Check if a user is a public member of an organization. + * + * @param string $org The organization name. + * @param string $username The user's username. + * + * @return string|null + * @since 3.2.0 + **/ + public function check(string $org, string $username): ?string + { + // Build the request path. + $path = "/orgs/{$org}/public_members/{$username}"; + + // Send the get request. + return $this->response->get( + $this->http->get( + $this->uri->get($path) + ), 204 + ); + } + + /** + * Publicize a user's membership. + * + * @param string $org The organization name. + * @param string $username The user's username. + * + * @return string|null + * @since 3.2.0 + **/ + public function publicize(string $org, string $username): ?string + { + // Build the request path. + $path = "/orgs/{$org}/public_members/{$username}"; + + // Send the put request. + return $this->response->get( + $this->http->put( + $this->uri->get($path), '' + ), 204 + ); + } + + /** + * Conceal a user's membership. + * + * @param string $org The organization name. + * @param string $username The user's username. + * + * @return string + * @since 3.2.0 + **/ + public function conceal(string $org, string $username): string + { + // Build the request path. + $path = "/orgs/{$org}/public_members/{$username}"; + + // Send the delete request. + return $this->response->get( + $this->http->delete( + $this->uri->get($path) + ), 204, 'success' + ); + } + +} + diff --git a/libraries/jcb_powers/VDM.Joomla.Gitea/src/Organization/Repository.php b/libraries/jcb_powers/VDM.Joomla.Gitea/src/Organization/Repository.php new file mode 100644 index 0000000..18c5384 --- /dev/null +++ b/libraries/jcb_powers/VDM.Joomla.Gitea/src/Organization/Repository.php @@ -0,0 +1,145 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ + +namespace VDM\Joomla\Gitea\Organization; + + +use VDM\Joomla\Gitea\Abstraction\Api; + + +/** + * The Gitea Organization Repository + * + * @since 3.2.0 + */ +class Repository extends Api +{ + /** + * List an organization's repos. + * + * @param string $org The organization name. + * @param int $pageNumber The page number. + * @param int $pageSize The page size of results. + * + * @return array|null + * @since 3.2.0 + **/ + public function list( + string $org, + int $pageNumber = 1, + int $pageSize = 10 + ): ?array + { + // Build the request path. + $path = "/orgs/{$org}/repos"; + + // Configure the request URI. + $uri = $this->uri->get($path); + $uri->setVar('page', $pageNumber); + $uri->setVar('limit', $pageSize); + + // Send the get request. + return $this->response->get( + $this->http->get($uri) + ); + } + + /** + * Create a repository in an organization. + * + * @param string $org The organization name. + * @param string $repoName The name of the repository. + * @param string|null $description The description of the repository (optional). + * @param bool|null $autoInit Whether the repository should be auto-initialized (optional). + * @param string|null $defaultBranch Default branch of the repository (optional). + * @param string|null $gitignores Gitignores to use (optional). + * @param string|null $issueLabels Label-set to use (optional). + * @param string|null $license License to use (optional). + * @param bool|null $private Whether the repository is private (optional). + * @param string|null $readme Readme of the repository to create (optional). + * @param bool|null $template Whether the repository is a template (optional). + * @param string|null $trustModel Trust model of the repository (optional). + * + * @return object|null + * @since 3.2.0 + **/ + public function create( + string $org, + string $repoName, + ?string $description = null, + ?bool $autoInit = null, + ?string $defaultBranch = null, + ?string $gitignores = null, + ?string $issueLabels = null, + ?string $license = null, + ?bool $private = null, + ?string $readme = null, + ?bool $template = null, + ?string $trustModel = null + ): ?object + { + // Build the request path. + $path = "/orgs/{$org}/repos"; + + // Set the repository data. + $data = new \stdClass(); + $data->name = $repoName; + if ($description !== null) + { + $data->description = $description; + } + if ($autoInit !== null) + { + $data->auto_init = $autoInit; + } + if ($defaultBranch !== null) + { + $data->default_branch = $defaultBranch; + } + if ($gitignores !== null) + { + $data->gitignores = $gitignores; + } + if ($issueLabels !== null) + { + $data->issue_labels = $issueLabels; + } + if ($license !== null) + { + $data->license = $license; + } + if ($private !== null) + { + $data->private = $private; + } + if ($readme !== null) + { + $data->readme = $readme; + } + if ($template !== null) + { + $data->template = $template; + } + if ($trustModel !== null) + { + $data->trust_model = $trustModel; + } + + // Send the post request. + return $this->response->get( + $this->http->post( + $this->uri->get($path), json_encode($data) + ) + ); + } + +} + diff --git a/libraries/jcb_powers/VDM.Joomla.Gitea/src/Organization/Teams.php b/libraries/jcb_powers/VDM.Joomla.Gitea/src/Organization/Teams.php new file mode 100644 index 0000000..46a27b0 --- /dev/null +++ b/libraries/jcb_powers/VDM.Joomla.Gitea/src/Organization/Teams.php @@ -0,0 +1,274 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ + +namespace VDM\Joomla\Gitea\Organization; + + +use VDM\Joomla\Gitea\Abstraction\Api; + + +/** + * The Gitea Organization Teams + * + * @since 3.2.0 + */ +class Teams extends Api +{ + /** + * List an organization's teams. + * + * @param string $organization The organization name. + * @param int $pageNumber The page number of results to return (1-based). + * @param int $pageSize The page size of results. + * + * @return array|null + * @since 3.2.0 + **/ + public function list( + string $organization, + int $pageNumber = 1, + int $pageSize = 10 + ): ?array + { + // Build the request path. + $path = "/orgs/{$organization}/teams"; + + // Get the URI object. + $uri = $this->uri->get($path); + + // Add the query parameters for page number and page size. + $uri->setVar('page', $pageNumber); + $uri->setVar('limit', $pageSize); + + // Send the get request. + return $this->response->get( + $this->http->get($uri) + ); + } + + /** + * Get a team. + * + * @param int $id The team ID. + * + * @return object|null + * @since 3.2.0 + **/ + public function get(int $id): ?object + { + // Build the request path. + $path = "/teams/{$id}"; + + // Send the get request. + return $this->response->get( + $this->http->get( + $this->uri->get($path) + ) + ); + } + + /** + * Create a team. + * + * @param string $organization The organization name. + * @param string $name The name of the team. + * @param string $description The description of the team. + * @param array $repoNames An array of repository names for the team (optional). + * @param string $permission The team's permission level (optional). + * @param array $units Units for the team (optional). + * @param array $unitsMap Units map for the team (optional). + * @param bool $canCreateOrgRepo Can create organization repository flag (optional). + * @param bool $includesAllRepositories Includes all repositories flag (optional). + * + * @return object|null + * @since 3.2.0 + **/ + public function create( + string $organization, + string $name, + string $description, + array $repoNames = [], + string $permission = 'read', + array $units = [], + array $unitsMap = [], + bool $canCreateOrgRepo = null, + bool $includesAllRepositories = null + ): ?object + { + // Build the request path. + $path = "/orgs/{$organization}/teams"; + + // Set the team data. + $data = new \stdClass(); + $data->name = $name; + $data->description = $description; + $data->permission = $permission; + + if (!empty($repoNames)) + { + $data->repo_names = $repoNames; + } + + if (!empty($units)) + { + $data->units = $units; + } + + if (!empty($unitsMap)) + { + $data->units_map = (object)$unitsMap; + } + + if ($canCreateOrgRepo !== null) + { + $data->can_create_org_repo = $canCreateOrgRepo; + } + + if ($includesAllRepositories !== null) + { + $data->includes_all_repositories = $includesAllRepositories; + } + + // Send the post request. + return $this->response->get( + $this->http->post( + $this->uri->get($path), json_encode($data) + ), 201 + ); + } + + /** + * Search for teams within an organization. + * + * @param string $organization The organization name. + * @param string $keywords The search keywords. + * @param bool $includeDesc Include search within team description (defaults to true). + * @param int $page The page number. + * @param int $limit The number of results per page. + * + * @return object|null + * @since 3.2.0 + **/ + public function search( + string $organization, + string $keywords, + bool $includeDesc = true, + int $page = 1, + int $limit = 10 + ): ?object + { + // Build the request path. + $path = "/orgs/{$organization}/teams/search"; + + // Configure the request URI. + $uri = $this->uri->get($path); + $uri->setVar('q', $keywords); + $uri->setVar('include_desc', $includeDesc); + $uri->setVar('page', $page); + $uri->setVar('limit', $limit); + + // Send the get request. + return $this->response->get( + $this->http->get($uri) + ); + } + + /** + * Delete a team. + * + * @param int $id The team ID. + * + * @return string + * @since 3.2.0 + **/ + public function delete(int $id): string + { + // Build the request path. + $path = "/teams/{$id}"; + + // Send the delete request. + return $this->response->get( + $this->http->delete( + $this->uri->get($path) + ), 204, 'success' + ); + } + + /** + * Edit a team. + * + * @param int $teamId The team ID. + * @param string|null $teamName The team name (optional). + * @param string|null $teamDescription The team description (optional). + * @param string|null $teamPermission The team's permission level (optional). + * @param bool|null $canCreateOrgRepo Can team create organization repositories (optional). + * @param bool|null $includesAllRepositories Include all repositories (optional). + * @param array|null $units List of units (optional). + * @param array|null $unitsMap Units map (optional). + * + * @return object|null + * @since 3.2.0 + **/ + public function edit( + int $teamId, + ?string $teamName = null, + ?string $teamDescription = null, + ?string $teamPermission = null, + ?bool $canCreateOrgRepo = null, + ?bool $includesAllRepositories = null, + ?array $units = null, + ?array $unitsMap = null + ): ?object + { + // Build the request path. + $path = "/teams/{$teamId}"; + + // Set the team data. + $data = new \stdClass(); + if ($teamName !== null) + { + $data->name = $teamName; + } + if ($teamDescription !== null) + { + $data->description = $teamDescription; + } + if ($teamPermission !== null) + { + $data->permission = $teamPermission; + } + if ($canCreateOrgRepo !== null) + { + $data->can_create_org_repo = $canCreateOrgRepo; + } + if ($includesAllRepositories !== null) + { + $data->includes_all_repositories = $includesAllRepositories; + } + if ($units !== null) + { + $data->units = $units; + } + if ($unitsMap !== null) + { + $data->units_map = $unitsMap; + } + + // Send the patch request. + return $this->response->get( + $this->http->patch( + $this->uri->get($path), json_encode($data) + ) + ); + } + +} + diff --git a/libraries/jcb_powers/VDM.Joomla.Gitea/src/Organization/Teams/Members.php b/libraries/jcb_powers/VDM.Joomla.Gitea/src/Organization/Teams/Members.php new file mode 100644 index 0000000..89e9145 --- /dev/null +++ b/libraries/jcb_powers/VDM.Joomla.Gitea/src/Organization/Teams/Members.php @@ -0,0 +1,124 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ + +namespace VDM\Joomla\Gitea\Organization\Teams; + + +use VDM\Joomla\Gitea\Abstraction\Api; + + +/** + * The Gitea Organization Teams Members + * + * @since 3.2.0 + */ +class Members extends Api +{ + /** + * List a team's members. + * + * @param int $teamId The team ID. + * @param int $pageNumber The page number of results to return (1-based). + * @param int $pageSize The page size of results. + * + * @return array|null + * @since 3.2.0 + **/ + public function list( + int $teamId, + int $pageNumber = 1, + int $pageSize = 10 + ): ?array + { + // Build the request path. + $path = "/teams/{$teamId}/members"; + + // Get the URI object. + $uri = $this->uri->get($path); + + // Add the query parameters for page number and page size. + $uri->setVar('page', $pageNumber); + $uri->setVar('limit', $pageSize); + + // Send the get request. + return $this->response->get( + $this->http->get($uri) + ); + } + + /** + * List a particular member of the team. + * + * @param int $id The team ID. + * @param string $username The user's username. + * + * @return object|null + * @since 3.2.0 + **/ + public function get(int $id, string $username): ?object + { + // Build the request path. + $path = "/teams/{$id}/members/{$username}"; + + // Send the get request. + return $this->response->get( + $this->http->get( + $this->uri->get($path) + ) + ); + } + + /** + * Add a team member. + * + * @param int $id The team ID. + * @param string $username The user's username. + * + * @return string + * @since 3.2.0 + **/ + public function add(int $id, string $username): string + { + // Build the request path. + $path = "/teams/{$id}/members/{$username}"; + + // Send the put request. + return $this->response->get( + $this->http->put( + $this->uri->get($path), '' + ), 204, 'success' + ); + } + + /** + * Remove a team member. + * + * @param int $id The team ID. + * @param string $username The user's username. + * + * @return string + * @since 3.2.0 + **/ + public function remove(int $id, string $username): string + { + // Build the request path. + $path = "/teams/{$id}/members/{$username}"; + + // Send the delete request. + return $this->response->get( + $this->http->delete( + $this->uri->get($path) + ), 204, 'success' + ); + } + +} + diff --git a/libraries/jcb_powers/VDM.Joomla.Gitea/src/Organization/Teams/Repository.php b/libraries/jcb_powers/VDM.Joomla.Gitea/src/Organization/Teams/Repository.php new file mode 100644 index 0000000..f485c09 --- /dev/null +++ b/libraries/jcb_powers/VDM.Joomla.Gitea/src/Organization/Teams/Repository.php @@ -0,0 +1,135 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ + +namespace VDM\Joomla\Gitea\Organization\Teams; + + +use VDM\Joomla\Gitea\Abstraction\Api; + + +/** + * The Gitea Organization Teams Repository + * + * @since 3.2.0 + */ +class Repository extends Api +{ + /** + * List a team's repos. + * + * @param int $teamId The team ID. + * @param int $pageNumber The page number of results to return (1-based). + * @param int $pageSize The page size of results. + * + * @return array|null + * @since 3.2.0 + **/ + public function list( + int $teamId, + int $pageNumber = 1, + int $pageSize = 10 + ): ?array + { + // Build the request path. + $path = "/teams/{$teamId}/repos"; + + // Get the URI object. + $uri = $this->uri->get($path); + + // Add the query parameters for page number and page size. + $uri->setVar('page', $pageNumber); + $uri->setVar('limit', $pageSize); + + // Send the get request. + return $this->response->get( + $this->http->get($uri) + ); + } + + /** + * List a particular repo of the team. + * + * @param int $teamId The team ID. + * @param string $organization The organization name. + * @param string $repository The repository name. + * + * @return object|null + * @since 3.2.0 + **/ + public function get( + int $teamId, + string $organization, + string $repository + ): ?object + { + // Build the request path. + $path = "/teams/{$teamId}/repos/{$organization}/{$repository}"; + + // Send the get request. + return $this->response->get( + $this->http->get( + $this->uri->get($path) + ) + ); + } + + /** + * Add a repository to a team. + * + * @param int $id The team ID. + * @param string $org The organization name. + * @param string $repo The repository name. + * + * @return string + * @since 3.2.0 + **/ + public function add( + int $id, + string $org, + string $repo + ): string + { + // Build the request path. + $path = "/teams/{$id}/repos/{$org}/{$repo}"; + + // Send the put request. + return $this->response->get( + $this->http->put( + $this->uri->get($path), '' + ),204, 'success' + ); + } + + /** + * Remove a repository from a team. + * + * @param int $id The team ID. + * @param string $org The organization name. + * @param string $repo The repository name. + * + * @return string + * @since 3.2.0 + **/ + public function remove(int $id, string $org, string $repo): string + { + // Build the request path. + $path = "/teams/{$id}/repos/{$org}/{$repo}"; + + // Send the delete request. + return $this->response->get( + $this->http->delete( + $this->uri->get($path) + ), 204, 'success' + ); + } + +} + diff --git a/libraries/jcb_powers/VDM.Joomla.Gitea/src/Organization/Teams/index.html b/libraries/jcb_powers/VDM.Joomla.Gitea/src/Organization/Teams/index.html new file mode 100644 index 0000000..fa6d84e --- /dev/null +++ b/libraries/jcb_powers/VDM.Joomla.Gitea/src/Organization/Teams/index.html @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/libraries/jcb_powers/VDM.Joomla.Gitea/src/Organization/User.php b/libraries/jcb_powers/VDM.Joomla.Gitea/src/Organization/User.php new file mode 100644 index 0000000..b59fe9b --- /dev/null +++ b/libraries/jcb_powers/VDM.Joomla.Gitea/src/Organization/User.php @@ -0,0 +1,111 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ + +namespace VDM\Joomla\Gitea\Organization; + + +use VDM\Joomla\Gitea\Abstraction\Api; + + +/** + * The Gitea Organization User + * + * @since 3.2.0 + */ +class User extends Api +{ + /** + * List the current user's organizations. + * + * @param int $pageNumber The page number of results to return (1-based). + * @param int $pageSize The page size of results. + * + * @return array|null + * @since 3.2.0 + **/ + public function list( + int $pageNumber = 1, + int $pageSize = 10 + ): ?array + { + // Build the request path. + $path = "/user/orgs"; + + // Get the URI object. + $uri = $this->uri->get($path); + + // Add the query parameters for page number and page size. + $uri->setVar('page', $pageNumber); + $uri->setVar('limit', $pageSize); + + // Send the get request. + return $this->response->get( + $this->http->get($uri) + ); + } + + /** + * List a user's organizations. + * + * @param string $username The user's username. + * @param int $pageNumber The page number of results to return (1-based). + * @param int $pageSize The page size of results. + * + * @return array|null + * @since 3.2.0 + **/ + public function get( + string $username, + int $pageNumber = 1, + int $pageSize = 10 + ): ?array + { + // Build the request path. + $path = "/users/{$username}/orgs"; + + // Get the URI object. + $uri = $this->uri->get($path); + + // Add the query parameters for page number and page size. + $uri->setVar('page', $pageNumber); + $uri->setVar('limit', $pageSize); + + // Send the get request. + return $this->response->get( + $this->http->get($uri) + ); + } + + /** + * Get user permissions in an organization. + * + * @param string $username The user's username. + * @param string $org The organization name. + * + * @return object|null + * @since 3.2.0 + **/ + public function permissions(string $username, string $org): ?object + { + // Build the request path. + $path = "/users/{$username}/orgs/{$org}/permissions"; + + // Send the get request. + return $this->response->get( + $this->http->get( + $this->uri->get($path) + ) + ); + } + + +} + diff --git a/libraries/jcb_powers/VDM.Joomla.Gitea/src/Organization/index.html b/libraries/jcb_powers/VDM.Joomla.Gitea/src/Organization/index.html new file mode 100644 index 0000000..fa6d84e --- /dev/null +++ b/libraries/jcb_powers/VDM.Joomla.Gitea/src/Organization/index.html @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/libraries/jcb_powers/VDM.Joomla.Gitea/src/Package.php b/libraries/jcb_powers/VDM.Joomla.Gitea/src/Package.php new file mode 100644 index 0000000..8fb1ac2 --- /dev/null +++ b/libraries/jcb_powers/VDM.Joomla.Gitea/src/Package.php @@ -0,0 +1,84 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ + +namespace VDM\Joomla\Gitea; + + +use VDM\Joomla\Gitea\Abstraction\Api; + + +/** + * The Gitea Package + * + * @since 3.2.0 + */ +class Package extends Api +{ + /** + * Gets a package. + * + * @param string $owner The owner of the package. + * @param string $type The type of the package. + * @param string $name The name of the package. + * @param string $version The version of the package. + * + * @return object|null + * @since 3.2.0 + **/ + public function get( + string $owner, + string $type, + string $name, + string $version + ): ?object + { + // Build the request path. + $path = "/packages/{$owner}/{$type}/{$name}/{$version}"; + + // Send the get request. + return $this->response->get( + $this->http->get( + $this->uri->get($path) + ) + ); + } + + /** + * Delete a package. + * + * @param string $owner The owner of the package. + * @param string $type The type of the package. + * @param string $name The name of the package. + * @param string $version The version of the package. + * + * @return string + * @since 3.2.0 + **/ + public function delete( + string $owner, + string $type, + string $name, + string $version + ): string + { + // Build the request path. + $path = "/packages/{$owner}/{$type}/{$name}/{$version}"; + + // Send the delete request. + return $this->response->get( + $this->http->delete( + $this->uri->get($path) + ), 204, 'success' + ); + } + +} + diff --git a/libraries/jcb_powers/VDM.Joomla.Gitea/src/Package/Files.php b/libraries/jcb_powers/VDM.Joomla.Gitea/src/Package/Files.php new file mode 100644 index 0000000..c3851c0 --- /dev/null +++ b/libraries/jcb_powers/VDM.Joomla.Gitea/src/Package/Files.php @@ -0,0 +1,55 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ + +namespace VDM\Joomla\Gitea\Package; + + +use VDM\Joomla\Gitea\Abstraction\Api; + + +/** + * The Gitea Package Files + * + * @since 3.2.0 + */ +class Files extends Api +{ + /** + * Gets all files of a package. + * + * @param string $owner The owner of the package. + * @param string $type The type of the package. + * @param string $name The name of the package. + * @param string $version The version of the package. + * + * @return object|null + * @since 3.2.0 + **/ + public function get( + string $owner, + string $type, + string $name, + string $version + ): ?object + { + // Build the request path. + $path = "/packages/{$owner}/{$type}/{$name}/{$version}/files"; + + // Send the get request. + return $this->response->get( + $this->http->get( + $this->uri->get($path) + ) + ); + } + +} + diff --git a/libraries/jcb_powers/VDM.Joomla.Gitea/src/Package/Owner.php b/libraries/jcb_powers/VDM.Joomla.Gitea/src/Package/Owner.php new file mode 100644 index 0000000..93960d1 --- /dev/null +++ b/libraries/jcb_powers/VDM.Joomla.Gitea/src/Package/Owner.php @@ -0,0 +1,68 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ + +namespace VDM\Joomla\Gitea\Package; + + +use VDM\Joomla\Gitea\Abstraction\Api; + + +/** + * The Gitea Package Owner + * + * @since 3.2.0 + */ +class Owner extends Api +{ + /** + * Gets all packages of an owner. + * + * @param string $owner The owner of the packages. + * @param int $page Page number of results to return (1-based). + * @param int $limit Page size of results. + * @param string|null $type Package type filter (optional). + * @param string|null $name Filter Name filter (optional). + * + * @return array|null + * @since 3.2.0 + **/ + public function get( + string $owner, + int $page = 1, + int $limit = 10, + ?string $type = null, + ?string $nameFilter = null + ): ?array + { + // Build the request path. + $path = "/packages/{$owner}"; + + // Configure the URI with query parameters. + $uri = $this->uri->get($path); + $uri->setVar('page', $page); + $uri->setVar('limit', $limit); + if ($type !== null) + { + $uri->setVar('type', $type); + } + if ($nameFilter !== null) + { + $uri->setVar('q', $nameFilter); + } + + // Send the get request. + return $this->response->get( + $this->http->get($uri) + ); + } + +} + diff --git a/libraries/jcb_powers/VDM.Joomla.Gitea/src/Package/index.html b/libraries/jcb_powers/VDM.Joomla.Gitea/src/Package/index.html new file mode 100644 index 0000000..fa6d84e --- /dev/null +++ b/libraries/jcb_powers/VDM.Joomla.Gitea/src/Package/index.html @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/libraries/jcb_powers/VDM.Joomla.Gitea/src/Repository.php b/libraries/jcb_powers/VDM.Joomla.Gitea/src/Repository.php new file mode 100644 index 0000000..c1e7126 --- /dev/null +++ b/libraries/jcb_powers/VDM.Joomla.Gitea/src/Repository.php @@ -0,0 +1,439 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ + +namespace VDM\Joomla\Gitea; + + +use VDM\Joomla\Gitea\Abstraction\Api; + + +/** + * The Gitea Repository + * + * @since 3.2.0 + */ +class Repository extends Api +{ + /** + * Search for repositories. + * + * @param string $q The search query. + * @param array $options Additional search options (optional). + * @param int $page The page number (optional). + * @param int $limit The number of items per page (optional). + * @param string $sort The sort order (optional). + * @param string $order The order direction (optional). + * + * @return object|null + * @since 3.2.0 + **/ + public function search( + string $q, + array $options = [], + int $page = 1, + int $limit = 10, + string $sort = 'alpha', + string $order = 'asc' + ): ?object + { + // Build the request path. + $path = '/repos/search'; + + // Create the URI object and set URL values. + $uri = $this->uri->get($path); + $uri->setVar('q', $q); + $uri->setVar('page', $page); + $uri->setVar('limit', $limit); + $uri->setVar('sort', $sort); + $uri->setVar('order', $order); + + foreach ($options as $key => $val) + { + $uri->setVar($key, $val); + } + + // Send the get request. + return $this->response->get( + $this->http->get($uri) + ); + } + + /** + * Get a repository. + * + * @param string $owner The owner name. + * @param string $repo The repository name. + * + * @return object|null + * @since 3.2.0 + **/ + public function get(string $owner, string $repo): ?object + { + // Build the request path. + $path = "/repos/{$owner}/{$repo}"; + + // Send the get request. + return $this->response->get( + $this->http->get( + $this->uri->get($path) + ) + ); + } + + /** + * Get a repository by owner and repo name. + * + * @param string $owner The owner name. + * @param string $repo The repository name. + * + * @return object|null + * @since 3.2.0 + **/ + public function id(string $owner, string $repo): ?object + { + // Build the request path. + $path = "/repos/{$owner}/{$repo}"; + + // Send the get request. + return $this->response->get( + $this->http->get( + $this->uri->get($path) + ) + ); + } + + /** + * Delete a repository. + * + * @param string $owner The owner name. + * @param string $repo The repository name. + * + * @return string + * @since 3.2.0 + **/ + public function delete(string $owner, string $repo): string + { + // Build the request path. + $path = "/repos/{$owner}/{$repo}"; + + // Send the delete request. + return $this->response->get( + $this->http->delete( + $this->uri->get($path) + ), 204, 'success' + ); + } + + /** + * Edit a repository's properties. + * + * @param string $owner The owner name. + * @param string $repo The repository name. + * @param string|null $description The repository description (optional). + * @param string|null $website The repository website (optional). + * @param bool|null $private Set the repository to private (optional). + * @param bool|null $hasIssues Set the repository to have issues (optional). + * @param bool|null $hasWiki Set the repository to have a wiki (optional). + * @param bool|null $hasProjects Set the repository to have projects (optional). + * @param bool|null $allowManualMerge Allow manual merge of pull requests (optional). + * @param bool|null $allowMergeCommits Allow merge commits for pull requests (optional). + * @param bool|null $allowRebase Allow rebase-merging pull requests (optional). + * @param bool|null $allowRebaseExplicit Allow rebase with explicit merge commits (optional). + * @param bool|null $allowRebaseUpdate Allow updating pull request branch by rebase (optional). + * @param bool|null $allowSquashMerge Allow squash-merging pull requests (optional). + * @param bool|null $archived + * @param bool|null $archived Set to true to archive this repository (optional). + * @param bool|null $autodetectManualMerge Enable AutodetectManualMerge (optional). + * @param string|null $defaultBranch Sets the default branch for this repository (optional). + * @param bool|null $defaultDeleteBranchAfterMerge Set to true to delete pr branch after merge by default (optional). + * @param string|null $defaultMergeStyle Set to a merge style to be used by this repository (optional). + * @param bool|null $enablePrune Enable prune - remove obsolete remote-tracking references (optional). + * @param object|null $externalTracker External tracker settings (optional). + * @param object|null $externalWiki External wiki settings (optional). + * @param bool|null $hasPullRequests Set the repository to have pull requests (optional). + * @param bool|null $ignoreWhitespaceConflicts Ignore whitespace for conflicts (optional). + * @param object|null $internalTracker Internal tracker settings (optional). + * @param string|null $mirrorInterval Set the mirror interval time (optional). + * @param bool|null $template Set to true to make this repository a template (optional). + * + * @return object|null + * @since 3.2.0 + **/ + public function edit( + string $owner, + string $repo, + ?string $description = null, + ?string $website = null, + ?bool $private = null, + ?bool $hasIssues = null, + ?bool $hasWiki = null, + ?bool $hasProjects = null, + ?bool $allowManualMerge = null, + ?bool $allowMergeCommits = null, + ?bool $allowRebase = null, + ?bool $allowRebaseExplicit = null, + ?bool $allowRebaseUpdate = null, + ?bool $allowSquashMerge = null, + ?bool $archived = null, + ?bool $autodetectManualMerge = null, + ?string $defaultBranch = null, + ?bool $defaultDeleteBranchAfterMerge = null, + ?string $defaultMergeStyle = null, + ?bool $enablePrune = null, + ?object $externalTracker = null, + ?object $externalWiki = null, + ?bool $hasPullRequests = null, + ?bool $ignoreWhitespaceConflicts = null, + ?object $internalTracker = null, + ?string $mirrorInterval = null, + ?bool $template = null + ): ?object + { + // Build the request path. + $path = "/repos/{$owner}/{$repo}"; + + // Set the repository properties to update. + $data = new \stdClass(); + + if ($description !== null) + { + $data->description = $description; + } + + if ($website !== null) + { + $data->website = $website; + } + + if ($private !== null) + { + $data->private = $private; + } + + if ($hasIssues !== null) + { + $data->has_issues = $hasIssues; + } + + if ($hasWiki !== null) + { + $data->has_wiki = $hasWiki; + } + + if ($hasProjects !== null) + { + $data->has_projects = $hasProjects; + } + + // Add the additional properties to update. + if ($allowManualMerge !== null) + { + $data->allow_manual_merge = $allowManualMerge; + } + + if ($allowMergeCommits !== null) + { + $data->allow_merge_commits = $allowMergeCommits; + } + + if ($allowRebase !== null) + { + $data->allow_rebase = $allowRebase; + } + + if ($allowRebaseExplicit !== null) + { + $data->allow_rebase_explicit = $allowRebaseExplicit; + } + + if ($allowRebaseUpdate !== null) + { + $data->allow_rebase_update = $allowRebaseUpdate; + } + + if ($allowSquashMerge !== null) + { + $data->allow_squash_merge = $allowSquashMerge; + } + + if ($archived !== null) + { + $data->archived = $archived; + } + + if ($autodetectManualMerge !== null) + { + $data->autodetect_manual_merge = $autodetectManualMerge; + } + + if ($defaultBranch !== null) + { + $data->default_branch = $defaultBranch; + } + + if ($defaultDeleteBranchAfterMerge !== null) + { + $data->default_delete_branch_after_merge = $defaultDeleteBranchAfterMerge; + } + + if ($defaultMergeStyle !== + null) + { + $data->default_merge_style = $defaultMergeStyle; + } + + if ($enablePrune !== null) + { + $data->enable_prune = $enablePrune; + } + + if ($externalTracker !== null) + { + $data->external_tracker = $externalTracker; + } + + if ($externalWiki !== null) + { + $data->external_wiki = $externalWiki; + } + + if ($hasPullRequests !== null) + { + $data->has_pull_requests = $hasPullRequests; + } + + if ($ignoreWhitespaceConflicts !== null) + { + $data->ignore_whitespace_conflicts = $ignoreWhitespaceConflicts; + } + + if ($internalTracker !== null) + { + $data->internal_tracker = $internalTracker; + } + + if ($mirrorInterval !== null) + { + $data->mirror_interval = $mirrorInterval; + } + + if ($template !== null) + { + $data->template = $template; + } + + // Send the patch request. + return $this->response->get( + $this->http->patch( + $this->uri->get($path), json_encode($data) + ) + ); + } + + /** + * Create a repository. + * + * @param string $name The name of the new repository. + * @param string|null $description Optional. The description of the new repository. + * @param bool|null $private Optional. Set to true if the new repository should be private. + * @param bool|null $autoInit Optional. Set to true to initialize the repository with a README. + * @param string|null $defaultBranch Optional. Default branch of the repository (used when initializes and in template). + * @param string|null $gitignores Optional. The desired .gitignore templates to apply. + * @param string|null $issueLabels Optional. Label-Set to use. + * @param string|null $license Optional. The desired license for the repository. + * @param string|null $readme Optional. Readme of the repository to create. + * @param bool|null $template Optional. Set to true if the repository is a template. + * @param string|null $trustModel Optional. TrustModel of the repository. + * + * @return object|null + * @since 3.2.0 + **/ + public function create( + string $name, + ?string $description = null, + ?bool $private = null, + ?bool $autoInit = null, + ?string $defaultBranch = null, + ?string $gitignores = null, + ?string $issueLabels = null, + ?string $license = null, + ?string $readme = null, + ?bool $template = null, + ?string $trustModel = null + ): ?object { + // Build the request path. + $path = "/user/repos"; + + // Set the repo data. + $data = new \stdClass(); + $data->name = $name; + + if ($description !== null) + { + $data->description = $description; + } + + if ($private !== null) + { + $data->private = $private; + } + + if ($autoInit !== null) + { + $data->auto_init = $autoInit; + } + + if ($defaultBranch !== null) + { + $data->default_branch = $defaultBranch; + } + + if ($gitignores !== null) + { + $data->gitignores = $gitignores; + } + + if ($issueLabels !== null) + { + $data->issue_labels = $issueLabels; + } + + if ($license !== null) + { + $data->license = $license; + } + + if ($readme !== null) + { + $data->readme = $readme; + } + + if ($template !== null) + { + $data->template = $template; + } + + if ($trustModel !== null) + { + $data->trust_model = $trustModel; + } + + // Send the post request. + return $this->response->get( + $this->http->post( + $this->uri->get($path), + json_encode($data) + ), 201 + ); + } + +} + diff --git a/libraries/jcb_powers/VDM.Joomla.Gitea/src/Repository/Archive.php b/libraries/jcb_powers/VDM.Joomla.Gitea/src/Repository/Archive.php new file mode 100644 index 0000000..8cc3499 --- /dev/null +++ b/libraries/jcb_powers/VDM.Joomla.Gitea/src/Repository/Archive.php @@ -0,0 +1,58 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ + +namespace VDM\Joomla\Gitea\Repository; + + +use VDM\Joomla\Gitea\Abstraction\Api; + + +/** + * The Gitea Repository Archive + * + * @since 3.2.0 + */ +class Archive extends Api +{ + /** + * Get an archive of a repository. + * + * @param string $owner The owner name. + * @param string $repo The repository name. + * @param string $archive The archive format, e.g., "zip" or "tar.gz". + * + * @return string + * @since 3.2.0 + **/ + public function get( + string $owner, + string $repo, + string $archive + ): string + { + // Build the request path. + $path = "/repos/{$owner}/{$repo}/archive/{$archive}"; + + // Set the required variables to the URI. + $uri = $this->uri->get($path); + $uri->setVar('owner', $owner); + $uri->setVar('repo', $repo); + $uri->setVar('archive', $archive); + + // Send the get request. + return $this->response->get( + $this->http->get($uri), 200, 'success' + ); + } + + +} + diff --git a/libraries/jcb_powers/VDM.Joomla.Gitea/src/Repository/Assignees.php b/libraries/jcb_powers/VDM.Joomla.Gitea/src/Repository/Assignees.php new file mode 100644 index 0000000..f6c8c75 --- /dev/null +++ b/libraries/jcb_powers/VDM.Joomla.Gitea/src/Repository/Assignees.php @@ -0,0 +1,51 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ + +namespace VDM\Joomla\Gitea\Repository; + + +use VDM\Joomla\Gitea\Abstraction\Api; + + +/** + * The Gitea Repository Assignees + * + * @since 3.2.0 + */ +class Assignees extends Api +{ + /** + * Return all users that have write access and can be assigned to issues. + * + * @param string $owner The owner name. + * @param string $repo The repository name. + * + * @return array|null + * @since 3.2.0 + **/ + public function get(string $owner, string $repo): ?array + { + // Build the request path. + $path = "/repos/{$owner}/{$repo}/assignees"; + + // Set the required variables to the URI. + $uri = $this->uri->get($path); + $uri->setVar('owner', $owner); + $uri->setVar('repo', $repo); + + // Send the get request. + return $this->response->get( + $this->http->get($uri) + ); + } + +} + diff --git a/libraries/jcb_powers/VDM.Joomla.Gitea/src/Repository/Attachments.php b/libraries/jcb_powers/VDM.Joomla.Gitea/src/Repository/Attachments.php new file mode 100644 index 0000000..121da5d --- /dev/null +++ b/libraries/jcb_powers/VDM.Joomla.Gitea/src/Repository/Attachments.php @@ -0,0 +1,196 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ + +namespace VDM\Joomla\Gitea\Repository; + + +use VDM\Joomla\Gitea\Abstraction\Api; + + +/** + * The Gitea Repository Attachments + * + * @since 3.2.0 + */ +class Attachments extends Api +{ + /** + * List release's attachments. + * + * @param string $ownerName The owner name. + * @param string $repoName The repository name. + * @param int $releaseId The release ID. + * + * @return array|null + * @since 3.2.0 + **/ + public function list( + string $ownerName, + string $repoName, + int $releaseId + ): ?array + { + // Build the request path. + $path = "/repos/{$ownerName}/{$repoName}/releases/{$releaseId}/assets"; + + // Retrieve the URI object with the path. + $uri = $this->uri->get($path); + + // Send the get request. + return $this->response->get( + $this->http->get($uri) + ); + } + + /** + * Create a release attachment. + * + * @param string $ownerName The owner name. + * @param string $repoName The repository name. + * @param int $releaseId The release ID. + * @param string $attachmentFile The attachment file content. + * @param string $attachmentName The attachment file name. + * @param string $contentType The attachment content type. + * + * @return object|null + * @since 3.2.0 + **/ + public function create( + string $ownerName, + string $repoName, + int $releaseId, + string $attachmentFile, + string $attachmentName, + string $contentType + ): ?object + { + // Build the request path. + $path = "/repos/{$ownerName}/{$repoName}/releases/{$releaseId}/assets"; + + // Retrieve the URI object with the path. + $uri = $this->uri->get($path); + + // Add the attachment name as a query parameter. + $uri->setVar('name', $attachmentName); + + // Set the request headers. + $headers = [ + "Content-Type: {$contentType}", + "Content-Disposition: attachment; filename={$attachmentName}" + ]; + + // Send the post request. + return $this->response->get( + $this->http->post( + $uri, $attachmentFile, $headers + ), 201 + ); + } + + /** + * Get a release attachment. + * + * @param string $owner The owner name. + * @param string $repo The repository name. + * @param int $id The release ID. + * @param int $attachmentId The attachment ID. + * + * @return object|null + * @since 3.2.0 + **/ + public function get( + string $owner, + string $repo, + int $id, + int $attachmentId + ): ?object + { + // Build the request path. + $path = "/repos/{$owner}/{$repo}/releases/{$id}/assets/{$attachmentId}"; + + // Send the get request. + return $this->response->get( + $this->http->get( + $this->uri->get($path) + ) + ); + } + + /** + * Delete a release attachment. + * + * @param string $owner The owner name. + * @param string $repo The repository name. + * @param int $id The release ID. + * @param int $attachmentId The attachment ID. + * + * @return string + * @since 3.2.0 + **/ + public function delete( + string $owner, + string $repo, + int $id, + int $attachmentId + ): string + { + // Build the request path. + $path = "/repos/{$owner}/{$repo}/releases/{$id}/assets/{$attachmentId}"; + + // Send the delete request. + return $this->response->get( + $this->http->delete( + $this->uri->get($path) + ), 204, 'success' + ); + } + + /** + * Edit a release attachment. + * + * @param string $owner The owner name. + * @param string $repo The repository name. + * @param int $id The release ID. + * @param int $attachmentId The attachment ID. + * @param string|null $name The new name of the attachment (optional). + * + * @return object|null + * @since 3.2.0 + **/ + public function edit( + string $owner, + string $repo, + int $id, + int $attachmentId, + ?string $name = null + ): ?object + { + // Build the request path. + $path = "/repos/{$owner}/{$repo}/releases/{$id}/assets/{$attachmentId}"; + + // Set the attachment data + $data = new \stdClass(); + + if ($name !== null) + { + $data->name = $name; + } + + // Send the patch request. + return $this->response->get( + $this->http->patch( + $this->uri->get($path), json_encode($data) + ) + ); + } + +} + diff --git a/libraries/jcb_powers/VDM.Joomla.Gitea/src/Repository/Branch.php b/libraries/jcb_powers/VDM.Joomla.Gitea/src/Repository/Branch.php new file mode 100644 index 0000000..0936bbe --- /dev/null +++ b/libraries/jcb_powers/VDM.Joomla.Gitea/src/Repository/Branch.php @@ -0,0 +1,148 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ + +namespace VDM\Joomla\Gitea\Repository; + + +use VDM\Joomla\Gitea\Abstraction\Api; + + +/** + * The Gitea Repository Branch + * + * @since 3.2.0 + */ +class Branch extends Api +{ + /** + * List a repository's branches. + * + * @param string $owner The owner name. + * @param string $repo The repository name. + * @param int $page Page number of results to return (1-based). + * @param int $limit Page size of results. + * + * @return array|null + * @since 3.2.0 + **/ + public function list( + string $owner, + string $repo, + int $page = 1, + int $limit = 10 + ): ?array + { + // Build the request path. + $path = "/repos/{$owner}/{$repo}/branches"; + + // Set the required variables to the URI. + $uri = $this->uri->get($path); + $uri->setVar('owner', $owner); + $uri->setVar('repo', $repo); + $uri->setVar('page', $page); + $uri->setVar('limit', $limit); + + // Send the get request. + return $this->response->get( + $this->http->get($uri) + ); + } + + /** + * Create a branch. + * + * @param string $owner The owner name. + * @param string $repo The repository name. + * @param string $branch_name The name of the new branch. + * @param string $old_branch The name of the existing branch from which to create the new branch. + * + * @return object|null + * @since 3.2.0 + **/ + public function create( + string $owner, + string $repo, + string $branch_name, + string $old_branch + ): ?object + { + // Build the request path. + $path = "/repos/{$owner}/{$repo}/branches"; + + // Set the branch data. + $data = new \stdClass(); + $data->branch_name = $branch_name; + $data->old_branch = $old_branch; + + // Send the post request. + return $this->response->get( + $this->http->post( + $this->uri->get($path), json_encode($data) + ), 201 + ); + } + + /** + * Retrieve a specific branch from a repository, including its effective branch protection. + * + * @param string $owner The owner name. + * @param string $repo The repository name. + * @param string $branch The branch name. + * + * @return object|null + * @since 3.2.0 + **/ + public function get(string $owner, string $repo, string $branch): ?object + { + // Build the request path. + $path = "/repos/{$owner}/{$repo}/branches/{$branch}"; + + // Set the required variables to the URI. + $uri = $this->uri->get($path); + $uri->setVar('owner', $owner); + $uri->setVar('repo', $repo); + $uri->setVar('branch', $branch); + + // Send the get request. + return $this->response->get( + $this->http->get($uri) + ); + } + + /** + * Delete a specific branch from a repository. + * + * @param string $owner The owner name. + * @param string $repo The repository name. + * @param string $branch The branch name. + * + * @return string + * @since 3.2.0 + **/ + public function delete( + string $owner, + string $repo, + string $branch + ): string + { + // Build the request path. + $path = "/repos/{$owner}/{$repo}/branches/{$branch}"; + + // Send the delete request. + return $this->response->get( + $this->http->delete( + $this->uri->get($path) + ), 204, 'success' + ); + } + +} + diff --git a/libraries/jcb_powers/VDM.Joomla.Gitea/src/Repository/Branch/Protection.php b/libraries/jcb_powers/VDM.Joomla.Gitea/src/Repository/Branch/Protection.php new file mode 100644 index 0000000..946bce2 --- /dev/null +++ b/libraries/jcb_powers/VDM.Joomla.Gitea/src/Repository/Branch/Protection.php @@ -0,0 +1,380 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ + +namespace VDM\Joomla\Gitea\Repository\Branch; + + +use VDM\Joomla\Gitea\Abstraction\Api; + + +/** + * The Gitea Repository Branch Protection + * + * @since 3.2.0 + */ +class Protection extends Api +{ + /** + * List branch protections for a repository. + * + * @param string $ownerName The owner name. + * @param string $repositoryName The repository name. + * + * @return array|null + * @since 3.2.0 + **/ + public function list(string $ownerName, string $repositoryName): ?array + { + // Build the request path. + $path = "/repos/{$ownerName}/{$repositoryName}/branch_protections"; + + // Get the URI with the path. + $uri = $this->uri->get($path); + + // Send the get request. + return $this->response->get( + $this->http->get($uri) + ); + } + + /** + * Create a branch protection for a repository. + * + * @param string $owner The owner name. + * @param string $repo The repository name. + * @param string $branchName The name of the branch to protect. + * @param array $approvalsWhitelistUsernames An array of usernames that can approve. + * @param array $approvalsWhitelistTeams An array of team names that can approve. + * @param bool $blockOnOfficialReviewRequests Enable/disable blocking on official review requests (optional, default false). + * @param bool $blockOnOutdatedBranch Enable/disable blocking on outdated branch (optional, default false). + * @param bool $blockOnRejectedReviews Enable/disable blocking on rejected reviews (optional, default false). + * @param bool $dismissStaleApprovals Enable/disable dismissing stale approvals (optional, default false). + * @param bool $enableApprovalsWhitelist Enable/disable approvals whitelist (optional, default false). + * @param bool $enableMergeWhitelist Enable/disable merge whitelist (optional, default false). + * @param bool $enablePush Enable/disable push (optional, default true). + * @param bool $enablePushWhitelist Enable/disable push whitelist (optional, default false). + * @param bool $enableStatusCheck Enable/disable status check (optional, default false). + * @param array $mergeWhitelistUsernames An array of usernames that can merge (optional). + * @param array $mergeWhitelistTeams An array of team names that can merge (optional). + * @param string $protectedFilePatterns Protected file patterns (optional). + * @param bool $pushWhitelistDeployKeys Enable/disable push whitelist deploy keys (optional, default false). + * @param array $pushWhitelistUsernames An array of usernames that can push (optional). + * @param array $pushWhitelistTeams An array of team names that can push (optional). + * @param bool $requireSignedCommits Enable/disable requiring signed commits (optional, default false). + * @param int $requiredApprovals Number of required approvals (optional, default 0). + * @param array $statusCheckContexts An array of status check contexts (optional). + * @param string $unprotectedFilePatterns Unprotected file patterns (optional). + * + * @return object|null + * @since 3.2.0 + **/ + public function create( + string $owner, + string $repo, + string $branchName, + array $approvalsWhitelistUsernames, + array $approvalsWhitelistTeams, + bool $blockOnOfficialReviewRequests = false, + bool $blockOnOutdatedBranch = false, + bool $blockOnRejectedReviews = false, + bool $dismissStaleApprovals = false, + bool $enableApprovalsWhitelist = false, + bool $enableMergeWhitelist = false, + bool $enablePush = true, + bool $enablePushWhitelist = false, + bool $enableStatusCheck = false, + array $mergeWhitelistUsernames = [], + array $mergeWhitelistTeams = [], + string $protectedFilePatterns = '', + bool $pushWhitelistDeployKeys = false, + array $pushWhitelistUsernames = [], + array $pushWhitelistTeams = [], + bool $requireSignedCommits = false, + int $requiredApprovals = 0, + array $statusCheckContexts = [], + string $unprotectedFilePatterns = '' + ): ?object + { + // Build the request path. + $path = "/repos/{$owner}/{$repo}/branch_protections"; + + // Set the branch protection data. + $data = new \stdClass(); + $data->branch_name = $branchName; + $data->approvals_whitelist_usernames = $approvalsWhitelistUsernames; + $data->approvals_whitelist_teams = $approvalsWhitelistTeams; + $data->block_on_official_review_requests = $blockOnOfficialReviewRequests; + $data->block_on_outdated_branch = $blockOnOutdatedBranch; + $data->block_on_rejected_reviews = $blockOnRejectedReviews; + $data->dismiss_stale_approvals = $dismissStaleApprovals; + $data->enable_approvals_whitelist = $enableApprovalsWhitelist; + $data->enable_merge_whitelist = $enableMergeWhitelist; + $data->enable_push = $enablePush; + $data->enable_push_whitelist = $enablePushWhitelist; + $data->enable_status_check = $enableStatusCheck; + $data->merge_whitelist_usernames = $mergeWhitelistUsernames; + $data->merge_whitelist_teams = $mergeWhitelistTeams; + $data->protected_file_patterns = $protectedFilePatterns; + $data->push_whitelist_deploy_keys = $pushWhitelistDeployKeys; + $data->push_whitelist_usernames = $pushWhitelistUsernames; + $data->push_whitelist_teams = $pushWhitelistTeams; + $data->require_signed_commits = $requireSignedCommits; + $data->required_approvals = $requiredApprovals; + $data->status_check_contexts = $statusCheckContexts; + $data->unprotected_file_patterns = $unprotectedFilePatterns; + + // Send the post request. + return $this->response->get( + $this->http->post( + $this->uri->get($path), json_encode($data) + ), 201 + ); + } + + /** + * Get a specific branch protection for the repository. + * + * @param string $owner The owner name. + * @param string $repo The repository name. + * @param string $branchName The branch protection name. + * + * @return object|null + * @since 3.2.0 + **/ + public function get( + string $owner, + string $repo, + string $branchName + ): ?object + { + // Build the request path. + $path = "/repos/{$owner}/{$repo}/branch_protections/{$branchName}"; + + // Get the URI object with the given path. + $uri = $this->uri->get($path); + + // Send the get request. + return $this->response->get( + $this->http->get($uri) + ); + } + + /** + * Delete a specific branch protection for the repository. + * + * @param string $ownerName The owner name. + * @param string $repoName The repository name. + * @param string $branchName The branch protection name. + * + * @return string + * @since 3.2.0 + **/ + public function delete( + string $ownerName, + string $repoName, + string $branchName + ): string + { + // Build the request path. + $path = "/repos/{$ownerName}/{$repoName}/branch_protections/{$branchName}"; + + // Set the required variables in the URI. + $this->uri->setVar('owner', $ownerName); + $this->uri->setVar('repo', $repoName); + $this->uri->setVar('name', $branchName); + + // Send the delete request. + return $this->response->get( + $this->http->delete( + $this->uri->get($path) + ), 204, 'success' + ); + } + + /** + * Edit a branch protection for a repository. + * + * @param string $owner The owner name. + * @param string $repo The repository name. + * @param string $name The branch protection name. + * @param array|null $approvalsWhitelistTeams An array of team names that are allowed to approve (optional). + * @param array|null $approvalsWhitelistUsernames An array of usernames that are allowed to approve (optional). + * @param bool|null $blockOnOfficialReviewRequests Block when official review requests are pending (optional). + * @param bool|null $blockOnOutdatedBranch Block when the branch is outdated (optional). + * @param bool|null $blockOnRejectedReviews Block when reviews are rejected (optional). + * @param bool|null $dismissStaleApprovals Dismiss stale approvals when new commits are pushed (optional). + * @param bool|null $enableApprovalsWhitelist Enable/disable approvals whitelist (optional). + * @param bool|null $enableMergeWhitelist Enable/disable merge whitelist (optional). + * @param bool|null $enablePush Enable/disable push (optional). + * @param bool|null $enablePushWhitelist Enable/disable push whitelist (optional). + * @param bool|null $enableStatusCheck Enable/disable status check (optional). + * @param array|null $mergeWhitelistTeams An array of team names that are allowed to merge (optional). + * @param array|null $mergeWhitelistUsernames An array of usernames that are allowed to merge (optional). + * @param string|null $protectedFilePatterns A string pattern for protected files (optional). + * @param bool|null $pushWhitelistDeployKeys Enable/disable push whitelist for deploy keys (optional). + * @param array|null $pushWhitelistTeams An array of team names that are allowed to push (optional). + * @param array|null $pushWhitelistUsernames An array of usernames that are allowed to push (optional). + * @param bool|null $requireSignedCommits Require signed commits (optional). + * @param int|null $requiredApprovals Number of required approvals (optional). + * @param array|null $statusCheckContexts An array of status check contexts (optional). + * @param string|null $unprotectedFilePatterns A string pattern for unprotected files (optional). + * + * @return object|null + * @since 3.2.0 + **/ + public function edit( + string $owner, + string $repo, + string $name, + ?array $approvalsWhitelistTeams = null, + ?array $approvalsWhitelistUsernames = null, + ?bool $blockOnOfficialReviewRequests = null, + ?bool $blockOnOutdatedBranch = null, + ?bool $blockOnRejectedReviews = null, + ?bool $dismissStaleApprovals = null, + ?bool $enableApprovalsWhitelist = null, + ?bool $enableMergeWhitelist = null, + ?bool $enablePush = null, + ?bool $enablePushWhitelist = null, + ?bool $enableStatusCheck = null, + ?array $mergeWhitelistTeams = null, + ?array $mergeWhitelistUsernames = null, + ?string $protectedFilePatterns = null, + ?bool $pushWhitelistDeployKeys = null, + ?array $pushWhitelistTeams = null, + ?array $pushWhitelistUsernames = null, + ?bool $requireSignedCommits = null, + ?int $requiredApprovals = null, + ?array $statusCheckContexts = null, + ?string $unprotectedFilePatterns = null + ): ?object + { + // Build the request path. + $path = "/repos/{$owner}/{$repo}/branch_protections/{$name}"; + + // Set the branch protection data. + $data = new \stdClass(); + + if ($approvalsWhitelistTeams !== null) + { + $data->approvals_whitelist_teams = $approvalsWhitelistTeams; + } + + if ($approvalsWhitelistUsernames !== null) + { + $data->approvals_whitelist_usernames = $approvalsWhitelistUsernames; + } + + if ($blockOnOfficialReviewRequests !== null) + { + $data->block_on_official_review_requests = $blockOnOfficialReviewRequests; + } + + if ($blockOnOutdatedBranch !== null) + { + $data->block_on_outdated_branch = $blockOnOutdatedBranch; + } + + if ($blockOnRejectedReviews !== null) + { + $data->block_on_rejected_reviews = $blockOnRejectedReviews; + } + + if ($dismissStaleApprovals !== null) + { + $data->dismiss_stale_approvals = $dismissStaleApprovals; + } + + if ($enableApprovalsWhitelist !== null) + { + $data->enable_approvals_whitelist = $enableApprovalsWhitelist; + } + + if ($enableMergeWhitelist !== null) + { + $data->enable_merge_whitelist = $enableMergeWhitelist; + } + + if ($enablePush !== null) + { + $data->enable_push = $enablePush; + } + + if ($enablePushWhitelist !== null) + { + $data->enable_push_whitelist = $enablePushWhitelist; + } + + if ($enableStatusCheck !== null) + { + $data->enable_status_check = $enableStatusCheck; + } + + if ($mergeWhitelistTeams !== null) + { + $data->merge_whitelist_teams = $mergeWhitelistTeams; + } + + if ($mergeWhitelistUsernames !== null) + { + $data->merge_whitelist_usernames = $mergeWhitelistUsernames; + } + + if ($protectedFilePatterns !== null) + { + $data->protected_file_patterns = $protectedFilePatterns; + } + + if ($pushWhitelistDeployKeys !== null) + { + $data->push_whitelist_deploy_keys = $pushWhitelistDeployKeys; + } + + if ($pushWhitelistTeams !== null) + { + $data->push_whitelist_teams = $pushWhitelistTeams; + } + + if ($pushWhitelistUsernames !== null) + { + $data->push_whitelist_usernames = $pushWhitelistUsernames; + } + + if ($requireSignedCommits !== null) + { + $data->require_signed_commits = $requireSignedCommits; + } + + if ($requiredApprovals !== null) + { + $data->required_approvals = $requiredApprovals; + } + + if ($statusCheckContexts !== null) + { + $data->status_check_contexts = $statusCheckContexts; + } + + if ($unprotectedFilePatterns !== null) + { + $data->unprotected_file_patterns = $unprotectedFilePatterns; + } + + // Send the patch request. + return $this->response->get( + $this->http->patch( + $this->uri->get($path), json_encode($data) + ) + ); + } + +} + diff --git a/libraries/jcb_powers/VDM.Joomla.Gitea/src/Repository/Branch/index.html b/libraries/jcb_powers/VDM.Joomla.Gitea/src/Repository/Branch/index.html new file mode 100644 index 0000000..fa6d84e --- /dev/null +++ b/libraries/jcb_powers/VDM.Joomla.Gitea/src/Repository/Branch/index.html @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/libraries/jcb_powers/VDM.Joomla.Gitea/src/Repository/Collaborator.php b/libraries/jcb_powers/VDM.Joomla.Gitea/src/Repository/Collaborator.php new file mode 100644 index 0000000..38ee512 --- /dev/null +++ b/libraries/jcb_powers/VDM.Joomla.Gitea/src/Repository/Collaborator.php @@ -0,0 +1,175 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ + +namespace VDM\Joomla\Gitea\Repository; + + +use VDM\Joomla\Gitea\Abstraction\Api; + + +/** + * The Gitea Repository Collaborator + * + * @since 3.2.0 + */ +class Collaborator extends Api +{ + /** + * List a repository's collaborators. + * + * @param string $owner The owner name. + * @param string $repo The repository name. + * @param int $page The page number of results to return (1-based). + * @param int $limit The page size of results. + * + * @return array|null + * @since 3.2.0 + **/ + public function list(string $owner, string $repo, int $page = 1, int $limit = 10): ?array + { + // Build the request path. + $path = "/repos/{$owner}/{$repo}/collaborators"; + + // Get the URI object for the path. + $uri = $this->uri->get($path); + + // Set the page and limit variables. + $uri->setVar('page', $page); + $uri->setVar('limit', $limit); + + // Send the get request. + return $this->response->get( + $this->http->get($uri) + ); + } + + /** + * Check if a user is a collaborator of a repository. + * + * @param string $owner The owner name. + * @param string $repo The repository name. + * @param string $collaborator The collaborator username. + * + * @return string + * @since 3.2.0 + **/ + public function check( + string $owner, + string $repo, + string $collaborator + ): string + { + // Build the request path. + $path = "/repos/{$owner}/{$repo}/collaborators/{$collaborator}"; + + // Get the URI object for the path. + $uri = $this->uri->get($path); + + // Send the get request. + return $this->response->get( + $this->http->get($uri), 204, 'success' + ); + } + + /** + * Add a collaborator to a repository. + * + * @param string $owner The owner name. + * @param string $repo The repository name. + * @param string $collaborator The collaborator username. + * @param string $permission The permission level for the collaborator (optional). + * + * @return string + * @since 3.2.0 + **/ + public function add( + string $owner, + string $repo, + string $collaborator, + string $permission = null + ): string + { + // Build the request path. + $path = "/repos/{$owner}/{$repo}/collaborators/{$collaborator}"; + + // Get the URI object for the path. + $uri = $this->uri->get($path); + + // Prepare the request body. + $body = new stdClass(); + if ($permission !== null) { + $body->permission = $permission; + } + $bodyJson = json_encode($body); + + // Send the put request. + return $this->response->get( + $this->http->put($uri, $bodyJson), 204, 'success' + ); + } + + /** + * Delete a collaborator from a repository. + * + * @param string $owner The owner name. + * @param string $repo The repository name. + * @param string $collaborator The collaborator username. + * + * @return string + * @since 3.2.0 + **/ + public function delete( + string $owner, + string $repo, + string $collaborator + ): string + { + // Build the request path. + $path = "/repos/{$owner}/{$repo}/collaborators/{$collaborator}"; + + // Send the delete request. + return $this->response->get( + $this->http->delete( + $this->uri->get($path) + ), 204, 'success' + ); + } + + /** + * Get repository permissions for a user. + * + * @param string $owner The owner name. + * @param string $repo The repository name. + * @param string $collaborator The collaborator username. + * + * @return object|null + * @since 3.2.0 + **/ + public function permission( + string $owner, + string $repo, + string $collaborator + ): ?object + { + // Build the request path. + $path = "/repos/{$owner}/{$repo}/collaborators/{$collaborator}/permission"; + + // Get the URI object for the path. + $uri = $this->uri->get($path); + + // Send the get request. + return $this->response->get( + $this->http->get($uri) + ); + } + +} + diff --git a/libraries/jcb_powers/VDM.Joomla.Gitea/src/Repository/Commits.php b/libraries/jcb_powers/VDM.Joomla.Gitea/src/Repository/Commits.php new file mode 100644 index 0000000..d8142c2 --- /dev/null +++ b/libraries/jcb_powers/VDM.Joomla.Gitea/src/Repository/Commits.php @@ -0,0 +1,225 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ + +namespace VDM\Joomla\Gitea\Repository; + + +use VDM\Joomla\Gitea\Abstraction\Api; + + +/** + * The Gitea Repository Commit + * + * @since 3.2.0 + */ +class Commits extends Api +{ + /** + * Get a list of all commits from a repository. + * + * @param string $owner The owner of the repo. + * @param string $repo The name of the repo. + * @param string|null $sha SHA or branch to start listing commits from (usually 'master'). + * @param string|null $path Filepath of a file/dir. + * @param bool|null $stat Include diff stats for every commit (disable for speedup, default 'true'). + * @param int|null $page Page number of results to return (1-based). + * @param int|null $limit Page size of results (ignored if used with 'path'). + * + * @return array|null + * @since 3.2.0 + */ + public function getList( + string $owner, + string $repo, + ?string $sha = null, + ?string $path = null, + ?bool $stat = true, + ?int $page = 1, + ?int $limit = 10 + ): ?object + { + // Build the request path. + $uriPath = "/repos/{$owner}/{$repo}/commits"; + + // Set query parameters. + $uri = $this->uri->get($uriPath); + + if ($sha !== null) + { + $uri->setVar('sha', $sha); + } + + if ($path !== null) + { + $uri->setVar('path', $path); + } + + if ($stat !== null) + { + $uri->setVar('stat', $stat ? 'true' : 'false'); + } + + if ($page !== null) + { + $uri->setVar('page', $page); + } + + if ($limit !== null) + { + $uri->setVar('limit', $limit); + } + + // Send the GET request. + return $this->response->get( + $this->http->get($uri) + ); + } + + /** + * Get a single commit from a repository. + * + * @param string $owner The owner of the repo. + * @param string $repo The name of the repo. + * @param string $sha A git ref or commit sha. + * + * @return object|null + * @since 3.2.0 + */ + public function getCommit(string $owner, string $repo, string $sha): ?object + { + // Build the request path. + $uriPath = "/repos/{$owner}/{$repo}/git/commits/{$sha}"; + + // Send the GET request. + return $this->response->get( + $this->http->get( + $this->uri->get($uriPath) + ) + ); + } + + /** + * Get a commit's combined status, by branch/tag/commit reference. + * + * @param string $owner The owner name. + * @param string $repo The repository name. + * @param string $ref The branch, tag, or commit reference. + * @param int $page Page number of results to return (1-based). + * @param int $limit Page size of results. + * + * @return object|null + * @since 3.2.0 + **/ + public function status( + string $owner, + string $repo, + string $ref, + int $page = 1, + int $limit = 10 + ): ?object + { + // Build the request path. + $path = "/repos/{$owner}/{$repo}/commits/{$ref}/status"; + + // Set up the URI with the required parameters. + $uri = $this->uri->get($path); + $uri->setVar('page', $page); + $uri->setVar('limit', $limit); + + // Send the get request. + return $this->response->get( + $this->http->get($uri) + ); + } + + /** + * Get a commit's statuses, by branch/tag/commit reference. + * + * @param string $owner The owner of the repository. + * @param string $repo The name of the repository. + * @param string $ref The branch, tag, or commit reference. + * @param string $sort The type of sort. Available values: oldest, recentupdate, leastupdate, leastindex, highestindex. + * @param string $state The type of state. Available values: pending, success, error, failure, warning. + * @param int $page The page number of results to return (1-based). Default value: 1. + * @param int $limit The page size of results. Default value: 10. + * + * @return array|null + * @since 3.2.0 + */ + public function statuses( + string $owner, + string $repo, + string $ref, + string $sort = null, + string $state = null, + int $page = 1, + int $limit = 10 + ): ?array + { + // Build the request path. + $path = "/repos/{$owner}/{$repo}/commits/{$ref}/statuses"; + + // Add query parameters to the URI. + $uri = $this->uri->get($path); + + if ($sort !== null) + { + $uri->setVar('sort', $sort); + } + + if ($state !== null) + { + $uri->setVar('state', $state); + } + + $uri->setVar('page', $page); + $uri->setVar('limit', $limit); + + // Send the GET request. + $response = $this->http->get($uri); + return $this->response->get($response); + } + + /** + * Get a commit's diff or patch. + * + * @param string $owner The owner name. + * @param string $repo The repository name. + * @param string $sha The SHA hash of the commit. + * @param string $diffType The diff type, either 'diff' or 'patch'. + * + * @return string + * @since 3.2.0 + **/ + public function diff( + string $owner, + string $repo, + string $sha, + string $diffType + ): string + { + // Build the request path. + $path = "/repos/{$owner}/{$repo}/git/commits/{$sha}"; + + // Set the diffType as a variable in the URI. + $this->uri->setVar('diffType', $diffType); + + // Send the get request. + return $this->response->get( + $this->http->get( + $this->uri->get($path) + ) + ); + } + + +} + diff --git a/libraries/jcb_powers/VDM.Joomla.Gitea/src/Repository/Contents.php b/libraries/jcb_powers/VDM.Joomla.Gitea/src/Repository/Contents.php new file mode 100644 index 0000000..982403c --- /dev/null +++ b/libraries/jcb_powers/VDM.Joomla.Gitea/src/Repository/Contents.php @@ -0,0 +1,509 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ + +namespace VDM\Joomla\Gitea\Repository; + + +use VDM\Joomla\Gitea\Abstraction\Api; + + +/** + * The Gitea Repository Contents + * + * @since 3.2.0 + */ +class Contents extends Api +{ + /** + * Get a file from a repository. + * + * @param string $owner The owner name. + * @param string $repo The repository name. + * @param string $filepath The file path. + * @param string|null $ref Optional. The name of the commit/branch/tag. + * Default the repository's default branch (usually master). + * + * @return mixed + * @since 3.2.0 + **/ + public function get(string $owner, string $repo, string $filepath, ?string $ref = null) + { + // Build the request path. + $path = "/repos/{$owner}/{$repo}/raw/{$filepath}"; + + // Get the URI with the specified path. + $uri = $this->uri->get($path); + + // Add the ref parameter if provided. + if ($ref !== null) + { + $uri->setVar('ref', $ref); + } + + // Send the get request. + return $this->response->get( + $this->http->get($uri) + ); + } + + /** + * Get the metadata and contents (if a file) of an entry in a repository, + * or a list of entries if a directory. + * + * @param string $owner The owner name. + * @param string $repo The repository name. + * @param string $filepath The file or directory path. + * @param string|null $ref Optional. The name of the commit/branch/tag. + * Default the repository's default branch (usually master). + * + * @return object|null + * @since 3.2.0 + **/ + public function metadata(string $owner, string $repo, string $filepath, ?string $ref = null): ?object + { + // Build the request path. + $path = "/repos/{$owner}/{$repo}/contents/{$filepath}"; + + // Get the URI with the specified path. + $uri = $this->uri->get($path); + + // Add the ref parameter if provided. + if ($ref !== null) + { + $uri->setVar('ref', $ref); + } + + // Send the get request. + return $this->response->get( + $this->http->get($uri) + ); + } + + /** + * Create a file in a repository. + * + * @param string $owner The owner name. + * @param string $repo The repository name. + * @param string $filepath The file path. + * @param string $content The file content. + * @param string $message The commit message. + * @param string $branch The branch name. Defaults to the repository's default branch. + * @param string|null $authorName The author's name. + * @param string|null $authorEmail The author's email. + * @param string|null $committerName The committer's name. + * @param string|null $committerEmail The committer's email. + * @param bool|null $newBranch Whether to create a new branch. Defaults to false. + * @param string|null $authorDate The author's date. + * @param string|null $committerDate The committer's date. + * @param bool|null $signoff Add a Signed-off-by trailer. Defaults to null. + * + * @return object|null + * @since 3.2.0 + **/ + public function create( + string $owner, + string $repo, + string $filepath, + string $content, + string $message, + string $branch = 'master', + ?string $authorName = null, + ?string $authorEmail = null, + ?string $committerName = null, + ?string $committerEmail = null, + ?bool $newBranch = false, + ?string $authorDate = null, + ?string $committerDate = null, + ?bool $signoff = null + ): ?object { + // Build the request path. + $path = "/repos/{$owner}/{$repo}/contents/{$filepath}"; + + // Set the post data + $data = new \stdClass(); + $data->content = base64_encode($content); + $data->message = $message; + $data->branch = $branch; + + if ($authorName !== null || $authorEmail !== null) + { + $data->author = new \stdClass(); + if ($authorName !== null) + { + $data->author->name = $authorName; + } + if ($authorEmail !== null) + { + $data->author->email = $authorEmail; + } + } + + if ($committerName !== null || $committerEmail !== null) + { + $data->committer = new \stdClass(); + if ($committerName !== null) + { + $data->committer->name = $committerName; + } + if ($committerEmail !== null) + { + $data->committer->email = $committerEmail; + } + } + + if ($newBranch !== null) + { + $data->new_branch = $newBranch; + } + + if ($authorDate !== null || $committerDate !== null) + { + $data->dates = new \stdClass(); + if ($authorDate !== null) + { + $data->dates->author = $authorDate; + } + if ($committerDate !== null) + { + $data->dates->committer = $committerDate; + } + } + + if ($signoff !== null) + { + $data->signoff = $signoff; + } + + // Send the post request. + return $this->response->get( + $this->http->post( + $this->uri->get($path), json_encode($data) + ), 201 + ); + } + + /** + * Get the metadata of all the entries of the root directory. + * + * @param string $owner The owner name. + * @param string $repo The repository name. + * @param string|null $ref The name of the commit/branch/tag. Default the repository's default branch (usually master). + * + * @return array|null + * @since 3.2.0 + **/ + public function root(string $owner, string $repo, ?string $ref = null): ?array + { + // Build the request path. + $path = "/repos/{$owner}/{$repo}/contents"; + + // Add the 'ref' parameter if it's provided. + if ($ref !== null) + { + $this->uri->setVar('ref', $ref); + } + + // Send the get request. + return $this->response->get( + $this->http->get( + $this->uri->get($path) + ) + ); + } + + /** + * Update a file in a repository. + * + * @param string $owner The owner name. + * @param string $repo The repository name. + * @param string $filepath The file path. + * @param string $content The file content. + * @param string $message The commit message. + * @param string $branch The branch name. Defaults to the repository's default branch. + * @param string $sha The blob SHA of the file. + * @param string|null $authorName The author name. Defaults to the authenticated user. + * @param string|null $authorEmail The author email. Defaults to the authenticated user. + * @param string|null $committerName The committer name. Defaults to the authenticated user. + * @param string|null $committerEmail The committer email. Defaults to the authenticated user. + * @param string|null $authorDate The author date. + * @param string|null $committerDate The committer date. + * @param string|null $fromPath The original file path to move/rename. + * @param string|null $newBranch The new branch to create from the specified branch. + * @param bool|null $signoff Add a Signed-off-by trailer. + * + * @return object|null + * @since 3.2.0 + **/ + public function update( + string $owner, + string $repo, + string $filepath, + string $content, + string $message, + string $branch = 'master', + string $sha, + ?string $authorName = null, + ?string $authorEmail = null, + ?string $committerName = null, + ?string $committerEmail = null, + ?string $authorDate = null, + ?string $committerDate = null, + ?string $fromPath = null, + ?string $newBranch = null, + ?bool $signoff = null + ): ?object { + // Build the request path. + $path = "/repos/{$owner}/{$repo}/contents/{$filepath}"; + + // Set the file data. + $data = new \stdClass(); + $data->content = base64_encode($content); + $data->message = $message; + $data->branch = $branch; + $data->sha = $sha; + + if ($authorName !== null || $authorEmail !== null) + { + $data->author = new \stdClass(); + + if ($authorName !== null) + { + $data->author->name = $authorName; + } + + if ($authorEmail !== null) + { + $data->author->email = $authorEmail; + } + } + + if ($committerName !== null || $committerEmail !== null) + { + $data->committer = new \stdClass(); + + if ($committerName !== null) + { + $data->committer->name = $committerName; + } + + if ($committerEmail !== null) + { + $data->committer->email = $committerEmail; + } + } + + if ($authorDate !== null || $committerDate !== null) + { + $data->dates = new \stdClass(); + + if ($authorDate !== null) + { + $data->dates->author = $authorDate; + } + + if ($committerDate !== null) + { + $data->dates->committer = $committerDate; + } + } + + if ($fromPath !== null) + { + $data->from_path = $fromPath; + } + + if ($newBranch !== null) + { + $data->new_branch = $newBranch; + } + + if ($signoff !== null) + { + $data->signoff = $signoff; + } + + // Send the put request. + return $this->response->get( + $this->http->put( + $this->uri->get($path), + json_encode($data) + ) + ); + } + + /** + * Delete a file in a repository. + * + * @param string $owner The owner name. + * @param string $repo The repository name. + * @param string $filepath The file path. + * @param string $message The commit message. + * @param string $branch The branch name (optional). + * @param string $sha The blob SHA of the file. + * @param string $authorName The author name (optional). + * @param string $authorEmail The author email (optional). + * @param string $committerName The committer name (optional). + * @param string $committerEmail The committer email (optional). + * @param string $authorDate The author date (optional). + * @param string $committerDate The committer date (optional). + * @param string $newBranch The new branch name (optional). + * @param bool $signoff Add a Signed-off-by trailer (optional). + * + * @return object|null + * @since 3.2.0 + **/ + public function delete( + string $owner, + string $repo, + string $filepath, + string $message, + string $sha, + ?string $branch = null, + ?string $authorName = null, + ?string $authorEmail = null, + ?string $committerName = null, + ?string $committerEmail = null, + ?string $authorDate = null, + ?string $committerDate = null, + ?string $newBranch = null, + ?bool $signoff = null + ): ?object { + // Build the request path. + $path = "/repos/{$owner}/{$repo}/contents/{$filepath}"; + + // Set the file data. + $data = new \stdClass(); + $data->message = $message; + $data->sha = $sha; + + if ($branch !== null) { + $data->branch = $branch; + } + + if ($authorName !== null || $authorEmail !== null) + { + $data->author = new \stdClass(); + + if ($authorName !== null) + { + $data->author->name = $authorName; + } + + if ($authorEmail !== null) + { + $data->author->email = $authorEmail; + } + } + + if ($committerName !== null || $committerEmail !== null) + { + $data->committer = new \stdClass(); + + if ($committerName !== null) + { + $data->committer->name = $committerName; + } + + if ($committerEmail !== null) + { + $data->committer->email = $committerEmail; + } + } + + if ($authorDate !== null || $committerDate !== null) + { + $data->dates = new \stdClass(); + + if ($authorDate !== null) + { + $data->dates->author = $authorDate; + } + + if ($committerDate !== null) + { + $data->dates->committer = $committerDate; + } + } + + if ($newBranch !== null) + { + $data->new_branch = $newBranch; + } + + if ($signoff !== null) + { + $data->signoff = $signoff; + } + + // Send the delete request. + return $this->response->get( + $this->http->delete( + $this->uri->get($path), + json_encode($data) + ) + ); + } + + /** + * Get the EditorConfig definitions of a file in a repository. + * + * @param string $owner The owner name. + * @param string $repo The repository name. + * @param string $filepath The file path. + * @param string $ref The name of the commit/branch/tag. + * + * @return string|null + * @since 3.2.0 + **/ + public function editor(string $owner, string $repo, string $filepath, string $ref = null): ?string + { + // Build the request path. + $path = "/repos/{$owner}/{$repo}/editorconfig/{$filepath}"; + + // Set the request parameters. + $uri = $this->uri->get($path); + + if ($ref !== null) + { + $uri->setVar('ref', $ref); + } + + // Send the get request. + return $this->response->get( + $this->http->get($uri) + ); + } + + /** + * Get the blob of a repository. + * + * @param string $owner The owner name. + * @param string $repo The repository name. + * @param string $sha The SHA hash of the blob. + * + * @return object|null + * @since 3.2.0 + **/ + public function blob(string $owner, string $repo, string $sha): ?object + { + // Build the request path. + $path = "/repos/{$owner}/{$repo}/git/blobs/{$sha}"; + + // Send the get request. + return $this->response->get( + $this->http->get( + $this->uri->get($path) + ) + ); + } + +} + diff --git a/libraries/jcb_powers/VDM.Joomla.Gitea/src/Repository/Forks.php b/libraries/jcb_powers/VDM.Joomla.Gitea/src/Repository/Forks.php new file mode 100644 index 0000000..224e286 --- /dev/null +++ b/libraries/jcb_powers/VDM.Joomla.Gitea/src/Repository/Forks.php @@ -0,0 +1,102 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ + +namespace VDM\Joomla\Gitea\Repository; + + +use VDM\Joomla\Gitea\Abstraction\Api; + + +/** + * The Gitea Repository Forks + * + * @since 3.2.0 + */ +class Forks extends Api +{ + /** + * List a repository's forks. + * + * @param string $owner The owner of the repo. + * @param string $repo The name of the repo. + * @param int $page The page number of results to return (1-based). + * @param int $limit The page size of results. + * + * @return array|null + * @since 3.2.0 + */ + public function listForks( + string $owner, + string $repo, + int $page = 1, + int $limit = 10 + ): ?array + { + // Build the request path. + $uriPath = "/repos/{$owner}/{$repo}/forks"; + + // Set the query parameters. + $uri = $this->uri->get($uriPath); + $uri->setVar('page', $page); + $uri->setVar('limit', $limit); + + // Send the get request. + return $this->response->get( + $this->http->get($uri) + ); + } + + /** + * Fork a repository. + * + * @param string $owner The owner name. + * @param string $repo The repository name. + * @param string $forkName The name of the forked repository (optional). + * @param string $organization The organization name (optional). + * + * @return object|null + * @since 3.2.0 + **/ + public function repo( + string $owner, + string $repo, + string $forkName = '', + string $organization = '' + ): ?object + { + // Build the request path. + $path = "/repos/{$owner}/{$repo}/forks"; + + // Set the fork data. + $data = new \stdClass(); + + if (!empty($forkName)) + { + $data->name = $forkName; + } + + if (!empty($organization)) + { + $data->organization = $organization; + } + + // Send the post request. + return $this->response->get( + $this->http->post( + $this->uri->get($path), + json_encode($data) + ), 202 + ); + } + + +} + diff --git a/libraries/jcb_powers/VDM.Joomla.Gitea/src/Repository/Gpg.php b/libraries/jcb_powers/VDM.Joomla.Gitea/src/Repository/Gpg.php new file mode 100644 index 0000000..0a6c317 --- /dev/null +++ b/libraries/jcb_powers/VDM.Joomla.Gitea/src/Repository/Gpg.php @@ -0,0 +1,48 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ + +namespace VDM\Joomla\Gitea\Repository; + + +use VDM\Joomla\Gitea\Abstraction\Api; + + +/** + * The Gitea Repository Gpg + * + * @since 3.2.0 + */ +class Gpg extends Api +{ + /** + * Get signing-key.gpg for a given repository. + * + * @param string $ownerName The owner name. + * @param string $repoName The repository name. + * + * @return string + * @since 3.2.0 + **/ + public function get(string $ownerName, string $repoName): string + { + // Build the request path. + $path = "/repos/{$ownerName}/{$repoName}/signing-key.gpg"; + + // Send the get request. + return $this->response->get( + $this->http->get( + $this->uri->get($path) + ) + ); + } + +} + diff --git a/libraries/jcb_powers/VDM.Joomla.Gitea/src/Repository/Hooks.php b/libraries/jcb_powers/VDM.Joomla.Gitea/src/Repository/Hooks.php new file mode 100644 index 0000000..eadb2e6 --- /dev/null +++ b/libraries/jcb_powers/VDM.Joomla.Gitea/src/Repository/Hooks.php @@ -0,0 +1,214 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ + +namespace VDM\Joomla\Gitea\Repository; + + +use VDM\Joomla\Gitea\Abstraction\Api; + + +/** + * The Gitea Repository Hooks + * + * @since 3.2.0 + */ +class Hooks extends Api +{ + /** + * List the hooks in a repository. + * + * @param string $owner The owner name. + * @param string $repo The repository name. + * @param int $page The page number of results to return (1-based). + * @param int $limit The page size of results. + * + * @return array|null + * @since 3.2.0 + **/ + public function list( + string $owner, + string $repo, + int $page = 1, + int $limit = 10 + ): ?array + { + // Build the request path. + $path = "/repos/{$owner}/{$repo}/hooks"; + + // Set up the URI with query parameters. + $uri = $this->uri->get($path); + $uri->setVar('page', $page); + $uri->setVar('limit', $limit); + + // Send the get request. + return $this->response->get( + $this->http->get($uri) + ); + } + + /** + * Create a hook in a repository. + * + * @param string $owner The owner name. + * @param string $repo The repository name. + * @param string $type The hook type. + * @param array $config The hook configuration. + * @param bool $active The hook's active status (optional, default: false). + * @param array|null $events The events for the hook (optional). + * @param string $branchFilter The branch filter (optional). + * + * @return object|null + * @since 3.2.0 + **/ + public function create( + string $owner, + string $repo, + string $type, + array $config, + string $type, + array $config, + bool $active = false, + ?array $events = null, + string $branchFilter = '' + ): ?object + { + // Build the request path. + $path = "/repos/{$owner}/{$repo}/hooks"; + + // Set the hook data. + $data = new \stdClass(); + $data->type = $type; + $data->config = (object) $config; + $data->active = $active; + + if ($events !== null) + { + $data->events = $events; + } + + if (!empty($branchFilter)) + { + $data->branch_filter = $branchFilter; + } + + // Send the request. + return $this->response->get( + $this->http->post( + $this->uri->get($path), json_encode($data) + ), 201 + ); + } + + /** + * Get a hook. + * + * @param string $owner The owner name. + * @param string $repo The repository name. + * @param int $hookId The hook ID. + * + * @return object|null + * @since 3.2.0 + **/ + public function get( + string $owner, + string $repo, + int $hookId + ): ?object + { + // Build the request path. + $path = "/repos/{$owner}/{$repo}/hooks/{$hookId}"; + + // Get the URI for the request path. + $uri = $this->uri->get($path); + + // Send the get request. + return $this->response->get( + $this->http->get($uri) + ); + } + + /** + * Edit a hook in a repository. + * + * @param string $owner The owner name. + * @param string $repo The repository name. + * @param int $id The hook ID. + * @param array $config The hook configuration. + * @param array $events The events to trigger the hook. + * @param bool $active Whether the hook is active. + * + * @return object|null + * @since 3.2.0 + **/ + public function edit( + string $owner, + string $repo, + int $id, + array $config, + array $events, + bool $active + ): ?object + { + // Build the request path. + $path = "/repos/{$owner}/{$repo}/hooks/{$id}"; + + // Set the hook data. + $data = new \stdClass(); + $data->config = $config; + $data->events = $events; + $data->active = $active; + + // Send the PATCH request. + return $this->response->get( + $this->http->patch( + $this->uri->get($path), + json_encode($data) + ) + ); + } + + /** + * Test a push webhook. + * + * @param string $owner The owner name. + * @param string $repo The repository name. + * @param int $hookId The hook ID. + * @param string $ref The name of the commit/branch/tag (optional). + * + * @return string + * @since 3.2.0 + **/ + public function test( + string $owner, + string $repo, + int $hookId, + string $ref = '' + ): string + { + // Build the request path. + $path = "/repos/{$owner}/{$repo}/hooks/{$hookId}/tests"; + + // Get the URI for the request path. + $uri = $this->uri->get($path); + + if (!empty($ref)) + { + $uri->setVar('ref', $ref); + } + + // Send the POST request. + return $this->response->get( + $this->http->post($uri), 204, 'success' + ); + } + +} + diff --git a/libraries/jcb_powers/VDM.Joomla.Gitea/src/Repository/Hooks/Git.php b/libraries/jcb_powers/VDM.Joomla.Gitea/src/Repository/Hooks/Git.php new file mode 100644 index 0000000..0b0a849 --- /dev/null +++ b/libraries/jcb_powers/VDM.Joomla.Gitea/src/Repository/Hooks/Git.php @@ -0,0 +1,137 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ + +namespace VDM\Joomla\Gitea\Repository\Hooks; + + +use VDM\Joomla\Gitea\Abstraction\Api; + + +/** + * The Gitea Repository Hooks Git + * + * @since 3.2.0 + */ +class Git extends Api +{ + /** + * List the Git hooks in a repository. + * + * @param string $ownerName The owner name. + * @param string $repoName The repository name. + * + * @return array|null + * @since 3.2.0 + **/ + public function list(string $ownerName, string $repoName): ?array + { + // Build the request path. + $path = "/repos/{$ownerName}/{$repoName}/hooks/git"; + + // Get the URI object with the path. + $uri = $this->uri->get($path); + + // Send the get request. + return $this->response->get( + $this->http->get($uri) + ); + } + + /** + * Get a Git hook. + * + * @param string $ownerName The owner name. + * @param string $repoName The repository name. + * @param int $hookId The Git hook ID. + * + * @return object|null + * @since 3.2.0 + **/ + public function get( + string $ownerName, + string $repoName, + int $hookId + ): ?object + { + // Build the request path. + $path = "/repos/{$ownerName}/{$repoName}/hooks/git/{$hookId}"; + + // Get the URI object with the path. + $uri = $this->uri->get($path); + + // Send the get request. + return $this->response->get( + $this->http->get($uri) + ); + } + + /** + * Delete a Git hook in a repository. + * + * @param string $ownerName The owner name. + * @param string $repositoryName The repository name. + * @param string $hookId The Git hook ID. + * + * @return string + * @since 3.2.0 + **/ + public function delete( + string $ownerName, + string $repositoryName, + string $hookId + ): string + { + // Build the request path. + $path = "/repos/{$ownerName}/{$repositoryName}/hooks/git/{$hookId}"; + + // Send the delete request. + return $this->response->get( + $this->http->delete( + $this->uri->get($path) + ), 204, 'success' + ); + } + + /** + * Edit a Git hook in a repository. + * + * @param string $owner The owner name. + * @param string $repo The repository name. + * @param string $hookId The Git hook ID. + * @param array $hookOptions The hook configuration. + * + * @return object|null + * @since 3.2.0 + **/ + public function edit( + string $owner, + string $repo, + string $hookId, + array $hookOptions + ): ?object + { + // Build the request path. + $path = "/repos/{$owner}/{$repo}/hooks/git/{$hookId}"; + + // Set the hook data. + $data = new \stdClass(); + $data->config = (object) $hookOptions; + + // Send the PATCH request. + return $this->response->get( + $this->http->patch( + $this->uri->get($path), json_encode($data) + ) + ); + } + +} + diff --git a/libraries/jcb_powers/VDM.Joomla.Gitea/src/Repository/Hooks/index.html b/libraries/jcb_powers/VDM.Joomla.Gitea/src/Repository/Hooks/index.html new file mode 100644 index 0000000..fa6d84e --- /dev/null +++ b/libraries/jcb_powers/VDM.Joomla.Gitea/src/Repository/Hooks/index.html @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/libraries/jcb_powers/VDM.Joomla.Gitea/src/Repository/Keys.php b/libraries/jcb_powers/VDM.Joomla.Gitea/src/Repository/Keys.php new file mode 100644 index 0000000..5e7757f --- /dev/null +++ b/libraries/jcb_powers/VDM.Joomla.Gitea/src/Repository/Keys.php @@ -0,0 +1,159 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ + +namespace VDM\Joomla\Gitea\Repository; + + +use VDM\Joomla\Gitea\Abstraction\Api; + + +/** + * The Gitea Repository Keys + * + * @since 3.2.0 + */ +class Keys extends Api +{ + /** + * List a repository's keys. + * + * @param string $owner The owner name. + * @param string $repo The repository name. + * @param int|null $keyId The key_id to search for. (Optional) + * @param string|null $fingerprint The fingerprint of the key. (Optional) + * @param int $page The page number of results to return. (Default: 1) + * @param int $limit The page size of results. (Default: 10) + * + * @return array|null + * @since 3.2.0 + */ + public function list(string $owner, string $repo, ?int $keyId = null, ?string $fingerprint = null, int $page = 1, int $limit = 10): ?array + { + // Build the request path. + $path = "/repos/{$owner}/{$repo}/keys"; + + // Prepare the URI. + $uri = $this->uri->get($path); + + // Add the optional query parameters. + if ($keyId !== null) + { + $uri->setVar('key_id', $keyId); + } + + if ($fingerprint !== null) + { + $uri->setVar('fingerprint', $fingerprint); + } + + $uri->setVar('page', $page); + $uri->setVar('limit', $limit); + + // Send the GET request. + return $this->response->get( + $this->http->get($uri) + ); + } + + /** + * Add a key to a repository. + * + * @param string $owner The owner name. + * @param string $repo The repository name. + * @param string $key The public key. + * @param string $title The title of the key. + * @param bool $readOnly Whether the key is read-only. + * + * @return object|null + * @since 3.2.0 + **/ + public function add( + string $owner, + string $repo, + string $key, + string $title, + bool $readOnly + ): ?object + { + // Build the request path. + $path = "/repos/{$owner}/{$repo}/keys"; + + // Set the key data. + $data = new \stdClass(); + $data->key = $key; + $data->title = $title; + $data->read_only = $readOnly; + + // Send the POST request. + return $this->response->get( + $this->http->post( + $this->uri->get($path), + json_encode($data) + ), 201 + ); + } + + /** + * Get a repository's key by id. + * + * @param string $owner The owner name. + * @param string $repo The repository name. + * @param int $id The key ID. + * + * @return object|null + * @since 3.2.0 + */ + public function id( + string $owner, + string $repo, + int $id + ): ?object + { + // Build the request path. + $path = "/repos/{$owner}/{$repo}/keys/{$id}"; + + // Send the GET request. + return $this->response->get( + $this->http->get( + $this->uri->get($path) + ) + ); + } + + /** + * Delete a key from a repository. + * + * @param string $owner The owner name. + * @param string $repo The repository name. + * @param int $id The key ID. + * + * @return string + * @since 3.2.0 + **/ + public function delete( + string $owner, + string $repo, + int $id + ): string + { + // Build the request path. + $path = "/repos/{$owner}/{$repo}/keys/{$id}"; + + // Send the DELETE request. + return $this->response->get( + $this->http->delete( + $this->uri->get($path) + ), 204, 'success' + ); + } + +} + diff --git a/libraries/jcb_powers/VDM.Joomla.Gitea/src/Repository/Languages.php b/libraries/jcb_powers/VDM.Joomla.Gitea/src/Repository/Languages.php new file mode 100644 index 0000000..e4f4f0e --- /dev/null +++ b/libraries/jcb_powers/VDM.Joomla.Gitea/src/Repository/Languages.php @@ -0,0 +1,49 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ + +namespace VDM\Joomla\Gitea\Repository; + + +use VDM\Joomla\Gitea\Abstraction\Api; + + +/** + * The Gitea Repository Languages + * + * @since 3.2.0 + */ +class Languages extends Api +{ + /** + * Get languages and number of bytes of code written in a repository. + * + * @param string $owner The owner name. + * @param string $repo The repository name. + * + * @return object|null + * @since 3.2.0 + **/ + public function getLanguages(string $owner, string $repo): ?object + { + // Build the request path. + $path = "/repos/{$owner}/{$repo}/languages"; + + // Build the URI. + $uri = $this->uri->get($path); + + // Send the GET request. + return $this->response->get( + $this->http->get($uri) + ); + } + +} + diff --git a/libraries/jcb_powers/VDM.Joomla.Gitea/src/Repository/Media.php b/libraries/jcb_powers/VDM.Joomla.Gitea/src/Repository/Media.php new file mode 100644 index 0000000..74ea839 --- /dev/null +++ b/libraries/jcb_powers/VDM.Joomla.Gitea/src/Repository/Media.php @@ -0,0 +1,63 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ + +namespace VDM\Joomla\Gitea\Repository; + + +use VDM\Joomla\Gitea\Abstraction\Api; + + +/** + * The Gitea Repository Media + * + * @since 3.2.0 + */ +class Media extends Api +{ + /** + * Get a file or its LFS object from a repository. + * + * @param string $owner The owner name. + * @param string $repo The repository name. + * @param string $filepath The file path. + * @param string|null $ref The name of the commit/branch/tag. (Optional) + * + * @return string + * @since 3.2.0 + */ + public function get( + string $owner, + string $repo, + string $filepath, + ?string $ref = null + ): string + { + // Build the request path. + $encodedFilepath = rawurlencode($filepath); + $path = "/repos/{$owner}/{$repo}/media/{$encodedFilepath}"; + + // Prepare the URI. + $uri = $this->uri->get($path); + + // Add the 'ref' query parameter if provided. + if ($ref !== null) + { + $uri->setVar('ref', $ref); + } + + // Send the GET request. + return $this->response->get( + $this->http->get($uri), 200, 'success' + ); + } + +} + diff --git a/libraries/jcb_powers/VDM.Joomla.Gitea/src/Repository/Merge.php b/libraries/jcb_powers/VDM.Joomla.Gitea/src/Repository/Merge.php new file mode 100644 index 0000000..2b2cd2d --- /dev/null +++ b/libraries/jcb_powers/VDM.Joomla.Gitea/src/Repository/Merge.php @@ -0,0 +1,167 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ + +namespace VDM\Joomla\Gitea\Repository; + + +use VDM\Joomla\Gitea\Abstraction\Api; + + +/** + * The Gitea Repository Merge + * + * @since 3.2.0 + */ +class Merge extends Api +{ + /** + * Check if a pull request has been merged. + * + * @param string $owner The owner name. + * @param string $repo The repository name. + * @param int $index The pull request index. + * + * @return string + * @since 3.2.0 + **/ + public function check( + string $owner, + string $repo, + int $index + ): string + { + // Build the request path. + $path = "/repos/{$owner}/{$repo}/pulls/{$index}/merge"; + + // Send the get request. + return $this->response->get( + $this->http->get( + $this->uri->get($path) + ), 204, 'success' + ); + } + + /** + * Merge a pull request. + * + * @param string $owner The owner name. + * @param string $repo The repository name. + * @param int $index The pull request index. + * @param string|null $mergeMethod Merge method to use (optional). + * @param string|null $mergeCommitId Merge commit ID (optional). + * @param string|null $mergeMessageField Merge message field (optional). + * @param string|null $mergeTitleField Merge title field (optional). + * @param bool|null $deleteBranchAfterMerge Delete branch after merge (optional). + * @param bool|null $forceMerge Force merge (optional). + * @param string|null $headCommitId Head commit ID (optional). + * @param bool|null $mergeWhenChecksSucceed Merge when checks succeed (optional). + * + * @return string + * @since 3.2.0 + **/ + public function pull( + string $owner, + string $repo, + int $index, + ?string $mergeMethod = null, + ?string $mergeCommitId = null, + ?string $mergeMessageField = null, + ?string $mergeTitleField = null, + ?bool $deleteBranchAfterMerge = null, + ?bool $forceMerge = null, + ?string $headCommitId = null, + ?bool $mergeWhenChecksSucceed = null + ): string + { + // Build the request path. + $path = "/repos/{$owner}/{$repo}/pulls/{$index}/merge"; + + // Set the merge data. + $data = new \stdClass(); + + if ($mergeMethod !== null) + { + $data->do = $mergeMethod; + } + + if ($mergeCommitId !== null) + { + $data->merge_commit_id = $mergeCommitId; + } + + if ($mergeMessageField !== null) + { + $data->merge_message_field = $mergeMessageField; + } + + if ($mergeTitleField !== null) + { + $data->merge_title_field = $mergeTitleField; + } + + if ($deleteBranchAfterMerge !== null) + { + $data->delete_branch_after_merge = $deleteBranchAfterMerge; + } + + if ($forceMerge !== null) + { + $data->force_merge = $forceMerge; + } + + if ($headCommitId !== null) + { + $data->head_commit_id = $headCommitId; + } + + if ($mergeWhenChecksSucceed !== null) + { + $data->merge_when_checks_succeed = $mergeWhenChecksSucceed; + } + + // Send the post request. + return $this->response->get( + $this->http->post( + $this->uri->get($path), json_encode($data) + ), 200, 'success' + ); + } + + /** + * Cancel the scheduled auto merge for a pull request. + * + * @param string $owner The owner name. + * @param string $repo The repository name. + * @param int $index The pull request index. + * + * @return string + * @since 3.2.0 + **/ + public function cancel( + string $owner, + string $repo, + int $index + ): string + { + // Build the request path. + $path = "/repos/{$owner}/{$repo}/pulls/{$index}/merge"; + + // Get the URI with the path. + $uri = $this->uri->get($path); + + // Send the delete request. + return $this->response->get( + $this->http->delete($uri), 204, 'success' + ); + } + +} + diff --git a/libraries/jcb_powers/VDM.Joomla.Gitea/src/Repository/Mirror.php b/libraries/jcb_powers/VDM.Joomla.Gitea/src/Repository/Mirror.php new file mode 100644 index 0000000..37e3b57 --- /dev/null +++ b/libraries/jcb_powers/VDM.Joomla.Gitea/src/Repository/Mirror.php @@ -0,0 +1,48 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ + +namespace VDM\Joomla\Gitea\Repository; + + +use VDM\Joomla\Gitea\Abstraction\Api; + + +/** + * The Gitea Repository Mirror + * + * @since 3.2.0 + */ +class Mirror extends Api +{ + /** + * Sync a mirrored repository. + * + * @param string $owner The owner name. + * @param string $repo The repository name. + * + * @return string + * @since 3.2.0 + */ + public function sync(string $owner, string $repo): string + { + // Build the request path. + $path = "/repos/{$owner}/{$repo}/mirror-sync"; + + // Send the POST request. + return $this->response->get( + $this->http->post( + $this->uri->get($path) + ), 200, 'success' + ); + } + +} + diff --git a/libraries/jcb_powers/VDM.Joomla.Gitea/src/Repository/Mirrors.php b/libraries/jcb_powers/VDM.Joomla.Gitea/src/Repository/Mirrors.php new file mode 100644 index 0000000..2dd60ed --- /dev/null +++ b/libraries/jcb_powers/VDM.Joomla.Gitea/src/Repository/Mirrors.php @@ -0,0 +1,190 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ + +namespace VDM\Joomla\Gitea\Repository; + + +use VDM\Joomla\Gitea\Abstraction\Api; + + +/** + * The Gitea Repository Mirrors + * + * @since 3.2.0 + */ +class Mirrors extends Api +{ + /** + * Get all push mirrors of the repository. + * + * @param string $owner The owner name. + * @param string $repo The repository name. + * @param int $page The page number of results to return (1-based). + * @param int $limit The page size of results. + * + * @return array|null + * @since 3.2.0 + */ + public function get( + string $owner, + string $repo, + int $page = 1, + int $limit = 10 + ): ?array + { + // Build the request path. + $path = "/repos/{$owner}/{$repo}/push_mirrors"; + + // Set query parameters. + $uri = $this->uri->get($path); + $uri->setVar('page', $page); + $uri->setVar('limit', $limit); + + // Send the request. + return $this->response->get( + $this->http->get($uri) + ); + } + + /** + * Add a push mirror to the repository. + * + * @param string $owner The owner name. + * @param string $repo The repository name. + * @param string $remoteAddress The push mirror address. + * @param string|null $remoteUsername The push mirror user. (Optional) + * @param string|null $remotePassword The push mirror password. (Optional) + * @param string $interval The interval for the push mirror. + * @param bool $syncOnCommit Sync on commit option. + * + * @return object|null + * @since 3.2.0 + */ + public function add( + string $owner, + string $repo, + string $remoteAddress, + ?string $remoteUsername = null, + ?string $remotePassword = null, + string $interval, + bool $syncOnCommit + ): ?object + { + // Build the request path. + $path = "/repos/{$owner}/{$repo}/push_mirrors"; + + // Set the mirror data. + $data = new \stdClass(); + $data->remote_address = $remoteAddress; + $data->interval = $interval; + $data->sync_on_commit = $syncOnCommit; + + if ($remoteUsername !== null) + { + $data->remote_username = $remoteUsername; + } + + if ($remotePassword !== null) + { + $data->remote_password = $remotePassword; + } + + // Send the request. + return $this->response->get( + $this->http->post( + $this->uri->get($path), json_encode($data) + ), 201 + ); + } + + /** + * Sync all push mirrored repositories. + * + * @param string $owner The owner name. + * @param string $repo The repository name. + * + * @return string + * @since 3.2.0 + */ + public function sync( + string $owner, + string $repo + ): string + { + // Build the request path. + $path = "/repos/{$owner}/{$repo}/push_mirrors-sync"; + + // Send the request. + return $this->response->get( + $this->http->post( + $this->uri->get($path) + ), 200, 'success' + ); + } + + /** + * Get push mirror of the repository by remoteName. + * + * @param string $owner The owner name. + * @param string $repo The repository name. + * @param string $name The remote name. + * + * @return object|null + * @since 3.2.0 + */ + public function name( + string $owner, + string $repo, + string $name + ): ?object + { + // Build the request path. + $path = "/repos/{$owner}/{$repo}/push_mirrors/{$name}"; + + // Get the URI with the path. + $uri = $this->uri->get($path); + + // Send the request. + return $this->response->get( + $this->http->get($uri) + ); + } + + /** + * Delete a push mirror from a repository by remoteName. + * + * @param string $owner The owner name. + * @param string $repo The repository name. + * @param string $name The remote name. + * + * @return string + * @since 3.2.0 + */ + public function delete( + string $owner, + string $repo, + string $name + ): string + { + // Build the request path. + $path = "/repos/{$owner}/{$repo}/push_mirrors/{$name}"; + + // Get the URI with the path. + $uri = $this->uri->get($path); + + // Send the request. + return $this->response->get( + $this->http->delete($uri), 204, 'success' + ); + } + +} + diff --git a/libraries/jcb_powers/VDM.Joomla.Gitea/src/Repository/Notes.php b/libraries/jcb_powers/VDM.Joomla.Gitea/src/Repository/Notes.php new file mode 100644 index 0000000..823d613 --- /dev/null +++ b/libraries/jcb_powers/VDM.Joomla.Gitea/src/Repository/Notes.php @@ -0,0 +1,53 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ + +namespace VDM\Joomla\Gitea\Repository; + + +use VDM\Joomla\Gitea\Abstraction\Api; + + +/** + * The Gitea Repository Notes + * + * @since 3.2.0 + */ +class Notes extends Api +{ + /** + * Get a note corresponding to a single commit from a repository. + * + * @param string $owner The owner name. + * @param string $repo The repository name. + * @param string $commitSha The SHA hash of the commit. + * + * @return object|null + * @since 3.2.0 + **/ + public function get( + string $owner, + string $repo, + string $commitSha + ): ?object + { + // Build the request path. + $path = "/repos/{$owner}/{$repo}/git/notes/{$commitSha}"; + + // Send the get request. + return $this->response->get( + $this->http->get( + $this->uri->get($path) + ) + ); + } + +} + diff --git a/libraries/jcb_powers/VDM.Joomla.Gitea/src/Repository/Patch.php b/libraries/jcb_powers/VDM.Joomla.Gitea/src/Repository/Patch.php new file mode 100644 index 0000000..d7d8007 --- /dev/null +++ b/libraries/jcb_powers/VDM.Joomla.Gitea/src/Repository/Patch.php @@ -0,0 +1,78 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ + +namespace VDM\Joomla\Gitea\Repository; + + +use VDM\Joomla\Gitea\Abstraction\Api; + + +/** + * The Gitea Repository Patch + * + * @since 3.2.0 + */ +class Patch extends Api +{ + /** + * Apply a diff patch to a repository. + * + * @param string $owner The owner of the repo. + * @param string $repo The name of the repo. + * @param array $options Options for updating files. + * $options = [ + * 'description' => 'UpdateFileOptions', + * 'body' => [ + * 'content' => 'string', // Content must be base64 encoded. + * 'sha' => 'string', // The SHA for the file that already exists. + * 'branch' => 'string', // Branch (optional) to base this file from. If not given, the default branch is used. + * 'new_branch' => 'string', // New branch (optional) will make a new branch from branch before creating the file. + * 'from_path' => 'string', // From_path (optional) is the path of the original file which will be moved/renamed to the path in the URL. + * 'message' => 'string', // Message (optional) for the commit of this file. If not supplied, a default message will be used. + * 'author' => [ // Identity for a person's identity like an author or committer. + * 'name' => 'string', + * 'email' => 'string($email)' + * ], + * 'committer' => [ // Identity for a person's identity like an author or committer. + * 'name' => 'string', + * 'email' => 'string($email)' + * ], + * 'dates' => [ // Store dates for GIT_AUTHOR_DATE and GIT_COMMITTER_DATE. + * 'author' => 'string($date-time)', + * 'committer' => 'string($date-time)' + * ], + * 'signoff' => 'boolean' // Add a Signed-off-by trailer by the committer at the end of the commit log message. + * ] + * ] + * + * @return object|null + * @since 3.2.0 + */ + public function applyDiffPatch( + string $owner, + string $repo, + array $option + ): ?object + { + // Build the request path. + $uriPath = "/repos/{$owner}/{$repo}/diffpatch"; + + // Send the post request. + return $this->response->get( + $this->http->post( + $this->uri->get($uriPath), + json_encode($options) + ) + ); + } + +} + diff --git a/libraries/jcb_powers/VDM.Joomla.Gitea/src/Repository/Pulls.php b/libraries/jcb_powers/VDM.Joomla.Gitea/src/Repository/Pulls.php new file mode 100644 index 0000000..a979e79 --- /dev/null +++ b/libraries/jcb_powers/VDM.Joomla.Gitea/src/Repository/Pulls.php @@ -0,0 +1,547 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ + +namespace VDM\Joomla\Gitea\Repository; + + +use VDM\Joomla\Gitea\Abstraction\Api; + + +/** + * The Gitea Repository Pulls + * + * @since 3.2.0 + */ +class Pulls extends Api +{ + /** + * List a repository's pull requests. + * + * @param string $owner The owner name. + * @param string $repo The repository name. + * @param string|null $state State of pull request: open, closed, or all (optional). + * @param string|null $sort Type of sort (optional). + * @param int|null $milestone ID of the milestone (optional). + * @param array|null $labels Label IDs (optional). + * @param int $page Page number of results to return (1-based, default: 1). + * @param int $limit Page size of results (default: 10). + * + * @return array|null + * @since 3.2.0 + */ + public function list( + string $owner, + string $repo, + ?string $state = null, + ?string $sort = null, + ?int $milestone = null, + ?array $labels = null, + int $page = 1, + int $limit = 10 + ): ?array + { + // Build the request path. + $path = "/repos/{$owner}/{$repo}/pulls"; + + // Set query parameters. + $this->uri->setVar('page', $page); + $this->uri->setVar('limit', $limit); + + if ($state !== null) + { + $this->uri->setVar('state', $state); + } + + if ($sort !== null) + { + $this->uri->setVar('sort', $sort); + } + + if ($milestone !== null) + { + $this->uri->setVar('milestone', $milestone); + } + + if ($labels !== null) + { + $this->uri->setVar('labels', implode(',', $labels)); + } + + // Send the GET request. + return $this->response->get( + $this->http->get( + $this->uri->get($path) + ) + ); + } + + /** + * Create a pull request. + * + * @param string $owner The owner name. + * @param string $repo The repository name. + * @param string $title The title of the pull request. + * @param string $head The head branch. + * @param string $base The base branch. + * @param string|null $body The description of the pull request (optional). + * @param string|null $assignee The assignee of the pull request (optional). + * @param array|null $assignees Additional assignees (optional). + * @param array|null $labels Label IDs (optional). + * @param int|null $milestone ID of the milestone (optional). + * @param string|null $dueDate Due date of the pull request (optional). + * + * @return object|null + * @since 3.2.0 + */ + public function create( + string $owner, + string $repo, + string $title, + string $head, + string $base, + ?string $body = null, + ?string $assignee = null, + ?array $assignees = null, + ?array $labels = null, + ?int $milestone = null, + ?string $dueDate = null + ): ?object + { + // Build the request path. + $path = "/repos/{$owner}/{$repo}/pulls"; + + // Set the pull request data. + $data = new \stdClass(); + $data->title = $title; + $data->head = $head; + $data->base = $base; + + if ($body !== null) + { + $data->body = $body; + } + + if ($assignee !== null) + { + $data->assignee = $assignee; + } + + if ($assignees !== null) + { + $data->assignees = $assignees; + } + + if ($labels !== null) + { + $data->labels = $labels; + } + + if ($milestone !== null) + { + $data->milestone = $milestone; + } + + if ($dueDate !== null) + { + $data->due_date = $dueDate; + } + + // Send the post request. + return $this->response->get( + $this->http->post( + $this->uri->get($path), json_encode($data) + ), 201 + ); + } + + /** + * Get a pull request. + * + * @param string $owner The owner name. + * @param string $repo The repository name. + * @param int $index The pull request index. + * + * @return object|null + * @since 3.2.0 + **/ + public function get(string $owner, string $repo, int $index): ?object + { + // Build the request path. + $path = "/repos/{$owner}/{$repo}/pulls/{$index}"; + + // Send the get request. + return $this->response->get( + $this->http->get( + $this->uri->get($path) + ) + ); + } + + /** + * Update a pull request. + * + * @param string $owner The owner name. + * @param string $repo The repository name. + * @param int $index The pull request index. + * @param string|null $title The title of the pull request (optional). + * @param string|null $body The description of the pull request (optional). + * @param string|null $assignee The assignee of the pull request (optional). + * @param array|null $assignees Additional assignees (optional). + * @param string|null $base The base branch (optional). + * @param string|null $state The state of the pull request (optional). + * @param array|null $labels Label IDs (optional). + * @param int|null $milestone ID of the milestone (optional). + * @param string|null $dueDate Due date of the pull request (optional). + * @param bool|null $unsetDueDate Whether to unset the due date (optional). + * @param bool|null $allowMaintainerEdit Allow maintainer to edit the pull request (optional). + * + * @return object|null + * @since 3.2.0 + */ + public function update( + string $owner, + string $repo, + int $index, + ?string $title = null, + ?string $body = null, + ?string $assignee = null, + ?array $assignees = null, + ?string $base = null, + ?string $state = null, + ?array $labels = null, + ?int $milestone = null, + ?string $dueDate = null, + ?bool $unsetDueDate = null, + ?bool $allowMaintainerEdit = null + ): ?object + { + // Build the request path. + $path = "/repos/{$owner}/{$repo}/pulls/{$index}"; + + // Set the pull request data. + $data = new \stdClass(); + + if ($title !== null) + { + $data->title = $title; + } + + if ($body !== null) + { + $data->body = $body; + } + + if ($assignee !== null) + { + $data->assignee = $assignee; + } + + if ($assignees !== null) + { + $data->assignees = $assignees; + } + + if ($base !== null) + { + $data->base = $base; + } + + if ($state !== null) + { + $data->state = $state; + } + + if ($labels !== null) + { + $data->labels = $labels; + } + + if ($milestone !== null) + { + $data->milestone = $milestone; + } + + if ($dueDate !== null) + { + $data->due_date = $dueDate; + } + + if ($unsetDueDate !== null) + { + $data->unset_due_date = $unsetDueDate; + } + + if ($allowMaintainerEdit !== null) + { + $data->allow_maintainer_edit = $allowMaintainerEdit; + } + + // Send the patch request. + return $this->response->get( + $this->http->patch( + $this->uri->get($path), json_encode($data) + ), 201 + ); + } + + /** + * Get a pull request diff or patch. + * + * @param string $owner The owner name. + * @param string $repo The repository name. + * @param int $index The pull request index. + * @param string $diffType The type of the requested data, either "diff" or "patch". + * @param bool $binary Whether to include binary file changes. If true, the diff is applicable with git apply. + * + * @return string + * @since 3.2.0 + **/ + public function diff( + string $owner, + string $repo, + int $index, + string $diffType, + bool $binary = false + ): string + { + // Validate the diff type. + if (!in_array($diffType, ['diff', 'patch'])) + { + throw new \InvalidArgumentException('Invalid diff type. Allowed types are "diff" and "patch".'); + } + + // Build the request path. + $path = "/repos/{$owner}/{$repo}/pulls/{$index}.{$diffType}"; + + // Get the URI with the path. + $uri = $this->uri->get($path); + + // Set the binary query parameter if required. + if ($binary) + { + $uri->setVar('binary', 'true'); + } + + // Send the get request. + return $this->response->get( + $this->http->get($uri) + ); + } + + /** + * Get commits for a pull request. + * + * @param string $owner The owner name. + * @param string $repo The repository name. + * @param int $index The pull request index. + * @param int $page Page number of results to return (1-based). + * @param int $limit Page size of results. + * + * @return array|null + * @since 3.2.0 + **/ + public function commits( + string $owner, + string $repo, + int $index, + int $page = 1, + int $limit = 10 + ): ?array + { + // Build the request path. + $path = "/repos/{$owner}/{$repo}/pulls/{$index}/commits"; + + // Get the URI with the path. + $uri = $this->uri->get($path); + + // Set the page and limit query parameters. + $uri->setVar('page', $page); + $uri->setVar('limit', $limit); + + // Send the get request. + return $this->response->get( + $this->http->get($uri) + ); + } + + /** + * Get changed files for a pull request. + * + * @param string $owner The owner name. + * @param string $repo The repository name. + * @param int $index The pull request index. + * @param string $skipTo Skip to the given file. + * @param string $whitespace Whitespace behavior. + * @param int $page Page number of results to return (1-based). + * @param int $limit Page size of results. + * + * @return array|null + * @since 3.2.0 + **/ + public function files( + string $owner, + string $repo, + int $index, + ?string $skipTo = null, + ?string $whitespace = null, + int $page = 1, + int $limit = 10 + ): ?array + { + // Build the request path. + $path = "/repos/{$owner}/{$repo}/pulls/{$index}/files"; + + // Get the URI with the path. + $uri = $this->uri->get($path); + + // Set the skip-to, whitespace, page, and limit query parameters if needed. + if ($skipTo !== null) + { + $uri->setVar('skip-to', $skipTo); + } + if ($whitespace !== null) + { + $uri->setVar('whitespace', $whitespace); + } + $uri->setVar('page', $page); + $uri->setVar('limit', $limit); + + // Send the get request. + return $this->response->get( + $this->http->get($uri) + ); + } + + /** + * Merge a pull request. + * + * @param string $owner The owner name. + * @param string $repo The repository name. + * @param int $index The pull request index. + * @param string|null $do Merge method. + * @param string|null $mergeCommitId Merge commit ID. + * @param string|null $mergeMessageField Merge message field. + * @param string|null $mergeTitleField Merge title field. + * @param bool|null $deleteBranchAfterMerge Whether to delete the branch after merge. + * @param bool|null $forceMerge Whether to force merge. + * @param string|null $headCommitId Head commit ID. + * @param bool|null $mergeWhenChecksSucceed Whether to merge when checks succeed. + * + * @return string + * @since 3.2.0 + **/ + public function merge( + string $owner, + string $repo, + int $index, + ?string $do = null, + ?string $mergeCommitId = null, + ?string $mergeMessageField = null, + ?string $mergeTitleField = null, + ?bool $deleteBranchAfterMerge = null, + ?bool $forceMerge = null, + ?string $headCommitId = null, + ?bool $mergeWhenChecksSucceed = null + ): string + { + // Build the request path. + $path = "/repos/{$owner}/{$repo}/pulls/{$index}/merge"; + + // Set the merge data. + $data = new \stdClass(); + + if ($do !== null) + { + $data->do = $do; + } + + if ($mergeCommitId !== null) + { + $data->merge_commit_id = $mergeCommitId; + } + + if ($mergeMessageField !== null) + { + $data->merge_message_field = $mergeMessageField; + } + + if ($mergeTitleField !== null) + { + $data->merge_title_field = $mergeTitleField; + } + + if ($deleteBranchAfterMerge !== null) + { + $data->delete_branch_after_merge = $deleteBranchAfterMerge; + } + + if ($forceMerge !== null) + { + $data->force_merge = $forceMerge; + } + + if ($headCommitId !== null) + { + $data->head_commit_id = $headCommitId; + } + + if ($mergeWhenChecksSucceed !== null) + { + $data->merge_when_checks_succeed = $mergeWhenChecksSucceed; + } + + // Send the post request. + return $this->response->get( + $this->http->post( + $this->uri->get($path), json_encode($data) + ), 200, 'success' + ); + } + + /** + * Merge PR's baseBranch into headBranch. + * + * @param string $owner The owner name. + * @param string $repo The repository name. + * @param int $index The pull request index. + * @param string|null $style How to update the pull request. (Optional) + * + * @return string + * @since 3.2.0 + */ + public function update( + string $owner, + string $repo, + int $index, + ?string $style = null + ): string + { + // Build the request path. + $path = "/repos/{$owner}/{$repo}/pulls/{$index}/update"; + + // Set the merge data. + $data = new \stdClass(); + + if ($style !== null) + { + $data->style = $style; + } + + // Send the request. + return $this->response->get( + $this->http->post( + $this->uri->get($path), json_encode($data) + ), 200, 'success' + ); + } + +} + diff --git a/libraries/jcb_powers/VDM.Joomla.Gitea/src/Repository/Refs.php b/libraries/jcb_powers/VDM.Joomla.Gitea/src/Repository/Refs.php new file mode 100644 index 0000000..6abc591 --- /dev/null +++ b/libraries/jcb_powers/VDM.Joomla.Gitea/src/Repository/Refs.php @@ -0,0 +1,77 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ + +namespace VDM\Joomla\Gitea\Repository; + + +use VDM\Joomla\Gitea\Abstraction\Api; + + +/** + * The Gitea Repository Refs + * + * @since 3.2.0 + */ +class Refs extends Api +{ + /** + * Get specified ref or filtered repository's refs. + * + * @param string $owner The owner name. + * @param string $repo The repository name. + * + * @return array|null + * @since 3.2.0 + **/ + public function list(string $owner, string $repo): ?array + { + // Build the request path. + $path = "/repos/{$owner}/{$repo}/git/refs"; + + // Build the URI. + $uri = $this->uri->get($path); + + // Send the get request. + return $this->response->get( + $this->http->get($uri) + ); + } + + /** + * Get specified ref. + * + * @param string $owner The owner name. + * @param string $repo The repository name. + * @param string $ref The ref name. + * + * @return array|null + * @since 3.2.0 + **/ + public function get( + string $owner, + string $repo, + string $ref + ): ?array + { + // Build the request path. + $path = "/repos/{$owner}/{$repo}/git/refs/{$ref}"; + + // Build the URI. + $uri = $this->uri->get($path); + + // Send the get request. + return $this->response->get( + $this->http->get($uri) + ); + } + +} + diff --git a/libraries/jcb_powers/VDM.Joomla.Gitea/src/Repository/Releases.php b/libraries/jcb_powers/VDM.Joomla.Gitea/src/Repository/Releases.php new file mode 100644 index 0000000..5723b56 --- /dev/null +++ b/libraries/jcb_powers/VDM.Joomla.Gitea/src/Repository/Releases.php @@ -0,0 +1,309 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ + +namespace VDM\Joomla\Gitea\Repository; + + +use VDM\Joomla\Gitea\Abstraction\Api; + + +/** + * The Gitea Repository Releases + * + * @since 3.2.0 + */ +class Releases extends Api +{ + /** + * List a repo's releases. + * + * @param string $ownerName The owner name. + * @param string $repoName The repository name. + * @param bool|null $draft Filter (exclude/include) drafts (optional). + * @param bool|null $preRelease Filter (exclude/include) pre-releases (optional). + * @param int $page Page number of results to return (1-based, optional). + * @param int $limit Page size of results (optional). + * + * @return array|null + * @since 3.2.0 + */ + public function list( + string $ownerName, + string $repoName, + ?bool $draft = null, + ?bool $preRelease = null, + int $page = 1, + int $limit = 10 + ): ?array + { + // Build the request path. + $path = "/repos/{$ownerName}/{$repoName}/releases"; + + // Set additional URI values. + $this->uri->setVar('page', $page); + $this->uri->setVar('limit', $limit); + + if ($draft !== null) + { + $this->uri->setVar('draft', $draft); + } + + if ($preRelease !== null) + { + $this->uri->setVar('pre-release', $preRelease); + } + + // Send the request. + return $this->response->get( + $this->http->get( + $this->uri->get($path) + ) + ); + } + + /** + * Create a release. + * + * @param string $ownerName The owner name. + * @param string $repoName The repository name. + * @param string $tagName The tag name. + * @param string $targetCommitish The commitish value that determines where the Git tag is created from. + * @param string $releaseName The name of the release. + * @param string $releaseBody The description of the release. + * @param bool $isDraft Whether the release is a draft. + * @param bool $isPrerelease Whether the release is a pre-release. + * + * @return object|null + * @since 3.2.0 + **/ + public function create( + string $ownerName, + string $repoName, + string $tagName, + string $targetCommitish, + string $releaseName, + string $releaseBody, + bool $isDraft = false, + bool $isPrerelease = false + ): ?object + { + // Build the request path. + $path = "/repos/{$ownerName}/{$repoName}/releases"; + + // Set the release data + $data = new \stdClass(); + $data->tag_name = $tagName; + $data->target_commitish = $targetCommitish; + $data->name = $releaseName; + $data->body = $releaseBody; + $data->draft = $isDraft; + $data->prerelease = $isPrerelease; + + // Send the post request. + return $this->response->get( + $this->http->post( + $this->uri->get($path), json_encode($data) + ), 201 + ); + } + + /** + * Get a release by ID. + * + * @param string $ownerName The owner name. + * @param string $repoName The repository name. + * @param int $releaseId The release ID. + * + * @return object|null + * @since 3.2.0 + **/ + public function get( + string $ownerName, + string $repoName, + int $releaseId + ): ?object + { + // Build the request path. + $path = "/repos/{$ownerName}/{$repoName}/releases/{$releaseId}"; + + // Send the get request. + return $this->response->get( + $this->http->get( + $this->uri->get($path) + ) + ); + } + + /** + * Delete a release by ID. + * + * @param string $ownerName The owner name. + * @param string $repoName The repository name. + * @param int $releaseId The release ID. + * + * @return string + * @since 3.2.0 + **/ + public function delete( + string $ownerName, + string $repoName, + int $releaseId + ): string + { + // Build the request path. + $path = "/repos/{$ownerName}/{$repoName}/releases/{$releaseId}"; + + // Send the delete request. + return $this->response->get( + $this->http->delete( + $this->uri->get($path) + ), 204, 'success' + ); + } + + /** + * Update a release. + * + * @param string $ownerName The owner name. + * @param string $repoName The repository name. + * @param int $releaseId The release ID. + * @param string|null $tagName The tag name (optional). + * @param string|null $targetCommitish The commitish value that determines where the Git tag is created from (optional). + * @param string|null $releaseName The name of the release (optional). + * @param string|null $description The description of the release (optional). + * @param bool|null $isDraft Whether the release is a draft (optional). + * @param bool|null $isPrerelease Whether the release is a pre-release (optional). + * + * @return object|null + * @since 3.2.0 + **/ + public function update( + string $ownerName, + string $repoName, + int $releaseId, + ?string $tagName = null, + ?string $targetCommitish = null, + ?string $releaseName = null, + ?string $description = null, + ?bool $isDraft = null, + ?bool $isPrerelease = null + ): ?object + { + // Build the request path. + $path = "/repos/{$ownerName}/{$repoName}/releases/{$releaseId}"; + + // Set the release data + $data = new \stdClass(); + + if ($tagName !== null || $targetCommitish !== null || $releaseName !== null || $description !== null || $isDraft !== null || $isPrerelease !== null) + { + $data->editReleaseOption = new \stdClass(); + + if ($tagName !== null) + { + $data->editReleaseOption->tag_name = $tagName; + } + + if ($targetCommitish !== null) + { + $data->editReleaseOption->target_commitish = $targetCommitish; + } + + if ($releaseName !== null) + { + $data->editReleaseOption->name = $releaseName; + } + + if ($description !== null) + { + $data->editReleaseOption->body = $description; + } + + if ($isDraft !== null) + { + $data->editReleaseOption->draft = $isDraft; + } + + if ($isPrerelease !== null) + { + $data->editReleaseOption->prerelease = $isPrerelease; + } + } + + // Send the patch request. + return $this->response->get( + $this->http->patch( + $this->uri->get($path), json_encode($data) + ) + ); + } + + /** + * Get a release by tag name. + * + * @param string $ownerName The owner name. + * @param string $repoName The repository name. + * @param string $tagName The tag name. + * + * @return object|null + * @since 3.2.0 + **/ + public function getByTag( + string $ownerName, + string $repoName, + string $tagName + ): ?object + { + // Build the request path. + $path = "/repos/{$ownerName}/{$repoName}/releases/tags/{$tagName}"; + + // Configure the URI with the path. + $this->uri->setVar('owner', $ownerName); + $this->uri->setVar('repo', $repoName); + $this->uri->setVar('tag', $tagName); + + // Send the get request. + return $this->response->get( + $this->http->get( + $this->uri->get($path) + ) + ); + } + + /** + * Delete a release by tag name. + * + * @param string $ownerName The owner name. + * @param string $repoName The repository name. + * @param string $tagName The tag name. + * + * @return string + * @since 3.2.0 + **/ + public function deleteByTag( + string $ownerName, + string $repoName, + string $tagName + ): string + { + // Build the request path. + $path = "/repos/{$ownerName}/{$repoName}/releases/tags/{$tagName}"; + + // Send the delete request. + return $this->response->get( + $this->http->delete( + $this->uri->get($path) + ), 204, 'success' + ); + } + +} + diff --git a/libraries/jcb_powers/VDM.Joomla.Gitea/src/Repository/Remote.php b/libraries/jcb_powers/VDM.Joomla.Gitea/src/Repository/Remote.php new file mode 100644 index 0000000..f1bf114 --- /dev/null +++ b/libraries/jcb_powers/VDM.Joomla.Gitea/src/Repository/Remote.php @@ -0,0 +1,96 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ + +namespace VDM\Joomla\Gitea\Repository; + + +use VDM\Joomla\Gitea\Abstraction\Api; + + +/** + * The Gitea Repository Remote + * + * @since 3.2.0 + */ +class Remote extends Api +{ + /** + * Migrate a remote git repository. + * + * @param string $cloneAddr The URL to clone the repository from. + * @param string $repoName The desired name for the new repository. + * @param string $repoOwner The name of the user or organization who will own the repo after migration. + * @param string $uid The ID of the user that will own the new repository (deprecated). + * @param string $description The description for the new repository (optional). + * @param bool $private Set the repository to private (optional, default false). + * @param string|null $authToken Authentication token (optional). + * @param string|null $authUsername Authentication username (optional). + * @param string|null $authPassword Authentication password (optional). + * @param array $options Additional migration options (optional). + * + * @return object|null + * @since 3.2.0 + **/ + public function migrate( + string $cloneAddr, + string $repoName, + string $repoOwner, + string $uid, + string $description = '', + bool $private = false, + ?string $authToken = null, + ?string $authUsername = null, + ?string $authPassword = null, + array $options = [] + ): ?object + { + // Build the request path. + $path = "/repos/migrate"; + + // Set the repository migration data. + $data = new \stdClass(); + $data->cloneAddr = $cloneAddr; + $data->repoName = $repoName; + $data->repoOwner = $repoOwner; + $data->uid = $uid; + $data->description = $description; + $data->private = $private; + + if ($authToken !== null) + { + $data->authToken = $authToken; + } + + if ($authUsername !== null) + { + $data->authUsername = $authUsername; + } + + if ($authPassword !== null) + { + $data->authPassword = $authPassword; + } + + foreach ($options as $key => $val) + { + $data->{$key} = $val; + } + + // Send the post request. + return $this->response->get( + $this->http->post( + $this->uri->get($path), json_encode($data) + ), 201 + ); + } + +} + diff --git a/libraries/jcb_powers/VDM.Joomla.Gitea/src/Repository/Reviewers.php b/libraries/jcb_powers/VDM.Joomla.Gitea/src/Repository/Reviewers.php new file mode 100644 index 0000000..ee0a4a0 --- /dev/null +++ b/libraries/jcb_powers/VDM.Joomla.Gitea/src/Repository/Reviewers.php @@ -0,0 +1,126 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ + +namespace VDM\Joomla\Gitea\Repository; + + +use VDM\Joomla\Gitea\Abstraction\Api; + + +/** + * The Gitea Repository Reviewers + * + * @since 3.2.0 + */ +class Reviewers extends Api +{ + /** + * Create review requests for a pull request. + * + * @param string $owner The owner name. + * @param string $repo The repository name. + * @param int $index The pull request index. + * @param array $reviewers Array of reviewers usernames. + * @param array|null $teamReviewers Array of team reviewers (optional). + * + * @return array|null + * @since 3.2.0 + **/ + public function request( + string $owner, + string $repo, + int $index, + array $reviewers, + ?array $teamReviewers = null + ): ?array + { + // Build the request path. + $path = "/repos/{$owner}/{$repo}/pulls/{$index}/requested_reviewers"; + + // Set the review requests data. + $data = new \stdClass(); + $data->reviewers = $reviewers; + + if ($teamReviewers !== null) + { + $data->team_reviewers = $teamReviewers; + } + + // Send the post request. + return $this->response->get( + $this->http->post( + $this->uri->get($path), json_encode($data) + ), 201 + ); + } + + /** + * Cancel review requests for a pull request. + * + * @param string $owner The owner name. + * @param string $repo The repository name. + * @param int $index The pull request index. + * @param array $reviewers Array of reviewers usernames. + * @param array|null $teamReviewers Array of team reviewers (optional). + * + * @return string + * @since 3.2.0 + **/ + public function cancel( + string $owner, + string $repo, + int $index, + array $reviewers, + ?array $teamReviewers = null + ): string + { + // Build the request path. + $path = "/repos/{$owner}/{$repo}/pulls/{$index}/requested_reviewers"; + + // Get the URI and set the required variables. + $uri = $this->uri->get($path); + $uri->setVar('reviewers', json_encode($reviewers)); + + if ($teamReviewers !== null) + { + $uri->setVar('teamReviewers', json_encode($teamReviewers)); + } + + // Send the delete request. + return $this->response->get( + $this->http->delete($uri), 204, 'success' + ); + } + + /** + * Return all users that can be requested to review in this repo. + * + * @param string $owner The owner name. + * @param string $repo The repository name. + * + * @return array|null + * @since 3.2.0 + **/ + public function get(string $owner, string $repo): ?array + { + // Build the request path. + $path = "/repos/{$owner}/{$repo}/reviewers"; + + // Send the get request. + return $this->response->get( + $this->http->get( + $this->uri->get($path) + ) + ); + } + +} + diff --git a/libraries/jcb_powers/VDM.Joomla.Gitea/src/Repository/Reviews.php b/libraries/jcb_powers/VDM.Joomla.Gitea/src/Repository/Reviews.php new file mode 100644 index 0000000..17e3ac3 --- /dev/null +++ b/libraries/jcb_powers/VDM.Joomla.Gitea/src/Repository/Reviews.php @@ -0,0 +1,321 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ + +namespace VDM\Joomla\Gitea\Repository; + + +use VDM\Joomla\Gitea\Abstraction\Api; + + +/** + * The Gitea Repository Reviews + * + * @since 3.2.0 + */ +class Reviews extends Api +{ + /** + * List all reviews for a pull request. + * + * @param string $owner The owner name. + * @param string $repo The repository name. + * @param int $index The pull request index. + * @param int $page The page number of results to return (1-based). + * @param int $limit The page size of results. + * + * @return array|null + * @since 3.2.0 + **/ + public function list( + string $owner, + string $repo, + int $index, + int $page = 1, + int $limit = 10 + ): ?array + { + // Build the request path. + $path = "/repos/{$owner}/{$repo}/pulls/{$index}/reviews"; + + // Get the URI. + $uri = $this->uri->get($path); + + // Set query parameters. + $uri->setVar('page', $page); + $uri->setVar('limit', $limit); + + // Send the get request. + return $this->response->get( + $this->http->get($uri) + ); + } + + /** + * Create a review for a pull request. + * + * @param string $owner The owner name. + * @param string $repo The repository name. + * @param int $index The pull request index. + * @param string $body The review body text. + * @param string $event The review event type (APPROVE, REQUEST_CHANGES, COMMENT). + * @param array|null $comments An array of CreatePullReviewComment objects. + * @param string|null $commitId The commit ID. + * + * @return object|null + * @since 3.2.0 + */ + public function create( + string $owner, + string $repo, + int $index, + string $body, + string $event, + ?array $comments = null, + ?string $commitId = null + ): ?object + { + // Build the request path. + $path = "/repos/{$owner}/{$repo}/pulls/{$index}/reviews"; + + // Set the review data. + $data = new \stdClass(); + $data->body = $body; + $data->event = $event; + + // Add comments if available. + if ($comments !== null) + { + $data->comments = $comments; + } + + // Add commitId if available. + if ($commitId !== null) + { + $data->commit_id = $commitId; + } + + // Send the request. + return $this->response->get( + $this->http->post( + $this->uri->get($path), json_encode($data) + ) + ); + } + + /** + * Get a specific review for a pull request. + * + * @param string $owner The owner name. + * @param string $repo The repository name. + * @param int $index The pull request index. + * @param int $id The review ID. + * + * @return object|null + * @since 3.2.0 + */ + public function get( + string $owner, + string $repo, + int $index, + int $id + ): ?object + { + // Build the request path. + $path = "/repos/{$owner}/{$repo}/pulls/{$index}/reviews/{$id}"; + + // Set the variables for the URI. + $uri = $this->uri->get($path); + $uri->setVar('owner', $owner); + $uri->setVar('repo', $repo); + $uri->setVar('index', $index); + $uri->setVar('id', $id); + + // Send the request. + return $this->response->get( + $this->http->get($uri) + ); + } + + /** + * Submit a pending review to a pull request. + * + * @param string $owner The owner name. + * @param string $repo The repository name. + * @param int $index The pull request index. + * @param int $id The review ID. + * @param string $body The review body text. + * @param string $event The review event type (APPROVE, REQUEST_CHANGES, COMMENT). + * + * @return object|null + * @since 3.2.0 + */ + public function submit( + string $owner, + string $repo, + int $index, + int $id, + string $body, + string $event + ): ?object + { + // Build the request path. + $path = "/repos/{$owner}/{$repo}/pulls/{$index}/reviews/{$id}"; + + // Set the review data. + $data = new \stdClass(); + $data->body = $body; + $data->event = $event; + + // Send the request. + return $this->response->get( + $this->http->post( + $this->uri->get($path), json_encode($data) + ) + ); + } + + /** + * Delete a specific review from a pull request. + * + * @param string $owner The owner name. + * @param string $repo The repository name. + * @param int $index The pull request index. + * @param int $id The review ID. + * + * @return string + * @since 3.2.0 + */ + public function delete( + string $owner, + string $repo, + int $index, + int $id + ): string + { + // Build the request path. + $path = "/repos/{$owner}/{$repo}/pulls/{$index}/reviews/{$id}"; + + // Set the variables for the URI. + $uri = $this->uri->get($path); + $uri->setVar('owner', $owner); + $uri->setVar('repo', $repo); + $uri->setVar('index', $index); + $uri->setVar('id', $id); + + // Send the delete request. + return $this->response->get( + $this->http->delete($uri), 204, 'success' + ); + } + + /** + * Get the comments of a specific review for a pull request. + * + * @param string $owner The owner name. + * @param string $repo The repository name. + * @param int $index The pull request index. + * @param int $id The review ID. + * + * @return array|null + * @since 3.2.0 + */ + public function comments( + string $owner, + string $repo, + int $index, + int $id + ): ?array + { + // Build the request path. + $path = "/repos/{$owner}/{$repo}/pulls/{$index}/reviews/{$id}/comments"; + + // Set the variables for the URI. + $uri = $this->uri->get($path); + $uri->setVar('owner', $owner); + $uri->setVar('repo', $repo); + $uri->setVar('index', $index); + $uri->setVar('id', $id); + + // Send the request. + return $this->response->get( + $this->http->get($uri) + ); + } + + /** + * Dismiss a review for a pull request. + * + * @param string $owner The owner name. + * @param string $repo The repository name. + * @param int $index The pull request index. + * @param int $id The review ID. + * @param string $message The dismissal message. + * @param bool $priors The flag to dismiss prior reviews. + * + * @return object|null + * @since 3.2.0 + */ + public function dismiss( + string $owner, + string $repo, + int $index, + int $id, + string $message, + bool $priors = false + ): ?object + { + // Build the request path. + $path = "/repos/{$owner}/{$repo}/pulls/{$index}/reviews/{$id}/dismissals"; + + // Set the dismissal data. + $data = new \stdClass(); + $data->message = $message; + $data->priors = $priors; + + // Send the request. + return $this->response->get( + $this->http->post( + $this->uri->get($path), json_encode($data) + ) + ); + } + + /** + * Cancel the dismissal of a review for a pull request. + * + * @param string $owner The owner name. + * @param string $repo The repository name. + * @param int $index The pull request index. + * @param int $id The review ID. + * + * @return object|null + * @since 3.2.0 + */ + public function undismiss( + string $owner, + string $repo, + int $index, + int $id + ): ?object + { + // Build the request path. + $path = "/repos/{$owner}/{$repo}/pulls/{$index}/reviews/{$id}/undismissals"; + + // Send the request. + return $this->response->get( + $this->http->post( + $this->uri->get($path) + ) + ); + } + +} + diff --git a/libraries/jcb_powers/VDM.Joomla.Gitea/src/Repository/Stargazers.php b/libraries/jcb_powers/VDM.Joomla.Gitea/src/Repository/Stargazers.php new file mode 100644 index 0000000..0c72b6d --- /dev/null +++ b/libraries/jcb_powers/VDM.Joomla.Gitea/src/Repository/Stargazers.php @@ -0,0 +1,59 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ + +namespace VDM\Joomla\Gitea\Repository; + + +use VDM\Joomla\Gitea\Abstraction\Api; + + +/** + * The Gitea Repository Stargazers + * + * @since 3.2.0 + */ +class Stargazers extends Api +{ + /** + * List a repo's stargazers. + * + * @param string $ownerName The owner name. + * @param string $repoName The repository name. + * @param int $page The page number of results to return (1-based). + * @param int $limit The page size of results. + * + * @return array|null + * @since 3.2.0 + **/ + public function list( + string $ownerName, + string $repoName, + int $page = 1, + int $limit = 10 + ): ?array + { + // Build the request path. + $path = "/repos/{$ownerName}/{$repoName}/stargazers"; + + // Set the page and limit values. + $this->uri->setVar('page', $page); + $this->uri->setVar('limit', $limit); + + // Send the get request. + return $this->response->get( + $this->http->get( + $this->uri->get($path) + ) + ); + } + +} + diff --git a/libraries/jcb_powers/VDM.Joomla.Gitea/src/Repository/Statuses.php b/libraries/jcb_powers/VDM.Joomla.Gitea/src/Repository/Statuses.php new file mode 100644 index 0000000..ba6e3c1 --- /dev/null +++ b/libraries/jcb_powers/VDM.Joomla.Gitea/src/Repository/Statuses.php @@ -0,0 +1,122 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ + +namespace VDM\Joomla\Gitea\Repository; + + +use VDM\Joomla\Gitea\Abstraction\Api; + + +/** + * The Gitea Repository Statuses + * + * @since 3.2.0 + */ +class Statuses extends Api +{ + /** + * Get a commit's statuses. + * + * @param string $ownerName The owner name. + * @param string $repoName The repository name. + * @param string $commitSha The commit SHA. + * @param string $sort The type of sort. + * @param string $state The type of state. + * @param int $page The page number of results to return (1-based). + * @param int $limit The page size of results. + * + * @return array|null + * @since 3.2.0 + **/ + public function get( + string $ownerName, + string $repoName, + string $commitSha, + string $sort = 'recentupdate', + string $state = 'pending', + int $page = 1, + int $limit = 10 + ): ?array + { + // Build the request path. + $path = "/repos/{$ownerName}/{$repoName}/statuses/{$commitSha}"; + + // Prepare the URI with the path. + $uri = $this->uri->get($path); + + // Set the query parameters. + $uri->setVar('sort', $sort); + $uri->setVar('state', $state); + $uri->setVar('page', $page); + $uri->setVar('limit', $limit); + + // Send the get request. + return $this->response->get( + $this->http->get($uri) + ); + } + + /** + * Create a commit status. + * + * @param string $ownerName The owner name. + * @param string $repoName The repository name. + * @param string $commitSha The commit SHA. + * @param string $state The commit status state (error, failure, pending, success, or warning). + * @param string|null $context The context of the status (optional). + * @param string|null $statusDescription The status description (optional). + * @param string|null $targetUrl The URL of the associated build status (optional). + * + * @return object|null + * @since 3.2.0 + **/ + public function create( + string $ownerName, + string $repoName, + string $commitSha, + string $state, + ?string $context = null, + ?string $statusDescription = null, + ?string $targetUrl = null + ): ?object + { + // Build the request path. + $path = "/repos/{$ownerName}/{$repoName}/statuses/{$commitSha}"; + + // Set the commit status data + $data = new \stdClass(); + $data->state = $state; + + if ($context !== null) + { + $data->context = $context; + } + + if ($statusDescription !== null) + { + $data->description = $statusDescription; + } + + if ($targetUrl !== null) + { + $data->target_url = $targetUrl; + } + + // Send the post request. + return $this->response->get( + $this->http->post( + $this->uri->get($path), json_encode($data) + ), 201 + ); + } + +} + diff --git a/libraries/jcb_powers/VDM.Joomla.Gitea/src/Repository/Tags.php b/libraries/jcb_powers/VDM.Joomla.Gitea/src/Repository/Tags.php new file mode 100644 index 0000000..600bfc2 --- /dev/null +++ b/libraries/jcb_powers/VDM.Joomla.Gitea/src/Repository/Tags.php @@ -0,0 +1,182 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ + +namespace VDM\Joomla\Gitea\Repository; + + +use VDM\Joomla\Gitea\Abstraction\Api; + + +/** + * The Gitea Repository Tags + * + * @since 3.2.0 + */ +class Tags extends Api +{ + /** + * List a repository's tags + * + * @param string $owner The owner of the repo. + * @param string $repo The name of the repo. + * @param int|null $page The page number of results to return (1-based). + * @param int|null $limit The page size of results, default maximum page size is 10. + * + * @return array|null + * @since 3.2.0 + **/ + public function list( + string $owner, + string $repo, + ?int $page = 1, + ?int $limit = 10 + ): ?array + { + // Build the request path. + $path = "/repos/{$owner}/{$repo}/tags"; + + // Get the URI with the path. + $uri = $this->uri->get($path); + + // Add query parameters if they are provided. + if ($page !== null) + { + $uri->setVar('page', $page); + } + + if ($limit !== null) + { + $uri->setVar('limit', $limit); + } + + // Send the get request. + return $this->response->get( + $this->http->get($uri) + ); + } + + /** + * Get the tag of a repository by tag name. + * + * @param string $owner The owner name. + * @param string $repo The repository name. + * @param string $tag The tag name. + * + * @return object|null + * @since 3.2.0 + **/ + public function get(string $owner, string $repo, string $tag): ?object + { + // Build the request path. + $path = "/repos/{$owner}/{$repo}/tags/{$tag}"; + + // Send the get request. + return $this->response->get( + $this->http->get( + $this->uri->get($path) + ) + ); + } + + /** + * Get the tag object of an annotated tag (not lightweight tags). + * + * @param string $owner The owner of the repo. + * @param string $repo The name of the repo. + * @param string $sha The sha of the tag. The Git tags API only supports annotated tag objects, not lightweight tags. + * + * @return object|null + * @since 3.2.0 + **/ + public function sha( + string $owner, + string $repo, + string $sha + ): ?object + { + // Build the request path. + $path = "/repos/{$owner}/{$repo}/git/tags/{$sha}"; + + // Get the URI with the path. + $uri = $this->uri->get($path); + + // Send the get request. + return $this->response->get( + $this->http->get($uri) + ); + } + + /** + * Create a new git tag in a repository. + * + * @param string $owner The owner of the repo. + * @param string $repo The name of the repo. + * @param string $tagName The name of the tag. + * @param string $target The SHA of the git object this is tagging. + * @param string $message The tag message. + * + * @return object|null + * @since 3.2.0 + **/ + public function create( + string $owner, + string $repo, + string $tagName, + string $target, + string $message + ): ?object + { + // Build the request path. + $path = "/repos/{$owner}/{$repo}/tags"; + + // Set the tag data + $data = new \stdClass(); + $data->tag_name = $tagName; + $data->target = $target; + $data->message = $message; + + // Send the post request. + return $this->response->get( + $this->http->post( + $this->uri->get($path), json_encode($data) + ) + ); + } + + /** + * Delete a repository's tag by name. + * + * @param string $owner The owner name. + * @param string $repo The repository name. + * @param string $tag The tag name. + * + * @return string + * @since 3.2.0 + **/ + public function delete( + string $owner, + string $repo, + string $tag + ): string + { + // Build the request path. + $path = "/repos/{$owner}/{$repo}/tags/{$tag}"; + + // Send the delete request. + return $this->response->get( + $this->http->delete( + $this->uri->get($path) + ), 204, 'succes' + ); + } + +} + diff --git a/libraries/jcb_powers/VDM.Joomla.Gitea/src/Repository/Teams.php b/libraries/jcb_powers/VDM.Joomla.Gitea/src/Repository/Teams.php new file mode 100644 index 0000000..cb39f7c --- /dev/null +++ b/libraries/jcb_powers/VDM.Joomla.Gitea/src/Repository/Teams.php @@ -0,0 +1,133 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ + +namespace VDM\Joomla\Gitea\Repository; + + +use VDM\Joomla\Gitea\Abstraction\Api; + + +/** + * The Gitea Repository Teams + * + * @since 3.2.0 + */ +class Teams extends Api +{ + /** + * List a repository's teams. + * + * @param string $ownerOfRepo The owner name. + * @param string $nameOfRepo The repository name. + * + * @return array|null + * @since 3.2.0 + **/ + public function list(string $ownerOfRepo, string $nameOfRepo): ?array + { + // Build the request path. + $path = "/repos/{$ownerOfRepo}/{$nameOfRepo}/teams"; + + // Get the URI with the path. + $uri = $this->uri->get($path); + + // Send the get request. + return $this->response->get( + $this->http->get($uri) + ); + } + + /** + * Check if a team is assigned to a repository. + * + * @param string $ownerOfRepo The owner name. + * @param string $nameOfRepo The repository name. + * @param string $teamName The team name. + * + * @return object|null + * @since 3.2.0 + **/ + public function check( + string $ownerOfRepo, + string $nameOfRepo, + string $teamName + ): ?object + { + // Build the request path. + $path = "/repos/{$ownerOfRepo}/{$nameOfRepo}/teams/{$teamName}"; + + // Get the URI with the path. + $uri = $this->uri->get($path); + + // Send the get request. + return $this->response->get( + $this->http->get($uri) + ); + } + + /** + * Add a team to a repository. + * + * @param string $ownerName The owner name. + * @param string $repoName The repository name. + * @param string $teamName The team name. + * + * @return string + * @since 3.2.0 + **/ + public function add( + string $ownerName, + string $repoName, + string $teamName + ): string + { + // Build the request path. + $path = "/repos/{$ownerName}/{$repoName}/teams/{$teamName}"; + + // Send the put request. + return $this->response->get( + $this->http->put( + $this->uri->get($path), '' + ), 204, 'success' + ); + } + + /** + * Delete a team from a repository. + * + * @param string $ownerName The owner name. + * @param string $repoName The repository name. + * @param string $teamName The team name. + * + * @return string + * @since 3.2.0 + **/ + public function delete( + string $ownerName, + string $repoName, + string $teamName + ): string + { + // Build the request path. + $path = "/repos/{$ownerName}/{$repoName}/teams/{$teamName}"; + + // Prepare the URI with the path. + $uri = $this->uri->get($path); + + // Send the delete request. + return $this->response->get( + $this->http->delete($uri), + 204, 'success' + ); + } + +} + diff --git a/libraries/jcb_powers/VDM.Joomla.Gitea/src/Repository/Templates.php b/libraries/jcb_powers/VDM.Joomla.Gitea/src/Repository/Templates.php new file mode 100644 index 0000000..40246fc --- /dev/null +++ b/libraries/jcb_powers/VDM.Joomla.Gitea/src/Repository/Templates.php @@ -0,0 +1,91 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ + +namespace VDM\Joomla\Gitea\Repository; + + +use VDM\Joomla\Gitea\Abstraction\Api; + + +/** + * The Gitea Repository Templates + * + * @since 3.2.0 + */ +class Templates extends Api +{ + /** + * Get available issue templates for a repository. + * + * @param string $owner The owner name. + * @param string $repo The repository name. + * + * @return array|null + * @since 3.2.0 + **/ + public function issue(string $owner, string $repo): ?array + { + // Build the request path. + $path = "/repos/{$owner}/{$repo}/issue_templates"; + + // Get the URI. + $uri = $this->uri->get($path); + + // Send the GET request. + return $this->response->get( + $this->http->get($uri) + ); + } + + /** + * Create a repository using a template. + * + * @param string $templateOwner The template owner's name. + * @param string $templateRepo The template repository name. + * @param string $name The name of the new repository. + * @param array $options Optional. Additional options for the new repository. + * + * @return object|null + * @since 3.2.0 + **/ + public function repo( + string $templateOwner, + string $templateRepo, + string $name, + array $options = [] + ): ?object + { + // Build the request path. + $path = "/repos/{$templateOwner}/{$templateRepo}/generate"; + + // Set the repo data. + $data = new \stdClass(); + $data->name = $name; + + foreach ($options as $key => $value) + { + if ($value !== null) + { + $data->{$key} = $value; + } + } + + // Send the post request. + return $this->response->get( + $this->http->post( + $this->uri->get($path), + json_encode($data) + ), 201 + ); + } + +} + diff --git a/libraries/jcb_powers/VDM.Joomla.Gitea/src/Repository/Times.php b/libraries/jcb_powers/VDM.Joomla.Gitea/src/Repository/Times.php new file mode 100644 index 0000000..bae1416 --- /dev/null +++ b/libraries/jcb_powers/VDM.Joomla.Gitea/src/Repository/Times.php @@ -0,0 +1,80 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ + +namespace VDM\Joomla\Gitea\Repository; + + +use VDM\Joomla\Gitea\Abstraction\Api; + + +/** + * The Gitea Repository Times + * + * @since 3.2.0 + */ +class Times extends Api +{ + /** + * List a repo's tracked times. + * + * @param string $ownerName The owner name. + * @param string $repoName The repository name. + * @param string $user Optional filter by user (available for issue managers). + * @param string $since Only show times updated after the given time. This is a timestamp in RFC 3339 format. + * @param string $before Only show times updated before the given time. This is a timestamp in RFC 3339 format. + * @param int $page The page number of results to return (1-based). + * @param int $limit The page size of results. + * + * @return array|null + * @since 3.2.0 + **/ + public function list( + string $ownerName, + string $repoName, + string $user = null, + string $since = null, + string $before = null, + int $page = 1, + int $limit = 10 + ): ?array + { + // Build the request path. + $path = "/repos/{$ownerName}/{$repoName}/times"; + + // Set the query parameters. + $uri = $this->uri->get($path); + + if ($user !== null) + { + $uri->setVar('user', $user); + } + + if ($since !== null) + { + $uri->setVar('since', $since); + } + + if ($before !== null) + { + $uri->setVar('before', $before); + } + + $uri->setVar('page', $page); + $uri->setVar('limit', $limit); + + // Send the get request. + return $this->response->get( + $this->http->get($uri) + ); + } + +} + diff --git a/libraries/jcb_powers/VDM.Joomla.Gitea/src/Repository/Topics.php b/libraries/jcb_powers/VDM.Joomla.Gitea/src/Repository/Topics.php new file mode 100644 index 0000000..bbd24b8 --- /dev/null +++ b/libraries/jcb_powers/VDM.Joomla.Gitea/src/Repository/Topics.php @@ -0,0 +1,175 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ + +namespace VDM\Joomla\Gitea\Repository; + + +use VDM\Joomla\Gitea\Abstraction\Api; + + +/** + * The Gitea Repository Topics + * + * @since 3.2.0 + */ +class Topics extends Api +{ + /** + * Get the list of topics that a repository has. + * + * @param string $owner The owner name. + * @param string $repo The repository name. + * @param int $page The page number of results to return (1-based). + * @param int $limit The page size of results. + * + * @return object|null + * @since 3.2.0 + **/ + public function get( + string $owner, + string $repo, + int $page = 1, + int $limit = 10 + ): ?object + { + // Build the request path. + $path = "/repos/{$owner}/{$repo}/topics"; + + // Set query parameters for pagination. + $uri = $this->uri->get($path); + $uri->setVar('page', $page); + $uri->setVar('limit', $limit); + + // Send the get request. + return $this->response->get( + $this->http->get($uri) + ); + } + + /** + * Replace the list of topics for a repository. + * + * @param string $ownerName The owner name. + * @param string $repoName The repository name. + * @param array $topicNames The new list of topics. + * + * @return string + * @since 3.2.0 + **/ + public function replace( + string $ownerName, + string $repoName, + array $topicNames + ): string + { + // Build the request path. + $path = "/repos/{$ownerName}/{$repoName}/topics"; + + // Set the topics data. + $data = new \stdClass(); + $data->topics = $topicNames; + + // Send the put request. + return $this->response->get( + $this->http->put( + $this->uri->get($path), + json_encode($data) + ), 204, 'success' + ); + } + + /** + * Add a topic to a repository. + * + * @param string $ownerName The owner name. + * @param string $repoName The repository name. + * @param string $topicName The topic to add. + * + * @return string + * @since 3.2.0 + **/ + public function add( + string $ownerName, + string $repoName, + string $topicName + ): string + { + // Build the request path. + $path = "/repos/{$ownerName}/{$repoName}/topics/{$topicName}"; + + // Send the put request. + return $this->response->get( + $this->http->put( + $this->uri->get($path), '' + ), 204, 'success' + ); + } + + /** + * Delete a topic from a repository. + * + * @param string $ownerName The owner name. + * @param string $repoName The repository name. + * @param string $topicName The topic to delete. + * + * @return string + * @since 3.2.0 + **/ + public function delete( + string $ownerName, + string $repoName, + string $topicName + ): string + { + // Build the request path. + $path = "/repos/{$ownerName}/{$repoName}/topics/{$topicName}"; + + // Send the delete request. + return $this->response->get( + $this->http->delete( + $this->uri->get($path) + ), 204, 'success' + ); + } + + /** + * Search topics via keyword. + * + * @param string $searchKeyword The keyword to search for. + * @param int $page The page number of results to return (1-based). + * @param int $limit The page size of results. + * + * @return array|null + * @since 3.2.0 + **/ + public function search( + string $searchKeyword, + int $page = 1, + int $limit = 10 + ): ?array + { + // Build the request path. + $path = "/topics/search"; + + // Set the query parameters. + $uri = $this->uri->get($path); + $uri->setVar('q', $searchKeyword); + $uri->setVar('page', $page); + $uri->setVar('limit', $limit); + + // Send the get request. + return $this->response->get( + $this->http->get($uri) + ); + } + +} + diff --git a/libraries/jcb_powers/VDM.Joomla.Gitea/src/Repository/Transfer.php b/libraries/jcb_powers/VDM.Joomla.Gitea/src/Repository/Transfer.php new file mode 100644 index 0000000..b2e80be --- /dev/null +++ b/libraries/jcb_powers/VDM.Joomla.Gitea/src/Repository/Transfer.php @@ -0,0 +1,108 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ + +namespace VDM\Joomla\Gitea\Repository; + + +use VDM\Joomla\Gitea\Abstraction\Api; + + +/** + * The Gitea Repository Transfer + * + * @since 3.2.0 + */ +class Transfer extends Api +{ + /** + * Transfer a repo ownership. + * + * @param string $owner The current owner name. + * @param string $repo The repository name. + * @param string $newOwner The new owner's name. + * @param array|null $teamIDs Optional. The IDs of the teams that will be granted access. + * + * @return object|null + * @since 3.2.0 + **/ + public function create( + string $owner, + string $repo, + string $newOwner, + ?array $teamIDs = null + ): ?object + { + // Build the request path. + $path = "/repos/{$owner}/{$repo}/transfer"; + + // Set the transfer data. + $data = new \stdClass(); + $data->new_owner = $newOwner; + if ($teamIDs !== null) + { + $data->team_ids = $teamIDs; + } + + // Send the post request. + return $this->response->get( + $this->http->post( + $this->uri->get($path), + json_encode($data) + ), 202 + ); + } + + /** + * Accept a repo transfer. + * + * @param string $owner The owner name. + * @param string $repo The repository name. + * + * @return object|null + * @since 3.2.0 + **/ + public function accept(string $owner, string $repo): ?object + { + // Build the request path. + $path = "/repos/{$owner}/{$repo}/transfer/accept"; + + // Send the post request. + return $this->response->get( + $this->http->post( + $this->uri->get($path) + ), 202 + ); + } + + /** + * Reject a repo transfer. + * + * @param string $owner The owner name. + * @param string $repo The repository name. + * + * @return object|null + * @since 3.2.0 + **/ + public function reject(string $owner, string $repo): ?object + { + // Build the request path. + $path = "/repos/{$owner}/{$repo}/transfer/reject"; + + // Send the post request. + return $this->response->get( + $this->http->post( + $this->uri->get($path) + ) + ); + } + +} + diff --git a/libraries/jcb_powers/VDM.Joomla.Gitea/src/Repository/Trees.php b/libraries/jcb_powers/VDM.Joomla.Gitea/src/Repository/Trees.php new file mode 100644 index 0000000..a9e1974 --- /dev/null +++ b/libraries/jcb_powers/VDM.Joomla.Gitea/src/Repository/Trees.php @@ -0,0 +1,63 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ + +namespace VDM\Joomla\Gitea\Repository; + + +use VDM\Joomla\Gitea\Abstraction\Api; + + +/** + * The Gitea Repository Trees + * + * @since 3.2.0 + */ +class Trees extends Api +{ + /** + * Get the tree of a repository. + * + * @param string $owner The owner name. + * @param string $repo The repository name. + * @param string $sha The commit SHA. + * @param bool $recursive Show all directories and files. + * @param int $page Page number. + * @param int $perPage Number of items per page. + * + * @return object|null + * @since 3.2.0 + **/ + public function get( + string $owner, + string $repo, + string $sha, + bool $recursive = false, + int $page = 1, + int $perPage = 30 + ): ?object + { + // Build the request path. + $path = "/repos/{$owner}/{$repo}/git/trees/{$sha}"; + + // Set URI variables. + $uri = $this->uri->get($path); + $uri->setVar('recursive', $recursive); + $uri->setVar('page', $page); + $uri->setVar('per_page', $perPage); + + // Send the get request. + return $this->response->get( + $this->http->get($uri) + ); + } + +} + diff --git a/libraries/jcb_powers/VDM.Joomla.Gitea/src/Repository/Watchers.php b/libraries/jcb_powers/VDM.Joomla.Gitea/src/Repository/Watchers.php new file mode 100644 index 0000000..131482a --- /dev/null +++ b/libraries/jcb_powers/VDM.Joomla.Gitea/src/Repository/Watchers.php @@ -0,0 +1,140 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ + +namespace VDM\Joomla\Gitea\Repository; + + +use VDM\Joomla\Gitea\Abstraction\Api; + + +/** + * The Gitea Repository Watchers + * + * @since 3.2.0 + */ +class Watchers extends Api +{ + /** + * List a repo's watchers. + * + * @param string $ownerName The owner name. + * @param string $repoName The repository name. + * @param int $page Page number of results to return (1-based). + * @param int $limit Page size of results. + * + * @return array|null + * @since 3.2.0 + **/ + public function list( + string $ownerName, + string $repoName, + int $page = 1, + int $limit = 10 + ): ?array + { + // Build the request path. + $path = "/repos/{$ownerName}/{$repoName}/subscribers"; + + // Prepare the URI with the path. + $uri = $this->uri->get($path); + + // Set the page and limit query parameters. + $uri->setVar('page', $page); + $uri->setVar('limit', $limit); + + // Send the get request. + return $this->response->get( + $this->http->get($uri) + ); + } + + /** + * Check if the current user is watching a repo. + * + * @param string $ownerName The owner name. + * @param string $repoName The repository name. + * + * @return object|null + * @since 3.2.0 + **/ + public function check(string $ownerName, string $repoName): ?object + { + // Build the request path. + $path = "/repos/{$ownerName}/{$repoName}/subscription"; + + // Prepare the URI with the path. + $uri = $this->uri->get($path); + + // Send the get request. + return $this->response->get( + $this->http->get($uri) + ); + } + + /** + * Watch a repo. + * + * @param string $ownerName The owner name. + * @param string $repoName The repository name. + * @param bool $subscribed Determine if notifications should be received from this repository. + * @param bool $ignored Determine if all notifications should be blocked from this repository. + * + * @return object|null + * @since 3.2.0 + **/ + public function watch( + string $ownerName, + string $repoName, + bool $subscribed = true, + bool $ignored = false + ): ?object + { + // Build the request path. + $path = "/repos/{$ownerName}/{$repoName}/subscription"; + + // Set the subscription data + $data = new \stdClass(); + $data->subscribed = $subscribed; + $data->ignored = $ignored; + + // Send the put request. + return $this->response->get( + $this->http->put( + $this->uri->get($path), json_encode($data) + ) + ); + } + + /** + * Unwatch a repo. + * + * @param string $ownerName The owner name. + * @param string $repoName The repository name. + * + * @return string + * @since 3.2.0 + **/ + public function unwatch(string $ownerName, string $repoName): string + { + // Build the request path. + $path = "/repos/{$ownerName}/{$repoName}/subscription"; + + // Prepare the URI with the path. + $uri = $this->uri->get($path); + + // Send the delete request. + return $this->response->get( + $this->http->delete($uri), 204, 'success' + ); + } + +} + diff --git a/libraries/jcb_powers/VDM.Joomla.Gitea/src/Repository/Wiki.php b/libraries/jcb_powers/VDM.Joomla.Gitea/src/Repository/Wiki.php new file mode 100644 index 0000000..7488608 --- /dev/null +++ b/libraries/jcb_powers/VDM.Joomla.Gitea/src/Repository/Wiki.php @@ -0,0 +1,232 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ + +namespace VDM\Joomla\Gitea\Repository; + + +use VDM\Joomla\Gitea\Abstraction\Api; + + +/** + * The Gitea Repository Wiki + * + * @since 3.2.0 + */ +class Wiki extends Api +{ + /** + * Create a wiki page. + * + * @param string $owner The owner name. + * @param string $repo The repository name. + * @param string $title The title of the wiki page. + * @param string $contentBase64 The base64 encoded content of the wiki page. + * @param string|null $message Optional commit message summarizing the change. + * + * @return object|null + * @since 3.2.0 + **/ + public function create( + string $owner, + string $repo, + string $title, + string $contentBase64, + ?string $message = null + ): ?object + { + // Build the request path. + $path = "/repos/{$owner}/{$repo}/wiki/new"; + + // Set the wiki data. + $data = new \stdClass(); + $data->title = $title; + $data->content_base64 = $contentBase64; + + if ($message !== null) + { + $data->message = $message; + } + + // Send the post request. + return $this->response->get( + $this->http->post( + $this->uri->get($path), + json_encode($data) + ), 201 + ); + } + + /** + * Get a wiki page. + * + * @param string $owner The owner name. + * @param string $repo The repository name. + * @param string $pageName The name of the wiki page. + * + * @return object|null + * @since 3.2.0 + **/ + public function get( + string $owner, + string $repo, + string $pageName + ): ?object + { + // Build the request path. + $path = "/repos/{$owner}/{$repo}/wiki/page/{$pageName}"; + + // Set the URI. + $uri = $this->uri->get($path); + + // Send the get request. + return $this->response->get( + $this->http->get($uri) + ); + } + + /** + * Get all wiki pages. + * + * @param string $owner The owner name. + * @param string $repo The repository name. + * @param int $page Page number of results to return (1-based). + * @param int $limit Page size of results. + * + * @return array|null + * @since 3.2.0 + **/ + public function pages( + string $owner, + string $repo, + int $page = 1, + int $limit = 10 + ): ?array + { + // Build the request path. + $path = "/repos/{$owner}/{$repo}/wiki/pages"; + + // Set the URI. + $uri = $this->uri->get($path); + $uri->setVar('page', $page); + $uri->setVar('limit', $limit); + + // Send the get request. + return $this->response->get( + $this->http->get($uri) + ); + } + + /** + * Delete a wiki page. + * + * @param string $owner The owner name. + * @param string $repo The repository name. + * @param string $pageName The name of the wiki page. + * + * @return string + * @since 3.2.0 + **/ + public function delete( + string $owner, + string $repo, + string $pageName + ): string + { + // Build the request path. + $path = "/repos/{$owner}/{$repo}/wiki/page/{$pageName}"; + + // Get the URI. + $uri = $this->uri->get($path); + + // Send the delete request. + return $this->response->get( + $this->http->delete($uri), 204, 'success' + ); + } + + /** + * Edit a wiki page. + * + * @param string $owner The owner name. + * @param string $repo The repository name. + * @param string $pageName The name of the wiki page. + * @param string $title The new title of the wiki page. + * @param string $content The new content of the wiki page. + * @param string $message The optional commit message summarizing the change. + * + * @return object|null + * @since 3.2.0 + **/ + public function edit( + string $owner, + string $repo, + string $pageName, + string $title, + string $content, + string $message = null + ): ?object + { + // Build the request path. + $path = "/repos/{$owner}/{$repo}/wiki/page/{$pageName}"; + + // Set the wiki data. + $data = new \stdClass(); + $data->title = $title; + $data->content_base64 = base64_encode($content); + + if ($message !== null) + { + $data->message = $message; + } + + // Send the patch request. + return $this->response->get( + $this->http->patch( + $this->uri->get($path), + json_encode($data) + ) + ); + } + + /** + * Get revisions of a wiki page. + * + * @param string $owner The owner name. + * @param string $repo The repository name. + * @param string $pageName The name of the wiki page. + * @param int $page The page number of results to return (1-based). + * + * @return object|null + * @since 3.2.0 + **/ + public function revisions( + string $owner, + string $repo, + string $pageName, + int $page = 1 + ): ?object + { + // Build the request path. + $path = "/repos/{$owner}/{$repo}/wiki/revisions/{$pageName}"; + + // Set the page number. + $this->uri->setVar('page', $page); + + // Send the get request. + return $this->response->get( + $this->http->get( + $this->uri->get($path) + ) + ); + } + +} + diff --git a/libraries/jcb_powers/VDM.Joomla.Gitea/src/Repository/index.html b/libraries/jcb_powers/VDM.Joomla.Gitea/src/Repository/index.html new file mode 100644 index 0000000..fa6d84e --- /dev/null +++ b/libraries/jcb_powers/VDM.Joomla.Gitea/src/Repository/index.html @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/libraries/jcb_powers/VDM.Joomla.Gitea/src/Service/Admin.php b/libraries/jcb_powers/VDM.Joomla.Gitea/src/Service/Admin.php new file mode 100644 index 0000000..be64aa1 --- /dev/null +++ b/libraries/jcb_powers/VDM.Joomla.Gitea/src/Service/Admin.php @@ -0,0 +1,185 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ + +namespace VDM\Joomla\Gitea\Service; + + +use Joomla\DI\Container; +use Joomla\DI\ServiceProviderInterface; +use VDM\Joomla\Gitea\Admin\Cron; +use VDM\Joomla\Gitea\Admin\Organizations; +use VDM\Joomla\Gitea\Admin\Unadopted; +use VDM\Joomla\Gitea\Admin\Users; +use VDM\Joomla\Gitea\Admin\Users\Keys; +use VDM\Joomla\Gitea\Admin\Users\Organization; +use VDM\Joomla\Gitea\Admin\Users\Repository; + + +/** + * The Gitea Admin Service + * + * @since 3.2.0 + */ +class Admin implements ServiceProviderInterface +{ + /** + * Registers the service provider with a DI container. + * + * @param Container $container The DI container. + * + * @return void + * @since 3.2.0 + */ + public function register(Container $container) + { + $container->alias(Cron::class, 'Gitea.Admin.Cron') + ->share('Gitea.Admin.Cron', [$this, 'getCron'], true); + + $container->alias(Organizations::class, 'Gitea.Admin.Organizations') + ->share('Gitea.Admin.Organizations', [$this, 'getOrganizations'], true); + + $container->alias(Unadopted::class, 'Gitea.Admin.Unadopted') + ->share('Gitea.Admin.Unadopted', [$this, 'getUnadopted'], true); + + $container->alias(Users::class, 'Gitea.Admin.Users') + ->share('Gitea.Admin.Users', [$this, 'getUsers'], true); + + $container->alias(Keys::class, 'Gitea.Admin.Users.Keys') + ->share('Gitea.Admin.Users.Keys', [$this, 'getKeys'], true); + + $container->alias(Organization::class, 'Gitea.Admin.Users.Organization') + ->share('Gitea.Admin.Users.Organization', [$this, 'getOrganization'], true); + + $container->alias(Repository::class, 'Gitea.Admin.Users.Repository') + ->share('Gitea.Admin.Users.Repository', [$this, 'getRepository'], true); + } + + /** + * Get the Cron class + * + * @param Container $container The DI container. + * + * @return Cron + * @since 3.2.0 + */ + public function getCron(Container $container): Cron + { + return new Cron( + $container->get('Gitea.Utilities.Http'), + $container->get('Gitea.Dynamic.Uri'), + $container->get('Gitea.Utilities.Response') + ); + } + + /** + * Get the Organizations class + * + * @param Container $container The DI container. + * + * @return Organizations + * @since 3.2.0 + */ + public function getOrganizations(Container $container): Organizations + { + return new Organizations( + $container->get('Gitea.Utilities.Http'), + $container->get('Gitea.Dynamic.Uri'), + $container->get('Gitea.Utilities.Response') + ); + } + + /** + * Get the Unadopted class + * + * @param Container $container The DI container. + * + * @return Unadopted + * @since 3.2.0 + */ + public function getUnadopted(Container $container): Unadopted + { + return new Unadopted( + $container->get('Gitea.Utilities.Http'), + $container->get('Gitea.Dynamic.Uri'), + $container->get('Gitea.Utilities.Response') + ); + } + + /** + * Get the Users class + * + * @param Container $container The DI container. + * + * @return Users + * @since 3.2.0 + */ + public function getUsers(Container $container): Users + { + return new Users( + $container->get('Gitea.Utilities.Http'), + $container->get('Gitea.Dynamic.Uri'), + $container->get('Gitea.Utilities.Response') + ); + } + + /** + * Get the Keys class + * + * @param Container $container The DI container. + * + * @return Keys + * @since 3.2.0 + */ + public function getKeys(Container $container): Keys + { + return new Keys( + $container->get('Gitea.Utilities.Http'), + $container->get('Gitea.Dynamic.Uri'), + $container->get('Gitea.Utilities.Response') + ); + } + + /** + * Get the Organization class + * + * @param Container $container The DI container. + * + * @return Organization + * @since 3.2.0 + */ + public function getOrganization(Container $container): Organization + { + return new Organization( + $container->get('Gitea.Utilities.Http'), + $container->get('Gitea.Dynamic.Uri'), + $container->get('Gitea.Utilities.Response') + ); + } + + /** + * Get the Repository class + * + * @param Container $container The DI container. + * + * @return Repository + * @since 3.2.0 + */ + public function getRepository(Container $container): Repository + { + return new Repository( + $container->get('Gitea.Utilities.Http'), + $container->get('Gitea.Dynamic.Uri'), + $container->get('Gitea.Utilities.Response') + ); + } + +} + diff --git a/libraries/jcb_powers/VDM.Joomla.Gitea/src/Service/Issue.php b/libraries/jcb_powers/VDM.Joomla.Gitea/src/Service/Issue.php new file mode 100644 index 0000000..9c49a5a --- /dev/null +++ b/libraries/jcb_powers/VDM.Joomla.Gitea/src/Service/Issue.php @@ -0,0 +1,294 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ + +namespace VDM\Joomla\Gitea\Service; + + +use Joomla\DI\Container; +use Joomla\DI\ServiceProviderInterface; +use VDM\Joomla\Gitea\Issue as Issu; +use VDM\Joomla\Gitea\Issue\Comments; +use VDM\Joomla\Gitea\Issue\Repository\Comments as RepoComments; +use VDM\Joomla\Gitea\Issue\Deadline; +use VDM\Joomla\Gitea\Labels; +use VDM\Joomla\Gitea\Issue\Labels as IssueLabels; +use VDM\Joomla\Gitea\Issue\Milestones; +use VDM\Joomla\Gitea\Issue\Reactions; +use VDM\Joomla\Gitea\Issue\Reactions\Comment; +use VDM\Joomla\Gitea\Issue\Stopwatch; +use VDM\Joomla\Gitea\Issue\Subscriptions; +use VDM\Joomla\Gitea\Issue\Timeline; +use VDM\Joomla\Gitea\Issue\Times; + + +/** + * The Gitea Issue Service + * + * @since 3.2.0 + */ +class Issue implements ServiceProviderInterface +{ + /** + * Registers the service provider with a DI container. + * + * @param Container $container The DI container. + * + * @return void + * @since 3.2.0 + */ + public function register(Container $container) + { + $container->alias(Issu::class, 'Gitea.Issue') + ->share('Gitea.Issue', [$this, 'getIssue'], true); + + $container->alias(Comments::class, 'Gitea.Issue.Comments') + ->share('Gitea.Issue.Comments', [$this, 'getComments'], true); + + $container->alias(RepoComments::class, 'Gitea.Issue.Repository.Comments') + ->share('Gitea.Issue.Repository.Comments', [$this, 'getRepoComments'], true); + + $container->alias(Deadline::class, 'Gitea.Issue.Deadline') + ->share('Gitea.Issue.Deadline', [$this, 'getDeadline'], true); + + $container->alias(Labels::class, 'Gitea.Labels') + ->share('Gitea.Labels', [$this, 'getLabels'], true); + + $container->alias(IssueLabels::class, 'Gitea.Issue.Labels') + ->share('Gitea.Issue.Labels', [$this, 'getIssueLabels'], true); + + $container->alias(Milestones::class, 'Gitea.Issue.Milestones') + ->share('Gitea.Issue.Milestones', [$this, 'getMilestones'], true); + + $container->alias(Reactions::class, 'Gitea.Issue.Reactions') + ->share('Gitea.Issue.Reactions', [$this, 'getReactions'], true); + + $container->alias(Comment::class, 'Gitea.Issue.Reactions.Comment') + ->share('Gitea.Issue.Reactions.Comment', [$this, 'getComment'], true); + + $container->alias(Stopwatch::class, 'Gitea.Issue.Stopwatch') + ->share('Gitea.Issue.Stopwatch', [$this, 'getStopwatch'], true); + + $container->alias(Subscriptions::class, 'Gitea.Issue.Subscriptions') + ->share('Gitea.Issue.Subscriptions', [$this, 'getSubscriptions'], true); + + $container->alias(Timeline::class, 'Gitea.Issue.Timeline') + ->share('Gitea.Issue.Timeline', [$this, 'getTimeline'], true); + + $container->alias(Times::class, 'Gitea.Issue.Times') + ->share('Gitea.Issue.Times', [$this, 'getTimes'], true); + } + + /** + * Get the Issue class + * + * @param Container $container The DI container. + * + * @return Issu + * @since 3.2.0 + */ + public function getIssue(Container $container): Issu + { + return new Issu( + $container->get('Gitea.Utilities.Http'), + $container->get('Gitea.Dynamic.Uri'), + $container->get('Gitea.Utilities.Response') + ); + } + + /** + * Get the Comments class + * + * @param Container $container The DI container. + * + * @return Comments + * @since 3.2.0 + */ + public function getComments(Container $container): Comments + { + return new Comments( + $container->get('Gitea.Utilities.Http'), + $container->get('Gitea.Dynamic.Uri'), + $container->get('Gitea.Utilities.Response') + ); + } + + /** + * Get the Repository Comments class + * + * @param Container $container The DI container. + * + * @return RepoComments + * @since 3.2.0 + */ + public function getRepoComments(Container $container): RepoComments + { + return new RepoComments( + $container->get('Gitea.Utilities.Http'), + $container->get('Gitea.Dynamic.Uri'), + $container->get('Gitea.Utilities.Response') + ); + } + + /** + * Get the Labels class + * + * @param Container $container The DI container. + * + * @return Labels + * @since 3.2.0 + */ + public function getLabels(Container $container): Labels + { + return new Labels( + $container->get('Gitea.Utilities.Http'), + $container->get('Gitea.Dynamic.Uri'), + $container->get('Gitea.Utilities.Response') + ); + } + + /** + * Get the Issue Labels class + * + * @param Container $container The DI container. + * + * @return IssueLabels + * @since 3.2.0 + */ + public function getIssueLabels(Container $container): IssueLabels + { + return new IssueLabels( + $container->get('Gitea.Utilities.Http'), + $container->get('Gitea.Dynamic.Uri'), + $container->get('Gitea.Utilities.Response') + ); + } + + /** + * Get the Milestones class + * + * @param Container $container The DI container. + * + * @return Milestones + * @since 3.2.0 + */ + public function getMilestones(Container $container): Milestones + { + return new Milestones( + $container->get('Gitea.Utilities.Http'), + $container->get('Gitea.Dynamic.Uri'), + $container->get('Gitea.Utilities.Response') + ); + } + + /** + * Get the Reactions class + * + * @param Container $container The DI container. + * + * @return Reactions + * @since 3.2.0 + */ + public function getReactions(Container $container): Reactions + { + return new Reactions( + $container->get('Gitea.Utilities.Http'), + $container->get('Gitea.Dynamic.Uri'), + $container->get('Gitea.Utilities.Response') + ); + } + + /** + * Get the Reactions Comment class + * + * @param Container $container The DI container. + * + * @return Comment + * @since 3.2.0 + */ + public function getComment(Container $container): Comment + { + return new Comment( + $container->get('Gitea.Utilities.Http'), + $container->get('Gitea.Dynamic.Uri'), + $container->get('Gitea.Utilities.Response') + ); + } + + /** + * Get the Stopwatch class + * + * @param Container $container The DI container. + * + * @return Stopwatch + * @since 3.2.0 + */ + public function getStopwatch(Container $container): Stopwatch + { + return new Stopwatch( + $container->get('Gitea.Utilities.Http'), + $container->get('Gitea.Dynamic.Uri'), + $container->get('Gitea.Utilities.Response') + ); + } + + /** + * Get the Subscriptions class + * + * @param Container $container The DI container. + * + * @return Subscriptions + * @since 3.2.0 + */ + public function getSubscriptions(Container $container): Subscriptions + { + return new Subscriptions( + $container->get('Gitea.Utilities.Http'), + $container->get('Gitea.Dynamic.Uri'), + $container->get('Gitea.Utilities.Response') + ); + } + + /** + * Get the Timeline class + * + * @param Container $container The DI container. + * + * @return Timeline + * @since 3.2.0 + */ + public function getTimeline(Container $container): Timeline + { + return new Timeline( + $container->get('Gitea.Utilities.Http'), + $container->get('Gitea.Dynamic.Uri'), + $container->get('Gitea.Utilities.Response') + ); + } + + /** + * Get the Times class + * + * @param Container $container The DI container. + * + * @return Times + * @since 3.2.0 + */ + public function getTimes(Container $container): Times + { + return new Times( + $container->get('Gitea.Utilities.Http'), + $container->get('Gitea.Dynamic.Uri'), + $container->get('Gitea.Utilities.Response') + ); + } + +} + diff --git a/libraries/jcb_powers/VDM.Joomla.Gitea/src/Service/Jcb.php b/libraries/jcb_powers/VDM.Joomla.Gitea/src/Service/Jcb.php new file mode 100644 index 0000000..5e6a7a8 --- /dev/null +++ b/libraries/jcb_powers/VDM.Joomla.Gitea/src/Service/Jcb.php @@ -0,0 +1,85 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ + +namespace VDM\Joomla\Gitea\Service; + + +use Joomla\DI\Container; +use Joomla\DI\ServiceProviderInterface; +use VDM\Joomla\Gitea\Utilities\Uri; +use VDM\Joomla\Gitea\Utilities\Http; +use VDM\Joomla\Utilities\Component\Helper; + + +/** + * The Gitea Utilities Service + * + * @since 3.2.0 + */ +class Jcb implements ServiceProviderInterface +{ + /** + * Registers the service provider with a DI container. + * + * @param Container $container The DI container. + * + * @return void + * @since 3.2.0 + */ + public function register(Container $container) + { + $container->alias(Uri::class, 'Gitea.Dynamic.Uri') + ->share('Gitea.Dynamic.Uri', [$this, 'getUri'], true); + + $container->alias(Http::class, 'Gitea.Utilities.Http') + ->share('Gitea.Utilities.Http', [$this, 'getHttp'], true); + } + + /** + * Get the Dynamic Uri class + * + * @param Container $container The DI container. + * + * @return Uri + * @since 3.2.0 + */ + public function getUri(Container $container): Uri + { + // get the global gitea URL + $add_gitea_url = Helper::getParams('com_componentbuilder')->get('add_custom_gitea_url', 1); + $gitea_url = Helper::getParams('com_componentbuilder')->get('custom_gitea_url'); + + // only load this if we have a custom URL set + if ($add_gitea_url == 2 && is_string($gitea_url) && strpos($gitea_url, 'http') !== false) + { + return new Uri($gitea_url); + } + + return $container->get('Gitea.Utilities.Uri'); + } + + /** + * Get the Http class + * + * @param Container $container The DI container. + * + * @return Http + * @since 3.2.0 + */ + public function getHttp(Container $container): Http + { + return new Http( + Helper::getParams('com_componentbuilder')->get('gitea_token') + ); + } + +} + diff --git a/libraries/jcb_powers/VDM.Joomla.Gitea/src/Service/Miscellaneous.php b/libraries/jcb_powers/VDM.Joomla.Gitea/src/Service/Miscellaneous.php new file mode 100644 index 0000000..14abf45 --- /dev/null +++ b/libraries/jcb_powers/VDM.Joomla.Gitea/src/Service/Miscellaneous.php @@ -0,0 +1,143 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ + +namespace VDM\Joomla\Gitea\Service; + + +use Joomla\DI\Container; +use Joomla\DI\ServiceProviderInterface; +use VDM\Joomla\Gitea\Miscellaneous\Activitypub; +use VDM\Joomla\Gitea\Miscellaneous\Gpg; +use VDM\Joomla\Gitea\Miscellaneous\Markdown; +use VDM\Joomla\Gitea\Miscellaneous\NodeInfo; +use VDM\Joomla\Gitea\Miscellaneous\Version; + + +/** + * The Gitea Miscellaneous Service + * + * @since 3.2.0 + */ +class Miscellaneous implements ServiceProviderInterface +{ + /** + * Registers the service provider with a DI container. + * + * @param Container $container The DI container. + * + * @return void + * @since 3.2.0 + */ + public function register(Container $container) + { + $container->alias(Activitypub::class, 'Gitea.Miscellaneous.Activitypub') + ->share('Gitea.Miscellaneous.Activitypub', [$this, 'getActivitypub'], true); + + $container->alias(Gpg::class, 'Gitea.Miscellaneous.Gpg') + ->share('Gitea.Miscellaneous.Gpg', [$this, 'getGpg'], true); + + $container->alias(Markdown::class, 'Gitea.Miscellaneous.Markdown') + ->share('Gitea.Miscellaneous.Markdown', [$this, 'getMarkdown'], true); + + $container->alias(NodeInfo::class, 'Gitea.Miscellaneous.NodeInfo') + ->share('Gitea.Miscellaneous.NodeInfo', [$this, 'getNodeInfo'], true); + + $container->alias(Version::class, 'Gitea.Miscellaneous.Version') + ->share('Gitea.Miscellaneous.Version', [$this, 'getVersion'], true); + } + + /** + * Get the Activitypub class + * + * @param Container $container The DI container. + * + * @return Activitypub + * @since 3.2.0 + */ + public function getActivitypub(Container $container): Activitypub + { + return new Activitypub( + $container->get('Gitea.Utilities.Http'), + $container->get('Gitea.Dynamic.Uri'), + $container->get('Gitea.Utilities.Response') + ); + } + + /** + * Get the Gpg class + * + * @param Container $container The DI container. + * + * @return Gpg + * @since 3.2.0 + */ + public function getGpg(Container $container): Gpg + { + return new Gpg( + $container->get('Gitea.Utilities.Http'), + $container->get('Gitea.Dynamic.Uri'), + $container->get('Gitea.Utilities.Response') + ); + } + + /** + * Get the Markdown class + * + * @param Container $container The DI container. + * + * @return Markdown + * @since 3.2.0 + */ + public function getMarkdown(Container $container): Markdown + { + return new Markdown( + $container->get('Gitea.Utilities.Http'), + $container->get('Gitea.Dynamic.Uri'), + $container->get('Gitea.Utilities.Response') + ); + } + + /** + * Get the NodeInfo class + * + * @param Container $container The DI container. + * + * @return NodeInfo + * @since 3.2.0 + */ + public function getNodeInfo(Container $container): NodeInfo + { + return new NodeInfo( + $container->get('Gitea.Utilities.Http'), + $container->get('Gitea.Dynamic.Uri'), + $container->get('Gitea.Utilities.Response') + ); + } + + /** + * Get the Version class + * + * @param Container $container The DI container. + * + * @return Version + * @since 3.2.0 + */ + public function getVersion(Container $container): Version + { + return new Version( + $container->get('Gitea.Utilities.Http'), + $container->get('Gitea.Dynamic.Uri'), + $container->get('Gitea.Utilities.Response') + ); + } + +} + diff --git a/libraries/jcb_powers/VDM.Joomla.Gitea/src/Service/Notifications.php b/libraries/jcb_powers/VDM.Joomla.Gitea/src/Service/Notifications.php new file mode 100644 index 0000000..b6b5a29 --- /dev/null +++ b/libraries/jcb_powers/VDM.Joomla.Gitea/src/Service/Notifications.php @@ -0,0 +1,101 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ + +namespace VDM\Joomla\Gitea\Service; + + +use Joomla\DI\Container; +use Joomla\DI\ServiceProviderInterface; +use VDM\Joomla\Gitea\Notifications as Notifi; +use VDM\Joomla\Gitea\Notifications\Repository; +use VDM\Joomla\Gitea\Notifications\Thread; + + +/** + * The Gitea Notifications Service + * + * @since 3.2.0 + */ +class Notifications implements ServiceProviderInterface +{ + /** + * Registers the service provider with a DI container. + * + * @param Container $container The DI container. + * + * @return void + * @since 3.2.0 + */ + public function register(Container $container) + { + $container->alias(Notifi::class, 'Gitea.Notifications') + ->share('Gitea.Notifications', [$this, 'getNotifications'], true); + + $container->alias(Repository::class, 'Gitea.Notifications.Repository') + ->share('Gitea.Notifications.Repository', [$this, 'getRepository'], true); + + $container->alias(Thread::class, 'Gitea.Notifications.Thread') + ->share('Gitea.Notifications.Thread', [$this, 'getThread'], true); + } + + /** + * Get the Notifications class + * + * @param Container $container The DI container. + * + * @return Notifi + * @since 3.2.0 + */ + public function getNotifications(Container $container): Notifi + { + return new Notifi( + $container->get('Gitea.Utilities.Http'), + $container->get('Gitea.Dynamic.Uri'), + $container->get('Gitea.Utilities.Response') + ); + } + + /** + * Get the Repository class + * + * @param Container $container The DI container. + * + * @return Repository + * @since 3.2.0 + */ + public function getRepository(Container $container): Repository + { + return new Repository( + $container->get('Gitea.Utilities.Http'), + $container->get('Gitea.Dynamic.Uri'), + $container->get('Gitea.Utilities.Response') + ); + } + + /** + * Get the Thread class + * + * @param Container $container The DI container. + * + * @return Thread + * @since 3.2.0 + */ + public function getThread(Container $container): Thread + { + return new Thread( + $container->get('Gitea.Utilities.Http'), + $container->get('Gitea.Dynamic.Uri'), + $container->get('Gitea.Utilities.Response') + ); + } + +} + diff --git a/libraries/jcb_powers/VDM.Joomla.Gitea/src/Service/Organization.php b/libraries/jcb_powers/VDM.Joomla.Gitea/src/Service/Organization.php new file mode 100644 index 0000000..dab899e --- /dev/null +++ b/libraries/jcb_powers/VDM.Joomla.Gitea/src/Service/Organization.php @@ -0,0 +1,248 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ + +namespace VDM\Joomla\Gitea\Service; + + +use Joomla\DI\Container; +use Joomla\DI\ServiceProviderInterface; +use VDM\Joomla\Gitea\Organization as Org; +use VDM\Joomla\Gitea\Organization\Hooks; +use VDM\Joomla\Gitea\Organization\Labels; +use VDM\Joomla\Gitea\Organization\Members; +use VDM\Joomla\Gitea\Organization\PublicMembers as PublicMembers; +use VDM\Joomla\Gitea\Organization\Repository; +use VDM\Joomla\Gitea\Organization\Teams; +use VDM\Joomla\Gitea\Organization\Teams\Members as TeamsMembers; +use VDM\Joomla\Gitea\Organization\Teams\Repository as TeamsRepository; +use VDM\Joomla\Gitea\Organization\User; + + +/** + * The Gitea Organization Service + * + * @since 3.2.0 + */ +class Organization implements ServiceProviderInterface +{ + /** + * Registers the service provider with a DI container. + * + * @param Container $container The DI container. + * + * @return void + * @since 3.2.0 + */ + public function register(Container $container) + { + $container->alias(Org::class, 'Gitea.Organization') + ->share('Gitea.Organization', [$this, 'getOrganization'], true); + + $container->alias(Hooks::class, 'Gitea.Organization.Hooks') + ->share('Gitea.Organization.Hooks', [$this, 'getHooks'], true); + + $container->alias(Labels::class, 'Gitea.Organization.Labels') + ->share('Gitea.Organization.Labels', [$this, 'getLabels'], true); + + $container->alias(Members::class, 'Gitea.Organization.Members') + ->share('Gitea.Organization.Members', [$this, 'getMembers'], true); + + $container->alias(PublicMembers::class, 'Gitea.Organization.Public.Members') + ->share('Gitea.Organization.Public.Members', [$this, 'getPublicMembers'], true); + + $container->alias(Repository::class, 'Gitea.Organization.Repository') + ->share('Gitea.Organization.Repository', [$this, 'getRepository'], true); + + $container->alias(Teams::class, 'Gitea.Organization.Teams') + ->share('Gitea.Organization.Teams', [$this, 'getTeams'], true); + + $container->alias(TeamsMembers::class, 'Gitea.Organization.Teams.Members') + ->share('Gitea.Organization.Teams.Members', [$this, 'getTeamsMembers'], true); + + $container->alias(TeamsRepository::class, 'Gitea.Organization.Teams.Repository') + ->share('Gitea.Organization.Teams.Repository', [$this, 'getTeamsRepository'], true); + + $container->alias(User::class, 'Gitea.Organization.User') + ->share('Gitea.Organization.User', [$this, 'getUser'], true); + } + + /** + * Get the Organization class + * + * @param Container $container The DI container. + * + * @return Org + * @since 3.2.0 + */ + public function getOrganization(Container $container): Org + { + return new Org( + $container->get('Gitea.Utilities.Http'), + $container->get('Gitea.Dynamic.Uri'), + $container->get('Gitea.Utilities.Response') + ); + } + + /** + * Get the Hooks class + * + * @param Container $container The DI container. + * + * @return Hooks + * @since 3.2.0 + */ + public function getHooks(Container $container): Hooks + { + return new Hooks( + $container->get('Gitea.Utilities.Http'), + $container->get('Gitea.Dynamic.Uri'), + $container->get('Gitea.Utilities.Response') + ); + } + + /** + * Get the Labels class + * + * @param Container $container The DI container. + * + * @return Labels + * @since 3.2.0 + */ + public function getLabels(Container $container): Labels + { + return new Labels( + $container->get('Gitea.Utilities.Http'), + $container->get('Gitea.Dynamic.Uri'), + $container->get('Gitea.Utilities.Response') + ); + } + + /** + * Get the Members class + * + * @param Container $container The DI container. + * + * @return Members + * @since 3.2.0 + */ + public function getMembers(Container $container): Members + { + return new Members( + $container->get('Gitea.Utilities.Http'), + $container->get('Gitea.Dynamic.Uri'), + $container->get('Gitea.Utilities.Response') + ); + } + + /** + * Get the Public Members class + * + * @param Container $container The DI container. + * + * @return PublicMembers + * @since 3.2.0 + */ + public function getPublicMembers(Container $container): PublicMembers + { + return new PublicMembers( + $container->get('Gitea.Utilities.Http'), + $container->get('Gitea.Dynamic.Uri'), + $container->get('Gitea.Utilities.Response') + ); + } + + /** + * Get the Repository class + * + * @param Container $container The DI container. + * + * @return Repository + * @since 3.2.0 + */ + public function getRepository(Container $container): Repository + { + return new Repository( + $container->get('Gitea.Utilities.Http'), + $container->get('Gitea.Dynamic.Uri'), + $container->get('Gitea.Utilities.Response') + ); + } + + /** + * Get the Teams class + * + * @param Container $container The DI container. + * + * @return Teams + * @since 3.2.0 + */ + public function getTeams(Container $container): Teams + { + return new Teams( + $container->get('Gitea.Utilities.Http'), + $container->get('Gitea.Dynamic.Uri'), + $container->get('Gitea.Utilities.Response') + ); + } + + /** + * Get the Teams Members class + * + * @param Container $container The DI container. + * + * @return TeamsMembers + * @since 3.2.0 + */ + public function getTeamsMembers(Container $container): TeamsMembers + { + return new TeamsMembers( + $container->get('Gitea.Utilities.Http'), + $container->get('Gitea.Dynamic.Uri'), + $container->get('Gitea.Utilities.Response') + ); + } + + /** + * Get the Teams Repository class + * + * @param Container $container The DI container. + * + * @return TeamsRepository + * @since 3.2.0 + */ + public function getTeamsRepository(Container $container): TeamsRepository + { + return new TeamsRepository( + $container->get('Gitea.Utilities.Http'), + $container->get('Gitea.Dynamic.Uri'), + $container->get('Gitea.Utilities.Response') + ); + } + + /** + * Get the User class + * + * @param Container $container The DI container. + * + * @return User + * @since 3.2.0 + */ + public function getUser(Container $container): User + { + return new User( + $container->get('Gitea.Utilities.Http'), + $container->get('Gitea.Dynamic.Uri'), + $container->get('Gitea.Utilities.Response') + ); + } + +} + diff --git a/libraries/jcb_powers/VDM.Joomla.Gitea/src/Service/Package.php b/libraries/jcb_powers/VDM.Joomla.Gitea/src/Service/Package.php new file mode 100644 index 0000000..75d92cb --- /dev/null +++ b/libraries/jcb_powers/VDM.Joomla.Gitea/src/Service/Package.php @@ -0,0 +1,101 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ + +namespace VDM\Joomla\Gitea\Service; + + +use Joomla\DI\Container; +use Joomla\DI\ServiceProviderInterface; +use VDM\Joomla\Gitea\Package as Pack; +use VDM\Joomla\Gitea\Package\Files; +use VDM\Joomla\Gitea\Package\Owner; + + +/** + * The Gitea Package Service + * + * @since 3.2.0 + */ +class Package implements ServiceProviderInterface +{ + /** + * Registers the service provider with a DI container. + * + * @param Container $container The DI container. + * + * @return void + * @since 3.2.0 + */ + public function register(Container $container) + { + $container->alias(Pack::class, 'Gitea.Package') + ->share('Gitea.Package', [$this, 'getPackage'], true); + + $container->alias(Files::class, 'Gitea.Package.Files') + ->share('Gitea.Package.Files', [$this, 'getFiles'], true); + + $container->alias(Owner::class, 'Gitea.Package.Owner') + ->share('Gitea.Package.Owner', [$this, 'getOwner'], true); + } + + /** + * Get the Package class + * + * @param Container $container The DI container. + * + * @return Pack + * @since 3.2.0 + */ + public function getPackage(Container $container): Pack + { + return new Pack( + $container->get('Gitea.Utilities.Http'), + $container->get('Gitea.Dynamic.Uri'), + $container->get('Gitea.Utilities.Response') + ); + } + + /** + * Get the Files class + * + * @param Container $container The DI container. + * + * @return Files + * @since 3.2.0 + */ + public function getFiles(Container $container): Files + { + return new Files( + $container->get('Gitea.Utilities.Http'), + $container->get('Gitea.Dynamic.Uri'), + $container->get('Gitea.Utilities.Response') + ); + } + + /** + * Get the Owner class + * + * @param Container $container The DI container. + * + * @return Owner + * @since 3.2.0 + */ + public function getOwner(Container $container): Owner + { + return new Owner( + $container->get('Gitea.Utilities.Http'), + $container->get('Gitea.Dynamic.Uri'), + $container->get('Gitea.Utilities.Response') + ); + } + +} + diff --git a/libraries/jcb_powers/VDM.Joomla.Gitea/src/Service/Repository.php b/libraries/jcb_powers/VDM.Joomla.Gitea/src/Service/Repository.php new file mode 100644 index 0000000..edfab0d --- /dev/null +++ b/libraries/jcb_powers/VDM.Joomla.Gitea/src/Service/Repository.php @@ -0,0 +1,836 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ + +namespace VDM\Joomla\Gitea\Service; + + +use Joomla\DI\Container; +use Joomla\DI\ServiceProviderInterface; +use VDM\Joomla\Gitea\Repository as Repo; +use VDM\Joomla\Gitea\Repository\Archive; +use VDM\Joomla\Gitea\Repository\Assignees; +use VDM\Joomla\Gitea\Repository\Attachments; +use VDM\Joomla\Gitea\Repository\Branch; +use VDM\Joomla\Gitea\Repository\Branch\Protection; +use VDM\Joomla\Gitea\Repository\Collaborator; +use VDM\Joomla\Gitea\Repository\Commits; +use VDM\Joomla\Gitea\Repository\Contents; +use VDM\Joomla\Gitea\Repository\Forks; +use VDM\Joomla\Gitea\Repository\Gpg; +use VDM\Joomla\Gitea\Repository\Hooks; +use VDM\Joomla\Gitea\Repository\Hooks\Git; +use VDM\Joomla\Gitea\Repository\Keys; +use VDM\Joomla\Gitea\Repository\Languages; +use VDM\Joomla\Gitea\Repository\Media; +use VDM\Joomla\Gitea\Repository\Merge; +use VDM\Joomla\Gitea\Repository\Mirror; +use VDM\Joomla\Gitea\Repository\Mirrors; +use VDM\Joomla\Gitea\Repository\Notes; +use VDM\Joomla\Gitea\Repository\Patch; +use VDM\Joomla\Gitea\Repository\Pulls; +use VDM\Joomla\Gitea\Repository\Refs; +use VDM\Joomla\Gitea\Repository\Releases; +use VDM\Joomla\Gitea\Repository\Remote; +use VDM\Joomla\Gitea\Repository\Reviewers; +use VDM\Joomla\Gitea\Repository\Reviews; +use VDM\Joomla\Gitea\Repository\Stargazers; +use VDM\Joomla\Gitea\Repository\Statuses; +use VDM\Joomla\Gitea\Repository\Tags; +use VDM\Joomla\Gitea\Repository\Teams; +use VDM\Joomla\Gitea\Repository\Templates; +use VDM\Joomla\Gitea\Repository\Times; +use VDM\Joomla\Gitea\Repository\Topics; +use VDM\Joomla\Gitea\Repository\Transfer; +use VDM\Joomla\Gitea\Repository\Trees; +use VDM\Joomla\Gitea\Repository\Watchers; +use VDM\Joomla\Gitea\Repository\Wiki; + + +/** + * The Gitea Repository Service + * + * @since 3.2.0 + */ +class Repository implements ServiceProviderInterface +{ + /** + * Registers the service provider with a DI container. + * + * @param Container $container The DI container. + * + * @return void + * @since 3.2.0 + */ + public function register(Container $container) + { + $container->alias(Repo::class, 'Gitea.Repository') + ->share('Gitea.Repository', [$this, 'getRepository'], true); + + $container->alias(Archive::class, 'Gitea.Repository.Archive') + ->share('Gitea.Repository.Archive', [$this, 'getArchive'], true); + + $container->alias(Assignees::class, 'Gitea.Repository.Assignees') + ->share('Gitea.Repository.Assignees', [$this, 'getAssignees'], true); + + $container->alias(Attachments::class, 'Gitea.Repository.Attachments') + ->share('Gitea.Repository.Attachments', [$this, 'getAttachments'], true); + + $container->alias(Branch::class, 'Gitea.Repository.Branch') + ->share('Gitea.Repository.Branch', [$this, 'getBranch'], true); + + $container->alias(Protection::class, 'Gitea.Repository.Branch.Protection') + ->share('Gitea.Repository.Branch.Protection', [$this, 'getProtection'], true); + + $container->alias(Collaborator::class, 'Gitea.Repository.Collaborator') + ->share('Gitea.Repository.Collaborator', [$this, 'getCollaborator'], true); + + $container->alias(Commits::class, 'Gitea.Repository.Commits') + ->share('Gitea.Repository.Commits', [$this, 'getCommits'], true); + + $container->alias(Contents::class, 'Gitea.Repository.Contents') + ->share('Gitea.Repository.Contents', [$this, 'getContents'], true); + + $container->alias(Forks::class, 'Gitea.Repository.Forks') + ->share('Gitea.Repository.Forks', [$this, 'getForks'], true); + + $container->alias(Gpg::class, 'Gitea.Repository.Gpg') + ->share('Gitea.Repository.Gpg', [$this, 'getGpg'], true); + + $container->alias(Hooks::class, 'Gitea.Repository.Hooks') + ->share('Gitea.Repository.Hooks', [$this, 'getHooks'], true); + + $container->alias(Git::class, 'Gitea.Repository.Hooks.Git') + ->share('Gitea.Repository.Hooks.Git', [$this, 'getGit'], true); + + $container->alias(Keys::class, 'Gitea.Repository.Keys') + ->share('Gitea.Repository.Keys', [$this, 'getKeys'], true); + + $container->alias(Languages::class, 'Gitea.Repository.Languages') + ->share('Gitea.Repository.Languages', [$this, 'getLanguages'], true); + + $container->alias(Media::class, 'Gitea.Repository.Media') + ->share('Gitea.Repository.Media', [$this, 'getMedia'], true); + + $container->alias(Merge::class, 'Gitea.Repository.Merge') + ->share('Gitea.Repository.Merge', [$this, 'getMerge'], true); + + $container->alias(Mirror::class, 'Gitea.Repository.Mirror') + ->share('Gitea.Repository.Mirror', [$this, 'getMirror'], true); + + $container->alias(Mirrors::class, 'Gitea.Repository.Mirrors') + ->share('Gitea.Repository.Mirrors', [$this, 'getMirrors'], true); + + $container->alias(Notes::class, 'Gitea.Repository.Notes') + ->share('Gitea.Repository.Notes', [$this, 'getNotes'], true); + + $container->alias(Patch::class, 'Gitea.Repository.Patch') + ->share('Gitea.Repository.Patch', [$this, 'getPatch'], true); + + $container->alias(Pulls::class, 'Gitea.Repository.Pulls') + ->share('Gitea.Repository.Pulls', [$this, 'getPulls'], true); + + $container->alias(Refs::class, 'Gitea.Repository.Refs') + ->share('Gitea.Repository.Refs', [$this, 'getRefs'], true); + + $container->alias(Releases::class, 'Gitea.Repository.Releases') + ->share('Gitea.Repository.Releases', [$this, 'getReleases'], true); + + $container->alias(Remote::class, 'Gitea.Repository.Remote') + ->share('Gitea.Repository.Remote', [$this, 'getRemote'], true); + + $container->alias(Reviewers::class, 'Gitea.Repository.Reviewers') + ->share('Gitea.Repository.Reviewers', [$this, 'getReviewers'], true); + + $container->alias(Reviews::class, 'Gitea.Repository.Reviews') + ->share('Gitea.Repository.Reviews', [$this, 'getReviews'], true); + + $container->alias(Stargazers::class, 'Gitea.Repository.Stargazers') + ->share('Gitea.Repository.Stargazers', [$this, 'getStargazers'], true); + + $container->alias(Statuses::class, 'Gitea.Repository.Statuses') + ->share('Gitea.Repository.Statuses', [$this, 'getStatuses'], true); + + $container->alias(Tags::class, 'Gitea.Repository.Tags') + ->share('Gitea.Repository.Tags', [$this, 'getTags'], true); + + $container->alias(Teams::class, 'Gitea.Repository.Teams') + ->share('Gitea.Repository.Teams', [$this, 'getTeams'], true); + + $container->alias(Templates::class, 'Gitea.Repository.Templates') + ->share('Gitea.Repository.Templates', [$this, 'getTemplates'], true); + + $container->alias(Times::class, 'Gitea.Repository.Times') + ->share('Gitea.Repository.Times', [$this, 'getTimes'], true); + + $container->alias(Topics::class, 'Gitea.Repository.Topics') + ->share('Gitea.Repository.Topics', [$this, 'getTopics'], true); + + $container->alias(Transfer::class, 'Gitea.Repository.Transfer') + ->share('Gitea.Repository.Transfer', [$this, 'getTransfer'], true); + + $container->alias(Trees::class, 'Gitea.Repository.Trees') + ->share('Gitea.Repository.Trees', [$this, 'getTrees'], true); + + $container->alias(Watchers::class, 'Gitea.Repository.Watchers') + ->share('Gitea.Repository.Watchers', [$this, 'getWatchers'], true); + + $container->alias(Wiki::class, 'Gitea.Repository.Wiki') + ->share('Gitea.Repository.Wiki', [$this, 'getWiki'], true); + } + + /** + * Get the Repository class + * + * @param Container $container The DI container. + * + * @return Repo + * @since 3.2.0 + */ + public function getRepository(Container $container): Repo + { + return new Repo( + $container->get('Gitea.Utilities.Http'), + $container->get('Gitea.Dynamic.Uri'), + $container->get('Gitea.Utilities.Response') + ); + } + + /** + * Get the Archive class + * + * @param Container $container The DI container. + * + * @return Archive + * @since 3.2.0 + */ + public function getArchive(Container $container): Archive + { + return new Archive( + $container->get('Gitea.Utilities.Http'), + $container->get('Gitea.Dynamic.Uri'), + $container->get('Gitea.Utilities.Response') + ); + } + + /** + * Get the Assignees class + * + * @param Container $container The DI container. + * + * @return Assignees + * @since 3.2.0 + */ + public function getAssignees(Container $container): Assignees + { + return new Assignees( + $container->get('Gitea.Utilities.Http'), + $container->get('Gitea.Dynamic.Uri'), + $container->get('Gitea.Utilities.Response') + ); + } + + /** + * Get the Attachments class + * + * @param Container $container The DI container. + * + * @return Attachments + * @since 3.2.0 + */ + public function getAttachments(Container $container): Attachments + { + return new Attachments( + $container->get('Gitea.Utilities.Http'), + $container->get('Gitea.Dynamic.Uri'), + $container->get('Gitea.Utilities.Response') + ); + } + + /** + * Get the Branch class + * + * @param Container $container The DI container. + * + * @return Branch + * @since 3.2.0 + */ + public function getBranch(Container $container): Branch + { + return new Branch( + $container->get('Gitea.Utilities.Http'), + $container->get('Gitea.Dynamic.Uri'), + $container->get('Gitea.Utilities.Response') + ); + } + + /** + * Get the Branch Protection class + * + * @param Container $container The DI container. + * + * @return Protection + * @since 3.2.0 + */ + public function getProtection(Container $container): Protection + { + return new Protection( + $container->get('Gitea.Utilities.Http'), + $container->get('Gitea.Dynamic.Uri'), + $container->get('Gitea.Utilities.Response') + ); + } + + /** + * Get the Collaborator class + * + * @param Container $container The DI container. + * + * @return Collaborator + * @since 3.2.0 + */ + public function getCollaborator(Container $container): Collaborator + { + return new Collaborator( + $container->get('Gitea.Utilities.Http'), + $container->get('Gitea.Dynamic.Uri'), + $container->get('Gitea.Utilities.Response') + ); + } + + /** + * Get the Commits class + * + * @param Container $container The DI container. + * + * @return Commits + * @since 3.2.0 + */ + public function getCommits(Container $container): Commits + { + return new Commits( + $container->get('Gitea.Utilities.Http'), + $container->get('Gitea.Dynamic.Uri'), + $container->get('Gitea.Utilities.Response') + ); + } + + /** + * Get the Contents class + * + * @param Container $container The DI container. + * + * @return Contents + * @since 3.2.0 + */ + public function getContents(Container $container): Contents + { + return new Contents( + $container->get('Gitea.Utilities.Http'), + $container->get('Gitea.Dynamic.Uri'), + $container->get('Gitea.Utilities.Response') + ); + } + + /** + * Get the Forks class + * + * @param Container $container The DI container. + * + * @return Forks + * @since 3.2.0 + */ + public function getForks(Container $container): Forks + { + return new Forks( + $container->get('Gitea.Utilities.Http'), + $container->get('Gitea.Dynamic.Uri'), + $container->get('Gitea.Utilities.Response') + ); + } + + /** + * Get the Gpg class + * + * @param Container $container The DI container. + * + * @return Gpg + * @since 3.2.0 + */ + public function getGpg(Container $container): Gpg + { + return new Gpg( + $container->get('Gitea.Utilities.Http'), + $container->get('Gitea.Dynamic.Uri'), + $container->get('Gitea.Utilities.Response') + ); + } + + /** + * Get the Hooks class + * + * @param Container $container The DI container. + * + * @return Hooks + * @since 3.2.0 + */ + public function getHooks(Container $container): Hooks + { + return new Hooks( + $container->get('Gitea.Utilities.Http'), + $container->get('Gitea.Dynamic.Uri'), + $container->get('Gitea.Utilities.Response') + ); + } + + /** + * Get the Hooks Git class + * + * @param Container $container The DI container. + * + * @return Git + * @since 3.2.0 + */ + public function getGit(Container $container): Git + { + return new Git( + $container->get('Gitea.Utilities.Http'), + $container->get('Gitea.Dynamic.Uri'), + $container->get('Gitea.Utilities.Response') + ); + } + + /** + * Get the Keys class + * + * @param Container $container The DI container. + * + * @return Keys + * @since 3.2.0 + */ + public function getKeys(Container $container): Keys + { + return new Keys( + $container->get('Gitea.Utilities.Http'), + $container->get('Gitea.Dynamic.Uri'), + $container->get('Gitea.Utilities.Response') + ); + } + + /** + * Get the Languages class + * + * @param Container $container The DI container. + * + * @return Languages + * @since 3.2.0 + */ + public function getLanguages(Container $container): Languages + { + return new Languages( + $container->get('Gitea.Utilities.Http'), + $container->get('Gitea.Dynamic.Uri'), + $container->get('Gitea.Utilities.Response') + ); + } + + /** + * Get the Media class + * + * @param Container $container The DI container. + * + * @return Media + * @since 3.2.0 + */ + public function getMedia(Container $container): Media + { + return new Media( + $container->get('Gitea.Utilities.Http'), + $container->get('Gitea.Dynamic.Uri'), + $container->get('Gitea.Utilities.Response') + ); + } + + /** + * Get the Merge class + * + * @param Container $container The DI container. + * + * @return Merge + * @since 3.2.0 + */ + public function getMerge(Container $container): Merge + { + return new Merge( + $container->get('Gitea.Utilities.Http'), + $container->get('Gitea.Dynamic.Uri'), + $container->get('Gitea.Utilities.Response') + ); + } + + /** + * Get the Mirror class + * + * @param Container $container The DI container. + * + * @return Mirror + * @since 3.2.0 + */ + public function getMirror(Container $container): Mirror + { + return new Mirror( + $container->get('Gitea.Utilities.Http'), + $container->get('Gitea.Dynamic.Uri'), + $container->get('Gitea.Utilities.Response') + ); + } + + /** + * Get the Mirrors class + * + * @param Container $container The DI container. + * + * @return Mirrors + * @since 3.2.0 + */ + public function getMirrors(Container $container): Mirrors + { + return new Mirrors( + $container->get('Gitea.Utilities.Http'), + $container->get('Gitea.Dynamic.Uri'), + $container->get('Gitea.Utilities.Response') + ); + } + + /** + * Get the Notes class + * + * @param Container $container The DI container. + * + * @return Notes + * @since 3.2.0 + */ + public function getNotes(Container $container): Notes + { + return new Notes( + $container->get('Gitea.Utilities.Http'), + $container->get('Gitea.Dynamic.Uri'), + $container->get('Gitea.Utilities.Response') + ); + } + + /** + * Get the Patch class + * + * @param Container $container The DI container. + * + * @return Patch + * @since 3.2.0 + */ + public function getPatch(Container $container): Patch + { + return new Patch( + $container->get('Gitea.Utilities.Http'), + $container->get('Gitea.Dynamic.Uri'), + $container->get('Gitea.Utilities.Response') + ); + } + + /** + * Get the Pulls class + * + * @param Container $container The DI container. + * + * @return Pulls + * @since 3.2.0 + */ + public function getPulls(Container $container): Pulls + { + return new Pulls( + $container->get('Gitea.Utilities.Http'), + $container->get('Gitea.Dynamic.Uri'), + $container->get('Gitea.Utilities.Response') + ); + } + + /** + * Get the Refs class + * + * @param Container $container The DI container. + * + * @return Refs + * @since 3.2.0 + */ + public function getRefs(Container $container): Refs + { + return new Refs( + $container->get('Gitea.Utilities.Http'), + $container->get('Gitea.Dynamic.Uri'), + $container->get('Gitea.Utilities.Response') + ); + } + + /** + * Get the Releases class + * + * @param Container $container The DI container. + * + * @return Releases + * @since 3.2.0 + */ + public function getReleases(Container $container): Releases + { + return new Releases( + $container->get('Gitea.Utilities.Http'), + $container->get('Gitea.Dynamic.Uri'), + $container->get('Gitea.Utilities.Response') + ); + } + + /** + * Get the Remote class + * + * @param Container $container The DI container. + * + * @return Remote + * @since 3.2.0 + */ + public function getRemote(Container $container): Remote + { + return new Remote( + $container->get('Gitea.Utilities.Http'), + $container->get('Gitea.Dynamic.Uri'), + $container->get('Gitea.Utilities.Response') + ); + } + + /** + * Get the Reviewers class + * + * @param Container $container The DI container. + * + * @return Reviewers + * @since 3.2.0 + */ + public function getReviewers(Container $container): Reviewers + { + return new Reviewers( + $container->get('Gitea.Utilities.Http'), + $container->get('Gitea.Dynamic.Uri'), + $container->get('Gitea.Utilities.Response') + ); + } + + /** + * Get the Reviews class + * + * @param Container $container The DI container. + * + * @return Reviews + * @since 3.2.0 + */ + public function getReviews(Container $container): Reviews + { + return new Reviews( + $container->get('Gitea.Utilities.Http'), + $container->get('Gitea.Dynamic.Uri'), + $container->get('Gitea.Utilities.Response') + ); + } + + /** + * Get the Stargazers class + * + * @param Container $container The DI container. + * + * @return Stargazers + * @since 3.2.0 + */ + public function getStargazers(Container $container): Stargazers + { + return new Stargazers( + $container->get('Gitea.Utilities.Http'), + $container->get('Gitea.Dynamic.Uri'), + $container->get('Gitea.Utilities.Response') + ); + } + + /** + * Get the Statuses class + * + * @param Container $container The DI container. + * + * @return Statuses + * @since 3.2.0 + */ + public function getStatuses(Container $container): Statuses + { + return new Statuses( + $container->get('Gitea.Utilities.Http'), + $container->get('Gitea.Dynamic.Uri'), + $container->get('Gitea.Utilities.Response') + ); + } + + /** + * Get the Tags class + * + * @param Container $container The DI container. + * + * @return Tags + * @since 3.2.0 + */ + public function getTags(Container $container): Tags + { + return new Tags( + $container->get('Gitea.Utilities.Http'), + $container->get('Gitea.Dynamic.Uri'), + $container->get('Gitea.Utilities.Response') + ); + } + + /** + * Get the Teams class + * + * @param Container $container The DI container. + * + * @return Teams + * @since 3.2.0 + */ + public function getTeams(Container $container): Teams + { + return new Teams( + $container->get('Gitea.Utilities.Http'), + $container->get('Gitea.Dynamic.Uri'), + $container->get('Gitea.Utilities.Response') + ); + } + + /** + * Get the Templates class + * + * @param Container $container The DI container. + * + * @return Templates + * @since 3.2.0 + */ + public function getTemplates(Container $container): Templates + { + return new Templates( + $container->get('Gitea.Utilities.Http'), + $container->get('Gitea.Dynamic.Uri'), + $container->get('Gitea.Utilities.Response') + ); + } + + /** + * Get the Times class + * + * @param Container $container The DI container. + * + * @return Times + * @since 3.2.0 + */ + public function getTimes(Container $container): Times + { + return new Times( + $container->get('Gitea.Utilities.Http'), + $container->get('Gitea.Dynamic.Uri'), + $container->get('Gitea.Utilities.Response') + ); + } + + /** + * Get the Topics class + * + * @param Container $container The DI container. + * + * @return Topics + * @since 3.2.0 + */ + public function getTopics(Container $container): Topics + { + return new Topics( + $container->get('Gitea.Utilities.Http'), + $container->get('Gitea.Dynamic.Uri'), + $container->get('Gitea.Utilities.Response') + ); + } + + /** + * Get the Transfer class + * + * @param Container $container The DI container. + * + * @return Transfer + * @since 3.2.0 + */ + public function getTransfer(Container $container): Transfer + { + return new Transfer( + $container->get('Gitea.Utilities.Http'), + $container->get('Gitea.Dynamic.Uri'), + $container->get('Gitea.Utilities.Response') + ); + } + + /** + * Get the Trees class + * + * @param Container $container The DI container. + * + * @return Trees + * @since 3.2.0 + */ + public function getTrees(Container $container): Trees + { + return new Trees( + $container->get('Gitea.Utilities.Http'), + $container->get('Gitea.Dynamic.Uri'), + $container->get('Gitea.Utilities.Response') + ); + } + + /** + * Get the Watchers class + * + * @param Container $container The DI container. + * + * @return Watchers + * @since 3.2.0 + */ + public function getWatchers(Container $container): Watchers + { + return new Watchers( + $container->get('Gitea.Utilities.Http'), + $container->get('Gitea.Dynamic.Uri'), + $container->get('Gitea.Utilities.Response') + ); + } + + /** + * Get the Wiki class + * + * @param Container $container The DI container. + * + * @return Wiki + * @since 3.2.0 + */ + public function getWiki(Container $container): Wiki + { + return new Wiki( + $container->get('Gitea.Utilities.Http'), + $container->get('Gitea.Dynamic.Uri'), + $container->get('Gitea.Utilities.Response') + ); + } + +} + diff --git a/libraries/jcb_powers/VDM.Joomla.Gitea/src/Service/Settings.php b/libraries/jcb_powers/VDM.Joomla.Gitea/src/Service/Settings.php new file mode 100644 index 0000000..e4b1a7e --- /dev/null +++ b/libraries/jcb_powers/VDM.Joomla.Gitea/src/Service/Settings.php @@ -0,0 +1,123 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ + +namespace VDM\Joomla\Gitea\Service; + + +use Joomla\DI\Container; +use Joomla\DI\ServiceProviderInterface; +use VDM\Joomla\Gitea\Settings\Api; +use VDM\Joomla\Gitea\Settings\Attachment; +use VDM\Joomla\Gitea\Settings\Repository; +use VDM\Joomla\Gitea\Settings\Ui; + + +/** + * The Gitea Settings Service + * + * @since 3.2.0 + */ +class Settings implements ServiceProviderInterface +{ + /** + * Registers the service provider with a DI container. + * + * @param Container $container The DI container. + * + * @return void + * @since 3.2.0 + */ + public function register(Container $container) + { + $container->alias(Api::class, 'Gitea.Settings.Api') + ->share('Gitea.Settings.Api', [$this, 'getApi'], true); + + $container->alias(Attachment::class, 'Gitea.Settings.Attachment') + ->share('Gitea.Settings.Attachment', [$this, 'getAttachment'], true); + + $container->alias(Repository::class, 'Gitea.Settings.Repository') + ->share('Gitea.Settings.Repository', [$this, 'getRepository'], true); + + $container->alias(Ui::class, 'Gitea.Settings.Ui') + ->share('Gitea.Settings.Ui', [$this, 'getUi'], true); + } + + /** + * Get the Api class + * + * @param Container $container The DI container. + * + * @return Api + * @since 3.2.0 + */ + public function getApi(Container $container): Api + { + return new Api( + $container->get('Gitea.Utilities.Http'), + $container->get('Gitea.Dynamic.Uri'), + $container->get('Gitea.Utilities.Response') + ); + } + + /** + * Get the Attachment class + * + * @param Container $container The DI container. + * + * @return Attachment + * @since 3.2.0 + */ + public function getAttachment(Container $container): Attachment + { + return new Attachment( + $container->get('Gitea.Utilities.Http'), + $container->get('Gitea.Dynamic.Uri'), + $container->get('Gitea.Utilities.Response') + ); + } + + /** + * Get the Repository class + * + * @param Container $container The DI container. + * + * @return Repository + * @since 3.2.0 + */ + public function getRepository(Container $container): Repository + { + return new Repository( + $container->get('Gitea.Utilities.Http'), + $container->get('Gitea.Dynamic.Uri'), + $container->get('Gitea.Utilities.Response') + ); + } + + /** + * Get the Ui class + * + * @param Container $container The DI container. + * + * @return Ui + * @since 3.2.0 + */ + public function getUi(Container $container): Ui + { + return new Ui( + $container->get('Gitea.Utilities.Http'), + $container->get('Gitea.Dynamic.Uri'), + $container->get('Gitea.Utilities.Response') + ); + } + + +} + diff --git a/libraries/jcb_powers/VDM.Joomla.Gitea/src/Service/User.php b/libraries/jcb_powers/VDM.Joomla.Gitea/src/Service/User.php new file mode 100644 index 0000000..63bc120 --- /dev/null +++ b/libraries/jcb_powers/VDM.Joomla.Gitea/src/Service/User.php @@ -0,0 +1,332 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ + +namespace VDM\Joomla\Gitea\Service; + + +use Joomla\DI\Container; +use Joomla\DI\ServiceProviderInterface; +use VDM\Joomla\Gitea\User as Usr; +use VDM\Joomla\Gitea\User\Applications; +use VDM\Joomla\Gitea\User\Emails; +use VDM\Joomla\Gitea\User\Followers; +use VDM\Joomla\Gitea\User\Following; +use VDM\Joomla\Gitea\User\Gpg; +use VDM\Joomla\Gitea\User\Keys; +use VDM\Joomla\Gitea\User\Repos; +use VDM\Joomla\Gitea\User\Settings; +use VDM\Joomla\Gitea\User\Starred; +use VDM\Joomla\Gitea\User\Subscriptions; +use VDM\Joomla\Gitea\User\Teams; +use VDM\Joomla\Gitea\User\Times; +use VDM\Joomla\Gitea\User\Tokens; + + +/** + * The Gitea User Service + * + * @since 3.2.0 + */ +class User implements ServiceProviderInterface +{ + /** + * Registers the service provider with a DI container. + * + * @param Container $container The DI container. + * + * @return void + * @since 3.2.0 + */ + public function register(Container $container) + { + $container->alias(Usr::class, 'Gitea.User') + ->share('Gitea.User', [$this, 'getUser'], true); + + $container->alias(Applications::class, 'Gitea.User.Applications') + ->share('Gitea.User.Applications', [$this, 'getApplications'], true); + + $container->alias(Emails::class, 'Gitea.User.Emails') + ->share('Gitea.User.Emails', [$this, 'getEmails'], true); + + $container->alias(Followers::class, 'Gitea.User.Followers') + ->share('Gitea.User.Followers', [$this, 'getFollowers'], true); + + $container->alias(Following::class, 'Gitea.User.Following') + ->share('Gitea.User.Following', [$this, 'getFollowing'], true); + + $container->alias(Gpg::class, 'Gitea.User.Gpg') + ->share('Gitea.User.Gpg', [$this, 'getGpg'], true); + + $container->alias(Keys::class, 'Gitea.User.Keys') + ->share('Gitea.User.Keys', [$this, 'getKeys'], true); + + $container->alias(Repos::class, 'Gitea.User.Repos') + ->share('Gitea.User.Repos', [$this, 'getRepos'], true); + + $container->alias(Settings::class, 'Gitea.User.Settings') + ->share('Gitea.User.Settings', [$this, 'getSettings'], true); + + $container->alias(Starred::class, 'Gitea.User.Starred') + ->share('Gitea.User.Starred', [$this, 'getStarred'], true); + + $container->alias(Subscriptions::class, 'Gitea.User.Subscriptions') + ->share('Gitea.User.Subscriptions', [$this, 'getSubscriptions'], true); + + $container->alias(Teams::class, 'Gitea.User.Teams') + ->share('Gitea.User.Teams', [$this, 'getTeams'], true); + + $container->alias(Times::class, 'Gitea.User.Times') + ->share('Gitea.User.Times', [$this, 'getTimes'], true); + + $container->alias(Tokens::class, 'Gitea.User.Tokens') + ->share('Gitea.User.Tokens', [$this, 'getTokens'], true); + } + + /** + * Get the User class + * + * @param Container $container The DI container. + * + * @return Usr + * @since 3.2.0 + */ + public function getUser(Container $container): Usr + { + return new Usr( + $container->get('Gitea.Utilities.Http'), + $container->get('Gitea.Dynamic.Uri'), + $container->get('Gitea.Utilities.Response') + ); + } + + /** + * Get the Applications class + * + * @param Container $container The DI container. + * + * @return Applications + * @since 3.2.0 + */ + public function getApplications(Container $container): Applications + { + return new Applications( + $container->get('Gitea.Utilities.Http'), + $container->get('Gitea.Dynamic.Uri'), + $container->get('Gitea.Utilities.Response') + ); + } + + /** + * Get the Emails class + * + * @param Container $container The DI container. + * + * @return Emails + * @since 3.2.0 + */ + public function getEmails(Container $container): Emails + { + return new Emails( + $container->get('Gitea.Utilities.Http'), + $container->get('Gitea.Dynamic.Uri'), + $container->get('Gitea.Utilities.Response') + ); + } + + /** + * Get the Followers class + * + * @param Container $container The DI container. + * + * @return Followers + * @since 3.2.0 + */ + public function getFollowers(Container $container): Followers + { + return new Followers( + $container->get('Gitea.Utilities.Http'), + $container->get('Gitea.Dynamic.Uri'), + $container->get('Gitea.Utilities.Response') + ); + } + + /** + * Get the Following class + * + * @param Container $container The DI container. + * + * @return Following + * @since 3.2.0 + */ + public function getFollowing(Container $container): Following + { + return new Following( + $container->get('Gitea.Utilities.Http'), + $container->get('Gitea.Dynamic.Uri'), + $container->get('Gitea.Utilities.Response') + ); + } + + /** + * Get the Gpg class + * + * @param Container $container The DI container. + * + * @return Gpg + * @since 3.2.0 + */ + public function getGpg(Container $container): Gpg + { + return new Gpg( + $container->get('Gitea.Utilities.Http'), + $container->get('Gitea.Dynamic.Uri'), + $container->get('Gitea.Utilities.Response') + ); + } + + /** + * Get the Keys class + * + * @param Container $container The DI container. + * + * @return Keys + * @since 3.2.0 + */ + public function getKeys(Container $container): Keys + { + return new Keys( + $container->get('Gitea.Utilities.Http'), + $container->get('Gitea.Dynamic.Uri'), + $container->get('Gitea.Utilities.Response') + ); + } + + /** + * Get the Repos class + * + * @param Container $container The DI container. + * + * @return Repos + * @since 3.2.0 + */ + public function getRepos(Container $container): Repos + { + return new Repos( + $container->get('Gitea.Utilities.Http'), + $container->get('Gitea.Dynamic.Uri'), + $container->get('Gitea.Utilities.Response') + ); + } + + /** + * Get the Settings class + * + * @param Container $container The DI container. + * + * @return Settings + * @since 3.2.0 + */ + public function getSettings(Container $container): Settings + { + return new Settings( + $container->get('Gitea.Utilities.Http'), + $container->get('Gitea.Dynamic.Uri'), + $container->get('Gitea.Utilities.Response') + ); + } + + /** + * Get the Starred class + * + * @param Container $container The DI container. + * + * @return Starred + * @since 3.2.0 + */ + public function getStarred(Container $container): Starred + { + return new Starred( + $container->get('Gitea.Utilities.Http'), + $container->get('Gitea.Dynamic.Uri'), + $container->get('Gitea.Utilities.Response') + ); + } + + /** + * Get the Subscriptions class + * + * @param Container $container The DI container. + * + * @return Subscriptions + * @since 3.2.0 + */ + public function getSubscriptions(Container $container): Subscriptions + { + return new Subscriptions( + $container->get('Gitea.Utilities.Http'), + $container->get('Gitea.Dynamic.Uri'), + $container->get('Gitea.Utilities.Response') + ); + } + + /** + * Get the Teams class + * + * @param Container $container The DI container. + * + * @return Teams + * @since 3.2.0 + */ + public function getTeams(Container $container): Teams + { + return new Teams( + $container->get('Gitea.Utilities.Http'), + $container->get('Gitea.Dynamic.Uri'), + $container->get('Gitea.Utilities.Response') + ); + } + + /** + * Get the Times class + * + * @param Container $container The DI container. + * + * @return Times + * @since 3.2.0 + */ + public function getTimes(Container $container): Times + { + return new Times( + $container->get('Gitea.Utilities.Http'), + $container->get('Gitea.Dynamic.Uri'), + $container->get('Gitea.Utilities.Response') + ); + } + + /** + * Get the Tokens class + * + * @param Container $container The DI container. + * + * @return Tokens + * @since 3.2.0 + */ + public function getTokens(Container $container): Tokens + { + return new Tokens( + $container->get('Gitea.Utilities.Http'), + $container->get('Gitea.Dynamic.Uri'), + $container->get('Gitea.Utilities.Response') + ); + } + +} + diff --git a/libraries/jcb_powers/VDM.Joomla.Gitea/src/Service/Utilities.php b/libraries/jcb_powers/VDM.Joomla.Gitea/src/Service/Utilities.php new file mode 100644 index 0000000..09112d2 --- /dev/null +++ b/libraries/jcb_powers/VDM.Joomla.Gitea/src/Service/Utilities.php @@ -0,0 +1,72 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ + +namespace VDM\Joomla\Gitea\Service; + + +use Joomla\DI\Container; +use Joomla\DI\ServiceProviderInterface; +use VDM\Joomla\Gitea\Utilities\Uri; +use VDM\Joomla\Gitea\Utilities\Response; + + +/** + * The Gitea Utilities Service + * + * @since 3.2.0 + */ +class Utilities implements ServiceProviderInterface +{ + /** + * Registers the service provider with a DI container. + * + * @param Container $container The DI container. + * + * @return void + * @since 3.2.0 + */ + public function register(Container $container) + { + $container->alias(Uri::class, 'Gitea.Utilities.Uri') + ->share('Gitea.Utilities.Uri', [$this, 'getUri'], true); + + $container->alias(Response::class, 'Gitea.Utilities.Response') + ->share('Gitea.Utilities.Response', [$this, 'getResponse'], true); + } + + /** + * Get the Uri class + * + * @param Container $container The DI container. + * + * @return Uri + * @since 3.2.0 + */ + public function getUri(Container $container): Uri + { + return new Uri(); + } + + /** + * Get the Response class + * + * @param Container $container The DI container. + * + * @return Response + * @since 3.2.0 + */ + public function getResponse(Container $container): Response + { + return new Response(); + } + +} + diff --git a/libraries/jcb_powers/VDM.Joomla.Gitea/src/Service/index.html b/libraries/jcb_powers/VDM.Joomla.Gitea/src/Service/index.html new file mode 100644 index 0000000..fa6d84e --- /dev/null +++ b/libraries/jcb_powers/VDM.Joomla.Gitea/src/Service/index.html @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/libraries/jcb_powers/VDM.Joomla.Gitea/src/Settings/Api.php b/libraries/jcb_powers/VDM.Joomla.Gitea/src/Settings/Api.php new file mode 100644 index 0000000..cf2d56f --- /dev/null +++ b/libraries/jcb_powers/VDM.Joomla.Gitea/src/Settings/Api.php @@ -0,0 +1,45 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ + +namespace VDM\Joomla\Gitea\Settings; + + +use VDM\Joomla\Gitea\Abstraction\Api as BaseAPI; + + +/** + * The Gitea Settings Api + * + * @since 3.2.0 + */ +class Api extends BaseAPI +{ + /** + * Get instance's global settings for API. + * + * @return object|null + * @since 3.2.0 + **/ + public function get(): ?object + { + // Build the request path. + $path = "/settings/api"; + + // Send the get request. + return $this->response->get( + $this->http->get( + $this->uri->get($path) + ) + ); + } + +} + diff --git a/libraries/jcb_powers/VDM.Joomla.Gitea/src/Settings/Attachment.php b/libraries/jcb_powers/VDM.Joomla.Gitea/src/Settings/Attachment.php new file mode 100644 index 0000000..9219388 --- /dev/null +++ b/libraries/jcb_powers/VDM.Joomla.Gitea/src/Settings/Attachment.php @@ -0,0 +1,45 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ + +namespace VDM\Joomla\Gitea\Settings; + + +use VDM\Joomla\Gitea\Abstraction\Api; + + +/** + * The Gitea Settings Attachment + * + * @since 3.2.0 + */ +class Attachment extends Api +{ + /** + * Get instance's global settings for Attachment. + * + * @return object|null + * @since 3.2.0 + **/ + public function get(): ?object + { + // Build the request path. + $path = "/settings/attachment"; + + // Send the get request. + return $this->response->get( + $this->http->get( + $this->uri->get($path) + ) + ); + } + +} + diff --git a/libraries/jcb_powers/VDM.Joomla.Gitea/src/Settings/Repository.php b/libraries/jcb_powers/VDM.Joomla.Gitea/src/Settings/Repository.php new file mode 100644 index 0000000..adbf908 --- /dev/null +++ b/libraries/jcb_powers/VDM.Joomla.Gitea/src/Settings/Repository.php @@ -0,0 +1,45 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ + +namespace VDM\Joomla\Gitea\Settings; + + +use VDM\Joomla\Gitea\Abstraction\Api; + + +/** + * The Gitea Settings Repository + * + * @since 3.2.0 + */ +class Repository extends Api +{ + /** + * Get instance's global settings for repositories. + * + * @return object|null + * @since 3.2.0 + **/ + public function get(): ?object + { + // Build the request path. + $path = "/settings/repository"; + + // Send the get request. + return $this->response->get( + $this->http->get( + $this->uri->get($path) + ) + ); + } + +} + diff --git a/libraries/jcb_powers/VDM.Joomla.Gitea/src/Settings/Ui.php b/libraries/jcb_powers/VDM.Joomla.Gitea/src/Settings/Ui.php new file mode 100644 index 0000000..def2668 --- /dev/null +++ b/libraries/jcb_powers/VDM.Joomla.Gitea/src/Settings/Ui.php @@ -0,0 +1,45 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ + +namespace VDM\Joomla\Gitea\Settings; + + +use VDM\Joomla\Gitea\Abstraction\Api; + + +/** + * The Gitea Settings Ui + * + * @since 3.2.0 + */ +class Ui extends Api +{ + /** + * Get instance's global settings for UI. + * + * @return object|null + * @since 3.2.0 + **/ + public function get(): ?object + { + // Build the request path. + $path = "/settings/ui"; + + // Send the get request. + return $this->response->get( + $this->http->get( + $this->uri->get($path) + ) + ); + } + +} + diff --git a/libraries/jcb_powers/VDM.Joomla.Gitea/src/Settings/index.html b/libraries/jcb_powers/VDM.Joomla.Gitea/src/Settings/index.html new file mode 100644 index 0000000..fa6d84e --- /dev/null +++ b/libraries/jcb_powers/VDM.Joomla.Gitea/src/Settings/index.html @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/libraries/jcb_powers/VDM.Joomla.Gitea/src/User.php b/libraries/jcb_powers/VDM.Joomla.Gitea/src/User.php new file mode 100644 index 0000000..bb9c82e --- /dev/null +++ b/libraries/jcb_powers/VDM.Joomla.Gitea/src/User.php @@ -0,0 +1,335 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ + +namespace VDM\Joomla\Gitea; + + +use VDM\Joomla\Gitea\Abstraction\Api; + + +/** + * The Gitea User + * + * @since 3.2.0 + */ +class User extends Api +{ + /** + * Get the authenticated user. + * + * @return object|null + * @since 3.2.0 + **/ + public function authenticate(): ?object + { + // Build the request path. + $path = '/user'; + + // Send the get request. + return $this->response->get( + $this->http->get( + $this->uri->get($path) + ) + ); + } + + /** + * Search for users. + * + * @param string $keyword The search keyword. + * @param int|null $uid Optional. ID of the user to search for. + * @param int $page Page number of results to return (1-based). + * @param int $limit Page size of results. + * + * @return object|null + * @since 3.2.0 + **/ + public function search( + string $keyword, + ?int $uid = null, + int $page = 1, + int $limit = 10 + ): ?object + { + // Build the request path. + $path = '/users/search'; + + // Build the URI with query parameters. + $uri = $this->uri->get($path); + $uri->setVar('q', $keyword); + + if ($uid !== null) + { + $uri->setVar('uid', $uid); + } + + $uri->setVar('page', $page); + $uri->setVar('limit', $limit); + + // Send the get request. + return $this->response->get( + $this->http->get($uri) + ); + } + + /** + * Get a user by their username. + * + * @param string $username The username of the user to retrieve. + * + * @return object|null + * @since 3.2.0 + **/ + public function get(string $username): o?bject + { + // Build the request path. + $path = "/users/{$username}"; + + // Send the get request. + return $this->response->get( + $this->http->get( + $this->uri->get($path) + ) + ); + } + + /** + * List the given user's followers. + * + * @param string $userName The username of the user to retrieve followers for. + * @param int $page Page number of results to return (1-based). + * @param int $limit Page size of results. + * + * @return array|null + * @since 3.2.0 + **/ + public function followers( + string $userName, + int $page = 1, + int $limit = 10 + ): ?array + { + // Build the request path. + $path = "/users/{$userName}/followers"; + + // Build the URI with query parameters. + $uri = $this->uri->get($path); + $uri->setVar('page', $page); + $uri->setVar('limit', $limit); + + // Send the get request. + return $this->response->get( + $this->http->get($uri) + ); + } + + /** + * List the users that the given user is following. + * + * @param string $userName The username of the user to retrieve the following users for. + * @param int $page Page number of results to return (1-based). + * @param int $limit Page size of results. + * + * @return array|null + * @since 3.2.0 + **/ + public function following( + string $userName, + int $page = 1, + int $limit = 10 + ): ?array + { + // Build the request path. + $path = "/users/{$userName}/following"; + + // Build the URI with query parameters. + $uri = $this->uri->get($path); + $uri->setVar('page', $page); + $uri->setVar('limit', $limit); + + // Send the get request. + return $this->response->get( + $this->http->get($uri) + ); + } + + /** + * Check if one user is following another user. + * + * @param string $username The username of the user to check. + * @param string $target The username of the target user. + * + * @return string + * @since 3.2.0 + **/ + public function check(string $username, string $target): string + { + // Build the request path. + $path = "/users/{$username}/following/{$target}"; + + // Send the get request. + return $this->response->get( + $this->http->get( + $this->uri->get($path) + ), 204, 'success' + ); + } + + /** + * List the given user's GPG keys. + * + * @param string $userName The username of the user to retrieve GPG keys for. + * @param int $page The page number of results to return (1-based). + * @param int $limit The page size of results. + * + * @return array|null + * @since 3.2.0 + **/ + public function gpg( + string $userName, + int $page = 1, + int $limit = 10 + ): ?array + { + // Build the request path. + $path = "/users/{$userName}/gpg_keys"; + + // Build the URI with query parameters. + $uri = $this->uri->get($path); + $uri->setVar('page', $page); + $uri->setVar('limit', $limit); + + // Send the get request. + return $this->response->get( + $this->http->get($uri) + ); + } + + /** + * Get a user's heatmap. + * + * @param string $username The username of the user to retrieve heatmap for. + * + * @return array|null + * @since 3.2.0 + **/ + public function heatmap(string $username): ?array + { + // Build the request path. + $path = "/users/{$username}/heatmap"; + + // Send the get request. + return $this->response->get( + $this->http->get( + $this->uri->get($path) + ) + ); + } + + /** + * List the given user's public keys. + * + * @param string $userName The username of the user to retrieve public keys for. + * @param string|null $fingerprint Optional. The fingerprint of the key. + * @param int $page The page number of results to return (1-based). + * @param int $limit The page size of results. + * + * @return array|null + * @since 3.2.0 + **/ + public function keys( + string $userName, + ?string $fingerprint = null, + int $page = 1, + int $limit = 10 + ): ?array + { + // Build the request path. + $path = "/users/{$userName}/keys"; + + // Build the URI with query parameters. + $uri = $this->uri->get($path); + $uri->setVar('page', $page); + $uri->setVar('limit', $limit); + + if ($fingerprint !== null) + { + $uri->setVar('fingerprint', $fingerprint); + } + + // Send the get request. + return $this->response->get( + $this->http->get($uri) + ); + } + + /** + * List the repos that the given user has starred. + * + * @param string $userName The username of the user to retrieve starred repos for. + * @param int $page The page number of results to return (1-based). + * @param int $limit The page size of results. + * + * @return array|null + * @since 3.2.0 + **/ + public function repos( + string $userName, + int $page = 1, + int $limit = 10 + ): ?array + { + // Build the request path. + $path = "/users/{$userName}/starred"; + + // Build the URI with query parameters. + $uri = $this->uri->get($path); + $uri->setVar('page', $page); + $uri->setVar('limit', $limit); + + // Send the get request. + return $this->response->get( + $this->http->get($uri) + ); + } + + /** + * List the repositories watched by a user. + * + * @param string $userName The username of the user to retrieve watched repositories for. + * @param int $page The page number of results to return (1-based). + * @param int $limit The page size of results. + * + * @return array|null + * @since 3.2.0 + **/ + public function watched( + string $userName, + int $page = 1, + int $limit = 10 + ): ?array + { + // Build the request path. + $path = "/users/{$userName}/subscriptions"; + + // Build the URI with query parameters. + $uri = $this->uri->get($path); + $uri->setVar('page', $page); + $uri->setVar('limit', $limit); + + // Send the get request. + return $this->response->get( + $this->http->get($uri) + ); + } + +} + diff --git a/libraries/jcb_powers/VDM.Joomla.Gitea/src/User/Applications.php b/libraries/jcb_powers/VDM.Joomla.Gitea/src/User/Applications.php new file mode 100644 index 0000000..10d8dc6 --- /dev/null +++ b/libraries/jcb_powers/VDM.Joomla.Gitea/src/User/Applications.php @@ -0,0 +1,166 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ + +namespace VDM\Joomla\Gitea\User; + + +use VDM\Joomla\Gitea\Abstraction\Api; + + +/** + * The Gitea User Applications + * + * @since 3.2.0 + */ +class Applications extends Api +{ + /** + * List the authenticated user's oauth2 applications. + * + * @param int $page Page number of results to return (1-based). + * @param int $limit Page size of results. + * + * @return array|null + * @since 3.2.0 + **/ + public function get( + int $page = 1, + int $limit = 10 + ): ?array + { + // Build the request path. + $path = '/user/applications/oauth2'; + + // Build the URI with query parameters. + $uri = $this->uri->get($path); + $uri->setVar('page', $page); + $uri->setVar('limit', $limit); + + // Send the get request. + return $this->response->get( + $this->http->get($uri) + ); + } + + /** + * Get an OAuth2 application by ID. + * + * @param int $id The OAuth2 application ID. + * + * @return object|null + * @since 3.2.0 + **/ + public function id(int $id): ?object + { + // Build the request path. + $path = "/user/applications/oauth2/{$id}"; + + // Send the get request. + return $this->response->get( + $this->http->get( + $this->uri->get($path) + ) + ); + } + + /** + * Creates a new OAuth2 application. + * + * @param string $appName The application name. + * @param array $redirectUris The application redirect URIs. + * @param bool $confidentialClient The confidentiality of the client (default: true). + * + * @return object|null + * @since 3.2.0 + **/ + public function create( + string $appName, + array $redirectUris, + bool $confidentialClient = true + ): ?object + { + // Build the request path. + $path = '/user/applications/oauth2'; + + // Set the application data. + $data = new \stdClass(); + $data->name = $appName; + $data->redirect_uris = $redirectUris; + $data->confidential_client = $confidentialClient; + + // Send the post request. + return $this->response->get( + $this->http->post( + $this->uri->get($path), + json_encode($data) + ), 201 + ); + } + + /** + * Delete an OAuth2 application by ID. + * + * @param int $id The OAuth2 application ID. + * + * @return string + * @since 3.2.0 + **/ + public function delete(int $id): string + { + // Build the request path. + $path = "/user/applications/oauth2/{$id}"; + + // Send the delete request. + return $this->response->get( + $this->http->delete( + $this->uri->get($path) + ), 204, 'success' + ); + } + + /** + * Update an OAuth2 application by ID, this includes regenerating the client secret. + * + * @param int $appId The OAuth2 application ID. + * @param string $appName The application name. + * @param array $redirectUris The application redirect URIs. + * @param bool $confidentialClient The confidentiality of the client (default: true). + * + * @return object|null + * @since 3.2.0 + **/ + public function update( + int $appId, + string $appName, + array $redirectUris, + bool $confidentialClient = true + ): ?object + { + // Build the request path. + $path = "/user/applications/oauth2/{$appId}"; + + // Set the application data. + $data = new \stdClass(); + $data->name = $appName; + $data->redirect_uris = $redirectUris; + $data->confidential_client = $confidentialClient; + + // Send the patch request. + return $this->response->get( + $this->http->patch( + $this->uri->get($path), + json_encode($data) + ) + ); + } + +} + diff --git a/libraries/jcb_powers/VDM.Joomla.Gitea/src/User/Emails.php b/libraries/jcb_powers/VDM.Joomla.Gitea/src/User/Emails.php new file mode 100644 index 0000000..aa63b28 --- /dev/null +++ b/libraries/jcb_powers/VDM.Joomla.Gitea/src/User/Emails.php @@ -0,0 +1,94 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ + +namespace VDM\Joomla\Gitea\User; + + +use VDM\Joomla\Gitea\Abstraction\Api; + + +/** + * The Gitea User Emails + * + * @since 3.2.0 + */ +class Emails extends Api +{ + /** + * List the authenticated user's email addresses. + * + * @return array|null + * @since 3.2.0 + **/ + public function list(): ?array + { + // Build the request path. + $path = '/user/emails'; + + // Send the get request. + return $this->response->get( + $this->http->get( + $this->uri->get($path) + ) + ); + } + + /** + * Add email addresses for the authenticated user. + * + * @param array $emails An array of email addresses to add. + * + * @return array|null + * @since 3.2.0 + **/ + public function add(array $emails): ?array + { + // Build the request path. + $path = '/user/emails'; + + // Create the request body. + $body = new \stdClass(); + $body->emails = $emails; + + // Send the post request. + return $this->response->get( + $this->http->post( + $this->uri->get($path), + json_encode($body) + ), 201 + ); + } + + /** + * Delete email addresses for the authenticated user. + * + * @param array $$emails An array of email addresses to delete. + * + * @return string + * @since 3.2.0 + **/ + public function delete(array $emails): string + { + // Build the request path. + $path = '/user/emails'; + + // Build the URI. + $uri = $this->uri->get($path); + $uri->setVar('emails', json_encode($emails)); + + // Send the delete request. + return $this->response->get( + $this->http->delete($uri), 204, 'success' + ); + } + +} + diff --git a/libraries/jcb_powers/VDM.Joomla.Gitea/src/User/Followers.php b/libraries/jcb_powers/VDM.Joomla.Gitea/src/User/Followers.php new file mode 100644 index 0000000..71b028a --- /dev/null +++ b/libraries/jcb_powers/VDM.Joomla.Gitea/src/User/Followers.php @@ -0,0 +1,54 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ + +namespace VDM\Joomla\Gitea\User; + + +use VDM\Joomla\Gitea\Abstraction\Api; + + +/** + * The Gitea User Followers + * + * @since 3.2.0 + */ +class Followers extends Api +{ + /** + * List the authenticated user's followers. + * + * @param int $page Page number of results to return (1-based). + * @param int $limit Page size of results. + * + * @return array|null + * @since 3.2.0 + **/ + public function list( + int $page = 1, + int $limit = 10 + ): ?array + { + // Build the request path. + $path = '/user/followers'; + + // Build the URL + $url = $this->uri->get($path); + $url->setVar('page', $page); + $url->setVar('limit', $limit); + + // Send the get request. + return $this->response->get( + $this->http->get($url) + ); + } + +} + diff --git a/libraries/jcb_powers/VDM.Joomla.Gitea/src/User/Following.php b/libraries/jcb_powers/VDM.Joomla.Gitea/src/User/Following.php new file mode 100644 index 0000000..3392449 --- /dev/null +++ b/libraries/jcb_powers/VDM.Joomla.Gitea/src/User/Following.php @@ -0,0 +1,122 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ + +namespace VDM\Joomla\Gitea\User; + + +use VDM\Joomla\Gitea\Abstraction\Api; + + +/** + * The Gitea User Following + * + * @since 3.2.0 + */ +class Following extends Api +{ + /** + * List the users that the authenticated user is following. + * + * @param int $page Page number of results to return (1-based). + * @param int $limit Page size of results. + * + * @return array|null + * @since 3.2.0 + **/ + public function list( + int $page = 1, + int $limit = 10 + ): ?array + { + // Build the request path. + $path = '/user/following'; + + // Build the URL + $url = $this->uri->get($path); + $url->setVar('page', $page); + $url->setVar('limit', $limit); + + // Send the get request. + return $this->response->get( + $this->http->get($url) + ); + } + + /** + * Check whether a user is followed by the authenticated user. + * + * @param string $username The username to check. + * + * @return bool + * @since 3.2.0 + **/ + public function check(string $username): bool + { + // Build the request path. + $path = "/user/following/{$username}"; + + // Send the get request. + $response = $this->http->get( + $this->uri->get($path) + ); + + // Check if the user is followed by the authenticated user. + if ($response->code === 204) + { + return true; + } + return false; + } + + /** + * Follow a user. + * + * @param string $username The username to follow. + * + * @return string + * @since 3.2.0 + **/ + public function follow(string $username): string + { + // Build the request path. + $path = "/user/following/{$username}"; + + // Send the put request. + return $this->response->get( + $this->http->put( + $this->uri->get($path), '' + ), 204, 'success' + ); + } + + /** + * Unfollow a user. + * + * @param string $username The username to unfollow. + * + * @return string + * @since 3.2.0 + **/ + public function unfollow(string $username): string + { + // Build the request path. + $path = "/user/following/{$username}"; + + // Send the delete request. + return $this->response->get( + $this->http->delete( + $this->uri->get($path) + ), 204, 'success' + ); + } + +} + diff --git a/libraries/jcb_powers/VDM.Joomla.Gitea/src/User/Gpg.php b/libraries/jcb_powers/VDM.Joomla.Gitea/src/User/Gpg.php new file mode 100644 index 0000000..bf8f6c6 --- /dev/null +++ b/libraries/jcb_powers/VDM.Joomla.Gitea/src/User/Gpg.php @@ -0,0 +1,173 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ + +namespace VDM\Joomla\Gitea\User; + + +use VDM\Joomla\Gitea\Abstraction\Api; + + +/** + * The Gitea User Gpg + * + * @since 3.2.0 + */ +class Gpg extends Api +{ + /** + * Create a GPG key for the authenticated user. + * + * @param string $armoredPublicKey The armored public GPG key. + * @param string|null $armoredSignature The armored signature (optional). + * + * @return object|null + * @since 3.2.0 + **/ + public function createGPGKey( + string $armoredPublicKey, + ?string $armoredSignature = null + ): ?object + { + // Build the request path. + $path = '/user/gpg_keys'; + + // Set the GPG key data. + $data = array_filter([ + 'armored_public_key' => $armoredPublicKey, + 'armored_signature' => $armoredSignature + ]); + + // Send the post request. + return $this->response->get( + $this->http->post( + $this->uri->get($path), + json_encode($data) + ), 201 + ); + } + + /** + * Get a GPG key for the authenticated user. + * + * @param int $id The GPG key ID. + * + * @return object|null + * @since 3.2.0 + **/ + public function get(int $id): ?object + { + // Build the request path. + $path = "/user/gpg_keys/{$id}"; + + // Send the get request. + return $this->response->get( + $this->http->get( + $this->uri->get($path) + ) + ); + } + + /** + * Get a token to verify. + * + * @return string|null + * @since 3.2.0 + **/ + public function token(): ?string + { + // Build the request path. + $path = '/user/gpg_key_token'; + + // Send the get request. + return $this->response->get( + $this->http->get( + $this->uri->get($path) + ) + ); + } + + /** + * Verify a GPG key. + * + * @param string $armoredPublicKey The armored public GPG key. + * + * @return object|null + * @since 3.2.0 + **/ + public function verify(string $armoredPublicKey): ?object + { + // Build the request path. + $path = '/user/gpg_key_verify'; + + // Set the GPG key data. + $data = new \stdClass(); + $data->armoredPublicKey = $armoredPublicKey; + + // Send the post request. + return $this->response->get( + $this->http->post( + $this->uri->get($path), + json_encode($data) + ), 201 + ); + } + + /** + * List the authenticated user's GPG keys. + * + * @param int $page Page number of results to return (1-based). + * @param int $limit Page size of results. + * + * @return array|null + * @since 3.2.0 + **/ + public function list( + int $page = 1, + int $limit = 10 + ): ?array + { + // Build the request path. + $path = '/user/gpg_keys'; + + // Build the URL + $url = $this->uri->get($path); + $url->setVar('page', $page); + $url->setVar('limit', $limit); + + // Send the get request. + return $this->response->get( + $this->http->get($url) + ); + } + + /** + * Remove a GPG key for the authenticated user. + * + * @param int $id The GPG key ID. + * + * @return string + * @since 3.2.0 + **/ + public function remove(int $id): string + { + // Build the request path. + $path = "/user/gpg_keys/{$id}"; + + // Send the delete request. + return $this->response->get( + $this->http->delete( + $this->uri->get($path) + ), 204, 'success' + ); + } + +} + diff --git a/libraries/jcb_powers/VDM.Joomla.Gitea/src/User/Keys.php b/libraries/jcb_powers/VDM.Joomla.Gitea/src/User/Keys.php new file mode 100644 index 0000000..ed22c40 --- /dev/null +++ b/libraries/jcb_powers/VDM.Joomla.Gitea/src/User/Keys.php @@ -0,0 +1,135 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ + +namespace VDM\Joomla\Gitea\User; + + +use VDM\Joomla\Gitea\Abstraction\Api; + + +/** + * The Gitea User Keys + * + * @since 3.2.0 + */ +class Keys extends Api +{ + /** + * Create a public key for the authenticated user. + * + * @param string $title The title of the public key. + * @param string $key The content of the public key. + * @param bool $readOnly Optional. True if the key has only read access, false for read/write access. + * + * @return object|null + * @since 3.2.0 + **/ + public function create( + string $title, + string $key, + bool $readOnly = false + ): ?object + { + // Build the request path. + $path = '/user/keys'; + + // Set the public key data. + $data = new \stdClass(); + $data->title = $title; + $data->key = $key; + $data->read_only = $readOnly; + + // Send the post request. + return $this->response->get( + $this->http->post( + $this->uri->get($path), + json_encode($data) + ), 201 + ); + } + + /** + * List the authenticated user's public keys. + * + * @param string|null $fingerprint Optional. The fingerprint of the key. + * @param int $page Page number of results to return (1-based). + * @param int $limit Page size of results. + * + * @return array|null + * @since 3.2.0 + **/ + public function list( + ?string $fingerprint = null, + int $page = 1, + int $limit = 10 + ): ?array + { + // Build the request path. + $path = '/user/keys'; + + // Build the URI with query parameters. + $uri = $this->uri->get($path); + if ($fingerprint !== null) { + $uri->setVar('fingerprint', $fingerprint); + } + $uri->setVar('page', $page); + $uri->setVar('limit', $limit); + + // Send the get request. + return $this->response->get( + $this->http->get($uri) + ); + } + + /** + * Get a public key for the authenticated user. + * + * @param int $id The public key ID. + * + * @return object|null + * @since 3.2.0 + **/ + public function get(int $id): ?object + { + // Build the request path. + $path = "/user/keys/{$id}"; + + // Send the get request. + return $this->response->get( + $this->http->get( + $this->uri->get($path) + ) + ); + } + + /** + * Delete a public key for the authenticated user. + * + * @param int $id The public key ID. + * + * @return string + * @since 3.2.0 + **/ + public function delete(int $id): string + { + // Build the request path. + $path = "/user/keys/{$id}"; + + // Send the delete request. + return $this->response->get( + $this->http->delete( + $this->uri->get($path) + ), 204, 'success' + ); + } + +} + diff --git a/libraries/jcb_powers/VDM.Joomla.Gitea/src/User/Repos.php b/libraries/jcb_powers/VDM.Joomla.Gitea/src/User/Repos.php new file mode 100644 index 0000000..a7f8021 --- /dev/null +++ b/libraries/jcb_powers/VDM.Joomla.Gitea/src/User/Repos.php @@ -0,0 +1,188 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ + +namespace VDM\Joomla\Gitea\User; + + +use VDM\Joomla\Gitea\Abstraction\Api; + + +/** + * The Gitea User Repos + * + * @since 3.2.0 + */ +class Repos extends Api +{ + /** + * Create a repository for the authenticated user. + * + * @param string $name The name of the repository. + * @param string|null $description Optional. The description of the repository. + * @param bool $private Optional. Indicates whether the repository should be private or not. + * @param bool $autoInit Optional. Indicates whether the repository should be auto-initialized. + * @param string|null $defaultBranch Optional. The default branch of the repository. + * @param string|null $gitignores Optional. Gitignores to use. + * @param string|null $issueLabels Optional. Label-Set to use. + * @param string|null $license Optional. License to use. + * @param string|null $readme Optional. Readme of the repository to create. + * @param bool|null $template Optional. Whether the repository is a template. + * @param string|null $trustModel Optional. TrustModel of the repository. + * + * @return object|null + * @since 3.2.0 + **/ + public function create( + string $name, + ?string $description = null, + bool $private = false, + bool $autoInit = false, + ?string $defaultBranch = null, + ?string $gitignores = null, + ?string $issueLabels = null, + ?string $license = null, + ?string $readme = null, + ?bool $template = null, + ?string $trustModel = null + ): ?object { + // Build the request path. + $path = '/user/repos'; + + // Set the repository data. + $data = new \stdClass(); + $data->name = $name; + + if ($description !== null) + { + $data->description = $description; + } + + $data->private = $private; + $data->auto_init = $autoInit; + + if ($defaultBranch !== null) + { + $data->default_branch = $defaultBranch; + } + + if ($gitignores !== null) + { + $data->gitignores = $gitignores; + } + + if ($issueLabels !== null) + { + $data->issue_labels = $issueLabels; + } + + if ($license !== null) + { + $data->license = $license; + } + + if ($readme !== null) + { + $data->readme = $readme; + } + + if ($template !== null) + { + $data->template = $template; + } + + if ($trustModel !== null) + { + $data->trust_model = $trustModel; + } + + // Send the post request. + return $this->response->get( + $this->http->post( + $this->uri->get($path), + json_encode($data) + ), 201 + ); + } + + /** + * List the repos that the authenticated user owns. + * + * @param int $page Page number of results to return (1-based). + * @param int $limit Page size of results. + * + * @return array|null + * @since 3.2.0 + **/ + public function list( + int $page = 1, + int $limit = 10 + ): ?array + { + // Build the request path. + $path = '/user/repos'; + + // Build the URI with query parameters. + $uri = $this->uri->get($path); + $uri->setVar('page', $page); + $uri->setVar('limit', $limit); + + // Send the get request. + return $this->response->get( + $this->http->get($uri) + ); + } + + /** + * Star the given repo for the authenticated user. + * + * @param string $owner The owner name. + * @param string $repo The repository name. + * + * @return string + * @since 3.2.0 + **/ + public function star(string $owner, string $repo): string + { + // Build the request path. + $path = "/user/starred/{$owner}/{$repo}"; + + // Send the put request. + return $this->response->get( + $this->http->put( + $this->uri->get($path), '' + ), 204, 'success' + ); + } + + /** + * Unstar the given repo for the authenticated user. + * + * @param string $owner The owner name. + * @param string $repo The repository name. + * + * @return string + * @since 3.2.0 + **/ + public function unstar(string $owner, string $repo): string + { + // Build the request path. + $path = "/user/starred/{$owner}/{$repo}"; + + // Send the delete request. + return $this->response->get( + $this->http->delete( + $this->uri->get($path) + ), 204, 'success' + ); + } + +} + diff --git a/libraries/jcb_powers/VDM.Joomla.Gitea/src/User/Settings.php b/libraries/jcb_powers/VDM.Joomla.Gitea/src/User/Settings.php new file mode 100644 index 0000000..2118c9e --- /dev/null +++ b/libraries/jcb_powers/VDM.Joomla.Gitea/src/User/Settings.php @@ -0,0 +1,124 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ + +namespace VDM\Joomla\Gitea\User; + + +use VDM\Joomla\Gitea\Abstraction\Api; + + +/** + * The Gitea User Settings + * + * @since 3.2.0 + */ +class Settings extends Api +{ + /** + * Get user settings for the authenticated user. + * + * @return object|null + * @since 3.2.0 + **/ + public function get(): ?object + { + // Build the request path. + $path = '/user/settings'; + + // Send the get request. + return $this->response->get( + $this->http->get( + $this->uri->get($path) + ) + ); + } + + /** + * Update user settings for the authenticated user. + * + * @param string|null $description Optional. The description to update. + * @param string|null $diffViewStyle Optional. The diff view style to update. + * @param string|null $fullName Optional. The full name to update. + * @param bool|null $hideActivity Optional. Whether to hide activity or not. + * @param bool|null $hideEmail Optional. Whether to hide email or not. + * @param string|null $language Optional. The language to update. + * @param string|null $location Optional. The location to update. + * @param string|null $theme Optional. The theme to update. + * @param string|null $website Optional. The website to update. + * + * @return array|null + * @since 3.2.0 + **/ + public function update( + ?string $description = null, + ?string $diffViewStyle = null, + ?string $fullName = null, + ?bool $hideActivity = null, + ?bool $hideEmail = null, + ?string $language = null, + ?string $location = null, + ?string $theme = null, + ?string $website = null + ): ?array + { + // Prepare settings data + $settings = []; + if ($description !== null) + { + $settings['description'] = $description; + } + if ($diffViewStyle !== null) + { + $settings['diff_view_style'] = $diffViewStyle; + } + if ($fullName !== null) + { + $settings['full_name'] = $fullName; + } + if ($hideActivity !== null) + { + $settings['hide_activity'] = $hideActivity; + } + if ($hideEmail !== null) + { + $settings['hide_email'] = $hideEmail; + } + if ($language !== null) + { + $settings['language'] = $language; + } + if ($location !== null) + { + $settings['location'] = $location; + } + if ($theme !== null) + { + $settings['theme'] = $theme; + } + if ($website !== null) + { + $settings['website'] = $website; + } + + // Build the request path. + $path = '/user/settings'; + + // Send the patch request. + return $this->response->get( + $this->http->patch( + $this->uri->get($path), + json_encode($settings) + ) + ); + } + +} + diff --git a/libraries/jcb_powers/VDM.Joomla.Gitea/src/User/Starred.php b/libraries/jcb_powers/VDM.Joomla.Gitea/src/User/Starred.php new file mode 100644 index 0000000..2414066 --- /dev/null +++ b/libraries/jcb_powers/VDM.Joomla.Gitea/src/User/Starred.php @@ -0,0 +1,76 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ + +namespace VDM\Joomla\Gitea\User; + + +use VDM\Joomla\Gitea\Abstraction\Api; + + +/** + * The Gitea User Starred + * + * @since 3.2.0 + */ +class Starred extends Api +{ + /** + * List the repos that the authenticated user has starred. + * + * @param int $page Page number of results to return (1-based). + * @param int $limit Page size of results. + * + * @return array|null + * @since 3.2.0 + **/ + public function list( + int $page = 1, + int $limit = 10 + ): ?array + { + // Build the request path. + $path = '/user/starred'; + + // Build the URL + $url = $this->uri->get($path); + $url->setVar('page', $page); + $url->setVar('limit', $limit); + + // Send the get request. + return $this->response->get( + $this->http->get($url) + ); + } + + /** + * Check whether the authenticated user is starring the repo. + * + * @param string $owner The owner name. + * @param string $repo The repository name. + * + * @return string + * @since 3.2.0 + **/ + public function check(string $owner, string $repo): string + { + // Build the request path. + $path = "/user/starred/{$owner}/{$repo}"; + + // Send the get request. + return $this->response->get( + $this->http->get( + $this->uri->get($path) + ), 204, 'success' + ); + } + +} + diff --git a/libraries/jcb_powers/VDM.Joomla.Gitea/src/User/Subscriptions.php b/libraries/jcb_powers/VDM.Joomla.Gitea/src/User/Subscriptions.php new file mode 100644 index 0000000..b627803 --- /dev/null +++ b/libraries/jcb_powers/VDM.Joomla.Gitea/src/User/Subscriptions.php @@ -0,0 +1,54 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ + +namespace VDM\Joomla\Gitea\User; + + +use VDM\Joomla\Gitea\Abstraction\Api; + + +/** + * The Gitea User Subscriptions + * + * @since 3.2.0 + */ +class Subscriptions extends Api +{ + /** + * List repositories watched by the authenticated user. + * + * @param int $page Page number of results to return (1-based). + * @param int $limit Page size of results. + * + * @return array|null + * @since 3.2.0 + **/ + public function list( + int $page = 1, + int $limit = 10 + ): ?array + { + // Build the request path. + $path = '/user/subscriptions'; + + // Build the URL + $url = $this->uri->get($path); + $url->setVar('page', $page); + $url->setVar('limit', $limit); + + // Send the get request. + return $this->response->get( + $this->http->get($url) + ); + } + +} + diff --git a/libraries/jcb_powers/VDM.Joomla.Gitea/src/User/Teams.php b/libraries/jcb_powers/VDM.Joomla.Gitea/src/User/Teams.php new file mode 100644 index 0000000..ce3f32b --- /dev/null +++ b/libraries/jcb_powers/VDM.Joomla.Gitea/src/User/Teams.php @@ -0,0 +1,54 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ + +namespace VDM\Joomla\Gitea\User; + + +use VDM\Joomla\Gitea\Abstraction\Api; + + +/** + * The Gitea User Teams + * + * @since 3.2.0 + */ +class Teams extends Api +{ + /** + * List all the teams a user belongs to. + * + * @param int $page Page number of results to return (1-based). + * @param int $limit Page size of results. + * + * @return array|null + * @since 3.2.0 + **/ + public function list( + int $page = 1, + int $limit = 10 + ): ?array + { + // Build the request path. + $path = '/user/teams'; + + // Build the URL + $url = $this->uri->get($path); + $url->setVar('page', $page); + $url->setVar('limit', $limit); + + // Send the get request. + return $this->response->get( + $this->http->get($url) + ); + } + +} + diff --git a/libraries/jcb_powers/VDM.Joomla.Gitea/src/User/Times.php b/libraries/jcb_powers/VDM.Joomla.Gitea/src/User/Times.php new file mode 100644 index 0000000..0274058 --- /dev/null +++ b/libraries/jcb_powers/VDM.Joomla.Gitea/src/User/Times.php @@ -0,0 +1,96 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ + +namespace VDM\Joomla\Gitea\User; + + +use VDM\Joomla\Gitea\Abstraction\Api; + + +/** + * The Gitea User Times + * + * @since 3.2.0 + */ +class Times extends Api +{ + /** + * List the current user's tracked times. + * + * @param int $page Page number of results to return (1-based). + * @param int $limit Page size of results. + * @param string|null $since Optional. Only show times updated after the given time (RFC 3339 format). + * @param string|null $before Optional. Only show times updated before the given time (RFC 3339 format). + * + * @return array|null + * @since 3.2.0 + **/ + public function list( + int $page = 1, + int $limit = 10, + ?string $since = null, + ?string $before = null + ): ?array + { + // Build the request path. + $path = '/user/times'; + + // Build the URL + $url = $this->uri->get($path); + $url->setVar('page', $page); + $url->setVar('limit', $limit); + + if ($since !== null) + { + $url->setVar('since', $since); + } + + if ($before !== null) + { + $url->setVar('before', $before); + } + + // Send the get request. + return $this->response->get( + $this->http->get($url) + ); + } + + /** + * Get list of all existing stopwatches for the authenticated user. + * + * @param int $page Page number of results to return (1-based). + * @param int $limit Page size of results. + * + * @return array|null + * @since 3.2.0 + **/ + public function stopwatches( + int $page = 1, + int $limit = 10 + ): ?array + { + // Build the request path. + $path = '/user/stopwatches'; + + // Build the URL + $url = $this->uri->get($path); + $url->setVar('page', $page); + $url->setVar('limit', $limit); + + // Send the get request. + return $this->response->get( + $this->http->get($url) + ); + } + +} + diff --git a/libraries/jcb_powers/VDM.Joomla.Gitea/src/User/Tokens.php b/libraries/jcb_powers/VDM.Joomla.Gitea/src/User/Tokens.php new file mode 100644 index 0000000..431ba71 --- /dev/null +++ b/libraries/jcb_powers/VDM.Joomla.Gitea/src/User/Tokens.php @@ -0,0 +1,111 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ + +namespace VDM\Joomla\Gitea\User; + + +use VDM\Joomla\Gitea\Abstraction\Api; + + +/** + * The Gitea User Tokens + * + * @since 3.2.0 + */ +class Tokens extends Api +{ + /** + * List the authenticated user's access tokens. + * + * @param string $username The username of the authenticated user to retrieve access tokens for. + * @param int|null $page Optional. Page number of results to return (1-based). + * @param int|null $limit Optional. Page size of results. + * + * @return array|null + * @since 3.2.0 + **/ + public function list( + string $username, + ?int $page = null, + ?int $limit = null + ): ?array + { + // Build the request path. + $path = "/users/{$username}/tokens"; + + // Build the URL + $url = $this->uri->get($path); + if ($page !== null) + { + $url->setVar('page', $page); + } + if ($limit !== null) + { + $url->setVar('limit', $limit); + } + + // Send the get request. + return $this->response->get( + $this->http->get($url) + ); + } + + /** + * Create an access token for a user. + * + * @param string $username The username of the user to create the access token for. + * @param string $name The name of the access token. + * + * @return object|null + * @since 3.2.0 + **/ + public function create(string $username, string $name): ?object + { + // Build the request path. + $path = "/users/{$username}/tokens"; + + // Set the token data + $data = new \stdClass(); + $data->name = $name; + + // Send the post request. + return $this->response->get( + $this->http->post( + $this->uri->get($path), + json_encode($data) + ), 201 + ); + } + + /** + * Delete an access token for a user. + * + * @param string $username The username of the user to delete the access token for. + * @param string $token The token to delete. + * + * @return string + * @since 3.2.0 + **/ + public function delete(string $username, string $token): string + { + // Build the request path. + $path = "/users/{$username}/tokens/{$token}"; + + // Send the delete request. + return $this->response->get( + $this->http->delete( + $this->uri->get($path) + ), 204, 'success' + ); + } + +} + diff --git a/libraries/jcb_powers/VDM.Joomla.Gitea/src/User/index.html b/libraries/jcb_powers/VDM.Joomla.Gitea/src/User/index.html new file mode 100644 index 0000000..fa6d84e --- /dev/null +++ b/libraries/jcb_powers/VDM.Joomla.Gitea/src/User/index.html @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/libraries/jcb_powers/VDM.Joomla.Gitea/src/Utilities/Http.php b/libraries/jcb_powers/VDM.Joomla.Gitea/src/Utilities/Http.php new file mode 100644 index 0000000..7f0b817 --- /dev/null +++ b/libraries/jcb_powers/VDM.Joomla.Gitea/src/Utilities/Http.php @@ -0,0 +1,78 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ + +namespace VDM\Joomla\Gitea\Utilities; + + +use Joomla\CMS\Http\Http as JoomlaHttp; +use Joomla\Registry\Registry; + + +/** + * The Gitea Http + * + * @since 3.2.0 + */ +final class Http extends JoomlaHttp +{ + /** + * Constructor. + * + * @param string|null $token The Gitea API token. + * + * @since 3.2.0 + * @throws \InvalidArgumentException + **/ + public function __construct(?string $token) + { + // setup config + $config = [ + 'userAgent' => 'JoomlaGitea/3.0', + 'headers' => [ + 'Content-Type' => 'application/json' + ] + ]; + + // add the token if given + if (is_string($token)) + { + $config['headers']['Authorization'] = 'token ' . $token; + } + + $options = new Registry($config); + + // run parent constructor + parent::__construct($options); + } + + /** + * Change the Token. + * + * @param string $token The Gitea API token. + * + * @since 3.2.0 + **/ + public function setToken(string $token) + { + // get the current headers + $headers = (array) $this->getOption('headers', [ + 'Content-Type' => 'application/json' + ] + ); + + // add the token + $headers['Authorization'] = 'token ' . $token; + + $this->setOption('headers', $headers); + } + +} + diff --git a/libraries/jcb_powers/VDM.Joomla.Gitea/src/Utilities/Response.php b/libraries/jcb_powers/VDM.Joomla.Gitea/src/Utilities/Response.php new file mode 100644 index 0000000..4b3574e --- /dev/null +++ b/libraries/jcb_powers/VDM.Joomla.Gitea/src/Utilities/Response.php @@ -0,0 +1,146 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ + +namespace VDM\Joomla\Gitea\Utilities; + + +use Joomla\CMS\Http\Response as JoomlaResponse; +use VDM\Joomla\Utilities\JsonHelper; +use VDM\Joomla\Utilities\StringHelper; + + +/** + * The Gitea Response + * + * @since 3.2.0 + */ +final class Response +{ + /** + * Process the response and decode it. + * + * @param JoomlaResponse $response The response. + * @param integer $expectedCode The expected "good" code. + * @param mixed $default The default if body not have length + * + * @return mixed + * + * @since 3.2.0 + * @throws \DomainException + **/ + public function get(JoomlaResponse $response, int $expectedCode = 200, $default = null) + { + // Validate the response code. + if ($response->code != $expectedCode) + { + // Decode the error response and throw an exception. + $message = $this->error($response); + + throw new \DomainException("Invalid response received from API. $message", $response->code); + + } + + return $this->body($response, $default); + } + + /** + * Process the response and decode it. (when we have multiple success codes) + * + * @param JoomlaResponse $response The response. + * @param array [$expectedCode => $default] The expected "good" code. and The default if body not have length + * + * @return mixed + * + * @since 3.2.0 + * @throws \DomainException + **/ + public function get_(JoomlaResponse $response, array $validate = [200 => null]) + { + // Validate the response code. + if (!isset($validate[$response->code])) + { + // Decode the error response and throw an exception. + $message = $this->error($response); + + throw new \DomainException("Invalid response received from API. $message", $response->code); + + } + + return $this->body($response, $validate[$response->code]); + } + + /** + * Return the body from the response + * + * @param JoomlaResponse $response The response. + * @param mixed $default The default if body not have length + * + * @return mixed + * @since 3.2.0 + **/ + protected function body(JoomlaResponse $response, $default = null) + { + // check that we have a body and that its JSON + if (isset($response->body) && StringHelper::check($response->body)) + { + if (JsonHelper::check($response->body)) + { + $body = json_decode((string) $response->body); + + if (isset($body->content_base64)) + { + $body->content = base64_decode((string) $body->content_base64); + } + + return $body; + } + + return $response->body; + } + + return $default; + } + + /** + * Get the error message from the return object + * + * @param JoomlaResponse $response The response. + * + * @return string + * @since 3.2.0 + **/ + protected function error(JoomlaResponse $response): string + { + // do we have a json string + if (isset($response->body) && JsonHelper::check($response->body)) + { + $error = json_decode($response->body); + } + else + { + return ''; + } + + // check + if (isset($error->error)) + { + return $error->error; + } + elseif (isset($error->message)) + { + return $error->message; + } + + return ''; + } + +} + diff --git a/libraries/jcb_powers/VDM.Joomla.Gitea/src/Utilities/Uri.php b/libraries/jcb_powers/VDM.Joomla.Gitea/src/Utilities/Uri.php new file mode 100644 index 0000000..d31ac8e --- /dev/null +++ b/libraries/jcb_powers/VDM.Joomla.Gitea/src/Utilities/Uri.php @@ -0,0 +1,140 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ + +namespace VDM\Joomla\Gitea\Utilities; + + +use Joomla\Uri\Uri as JoomlaUri; + + +/** + * The Gitea Uri + * + * @since 3.2.0 + */ +final class Uri +{ + /** + * The api endpoint + * + * @var string + * @since 3.2.0 + */ + private string $endpoint; + + /** + * The api version + * + * @var string + * @since 3.2.0 + */ + private string $version; + + /** + * The api URL + * + * @var string + * @since 3.2.0 + */ + private string $url; + + /** + * Constructor + * + * @param string $url URL to the gitea system + * example: https://git.vdm.dev + * @param string $endpoint Endpoint to the gitea system + * @param string $version Version to the gitea system + * + * @since 3.2.0 + **/ + public function __construct( + string $url = 'https://git.vdm.dev', + string $endpoint = 'api', + string $version = 'v1') + { + // set the API details + $this->setUrl($url); + $this->setEndpoint($endpoint); + $this->setVersion($version); + } + + /** + * Method to build and return a full request URL for the request. This method will + * add appropriate pagination details if necessary and also prepend the API url + * to have a complete URL for the request. + * + * @param string $path URL to inflect + * + * @return JoomlaUri + * @since 3.2.0 + **/ + public function get(string $path): JoomlaUri + { + // Get a new Uri object focusing the api url and given path. + $uri = new JoomlaUri($this->api() . $path); + + return $uri; + } + + /** + * Get the full API URL + * + * @return string + * @since 3.2.0 + **/ + public function api(): string + { + return $this->url . '/' . $this->endpoint . '/' . $this->version; + } + + /** + * Set the URL of the API + * + * @param string $url URL to your gitea system + * example: https://git.vdm.dev + * + * @return void + * @since 3.2.0 + **/ + public function setUrl(string $url) + { + return $this->url = $url; + } + + /** + * Set the endpoint of the API + * + * @param string $endpoint endpoint to your gitea API + * + * @return void + * @since 3.2.0 + **/ + private function setEndpoint(string $endpoint) + { + return $this->endpoint = $endpoint; + } + + /** + * Set the version of the API + * + * @param string $version version to your gitea API + * + * @return void + * @since 3.2.0 + **/ + private function setVersion($version) + { + return $this->version = $version; + } + +} + diff --git a/libraries/jcb_powers/VDM.Joomla.Gitea/src/Utilities/index.html b/libraries/jcb_powers/VDM.Joomla.Gitea/src/Utilities/index.html new file mode 100644 index 0000000..fa6d84e --- /dev/null +++ b/libraries/jcb_powers/VDM.Joomla.Gitea/src/Utilities/index.html @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/libraries/jcb_powers/VDM.Joomla.Gitea/src/index.html b/libraries/jcb_powers/VDM.Joomla.Gitea/src/index.html new file mode 100644 index 0000000..fa6d84e --- /dev/null +++ b/libraries/jcb_powers/VDM.Joomla.Gitea/src/index.html @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/libraries/jcb_powers/VDM.Joomla.Openai/index.html b/libraries/jcb_powers/VDM.Joomla.Openai/index.html new file mode 100644 index 0000000..fa6d84e --- /dev/null +++ b/libraries/jcb_powers/VDM.Joomla.Openai/index.html @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/libraries/jcb_powers/VDM.Joomla.Openai/src/Abstraction/Api.php b/libraries/jcb_powers/VDM.Joomla.Openai/src/Abstraction/Api.php new file mode 100644 index 0000000..2824706 --- /dev/null +++ b/libraries/jcb_powers/VDM.Joomla.Openai/src/Abstraction/Api.php @@ -0,0 +1,67 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ + +namespace VDM\Joomla\Openai\Abstraction; + + +use VDM\Joomla\Openai\Utilities\Http; +use VDM\Joomla\Openai\Utilities\Uri; +use VDM\Joomla\Openai\Utilities\Response; + + +/** + * The Openai Api + * + * @since 3.2.0 + */ +abstract class Api +{ + /** + * The Http class + * + * @var Http + * @since 3.2.0 + */ + protected Http $http; + + /** + * The Uri class + * + * @var Uri + * @since 3.2.0 + */ + protected Uri $uri; + + /** + * The Response class + * + * @var Response + * @since 3.2.0 + */ + protected Response $response; + + /** + * Constructor. + * + * @param Http $http The http class. + * @param Uri $uri The uri class. + * @param Response $response The response class. + * + * @since 3.2.0 + **/ + public function __construct(Http $http, Uri $uri, Response $response) + { + $this->http = $http; + $this->uri = $uri; + $this->response = $response; + } +} + diff --git a/libraries/jcb_powers/VDM.Joomla.Openai/src/Abstraction/index.html b/libraries/jcb_powers/VDM.Joomla.Openai/src/Abstraction/index.html new file mode 100644 index 0000000..fa6d84e --- /dev/null +++ b/libraries/jcb_powers/VDM.Joomla.Openai/src/Abstraction/index.html @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/libraries/jcb_powers/VDM.Joomla.Openai/src/Chat.php b/libraries/jcb_powers/VDM.Joomla.Openai/src/Chat.php new file mode 100644 index 0000000..deb9097 --- /dev/null +++ b/libraries/jcb_powers/VDM.Joomla.Openai/src/Chat.php @@ -0,0 +1,142 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ + +namespace VDM\Joomla\Openai; + + +use VDM\Joomla\Openai\Abstraction\Api; + + +/** + * The Openai Chat + * + * @since 3.2.0 + */ +class Chat extends Api +{ + /** + * Create a chat completion with the OpenAI API. + * API Ref: https://platform.openai.com/docs/api-reference/chat/create + * + * @param string $model The model to use for completion. + * @param array $messages A list of messages describing the conversation so far. + * + * Each item in the array is an object with the following: + * - role (string) Required + * The role of the author of this message. + * One of system, user, or assistant. + * - content (string) Required + * The contents of the message. + * - name (string) Optional + * The name of the author of this message. + * May contain a-z, A-Z, 0-9, and underscores, + * with a maximum length of 64 characters. + * + * @param int|null $maxTokens Maximum number of tokens to generate (optional). + * @param float|null $temperature The sampling temperature to use (optional). + * @param float|null $topP The nucleus sampling parameter (optional). + * @param int|null $n The number of chat completion choices to generate (optional). + * @param bool|null $stream Partial message deltas (optional). + * @param mixed|null $stop Sequences where the API will stop generating tokens (optional). + * @param float|null $presencePenalty Penalty for new tokens based on whether they appear in the text (optional). + * @param float|null $frequencyPenalty Penalty for new tokens based on their frequency in the text (optional). + * @param array|null $logitBias Modify the likelihood of specified tokens appearing (optional). + * @param string|null $user A unique identifier representing the end-user (optional). + * + * @return object|null + * @since 3.2.0 + **/ + public function create( + string $model, + array $messages, + ?int $maxTokens = null, + ?float $temperature = null, + ?float $topP = null, + ?int $n = null, + ?bool $stream = null, + $stop = null, + ?float $presencePenalty = null, + ?float $frequencyPenalty = null, + ?array $logitBias = null, + ?string $user = null + ): ?object + { + // Build the request path. + $path = "/chat/completions"; + + // Set the request data. + $data = new \stdClass(); + $data->model = $model; + $data->messages = $messages; + + if ($maxTokens !== null) + { + $data->max_tokens = $maxTokens; + } + + if ($temperature !== null) + { + $data->temperature = $temperature; + } + + if ($topP !== null) + { + $data->top_p = $topP; + } + + if ($n !== null) + { + $data->n = $n; + } + + if ($stream !== null) + { + $data->stream = $stream; + } + + if ($stop !== null) + { + $data->stop = $stop; + } + + if ($presencePenalty !== null) + { + $data->presence_penalty = $presencePenalty; + } + + if ($frequencyPenalty !== null) + { + $data->frequency_penalty = $frequencyPenalty; + } + + if ($logitBias !== null) + { + $data->logit_bias = new \stdClass(); + foreach ($logitBias as $key => $val) + { + $data->logit_bias->$key = $val; + } + } + + if ($user !== null) + { + $data->user = $user; + } + + // Send the post request. + return $this->response->get( + $this->http->post( + $this->uri->get($path), json_encode($data) + ) + ); + } +} + diff --git a/libraries/jcb_powers/VDM.Joomla.Openai/src/Completions.php b/libraries/jcb_powers/VDM.Joomla.Openai/src/Completions.php new file mode 100644 index 0000000..65769df --- /dev/null +++ b/libraries/jcb_powers/VDM.Joomla.Openai/src/Completions.php @@ -0,0 +1,158 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ + +namespace VDM\Joomla\Openai; + + +use VDM\Joomla\Openai\Abstraction\Api; + + +/** + * The Openai Completions + * + * @since 3.2.0 + */ +class Completions extends Api +{ + /** + * Create a completion using the OpenAI API. + * API Ref: https://platform.openai.com/docs/api-reference/completions + * + * @param string $model The ID of the model to use. + * @param string|array $prompt The prompt(s) to generate completions for. + * @param int|null $maxTokens The maximum number of tokens to generate (optional). + * @param float|null $temperature The sampling temperature to use (optional). + * @param string $suffix The suffix that comes after a completion of inserted text. (optional). + * @param float|null $topP The top_p value for nucleus sampling (optional). + * @param int|null $n How many completions to generate (optional). + * @param bool|null $stream Whether to stream back partial progress (optional). + * @param int|null $logprobs Include the log probabilities on the most likely tokens (optional). + * @param bool|null $echo Echo back the prompt in addition to the completion (optional). + * @param string|null $stop Up to 4 sequences where the API will stop generating (optional). + * @param float|null $presencePenalty The presence penalty to use (optional). + * @param float|null $frequencyPenalty The frequency penalty to use (optional). + * @param int|null $bestOf Generates best_of completions server-side (optional). + * @param array|null $logitBias Modify the likelihood of specified tokens (optional). + * @param string|null $user A unique identifier representing your end-user (optional). + * + * @return object|null + * @since 3.2.0 + **/ + public function create( + string $model, + $prompt, + ?int $maxTokens = null, + ?string $suffix = null, + ?float $temperature = null, + ?float $topP = null, + ?int $n = null, + ?bool $stream = null, + ?int $logprobs = null, + ?bool $echo = null, + $stop = null, + ?float $presencePenalty = null, + ?float $frequencyPenalty = null, + ?int $bestOf = null, + ?array $logitBias = null, + ?string $user = null + ): ?object + { + // Build the request path. + $path = "/completions"; + + // Set the completion data. + $data = new \stdClass(); + $data->model = $model; + $data->prompt = $prompt; + + if ($maxTokens !== null) + { + $data->max_tokens = $maxTokens; + } + + if ($temperature !== null) + { + $data->temperature = $temperature; + } + + if ($suffix !== null) + { + $data->suffix = $suffix; + } + + if ($topP !== null) + { + $data->top_p = $topP; + } + + if ($n !== null) + { + $data->n = $n; + } + + if ($stream !== null) + { + $data->stream = $stream; + } + + if ($logprobs !== null) + { + $data->logprobs = $logprobs; + } + + if ($echo !== null) + { + $data->echo = $echo; + } + + if ($stop !== null) + { + $data->stop = $stop; + } + + if ($presencePenalty !== null) + { + $data->presence_penalty = $presencePenalty; + } + + if ($frequencyPenalty !== null) + { + $data->frequency_penalty = $frequencyPenalty; + } + + if ($bestOf !== null) + { + $data->best_of = $bestOf; + } + + if ($logitBias !== null) + { + $data->logit_bias = new \stdClass(); + foreach ($logitBias as $key => $val) + { + $data->logit_bias->$key = $val; + } + } + + if ($user !== null) + { + $data->user = $user; + } + + // Send the post request. + return $this->response->get( + $this->http->post( + $this->uri->get($path), json_encode($data) + ) + ); + } +} + diff --git a/libraries/jcb_powers/VDM.Joomla.Openai/src/Models.php b/libraries/jcb_powers/VDM.Joomla.Openai/src/Models.php new file mode 100644 index 0000000..034cdd3 --- /dev/null +++ b/libraries/jcb_powers/VDM.Joomla.Openai/src/Models.php @@ -0,0 +1,44 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ + +namespace VDM\Joomla\Openai; + + +use VDM\Joomla\Openai\Abstraction\Api; + + +/** + * The Openai Models + * + * @since 3.2.0 + */ +class Models extends Api +{ + /** + * List the available models from OpenAI API. + * + * @return object|null + * @since 3.2.0 + **/ + public function list(): ?object + { + // Build the request path. + $path = "/models"; + + // Send the get request. + return $this->response->get( + $this->http->get( + $this->uri->get($path) + ) + ); + } +} + diff --git a/libraries/jcb_powers/VDM.Joomla.Openai/src/Moderate.php b/libraries/jcb_powers/VDM.Joomla.Openai/src/Moderate.php new file mode 100644 index 0000000..5f02896 --- /dev/null +++ b/libraries/jcb_powers/VDM.Joomla.Openai/src/Moderate.php @@ -0,0 +1,60 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ + +namespace VDM\Joomla\Openai; + + +use VDM\Joomla\Openai\Abstraction\Api; + + +/** + * The Openai Moderate + * + * @since 3.2.0 + */ +class Moderate extends Api +{ + /** + * Classify if text violates OpenAI's Content Policy. + * API Ref: https://platform.openai.com/docs/api-reference/moderations/create + * + * @param string|array $input The input text to classify. + * @param string|null $model The moderation model (optional). + * + * @return object|null + * @since 3.2.0 + **/ + public function text( + $input, + ?string $model = null + ): ?object + { + // Build the request path. + $path = "/moderations"; + + // Set the moderation data. + $data = new \stdClass(); + $data->input = $input; + + if ($model !== null) + { + $data->model = $model; + } + + // Send the post request. + return $this->response->get( + $this->http->post( + $this->uri->get($path), json_encode($data) + ) + ); + } +} + diff --git a/libraries/jcb_powers/VDM.Joomla.Openai/src/Service/Utilities.php b/libraries/jcb_powers/VDM.Joomla.Openai/src/Service/Utilities.php new file mode 100644 index 0000000..b7f6a4c --- /dev/null +++ b/libraries/jcb_powers/VDM.Joomla.Openai/src/Service/Utilities.php @@ -0,0 +1,113 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ + +namespace VDM\Joomla\Openai\Service; + + +use Joomla\DI\Container; +use Joomla\DI\ServiceProviderInterface; +use VDM\Joomla\Openai\Utilities\Uri; +use VDM\Joomla\Openai\Utilities\Response; +use VDM\Joomla\Openai\Utilities\Http; +use VDM\Joomla\Utilities\Component\Helper; + + +/** + * The Openai Utilities Service + * + * @since 3.2.0 + */ +class Utilities implements ServiceProviderInterface +{ + /** + * Registers the service provider with a DI container. + * + * @param Container $container The DI container. + * + * @return void + * @since 3.2.0 + */ + public function register(Container $container) + { + $container->alias(Uri::class, 'Openai.Utilities.Uri') + ->share('Openai.Utilities.Uri', [$this, 'getUri'], true); + + $container->alias(Response::class, 'Openai.Utilities.Response') + ->share('Openai.Utilities.Response', [$this, 'getResponse'], true); + + $container->alias(Http::class, 'Openai.Utilities.Http') + ->share('Openai.Utilities.Http', [$this, 'getHttp'], true); + } + + /** + * Get the Uri class + * + * @param Container $container The DI container. + * + * @return Uri + * @since 3.2.0 + */ + public function getUri(Container $container): Uri + { + return new Uri(); + } + + /** + * Get the Response class + * + * @param Container $container The DI container. + * + * @return Response + * @since 3.2.0 + */ + public function getResponse(Container $container): Response + { + return new Response(); + } + + /** + * Get the Http class + * + * @param Container $container The DI container. + * + * @return Http + * @since 3.2.0 + */ + public function getHttp(Container $container): Http + { + $openai_token = null; + $openai_org_token = null; + if (Helper::getParams()->get('enable_open_ai') == 1) + { + $openai_token = Helper::getParams()->get('openai_token'); + if (Helper::getParams()->get('enable_open_ai_org') == 1) + { + $openai_org_token = Helper::getParams()->get('openai_org_token'); + } + + if ($openai_token === 'secret') + { + $openai_token = null; + } + + if ($openai_org_token === 'secret') + { + $openai_org_token = null; + } + } + + return new Http( + $openai_token, + $openai_org_token + ); + } +} + diff --git a/libraries/jcb_powers/VDM.Joomla.Openai/src/Service/index.html b/libraries/jcb_powers/VDM.Joomla.Openai/src/Service/index.html new file mode 100644 index 0000000..fa6d84e --- /dev/null +++ b/libraries/jcb_powers/VDM.Joomla.Openai/src/Service/index.html @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/libraries/jcb_powers/VDM.Joomla.Openai/src/Utilities/Http.php b/libraries/jcb_powers/VDM.Joomla.Openai/src/Utilities/Http.php new file mode 100644 index 0000000..6d0b705 --- /dev/null +++ b/libraries/jcb_powers/VDM.Joomla.Openai/src/Utilities/Http.php @@ -0,0 +1,139 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ + +namespace VDM\Joomla\Openai\Utilities; + + +use Joomla\CMS\Http\Http as JoomlaHttp; +use Joomla\Registry\Registry; + + +/** + * The Openai Http + * + * @since 3.2.0 + */ +final class Http extends JoomlaHttp +{ + /** + * The default Header + * + * @var array + * @since 3.2.0 + */ + protected array $defaultHeaders = ['Content-Type' => 'application/json']; + + /** + * Constructor. + * + * @param string|null $token The Openai API token. + * @param string|null $orgToken The Openai API Organization token. + * + * @since 3.2.0 + * @throws \InvalidArgumentException + **/ + public function __construct(?string $token, ?string $orgToken = null) + { + // add the token if given + if (is_string($token)) + { + $this->defaultHeaders['Authorization'] = 'Bearer ' . $token; + } + + // add the organization token if given + if (is_string($orgToken)) + { + $this->defaultHeaders['OpenAI-Organization'] = $orgToken; + } + + // setup config + $config = [ + 'userAgent' => 'JoomlaOpenai/3.0', + 'headers' => $this->defaultHeaders + ]; + + $options = new Registry($config); + + // run parent constructor + parent::__construct($options); + } + + /** + * Change the Tokens. + * + * @param string|null $token The Openai API token. + * @param string|null $orgToken The Openai API Organization token. + * + * @since 3.2.0 + **/ + public function setTokens(?string $token = null, ?string $orgToken = null) + { + // get the current headers + $this->defaultHeaders = (array) $this->getOption('headers', + $this->defaultHeaders + ); + + // add the token if given + if (is_string($token)) + { + $this->defaultHeaders['Authorization'] = 'Bearer ' . $token; + } + + // add the organization token if given + if (is_string($orgToken)) + { + $this->defaultHeaders['OpenAI-Organization'] = $orgToken; + } + + $this->setOption('headers', $this->defaultHeaders); + } + + /** + * Change the User Token. + * + * @param string $token The API token. + * + * @since 3.2.0 + **/ + public function setToken(string $token) + { + // get the current headers + $this->defaultHeaders = (array) $this->getOption('headers', + $this->defaultHeaders + ); + + // add the token + $this->defaultHeaders['Authorization'] = 'Bearer ' . $token; + + $this->setOption('headers', $this->defaultHeaders); + } + + /** + * Change the Organization Token. + * + * @param string $token The Organization API token. + * + * @since 3.2.0 + **/ + public function setOrgToken(string $token) + { + // get the current headers + $this->defaultHeaders = (array) $this->getOption('headers', + $this->defaultHeader + ); + + // add the token + $this->defaultHeaders['OpenAI-Organization'] = $token; + + $this->setOption('headers', $this->defaultHeaders); + } +} + diff --git a/libraries/jcb_powers/VDM.Joomla.Openai/src/Utilities/Response.php b/libraries/jcb_powers/VDM.Joomla.Openai/src/Utilities/Response.php new file mode 100644 index 0000000..b07d31d --- /dev/null +++ b/libraries/jcb_powers/VDM.Joomla.Openai/src/Utilities/Response.php @@ -0,0 +1,140 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ + +namespace VDM\Joomla\Openai\Utilities; + + +use Joomla\CMS\Http\Response as JoomlaResponse; +use VDM\Joomla\Utilities\JsonHelper; +use VDM\Joomla\Utilities\StringHelper; + + +/** + * The Openai Response + * + * @since 3.2.0 + */ +final class Response +{ + /** + * Process the response and decode it. + * + * @param JoomlaResponse $response The response. + * @param integer $expectedCode The expected "good" code. + * @param mixed $default The default if body not have length + * + * @return mixed + * + * @since 3.2.0 + * @throws \DomainException + **/ + public function get(JoomlaResponse $response, int $expectedCode = 200, $default = null) + { + // Validate the response code. + if ($response->code != $expectedCode) + { + // Decode the error response and throw an exception. + $message = $this->error($response); + + // Throw an exception with the OpenAI error message and code. + throw new \DomainException($message, $response->code); + } + + return $this->body($response, $default); + } + + /** + * Process the response and decode it. (when we have multiple success codes) + * + * @param JoomlaResponse $response The response. + * @param array [$expectedCode => $default] The expected "good" code. and The default if body not have length + * + * @return mixed + * + * @since 3.2.0 + * @throws \DomainException + **/ + public function get_(JoomlaResponse $response, array $validate = [200 => null]) + { + // Validate the response code. + if (!isset($validate[$response->code])) + { + // Decode the error response and throw an exception. + $message = $this->error($response); + + // Throw an exception with the OpenAI error message and code. + throw new \DomainException($message, $response->code); + + } + + return $this->body($response, $validate[$response->code]); + } + + /** + * Return the body from the response + * + * @param JoomlaResponse $response The response. + * @param mixed $default The default if body not have length + * + * @return mixed + * @since 3.2.0 + **/ + protected function body(JoomlaResponse $response, $default = null) + { + // check that we have a body and that its JSON + if (isset($response->body) && StringHelper::check($response->body)) + { + if (JsonHelper::check($response->body)) + { + return json_decode((string) $response->body); + } + + return $response->body; + } + + return $default; + } + + /** + * Get the error message from the OpenAI API response + * + * @param JoomlaResponse $response The response. + * + * @return string + * @since 3.2.0 + **/ + protected function error(JoomlaResponse $response): string + { + // do we have a json string + if (isset($response->body) && JsonHelper::check($response->body)) + { + $error = json_decode($response->body); + } + else + { + return 'Invalid or empty response body.'; + } + + // check if OpenAI returned an error object + if (isset($error->error)) + { + // error object found, extract message and code + $errorMessage = isset($error->error->message) ? $error->error->message : 'Unknown error.'; + $errorCode = isset($error->error->code) ? $error->error->code : 'Unknown error code.'; + + // return formatted error message + return 'OpenAI Error: ' . $errorMessage . ' Code: ' . $errorCode; + } + + return 'No error information found in response.'; + } +} + diff --git a/libraries/jcb_powers/VDM.Joomla.Openai/src/Utilities/Uri.php b/libraries/jcb_powers/VDM.Joomla.Openai/src/Utilities/Uri.php new file mode 100644 index 0000000..ceeb5cd --- /dev/null +++ b/libraries/jcb_powers/VDM.Joomla.Openai/src/Utilities/Uri.php @@ -0,0 +1,115 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ + +namespace VDM\Joomla\Openai\Utilities; + + +use Joomla\Uri\Uri as JoomlaUri; + + +/** + * The Openai Uri + * + * @since 3.2.0 + */ +final class Uri +{ + /** + * The api version + * + * @var string + * @since 3.2.0 + */ + private string $version; + + /** + * The api URL + * + * @var string + * @since 3.2.0 + */ + private string $url; + + /** + * Constructor + * + * @param string $url URL to the openai system + * example: https://api.openai.com + * @param string $version Version to the openai system + * + * @since 3.2.0 + **/ + public function __construct( + string $url = 'https://api.openai.com', + string $version = 'v1') + { + // set the API details + $this->setUrl($url); + $this->setVersion($version); + } + + /** + * Method to build and return a full request URL for the request. This method will + * add appropriate pagination details if necessary and also prepend the API url + * to have a complete URL for the request. + * + * @param string $path URL to inflect + * + * @return JoomlaUri + * @since 3.2.0 + **/ + public function get(string $path): JoomlaUri + { + // Get a new Uri object focusing the api url and given path. + $uri = new JoomlaUri($this->api() . $path); + + return $uri; + } + + /** + * Get the full API URL + * + * @return string + * @since 3.2.0 + **/ + public function api(): string + { + return $this->url . '/' . $this->version; + } + + /** + * Set the URL of the API + * + * @param string $url URL to your openai system + * example: https://api.openai.com + * + * @return void + * @since 3.2.0 + **/ + private function setUrl(string $url) + { + return $this->url = $url; + } + + /** + * Set the version of the API + * + * @param string $version version to your openai API + * + * @return void + * @since 3.2.0 + **/ + private function setVersion($version) + { + return $this->version = $version; + } +} + diff --git a/libraries/jcb_powers/VDM.Joomla.Openai/src/Utilities/index.html b/libraries/jcb_powers/VDM.Joomla.Openai/src/Utilities/index.html new file mode 100644 index 0000000..fa6d84e --- /dev/null +++ b/libraries/jcb_powers/VDM.Joomla.Openai/src/Utilities/index.html @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/libraries/jcb_powers/VDM.Joomla.Openai/src/index.html b/libraries/jcb_powers/VDM.Joomla.Openai/src/index.html new file mode 100644 index 0000000..fa6d84e --- /dev/null +++ b/libraries/jcb_powers/VDM.Joomla.Openai/src/index.html @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/libraries/jcb_powers/VDM.Joomla/index.html b/libraries/jcb_powers/VDM.Joomla/index.html new file mode 100644 index 0000000..fa6d84e --- /dev/null +++ b/libraries/jcb_powers/VDM.Joomla/index.html @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/libraries/jcb_powers/VDM.Joomla/src/Abstraction/BaseConfig.php b/libraries/jcb_powers/VDM.Joomla/src/Abstraction/BaseConfig.php new file mode 100644 index 0000000..fbd3c09 --- /dev/null +++ b/libraries/jcb_powers/VDM.Joomla/src/Abstraction/BaseConfig.php @@ -0,0 +1,122 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ + +namespace VDM\Joomla\Abstraction; + + +use Joomla\Registry\Registry as JoomlaRegistry; +use VDM\Joomla\Utilities\String\ClassfunctionHelper; + + +/** + * Config + * + * @since 3.2.0 + */ +abstract class BaseConfig extends JoomlaRegistry +{ + /** + * Constructor + * + * @since 3.2.0 + */ + public function __construct() + { + // Instantiate the internal data object. + $this->data = new \stdClass(); + } + + /** + * setting any config value + * + * @param string $key The value's key/path name + * @param mixed $value Optional default value, returned if the internal value is null. + * + * @since 3.2.0 + */ + public function __set(string $key, $value) + { + $this->set($key, $value); + } + + /** + * getting any valid value + * + * @param string $key The value's key/path name + * + * @since 3.2.0 + * @throws \InvalidArgumentException If $key is not a valid function name. + */ + public function __get(string $key) + { + // check if it has been set + if (($value = $this->get($key, '__N0T_S3T_Y3T_')) !== '__N0T_S3T_Y3T_') + { + return $value; + } + + throw new \InvalidArgumentException(sprintf('Argument %s could not be found as function or path.', $key)); + } + + /** + * Get a config value. + * + * @param string $path Registry path (e.g. joomla_content_showauthor) + * @param mixed $default Optional default value, returned if the internal value is null. + * + * @return mixed Value of entry or null + * + * @since 3.2.0 + */ + public function get($path, $default = null) + { + // function name with no underscores + $method = 'get' . ucfirst((string) ClassfunctionHelper::safe(str_replace('_', '', $path))); + + // check if it has been set + if (($value = parent::get($path, '__N0T_S3T_Y3T_')) !== '__N0T_S3T_Y3T_') + { + return $value; + } + elseif (method_exists($this, $method)) + { + $value = $this->{$method}($default); + + $this->set($path, $value); + + return $value; + } + + return $default; + } + + /** + * Append value to a path in registry of an array + * + * @param string $path Parent registry Path (e.g. joomla.content.showauthor) + * @param mixed $value Value of entry + * + * @return mixed The value of the that has been set. + * + * @since 3.2.0 + */ + public function appendArray(string $path, $value) + { + // check if it does not exist + if (!$this->exists($path)) + { + $this->set($path, []); + } + + return $this->append($path, $value); + } +} + diff --git a/libraries/jcb_powers/VDM.Joomla/src/Abstraction/BaseTable.php b/libraries/jcb_powers/VDM.Joomla/src/Abstraction/BaseTable.php new file mode 100644 index 0000000..468645b --- /dev/null +++ b/libraries/jcb_powers/VDM.Joomla/src/Abstraction/BaseTable.php @@ -0,0 +1,364 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ + +namespace VDM\Joomla\Abstraction; + + +use VDM\Joomla\Interfaces\Tableinterface; + + +/** + * Base Table + * + * @since 3.2.0 + */ +abstract class BaseTable implements Tableinterface +{ + /** + * All areas/views/tables with their field details + * + * @var array + * @since 3.2.0 + **/ + protected array $tables; + + /** + * All default fields + * + * @var array + * @since 3.2.0 + **/ + protected array $defaults = [ + 'id' => [ + 'order' => -1, + 'name' => 'id', + 'label' => 'ID', + 'type' => 'text', + 'title' => false, + 'list' => NULL, + 'store' => NULL, + 'tab_name' => NULL + ], + 'ordering' => [ + 'name' => 'ordering', + 'label' => 'Ordering', + 'type' => 'number', + 'title' => false, + 'list' => NULL, + 'store' => NULL, + 'tab_name' => NULL + ], + 'published' => [ + 'name' => 'published', + 'label' => 'Status', + 'type' => 'list', + 'title' => false, + 'list' => NULL, + 'store' => NULL, + 'tab_name' => NULL + ], + 'modified_by' => [ + 'name' => 'modified_by', + 'label' => 'Modified by', + 'type' => 'user', + 'title' => false, + 'list' => NULL, + 'store' => NULL, + 'tab_name' => NULL + ], + 'modified' => [ + 'name' => 'modified', + 'label' => 'Modified', + 'type' => 'calendar', + 'title' => false, + 'list' => NULL, + 'store' => NULL, + 'tab_name' => NULL + ], + 'created_by' => [ + 'name' => 'created_by', + 'label' => 'Created by', + 'type' => 'user', + 'title' => false, + 'list' => NULL, + 'store' => NULL, + 'tab_name' => NULL + ], + 'created' => [ + 'name' => 'created', + 'label' => 'Created', + 'type' => 'calendar', + 'title' => false, + 'list' => NULL, + 'store' => NULL, + 'tab_name' => NULL + ], + 'hits' => [ + 'name' => 'hits', + 'label' => 'Hits', + 'type' => 'number', + 'title' => false, + 'list' => NULL, + 'store' => NULL, + 'tab_name' => NULL + ], + 'version' => [ + 'name' => 'version', + 'label' => 'Version', + 'type' => 'text', + 'title' => false, + 'list' => NULL, + 'store' => NULL, + 'tab_name' => NULL + ] + ]; + + /** + * Get any value from a item/field/column of an area/view/table + * Example: $this->get('table_name', 'field_name', 'value_key'); + * Get an item/field/column of an area/view/table + * Example: $this->get('table_name', 'field_name'); + * Get all items/fields/columns of an area/view/table + * Example: $this->get('table_name'); + * Get all areas/views/tables with all their item/field/column details + * Example: $this->get('All'); + * + * @param string $table The table + * @param string|null $field The field + * @param string|null $key The value key + * + * @return mixed + * @since 3.2.0 + */ + public function get(string $table, ?string $field = null, ?string $key = null) + { + // return the item/field/column of an area/view/table + if (is_string($field) && is_string($key)) + { + // return the value of a item/field/column of an area/view/table + if (isset($this->tables[$table][$field][$key])) + { + return $this->tables[$table][$field][$key]; + } + + return $this->getDefaultKey($field, $key); + } + // return the item/field/column of an area/view/table + elseif (is_string($field)) + { + if (isset($this->tables[$table][$field])) + { + return $this->tables[$table][$field]; + } + + return $this->getDefault($field); + } + // return an area/view/table + elseif ($table !== 'All') + { + if (isset($this->tables[$table])) + { + return $this->tables[$table]; + } + return null; + } + + // return all + return $this->tables; + } + + /** + * Get title field from an area/view/table + * + * @param string $table The area + * + * @return ?array + * @since 3.2.0 + */ + public function title(string $table): ?array + { + // return the title item/field/column of an area/view/table + if (($table = $this->get($table)) !== null) + { + foreach ($table as $item) + { + if ($item['title']) + { + return $item; + } + } + } + + // none found + return null; + } + + /** + * Get title field name + * + * @param string $table The area + * + * @return string + * @since 3.2.0 + */ + public function titleName(string $table): string + { + // return the title name of an area/view/table + if (($field = $this->title($table)) !== null) + { + return $field['name']; + } + + // none found default to ID + return 'id'; + } + + /** + * Get all tables + * + * @return array + * @since 3.2.0 + */ + public function tables(): array + { + // return all areas/views/tables + return array_keys($this->tables); + } + + /** + * Check if a table (and field) exist + * + * @param string $table The area + * @param string|null $field The area + * + * @return bool + * @since 3.2.0 + */ + public function exist(string $table, ?string $field = null): bool + { + if (isset($this->tables[$table])) + { + // if we have a field + if (is_string($field)) + { + if (isset($this->tables[$table][$field])) + { + return true; + } + } + else + { + return true; + } + } + + return $this->isDefault($field); + } + + /** + * Get all fields of an area/view/table + * + * @param string $table The area + * @param bool $default Add the default fields + * + * @return array|null On success an array of fields + * @since 3.2.0 + */ + public function fields(string $table, bool $default = false): ?array + { + // return all fields of an area/view/table + if (($table = $this->get($table)) !== null) + { + if ($default) + { + return $this->addDefault(array_keys($table)); + } + else + { + return array_keys($table); + } + } + + // none found + return null; + } + + /** + * Add the default fields + * + * @param array $fields The table dynamic fields + * + * @return array Fields (with defaults added) + * @since 3.2.0 + */ + protected function addDefault(array $fields): array + { + // add default fields + foreach ($this->defaults as $default) + { + // used just for loading the fields + $order = $default['order'] ?? 1; + unset($default['order']); + + if ($order < 0) + { + array_unshift($fields, $default['name']); + } + else + { + $fields[] = $default['name']; + } + } + + return $fields; + } + + /** + * Check if the field is a default field + * + * @param string $field The field to check + * + * @return bool True if a default field + * @since 3.2.0 + */ + protected function isDefault(string $field): bool + { + return isset($this->defaults[$field]); + } + + /** + * Get a default field + * + * @param string $field The field to check + * + * @return array|null True if a default field + * @since 3.2.0 + */ + protected function getDefault(string $field): ?array + { + return $this->defaults[$field] ?? null; + } + + /** + * Get a default field property + * + * @param string $field The field to check + * @param string $key The field key/property to check + * + * @return string|null String value if a default field property exist + * @since 3.2.0 + */ + protected function getDefaultKey(string $field, string $key): ?string + { + return $this->defaults[$field][$key] ?? null; + } +} + diff --git a/libraries/jcb_powers/VDM.Joomla/src/Abstraction/Database.php b/libraries/jcb_powers/VDM.Joomla/src/Abstraction/Database.php new file mode 100644 index 0000000..f615e70 --- /dev/null +++ b/libraries/jcb_powers/VDM.Joomla/src/Abstraction/Database.php @@ -0,0 +1,118 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ + +namespace VDM\Joomla\Abstraction; + + +use Joomla\CMS\Factory as JoomlaFactory; +use VDM\Joomla\Utilities\Component\Helper; + + +/** + * Database + * + * @since 3.2.0 + */ +abstract class Database +{ + /** + * Database object to query local DB + * + * @var \JDatabaseDriver + * @since 3.2.0 + */ + protected \JDatabaseDriver $db; + + /** + * Core Component Table Name + * + * @var string + * @since 3.2.0 + */ + protected string $table; + + /** + * Constructor + * + * @param \JDatabaseDriver|null $db The database driver + * + * @throws \Exception + * @since 3.2.0 + */ + public function __construct(?\JDatabaseDriver $db = null) + { + $this->db = $db ?: JoomlaFactory::getDbo(); + + // set the component table + $this->table = '#__' . Helper::getCode(); + } + + /** + * Set a value based on data type + * + * @param mixed $value The value to set + * + * @return mixed + * @since 3.2.0 + **/ + protected function quote($value) + { + if ($value === null) // hmm the null does pose an issue (will keep an eye on this) + { + return 'NULL'; + } + + if (is_numeric($value)) + { + if (filter_var($value, FILTER_VALIDATE_INT)) + { + return (int) $value; + } + elseif (filter_var($value, FILTER_VALIDATE_FLOAT)) + { + return (float) $value; + } + } + elseif (is_bool($value)) // not sure if this will work well (but its correct) + { + return $value ? 'TRUE' : 'FALSE'; + } + + // For date and datetime values + if ($value instanceof \DateTime) + { + return $this->db->quote($value->format('Y-m-d H:i:s')); + } + + // For other data types, just escape it + return $this->db->quote($value); + } + + /** + * Set a table name, adding the + * core component as needed + * + * @param string $table The table string + * + * @return string + * @since 3.2.0 + **/ + protected function getTable(string $table): string + { + if (strpos($table, '#__') === false) + { + return $this->table . '_' . $table; + } + + return $table; + } +} + diff --git a/libraries/jcb_powers/VDM.Joomla/src/Abstraction/Model.php b/libraries/jcb_powers/VDM.Joomla/src/Abstraction/Model.php new file mode 100644 index 0000000..9321eef --- /dev/null +++ b/libraries/jcb_powers/VDM.Joomla/src/Abstraction/Model.php @@ -0,0 +1,358 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ + +namespace VDM\Joomla\Abstraction; + + +use VDM\Joomla\Utilities\StringHelper; +use VDM\Joomla\Utilities\ArrayHelper; +use VDM\Joomla\Interfaces\Tableinterface as Table; + + +/** + * Base Model + * + * @since 3.2.0 + */ +abstract class Model +{ + /** + * Last ID + * + * @var array + * @since 3.2.0 + */ + protected array $last; + + /** + * Search Table + * + * @var Table + * @since 3.2.0 + */ + protected Table $table; + + /** + * Constructor + * + * @param Table $table The search table object. + * + * @since 3.2.0 + */ + public function __construct(Table $table) + { + $this->table = $table; + } + + /** + * Model the value + * Example: $this->value(value, 'value_key', 'table_name'); + * + * @param mixed $value The value to model + * @param string $field The field key + * @param string|null $table The table + * + * @return mixed + * @since 3.2.0 + */ + abstract public function value($value, string $field, ?string $table = null); + + /** + * Model the values of an item + * Example: $this->item(Object, 'table_name'); + * + * @param object|null $item The item object + * @param string|null $table The table + * + * @return object|null + * @since 3.2.0 + */ + public function item(?object $item, ?string $table = null): ?object + { + // we must have an object + if (empty($item)) + { + return null; + } + + // set the table name + if (empty($table)) + { + $table = $this->getTable(); + } + + if (($fields = $this->getTableFields($table, true)) !== null) + { + // field counter + $field_number = 0; + + // check if this is a valid table + $item_bucket = new \stdClass(); + + foreach ($fields as $field) + { + // model a value if it exists + if(isset($item->{$field})) + { + if (!$this->validateBefore($item->{$field}, $field, $table)) + { + continue; + } + + $item->{$field} = $this->value($item->{$field}, $field, $table); + + if (!$this->validateAfter($item->{$field}, $field, $table)) + { + continue; + } + + $item_bucket->{$field} = $item->{$field}; + + $field_number++; + } + } + + // all items must have more than one field or its empty (1 = key) + if ($field_number > 1) + { + return $item_bucket; + } + } + + return null; + } + + /** + * Model the values of multiple items + * Example: $this->items(Array, 'table_name'); + * + * @param array|null $items The array of item objects + * @param string|null $table The table + * + * @return array|null + * @since 3.2.0 + */ + public function items(?array $items = null, ?string $table = null): ?array + { + // check if this is a valid table + if (ArrayHelper::check($items)) + { + // set the table name + if (empty($table)) + { + $table = $this->getTable(); + } + + foreach ($items as $id => &$item) + { + // model the item + if (($item = $this->item($item, $table)) !== null) + { + // add the last ID + $this->last[$table] = $item->id ?? $this->last[$table] ?? null; + } + else + { + unset($items[$id]); + } + } + + if (ArrayHelper::check($items)) + { + return $items; + } + } + + return null; + } + + /** + * Model the values of an row + * Example: $this->item(Array, 'table_name'); + * + * @param array|null $item The item array + * @param string|null $table The table + * + * @return array|null + * @since 3.2.0 + */ + public function row(?array $item, ?string $table = null): ?array + { + // we must have an array + if (empty($item)) + { + return null; + } + + // set the table name + if (empty($table)) + { + $table = $this->getTable(); + } + + if (($fields = $this->getTableFields($table, true)) !== null) + { + // field counter + $field_number = 0; + + // check if this is a valid table + $item_bucket = []; + + foreach ($fields as $field) + { + // model a value if it exists + if(isset($item[$field])) + { + if (!$this->validateBefore($item[$field], $field, $table)) + { + continue; + } + + $item[$field] = $this->value($item[$field], $field, $table); + + if (!$this->validateAfter($item[$field], $field, $table)) + { + continue; + } + + $item_bucket[$field] = $item[$field]; + + $field_number++; + } + } + + // all items must have more than one field or its empty (1 = id or guid) + if ($field_number > 1) + { + return $item_bucket; + } + } + + return null; + } + + /** + * Model the values of multiple rows + * Example: $this->items(Array, 'table_name'); + * + * @param array|null $items The array of item array + * @param string|null $table The table + * + * @return array|null + * @since 3.2.0 + */ + public function rows(?array $items = null, ?string $table = null): ?array + { + // check if this is a valid table + if (ArrayHelper::check($items)) + { + // set the table name + if (empty($table)) + { + $table = $this->getTable(); + } + + foreach ($items as $id => &$item) + { + // model the item + if (($item = $this->row($item, $table)) !== null) + { + // add the last ID + $this->last[$table] = $item['id'] ?? $this->last[$table] ?? null; + } + else + { + unset($items[$id]); + } + } + + if (ArrayHelper::check($items)) + { + return $items; + } + } + + return null; + } + + /** + * Get last modeled ID + * Example: $this->last('table_name'); + * + * @param string|null $table The table + * + * @return int|null + * @since 3.2.0 + */ + public function last(?string $table = null): ?int + { + // set the table name + if (empty($table)) + { + $table = $this->getTable(); + } + + // check if this is a valid table + if ($table && isset($this->last[$table])) + { + return $this->last[$table]; + } + + return null; + } + + /** + * Get the current active table's fields (including defaults) + * + * @param string $table The area + * @param bool $default Add the default fields + * + * @return array + * @since 3.2.0 + */ + protected function getTableFields(string $table, bool $default = false): ?array + { + return $this->table->fields($table, $default); + } + + /** + * Validate before the value is modelled (basic, override in child class) + * + * @param mixed $value The field value + * @param string|null $field The field key + * @param string|null $table The table + * + * @return bool + * @since 3.2.0 + */ + abstract protected function validateBefore(&$value, ?string $field = null, ?string $table = null): bool; + + /** + * Validate after the value is modelled (basic, override in child class) + * + * @param mixed $value The field value + * @param string|null $field The field key + * @param string|null $table The table + * + * @return bool + * @since 3.2.0 + */ + abstract protected function validateAfter(&$value, ?string $field = null, ?string $table = null): bool; + + /** + * Get the current active table + * + * @return string + * @since 3.2.0 + */ + abstract protected function getTable(): string; +} + diff --git a/libraries/jcb_powers/VDM.Joomla/src/Abstraction/index.html b/libraries/jcb_powers/VDM.Joomla/src/Abstraction/index.html new file mode 100644 index 0000000..fa6d84e --- /dev/null +++ b/libraries/jcb_powers/VDM.Joomla/src/Abstraction/index.html @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/libraries/jcb_powers/VDM.Joomla/src/Database/Insert.php b/libraries/jcb_powers/VDM.Joomla/src/Database/Insert.php new file mode 100644 index 0000000..bf7611a --- /dev/null +++ b/libraries/jcb_powers/VDM.Joomla/src/Database/Insert.php @@ -0,0 +1,290 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ + +namespace VDM\Joomla\Database; + + +use Joomla\CMS\Date\Date; +use VDM\Joomla\Utilities\ArrayHelper; +use VDM\Joomla\Interfaces\InsertInterface; +use VDM\Joomla\Abstraction\Database; + + +/** + * Database Insert Class + * + * @since 3.2.0 + */ +final class Insert extends Database implements InsertInterface +{ + /** + * Switch to set the defaults + * + * @var bool + * @since 1.2.0 + **/ + protected bool $defaults = true; + + /** + * Switch to prevent/allow defaults from being added. + * + * @param bool $trigger toggle the defaults + * + * @return void + * @since 3.2.0 + **/ + public function defaults(bool $trigger = true) + { + $this->defaults = $trigger; + } + + /** + * Insert rows to the database (with remapping and filtering columns option) + * + * @param array $data Dataset to store in database [array of arrays (key => value)] + * @param string $table The table where the data is being added + * @param array $columns Data columns for remapping and filtering + * + * @return bool + * @since 3.2.0 + **/ + public function rows(array $data, string $table, array $columns = []): bool + { + if (!ArrayHelper::check($data)) + { + return false; + } + + if ($columns === []) + { + $columns = $this->getArrayColumns($data); + } + + return ($columns === []) ? false : $this->insert($data, $table, $columns, true); + } + + /** + * Insert items to the database (with remapping and filtering columns option) + * + * @param array $data Data to store in database (array of objects) + * @param string $table The table where the data is being added + * @param array $columns Data columns for remapping and filtering + * + * @return bool + * @since 3.2.0 + **/ + public function items(array $data, string $table, array $columns = []): bool + { + if (!ArrayHelper::check($data)) + { + return false; + } + + if ($columns === []) + { + $columns = $this->getObjectsColumns($data); + } + + return ($columns === []) ? false : $this->insert($data, $table, $columns, false); + } + + /** + * Insert row to the database + * + * @param array $data Dataset to store in database (key => value) + * @param string $table The table where the data is being added + * + * @return bool + * @since 3.2.0 + **/ + public function row(array $data, string $table): bool + { + return $this->rows([$data], $table); + } + + /** + * Insert item to the database + * + * @param object $data Dataset to store in database (key => value) + * @param string $table The table where the data is being added + * + * @return bool + * @since 3.2.0 + **/ + public function item(object $data, string $table): bool + { + return $this->items([$data], $table); + } + + /** + * Get columns from data array + * + * @param array $data Data array + * + * @return array + * @since 3.2.0 + **/ + protected function getArrayColumns(array &$data): array + { + $row = array_values($data)[0]; + + if (!ArrayHelper::check($row)) + { + return []; + } + + $columns = array_keys($row); + + return array_combine($columns, $columns); + } + + /** + * Get columns from data objects + * + * @param array $data Data objects + * + * @return array + * @since 3.2.0 + **/ + protected function getObjectsColumns(array &$data): array + { + $row = array_values($data)[0]; + + if (!is_object($row)) + { + return []; + } + + $columns = get_object_vars($row); + + return array_combine(array_keys($columns), array_keys($columns)); + } + + /** + * Insert data into the database + * + * @param array $data Data to store in database + * @param string $table The table where the data is being added + * @param array $columns Data columns for remapping and filtering + * @param bool $isArray Whether the data is an array of arrays or an array of objects + * + * @return bool + * @since 3.2.0 + **/ + protected function insert(array &$data, string $table, array $columns, bool $isArray): bool + { + // set joomla default columns + $add_created = false; + $add_version = false; + $add_published = false; + + // check if we should load the defaults + if ($this->defaults) + { + // get the date + $date = (new Date())->toSql(); + + if (!isset($columns['created'])) + { + $columns['created'] = ' (o_O) '; + $add_created = true; + } + + if (!isset($columns['version'])) + { + $columns['version'] = ' (o_O) '; + $add_version = true; + } + + if (!isset($columns['published'])) + { + $columns['published'] = ' (o_O) '; + $add_published = true; + } + // the (o_O) prevents an empty value from being loaded + } + + // get a query object + $query = $this->db->getQuery(true); + + // set the query targets + $query->insert($this->db->quoteName($this->getTable($table)))->columns($this->db->quoteName(array_keys($columns))); + + // limiting factor on the amount of rows to insert before we reset the query + $limit = 300; + + // set the insert values + foreach ($data as $nr => $value) + { + // check the limit + if ($limit <= 1) + { + // execute and reset the query + $this->db->setQuery($query); + $this->db->execute(); + + // reset limit + $limit = 300; + + // get a query object + $query = $this->db->getQuery(true); + + // set the query targets + $query->insert($this->db->quoteName($this->getTable($table)))->columns($this->db->quoteName(array_keys($columns))); + } + + $row = []; + foreach ($columns as $column => $key) + { + if (' (o_O) ' !== $key) + { + $row[] = ($isArray && isset($value[$key])) ? $this->quote($value[$key]) + : ((!$isArray && isset($value->{$key})) ? $this->quote($value->{$key}) : ''); + } + } + + // set joomla default columns + if ($add_created) + { + $row[] = $this->db->quote($date); + } + + if ($add_version) + { + $row[] = 1; + } + + if ($add_published) + { + $row[] = 1; + } + + // add to query + $query->values(implode(',', $row)); + + // decrement the limiter + $limit--; + + // clear the data from memory + unset($data[$nr]); + } + + // execute the final query + $this->db->setQuery($query); + $this->db->execute(); + + // always reset the default switch + $this->defaults(); + + return true; + } +} + diff --git a/libraries/jcb_powers/VDM.Joomla/src/Database/Load.php b/libraries/jcb_powers/VDM.Joomla/src/Database/Load.php new file mode 100644 index 0000000..5d88778 --- /dev/null +++ b/libraries/jcb_powers/VDM.Joomla/src/Database/Load.php @@ -0,0 +1,446 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ + +namespace VDM\Joomla\Database; + + +use VDM\Joomla\Utilities\ArrayHelper; +use VDM\Joomla\Interfaces\LoadInterface; +use VDM\Joomla\Abstraction\Database; + + +/** + * Database Load + * + * @since 3.2.0 + */ +final class Load extends Database implements LoadInterface +{ + /** + * Load data rows as an array of associated arrays + * + * @param array $select Array of selection keys + * @param array $tables Array of tables to search + * @param array|null $where Array of where key=>value match exist + * @param array|null $order Array of how to order the data + * @param int|null $limit Limit the number of values returned + * + * @return array|null + * @since 3.2.0 + **/ + public function rows(array $select, array $tables, ?array $where = null, + ?array $order = null, ?int $limit = null): ?array + { + // set key if found + $key = ''; + if (isset($select['key'])) + { + if (is_string($select['key'])) + { + $key = $select['key']; + } + unset($select['key']); + } + + // check if we can get many rows + if ($this->many($select, $tables, $where, $order, $limit)) + { + // return associated arrays from the table records + return $this->db->loadAssocList($key); + } + + // data does not exist + return null; + } + + /** + * Load data rows as an array of objects + * + * @param array $select Array of selection keys + * @param array $tables Array of tables to search + * @param array|null $where Array of where key=>value match exist + * @param array|null $order Array of how to order the data + * @param int|null $limit Limit the number of values returned + * + * @return array|null + * @since 3.2.0 + **/ + public function items(array $select, array $tables, ?array $where = null, + ?array $order = null, ?int $limit = null): ?array + { + // set key if found + $key = ''; + if (isset($select['key'])) + { + if (is_string($select['key'])) + { + $key = $select['key']; + } + unset($select['key']); + } + + // check if we can get many rows + if ($this->many($select, $tables, $where, $order, $limit)) + { + // return associated arrays from the table records + return $this->db->loadObjectList($key); + } + + // data does not exist + return null; + } + + /** + * Load data row as an associated array + * + * @param array $select Array of selection keys + * @param array $tables Array of tables to search + * @param array|null $where Array of where key=>value match exist + * @param array|null $order Array of how to order the data + * + * @return array|null + * @since 3.2.0 + **/ + public function row(array $select, array $tables, ?array $where = null, ?array $order = null): ?array + { + // check if we can get one row + if ($this->one($select, $tables, $where, $order)) + { + return $this->db->loadAssoc(); + } + + // data does not exist + return null; + } + + /** + * Load data row as an object + * + * @param array $select Array of selection keys + * @param array $tables Array of tables to search + * @param array|null $where Array of where key=>value match exist + * @param array|null $order Array of how to order the data + * + * @return object|null + * @since 3.2.0 + **/ + public function item(array $select, array $tables, ?array $where = null, ?array $order = null): ?object + { + // check if we can get one row + if ($this->one($select, $tables, $where, $order)) + { + return $this->db->loadObject(); + } + + // data does not exist + return null; + } + + /** + * Get the max value based on a filtered result from a given table + * + * @param string $field The field key + * @param string $tables The tables + * @param array $filter The filter keys + * + * @return int|null + * @since 3.2.0 + **/ + public function max($field, array $tables, array $filter): ?int + { + // only do check if we have the table set + if (isset($tables['a'])) + { + // get the query + $query = $this->query(["all" => "MAX(`$field`)"], $tables, $filter); + + // Load the max number + $this->db->setQuery($query); + $this->db->execute(); + + // check if we have values + if ($this->db->getNumRows()) + { + return (int) $this->db->loadResult(); + } + } + + // data does not exist + return null; + } + + /** + * Count the number of items based on filter result from a given table + * + * @param string $tables The table + * @param array $filter The filter keys + * + * @return int|null + * @since 3.2.0 + **/ + public function count(array $tables, array $filter): ?int + { + // only do check if we have the table set + if (isset($tables['a'])) + { + // get the query + $query = $this->query(["all" => 'COUNT(*)'], $tables, $filter); + + // Load the max number + $this->db->setQuery($query); + $this->db->execute(); + + // check if we have values + if ($this->db->getNumRows()) + { + return (int) $this->db->loadResult(); + } + } + + // data does not exist + return null; + } + + /** + * Load one value from a row + * + * @param array $select Array of selection keys + * @param array $tables Array of tables to search + * @param array|null $where Array of where key=>value match exist + * @param array|null $order Array of how to order the data + * + * @return mixed + * @since 3.2.0 + **/ + public function value(array $select, array $tables, ?array $where = null, ?array $order = null) + { + // check if we can get one value + if ($this->one($select, $tables, $where, $order)) + { + return $this->db->loadResult(); + } + + // data does not exist + return null; + } + + /** + * Load many + * + * @param array $select Array of selection keys + * @param array $tables Array of tables to search + * @param array|null $where Array of where key=>value match exist + * @param array|null $order Array of how to order the data + * @param int|null $limit Limit the number of values returned + * + * @return bool + * @since 3.2.0 + **/ + protected function many(array $select, array $tables, ?array $where = null, + ?array $order = null, ?int $limit = null): bool + { + // only do check if we have the table set + if (isset($tables['a'])) + { + // get the query + $query = $this->query($select, $tables, $where, $order, $limit); + + // Load the items + $this->db->setQuery($query); + $this->db->execute(); + + // check if we have values + if ($this->db->getNumRows()) + { + return true; + } + } + + // data does not exist + return false; + } + + /** + * Load one + * + * @param array $select Array of selection keys + * @param array $tables Array of tables to search + * @param array|null $where Array of where key=>value match exist + * @param array|null $order Array of how to order the data + * + * @return bool + * @since 3.2.0 + **/ + protected function one(array $select, array $tables, ?array $where = null, ?array $order = null): bool + { + // only do check if we have the table set + if (isset($tables['a'])) + { + // get the query + $query = $this->query($select, $tables, $where, $order); + + // Load the item + $this->db->setQuery($query, 0, 1); + $this->db->execute(); + + // check if we have values + if ($this->db->getNumRows()) + { + return true; + } + } + + // data does not exist + return false; + } + + /** + * Get the query object + * + * @param array $select Array of selection keys + * @param array $tables Array of tables to search + * @param array|null $where Array of where key=>value match exist + * @param array|null $order Array of how to order the data + * @param int|null $limit Limit the number of values returned + * + * @return object|null The query object (DatabaseQuery) + * @since 3.2.0 + **/ + protected function query(array $select, array $tables, ?array $where = null, + ?array $order = null, ?int $limit = null): ?object + { + $query = $this->db->getQuery(true); + + // check if we have an all selection set + if (isset($select['all'])) + { + // all selection example array: ['all' => ['a.*', 'b.*']] + if (ArrayHelper::check($select['all'])) + { + foreach ($select['all'] as $select_all) + { + // set target selection + $query->select( + $select_all + ); + } + } + // all selection example string: ['all' =>'a.*'] + elseif (is_string($select['all'])) + { + // set target selection + $query->select( + $select['all'] + ); + } + unset($select['all']); + } + + // load the table where join + if (ArrayHelper::check($select)) + { + // set target selection + $query->select( + $this->db->quoteName( + array_keys($select), + array_values($select) + ) + ); + } + + // set main table + $query->from($this->db->quoteName($this->getTable($tables['a']), 'a')); + + // remove main table + unset($tables['a']); + + // load the table where join + if (ArrayHelper::check($tables)) + { + foreach ($tables as $as => $table) + { + $query->join( + 'LEFT', $this->db->quoteName( + $this->getTable($table['name']), $as + ) . ' ON (' . $this->db->quoteName($table['join_on']) + . ' = ' . $this->db->quoteName($table['as_on']) . ')' + ); + } + } + + // load the table where getters + if (ArrayHelper::check($where)) + { + foreach ($where as $key => $value) + { + if (ArrayHelper::check($value)) + { + if (isset($value['value']) && isset($value['operator'])) + { + if (ArrayHelper::check($value['value'])) + { + // add the where by array + $query->where($this->db->quoteName($key) . ' ' . + $value['operator'] . ' (' . + implode(',', + array_map( + fn($val) => $this->quote($val), + $value['value'] + ) + ) + . ')' + ); + } + else + { + // add the where + $query->where($this->db->quoteName($key) . ' ' . + $value['operator'] . ' ' . $this->quote($value['value'])); + } + } + else + { + // we should through an exception + // for security we just return nothing for now + return null; + } + } + else + { + // add the where + $query->where($this->db->quoteName($key) . + ' = ' . $this->quote($value)); + } + } + } + + // load the row ordering + if (ArrayHelper::check($order)) + { + foreach ($order as $key => $direction) + { + // add the ordering + $query->order($this->db->quoteName($key) . + ' ' . $direction); + } + } + + // only return a limited number + if (is_numeric($limit)) + { + $query->setLimit($limit); + } + + return $query; + } + +} + diff --git a/libraries/jcb_powers/VDM.Joomla/src/Database/Update.php b/libraries/jcb_powers/VDM.Joomla/src/Database/Update.php new file mode 100644 index 0000000..6c4a122 --- /dev/null +++ b/libraries/jcb_powers/VDM.Joomla/src/Database/Update.php @@ -0,0 +1,188 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ + +namespace VDM\Joomla\Database; + + +use VDM\Joomla\Interfaces\UpdateInterface; +use VDM\Joomla\Abstraction\Database; + + +/** + * Database Update Class + * + * @since 3.2.0 + */ +final class Update extends Database implements UpdateInterface +{ + /** + * Update rows in the database (with remapping and filtering columns option) + * + * @param array $data Dataset to update in database [array of arrays (key => value)] + * @param string $key Dataset key column to use in updating the values in the Database + * @param string $table The table where the data is being updated + * @param array $columns Data columns for remapping and filtering + * + * @return bool + * @since 3.2.0 + **/ + public function rows(array $data, string $key, string $table, array $columns = []): bool + { + // set the update columns + if ($data === [] || strlen($key) == 0) + { + return false; + } + + // set the update values + foreach ($data as $values) + { + if ($columns !== []) + { + // load only what is part of the columns set + $row = []; + foreach ($columns as $column => $key_) + { + if (isset($values[$key_])) + { + $row[$column] = $values[$key_]; + } + } + + // update the row + $this->row($row, $key, $table); + } + else + { + // update the row + $this->row((array) $values, $key, $table); + } + } + + return true; + } + + /** + * Update items in the database (with remapping and filtering columns option) + * + * @param array $data Data to updated in database (array of objects) + * @param string $key Dataset key column to use in updating the values in the Database + * @param string $table The table where the data is being update + * @param array $columns Data columns for remapping and filtering + * + * @return bool + * @since 3.2.0 + **/ + public function items(array $data, string $key, string $table, array $columns = []): bool + { + // set the update columns + if ($data === [] || strlen($key) == 0) + { + return false; + } + + // set the update values + foreach ($data as $nr => $values) + { + if ($columns !== []) + { + // load only what is part of the columns set + $row = []; + foreach ($columns as $column => $key_) + { + if (isset($values->{$key_})) + { + $row[$column] = $values->{$key_}; + } + } + + // update the row + $this->row($row, $key, $table); + } + else + { + // update the row + $this->row((array) $values, $key, $table); + } + } + + return true; + } + + /** + * Update row in the database + * + * @param array $data Dataset to update in database (key => value) + * @param string $key Dataset key column to use in updating the values in the Database + * @param string $table The table where the data is being updated + * + * @return bool + * @since 3.2.0 + **/ + public function row(array $data, string $key, string $table): bool + { + // set the update columns + if ($data === [] || strlen($key) == 0) + { + return false; + } + + // get a query object + $query = $this->db->getQuery(true); + + // set the query targets + $query->update($this->db->quoteName($this->getTable($table))); + + // set the update values + $key_ = null; + foreach ($data as $column => $value) + { + if ($column === $key) + { + $key_ = $value; + } + else + { + $query->set($this->db->quoteName($column) . ' = ' . $this->quote($value)); + } + } + + // add the key condition + if ($key_ !== null) + { + $query->where($this->db->quoteName($key) . ' = ' . $this->quote($key_)); + + // execute the final query + $this->db->setQuery($query); + + return $this->db->execute(); + } + + return false; + } + + /** + * Update item in the database + * + * @param object $data Dataset to update in database (key => value) + * @param string $key Dataset key column to use in updating the values in the Database + * @param string $table The table where the data is being updated + * + * @return bool + * @since 3.2.0 + **/ + public function item(object $data, string $key, string $table): bool + { + // convert to an array + return $this->row((array) get_object_vars($data), $key, $table); + } +} + diff --git a/libraries/jcb_powers/VDM.Joomla/src/Database/index.html b/libraries/jcb_powers/VDM.Joomla/src/Database/index.html new file mode 100644 index 0000000..fa6d84e --- /dev/null +++ b/libraries/jcb_powers/VDM.Joomla/src/Database/index.html @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/libraries/jcb_powers/VDM.Joomla/src/Interfaces/FactoryInterface.php b/libraries/jcb_powers/VDM.Joomla/src/Interfaces/FactoryInterface.php new file mode 100644 index 0000000..0dd2e4c --- /dev/null +++ b/libraries/jcb_powers/VDM.Joomla/src/Interfaces/FactoryInterface.php @@ -0,0 +1,41 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ + +namespace VDM\Joomla\Interfaces; + + +use Joomla\DI\Container; + + +/** + * The Container Factory Interface + */ +interface FactoryInterface +{ + /** + * Get any class from the container + * + * @param string $key The container class key + * + * @return Mixed + * @since 3.2.0 + */ + public static function _(string $key); + + /** + * Get the global container + * + * @return Container + * @since 3.2.0 + */ + public static function getContainer(): Container; +} + diff --git a/libraries/jcb_powers/VDM.Joomla/src/Interfaces/InsertInterface.php b/libraries/jcb_powers/VDM.Joomla/src/Interfaces/InsertInterface.php new file mode 100644 index 0000000..c76b97b --- /dev/null +++ b/libraries/jcb_powers/VDM.Joomla/src/Interfaces/InsertInterface.php @@ -0,0 +1,78 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ + +namespace VDM\Joomla\Interfaces; + + +/** + * Database Insert Interface + * + * @since 3.2.0 + */ +interface InsertInterface +{ + /** + * Switch to prevent/allow defaults from being added. + * + * @param bool $trigger toggle the defaults + * + * @return void + * @since 3.2.0 + **/ + public function defaults(bool $trigger = true); + + /** + * Insert rows to the database (with remapping and filtering columns option) + * + * @param array $data Dataset to store in database [array of arrays (key => value)] + * @param string $table The table where the data is being added + * @param array $columns Data columns for remapping and filtering + * + * @return bool + * @since 3.2.0 + **/ + public function rows(array $data, string $table, array $columns = []): bool; + + /** + * Insert items to the database (with remapping and filtering columns option) + * + * @param array $data Data to store in database (array of objects) + * @param string $table The table where the data is being added + * @param array $columns Data columns for remapping and filtering + * + * @return bool + * @since 3.2.0 + **/ + public function items(array $data, string $table, array $columns = []): bool; + + /** + * Insert row to the database + * + * @param array $data Dataset to store in database (key => value) + * @param string $table The table where the data is being added + * + * @return bool + * @since 3.2.0 + **/ + public function row(array $data, string $table): bool; + + /** + * Insert item to the database + * + * @param object $data Dataset to store in database (key => value) + * @param string $table The table where the data is being added + * + * @return bool + * @since 3.2.0 + **/ + public function item(object $data, string $table): bool; +} + diff --git a/libraries/jcb_powers/VDM.Joomla/src/Interfaces/LoadInterface.php b/libraries/jcb_powers/VDM.Joomla/src/Interfaces/LoadInterface.php new file mode 100644 index 0000000..31017c5 --- /dev/null +++ b/libraries/jcb_powers/VDM.Joomla/src/Interfaces/LoadInterface.php @@ -0,0 +1,114 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ + +namespace VDM\Joomla\Interfaces; + + +/** + * Database Load Interface + * + * @since 3.2.0 + */ +interface LoadInterface +{ + /** + * Load data rows as an array of associated arrays + * + * @param array $select Array of selection keys + * @param array $tables Array of tables to search + * @param array|null $where Array of where key=>value match exist + * @param array|null $order Array of how to order the data + * @param int|null $limit Limit the number of values returned + * + * @return array|null + * @since 3.2.0 + **/ + public function rows(array $select, array $tables, ?array $where = null, + ?array $order = null, ?int $limit = null): ?array; + + /** + * Load data rows as an array of objects + * + * @param array $select Array of selection keys + * @param array $tables Array of tables to search + * @param array|null $where Array of where key=>value match exist + * @param array|null $order Array of how to order the data + * @param int|null $limit Limit the number of values returned + * + * @return array|null + * @since 3.2.0 + **/ + public function items(array $select, array $tables, ?array $where = null, + ?array $order = null, ?int $limit = null): ?array; + + /** + * Load data row as an associated array + * + * @param array $select Array of selection keys + * @param array $tables Array of tables to search + * @param array|null $where Array of where key=>value match exist + * @param array|null $order Array of how to order the data + * + * @return array|null + * @since 3.2.0 + **/ + public function row(array $select, array $tables, ?array $where = null, ?array $order = null): ?array; + + /** + * Load data row as an object + * + * @param array $select Array of selection keys + * @param array $tables Array of tables to search + * @param array|null $where Array of where key=>value match exist + * @param array|null $order Array of how to order the data + * + * @return object|null + * @since 3.2.0 + **/ + public function item(array $select, array $tables, ?array $where = null, ?array $order = null): ?object; + + /** + * Get the max value based on a filtered result from a given table + * + * @param string $field The field key + * @param string $tables The table + * @param array $filter The filter keys + * + * @return int|null + * @since 3.2.0 + **/ + public function max($field, array $tables, array $filter): ?int; + + /** + * Count the number of items based on filter result from a given table + * + * @param string $tables The table + * @param array $filter The filter keys + * + * @return int|null + * @since 3.2.0 + **/ + public function count(array $tables, array $filter): ?int; + + /** + * Load one value from a row + * + * @param array $select Array of selection keys + * @param array $tables Array of tables to search + * @param array|null $where Array of where key=>value match exist + * @param array|null $order Array of how to order the data + * + * @return mixed + * @since 3.2.0 + **/ + public function value(array $select, array $tables, ?array $where = null, ?array $order = null); +} + diff --git a/libraries/jcb_powers/VDM.Joomla/src/Interfaces/ModelInterface.php b/libraries/jcb_powers/VDM.Joomla/src/Interfaces/ModelInterface.php new file mode 100644 index 0000000..51f3424 --- /dev/null +++ b/libraries/jcb_powers/VDM.Joomla/src/Interfaces/ModelInterface.php @@ -0,0 +1,94 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ + +namespace VDM\Joomla\Interfaces; + + +/** + * Model Interface + * + * @since 3.2.0 + */ +interface ModelInterface +{ + /** + * Model the value + * Example: $this->value(value, 'value_key', 'table_name'); + * + * @param mixed $value The value to model + * @param string $field The field key + * @param string|null $table The table + * + * @return mixed + * @since 3.2.0 + */ + public function value($value, string $field, ?string $table = null); + + /** + * Model the values of an item + * Example: $this->item(Object, 'table_name'); + * + * @param object $item The item object + * @param string|null $table The table + * + * @return object|null + * @since 3.2.0 + */ + public function item(object $item, ?string $table = null): ?object; + + /** + * Model the values of multiple items + * Example: $this->items(Array, 'table_name'); + * + * @param array|null $items The array of item objects + * @param string|null $table The table + * + * @return array|null + * @since 3.2.0 + */ + public function items(?array $items = null, ?string $table = null): ?array; + + /** + * Model the values of an row + * Example: $this->item(Array, 'table_name'); + * + * @param array $item The item array + * @param string|null $table The table + * + * @return array|null + * @since 3.2.0 + */ + public function row(array $item, ?string $table = null): ?array; + + /** + * Model the values of multiple rows + * Example: $this->items(Array, 'table_name'); + * + * @param array|null $items The array of item array + * @param string|null $table The table + * + * @return array|null + * @since 3.2.0 + */ + public function rows(?array $items = null, ?string $table = null): ?array; + + /** + * Get last modeled ID + * Example: $this->last('table_name'); + * + * @param string|null $table The table + * + * @return int|null + * @since 3.2.0 + */ + public function last(?string $table = null): ?int; +} + diff --git a/libraries/jcb_powers/VDM.Joomla/src/Interfaces/Tableinterface.php b/libraries/jcb_powers/VDM.Joomla/src/Interfaces/Tableinterface.php new file mode 100644 index 0000000..4d8f741 --- /dev/null +++ b/libraries/jcb_powers/VDM.Joomla/src/Interfaces/Tableinterface.php @@ -0,0 +1,89 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ + +namespace VDM\Joomla\Interfaces; + + +/** + * The VDM Core Table Interface + */ +interface Tableinterface +{ + /** + * Get any value from a item/field/column of an area/view/table + * Example: $this->get('table_name', 'field_name', 'value_key'); + * Get an item/field/column of an area/view/table + * Example: $this->get('table_name', 'field_name'); + * Get all items/fields/columns of an area/view/table + * Example: $this->get('table_name'); + * Get all areas/views/tables with all their item/field/column details + * Example: $this->get('All'); + * + * @param string $table The table + * @param string|null $field The field + * @param string|null $key The value key + * + * @return mixed + * @since 3.2.0 + */ + public function get(string $table, ?string $field = null, ?string $key = null); + + /** + * Get title field from an area/view/table + * + * @param string $table The area + * + * @return ?array + * @since 3.2.0 + */ + public function title(string $table): ?array; + + /** + * Get title field name + * + * @param string $table The area + * + * @return string + * @since 3.2.0 + */ + public function titleName(string $table): string; + + /** + * Get all tables + * + * @return array + * @since 3.2.0 + */ + public function tables(): array; + + /** + * Check if a table (and field) exist + * + * @param string $table The area + * @param string|null $field The area + * + * @return bool + * @since 3.2.0 + */ + public function exist(string $table, ?string $field = null): bool; + + /** + * Get all fields of an area/view/table + * + * @param string $table The area + * @param bool $default Add the default fields + * + * @return array|null On success an array of fields + * @since 3.2.0 + */ + public function fields(string $table, bool $default = false): ?array; +} + diff --git a/libraries/jcb_powers/VDM.Joomla/src/Interfaces/UpdateInterface.php b/libraries/jcb_powers/VDM.Joomla/src/Interfaces/UpdateInterface.php new file mode 100644 index 0000000..3e43b16 --- /dev/null +++ b/libraries/jcb_powers/VDM.Joomla/src/Interfaces/UpdateInterface.php @@ -0,0 +1,72 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ + +namespace VDM\Joomla\Interfaces; + + +/** + * Database Update Interface + * + * @since 3.2.0 + */ +interface UpdateInterface +{ + /** + * Update rows in the database (with remapping and filtering columns option) + * + * @param array $data Dataset to update in database [array of arrays (key => value)] + * @param string $key Dataset key column to use in updating the values in the Database + * @param string $table The table where the data is being updated + * @param array $columns Data columns for remapping and filtering + * + * @return bool + * @since 3.2.0 + **/ + public function rows(array $data, string $key, string $table, array $columns = []): bool; + + /** + * Update items in the database (with remapping and filtering columns option) + * + * @param array $data Data to updated in database (array of objects) + * @param string $key Dataset key column to use in updating the values in the Database + * @param string $table The table where the data is being update + * @param array $columns Data columns for remapping and filtering + * + * @return bool + * @since 3.2.0 + **/ + public function items(array $data, string $key, string $table, array $columns = []): bool; + + /** + * Update row in the database + * + * @param array $data Dataset to update in database (key => value) + * @param string $key Dataset key column to use in updating the values in the Database + * @param string $table The table where the data is being updated + * + * @return bool + * @since 3.2.0 + **/ + public function row(array $data, string $key, string $table): bool; + + /** + * Update item in the database + * + * @param object $data Dataset to update in database (key => value) + * @param string $key Dataset key column to use in updating the values in the Database + * @param string $table The table where the data is being updated + * + * @return bool + * @since 3.2.0 + **/ + public function item(object $data, string $key, string $table): bool; +} + diff --git a/libraries/jcb_powers/VDM.Joomla/src/Interfaces/index.html b/libraries/jcb_powers/VDM.Joomla/src/Interfaces/index.html new file mode 100644 index 0000000..fa6d84e --- /dev/null +++ b/libraries/jcb_powers/VDM.Joomla/src/Interfaces/index.html @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/libraries/jcb_powers/VDM.Joomla/src/Utilities/ArrayHelper.php b/libraries/jcb_powers/VDM.Joomla/src/Utilities/ArrayHelper.php new file mode 100644 index 0000000..70cc939 --- /dev/null +++ b/libraries/jcb_powers/VDM.Joomla/src/Utilities/ArrayHelper.php @@ -0,0 +1,107 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ + +namespace VDM\Joomla\Utilities; + + +/** + * Some array tricks helper + * + * @since 3.0.9 + */ +abstract class ArrayHelper +{ + /** + * Check if have an array with a length + * + * @input array The array to check + * + * @returns int|false number of items in array on success + * + * @since 3.2.0 + */ + public static function check($array, $removeEmptyString = false) + { + if (is_array($array) && ($nr = count((array) $array)) > 0) + { + // also make sure the empty strings are removed + if ($removeEmptyString) + { + $array = array_filter($array); + + if ($array === []) + { + return false; + } + + return count($array); + } + + return $nr; + } + + return false; + } + + /** + * Merge an array of array's + * + * @input array The arrays you would like to merge + * + * @returns array|null merged array on success + * + * @since 3.0.9 + */ + public static function merge($arrays): ?array + { + if(self::check($arrays)) + { + $merged = []; + foreach ($arrays as $array) + { + if (self::check($array)) + { + $merged = array_merge($merged, $array); + } + } + return $merged; + } + return null; + } + + /** + * Check if arrays intersect + * + * @input array The first array + * @input array The second array + * + * @returns bool true if intersect else false + * + * @since 3.1.1 + */ + public static function intersect($a_array, $b_array): bool + { + // flip the second array + $b_array = array_flip($b_array); + + // loop the first array + foreach ($a_array as $v) + { + if (isset($b_array[$v])) + { + return true; + } + } + return false; + } + +} + diff --git a/libraries/jcb_powers/VDM.Joomla/src/Utilities/Component/Helper.php b/libraries/jcb_powers/VDM.Joomla/src/Utilities/Component/Helper.php new file mode 100644 index 0000000..61dbf59 --- /dev/null +++ b/libraries/jcb_powers/VDM.Joomla/src/Utilities/Component/Helper.php @@ -0,0 +1,189 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ + +namespace VDM\Joomla\Utilities\Component; + + +use Joomla\Input\Input; +use Joomla\CMS\Component\ComponentHelper; +use Joomla\Registry\Registry; + + +/** + * Some component helper + * + * @since 3.0.11 + */ +abstract class Helper +{ + /** + * The current option + * + * @var string + * @since 3.0.11 + */ + public static string $option; + + /** + * The component params list cache + * + * @var Registry[] + * @since 3.0.11 + */ + protected static array $params = []; + + /** + * Gets the parameter object for the component + * + * @param string|null $option The option for the component. + * + * @return Registry A Registry object. + * @see Registry + * @since 3.0.11 + */ + public static function getParams(?string $option = null): Registry + { + // check that we have an option + if (empty($option)) + { + $option = self::getOption(); + } + + // get global value + if (!isset(self::$params[$option]) || !self::$params[$option] instanceof Registry) + { + self::$params[$option] = ComponentHelper::getParams($option); + } + + return self::$params[$option]; + } + + /** + * Gets the component option + * + * @param string|null $default The default return value if none is found + * + * @return string|null A component option + * @since 3.0.11 + */ + public static function getOption(string $default = 'empty'): ?string + { + if (empty(self::$option)) + { + // get the option from the url input + self::$option = (new Input)->getString('option', false); + } + + if (self::$option) + { + return self::$option; + } + + return $default; + } + + /** + * Gets the component code name + * + * @param string|null $option The option for the component. + * @param string|null $default The default return value if none is found + * + * @return string|null A component code name + * @since 3.0.11 + */ + public static function getCode(?string $option = null, ?string $default = null): ?string + { + // check that we have an option + if (empty($option)) + { + $option = self::getOption(); + } + // option with com_ + if (is_string($option) && strpos($option, 'com_') === 0) + { + return strtolower(trim(substr($option, 4))); + } + + return $default; + } + + /** + * Gets the component abstract helper class + * + * @param string|null $option The option for the component. + * @param string|null $default The default return value if none is found + * + * @return string|null A component helper name + * + * @since 3.0.11 + */ + public static function get(string $option = null, string $default = null): ?string + { + // check that we have an option + // and get the code name from it + if (($code_name = self::getCode($option, false)) !== false) + { + // we build the helper class name + $helper_name = '\\' . \ucfirst($code_name) . 'Helper'; + // check if class exist + if (class_exists($helper_name)) + { + return $helper_name; + } + } + + return $default; + } + + /** + * Check if the helper class of this component has a method + * + * @param string $method The method name to search for + * @param string|null $option The option for the component. + * + * @return bool true if method exist + * + * @since 3.0.11 + */ + public static function methodExists(string $method, string $option = null): bool + { + // get the helper class + return ($helper = self::get($option, false)) !== false && + method_exists($helper, $method); + } + + /** + * Check if the helper class of this component has a method, and call it with the arguments + * + * @param string $method The method name to search for + * @param array $arguments The arguments for function. + * @param string|null $option The option for the component. + * + * @return mixed return whatever the method returns or null + * @since 3.2.0 + */ + public static function _(string $method, array $arguments = [], ?string $option = null) + { + // get the helper class + if (($helper = self::get($option, false)) !== false && + method_exists($helper, $method)) + { + // we know this is not ideal... + // so we need to move these + // functions to their own classes + return call_user_func_array([$helper, $method], $arguments); + } + + return null; + } + +} + diff --git a/libraries/jcb_powers/VDM.Joomla/src/Utilities/Component/index.html b/libraries/jcb_powers/VDM.Joomla/src/Utilities/Component/index.html new file mode 100644 index 0000000..fa6d84e --- /dev/null +++ b/libraries/jcb_powers/VDM.Joomla/src/Utilities/Component/index.html @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/libraries/jcb_powers/VDM.Joomla/src/Utilities/FileHelper.php b/libraries/jcb_powers/VDM.Joomla/src/Utilities/FileHelper.php new file mode 100644 index 0000000..7bbc782 --- /dev/null +++ b/libraries/jcb_powers/VDM.Joomla/src/Utilities/FileHelper.php @@ -0,0 +1,363 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ + +namespace VDM\Joomla\Utilities; + + +use Joomla\CMS\Uri\Uri; +use Joomla\CMS\Factory; +use Joomla\CMS\Language\Text; +use Joomla\CMS\Filesystem\Path; +use Joomla\CMS\Filesystem\File; +use Joomla\CMS\Filesystem\Folder; +use Joomla\Archive\Archive; +use VDM\Joomla\Utilities\Component\Helper; + + +/** + * File helper + * + * @since 3.0.9 + */ +abstract class FileHelper +{ + /** + * Trigger error notice only once + * + * @var bool + * + * @since 3.0.9 + */ + protected static $curlError = false; + + /** + * The zipper method + * + * @param string $workingDirectory The directory where the items must be zipped + * @param string $filepath The path to where the zip file must be placed + * + * @return bool true On success + * + * @since 3.0.9 + */ + public static function zip($workingDirectory, &$filepath): bool + { + // store the current joomla working directory + $joomla = getcwd(); + + // we are changing the working directory to the component temp folder + chdir($workingDirectory); + + // the full file path of the zip file + $filepath = Path::clean($filepath); + + // delete an existing zip file (or use an exclusion parameter in Folder::files() + File::delete($filepath); + + // get a list of files in the current directory tree (also the hidden files) + $files = Folder::files('.', '', true, true, array('.svn', 'CVS', '.DS_Store', '__MACOSX'), array('.*~')); + + $zipArray = []; + // setup the zip array + foreach ($files as $file) + { + $tmp = []; + $tmp['name'] = str_replace('./', '', (string) $file); + $tmp['data'] = self::getContent($file); + $tmp['time'] = filemtime($file); + $zipArray[] = $tmp; + } + + // change back to joomla working directory + chdir($joomla); + + // get the zip adapter + $zip = (new Archive())->getAdapter('zip'); + + //create the zip file + return (bool) $zip->create($filepath, $zipArray); + } + + /** + * get the content of a file + * + * @param string $path The path to the file + * @param string/bool $none The return value if no content was found + * + * @return string On success + * + * @since 3.0.9 + */ + public static function getContent($path, $none = '') + { + if (StringHelper::check($path)) + { + // use basic file get content for now + if (($content = @file_get_contents($path)) !== FALSE) + { + return $content; + } + // use curl if available + elseif (function_exists('curl_version')) + { + // start curl + $ch = curl_init(); + // set the options + $options = []; + $options[CURLOPT_URL] = $path; + $options[CURLOPT_USERAGENT] = 'Mozilla/5.0 (Windows; U; Windows NT 6.1; en-US; rv:1.9.2.12) Gecko/20101026 Firefox/3.6.12'; + $options[CURLOPT_RETURNTRANSFER] = TRUE; + $options[CURLOPT_SSL_VERIFYPEER] = FALSE; + // load the options + curl_setopt_array($ch, $options); + // get the content + $content = curl_exec($ch); + // close the connection + curl_close($ch); + + // return if found + if (StringHelper::check($content)) + { + return $content; + } + } + elseif (!self::$curlError) + { + // set the notice + Factory::getApplication()->enqueueMessage(Text::_('COM_GETBIBLE_HTWOCURL_NOT_FOUNDHTWOPPLEASE_SETUP_CURL_ON_YOUR_SYSTEM_OR_BGETBIBLEB_WILL_NOT_FUNCTION_CORRECTLYP'), 'Error'); + // load this notice only once + self::$curlError = true; + } + } + return $none; + } + + /** + * Write a file to the server + * + * @param string $path The path and file name where to safe the data + * @param string $data The data to safe + * + * @return bool true On success + * + * @since 3.0.9 + */ + public static function write($path, $data) + { + $klaar = false; + if (StringHelper::check($data)) + { + // open the file + $fh = fopen($path, "w"); + if (!is_resource($fh)) + { + return $klaar; + } + // write to the file + if (fwrite($fh, $data)) + { + // has been done + $klaar = true; + } + // close file. + fclose($fh); + } + return $klaar; + } + + /** + * get all the file paths in folder and sub folders + * + * @param string $folder The local path to parse + * @param array $fileTypes The type of files to get + * + * @return void + * + * @since 3.0.9 + */ + public static function getPaths($folder, $fileTypes = array('\.php', '\.js', '\.css', '\.less'), $recurse = true, $full = true) + { + if (Folder::exists($folder)) + { + // we must first store the current woking directory + $joomla = getcwd(); + // we are changing the working directory to the component path + chdir($folder); + + // make sure we have file type filter + if (ArrayHelper::check($fileTypes)) + { + // get the files + foreach ($fileTypes as $type) + { + // get a list of files in the current directory tree + $files[] = Folder::files('.', $type, $recurse, $full); + } + } + elseif (StringHelper::check($fileTypes)) + { + // get a list of files in the current directory tree + $files[] = Folder::files('.', $fileTypes, $recurse, $full); + } + else + { + // get a list of files in the current directory tree + $files[] = Folder::files('.', '.', $recurse, $full); + } + + // change back to Joomla working directory + chdir($joomla); + + // return array of files + return array_map( fn($file) => str_replace('./', '/', (string) $file), (array) ArrayHelper::merge($files)); + } + return false; + } + + /** + * Get the file path or url + * + * @param string $type The (url/path) type to return + * @param string $target The Params Target name (if set) + * @param string $fileType The kind of filename to generate (if not set no file name is generated) + * @param string $key The key to adjust the filename (if not set ignored) + * @param string $default The default path if not set in Params (fallback path) + * @param bool $createIfNotSet The switch to create the folder if not found + * + * @return string On success the path or url is returned based on the type requested + * + * @since 3.0.9 + */ + public static function getPath($type = 'path', $target = 'filepath', $fileType = null, $key = '', $default = '', $createIfNotSet = true) + { + // make sure to always have a string/path + if(!StringHelper::check($default)) + { + $default = JPATH_SITE . '/images/'; + } + + // get the global settings + $filePath = Helper::getParams()->get($target, $default); + + // check the file path (revert to default only of not a hidden file path) + if ('hiddenfilepath' !== $target && strpos((string) $filePath, (string) JPATH_SITE) === false) + { + $filePath = $default; + } + + // create the folder if it does not exist + if ($createIfNotSet && !Folder::exists($filePath)) + { + Folder::create($filePath); + } + + // setup the file name + $fileName = ''; + + // Get basic key + $basickey = 'Th!s_iS_n0t_sAfe_buT_b3tter_then_n0thiug'; + // get the component helper + $helper = Helper::get(); + // check if method exist in helper class + if ($helper && Helper::methodExists('getCryptKey')) + { + $basickey = $helper::getCryptKey('basic', $basickey); + } + + // check the key + if (!StringHelper::check($key)) + { + $key = 'vDm'; + } + + // set the file name + if (StringHelper::check($fileType)) + { + // set the name + $fileName = trim( md5($type . $target . $basickey . $key) . '.' . trim($fileType, '.')); + } + else + { + $fileName = trim( md5($type . $target . $basickey . $key)) . '.txt'; + } + + // return the url + if ('url' === $type) + { + if (\strpos((string) $filePath, (string) JPATH_SITE) !== false) + { + $filePath = trim( str_replace( JPATH_SITE, '', (string) $filePath), '/'); + + return Uri::root() . $filePath . '/' . $fileName; + } + + // since the path is behind the root folder of the site, return only the root url (may be used to build the link) + return Uri::root(); + } + + // sanitize the path + return '/' . trim((string) $filePath, '/' ) . '/' . $fileName; + } + + /** + * Check if file exist + * + * @param string $path The url/path to check + * + * @return bool If exist true + * + * @since 3.0.9 + */ + public static function exists($path) + { + $exists = false; + // if this is a local path + if (strpos($path, 'http:') === false && strpos($path, 'https:') === false) + { + if (file_exists($path)) + { + $exists = true; + } + } + // check if we can use curl + elseif (function_exists('curl_version')) + { + // initiate curl + $ch = curl_init($path); + // CURLOPT_NOBODY (do not return body) + curl_setopt($ch, CURLOPT_NOBODY, true); + // make call + $result = curl_exec($ch); + // check return value + if ($result !== false) + { + // get the http CODE + $statusCode = curl_getinfo($ch, CURLINFO_HTTP_CODE); + if ($statusCode !== 404) + { + $exists = true; + } + } + // close the connection + curl_close($ch); + } + elseif ($headers = @get_headers($path)) + { + if(isset($headers[0]) && is_string($headers[0]) && strpos($headers[0],'404') === false) + { + $exists = true; + } + } + return $exists; + } + +} + diff --git a/libraries/jcb_powers/VDM.Joomla/src/Utilities/GetHelper.php b/libraries/jcb_powers/VDM.Joomla/src/Utilities/GetHelper.php new file mode 100644 index 0000000..f584097 --- /dev/null +++ b/libraries/jcb_powers/VDM.Joomla/src/Utilities/GetHelper.php @@ -0,0 +1,253 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ + +namespace VDM\Joomla\Utilities; + + +use Joomla\CMS\Factory; +use VDM\Joomla\Utilities\Component\Helper; + + +/** + * Some easy get... + * + * @since 3.0.9 + */ +abstract class GetHelper +{ + /** + * Get a Variable + * + * @param string|null $table The table from which to get the variable + * @param mixed $where The value where + * @param string $whereString The target/field string where/name + * @param string $what The return field + * @param string $operator The operator between $whereString/field and $where/value + * @param string $main The component in which the table is found + * + * @return mixed string/int/float + * @since 3.0.9 + */ + public static function var(?string $table = null, $where = null, + string $whereString = 'user', string $what = 'id', + string $operator = '=', ?string $main = null) + { + if(empty($where)) + { + $where = Factory::getUser()->id; + } + + if(empty($main)) + { + $main = Helper::getCode(); + } + + // Get a db connection. + $db = Factory::getDbo(); + + // Create a new query object. + $query = $db->getQuery(true); + $query->select($db->quoteName(array($what))); + + if (empty($table)) + { + $query->from($db->quoteName('#__' . $main)); + } + else + { + $query->from($db->quoteName('#__' . $main . '_' . $table)); + } + + if (is_numeric($where)) + { + $query->where($db->quoteName($whereString) . ' ' . $operator . ' ' . (int) $where); + } + elseif (is_string($where)) + { + $query->where($db->quoteName($whereString) . ' ' . $operator . ' ' . $db->quote((string)$where)); + } + else + { + return false; + } + + $db->setQuery($query); + $db->execute(); + + if ($db->getNumRows()) + { + return $db->loadResult(); + } + + return false; + } + + /** + * Get array of variables + * + * @param string|null $table The table from which to get the variables + * @param mixed $where The value where + * @param string $whereString The target/field string where/name + * @param string $what The return field + * @param string $operator The operator between $whereString/field and $where/value + * @param string $main The component in which the table is found + * @param bool $unique The switch to return a unique array + * + * @return array|null + * @since 3.0.9 + */ + public static function vars(?string $table = null, $where = null, + string $whereString = 'user', string $what = 'id', string $operator = 'IN', + ?string $main = null, bool $unique = true): ?array + { + if(empty($where)) + { + $where = Factory::getUser()->id; + } + + if(is_null($main)) + { + $main = Helper::getCode(); + } + + if (!ArrayHelper::check($where) && $where > 0) + { + $where = array($where); + } + + if (ArrayHelper::check($where)) + { + // prep main <-- why? well if $main='' is empty then $table can be categories or users + if (StringHelper::check($main)) + { + $main = '_' . ltrim($main, '_'); + } + + // Get a db connection. + $db = Factory::getDbo(); + + // Create a new query object. + $query = $db->getQuery(true); + $query->select($db->quoteName(array($what))); + + if (empty($table)) + { + $query->from($db->quoteName('#__' . $main)); + } + else + { + $query->from($db->quoteName('#_' . $main . '_' . $table)); + } + + // add strings to array search + if ('IN_STRINGS' === $operator || 'NOT IN_STRINGS' === $operator) + { + $query->where($db->quoteName($whereString) . ' ' . str_replace('_STRINGS', '', $operator) . ' ("' . implode('","', $where) . '")'); + } + else + { + $query->where($db->quoteName($whereString) . ' ' . $operator . ' (' . implode(',', $where) . ')'); + } + + $db->setQuery($query); + $db->execute(); + + if ($db->getNumRows()) + { + if ($unique) + { + return array_unique($db->loadColumn()); + } + return $db->loadColumn(); + } + } + + return null; + } + + /** + * get all strings between two other strings + * + * @param string $content The content to search + * @param string $start The starting value + * @param string $end The ending value + * + * @return array|null On success + * @since 3.0.9 + */ + public static function allBetween(string $content, string $start, string $end): ?array + { + // reset bucket + $bucket = []; + for ($i = 0; ; $i++) + { + // search for string + $found = self::between($content, $start, $end); + + if (StringHelper::check($found)) + { + // add to bucket + $bucket[] = $found; + + // build removal string + $remove = $start . $found . $end; + + // remove from content + $content = str_replace($remove, '', $content); + } + else + { + break; + } + + // safety catch + if ($i == 500) + { + break; + } + } + + // only return unique array of values + if (ArrayHelper::check($bucket)) + { + return array_unique($bucket); + } + + return null; + } + + /** + * get a string between two other strings + * + * @param string $content The content to search + * @param string $start The starting value + * @param string $end The ending value + * @param string $default The default value if none found + * + * @return string On success / empty string on failure + * @since 3.0.9 + */ + public static function between(string $content, string $start, string $end, string $default = ''): string + { + $array = explode($start, $content); + if (isset($array[1]) && strpos($array[1], $end) !== false) + { + $array = explode($end, $array[1]); + + // return string found between + return $array[0]; + } + + return $default; + } + +} + diff --git a/libraries/jcb_powers/VDM.Joomla/src/Utilities/GuidHelper.php b/libraries/jcb_powers/VDM.Joomla/src/Utilities/GuidHelper.php new file mode 100644 index 0000000..e219473 --- /dev/null +++ b/libraries/jcb_powers/VDM.Joomla/src/Utilities/GuidHelper.php @@ -0,0 +1,215 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ + +namespace VDM\Joomla\Utilities; + + +use Joomla\CMS\Factory; +use VDM\Joomla\Utilities\Component\Helper; + + +/** + * Global Unique ID Helper + * + * @since 3.0.9 + */ +abstract class GuidHelper +{ + /** + * Returns a GUIDv4 string + * + * Thanks to Dave Pearson (and other) + * https://www.php.net/manual/en/function.com-create-guid.php#119168 + * + * Uses the best cryptographically secure method + * for all supported platforms with fallback to an older, + * less secure version. + * + * @param bool $trim + * + * @return string + * + * @since 3.0.9 + */ + public static function get(bool $trim = true): string + { + // Windows + if (function_exists('com_create_guid')) + { + if ($trim) + { + return trim(com_create_guid(), '{}'); + } + return com_create_guid(); + } + + // set the braces if needed + $lbrace = $trim ? "" : chr(123); // "{" + $rbrace = $trim ? "" : chr(125); // "}" + + // OSX/Linux + if (function_exists('openssl_random_pseudo_bytes')) + { + $data = openssl_random_pseudo_bytes(16); + $data[6] = chr( ord($data[6]) & 0x0f | 0x40); // set version to 0100 + $data[8] = chr( ord($data[8]) & 0x3f | 0x80); // set bits 6-7 to 10 + return $lbrace . vsprintf('%s%s-%s-%s-%s-%s%s%s', str_split(bin2hex($data), 4)) . $lbrace; + } + + // Fallback (PHP 4.2+) + mt_srand((double) microtime() * 10000); + $charid = strtolower( md5( uniqid( rand(), true))); + $hyphen = chr(45); // "-" + $guidv4 = $lbrace. + substr($charid, 0, 8). $hyphen. + substr($charid, 8, 4). $hyphen. + substr($charid, 12, 4). $hyphen. + substr($charid, 16, 4). $hyphen. + substr($charid, 20, 12). + $rbrace; + return $guidv4; + } + + /** + * Validate the Globally Unique Identifier ( and check if table already has this identifier) + * + * @param string $guid + * @param string|null $table + * @param int $id + * @param string|null $component + * + * @return bool + * + * @since 3.0.9 + */ + public static function valid($guid, ?string $table = null, int $id = 0, ?string $component = null): bool + { + // check if we have a string + if (self::validate($guid)) + { + // check if table already has this identifier + if (StringHelper::check($table)) + { + // check that we have the component code name + if (!is_string($component)) + { + $component = (string) Helper::getCode(); + } + // Get the database object and a new query object. + $db = Factory::getDbo(); + $query = $db->getQuery(true); + $query->select('COUNT(*)') + ->from('#__' . (string) $component . '_' . (string) $table) + ->where($db->quoteName('guid') . ' = ' . $db->quote($guid)); + + // remove this item from the list + if ($id > 0) + { + $query->where($db->quoteName('id') . ' <> ' . (int) $id); + } + + // Set and query the database. + $db->setQuery($query); + $duplicate = (bool) $db->loadResult(); + + if ($duplicate) + { + return false; + } + } + return true; + } + return false; + } + + /** + * get the item by guid in a table + * + * @param string $guid + * @param string $table + * @param string|array $what + * @param string|null $component + * + * @return mix + * + * @since 3.0.9 + */ + public static function item($guid, $table, $what = 'a.id', ?string $component = null) + { + // check if we have a string + // check if table already has this identifier + if (self::validate($guid) && StringHelper::check($table)) + { + // check that we have the component code name + if (!is_string($component)) + { + $component = (string) Helper::getCode(); + } + // Get the database object and a new query object. + $db = Factory::getDbo(); + $query = $db->getQuery(true); + + if (ArrayHelper::check($what)) + { + $query->select($db->quoteName($what)); + } + else + { + $query->select($what); + } + + $query->from($db->quoteName('#__' . (string) $component . '_' . (string) $table, 'a')) + ->where($db->quoteName('a.guid') . ' = ' . $db->quote($guid)); + + // Set and query the database. + $db->setQuery($query); + $db->execute(); + + if ($db->getNumRows()) + { + if (ArrayHelper::check($what) || $what === 'a.*') + { + return $db->loadObject(); + } + else + { + return $db->loadResult(); + } + } + } + + return null; + } + + /** + * Validate the Globally Unique Identifier + * + * Thanks to Lewie + * https://stackoverflow.com/a/1515456/1429677 + * + * @param string $guid + * + * @return bool + * + * @since 3.0.9 + */ + protected static function validate($guid) + { + // check if we have a string + if (StringHelper::check($guid)) + { + return preg_match("/^(\{)?[a-f\d]{8}(-[a-f\d]{4}){4}[a-f\d]{8}(?(1)\})$/i", $guid); + } + return false; + } + +} + diff --git a/libraries/jcb_powers/VDM.Joomla/src/Utilities/JsonHelper.php b/libraries/jcb_powers/VDM.Joomla/src/Utilities/JsonHelper.php new file mode 100644 index 0000000..47fbd24 --- /dev/null +++ b/libraries/jcb_powers/VDM.Joomla/src/Utilities/JsonHelper.php @@ -0,0 +1,101 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ + +namespace VDM\Joomla\Utilities; + + +/** + * The json checker + * + * @since 3.0.9 + */ +abstract class JsonHelper +{ + /** + * Check if you have a json string + * + * @input string $string The json string to check + * + * @returns bool true on success + * + * @since 3.0.9 + */ + public static function check($string): bool + { + if (StringHelper::check($string)) + { + json_decode((string) $string); + return (json_last_error() === JSON_ERROR_NONE); + } + + return false; + } + + /** + * Convert a json object to a string + * + * @input string $value The json string to convert + * + * @returns a string + * + * @since 3.0.9 + */ + public static function string($value, $separator = ", ", $table = null, $id = 'id', $name = 'name') + { + // do some table foot work + $external = false; + if (is_string($table) && strpos((string) $table, '#__') !== false) + { + $external = true; + $table = str_replace('#__', '', (string) $table); + } + + // check if string is JSON + $result = json_decode((string) $value, true); + if (json_last_error() === JSON_ERROR_NONE) + { + // is JSON + if (ArrayHelper::check($result)) + { + if (StringHelper::check($table)) + { + $names = []; + foreach ($result as $val) + { + if ($external) + { + if ($_name = GetHelper::var(null, $val, $id, $name, '=', $table)) + { + $names[] = $_name; + } + } + else + { + if ($_name = GetHelper::var($table, $val, $id, $name)) + { + $names[] = $_name; + } + } + } + if (ArrayHelper::check($names)) + { + return (string) implode($separator, $names); + } + } + return (string) implode($separator, $result); + } + return (string) json_decode((string) $value); + } + return $value; + } + +} + diff --git a/libraries/jcb_powers/VDM.Joomla/src/Utilities/ObjectHelper.php b/libraries/jcb_powers/VDM.Joomla/src/Utilities/ObjectHelper.php new file mode 100644 index 0000000..2646f7c --- /dev/null +++ b/libraries/jcb_powers/VDM.Joomla/src/Utilities/ObjectHelper.php @@ -0,0 +1,78 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ + +namespace VDM\Joomla\Utilities; + + +/** + * Some object tricks + * + * @since 3.0.9 + */ +abstract class ObjectHelper +{ + /** + * Check if have an object with a length + * + * @input object The object to check + * + * @returns bool true on success + * + * @since 3.0.9 + */ + public static function check($object) + { + if (is_object($object)) + { + return count((array) $object) > 0; + } + + return false; + } + + /** + * Compare two objects for equality based on their property values. + * + * Note that this method works only for simple objects that don't + * contain any nested objects or resource references. If you need + * to compare more complex objects, you may need to use a + * more advanced method such as serialization or reflection. + * + * @param object|null $obj1 The first object to compare. + * @param object|null $obj2 The second object to compare. + * + * @return bool True if the objects have the same key-value pairs and false otherwise. + */ + public static function equal(?object $obj1, ?object $obj2): bool + { + // if any is null we return false as that means there is a none object + // we are not comparing null but objects + // but we allow null as some objects while + // not instantiate are still null + if (is_null($obj1) || is_null($obj2)) + { + return false; + } + + // Convert the objects to arrays of their property values using get_object_vars. + $array1 = get_object_vars($obj1); + $array2 = get_object_vars($obj2); + + // Compare the arrays using array_diff_assoc to detect any differences. + $diff1 = array_diff_assoc($array1, $array2); + $diff2 = array_diff_assoc($array2, $array1); + + // If the arrays have the same key-value pairs, they will have no differences, so return true. + return empty($diff1) && empty($diff2); + } + +} + diff --git a/libraries/jcb_powers/VDM.Joomla/src/Utilities/String/ClassfunctionHelper.php b/libraries/jcb_powers/VDM.Joomla/src/Utilities/String/ClassfunctionHelper.php new file mode 100644 index 0000000..42d21af --- /dev/null +++ b/libraries/jcb_powers/VDM.Joomla/src/Utilities/String/ClassfunctionHelper.php @@ -0,0 +1,47 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ + +namespace VDM\Joomla\Utilities\String; + + +use VDM\Joomla\Utilities\StringHelper; + + +/** + * Control the naming of a class and function + * + * @since 3.0.9 + */ +abstract class ClassfunctionHelper +{ + /** + * Making class or function name safe + * + * @input string The name you would like to make safe + * + * @returns string on success + * + * @since 3.0.9 + */ + public static function safe($name): string + { + // remove numbers if the first character is a number + if (is_numeric(substr((string) $name, 0, 1))) + { + $name = StringHelper::numbers($name); + } + + // remove all spaces and strange characters + return trim(preg_replace("/[^A-Za-z0-9_-]/", '', (string) $name)); + } + +} + diff --git a/libraries/jcb_powers/VDM.Joomla/src/Utilities/String/index.html b/libraries/jcb_powers/VDM.Joomla/src/Utilities/String/index.html new file mode 100644 index 0000000..fa6d84e --- /dev/null +++ b/libraries/jcb_powers/VDM.Joomla/src/Utilities/String/index.html @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/libraries/jcb_powers/VDM.Joomla/src/Utilities/StringHelper.php b/libraries/jcb_powers/VDM.Joomla/src/Utilities/StringHelper.php new file mode 100644 index 0000000..3a37f2b --- /dev/null +++ b/libraries/jcb_powers/VDM.Joomla/src/Utilities/StringHelper.php @@ -0,0 +1,416 @@ + + * @git Joomla Component Builder + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ + +namespace VDM\Joomla\Utilities; + + +use Joomla\CMS\Filter\InputFilter; +use Joomla\CMS\Language\Language; +use VDM\Joomla\Utilities\Component\Helper; + + +/** + * Some string tricks + * + * @since 3.0.9 + */ +abstract class StringHelper +{ + /** + * The Main Active Language + * + * @var string + * + * @since 3.0.9 + */ + public static $langTag; + + /** + * Check if we have a string with a length + * + * @input string $string The string to check + * + * @returns bool true on success + * + * @since 3.0.9 + */ + public static function check($string): bool + { + return is_string($string) && strlen($string) > 0; + } + + /** + * Shorten a string + * + * @input string The you would like to shorten + * + * @returns string on success + * + * @since 3.0.9 + */ + public static function shorten($string, $length = 40, $addTip = true) + { + if (self::check($string)) + { + $initial = strlen((string) $string); + $words = preg_split('/([\s\n\r]+)/', (string) $string, null, PREG_SPLIT_DELIM_CAPTURE); + $words_count = count((array)$words); + + $word_length = 0; + $last_word = 0; + for (; $last_word < $words_count; ++$last_word) + { + $word_length += strlen($words[$last_word]); + if ($word_length > $length) + { + break; + } + } + + $newString = implode(array_slice($words, 0, $last_word)); + $final = strlen($newString); + if ($initial !== $final && $addTip) + { + $title = self::shorten($string, 400 , false); + return '' . trim($newString) . '...'; + } + elseif ($initial !== $final && !$addTip) + { + return trim($newString) . '...'; + } + } + return $string; + } + + /** + * Making strings safe (various ways) + * + * @input string The you would like to make safe + * + * @returns string on success + * + * @since 3.0.9 + */ + public static function safe($string, $type = 'L', $spacer = '_', $replaceNumbers = true, $keepOnlyCharacters = true) + { + if ($replaceNumbers === true) + { + // remove all numbers and replace with English text version (works well only up to millions) + $string = self::numbers($string); + } + // 0nly continue if we have a string + if (self::check($string)) + { + // create file name without the extension that is safe + if ($type === 'filename') + { + // make sure VDM is not in the string + $string = str_replace('VDM', 'vDm', (string) $string); + // Remove anything which isn't a word, whitespace, number + // or any of the following caracters -_() + // If you don't need to handle multi-byte characters + // you can use preg_replace rather than mb_ereg_replace + // Thanks @Łukasz Rysiak! + // $string = mb_ereg_replace("([^\w\s\d\-_\(\)])", '', $string); + $string = preg_replace("([^\w\s\d\-_\(\)])", '', $string); + + // http://stackoverflow.com/a/2021729/1429677 + return preg_replace('/\s+/', ' ', (string) $string); + } + // remove all other characters + $string = trim((string) $string); + $string = preg_replace('/'.$spacer.'+/', ' ', $string); + $string = preg_replace('/\s+/', ' ', $string); + // Transliterate string + $string = self::transliterate($string); + // remove all and keep only characters + if ($keepOnlyCharacters) + { + $string = preg_replace("/[^A-Za-z ]/", '', (string) $string); + } + // keep both numbers and characters + else + { + $string = preg_replace("/[^A-Za-z0-9 ]/", '', (string) $string); + } + // select final adaptations + if ($type === 'L' || $type === 'strtolower') + { + // replace white space with underscore + $string = preg_replace('/\s+/', (string) $spacer, (string) $string); + // default is to return lower + return strtolower($string); + } + elseif ($type === 'W') + { + // return a string with all first letter of each word uppercase(no underscore) + return ucwords(strtolower($string)); + } + elseif ($type === 'w' || $type === 'word') + { + // return a string with all lowercase(no underscore) + return strtolower($string); + } + elseif ($type === 'Ww' || $type === 'Word') + { + // return a string with first letter of the first word uppercase and all the rest lowercase(no underscore) + return ucfirst(strtolower($string)); + } + elseif ($type === 'WW' || $type === 'WORD') + { + // return a string with all the uppercase(no underscore) + return strtoupper($string); + } + elseif ($type === 'U' || $type === 'strtoupper') + { + // replace white space with underscore + $string = preg_replace('/\s+/', (string) $spacer, $string); + // return all upper + return strtoupper($string); + } + elseif ($type === 'F' || $type === 'ucfirst') + { + // replace white space with underscore + $string = preg_replace('/\s+/', (string) $spacer, $string); + // return with first character to upper + return ucfirst(strtolower($string)); + } + elseif ($type === 'cA' || $type === 'cAmel' || $type === 'camelcase') + { + // convert all words to first letter uppercase + $string = ucwords(strtolower($string)); + // remove white space + $string = preg_replace('/\s+/', '', $string); + // now return first letter lowercase + return lcfirst($string); + } + // return string + return $string; + } + // not a string + return ''; + } + + /** + * Convert none English strings to code usable string + * + * @input an string + * + * @returns a string + * + * @since 3.0.9 + */ + public static function transliterate($string) + { + // set tag only once + if (!self::check(self::$langTag)) + { + // get global value + self::$langTag = Helper::getParams()->get('language', 'en-GB'); + } + + // Transliterate on the language requested + $lang = Language::getInstance(self::$langTag); + + return $lang->transliterate($string); + } + + /** + * make sure a string is HTML save + * + * @input an html string + * + * @returns a string + * + * @since 3.0.9 + */ + public static function html($var, $charset = 'UTF-8', $shorten = false, $length = 40, $addTip = true) + { + if (self::check($var)) + { + $filter = new InputFilter(); + $string = $filter->clean( + html_entity_decode( + htmlentities( + (string) $var, + ENT_COMPAT, + $charset + ) + ), + 'HTML' + ); + if ($shorten) + { + return self::shorten($string, $length, $addTip); + } + return $string; + } + else + { + return ''; + } + } + + /** + * Convert all int in a string to an English word string + * + * @input an string with numbers + * + * @returns a string + * + * @since 3.0.9 + */ + public static function numbers($string) + { + // set numbers array + $numbers = []; + $search_replace= []; + + // first get all numbers + preg_match_all('!\d+!', (string) $string, $numbers); + + // check if we have any numbers + if (isset($numbers[0]) && ArrayHelper::check($numbers[0])) + { + foreach ($numbers[0] as $number) + { + $search_replace[$number] = self::number((int)$number); + } + + // now replace numbers in string + $string = str_replace(array_keys($search_replace), array_values($search_replace), (string) $string); + + // check if we missed any, strange if we did. + return self::numbers($string); + } + + // return the string with no numbers remaining. + return $string; + } + + /** + * Convert an integer into an English word string + * Thanks to Tom Nicholson + * + * @input an int + * @returns a string + * + * @since 3.0.9 + */ + public static function number($x) + { + $nwords = array( "zero", "one", "two", "three", "four", "five", "six", "seven", + "eight", "nine", "ten", "eleven", "twelve", "thirteen", + "fourteen", "fifteen", "sixteen", "seventeen", "eighteen", + "nineteen", "twenty", 30 => "thirty", 40 => "forty", + 50 => "fifty", 60 => "sixty", 70 => "seventy", 80 => "eighty", + 90 => "ninety" ); + + if(!is_numeric($x)) + { + $w = $x; + } + elseif(fmod($x, 1) != 0) + { + $w = $x; + } + else + { + if($x < 0) + { + $w = 'minus '; + $x = -$x; + } + else + { + $w = ''; + // ... now $x is a non-negative integer. + } + + if($x < 21) // 0 to 20 + { + $w .= $nwords[$x]; + } + elseif($x < 100) // 21 to 99 + { + $w .= $nwords[10 * floor($x/10)]; + $r = fmod($x, 10); + if($r > 0) + { + $w .= ' ' . $nwords[$r]; + } + } + elseif($x < 1000) // 100 to 999 + { + $w .= $nwords[floor($x/100)] .' hundred'; + $r = fmod($x, 100); + if($r > 0) + { + $w .= ' and '. self::number($r); + } + } + elseif($x < 1000000) // 1000 to 999999 + { + $w .= self::number(floor($x/1000)) .' thousand'; + $r = fmod($x, 1000); + if($r > 0) + { + $w .= ' '; + if($r < 100) + { + $w .= 'and '; + } + $w .= self::number($r); + } + } + else // millions + { + $w .= self::number(floor($x/1000000)) .' million'; + $r = fmod($x, 1000000); + if($r > 0) + { + $w .= ' '; + if($r < 100) + { + $w .= 'and '; + } + $w .= self::number($r); + } + } + } + return $w; + } + + /** + * Random Key + * + * @input int $size The size of the random string + * + * @returns a string + * @since 3.0.9 + */ + public static function random(int $size): string + { + $bag = "abcefghijknopqrstuwxyzABCDDEFGHIJKLLMMNOPQRSTUVVWXYZabcddefghijkllmmnopqrstuvvwxyzABCEFGHIJKNOPQRSTUWXYZ"; + $key = []; + $bagsize = strlen($bag) - 1; + + for ($i = 0; $i < $size; $i++) + { + $get = rand(0, $bagsize); + $key[] = $bag[$get]; + } + + return implode($key); + } + +} + diff --git a/libraries/jcb_powers/htaccess.txt b/libraries/jcb_powers/htaccess.txt new file mode 100644 index 0000000..9afb1a1 --- /dev/null +++ b/libraries/jcb_powers/htaccess.txt @@ -0,0 +1,9 @@ +# Apache 2.4+ + + Require all denied + + +# Apache 2.0-2.2 + + Deny from all + diff --git a/libraries/jcb_powers/index.html b/libraries/jcb_powers/index.html new file mode 100644 index 0000000..fa6d84e --- /dev/null +++ b/libraries/jcb_powers/index.html @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/libraries/jcb_powers/web.config b/libraries/jcb_powers/web.config new file mode 100644 index 0000000..47b6d6d --- /dev/null +++ b/libraries/jcb_powers/web.config @@ -0,0 +1,7 @@ + + + + + + + diff --git a/media/css/index.html b/media/css/index.html new file mode 100644 index 0000000..fa6d84e --- /dev/null +++ b/media/css/index.html @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/media/datatable/css/datatables.min.css b/media/datatable/css/datatables.min.css new file mode 100644 index 0000000..5c9d00a --- /dev/null +++ b/media/datatable/css/datatables.min.css @@ -0,0 +1,57 @@ +/* + * This combined file was created by the DataTables downloader builder: + * https://datatables.net/download + * + * To rebuild or modify this file with the latest versions of the included + * software please visit: + * https://datatables.net/download/#dt/jszip-2.5.0/dt-1.11.5/b-2.2.2/b-colvis-2.2.2/b-html5-2.2.2/b-print-2.2.2/cr-1.5.5/date-1.1.2/fc-4.0.2/fh-3.2.2/kt-2.6.4/r-2.2.9/rg-1.1.4/rr-1.2.8/sc-2.0.5/sb-1.3.2/sp-2.0.0/sl-1.3.4/sr-1.1.0 + * + * Included libraries: + * JSZip 2.5.0, DataTables 1.11.5, Buttons 2.2.2, Column visibility 2.2.2, HTML5 export 2.2.2, Print view 2.2.2, ColReorder 1.5.5, DateTime 1.1.2, FixedColumns 4.0.2, FixedHeader 3.2.2, KeyTable 2.6.4, Responsive 2.2.9, RowGroup 1.1.4, RowReorder 1.2.8, Scroller 2.0.5, SearchBuilder 1.3.2, SearchPanes 2.0.0, Select 1.3.4, StateRestore 1.1.0 + */ + +table.dataTable th.dt-left,table.dataTable td.dt-left{text-align:left}table.dataTable th.dt-center,table.dataTable td.dt-center,table.dataTable td.dataTables_empty{text-align:center}table.dataTable th.dt-right,table.dataTable td.dt-right{text-align:right}table.dataTable th.dt-justify,table.dataTable td.dt-justify{text-align:justify}table.dataTable th.dt-nowrap,table.dataTable td.dt-nowrap{white-space:nowrap}table.dataTable thead th.dt-head-left,table.dataTable thead td.dt-head-left,table.dataTable tfoot th.dt-head-left,table.dataTable tfoot td.dt-head-left{text-align:left}table.dataTable thead th.dt-head-center,table.dataTable thead td.dt-head-center,table.dataTable tfoot th.dt-head-center,table.dataTable tfoot td.dt-head-center{text-align:center}table.dataTable thead th.dt-head-right,table.dataTable thead td.dt-head-right,table.dataTable tfoot th.dt-head-right,table.dataTable tfoot td.dt-head-right{text-align:right}table.dataTable thead th.dt-head-justify,table.dataTable thead td.dt-head-justify,table.dataTable tfoot th.dt-head-justify,table.dataTable tfoot td.dt-head-justify{text-align:justify}table.dataTable thead th.dt-head-nowrap,table.dataTable thead td.dt-head-nowrap,table.dataTable tfoot th.dt-head-nowrap,table.dataTable tfoot td.dt-head-nowrap{white-space:nowrap}table.dataTable tbody th.dt-body-left,table.dataTable tbody td.dt-body-left{text-align:left}table.dataTable tbody th.dt-body-center,table.dataTable tbody td.dt-body-center{text-align:center}table.dataTable tbody th.dt-body-right,table.dataTable tbody td.dt-body-right{text-align:right}table.dataTable tbody th.dt-body-justify,table.dataTable tbody td.dt-body-justify{text-align:justify}table.dataTable tbody th.dt-body-nowrap,table.dataTable tbody td.dt-body-nowrap{white-space:nowrap}table.dataTable td.dt-control{text-align:center;cursor:pointer}table.dataTable td.dt-control:before{height:1em;width:1em;margin-top:-9px;display:inline-block;color:white;border:.15em solid white;border-radius:1em;box-shadow:0 0 .2em #444;box-sizing:content-box;text-align:center;text-indent:0 !important;font-family:"Courier New",Courier,monospace;line-height:1em;content:"+";background-color:#31b131}table.dataTable tr.dt-hasChild td.dt-control:before{content:"-";background-color:#d33333}table.dataTable{width:100%;margin:0 auto;clear:both;border-collapse:separate;border-spacing:0}table.dataTable thead th,table.dataTable tfoot th{font-weight:bold}table.dataTable thead th,table.dataTable thead td{padding:10px 18px;border-bottom:1px solid #111}table.dataTable thead th:active,table.dataTable thead td:active{outline:none}table.dataTable tfoot th,table.dataTable tfoot td{padding:10px 18px 6px 18px;border-top:1px solid #111}table.dataTable thead .sorting,table.dataTable thead .sorting_asc,table.dataTable thead .sorting_desc,table.dataTable thead .sorting_asc_disabled,table.dataTable thead .sorting_desc_disabled{cursor:pointer;*cursor:hand;background-repeat:no-repeat;background-position:center right}table.dataTable thead .sorting{background-image:url("/DataTables-1.11.5/images/sort_both.png")}table.dataTable thead .sorting_asc{background-image:url("/DataTables-1.11.5/images/sort_asc.png") !important}table.dataTable thead .sorting_desc{background-image:url("/DataTables-1.11.5/images/sort_desc.png") !important}table.dataTable thead .sorting_asc_disabled{background-image:url("/DataTables-1.11.5/images/sort_asc_disabled.png")}table.dataTable thead .sorting_desc_disabled{background-image:url("/DataTables-1.11.5/images/sort_desc_disabled.png")}table.dataTable tbody tr{background-color:#fff}table.dataTable tbody tr.selected{background-color:#b0bed9}table.dataTable tbody th,table.dataTable tbody td{padding:8px 10px}table.dataTable.row-border tbody th,table.dataTable.row-border tbody td,table.dataTable.display tbody th,table.dataTable.display tbody td{border-top:1px solid #ddd}table.dataTable.row-border tbody tr:first-child th,table.dataTable.row-border tbody tr:first-child td,table.dataTable.display tbody tr:first-child th,table.dataTable.display tbody tr:first-child td{border-top:none}table.dataTable.cell-border tbody th,table.dataTable.cell-border tbody td{border-top:1px solid #ddd;border-right:1px solid #ddd}table.dataTable.cell-border tbody tr th:first-child,table.dataTable.cell-border tbody tr td:first-child{border-left:1px solid #ddd}table.dataTable.cell-border tbody tr:first-child th,table.dataTable.cell-border tbody tr:first-child td{border-top:none}table.dataTable.stripe tbody tr.odd,table.dataTable.display tbody tr.odd{background-color:#f9f9f9}table.dataTable.stripe tbody tr.odd.selected,table.dataTable.display tbody tr.odd.selected{background-color:#acbad4}table.dataTable.hover tbody tr:hover,table.dataTable.display tbody tr:hover{background-color:#f6f6f6}table.dataTable.hover tbody tr:hover.selected,table.dataTable.display tbody tr:hover.selected{background-color:#aab7d1}table.dataTable.order-column tbody tr>.sorting_1,table.dataTable.order-column tbody tr>.sorting_2,table.dataTable.order-column tbody tr>.sorting_3,table.dataTable.display tbody tr>.sorting_1,table.dataTable.display tbody tr>.sorting_2,table.dataTable.display tbody tr>.sorting_3{background-color:#fafafa}table.dataTable.order-column tbody tr.selected>.sorting_1,table.dataTable.order-column tbody tr.selected>.sorting_2,table.dataTable.order-column tbody tr.selected>.sorting_3,table.dataTable.display tbody tr.selected>.sorting_1,table.dataTable.display tbody tr.selected>.sorting_2,table.dataTable.display tbody tr.selected>.sorting_3{background-color:#acbad5}table.dataTable.display tbody tr.odd>.sorting_1,table.dataTable.order-column.stripe tbody tr.odd>.sorting_1{background-color:#f1f1f1}table.dataTable.display tbody tr.odd>.sorting_2,table.dataTable.order-column.stripe tbody tr.odd>.sorting_2{background-color:#f3f3f3}table.dataTable.display tbody tr.odd>.sorting_3,table.dataTable.order-column.stripe tbody tr.odd>.sorting_3{background-color:whitesmoke}table.dataTable.display tbody tr.odd.selected>.sorting_1,table.dataTable.order-column.stripe tbody tr.odd.selected>.sorting_1{background-color:#a6b4cd}table.dataTable.display tbody tr.odd.selected>.sorting_2,table.dataTable.order-column.stripe tbody tr.odd.selected>.sorting_2{background-color:#a8b5cf}table.dataTable.display tbody tr.odd.selected>.sorting_3,table.dataTable.order-column.stripe tbody tr.odd.selected>.sorting_3{background-color:#a9b7d1}table.dataTable.display tbody tr.even>.sorting_1,table.dataTable.order-column.stripe tbody tr.even>.sorting_1{background-color:#fafafa}table.dataTable.display tbody tr.even>.sorting_2,table.dataTable.order-column.stripe tbody tr.even>.sorting_2{background-color:#fcfcfc}table.dataTable.display tbody tr.even>.sorting_3,table.dataTable.order-column.stripe tbody tr.even>.sorting_3{background-color:#fefefe}table.dataTable.display tbody tr.even.selected>.sorting_1,table.dataTable.order-column.stripe tbody tr.even.selected>.sorting_1{background-color:#acbad5}table.dataTable.display tbody tr.even.selected>.sorting_2,table.dataTable.order-column.stripe tbody tr.even.selected>.sorting_2{background-color:#aebcd6}table.dataTable.display tbody tr.even.selected>.sorting_3,table.dataTable.order-column.stripe tbody tr.even.selected>.sorting_3{background-color:#afbdd8}table.dataTable.display tbody tr:hover>.sorting_1,table.dataTable.order-column.hover tbody tr:hover>.sorting_1{background-color:#eaeaea}table.dataTable.display tbody tr:hover>.sorting_2,table.dataTable.order-column.hover tbody tr:hover>.sorting_2{background-color:#ececec}table.dataTable.display tbody tr:hover>.sorting_3,table.dataTable.order-column.hover tbody tr:hover>.sorting_3{background-color:#efefef}table.dataTable.display tbody tr:hover.selected>.sorting_1,table.dataTable.order-column.hover tbody tr:hover.selected>.sorting_1{background-color:#a2aec7}table.dataTable.display tbody tr:hover.selected>.sorting_2,table.dataTable.order-column.hover tbody tr:hover.selected>.sorting_2{background-color:#a3b0c9}table.dataTable.display tbody tr:hover.selected>.sorting_3,table.dataTable.order-column.hover tbody tr:hover.selected>.sorting_3{background-color:#a5b2cb}table.dataTable.no-footer{border-bottom:1px solid #111}table.dataTable.nowrap th,table.dataTable.nowrap td{white-space:nowrap}table.dataTable.compact thead th,table.dataTable.compact thead td{padding:4px 17px}table.dataTable.compact tfoot th,table.dataTable.compact tfoot td{padding:4px}table.dataTable.compact tbody th,table.dataTable.compact tbody td{padding:4px}table.dataTable th,table.dataTable td{box-sizing:content-box}.dataTables_wrapper{position:relative;clear:both}.dataTables_wrapper .dataTables_length{float:left}.dataTables_wrapper .dataTables_length select{border:1px solid #aaa;border-radius:3px;padding:5px;background-color:transparent;padding:4px}.dataTables_wrapper .dataTables_filter{float:right;text-align:right}.dataTables_wrapper .dataTables_filter input{border:1px solid #aaa;border-radius:3px;padding:5px;background-color:transparent;margin-left:3px}.dataTables_wrapper .dataTables_info{clear:both;float:left;padding-top:.755em}.dataTables_wrapper .dataTables_paginate{float:right;text-align:right;padding-top:.25em}.dataTables_wrapper .dataTables_paginate .paginate_button{box-sizing:border-box;display:inline-block;min-width:1.5em;padding:.5em 1em;margin-left:2px;text-align:center;text-decoration:none !important;cursor:pointer;*cursor:hand;color:#333 !important;border:1px solid transparent;border-radius:2px}.dataTables_wrapper .dataTables_paginate .paginate_button.current,.dataTables_wrapper .dataTables_paginate .paginate_button.current:hover{color:#333 !important;border:1px solid #979797;background-color:white;background:-webkit-gradient(linear, left top, left bottom, color-stop(0%, white), color-stop(100%, #dcdcdc));background:-webkit-linear-gradient(top, white 0%, #dcdcdc 100%);background:-moz-linear-gradient(top, white 0%, #dcdcdc 100%);background:-ms-linear-gradient(top, white 0%, #dcdcdc 100%);background:-o-linear-gradient(top, white 0%, #dcdcdc 100%);background:linear-gradient(to bottom, white 0%, #dcdcdc 100%)}.dataTables_wrapper .dataTables_paginate .paginate_button.disabled,.dataTables_wrapper .dataTables_paginate .paginate_button.disabled:hover,.dataTables_wrapper .dataTables_paginate .paginate_button.disabled:active{cursor:default;color:#666 !important;border:1px solid transparent;background:transparent;box-shadow:none}.dataTables_wrapper .dataTables_paginate .paginate_button:hover{color:white !important;border:1px solid #111;background-color:#585858;background:-webkit-gradient(linear, left top, left bottom, color-stop(0%, #585858), color-stop(100%, #111));background:-webkit-linear-gradient(top, #585858 0%, #111 100%);background:-moz-linear-gradient(top, #585858 0%, #111 100%);background:-ms-linear-gradient(top, #585858 0%, #111 100%);background:-o-linear-gradient(top, #585858 0%, #111 100%);background:linear-gradient(to bottom, #585858 0%, #111 100%)}.dataTables_wrapper .dataTables_paginate .paginate_button:active{outline:none;background-color:#2b2b2b;background:-webkit-gradient(linear, left top, left bottom, color-stop(0%, #2b2b2b), color-stop(100%, #0c0c0c));background:-webkit-linear-gradient(top, #2b2b2b 0%, #0c0c0c 100%);background:-moz-linear-gradient(top, #2b2b2b 0%, #0c0c0c 100%);background:-ms-linear-gradient(top, #2b2b2b 0%, #0c0c0c 100%);background:-o-linear-gradient(top, #2b2b2b 0%, #0c0c0c 100%);background:linear-gradient(to bottom, #2b2b2b 0%, #0c0c0c 100%);box-shadow:inset 0 0 3px #111}.dataTables_wrapper .dataTables_paginate .ellipsis{padding:0 1em}.dataTables_wrapper .dataTables_processing{position:absolute;top:50%;left:50%;width:100%;height:40px;margin-left:-50%;margin-top:-25px;padding-top:20px;text-align:center;font-size:1.2em;background-color:white;background:-webkit-gradient(linear, left top, right top, color-stop(0%, rgba(255, 255, 255, 0)), color-stop(25%, rgba(255, 255, 255, 0.9)), color-stop(75%, rgba(255, 255, 255, 0.9)), color-stop(100%, rgba(255, 255, 255, 0)));background:-webkit-linear-gradient(left, rgba(255, 255, 255, 0) 0%, rgba(255, 255, 255, 0.9) 25%, rgba(255, 255, 255, 0.9) 75%, rgba(255, 255, 255, 0) 100%);background:-moz-linear-gradient(left, rgba(255, 255, 255, 0) 0%, rgba(255, 255, 255, 0.9) 25%, rgba(255, 255, 255, 0.9) 75%, rgba(255, 255, 255, 0) 100%);background:-ms-linear-gradient(left, rgba(255, 255, 255, 0) 0%, rgba(255, 255, 255, 0.9) 25%, rgba(255, 255, 255, 0.9) 75%, rgba(255, 255, 255, 0) 100%);background:-o-linear-gradient(left, rgba(255, 255, 255, 0) 0%, rgba(255, 255, 255, 0.9) 25%, rgba(255, 255, 255, 0.9) 75%, rgba(255, 255, 255, 0) 100%);background:linear-gradient(to right, rgba(255, 255, 255, 0) 0%, rgba(255, 255, 255, 0.9) 25%, rgba(255, 255, 255, 0.9) 75%, rgba(255, 255, 255, 0) 100%)}.dataTables_wrapper .dataTables_length,.dataTables_wrapper .dataTables_filter,.dataTables_wrapper .dataTables_info,.dataTables_wrapper .dataTables_processing,.dataTables_wrapper .dataTables_paginate{color:#333}.dataTables_wrapper .dataTables_scroll{clear:both}.dataTables_wrapper .dataTables_scroll div.dataTables_scrollBody{*margin-top:-1px;-webkit-overflow-scrolling:touch}.dataTables_wrapper .dataTables_scroll div.dataTables_scrollBody>table>thead>tr>th,.dataTables_wrapper .dataTables_scroll div.dataTables_scrollBody>table>thead>tr>td,.dataTables_wrapper .dataTables_scroll div.dataTables_scrollBody>table>tbody>tr>th,.dataTables_wrapper .dataTables_scroll div.dataTables_scrollBody>table>tbody>tr>td{vertical-align:middle}.dataTables_wrapper .dataTables_scroll div.dataTables_scrollBody>table>thead>tr>th>div.dataTables_sizing,.dataTables_wrapper .dataTables_scroll div.dataTables_scrollBody>table>thead>tr>td>div.dataTables_sizing,.dataTables_wrapper .dataTables_scroll div.dataTables_scrollBody>table>tbody>tr>th>div.dataTables_sizing,.dataTables_wrapper .dataTables_scroll div.dataTables_scrollBody>table>tbody>tr>td>div.dataTables_sizing{height:0;overflow:hidden;margin:0 !important;padding:0 !important}.dataTables_wrapper.no-footer .dataTables_scrollBody{border-bottom:1px solid #111}.dataTables_wrapper.no-footer div.dataTables_scrollHead table.dataTable,.dataTables_wrapper.no-footer div.dataTables_scrollBody>table{border-bottom:none}.dataTables_wrapper:after{visibility:hidden;display:block;content:"";clear:both;height:0}@media screen and (max-width: 767px){.dataTables_wrapper .dataTables_info,.dataTables_wrapper .dataTables_paginate{float:none;text-align:center}.dataTables_wrapper .dataTables_paginate{margin-top:.5em}}@media screen and (max-width: 640px){.dataTables_wrapper .dataTables_length,.dataTables_wrapper .dataTables_filter{float:none;text-align:center}.dataTables_wrapper .dataTables_filter{margin-top:.5em}} + + +@keyframes dtb-spinner{100%{transform:rotate(360deg)}}@-o-keyframes dtb-spinner{100%{-o-transform:rotate(360deg);transform:rotate(360deg)}}@-ms-keyframes dtb-spinner{100%{-ms-transform:rotate(360deg);transform:rotate(360deg)}}@-webkit-keyframes dtb-spinner{100%{-webkit-transform:rotate(360deg);transform:rotate(360deg)}}@-moz-keyframes dtb-spinner{100%{-moz-transform:rotate(360deg);transform:rotate(360deg)}}div.dataTables_wrapper{position:relative}div.dt-buttons{position:initial}div.dt-button-info{position:fixed;top:50%;left:50%;width:400px;margin-top:-100px;margin-left:-200px;background-color:white;border:2px solid #111;box-shadow:3px 4px 10px 1px rgba(0, 0, 0, 0.3);border-radius:3px;text-align:center;z-index:21}div.dt-button-info h2{padding:.5em;margin:0;font-weight:normal;border-bottom:1px solid #ddd;background-color:#f3f3f3}div.dt-button-info>div{padding:1em}div.dtb-popover-close{position:absolute;top:10px;right:10px;width:22px;height:22px;border:1px solid #eaeaea;background-color:#f9f9f9;text-align:center;border-radius:3px;cursor:pointer;z-index:12}button.dtb-hide-drop{display:none !important}div.dt-button-collection-title{text-align:center;padding:.3em 0 .5em;margin-left:.5em;margin-right:.5em;font-size:.9em}div.dt-button-collection-title:empty{display:none}span.dt-button-spacer{display:inline-block;margin:.5em;white-space:nowrap}span.dt-button-spacer.bar{border-left:1px solid rgba(0, 0, 0, 0.3);vertical-align:middle;padding-left:.5em}span.dt-button-spacer.bar:empty{height:1em;width:1px;padding-left:0}div.dt-button-collection span.dt-button-spacer{width:100%;font-size:.9em;text-align:center;margin:.5em 0}div.dt-button-collection span.dt-button-spacer:empty{height:0;width:100%}div.dt-button-collection span.dt-button-spacer.bar{border-left:none;border-bottom:1px solid rgba(0, 0, 0, 0.3);padding-left:0}button.dt-button,div.dt-button,a.dt-button,input.dt-button{position:relative;display:inline-block;box-sizing:border-box;margin-left:.167em;margin-right:.167em;margin-bottom:.333em;padding:.5em 1em;border:1px solid rgba(0, 0, 0, 0.3);border-radius:2px;cursor:pointer;font-size:.88em;line-height:1.6em;color:black;white-space:nowrap;overflow:hidden;background-color:rgba(0, 0, 0, 0.1);background:-webkit-linear-gradient(top, rgba(230, 230, 230, 0.1) 0%, rgba(0, 0, 0, 0.1) 100%);background:-moz-linear-gradient(top, rgba(230, 230, 230, 0.1) 0%, rgba(0, 0, 0, 0.1) 100%);background:-ms-linear-gradient(top, rgba(230, 230, 230, 0.1) 0%, rgba(0, 0, 0, 0.1) 100%);background:-o-linear-gradient(top, rgba(230, 230, 230, 0.1) 0%, rgba(0, 0, 0, 0.1) 100%);background:linear-gradient(to bottom, rgba(230, 230, 230, 0.1) 0%, rgba(0, 0, 0, 0.1) 100%);filter:progid:DXImageTransform.Microsoft.gradient(GradientType=0,StartColorStr="rgba(230, 230, 230, 0.1)", EndColorStr="rgba(0, 0, 0, 0.1)");-webkit-user-select:none;-moz-user-select:none;-ms-user-select:none;user-select:none;text-decoration:none;outline:none;text-overflow:ellipsis}button.dt-button:first-child,div.dt-button:first-child,a.dt-button:first-child,input.dt-button:first-child{margin-left:0}button.dt-button.disabled,div.dt-button.disabled,a.dt-button.disabled,input.dt-button.disabled{cursor:default;opacity:.4}button.dt-button:active:not(.disabled),button.dt-button.active:not(.disabled),div.dt-button:active:not(.disabled),div.dt-button.active:not(.disabled),a.dt-button:active:not(.disabled),a.dt-button.active:not(.disabled),input.dt-button:active:not(.disabled),input.dt-button.active:not(.disabled){background-color:rgba(0, 0, 0, 0.1);background:-webkit-linear-gradient(top, rgba(179, 179, 179, 0.1) 0%, rgba(0, 0, 0, 0.1) 100%);background:-moz-linear-gradient(top, rgba(179, 179, 179, 0.1) 0%, rgba(0, 0, 0, 0.1) 100%);background:-ms-linear-gradient(top, rgba(179, 179, 179, 0.1) 0%, rgba(0, 0, 0, 0.1) 100%);background:-o-linear-gradient(top, rgba(179, 179, 179, 0.1) 0%, rgba(0, 0, 0, 0.1) 100%);background:linear-gradient(to bottom, rgba(179, 179, 179, 0.1) 0%, rgba(0, 0, 0, 0.1) 100%);filter:progid:DXImageTransform.Microsoft.gradient(GradientType=0,StartColorStr="rgba(179, 179, 179, 0.1)", EndColorStr="rgba(0, 0, 0, 0.1)");box-shadow:inset 1px 1px 3px #999}button.dt-button:active:not(.disabled):hover:not(.disabled),button.dt-button.active:not(.disabled):hover:not(.disabled),div.dt-button:active:not(.disabled):hover:not(.disabled),div.dt-button.active:not(.disabled):hover:not(.disabled),a.dt-button:active:not(.disabled):hover:not(.disabled),a.dt-button.active:not(.disabled):hover:not(.disabled),input.dt-button:active:not(.disabled):hover:not(.disabled),input.dt-button.active:not(.disabled):hover:not(.disabled){box-shadow:inset 1px 1px 3px #999;background-color:rgba(0, 0, 0, 0.1);background:-webkit-linear-gradient(top, rgba(128, 128, 128, 0.1) 0%, rgba(0, 0, 0, 0.1) 100%);background:-moz-linear-gradient(top, rgba(128, 128, 128, 0.1) 0%, rgba(0, 0, 0, 0.1) 100%);background:-ms-linear-gradient(top, rgba(128, 128, 128, 0.1) 0%, rgba(0, 0, 0, 0.1) 100%);background:-o-linear-gradient(top, rgba(128, 128, 128, 0.1) 0%, rgba(0, 0, 0, 0.1) 100%);background:linear-gradient(to bottom, rgba(128, 128, 128, 0.1) 0%, rgba(0, 0, 0, 0.1) 100%);filter:progid:DXImageTransform.Microsoft.gradient(GradientType=0,StartColorStr="rgba(128, 128, 128, 0.1)", EndColorStr="rgba(0, 0, 0, 0.1)")}button.dt-button:hover,div.dt-button:hover,a.dt-button:hover,input.dt-button:hover{text-decoration:none}button.dt-button:hover:not(.disabled),div.dt-button:hover:not(.disabled),a.dt-button:hover:not(.disabled),input.dt-button:hover:not(.disabled){border:1px solid #666;background-color:rgba(0, 0, 0, 0.1);background:-webkit-linear-gradient(top, rgba(153, 153, 153, 0.1) 0%, rgba(0, 0, 0, 0.1) 100%);background:-moz-linear-gradient(top, rgba(153, 153, 153, 0.1) 0%, rgba(0, 0, 0, 0.1) 100%);background:-ms-linear-gradient(top, rgba(153, 153, 153, 0.1) 0%, rgba(0, 0, 0, 0.1) 100%);background:-o-linear-gradient(top, rgba(153, 153, 153, 0.1) 0%, rgba(0, 0, 0, 0.1) 100%);background:linear-gradient(to bottom, rgba(153, 153, 153, 0.1) 0%, rgba(0, 0, 0, 0.1) 100%);filter:progid:DXImageTransform.Microsoft.gradient(GradientType=0,StartColorStr="rgba(153, 153, 153, 0.1)", EndColorStr="rgba(0, 0, 0, 0.1)")}button.dt-button:focus:not(.disabled),div.dt-button:focus:not(.disabled),a.dt-button:focus:not(.disabled),input.dt-button:focus:not(.disabled){border:1px solid #426c9e;text-shadow:0 1px 0 #c4def1;outline:none;background-color:#79ace9;background:-webkit-linear-gradient(top, #d1e2f7 0%, #79ace9 100%);background:-moz-linear-gradient(top, #d1e2f7 0%, #79ace9 100%);background:-ms-linear-gradient(top, #d1e2f7 0%, #79ace9 100%);background:-o-linear-gradient(top, #d1e2f7 0%, #79ace9 100%);background:linear-gradient(to bottom, #d1e2f7 0%, #79ace9 100%);filter:progid:DXImageTransform.Microsoft.gradient(GradientType=0,StartColorStr="#d1e2f7", EndColorStr="#79ace9")}button.dt-button span.dt-down-arrow,div.dt-button span.dt-down-arrow,a.dt-button span.dt-down-arrow,input.dt-button span.dt-down-arrow{position:relative;top:-2px;color:rgba(70, 70, 70, 0.75);font-size:8px;padding-left:10px;line-height:1em}.dt-button embed{outline:none}div.dt-buttons{float:left}div.dt-buttons.buttons-right{float:right}div.dataTables_layout_cell div.dt-buttons{float:none}div.dataTables_layout_cell div.dt-buttons.buttons-right{float:none}div.dt-btn-split-wrapper{display:inline-block}div.dt-button-collection{position:absolute;top:0;left:0;width:200px;margin-top:3px;margin-bottom:3px;padding:4px 4px 2px 4px;border:1px solid #ccc;border:1px solid rgba(0, 0, 0, 0.4);background-color:white;overflow:hidden;z-index:2002;border-radius:5px;box-shadow:3px 4px 10px 1px rgba(0, 0, 0, 0.3);box-sizing:border-box}div.dt-button-collection button.dt-button,div.dt-button-collection div.dt-button,div.dt-button-collection a.dt-button{position:relative;left:0;right:0;width:100%;display:block;float:none;margin:4px 0 2px 0}div.dt-button-collection button.dt-button:active:not(.disabled),div.dt-button-collection button.dt-button.active:not(.disabled),div.dt-button-collection div.dt-button:active:not(.disabled),div.dt-button-collection div.dt-button.active:not(.disabled),div.dt-button-collection a.dt-button:active:not(.disabled),div.dt-button-collection a.dt-button.active:not(.disabled){background-color:#dadada;background:-webkit-linear-gradient(top, #f0f0f0 0%, #dadada 100%);background:-moz-linear-gradient(top, #f0f0f0 0%, #dadada 100%);background:-ms-linear-gradient(top, #f0f0f0 0%, #dadada 100%);background:-o-linear-gradient(top, #f0f0f0 0%, #dadada 100%);background:linear-gradient(to bottom, #f0f0f0 0%, #dadada 100%);filter:progid:DXImageTransform.Microsoft.gradient(GradientType=0,StartColorStr="#f0f0f0", EndColorStr="#dadada");box-shadow:inset 1px 1px 3px #666}div.dt-button-collection button.dt-button:first-child,div.dt-button-collection div.dt-button:first-child,div.dt-button-collection a.dt-button:first-child{margin-top:0;border-top-left-radius:3px;border-top-right-radius:3px}div.dt-button-collection button.dt-button:last-child,div.dt-button-collection div.dt-button:last-child,div.dt-button-collection a.dt-button:last-child{border-bottom-left-radius:3px;border-bottom-right-radius:3px}div.dt-button-collection div.dt-btn-split-wrapper{display:flex;flex-direction:row;flex-wrap:wrap;justify-content:flex-start;align-content:flex-start;align-items:stretch;margin:4px 0 2px 0}div.dt-button-collection div.dt-btn-split-wrapper button.dt-button{margin:0;display:inline-block;width:0;flex-grow:1;flex-shrink:0;flex-basis:50px;border-radius:0}div.dt-button-collection div.dt-btn-split-wrapper button.dt-btn-split-drop{min-width:20px;flex-grow:0;flex-shrink:0;flex-basis:0}div.dt-button-collection div.dt-btn-split-wrapper:first-child{margin-top:0}div.dt-button-collection div.dt-btn-split-wrapper:first-child button.dt-button{border-top-left-radius:3px}div.dt-button-collection div.dt-btn-split-wrapper:first-child button.dt-btn-split-drop{border-top-right-radius:3px}div.dt-button-collection div.dt-btn-split-wrapper:last-child button.dt-button{border-bottom-left-radius:3px}div.dt-button-collection div.dt-btn-split-wrapper:last-child button.dt-btn-split-drop{border-bottom-right-radius:3px}div.dt-button-collection div.dt-btn-split-wrapper:active:not(.disabled) button.dt-button,div.dt-button-collection div.dt-btn-split-wrapper.active:not(.disabled) button.dt-button{background-color:#dadada;background:-webkit-linear-gradient(top, #f0f0f0 0%, #dadada 100%);background:-moz-linear-gradient(top, #f0f0f0 0%, #dadada 100%);background:-ms-linear-gradient(top, #f0f0f0 0%, #dadada 100%);background:-o-linear-gradient(top, #f0f0f0 0%, #dadada 100%);background:linear-gradient(to bottom, #f0f0f0 0%, #dadada 100%);filter:progid:DXImageTransform.Microsoft.gradient(GradientType=0,StartColorStr="#f0f0f0", EndColorStr="#dadada");box-shadow:inset 0px 0px 4px #666}div.dt-button-collection div.dt-btn-split-wrapper:active:not(.disabled) button.dt-btn-split-drop,div.dt-button-collection div.dt-btn-split-wrapper.active:not(.disabled) button.dt-btn-split-drop{box-shadow:none}div.dt-button-collection.fixed .dt-button:first-child{margin-top:0;border-top-left-radius:0;border-top-right-radius:0}div.dt-button-collection.fixed .dt-button:last-child{border-bottom-left-radius:0;border-bottom-right-radius:0}div.dt-button-collection.fixed{position:fixed;display:block;top:50%;left:50%;margin-left:-75px;border-radius:5px;background-color:white}div.dt-button-collection.fixed.two-column{margin-left:-200px}div.dt-button-collection.fixed.three-column{margin-left:-225px}div.dt-button-collection.fixed.four-column{margin-left:-300px}div.dt-button-collection.fixed.columns{margin-left:-409px}@media screen and (max-width: 1024px){div.dt-button-collection.fixed.columns{margin-left:-308px}}@media screen and (max-width: 640px){div.dt-button-collection.fixed.columns{margin-left:-203px}}@media screen and (max-width: 460px){div.dt-button-collection.fixed.columns{margin-left:-100px}}div.dt-button-collection.fixed>:last-child{max-height:100vh;overflow:auto}div.dt-button-collection.two-column>:last-child,div.dt-button-collection.three-column>:last-child,div.dt-button-collection.four-column>:last-child{display:block !important;-webkit-column-gap:8px;-moz-column-gap:8px;-ms-column-gap:8px;-o-column-gap:8px;column-gap:8px}div.dt-button-collection.two-column>:last-child>*,div.dt-button-collection.three-column>:last-child>*,div.dt-button-collection.four-column>:last-child>*{-webkit-column-break-inside:avoid;break-inside:avoid}div.dt-button-collection.two-column{width:400px}div.dt-button-collection.two-column>:last-child{padding-bottom:1px;column-count:2}div.dt-button-collection.three-column{width:450px}div.dt-button-collection.three-column>:last-child{padding-bottom:1px;column-count:3}div.dt-button-collection.four-column{width:600px}div.dt-button-collection.four-column>:last-child{padding-bottom:1px;column-count:4}div.dt-button-collection .dt-button{border-radius:0}div.dt-button-collection.columns{width:auto}div.dt-button-collection.columns>:last-child{display:flex;flex-wrap:wrap;justify-content:flex-start;align-items:center;gap:6px;width:818px;padding-bottom:1px}div.dt-button-collection.columns>:last-child .dt-button{min-width:200px;flex:0 1;margin:0}div.dt-button-collection.columns.dtb-b3>:last-child,div.dt-button-collection.columns.dtb-b2>:last-child,div.dt-button-collection.columns.dtb-b1>:last-child{justify-content:space-between}div.dt-button-collection.columns.dtb-b3 .dt-button{flex:1 1 32%}div.dt-button-collection.columns.dtb-b2 .dt-button{flex:1 1 48%}div.dt-button-collection.columns.dtb-b1 .dt-button{flex:1 1 100%}@media screen and (max-width: 1024px){div.dt-button-collection.columns>:last-child{width:612px}}@media screen and (max-width: 640px){div.dt-button-collection.columns>:last-child{width:406px}div.dt-button-collection.columns.dtb-b3 .dt-button{flex:0 1 32%}}@media screen and (max-width: 460px){div.dt-button-collection.columns>:last-child{width:200px}}div.dt-button-background{position:fixed;top:0;left:0;width:100%;height:100%;background:rgba(0, 0, 0, 0.7);background:-ms-radial-gradient(center, ellipse farthest-corner, rgba(0, 0, 0, 0.3) 0%, rgba(0, 0, 0, 0.7) 100%);background:-moz-radial-gradient(center, ellipse farthest-corner, rgba(0, 0, 0, 0.3) 0%, rgba(0, 0, 0, 0.7) 100%);background:-o-radial-gradient(center, ellipse farthest-corner, rgba(0, 0, 0, 0.3) 0%, rgba(0, 0, 0, 0.7) 100%);background:-webkit-gradient(radial, center center, 0, center center, 497, color-stop(0, rgba(0, 0, 0, 0.3)), color-stop(1, rgba(0, 0, 0, 0.7)));background:-webkit-radial-gradient(center, ellipse farthest-corner, rgba(0, 0, 0, 0.3) 0%, rgba(0, 0, 0, 0.7) 100%);background:radial-gradient(ellipse farthest-corner at center, rgba(0, 0, 0, 0.3) 0%, rgba(0, 0, 0, 0.7) 100%);z-index:2001}@media screen and (max-width: 640px){div.dt-buttons{float:none !important;text-align:center}}button.dt-button.processing,div.dt-button.processing,a.dt-button.processing{color:rgba(0, 0, 0, 0.2)}button.dt-button.processing:after,div.dt-button.processing:after,a.dt-button.processing:after{position:absolute;top:50%;left:50%;width:16px;height:16px;margin:-8px 0 0 -8px;box-sizing:border-box;display:block;content:" ";border:2px solid #282828;border-radius:50%;border-left-color:transparent;border-right-color:transparent;animation:dtb-spinner 1500ms infinite linear;-o-animation:dtb-spinner 1500ms infinite linear;-ms-animation:dtb-spinner 1500ms infinite linear;-webkit-animation:dtb-spinner 1500ms infinite linear;-moz-animation:dtb-spinner 1500ms infinite linear}button.dt-btn-split-drop{margin-left:calc(-1px - .333em);padding-bottom:calc(.5em - 1px);border-radius:0px 1px 1px 0px;color:rgba(70, 70, 70, 0.9);border-left:none}button.dt-btn-split-drop span.dt-btn-split-drop-arrow{position:relative;top:-1px;left:-2px;font-size:8px}button.dt-btn-split-drop:hover{z-index:2}button.buttons-split{border-right:1px solid rgba(70, 70, 70, 0);border-radius:1px 0px 0px 1px}button.dt-btn-split-drop-button{background-color:white}button.dt-btn-split-drop-button:hover{background-color:white} + + +table.DTCR_clonedTable.dataTable{position:absolute !important;background-color:rgba(255, 255, 255, 0.7);z-index:202}div.DTCR_pointer{width:1px;background-color:#0259c4;z-index:201} + + +div.dt-datetime{position:absolute;background-color:white;z-index:2050;border:1px solid #ccc;box-shadow:0 5px 15px -5px rgba(0, 0, 0, 0.5);padding:0 20px 6px 20px;width:275px}div.dt-datetime.inline{position:relative;box-shadow:none}div.dt-datetime div.dt-datetime-title{text-align:center;padding:5px 0px 3px}div.dt-datetime div.dt-datetime-buttons{text-align:center}div.dt-datetime div.dt-datetime-buttons a{display:inline-block;padding:0 .5em .5em .5em;margin:0;font-size:.9em}div.dt-datetime div.dt-datetime-buttons a:hover{text-decoration:underline}div.dt-datetime table{border-spacing:0;margin:12px 0;width:100%}div.dt-datetime table.dt-datetime-table-nospace{margin-top:-12px}div.dt-datetime table th{font-size:.8em;color:#777;font-weight:normal;width:14.285714286%;padding:0 0 4px 0;text-align:center}div.dt-datetime table td{font-size:.9em;color:#444;padding:0}div.dt-datetime table td.selectable{text-align:center;background:#f5f5f5}div.dt-datetime table td.selectable.disabled{color:#aaa;background:white}div.dt-datetime table td.selectable.disabled button:hover{color:#aaa;background:white}div.dt-datetime table td.selectable.now{background-color:#ddd}div.dt-datetime table td.selectable.now button{font-weight:bold}div.dt-datetime table td.selectable.selected button{background:#4e6ca3;color:white;border-radius:2px}div.dt-datetime table td.selectable button:hover{background:#ff8000;color:white;border-radius:2px}div.dt-datetime table td.dt-datetime-week{font-size:.7em}div.dt-datetime table button{width:100%;box-sizing:border-box;border:none;background:transparent;font-size:inherit;color:inherit;text-align:center;padding:4px 0;cursor:pointer;margin:0}div.dt-datetime table button span{display:inline-block;min-width:14px;text-align:right}div.dt-datetime table.weekNumber th{width:12.5%}div.dt-datetime div.dt-datetime-calendar table{margin-top:0}div.dt-datetime div.dt-datetime-label{position:relative;display:inline-block;height:30px;padding:5px 6px;border:1px solid transparent;box-sizing:border-box;cursor:pointer}div.dt-datetime div.dt-datetime-label:hover{border:1px solid #ddd;border-radius:2px;background-color:#f5f5f5}div.dt-datetime div.dt-datetime-label select{position:absolute;top:6px;left:0;cursor:pointer;opacity:0}div.dt-datetime.horizontal{width:550px}div.dt-datetime.horizontal div.dt-datetime-date,div.dt-datetime.horizontal div.dt-datetime-time{width:48%}div.dt-datetime.horizontal div.dt-datetime-time{margin-left:4%}div.dt-datetime div.dt-datetime-date{position:relative;float:left;width:100%}div.dt-datetime div.dt-datetime-time{position:relative;float:left;width:100%;text-align:center}div.dt-datetime div.dt-datetime-time>span{vertical-align:middle}div.dt-datetime div.dt-datetime-time th{text-align:left}div.dt-datetime div.dt-datetime-time div.dt-datetime-timeblock{display:inline-block;vertical-align:middle}div.dt-datetime div.dt-datetime-iconLeft,div.dt-datetime div.dt-datetime-iconRight,div.dt-datetime div.dt-datetime-iconUp,div.dt-datetime div.dt-datetime-iconDown{width:30px;height:30px;background-position:center;background-repeat:no-repeat;opacity:.3;overflow:hidden;box-sizing:border-box}div.dt-datetime div.dt-datetime-iconLeft:hover,div.dt-datetime div.dt-datetime-iconRight:hover,div.dt-datetime div.dt-datetime-iconUp:hover,div.dt-datetime div.dt-datetime-iconDown:hover{border:1px solid #ccc;border-radius:2px;background-color:#f0f0f0;opacity:.6}div.dt-datetime div.dt-datetime-iconLeft button,div.dt-datetime div.dt-datetime-iconRight button,div.dt-datetime div.dt-datetime-iconUp button,div.dt-datetime div.dt-datetime-iconDown button{border:none;background:transparent;text-indent:30px;height:100%;width:100%;cursor:pointer}div.dt-datetime div.dt-datetime-iconLeft{position:absolute;top:5px;left:5px;background-image:url("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABQAAAAeCAYAAAAsEj5rAAAAUklEQVR42u3VMQoAIBADQf8Pgj+OD9hG2CtONJB2ymQkKe0HbwAP0xucDiQWARITIDEBEnMgMQ8S8+AqBIl6kKgHiXqQqAeJepBo/z38J/U0uAHlaBkBl9I4GwAAAABJRU5ErkJggg==")}div.dt-datetime div.dt-datetime-iconRight{position:absolute;top:5px;right:5px;background-image:url("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABQAAAAeCAYAAAAsEj5rAAAAU0lEQVR42u3VOwoAMAgE0dwfAnNjU26bYkBCFGwfiL9VVWoO+BJ4Gf3gtsEKKoFBNTCoCAYVwaAiGNQGMUHMkjGbgjk2mIONuXo0nC8XnCf1JXgArVIZAQh5TKYAAAAASUVORK5CYII=")}div.dt-datetime div.dt-datetime-iconUp{height:20px;background-image:url("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAB4AAAALCAMAAABf9c24AAAAFVBMVEX///99fX1+fn57e3t6enoAAAAAAAC73bqPAAAABnRSTlMAYmJkZt92bnysAAAAL0lEQVR4AWOgJmBhxCvLyopHnpmVjY2VCadeoCxIHrcsWJ4RlyxCHlMWCTBRJxwAjrIBDMWSiM0AAAAASUVORK5CYII=")}div.dt-datetime div.dt-datetime-iconDown{height:20px;background-image:url("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAB4AAAALCAMAAABf9c24AAAAFVBMVEX///99fX1+fn57e3t6enoAAAAAAAC73bqPAAAABnRSTlMAYmJkZt92bnysAAAAMElEQVR4AWOgDmBiRQIsmPKMrGxQgJDFlEfIYpoPk8Utz8qM232MYFfhkQfKUg8AANefAQxecJ58AAAAAElFTkSuQmCC")}div.dt-datetime-error{clear:both;padding:0 1em;max-width:240px;font-size:11px;line-height:1.25em;text-align:center;color:#b11f1f} + + +table.dataTable.display tbody tr.DTFC_NoData{background-color:transparent}tr.even td{background-color:#fff}tr.odd td{background-color:#f9f9f9}tr.selected td{background-color:#a6b4cd}thead th{background-color:white}tfoot th{background-color:white}tr.dt-rowReorder-moving td.dtfc-fixed-left,tr.dt-rowReorder-moving td.dtfc-fixed-right{border-top:2px solid #555 !important;border-bottom:2px solid #555 !important}tr.dt-rowReorder-moving td.dtfc-fixed-left:first-child{border-left:2px solid #555 !important}tr.dt-rowReorder-moving td.dtfc-fixed-right:last-child{border-right:2px solid #555 !important} + + +table.fixedHeader-floating{background-color:white}table.fixedHeader-floating.no-footer{border-bottom-width:0}table.fixedHeader-locked{position:absolute !important;background-color:white}@media print{table.fixedHeader-floating{display:none}} + + +table.dataTable tbody th.focus,table.dataTable tbody td.focus{box-shadow:inset 0 0 1px 2px #36f}div.dtk-focus-alt table.dataTable tbody th.focus,div.dtk-focus-alt table.dataTable tbody td.focus{box-shadow:inset 0 0 1px 2px #ff8b33} + + +table.dataTable.dtr-inline.collapsed>tbody>tr>td.child,table.dataTable.dtr-inline.collapsed>tbody>tr>th.child,table.dataTable.dtr-inline.collapsed>tbody>tr>td.dataTables_empty{cursor:default !important}table.dataTable.dtr-inline.collapsed>tbody>tr>td.child:before,table.dataTable.dtr-inline.collapsed>tbody>tr>th.child:before,table.dataTable.dtr-inline.collapsed>tbody>tr>td.dataTables_empty:before{display:none !important}table.dataTable.dtr-inline.collapsed>tbody>tr>td.dtr-control,table.dataTable.dtr-inline.collapsed>tbody>tr>th.dtr-control{position:relative;padding-left:30px;cursor:pointer}table.dataTable.dtr-inline.collapsed>tbody>tr>td.dtr-control:before,table.dataTable.dtr-inline.collapsed>tbody>tr>th.dtr-control:before{top:50%;left:5px;height:1em;width:1em;margin-top:-9px;display:block;position:absolute;color:white;border:.15em solid white;border-radius:1em;box-shadow:0 0 .2em #444;box-sizing:content-box;text-align:center;text-indent:0 !important;font-family:"Courier New",Courier,monospace;line-height:1em;content:"+";background-color:#31b131}table.dataTable.dtr-inline.collapsed>tbody>tr.parent>td.dtr-control:before,table.dataTable.dtr-inline.collapsed>tbody>tr.parent>th.dtr-control:before{content:"-";background-color:#d33333}table.dataTable.dtr-inline.collapsed.compact>tbody>tr>td.dtr-control,table.dataTable.dtr-inline.collapsed.compact>tbody>tr>th.dtr-control{padding-left:27px}table.dataTable.dtr-inline.collapsed.compact>tbody>tr>td.dtr-control:before,table.dataTable.dtr-inline.collapsed.compact>tbody>tr>th.dtr-control:before{left:4px;height:14px;width:14px;border-radius:14px;line-height:14px;text-indent:3px}table.dataTable.dtr-column>tbody>tr>td.dtr-control,table.dataTable.dtr-column>tbody>tr>th.dtr-control,table.dataTable.dtr-column>tbody>tr>td.control,table.dataTable.dtr-column>tbody>tr>th.control{position:relative;cursor:pointer}table.dataTable.dtr-column>tbody>tr>td.dtr-control:before,table.dataTable.dtr-column>tbody>tr>th.dtr-control:before,table.dataTable.dtr-column>tbody>tr>td.control:before,table.dataTable.dtr-column>tbody>tr>th.control:before{top:50%;left:50%;height:.8em;width:.8em;margin-top:-0.5em;margin-left:-0.5em;display:block;position:absolute;color:white;border:.15em solid white;border-radius:1em;box-shadow:0 0 .2em #444;box-sizing:content-box;text-align:center;text-indent:0 !important;font-family:"Courier New",Courier,monospace;line-height:1em;content:"+";background-color:#31b131}table.dataTable.dtr-column>tbody>tr.parent td.dtr-control:before,table.dataTable.dtr-column>tbody>tr.parent th.dtr-control:before,table.dataTable.dtr-column>tbody>tr.parent td.control:before,table.dataTable.dtr-column>tbody>tr.parent th.control:before{content:"-";background-color:#d33333}table.dataTable>tbody>tr.child{padding:.5em 1em}table.dataTable>tbody>tr.child:hover{background:transparent !important}table.dataTable>tbody>tr.child ul.dtr-details{display:inline-block;list-style-type:none;margin:0;padding:0}table.dataTable>tbody>tr.child ul.dtr-details>li{border-bottom:1px solid #efefef;padding:.5em 0}table.dataTable>tbody>tr.child ul.dtr-details>li:first-child{padding-top:0}table.dataTable>tbody>tr.child ul.dtr-details>li:last-child{border-bottom:none}table.dataTable>tbody>tr.child span.dtr-title{display:inline-block;min-width:75px;font-weight:bold}div.dtr-modal{position:fixed;box-sizing:border-box;top:0;left:0;height:100%;width:100%;z-index:100;padding:10em 1em}div.dtr-modal div.dtr-modal-display{position:absolute;top:0;left:0;bottom:0;right:0;width:50%;height:50%;overflow:auto;margin:auto;z-index:102;overflow:auto;background-color:#f5f5f7;border:1px solid black;border-radius:.5em;box-shadow:0 12px 30px rgba(0, 0, 0, 0.6)}div.dtr-modal div.dtr-modal-content{position:relative;padding:1em}div.dtr-modal div.dtr-modal-close{position:absolute;top:6px;right:6px;width:22px;height:22px;border:1px solid #eaeaea;background-color:#f9f9f9;text-align:center;border-radius:3px;cursor:pointer;z-index:12}div.dtr-modal div.dtr-modal-close:hover{background-color:#eaeaea}div.dtr-modal div.dtr-modal-background{position:fixed;top:0;left:0;right:0;bottom:0;z-index:101;background:rgba(0, 0, 0, 0.6)}@media screen and (max-width: 767px){div.dtr-modal div.dtr-modal-display{width:95%}} + + +table.dataTable tr.dtrg-group td{background-color:#e0e0e0}table.dataTable tr.dtrg-group.dtrg-level-0 td{font-weight:bold}table.dataTable tr.dtrg-group.dtrg-level-1 td,table.dataTable tr.dtrg-group.dtrg-level-2 td,table.dataTable tr.dtrg-group.dtrg-level-3 td,table.dataTable tr.dtrg-group.dtrg-level-4 td,table.dataTable tr.dtrg-group.dtrg-level-5 td{background-color:#f0f0f0;padding-top:.25em;padding-bottom:.25em;padding-left:2em;font-size:.9em}table.dataTable tr.dtrg-group.dtrg-level-2 td{background-color:#f3f3f3;padding-left:2.5em}table.dataTable tr.dtrg-group.dtrg-level-3 td{background-color:#f3f3f3;padding-left:3em}table.dataTable tr.dtrg-group.dtrg-level-4 td{background-color:#f3f3f3;padding-left:3.5em}table.dataTable tr.dtrg-group.dtrg-level-5 td{background-color:#f3f3f3;padding-left:4em} + + +table.dt-rowReorder-float{position:absolute !important;opacity:.8;table-layout:fixed;outline:2px solid #888;outline-offset:-2px;z-index:2001}tr.dt-rowReorder-moving{outline:2px solid #555;outline-offset:-2px}body.dt-rowReorder-noOverflow{overflow-x:hidden}table.dataTable td.reorder{text-align:center;cursor:move} + + +div.dts{display:block !important}div.dts tbody th,div.dts tbody td{white-space:nowrap}div.dts div.dts_loading{z-index:1}div.dts div.dts_label{position:absolute;right:10px;background:rgba(0, 0, 0, 0.8);color:white;box-shadow:3px 3px 10px rgba(0, 0, 0, 0.5);text-align:right;border-radius:3px;padding:.4em;z-index:2;display:none}div.dts div.dataTables_scrollBody{background:repeating-linear-gradient(45deg, #edeeff, #edeeff 10px, white 10px, white 20px)}div.dts div.dataTables_scrollBody table{z-index:2}div.dts div.dataTables_paginate,div.dts div.dataTables_length{display:none} + + +div.dt-button-collection{overflow:visible !important;z-index:2002 !important}div.dt-button-collection div.dtsb-searchBuilder{width:99% !important;padding-left:10px !important;padding-right:10px !important}div.dt-button-collection.dtb-collection-closeable div.dtsb-titleRow{padding-right:40px}.dtsb-greyscale{border:1px solid #cecece !important}div.dtsb-logicContainer .dtsb-greyscale{border:none !important}div.dtsb-searchBuilder{justify-content:space-evenly;cursor:default;margin-bottom:1em;text-align:left}div.dtsb-searchBuilder button.dtsb-button,div.dtsb-searchBuilder select{font-size:1em}div.dtsb-searchBuilder div.dtsb-titleRow{justify-content:space-evenly;margin-bottom:.5em}div.dtsb-searchBuilder div.dtsb-titleRow div.dtsb-title{display:inline-block;padding-top:6px}div.dtsb-searchBuilder div.dtsb-titleRow div.dtsb-title:empty{display:inline}div.dtsb-searchBuilder div.dtsb-titleRow button.dtsb-clearAll{float:right;margin-bottom:.333em}div.dtsb-searchBuilder div.dtsb-vertical .dtsb-value,div.dtsb-searchBuilder div.dtsb-vertical .dtsb-data,div.dtsb-searchBuilder div.dtsb-vertical .dtsb-condition{display:block}div.dtsb-searchBuilder div.dtsb-group{position:relative;clear:both;margin-bottom:.8em}div.dtsb-searchBuilder div.dtsb-group button.dtsb-clearGroup{margin:2px;text-align:center;padding:0}div.dtsb-searchBuilder div.dtsb-group div.dtsb-logicContainer{-webkit-transform:rotate(90deg);-moz-transform:rotate(90deg);-o-transform:rotate(90deg);-ms-transform:rotate(90deg);transform:rotate(90deg);position:absolute;margin-top:.8em;margin-right:.8em}div.dtsb-searchBuilder div.dtsb-group div.dtsb-criteria{margin-bottom:.8em}div.dtsb-searchBuilder div.dtsb-group div.dtsb-criteria select.dtsb-dropDown,div.dtsb-searchBuilder div.dtsb-group div.dtsb-criteria input.dtsb-input{padding:.4em;margin-right:.8em;max-width:20em;background-color:rgba(200, 200, 200, 0.3)}div.dtsb-searchBuilder div.dtsb-group div.dtsb-criteria select.dtsb-dropDown option.dtsb-notItalic,div.dtsb-searchBuilder div.dtsb-group div.dtsb-criteria input.dtsb-input option.dtsb-notItalic{font-style:normal}div.dtsb-searchBuilder div.dtsb-group div.dtsb-criteria select.dtsb-italic{font-style:italic}div.dtsb-searchBuilder div.dtsb-group div.dtsb-criteria div.dtsb-buttonContainer{float:right;display:inline-block}div.dtsb-searchBuilder div.dtsb-group div.dtsb-criteria div.dtsb-buttonContainer button.dtsb-delete,div.dtsb-searchBuilder div.dtsb-group div.dtsb-criteria div.dtsb-buttonContainer button.dtsb-right,div.dtsb-searchBuilder div.dtsb-group div.dtsb-criteria div.dtsb-buttonContainer button.dtsb-left{margin-right:.8em}div.dtsb-searchBuilder div.dtsb-group div.dtsb-criteria div.dtsb-buttonContainer button.dtsb-delete:last-child,div.dtsb-searchBuilder div.dtsb-group div.dtsb-criteria div.dtsb-buttonContainer button.dtsb-right:last-child,div.dtsb-searchBuilder div.dtsb-group div.dtsb-criteria div.dtsb-buttonContainer button.dtsb-left:last-child{margin-right:0}div.dtsb-searchBuilder div.dtsb-group div.dtsb-criteria span.dtsp-joiner{margin-right:.8em}div.dtsb-searchBuilder button,div.dtsb-searchBuilder select,div.dtsb-searchBuilder input{background-color:#f9f9f9}div.dtsb-searchBuilder button.dtsb-button{position:relative;display:inline-block;box-sizing:border-box;padding:.5em 1em;border:1px solid rgba(0, 0, 0, 0.3);border-radius:2px;cursor:pointer;font-size:.88em;line-height:1.6em;color:black;white-space:nowrap;overflow:hidden;background-color:rgba(0, 0, 0, 0.1);background:linear-gradient(to bottom, rgba(230, 230, 230, 0.1) 0%, rgba(0, 0, 0, 0.1) 100%);-webkit-user-select:none;-moz-user-select:none;-ms-user-select:none;user-select:none;text-decoration:none;outline:none;text-overflow:ellipsis}div.dtsb-searchBuilder button.dtsb-button:hover{background-color:#cecece !important;cursor:pointer}div.dtsb-searchBuilder div.dtsb-logicContainer{border:1px solid rgba(0, 0, 0, 0.3);background-color:rgba(0, 0, 0, 0.1);background:linear-gradient(to right, rgba(230, 230, 230, 0.1) 0%, rgba(0, 0, 0, 0.1) 100%)}div.dtsb-searchBuilder div.dtsb-logicContainer button{border:1px solid transparent;background:transparent}div.dtsb-searchBuilder button.dtsb-clearGroup{min-width:2em;padding:0}div.dtsb-searchBuilder button.dtsb-iptbtn{min-width:100px;text-align:left}div.dtsb-searchBuilder div.dtsb-group div.dtsb-logicContainer{border:1px solid;border-color:#cecece;border-radius:3px;display:flex;flex-direction:row;flex-wrap:wrap;justify-content:flex-start;align-content:flex-start;align-items:flex-start}div.dtsb-searchBuilder div.dtsb-group div.dtsb-logicContainer button.dtsb-logic{border:none;border-radius:0px;flex-grow:1;flex-shrink:0;flex-basis:3em;margin:0px}div.dtsb-searchBuilder div.dtsb-group div.dtsb-logicContainer button.dtsb-clearGroup{border:none;border-radius:0px;width:2em;margin:0px}div.dtsb-searchBuilder div.dtsb-group div.dtsb-criteria select.dtsb-dropDown,div.dtsb-searchBuilder div.dtsb-group div.dtsb-criteria input.dtsb-input{border:1px solid;border-radius:3px}div.dtsb-searchBuilder div.dtsb-group div.dtsb-criteria select.dtsb-condition{border-color:#48b13c}div.dtsb-searchBuilder div.dtsb-group div.dtsb-criteria select.dtsb-data{border-color:#e70f00}div.dtsb-searchBuilder div.dtsb-group div.dtsb-criteria select.dtsb-value,div.dtsb-searchBuilder div.dtsb-group div.dtsb-criteria input.dtsb-value{border-color:#0069ba}div.dtsb-searchBuilder div.dtsb-group div.dtsb-criteria select.dtsb-condition option.dtsb-option,div.dtsb-searchBuilder div.dtsb-group div.dtsb-criteria select.dtsb-data option.dtsb-option,div.dtsb-searchBuilder div.dtsb-group div.dtsb-criteria select.dtsb-value option.dtsb-option{background-color:white} + + +div.dtsp-topRow{display:flex;flex-direction:row;flex-wrap:nowrap;border:2px solid rgba(0, 0, 0, 0);border-radius:3px;justify-content:space-around;align-content:flex-start;align-items:flex-start;min-height:37px}div.dtsp-topRow input.dtsp-search{text-overflow:ellipsis;min-width:50px;flex-basis:90px;max-width:none}div.dtsp-topRow input.dtsp-search::placeholder{color:black}div.dtsp-topRow div.dtsp-subRow1{display:flex;flex-direction:row;flex-wrap:nowrap;flex:1 1 auto}div.dtsp-topRow div.dtsp-subRow1 div.dtsp-searchCont{position:relative;width:100%}div.dtsp-topRow div.dtsp-subRow1 div.dtsp-searchCont input.dtsp-disabledButton{padding-top:10px;padding-bottom:10px;background-color:transparent}div.dtsp-topRow div.dtsp-subRow1 input{padding-right:2em;width:100% !important;box-sizing:border-box;font-size:1em}div.dtsp-topRow div.dtsp-subRow1 button.dtsp-searchIcon{position:absolute;top:0;right:0;bottom:0;background-image:url("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAA8AAAAPCAYAAAA71pVKAAABbmlDQ1BpY2MAACiRdZE7SwNBFIU/EyWikRRaiFhsoWKhEBREO42FTZAQFYza7G5eQhKX3QQJtoKNhWAh2vgq/AfaCrYKgqAIIhb+Al+NhPVOEkiQZJbZ+3FmzmXmDHjCGTPrtAYhm8vb0bmQthxb0Xzv+PHRxRSabjrWTCQSpun4eaRF1YdR1av5voajM55wTGhpF54wLTsvPC0c3sxbineFe8y0Hhc+ER6x5YDCt0o3KvymOFXhL8X2YnQWPKqnlqpjo47NtJ0VHhYeyGYKZvU86ib+RG5pQWqfzH4coswRQsOgwDoZ8oxKzUlmjX3Bsm+eDfGY8rcoYosjRVq8I6IWpGtCalL0hHwZiir3/3k6yfGxSnd/CNpeXfdzEHz7UNpz3d9T1y2dgfcFrnM1/4bkNPkt+l5NGziGwDZc3tQ04wCudqD32dJtvSx5ZXqSSfi4gK4YdN9Dx2olq+o650+wuCVPdAeHRzAk+wNrfw8JaBFXEnV+AAAACXBIWXMAAA9hAAAPYQGoP6dpAAABMUlEQVQoU6XRr0vDQRjH8akoM4iIjqGoOIZ5oIjB5XWxajaYDGLSIhhNYjcPRDSJwbQNw+L+BNGgYYo/5pT5/shz8vDlBgMPXux7z3N3z+25VOofYyCyd4ZYCavI4gXPsRp9LqiDdrEMH+8wv8Vh8gBfWclFPOEUN3hAHjlMoRa7wTzBS5xgKLFglPkZLjDic6HyDsEMNvGR2Nxifoci3tEI+X770JU0XmPXIlax+LTPh83fFox1X6kxyzdjm9UcdXi9S+Vti6svfyNULhNR9TVsYNhW6Ff9KKCNR7/Zv6eeaQ+6+qcdpu9BqGlp1HFgud+FYdzzUcUExu0Q/cdzHGEFetIlXKPjK/sbqYoOftMiS+j9jzEJPd1Wt+5+kdR/9EM9ucIC5jCbyPc01Q32kfsBppYz3hYFcCwAAAAASUVORK5CYII=") !important;background-repeat:no-repeat;background-position:center;background-size:12px}div.dtsp-topRow div.dtsp-subRow2{white-space:nowrap;flex:0 0 auto}div.dtsp-topRow button.dtsp-nameButton{background-image:url("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACMAAAAjCAYAAAAe2bNZAAABcGlDQ1BpY2MAACiRdZHNSwJBGMYftTDS8FCHkA57sOigIAXRMQzyYh3UIKvL7rirwe66zK6IdA26dBA6RF36OvQf1DXoWhAERRAR9B/0dQnZ3nEFJXSG2ffHs/O8zDwD+DM6M+yBJGCYDs+mU9JaYV0KviNMM4QoEjKzreXcUh59x88jfKI+JESv/vt6jlBRtRngGyKeYxZ3iBeIMzXHErxHPMbKcpH4hDjO6YDEt0JXPH4TXPL4SzDPZxcBv+gplbpY6WJW5gbxNHHM0KusfR5xk7BqruaoRmlNwEYWaaQgQUEVW9DhIEHVpMx6+5It3woq5GH0tVAHJ0cJZfLGSa1SV5WqRrpKU0dd5P4/T1ubnfG6h1PA4Kvrfk4CwX2g2XDd31PXbZ4BgRfg2uz4K5TT/DfpjY4WOwYiO8DlTUdTDoCrXWD82ZK53JICtPyaBnxcACMFYPQeGN7wsmr/x/kTkN+mJ7oDDo+AKdof2fwDCBRoDkL8UccAAAAJcEhZcwAAD2EAAA9hAag/p2kAAAK2SURBVFgJ7ZY9j41BFICvryCExrJBQ6HyEYVEIREaUZDQIRoR2ViJKCioxV+gkVXYTVZEQiEUhG2EQnxUCh0FKolY4ut5XnM2cyfva3Pt5m7EPcmzZ2bemTNnzjkzd1utnvQi0IvAfxiBy5z5FoxO89kPY+8mbMjtzs47RXs5/WVpbAG6bWExt5PuIibvhVkwmC+ck3eK9ln6/fAddFojYzBVuYSBpcnIEvRaqOw2RcaN18FPuJH0JvRUxbT3wWf4ltiKPgfVidWlbGZgPozDFfgAC+EA/K2EI4cwcAJ+gPaeQ+VQU2SOMMGcPgPl/m/V2p50rrbRsRgt9Iv5h6xtpP22Bz7Ce1C+gFFxfKzOmShcU+Qmyh2w3w8rIJfddHTck66EukL/xPhj+JM8rHNmFys0Pg4v0up3aFNlwR9NYyodd3OL/C64zpsymcTFcf6ElM4YzjAWKYrJkaq8kE/yUYNP4BoYvS1QRo+hNtF5xfkTUjoTheukSFFMjlTFm6PjceOca/SMpKfeCR1L6Uzk/y2WIkVhNFJlJAZhP+hYns7b9D3IPuhY5mYrIv8OrQJvR5NYyNaW4jsU8pSGNySiVx4o5tXq3JkoXE/mg5R/M8dGJCJpKhaDcjBRdbI/Rm8g69c122om33BHmj2CHoV5qa9jUXBraJ+G1fAVjIBO1klc87ro1K4JZ/K35SWW3TwcyDd6TecqnAEd8cGq2+w84xvBm1n3vS0izKkkwh5XNC/GmFPqqAtPF89AOScKuemaNzoTV1SD5dtSbmLf1/RV+tC0WTgcj6R7HEtrVGWaqu/lYDZ/2pvxQ/kIyw/gFByHC9AHw910hv1aUUumyd8yy0QfhmEkfiNod0Xusct68J1qc8Tdux0Z97Q+hsDb+AYGYEbF/4Guw2Q/qDPqZG/zXgT+3Qj8AtKnfWhFwmuAAAAAAElFTkSuQmCC") !important;background-repeat:no-repeat;background-position:center;background-size:23px;vertical-align:bottom}div.dtsp-topRow button.dtsp-countButton{background-image:url("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABgAAAAYCAYAAADgdz34AAABcGlDQ1BpY2MAACiRdZHNSwJBGMYftTDS8FCHkA57sOigIAXRMQzyYh3UIKvL7rirwe66zK6IdA26dBA6RF36OvQf1DXoWhAERRAR9B/0dQnZ3nEFJXSG2ffHs/O8zDwD+DM6M+yBJGCYDs+mU9JaYV0KviNMM4QoEjKzreXcUh59x88jfKI+JESv/vt6jlBRtRngGyKeYxZ3iBeIMzXHErxHPMbKcpH4hDjO6YDEt0JXPH4TXPL4SzDPZxcBv+gplbpY6WJW5gbxNHHM0KusfR5xk7BqruaoRmlNwEYWaaQgQUEVW9DhIEHVpMx6+5It3woq5GH0tVAHJ0cJZfLGSa1SV5WqRrpKU0dd5P4/T1ubnfG6h1PA4Kvrfk4CwX2g2XDd31PXbZ4BgRfg2uz4K5TT/DfpjY4WOwYiO8DlTUdTDoCrXWD82ZK53JICtPyaBnxcACMFYPQeGN7wsmr/x/kTkN+mJ7oDDo+AKdof2fwDCBRoDkL8UccAAAAJcEhZcwAAD2EAAA9hAag/p2kAAAG5SURBVEgN3VU9LwVBFF0fiYhofUSlEQkKhU7z/oBCQkIiGr9BgUbhVzy9BAnhFyjV/AYFiU5ICM7ZN+c5Zud5dm3lJmfmzrkz9+7cu3c3y/6jjOBSF8CxXS7FmTkbwqIJjDpJvTcmsJ4K3KPZUpyZsx0sxoB9J6mnAkyC7wGuuCFIipNtEcpcWExgXpOBc78vgj6N+QO4NVsjwdFM59tUIDxDrHMBOeIQ34C5ZDregXuAQm4YcI68nN9B3wr2PcwPAIPkN2EqtJH6b+QZm1ajjTx7BqwAr26Lb+C2Kvpbt0Mb2HAJ7NrGFGfmXO3DeA4UshDfQAVmH0gaUFg852TTTDvlxwBlCtxy9zXyBhQFaq0wMmIdRebrfgosA3zb2hKnqG0oqchp4QbuR8X0TjzABhbdOT8jnQ/atcgqpnfwOA7yqZyTU587ZkIGdesLTt2EkynOnbreMUUKMI/dA4B/QVOcO13CQh+5wWCgDwo/75u59odB/wjmfhbgvACcAOyZPHihMWAoIwxyCLgf1oxfgjzVbgBXSTzIN+f0pg6s5DkcesLMRpsBrgE2XO3CN64JFP7JtUeKHX4CKtRRXFZ+7dEAAAAASUVORK5CYII=") !important;background-repeat:no-repeat;background-position:center;background-size:18px;vertical-align:bottom}div.dtsp-topRow button.dtsp-collapseButton span.dtsp-caret{position:relative;top:2px;display:inline-block}div.dtsp-topRow button.dtsp-collapseButton.dtsp-rotated{transform:rotate(180deg)}div.dtsp-topRow.dtsp-bordered{border:2px solid #f0f0f0;border-radius:3px}div.dtsp-topRow.dtsp-bordered:hover{background-color:#f0f0f0;opacity:.6;border:2px solid #cfcfcf;border-radius:3px;cursor:pointer !important}div.dtsp-panesContainer div.dtsp-searchPanes div.dtsp-searchPane table thead th,div.dtsp-panesContainer div.dtsp-searchPanes div.dtsp-searchPane table thead td{width:100% !important}div.dt-button-collection{z-index:2002}div.dt-button-collection.dtb-collection-closeable div.dtsp-titleRow{padding-right:25px}div.dtsp-columns-1{max-width:100%;margin:0px !important}div.dtsp-columns-2{max-width:49%;margin:0px !important}div.dtsp-columns-3{max-width:32%;margin:0px !important}div.dtsp-columns-4{max-width:24%;margin:0px !important}div.dtsp-columns-5{max-width:19%;margin:0px !important}div.dtsp-columns-6{max-width:16%;margin:0px !important}div.dtsp-columns-7{max-width:14%;margin:0px !important}div.dtsp-columns-8{min-width:12%;margin:0px !important}div.dtsp-columns-9{max-width:10.5%;margin:0px !important}div.dt-button-collection{float:none}div.dtsp-panesContainer{margin-bottom:1em}div.dtsp-panesContainer div.dataTables_wrapper{width:100%}div.dtsp-panesContainer div.dataTables_wrapper div.dataTables_layout_cell{padding:0}div.dtsp-panesContainer div.dataTables_wrapper div.dataTables_scrollHead{display:none !important}div.dtsp-panesContainer div.dataTables_wrapper div.dataTables_scrollBody{background:white !important;border-bottom:none}div.dtsp-panesContainer div.dataTables_wrapper div.dataTables_scrollBody thead{display:none}div.dtsp-panesContainer div.dataTables_wrapper div.dataTables_scrollBody table{table-layout:fixed}div.dtsp-panesContainer div.dataTables_wrapper div.dataTables_scrollBody table tr>th,div.dtsp-panesContainer div.dataTables_wrapper div.dataTables_scrollBody table tr>td{padding:5px 10px}div.dtsp-panesContainer div.dataTables_wrapper div.dataTables_scrollBody td.dtsp-nameColumn{width:100% !important}div.dtsp-panesContainer div.dataTables_wrapper div.dataTables_scrollBody div.dtsp-nameCont{width:100%;display:flex;flex-direction:row;justify-content:flex-start;align-content:flex-start;align-items:flex-start}div.dtsp-panesContainer div.dataTables_wrapper div.dataTables_scrollBody div.dtsp-nameCont span.dtsp-name,div.dtsp-panesContainer div.dataTables_wrapper div.dataTables_scrollBody div.dtsp-nameCont span.dtsp-pill{cursor:default}div.dtsp-panesContainer div.dataTables_wrapper div.dataTables_scrollBody div.dtsp-nameCont span.dtsp-name{text-overflow:ellipsis;overflow:hidden;display:inline-block;vertical-align:middle;white-space:nowrap;flex-grow:1;text-align:left}div.dtsp-panesContainer div.dataTables_wrapper div.dataTables_scrollBody div.dtsp-nameCont span.dtsp-pill{display:inline-block;background-color:#cfcfcf;text-align:center;border:1px solid #cfcfcf;border-radius:10px;width:auto;min-width:30px;color:black;font-size:.9em;padding:0 4px}div.dtsp-panesContainer div.dataTables_wrapper div.dataTables_scrollBody div.dtsp-nameCont span.dtsp-pill:empty{display:none}div.dtsp-panesContainer{clear:both;padding-left:0;padding-right:0;text-align:center}div.dtsp-panesContainer div.dtsp-searchPanes{display:flex;flex-direction:row;flex-wrap:wrap;justify-content:space-between;align-content:flex-start;align-items:stretch;clear:both;text-align:left}div.dtsp-panesContainer div.dtsp-searchPanes div.dtsp-searchPane{flex-grow:1;flex-shrink:0;font-size:.9em;margin-top:15px !important}div.dtsp-panesContainer div.dtsp-searchPanes div.dtsp-searchPane div.dataTables_wrapper{flex:1;box-sizing:border-box}div.dtsp-panesContainer div.dtsp-searchPanes div.dtsp-searchPane div.dataTables_wrapper div.dataTables_filter{display:none}div.dtsp-panesContainer div.dtsp-title{float:left;padding:10px 0}div.dtsp-panesContainer button.dtsp-clearAll,div.dtsp-panesContainer button.dtsp-collapseAll,div.dtsp-panesContainer button.dtsp-showAll{float:right;padding:10px}div.dtsp-hidden{display:none !important}div.dtsp-panesContainer div.dtsp-searchPanes div.dtsp-searchPane div.dataTables_wrapper{border:2px solid #f0f0f0;border-radius:4px}div.dtsp-panesContainer div.dtsp-searchPanes div.dtsp-searchPane div.dataTables_wrapper:hover{border:2px solid #cfcfcf}div.dtsp-panesContainer div.dtsp-searchPanes div.dtsp-searchPane div.dtsp-selected{border:2px solid #3276b1;border-radius:4px}div.dtsp-panesContainer div.dtsp-searchPanes div.dtsp-searchPane div.dtsp-selected:hover{border:2px solid #286092}div.dtsp-panesContainer div.dtsp-searchPanes div.dtsp-searchPane div.dtsp-topRow div.dtsp-searchCont input.dtsp-search{border:none;padding-left:3px}div.dtsp-panesContainer div.dtsp-searchPanes div.dtsp-searchPane input.dtsp-paneInputButton,div.dtsp-panesContainer div.dtsp-searchPanes div.dtsp-searchPane button.dtsp-paneButton{height:35px;width:35px;min-width:0;display:inline-block;margin:2px;border:0px solid transparent;background-color:transparent;margin-bottom:0px}div.dtsp-panesContainer div.dtsp-searchPanes div.dtsp-searchPane input.dtsp-paneInputButton:hover,div.dtsp-panesContainer div.dtsp-searchPanes div.dtsp-searchPane button.dtsp-paneButton:hover{background-color:#f0f0f0;border-radius:2px;cursor:pointer}div.dtsp-panesContainer div.dtsp-searchPanes div.dtsp-searchPane button.dtsp-paneButton{opacity:.6}div.dtsp-panesContainer button.dtsp-clearAll,div.dtsp-panesContainer button.dtsp-collapseAll,div.dtsp-panesContainer button.dtsp-showAll{border:1px solid transparent;background-color:transparent}div.dtsp-panesContainer button.dtsp-clearAll:hover,div.dtsp-panesContainer button.dtsp-collapseAll:hover,div.dtsp-panesContainer button.dtsp-showAll:hover{background-color:#f0f0f0;border-radius:2px;cursor:pointer}div.dtsp-panesContainer button.dtsp-disabledButton{cursor:default !important;color:#7c7c7c}div.dtsp-panesContainer button.dtsp-disabledButton:hover{background-color:transparent}div.dtsp-panesContainer button.dtsp-disabledButton:focus{outline:none}div.dtsp-topRow.dtsp-bordered:hover button.dtsp-disabledButton{cursor:pointer !important;pointer-events:none}div.dtsp-topRow.dtsp-bordered:hover input.dtsp-paneInputButton{pointer-events:none}div.dtsp-narrow{flex-direction:column !important}div.dtsp-narrow div.dtsp-subRows{width:100%;text-align:right}@media screen and (max-width: 767px){div.dtsp-columns-4,div.dtsp-columns-5,div.dtsp-columns-6{max-width:31% !important;min-width:31% !important}}@media screen and (max-width: 640px){div.dtsp-searchPanes{flex-direction:column !important}div.dtsp-searchPane{max-width:98% !important;min-width:98% !important}} + + +table.dataTable tbody>tr.selected,table.dataTable tbody>tr>.selected{background-color:#b0bed9}table.dataTable.stripe tbody>tr.odd.selected,table.dataTable.stripe tbody>tr.odd>.selected,table.dataTable.display tbody>tr.odd.selected,table.dataTable.display tbody>tr.odd>.selected{background-color:#acbad4}table.dataTable.hover tbody>tr.selected:hover,table.dataTable.hover tbody>tr>.selected:hover,table.dataTable.display tbody>tr.selected:hover,table.dataTable.display tbody>tr>.selected:hover{background-color:#aab7d1}table.dataTable.order-column tbody>tr.selected>.sorting_1,table.dataTable.order-column tbody>tr.selected>.sorting_2,table.dataTable.order-column tbody>tr.selected>.sorting_3,table.dataTable.order-column tbody>tr>.selected,table.dataTable.display tbody>tr.selected>.sorting_1,table.dataTable.display tbody>tr.selected>.sorting_2,table.dataTable.display tbody>tr.selected>.sorting_3,table.dataTable.display tbody>tr>.selected{background-color:#acbad5}table.dataTable.display tbody>tr.odd.selected>.sorting_1,table.dataTable.order-column.stripe tbody>tr.odd.selected>.sorting_1{background-color:#a6b4cd}table.dataTable.display tbody>tr.odd.selected>.sorting_2,table.dataTable.order-column.stripe tbody>tr.odd.selected>.sorting_2{background-color:#a8b5cf}table.dataTable.display tbody>tr.odd.selected>.sorting_3,table.dataTable.order-column.stripe tbody>tr.odd.selected>.sorting_3{background-color:#a9b7d1}table.dataTable.display tbody>tr.even.selected>.sorting_1,table.dataTable.order-column.stripe tbody>tr.even.selected>.sorting_1{background-color:#acbad5}table.dataTable.display tbody>tr.even.selected>.sorting_2,table.dataTable.order-column.stripe tbody>tr.even.selected>.sorting_2{background-color:#aebcd6}table.dataTable.display tbody>tr.even.selected>.sorting_3,table.dataTable.order-column.stripe tbody>tr.even.selected>.sorting_3{background-color:#afbdd8}table.dataTable.display tbody>tr.odd>.selected,table.dataTable.order-column.stripe tbody>tr.odd>.selected{background-color:#a6b4cd}table.dataTable.display tbody>tr.even>.selected,table.dataTable.order-column.stripe tbody>tr.even>.selected{background-color:#acbad5}table.dataTable.display tbody>tr.selected:hover>.sorting_1,table.dataTable.order-column.hover tbody>tr.selected:hover>.sorting_1{background-color:#a2aec7}table.dataTable.display tbody>tr.selected:hover>.sorting_2,table.dataTable.order-column.hover tbody>tr.selected:hover>.sorting_2{background-color:#a3b0c9}table.dataTable.display tbody>tr.selected:hover>.sorting_3,table.dataTable.order-column.hover tbody>tr.selected:hover>.sorting_3{background-color:#a5b2cb}table.dataTable.display tbody>tr:hover>.selected,table.dataTable.display tbody>tr>.selected:hover,table.dataTable.order-column.hover tbody>tr:hover>.selected,table.dataTable.order-column.hover tbody>tr>.selected:hover{background-color:#a2aec7}table.dataTable tbody td.select-checkbox,table.dataTable tbody th.select-checkbox{position:relative}table.dataTable tbody td.select-checkbox:before,table.dataTable tbody td.select-checkbox:after,table.dataTable tbody th.select-checkbox:before,table.dataTable tbody th.select-checkbox:after{display:block;position:absolute;top:1.2em;left:50%;width:12px;height:12px;box-sizing:border-box}table.dataTable tbody td.select-checkbox:before,table.dataTable tbody th.select-checkbox:before{content:" ";margin-top:-6px;margin-left:-6px;border:1px solid black;border-radius:3px}table.dataTable tr.selected td.select-checkbox:after,table.dataTable tr.selected th.select-checkbox:after{content:"✓";font-size:20px;margin-top:-19px;margin-left:-6px;text-align:center;text-shadow:1px 1px #b0bed9,-1px -1px #b0bed9,1px -1px #b0bed9,-1px 1px #b0bed9}table.dataTable.compact tbody td.select-checkbox:before,table.dataTable.compact tbody th.select-checkbox:before{margin-top:-12px}table.dataTable.compact tr.selected td.select-checkbox:after,table.dataTable.compact tr.selected th.select-checkbox:after{margin-top:-16px}div.dataTables_wrapper span.select-info,div.dataTables_wrapper span.select-item{margin-left:.5em}@media screen and (max-width: 640px){div.dataTables_wrapper span.select-info,div.dataTables_wrapper span.select-item{margin-left:0;display:block}} + + +div.dtsr-confirmation,div.dtsr-creation{position:fixed;top:20%;left:50%;width:500px;background-color:white;margin-left:-250px;border-radius:6px;box-shadow:0 0 5px #555;border:2px solid #444;z-index:2003;box-sizing:border-box;padding:1em}div.dtsr-confirmation div.dtsr-confirmation-title-row,div.dtsr-creation div.dtsr-confirmation-title-row{text-align:left}div.dtsr-confirmation div.dtsr-confirmation-title-row h2,div.dtsr-creation div.dtsr-confirmation-title-row h2{border-bottom:0px;margin-top:0px;padding-top:0px}div.dtsr-confirmation div.dtsr-confirmation-text,div.dtsr-creation div.dtsr-confirmation-text{text-align:center}div.dtsr-confirmation div.dtsr-confirmation-buttons,div.dtsr-creation div.dtsr-confirmation-buttons{text-align:right;margin-top:1em}div.dtsr-confirmation div.dtsr-confirmation-buttons button.dtsr-confirmation-button,div.dtsr-creation div.dtsr-confirmation-buttons button.dtsr-confirmation-button{margin:0px}div.dtsr-confirmation div.dtsr-creation-text,div.dtsr-creation div.dtsr-creation-text{text-align:left;padding:0px;border:none}div.dtsr-confirmation div.dtsr-creation-text span,div.dtsr-creation div.dtsr-creation-text span{font-size:20px}div.dtsr-confirmation div.dtsr-creation-form div.dtsr-left,div.dtsr-confirmation div.dtsr-creation-form div.dtsr-right,div.dtsr-creation div.dtsr-creation-form div.dtsr-left,div.dtsr-creation div.dtsr-creation-form div.dtsr-right{display:inline-block;width:50%}div.dtsr-confirmation div.dtsr-creation-form div.dtsr-left,div.dtsr-creation div.dtsr-creation-form div.dtsr-left{text-align:right}div.dtsr-confirmation div.dtsr-creation-form div.dtsr-right,div.dtsr-confirmation div.dtsr-creation-form div.dtsr-name-row,div.dtsr-creation div.dtsr-creation-form div.dtsr-right,div.dtsr-creation div.dtsr-creation-form div.dtsr-name-row{text-align:left}div.dtsr-confirmation div.dtsr-creation-form div.dtsr-form-row label.dtsr-name-label,div.dtsr-creation div.dtsr-creation-form div.dtsr-form-row label.dtsr-name-label{width:33.3%;display:inline-block;text-align:right;padding-right:15px;padding-left:15px}div.dtsr-confirmation div.dtsr-creation-form div.dtsr-form-row input.dtsr-name-input,div.dtsr-creation div.dtsr-creation-form div.dtsr-form-row input.dtsr-name-input{width:66.6%;display:inline-block}div.dtsr-confirmation div.dtsr-creation-form div.dtsr-form-row input.dtsr-check-box,div.dtsr-creation div.dtsr-creation-form div.dtsr-form-row input.dtsr-check-box{margin-left:33.3%;margin-right:14px;display:inline-block}div.dtsr-confirmation div.dtsr-creation-form div.dtsr-form-row label.dtsr-toggle-title,div.dtsr-creation div.dtsr-creation-form div.dtsr-form-row label.dtsr-toggle-title{margin-right:-33.3%}div.dtsr-confirmation div.dtsr-confirmation-text,div.dtsr-creation div.dtsr-confirmation-text{text-align:left}div.dtsr-confirmation div.dtsr-confirmation-text label.dtsr-name-label,div.dtsr-creation div.dtsr-confirmation-text label.dtsr-name-label{width:auto;display:inline-block;text-align:right;padding-right:15px}div.dtsr-confirmation div.dtsr-confirmation-text input.dtsr-name-input,div.dtsr-creation div.dtsr-confirmation-text input.dtsr-name-input{width:66.6%;display:inline-block}div.dtsr-confirmation div.dtsr-confirmation-text input.dtsr-check-box,div.dtsr-creation div.dtsr-confirmation-text input.dtsr-check-box{margin-left:33.3%;margin-right:14px;display:inline-block}div.dtsr-confirmation div.dtsr-modal-foot,div.dtsr-creation div.dtsr-modal-foot{text-align:right;padding-top:10px}div.dtsr-confirmation span.dtsr-modal-error,div.dtsr-creation span.dtsr-modal-error{color:red;font-size:.9em}div.dtsr-creation{top:10%}div.dtsr-form-row{padding:10px}div.dtsr-check-row{padding-top:0px}div.dtsr-creation-text{padding:10px}div.dtsr-popover-close{position:absolute;top:10px;right:10px;width:22px;height:22px;border:1px solid #eaeaea;background-color:#f9f9f9;text-align:center;border-radius:3px;cursor:pointer;z-index:12}div.dtsr-background{z-index:2002;position:fixed;top:0;left:0;width:100%;height:100%;background:rgba(0, 0, 0, 0.7);background:radial-gradient(ellipse farthest-corner at center, rgba(0, 0, 0, 0.3) 0%, rgba(0, 0, 0, 0.7) 100%)}div.dt-button-collection h3{text-align:center;margin-top:4px;margin-bottom:8px;font-size:1.5em;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}div.dt-button-collection span.dtsr-emptyStates{border-radius:5px;display:inline-block;line-height:1.6em;white-space:nowrap;text-align:center;vertical-align:middle;width:100%;padding-bottom:7px;padding-top:3px}div.dt-button-collection h3{font-size:1.1em}div.dtsr-creation-form div.dtsr-form-row input.dtsr-name-input{width:57% !important;padding:5px 4px;border:1px solid #aaa;border-radius:3px}div.dtsr-creation-form div.dtsr-form-row input.dtsr-check-box{margin-left:calc(33.3% + 30px) !important}div.dtsr-creation-form div.dtsr-form-row label.dtsr-toggle-title{margin-right:calc(-33.3% - 30px) !important} + + diff --git a/media/datatable/css/index.html b/media/datatable/css/index.html new file mode 100644 index 0000000..fa6d84e --- /dev/null +++ b/media/datatable/css/index.html @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/media/datatable/index.html b/media/datatable/index.html new file mode 100644 index 0000000..fa6d84e --- /dev/null +++ b/media/datatable/index.html @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/media/datatable/js/datatables.min.js b/media/datatable/js/datatables.min.js new file mode 100644 index 0000000..cd9d163 --- /dev/null +++ b/media/datatable/js/datatables.min.js @@ -0,0 +1,1238 @@ +/* + * This combined file was created by the DataTables downloader builder: + * https://datatables.net/download + * + * To rebuild or modify this file with the latest versions of the included + * software please visit: + * https://datatables.net/download/#dt/jszip-2.5.0/dt-1.11.5/b-2.2.2/b-colvis-2.2.2/b-html5-2.2.2/b-print-2.2.2/cr-1.5.5/date-1.1.2/fc-4.0.2/fh-3.2.2/kt-2.6.4/r-2.2.9/rg-1.1.4/rr-1.2.8/sc-2.0.5/sb-1.3.2/sp-2.0.0/sl-1.3.4/sr-1.1.0 + * + * Included libraries: + * JSZip 2.5.0, DataTables 1.11.5, Buttons 2.2.2, Column visibility 2.2.2, HTML5 export 2.2.2, Print view 2.2.2, ColReorder 1.5.5, DateTime 1.1.2, FixedColumns 4.0.2, FixedHeader 3.2.2, KeyTable 2.6.4, Responsive 2.2.9, RowGroup 1.1.4, RowReorder 1.2.8, Scroller 2.0.5, SearchBuilder 1.3.2, SearchPanes 2.0.0, Select 1.3.4, StateRestore 1.1.0 + */ + +/*! + +JSZip - A Javascript class for generating and reading zip files + + +(c) 2009-2014 Stuart Knightley +Dual licenced under the MIT license or GPLv3. See https://raw.github.com/Stuk/jszip/master/LICENSE.markdown. + +JSZip uses the library pako released under the MIT license : +https://github.com/nodeca/pako/blob/master/LICENSE +*/ +!function(a){if("object"==typeof exports&&"undefined"!=typeof module)module.exports=a();else if("function"==typeof define&&define.amd)define([],a);else{var b;"undefined"!=typeof window?b=window:"undefined"!=typeof global?b=global:"undefined"!=typeof self&&(b=self),b.JSZip=a()}}(function(){return function a(b,c,d){function e(g,h){if(!c[g]){if(!b[g]){var i="function"==typeof require&&require;if(!h&&i)return i(g,!0);if(f)return f(g,!0);throw new Error("Cannot find module '"+g+"'")}var j=c[g]={exports:{}};b[g][0].call(j.exports,function(a){var c=b[g][1][a];return e(c?c:a)},j,j.exports,a,b,c,d)}return c[g].exports}for(var f="function"==typeof require&&require,g=0;g>2,g=(3&b)<<4|c>>4,h=(15&c)<<2|e>>6,i=63&e,isNaN(c)?h=i=64:isNaN(e)&&(i=64),j=j+d.charAt(f)+d.charAt(g)+d.charAt(h)+d.charAt(i);return j},c.decode=function(a){var b,c,e,f,g,h,i,j="",k=0;for(a=a.replace(/[^A-Za-z0-9\+\/\=]/g,"");k>4,c=(15&g)<<4|h>>2,e=(3&h)<<6|i,j+=String.fromCharCode(b),64!=h&&(j+=String.fromCharCode(c)),64!=i&&(j+=String.fromCharCode(e));return j}},{}],2:[function(a,b){"use strict";function c(){this.compressedSize=0,this.uncompressedSize=0,this.crc32=0,this.compressionMethod=null,this.compressedContent=null}c.prototype={getContent:function(){return null},getCompressedContent:function(){return null}},b.exports=c},{}],3:[function(a,b,c){"use strict";c.STORE={magic:"\x00\x00",compress:function(a){return a},uncompress:function(a){return a},compressInputType:null,uncompressInputType:null},c.DEFLATE=a("./flate")},{"./flate":8}],4:[function(a,b){"use strict";var c=a("./utils"),d=[0,1996959894,3993919788,2567524794,124634137,1886057615,3915621685,2657392035,249268274,2044508324,3772115230,2547177864,162941995,2125561021,3887607047,2428444049,498536548,1789927666,4089016648,2227061214,450548861,1843258603,4107580753,2211677639,325883990,1684777152,4251122042,2321926636,335633487,1661365465,4195302755,2366115317,997073096,1281953886,3579855332,2724688242,1006888145,1258607687,3524101629,2768942443,901097722,1119000684,3686517206,2898065728,853044451,1172266101,3705015759,2882616665,651767980,1373503546,3369554304,3218104598,565507253,1454621731,3485111705,3099436303,671266974,1594198024,3322730930,2970347812,795835527,1483230225,3244367275,3060149565,1994146192,31158534,2563907772,4023717930,1907459465,112637215,2680153253,3904427059,2013776290,251722036,2517215374,3775830040,2137656763,141376813,2439277719,3865271297,1802195444,476864866,2238001368,4066508878,1812370925,453092731,2181625025,4111451223,1706088902,314042704,2344532202,4240017532,1658658271,366619977,2362670323,4224994405,1303535960,984961486,2747007092,3569037538,1256170817,1037604311,2765210733,3554079995,1131014506,879679996,2909243462,3663771856,1141124467,855842277,2852801631,3708648649,1342533948,654459306,3188396048,3373015174,1466479909,544179635,3110523913,3462522015,1591671054,702138776,2966460450,3352799412,1504918807,783551873,3082640443,3233442989,3988292384,2596254646,62317068,1957810842,3939845945,2647816111,81470997,1943803523,3814918930,2489596804,225274430,2053790376,3826175755,2466906013,167816743,2097651377,4027552580,2265490386,503444072,1762050814,4150417245,2154129355,426522225,1852507879,4275313526,2312317920,282753626,1742555852,4189708143,2394877945,397917763,1622183637,3604390888,2714866558,953729732,1340076626,3518719985,2797360999,1068828381,1219638859,3624741850,2936675148,906185462,1090812512,3747672003,2825379669,829329135,1181335161,3412177804,3160834842,628085408,1382605366,3423369109,3138078467,570562233,1426400815,3317316542,2998733608,733239954,1555261956,3268935591,3050360625,752459403,1541320221,2607071920,3965973030,1969922972,40735498,2617837225,3943577151,1913087877,83908371,2512341634,3803740692,2075208622,213261112,2463272603,3855990285,2094854071,198958881,2262029012,4057260610,1759359992,534414190,2176718541,4139329115,1873836001,414664567,2282248934,4279200368,1711684554,285281116,2405801727,4167216745,1634467795,376229701,2685067896,3608007406,1308918612,956543938,2808555105,3495958263,1231636301,1047427035,2932959818,3654703836,1088359270,936918e3,2847714899,3736837829,1202900863,817233897,3183342108,3401237130,1404277552,615818150,3134207493,3453421203,1423857449,601450431,3009837614,3294710456,1567103746,711928724,3020668471,3272380065,1510334235,755167117];b.exports=function(a,b){if("undefined"==typeof a||!a.length)return 0;var e="string"!==c.getTypeOf(a);"undefined"==typeof b&&(b=0);var f=0,g=0,h=0;b=-1^b;for(var i=0,j=a.length;j>i;i++)h=e?a[i]:a.charCodeAt(i),g=255&(b^h),f=d[g],b=b>>>8^f;return-1^b}},{"./utils":21}],5:[function(a,b){"use strict";function c(){this.data=null,this.length=0,this.index=0}var d=a("./utils");c.prototype={checkOffset:function(a){this.checkIndex(this.index+a)},checkIndex:function(a){if(this.lengtha)throw new Error("End of data reached (data length = "+this.length+", asked index = "+a+"). Corrupted zip ?")},setIndex:function(a){this.checkIndex(a),this.index=a},skip:function(a){this.setIndex(this.index+a)},byteAt:function(){},readInt:function(a){var b,c=0;for(this.checkOffset(a),b=this.index+a-1;b>=this.index;b--)c=(c<<8)+this.byteAt(b);return this.index+=a,c},readString:function(a){return d.transformTo("string",this.readData(a))},readData:function(){},lastIndexOfSignature:function(){},readDate:function(){var a=this.readInt(4);return new Date((a>>25&127)+1980,(a>>21&15)-1,a>>16&31,a>>11&31,a>>5&63,(31&a)<<1)}},b.exports=c},{"./utils":21}],6:[function(a,b,c){"use strict";c.base64=!1,c.binary=!1,c.dir=!1,c.createFolders=!1,c.date=null,c.compression=null,c.compressionOptions=null,c.comment=null,c.unixPermissions=null,c.dosPermissions=null},{}],7:[function(a,b,c){"use strict";var d=a("./utils");c.string2binary=function(a){return d.string2binary(a)},c.string2Uint8Array=function(a){return d.transformTo("uint8array",a)},c.uint8Array2String=function(a){return d.transformTo("string",a)},c.string2Blob=function(a){var b=d.transformTo("arraybuffer",a);return d.arrayBuffer2Blob(b)},c.arrayBuffer2Blob=function(a){return d.arrayBuffer2Blob(a)},c.transformTo=function(a,b){return d.transformTo(a,b)},c.getTypeOf=function(a){return d.getTypeOf(a)},c.checkSupport=function(a){return d.checkSupport(a)},c.MAX_VALUE_16BITS=d.MAX_VALUE_16BITS,c.MAX_VALUE_32BITS=d.MAX_VALUE_32BITS,c.pretty=function(a){return d.pretty(a)},c.findCompression=function(a){return d.findCompression(a)},c.isRegExp=function(a){return d.isRegExp(a)}},{"./utils":21}],8:[function(a,b,c){"use strict";var d="undefined"!=typeof Uint8Array&&"undefined"!=typeof Uint16Array&&"undefined"!=typeof Uint32Array,e=a("pako");c.uncompressInputType=d?"uint8array":"array",c.compressInputType=d?"uint8array":"array",c.magic="\b\x00",c.compress=function(a,b){return e.deflateRaw(a,{level:b.level||-1})},c.uncompress=function(a){return e.inflateRaw(a)}},{pako:24}],9:[function(a,b){"use strict";function c(a,b){return this instanceof c?(this.files={},this.comment=null,this.root="",a&&this.load(a,b),void(this.clone=function(){var a=new c;for(var b in this)"function"!=typeof this[b]&&(a[b]=this[b]);return a})):new c(a,b)}var d=a("./base64");c.prototype=a("./object"),c.prototype.load=a("./load"),c.support=a("./support"),c.defaults=a("./defaults"),c.utils=a("./deprecatedPublicUtils"),c.base64={encode:function(a){return d.encode(a)},decode:function(a){return d.decode(a)}},c.compressions=a("./compressions"),b.exports=c},{"./base64":1,"./compressions":3,"./defaults":6,"./deprecatedPublicUtils":7,"./load":10,"./object":13,"./support":17}],10:[function(a,b){"use strict";var c=a("./base64"),d=a("./zipEntries");b.exports=function(a,b){var e,f,g,h;for(b=b||{},b.base64&&(a=c.decode(a)),f=new d(a,b),e=f.files,g=0;gc;c++)d+=String.fromCharCode(255&a),a>>>=8;return d},t=function(){var a,b,c={};for(a=0;a0?a.substring(0,b):""},x=function(a){return"/"!=a.slice(-1)&&(a+="/"),a},y=function(a,b){return b="undefined"!=typeof b?b:!1,a=x(a),this.files[a]||v.call(this,a,null,{dir:!0,createFolders:b}),this.files[a]},z=function(a,b,c){var f,g=new j;return a._data instanceof j?(g.uncompressedSize=a._data.uncompressedSize,g.crc32=a._data.crc32,0===g.uncompressedSize||a.dir?(b=i.STORE,g.compressedContent="",g.crc32=0):a._data.compressionMethod===b.magic?g.compressedContent=a._data.getCompressedContent():(f=a._data.getContent(),g.compressedContent=b.compress(d.transformTo(b.compressInputType,f),c))):(f=p(a),(!f||0===f.length||a.dir)&&(b=i.STORE,f=""),g.uncompressedSize=f.length,g.crc32=e(f),g.compressedContent=b.compress(d.transformTo(b.compressInputType,f),c)),g.compressedSize=g.compressedContent.length,g.compressionMethod=b.magic,g},A=function(a,b){var c=a;return a||(c=b?16893:33204),(65535&c)<<16},B=function(a){return 63&(a||0)},C=function(a,b,c,g,h){var i,j,k,m,n=(c.compressedContent,d.transformTo("string",l.utf8encode(b.name))),o=b.comment||"",p=d.transformTo("string",l.utf8encode(o)),q=n.length!==b.name.length,r=p.length!==o.length,t=b.options,u="",v="",w="";k=b._initialMetadata.dir!==b.dir?b.dir:t.dir,m=b._initialMetadata.date!==b.date?b.date:t.date;var x=0,y=0;k&&(x|=16),"UNIX"===h?(y=798,x|=A(b.unixPermissions,k)):(y=20,x|=B(b.dosPermissions,k)),i=m.getHours(),i<<=6,i|=m.getMinutes(),i<<=5,i|=m.getSeconds()/2,j=m.getFullYear()-1980,j<<=4,j|=m.getMonth()+1,j<<=5,j|=m.getDate(),q&&(v=s(1,1)+s(e(n),4)+n,u+="up"+s(v.length,2)+v),r&&(w=s(1,1)+s(this.crc32(p),4)+p,u+="uc"+s(w.length,2)+w);var z="";z+="\n\x00",z+=q||r?"\x00\b":"\x00\x00",z+=c.compressionMethod,z+=s(i,2),z+=s(j,2),z+=s(c.crc32,4),z+=s(c.compressedSize,4),z+=s(c.uncompressedSize,4),z+=s(n.length,2),z+=s(u.length,2);var C=f.LOCAL_FILE_HEADER+z+n+u,D=f.CENTRAL_FILE_HEADER+s(y,2)+z+s(p.length,2)+"\x00\x00\x00\x00"+s(x,4)+s(g,4)+n+u+p;return{fileRecord:C,dirRecord:D,compressedObject:c}},D={load:function(){throw new Error("Load method is not defined. Is the file jszip-load.js included ?")},filter:function(a){var b,c,d,e,f=[];for(b in this.files)this.files.hasOwnProperty(b)&&(d=this.files[b],e=new r(d.name,d._data,t(d.options)),c=b.slice(this.root.length,b.length),b.slice(0,this.root.length)===this.root&&a(c,e)&&f.push(e));return f},file:function(a,b,c){if(1===arguments.length){if(d.isRegExp(a)){var e=a;return this.filter(function(a,b){return!b.dir&&e.test(a)})}return this.filter(function(b,c){return!c.dir&&b===a})[0]||null}return a=this.root+a,v.call(this,a,b,c),this},folder:function(a){if(!a)return this;if(d.isRegExp(a))return this.filter(function(b,c){return c.dir&&a.test(b)});var b=this.root+a,c=y.call(this,b),e=this.clone();return e.root=c.name,e},remove:function(a){a=this.root+a;var b=this.files[a];if(b||("/"!=a.slice(-1)&&(a+="/"),b=this.files[a]),b&&!b.dir)delete this.files[a];else for(var c=this.filter(function(b,c){return c.name.slice(0,a.length)===a}),d=0;d=0;--f)if(this.data[f]===b&&this.data[f+1]===c&&this.data[f+2]===d&&this.data[f+3]===e)return f;return-1},c.prototype.readData=function(a){if(this.checkOffset(a),0===a)return new Uint8Array(0);var b=this.data.subarray(this.index,this.index+a);return this.index+=a,b},b.exports=c},{"./dataReader":5}],19:[function(a,b){"use strict";var c=a("./utils"),d=function(a){this.data=new Uint8Array(a),this.index=0};d.prototype={append:function(a){0!==a.length&&(a=c.transformTo("uint8array",a),this.data.set(a,this.index),this.index+=a.length)},finalize:function(){return this.data}},b.exports=d},{"./utils":21}],20:[function(a,b,c){"use strict";for(var d=a("./utils"),e=a("./support"),f=a("./nodeBuffer"),g=new Array(256),h=0;256>h;h++)g[h]=h>=252?6:h>=248?5:h>=240?4:h>=224?3:h>=192?2:1;g[254]=g[254]=1;var i=function(a){var b,c,d,f,g,h=a.length,i=0;for(f=0;h>f;f++)c=a.charCodeAt(f),55296===(64512&c)&&h>f+1&&(d=a.charCodeAt(f+1),56320===(64512&d)&&(c=65536+(c-55296<<10)+(d-56320),f++)),i+=128>c?1:2048>c?2:65536>c?3:4;for(b=e.uint8array?new Uint8Array(i):new Array(i),g=0,f=0;i>g;f++)c=a.charCodeAt(f),55296===(64512&c)&&h>f+1&&(d=a.charCodeAt(f+1),56320===(64512&d)&&(c=65536+(c-55296<<10)+(d-56320),f++)),128>c?b[g++]=c:2048>c?(b[g++]=192|c>>>6,b[g++]=128|63&c):65536>c?(b[g++]=224|c>>>12,b[g++]=128|c>>>6&63,b[g++]=128|63&c):(b[g++]=240|c>>>18,b[g++]=128|c>>>12&63,b[g++]=128|c>>>6&63,b[g++]=128|63&c);return b},j=function(a,b){var c;for(b=b||a.length,b>a.length&&(b=a.length),c=b-1;c>=0&&128===(192&a[c]);)c--;return 0>c?b:0===c?b:c+g[a[c]]>b?c:b},k=function(a){var b,c,e,f,h=a.length,i=new Array(2*h);for(c=0,b=0;h>b;)if(e=a[b++],128>e)i[c++]=e;else if(f=g[e],f>4)i[c++]=65533,b+=f-1;else{for(e&=2===f?31:3===f?15:7;f>1&&h>b;)e=e<<6|63&a[b++],f--;f>1?i[c++]=65533:65536>e?i[c++]=e:(e-=65536,i[c++]=55296|e>>10&1023,i[c++]=56320|1023&e)}return i.length!==c&&(i.subarray?i=i.subarray(0,c):i.length=c),d.applyFromCharCode(i)};c.utf8encode=function(a){return e.nodebuffer?f(a,"utf-8"):i(a)},c.utf8decode=function(a){if(e.nodebuffer)return d.transformTo("nodebuffer",a).toString("utf-8");a=d.transformTo(e.uint8array?"uint8array":"array",a);for(var b=[],c=0,f=a.length,g=65536;f>c;){var h=j(a,Math.min(c+g,f));b.push(e.uint8array?k(a.subarray(c,h)):k(a.slice(c,h))),c=h}return b.join("")}},{"./nodeBuffer":11,"./support":17,"./utils":21}],21:[function(a,b,c){"use strict";function d(a){return a}function e(a,b){for(var c=0;cg&&b>1;)try{d.push("array"===f||"nodebuffer"===f?String.fromCharCode.apply(null,a.slice(g,Math.min(g+b,e))):String.fromCharCode.apply(null,a.subarray(g,Math.min(g+b,e)))),g+=b}catch(i){b=Math.floor(b/2)}return d.join("")}function g(a,b){for(var c=0;cb?"0":"")+b.toString(16).toUpperCase();return d},c.findCompression=function(a){for(var b in i)if(i.hasOwnProperty(b)&&i[b].magic===a)return i[b];return null},c.isRegExp=function(a){return"[object RegExp]"===Object.prototype.toString.call(a)}},{"./compressions":3,"./nodeBuffer":11,"./support":17}],22:[function(a,b){"use strict";function c(a,b){this.files=[],this.loadOptions=b,a&&this.load(a)}var d=a("./stringReader"),e=a("./nodeBufferReader"),f=a("./uint8ArrayReader"),g=a("./utils"),h=a("./signature"),i=a("./zipEntry"),j=a("./support"),k=a("./object");c.prototype={checkSignature:function(a){var b=this.reader.readString(4);if(b!==a)throw new Error("Corrupted zip or bug : unexpected signature ("+g.pretty(b)+", expected "+g.pretty(a)+")")},readBlockEndOfCentral:function(){this.diskNumber=this.reader.readInt(2),this.diskWithCentralDirStart=this.reader.readInt(2),this.centralDirRecordsOnThisDisk=this.reader.readInt(2),this.centralDirRecords=this.reader.readInt(2),this.centralDirSize=this.reader.readInt(4),this.centralDirOffset=this.reader.readInt(4),this.zipCommentLength=this.reader.readInt(2),this.zipComment=this.reader.readString(this.zipCommentLength),this.zipComment=k.utf8decode(this.zipComment)},readBlockZip64EndOfCentral:function(){this.zip64EndOfCentralSize=this.reader.readInt(8),this.versionMadeBy=this.reader.readString(2),this.versionNeeded=this.reader.readInt(2),this.diskNumber=this.reader.readInt(4),this.diskWithCentralDirStart=this.reader.readInt(4),this.centralDirRecordsOnThisDisk=this.reader.readInt(8),this.centralDirRecords=this.reader.readInt(8),this.centralDirSize=this.reader.readInt(8),this.centralDirOffset=this.reader.readInt(8),this.zip64ExtensibleData={};for(var a,b,c,d=this.zip64EndOfCentralSize-44,e=0;d>e;)a=this.reader.readInt(2),b=this.reader.readInt(4),c=this.reader.readString(b),this.zip64ExtensibleData[a]={id:a,length:b,value:c}},readBlockZip64EndOfCentralLocator:function(){if(this.diskWithZip64CentralDirStart=this.reader.readInt(4),this.relativeOffsetEndOfZip64CentralDir=this.reader.readInt(8),this.disksCount=this.reader.readInt(4),this.disksCount>1)throw new Error("Multi-volumes zip are not supported")},readLocalFiles:function(){var a,b;for(a=0;a>8;this.dir=16&this.externalFileAttributes?!0:!1,a===h&&(this.dosPermissions=63&this.externalFileAttributes),a===i&&(this.unixPermissions=this.externalFileAttributes>>16&65535),this.dir||"/"!==this.fileName.slice(-1)||(this.dir=!0)},parseZIP64ExtraField:function(){if(this.extraFields[1]){var a=new d(this.extraFields[1].value);this.uncompressedSize===e.MAX_VALUE_32BITS&&(this.uncompressedSize=a.readInt(8)),this.compressedSize===e.MAX_VALUE_32BITS&&(this.compressedSize=a.readInt(8)),this.localHeaderOffset===e.MAX_VALUE_32BITS&&(this.localHeaderOffset=a.readInt(8)),this.diskNumberStart===e.MAX_VALUE_32BITS&&(this.diskNumberStart=a.readInt(4))}},readExtraFields:function(a){var b,c,d,e=a.index;for(this.extraFields=this.extraFields||{};a.index0?b.windowBits=-b.windowBits:b.gzip&&b.windowBits>0&&b.windowBits<16&&(b.windowBits+=16),this.err=0,this.msg="",this.ended=!1,this.chunks=[],this.strm=new k,this.strm.avail_out=0;var c=g.deflateInit2(this.strm,b.level,b.method,b.windowBits,b.memLevel,b.strategy);if(c!==n)throw new Error(j[c]);b.header&&g.deflateSetHeader(this.strm,b.header)};s.prototype.push=function(a,b){var c,d,e=this.strm,f=this.options.chunkSize;if(this.ended)return!1;d=b===~~b?b:b===!0?m:l,e.input="string"==typeof a?i.string2buf(a):a,e.next_in=0,e.avail_in=e.input.length;do{if(0===e.avail_out&&(e.output=new h.Buf8(f),e.next_out=0,e.avail_out=f),c=g.deflate(e,d),c!==o&&c!==n)return this.onEnd(c),this.ended=!0,!1;(0===e.avail_out||0===e.avail_in&&d===m)&&this.onData("string"===this.options.to?i.buf2binstring(h.shrinkBuf(e.output,e.next_out)):h.shrinkBuf(e.output,e.next_out))}while((e.avail_in>0||0===e.avail_out)&&c!==o);return d===m?(c=g.deflateEnd(this.strm),this.onEnd(c),this.ended=!0,c===n):!0},s.prototype.onData=function(a){this.chunks.push(a)},s.prototype.onEnd=function(a){a===n&&(this.result="string"===this.options.to?this.chunks.join(""):h.flattenChunks(this.chunks)),this.chunks=[],this.err=a,this.msg=this.strm.msg},c.Deflate=s,c.deflate=d,c.deflateRaw=e,c.gzip=f},{"./utils/common":27,"./utils/strings":28,"./zlib/deflate.js":32,"./zlib/messages":37,"./zlib/zstream":39}],26:[function(a,b,c){"use strict";function d(a,b){var c=new m(b);if(c.push(a,!0),c.err)throw c.msg;return c.result}function e(a,b){return b=b||{},b.raw=!0,d(a,b)}var f=a("./zlib/inflate.js"),g=a("./utils/common"),h=a("./utils/strings"),i=a("./zlib/constants"),j=a("./zlib/messages"),k=a("./zlib/zstream"),l=a("./zlib/gzheader"),m=function(a){this.options=g.assign({chunkSize:16384,windowBits:0,to:""},a||{});var b=this.options;b.raw&&b.windowBits>=0&&b.windowBits<16&&(b.windowBits=-b.windowBits,0===b.windowBits&&(b.windowBits=-15)),!(b.windowBits>=0&&b.windowBits<16)||a&&a.windowBits||(b.windowBits+=32),b.windowBits>15&&b.windowBits<48&&0===(15&b.windowBits)&&(b.windowBits|=15),this.err=0,this.msg="",this.ended=!1,this.chunks=[],this.strm=new k,this.strm.avail_out=0;var c=f.inflateInit2(this.strm,b.windowBits);if(c!==i.Z_OK)throw new Error(j[c]);this.header=new l,f.inflateGetHeader(this.strm,this.header)};m.prototype.push=function(a,b){var c,d,e,j,k,l=this.strm,m=this.options.chunkSize;if(this.ended)return!1;d=b===~~b?b:b===!0?i.Z_FINISH:i.Z_NO_FLUSH,l.input="string"==typeof a?h.binstring2buf(a):a,l.next_in=0,l.avail_in=l.input.length;do{if(0===l.avail_out&&(l.output=new g.Buf8(m),l.next_out=0,l.avail_out=m),c=f.inflate(l,i.Z_NO_FLUSH),c!==i.Z_STREAM_END&&c!==i.Z_OK)return this.onEnd(c),this.ended=!0,!1;l.next_out&&(0===l.avail_out||c===i.Z_STREAM_END||0===l.avail_in&&d===i.Z_FINISH)&&("string"===this.options.to?(e=h.utf8border(l.output,l.next_out),j=l.next_out-e,k=h.buf2string(l.output,e),l.next_out=j,l.avail_out=m-j,j&&g.arraySet(l.output,l.output,e,j,0),this.onData(k)):this.onData(g.shrinkBuf(l.output,l.next_out)))}while(l.avail_in>0&&c!==i.Z_STREAM_END);return c===i.Z_STREAM_END&&(d=i.Z_FINISH),d===i.Z_FINISH?(c=f.inflateEnd(this.strm),this.onEnd(c),this.ended=!0,c===i.Z_OK):!0},m.prototype.onData=function(a){this.chunks.push(a)},m.prototype.onEnd=function(a){a===i.Z_OK&&(this.result="string"===this.options.to?this.chunks.join(""):g.flattenChunks(this.chunks)),this.chunks=[],this.err=a,this.msg=this.strm.msg},c.Inflate=m,c.inflate=d,c.inflateRaw=e,c.ungzip=d},{"./utils/common":27,"./utils/strings":28,"./zlib/constants":30,"./zlib/gzheader":33,"./zlib/inflate.js":35,"./zlib/messages":37,"./zlib/zstream":39}],27:[function(a,b,c){"use strict";var d="undefined"!=typeof Uint8Array&&"undefined"!=typeof Uint16Array&&"undefined"!=typeof Int32Array;c.assign=function(a){for(var b=Array.prototype.slice.call(arguments,1);b.length;){var c=b.shift();if(c){if("object"!=typeof c)throw new TypeError(c+"must be non-object");for(var d in c)c.hasOwnProperty(d)&&(a[d]=c[d])}}return a},c.shrinkBuf=function(a,b){return a.length===b?a:a.subarray?a.subarray(0,b):(a.length=b,a)};var e={arraySet:function(a,b,c,d,e){if(b.subarray&&a.subarray)return void a.set(b.subarray(c,c+d),e);for(var f=0;d>f;f++)a[e+f]=b[c+f]},flattenChunks:function(a){var b,c,d,e,f,g;for(d=0,b=0,c=a.length;c>b;b++)d+=a[b].length;for(g=new Uint8Array(d),e=0,b=0,c=a.length;c>b;b++)f=a[b],g.set(f,e),e+=f.length;return g}},f={arraySet:function(a,b,c,d,e){for(var f=0;d>f;f++)a[e+f]=b[c+f]},flattenChunks:function(a){return[].concat.apply([],a)}};c.setTyped=function(a){a?(c.Buf8=Uint8Array,c.Buf16=Uint16Array,c.Buf32=Int32Array,c.assign(c,e)):(c.Buf8=Array,c.Buf16=Array,c.Buf32=Array,c.assign(c,f))},c.setTyped(d)},{}],28:[function(a,b,c){"use strict";function d(a,b){if(65537>b&&(a.subarray&&g||!a.subarray&&f))return String.fromCharCode.apply(null,e.shrinkBuf(a,b));for(var c="",d=0;b>d;d++)c+=String.fromCharCode(a[d]);return c}var e=a("./common"),f=!0,g=!0;try{String.fromCharCode.apply(null,[0])}catch(h){f=!1}try{String.fromCharCode.apply(null,new Uint8Array(1))}catch(h){g=!1}for(var i=new e.Buf8(256),j=0;256>j;j++)i[j]=j>=252?6:j>=248?5:j>=240?4:j>=224?3:j>=192?2:1;i[254]=i[254]=1,c.string2buf=function(a){var b,c,d,f,g,h=a.length,i=0;for(f=0;h>f;f++)c=a.charCodeAt(f),55296===(64512&c)&&h>f+1&&(d=a.charCodeAt(f+1),56320===(64512&d)&&(c=65536+(c-55296<<10)+(d-56320),f++)),i+=128>c?1:2048>c?2:65536>c?3:4;for(b=new e.Buf8(i),g=0,f=0;i>g;f++)c=a.charCodeAt(f),55296===(64512&c)&&h>f+1&&(d=a.charCodeAt(f+1),56320===(64512&d)&&(c=65536+(c-55296<<10)+(d-56320),f++)),128>c?b[g++]=c:2048>c?(b[g++]=192|c>>>6,b[g++]=128|63&c):65536>c?(b[g++]=224|c>>>12,b[g++]=128|c>>>6&63,b[g++]=128|63&c):(b[g++]=240|c>>>18,b[g++]=128|c>>>12&63,b[g++]=128|c>>>6&63,b[g++]=128|63&c);return b},c.buf2binstring=function(a){return d(a,a.length)},c.binstring2buf=function(a){for(var b=new e.Buf8(a.length),c=0,d=b.length;d>c;c++)b[c]=a.charCodeAt(c);return b},c.buf2string=function(a,b){var c,e,f,g,h=b||a.length,j=new Array(2*h);for(e=0,c=0;h>c;)if(f=a[c++],128>f)j[e++]=f;else if(g=i[f],g>4)j[e++]=65533,c+=g-1;else{for(f&=2===g?31:3===g?15:7;g>1&&h>c;)f=f<<6|63&a[c++],g--;g>1?j[e++]=65533:65536>f?j[e++]=f:(f-=65536,j[e++]=55296|f>>10&1023,j[e++]=56320|1023&f)}return d(j,e)},c.utf8border=function(a,b){var c;for(b=b||a.length,b>a.length&&(b=a.length),c=b-1;c>=0&&128===(192&a[c]);)c--;return 0>c?b:0===c?b:c+i[a[c]]>b?c:b}},{"./common":27}],29:[function(a,b){"use strict";function c(a,b,c,d){for(var e=65535&a|0,f=a>>>16&65535|0,g=0;0!==c;){g=c>2e3?2e3:c,c-=g;do e=e+b[d++]|0,f=f+e|0;while(--g);e%=65521,f%=65521}return e|f<<16|0}b.exports=c},{}],30:[function(a,b){b.exports={Z_NO_FLUSH:0,Z_PARTIAL_FLUSH:1,Z_SYNC_FLUSH:2,Z_FULL_FLUSH:3,Z_FINISH:4,Z_BLOCK:5,Z_TREES:6,Z_OK:0,Z_STREAM_END:1,Z_NEED_DICT:2,Z_ERRNO:-1,Z_STREAM_ERROR:-2,Z_DATA_ERROR:-3,Z_BUF_ERROR:-5,Z_NO_COMPRESSION:0,Z_BEST_SPEED:1,Z_BEST_COMPRESSION:9,Z_DEFAULT_COMPRESSION:-1,Z_FILTERED:1,Z_HUFFMAN_ONLY:2,Z_RLE:3,Z_FIXED:4,Z_DEFAULT_STRATEGY:0,Z_BINARY:0,Z_TEXT:1,Z_UNKNOWN:2,Z_DEFLATED:8}},{}],31:[function(a,b){"use strict";function c(){for(var a,b=[],c=0;256>c;c++){a=c;for(var d=0;8>d;d++)a=1&a?3988292384^a>>>1:a>>>1;b[c]=a}return b}function d(a,b,c,d){var f=e,g=d+c;a=-1^a;for(var h=d;g>h;h++)a=a>>>8^f[255&(a^b[h])];return-1^a}var e=c();b.exports=d},{}],32:[function(a,b,c){"use strict";function d(a,b){return a.msg=G[b],b}function e(a){return(a<<1)-(a>4?9:0)}function f(a){for(var b=a.length;--b>=0;)a[b]=0}function g(a){var b=a.state,c=b.pending;c>a.avail_out&&(c=a.avail_out),0!==c&&(C.arraySet(a.output,b.pending_buf,b.pending_out,c,a.next_out),a.next_out+=c,b.pending_out+=c,a.total_out+=c,a.avail_out-=c,b.pending-=c,0===b.pending&&(b.pending_out=0))}function h(a,b){D._tr_flush_block(a,a.block_start>=0?a.block_start:-1,a.strstart-a.block_start,b),a.block_start=a.strstart,g(a.strm)}function i(a,b){a.pending_buf[a.pending++]=b}function j(a,b){a.pending_buf[a.pending++]=b>>>8&255,a.pending_buf[a.pending++]=255&b}function k(a,b,c,d){var e=a.avail_in;return e>d&&(e=d),0===e?0:(a.avail_in-=e,C.arraySet(b,a.input,a.next_in,e,c),1===a.state.wrap?a.adler=E(a.adler,b,e,c):2===a.state.wrap&&(a.adler=F(a.adler,b,e,c)),a.next_in+=e,a.total_in+=e,e)}function l(a,b){var c,d,e=a.max_chain_length,f=a.strstart,g=a.prev_length,h=a.nice_match,i=a.strstart>a.w_size-jb?a.strstart-(a.w_size-jb):0,j=a.window,k=a.w_mask,l=a.prev,m=a.strstart+ib,n=j[f+g-1],o=j[f+g];a.prev_length>=a.good_match&&(e>>=2),h>a.lookahead&&(h=a.lookahead);do if(c=b,j[c+g]===o&&j[c+g-1]===n&&j[c]===j[f]&&j[++c]===j[f+1]){f+=2,c++;do;while(j[++f]===j[++c]&&j[++f]===j[++c]&&j[++f]===j[++c]&&j[++f]===j[++c]&&j[++f]===j[++c]&&j[++f]===j[++c]&&j[++f]===j[++c]&&j[++f]===j[++c]&&m>f);if(d=ib-(m-f),f=m-ib,d>g){if(a.match_start=b,g=d,d>=h)break;n=j[f+g-1],o=j[f+g]}}while((b=l[b&k])>i&&0!==--e);return g<=a.lookahead?g:a.lookahead}function m(a){var b,c,d,e,f,g=a.w_size;do{if(e=a.window_size-a.lookahead-a.strstart,a.strstart>=g+(g-jb)){C.arraySet(a.window,a.window,g,g,0),a.match_start-=g,a.strstart-=g,a.block_start-=g,c=a.hash_size,b=c;do d=a.head[--b],a.head[b]=d>=g?d-g:0;while(--c);c=g,b=c;do d=a.prev[--b],a.prev[b]=d>=g?d-g:0;while(--c);e+=g}if(0===a.strm.avail_in)break;if(c=k(a.strm,a.window,a.strstart+a.lookahead,e),a.lookahead+=c,a.lookahead+a.insert>=hb)for(f=a.strstart-a.insert,a.ins_h=a.window[f],a.ins_h=(a.ins_h<a.pending_buf_size-5&&(c=a.pending_buf_size-5);;){if(a.lookahead<=1){if(m(a),0===a.lookahead&&b===H)return sb;if(0===a.lookahead)break}a.strstart+=a.lookahead,a.lookahead=0;var d=a.block_start+c;if((0===a.strstart||a.strstart>=d)&&(a.lookahead=a.strstart-d,a.strstart=d,h(a,!1),0===a.strm.avail_out))return sb;if(a.strstart-a.block_start>=a.w_size-jb&&(h(a,!1),0===a.strm.avail_out))return sb}return a.insert=0,b===K?(h(a,!0),0===a.strm.avail_out?ub:vb):a.strstart>a.block_start&&(h(a,!1),0===a.strm.avail_out)?sb:sb}function o(a,b){for(var c,d;;){if(a.lookahead=hb&&(a.ins_h=(a.ins_h<=hb)if(d=D._tr_tally(a,a.strstart-a.match_start,a.match_length-hb),a.lookahead-=a.match_length,a.match_length<=a.max_lazy_match&&a.lookahead>=hb){a.match_length--;do a.strstart++,a.ins_h=(a.ins_h<=hb&&(a.ins_h=(a.ins_h<4096)&&(a.match_length=hb-1)),a.prev_length>=hb&&a.match_length<=a.prev_length){e=a.strstart+a.lookahead-hb,d=D._tr_tally(a,a.strstart-1-a.prev_match,a.prev_length-hb),a.lookahead-=a.prev_length-1,a.prev_length-=2;do++a.strstart<=e&&(a.ins_h=(a.ins_h<=hb&&a.strstart>0&&(e=a.strstart-1,d=g[e],d===g[++e]&&d===g[++e]&&d===g[++e])){f=a.strstart+ib;do;while(d===g[++e]&&d===g[++e]&&d===g[++e]&&d===g[++e]&&d===g[++e]&&d===g[++e]&&d===g[++e]&&d===g[++e]&&f>e);a.match_length=ib-(f-e),a.match_length>a.lookahead&&(a.match_length=a.lookahead)}if(a.match_length>=hb?(c=D._tr_tally(a,1,a.match_length-hb),a.lookahead-=a.match_length,a.strstart+=a.match_length,a.match_length=0):(c=D._tr_tally(a,0,a.window[a.strstart]),a.lookahead--,a.strstart++),c&&(h(a,!1),0===a.strm.avail_out))return sb}return a.insert=0,b===K?(h(a,!0),0===a.strm.avail_out?ub:vb):a.last_lit&&(h(a,!1),0===a.strm.avail_out)?sb:tb}function r(a,b){for(var c;;){if(0===a.lookahead&&(m(a),0===a.lookahead)){if(b===H)return sb;break}if(a.match_length=0,c=D._tr_tally(a,0,a.window[a.strstart]),a.lookahead--,a.strstart++,c&&(h(a,!1),0===a.strm.avail_out))return sb}return a.insert=0,b===K?(h(a,!0),0===a.strm.avail_out?ub:vb):a.last_lit&&(h(a,!1),0===a.strm.avail_out)?sb:tb}function s(a){a.window_size=2*a.w_size,f(a.head),a.max_lazy_match=B[a.level].max_lazy,a.good_match=B[a.level].good_length,a.nice_match=B[a.level].nice_length,a.max_chain_length=B[a.level].max_chain,a.strstart=0,a.block_start=0,a.lookahead=0,a.insert=0,a.match_length=a.prev_length=hb-1,a.match_available=0,a.ins_h=0}function t(){this.strm=null,this.status=0,this.pending_buf=null,this.pending_buf_size=0,this.pending_out=0,this.pending=0,this.wrap=0,this.gzhead=null,this.gzindex=0,this.method=Y,this.last_flush=-1,this.w_size=0,this.w_bits=0,this.w_mask=0,this.window=null,this.window_size=0,this.prev=null,this.head=null,this.ins_h=0,this.hash_size=0,this.hash_bits=0,this.hash_mask=0,this.hash_shift=0,this.block_start=0,this.match_length=0,this.prev_match=0,this.match_available=0,this.strstart=0,this.match_start=0,this.lookahead=0,this.prev_length=0,this.max_chain_length=0,this.max_lazy_match=0,this.level=0,this.strategy=0,this.good_match=0,this.nice_match=0,this.dyn_ltree=new C.Buf16(2*fb),this.dyn_dtree=new C.Buf16(2*(2*db+1)),this.bl_tree=new C.Buf16(2*(2*eb+1)),f(this.dyn_ltree),f(this.dyn_dtree),f(this.bl_tree),this.l_desc=null,this.d_desc=null,this.bl_desc=null,this.bl_count=new C.Buf16(gb+1),this.heap=new C.Buf16(2*cb+1),f(this.heap),this.heap_len=0,this.heap_max=0,this.depth=new C.Buf16(2*cb+1),f(this.depth),this.l_buf=0,this.lit_bufsize=0,this.last_lit=0,this.d_buf=0,this.opt_len=0,this.static_len=0,this.matches=0,this.insert=0,this.bi_buf=0,this.bi_valid=0}function u(a){var b;return a&&a.state?(a.total_in=a.total_out=0,a.data_type=X,b=a.state,b.pending=0,b.pending_out=0,b.wrap<0&&(b.wrap=-b.wrap),b.status=b.wrap?lb:qb,a.adler=2===b.wrap?0:1,b.last_flush=H,D._tr_init(b),M):d(a,O)}function v(a){var b=u(a);return b===M&&s(a.state),b}function w(a,b){return a&&a.state?2!==a.state.wrap?O:(a.state.gzhead=b,M):O}function x(a,b,c,e,f,g){if(!a)return O;var h=1;if(b===R&&(b=6),0>e?(h=0,e=-e):e>15&&(h=2,e-=16),1>f||f>Z||c!==Y||8>e||e>15||0>b||b>9||0>g||g>V)return d(a,O);8===e&&(e=9);var i=new t;return a.state=i,i.strm=a,i.wrap=h,i.gzhead=null,i.w_bits=e,i.w_size=1<>1,i.l_buf=3*i.lit_bufsize,i.level=b,i.strategy=g,i.method=c,v(a)}function y(a,b){return x(a,b,Y,$,_,W)}function z(a,b){var c,h,k,l;if(!a||!a.state||b>L||0>b)return a?d(a,O):O;if(h=a.state,!a.output||!a.input&&0!==a.avail_in||h.status===rb&&b!==K)return d(a,0===a.avail_out?Q:O);if(h.strm=a,c=h.last_flush,h.last_flush=b,h.status===lb)if(2===h.wrap)a.adler=0,i(h,31),i(h,139),i(h,8),h.gzhead?(i(h,(h.gzhead.text?1:0)+(h.gzhead.hcrc?2:0)+(h.gzhead.extra?4:0)+(h.gzhead.name?8:0)+(h.gzhead.comment?16:0)),i(h,255&h.gzhead.time),i(h,h.gzhead.time>>8&255),i(h,h.gzhead.time>>16&255),i(h,h.gzhead.time>>24&255),i(h,9===h.level?2:h.strategy>=T||h.level<2?4:0),i(h,255&h.gzhead.os),h.gzhead.extra&&h.gzhead.extra.length&&(i(h,255&h.gzhead.extra.length),i(h,h.gzhead.extra.length>>8&255)),h.gzhead.hcrc&&(a.adler=F(a.adler,h.pending_buf,h.pending,0)),h.gzindex=0,h.status=mb):(i(h,0),i(h,0),i(h,0),i(h,0),i(h,0),i(h,9===h.level?2:h.strategy>=T||h.level<2?4:0),i(h,wb),h.status=qb);else{var m=Y+(h.w_bits-8<<4)<<8,n=-1;n=h.strategy>=T||h.level<2?0:h.level<6?1:6===h.level?2:3,m|=n<<6,0!==h.strstart&&(m|=kb),m+=31-m%31,h.status=qb,j(h,m),0!==h.strstart&&(j(h,a.adler>>>16),j(h,65535&a.adler)),a.adler=1}if(h.status===mb)if(h.gzhead.extra){for(k=h.pending;h.gzindex<(65535&h.gzhead.extra.length)&&(h.pending!==h.pending_buf_size||(h.gzhead.hcrc&&h.pending>k&&(a.adler=F(a.adler,h.pending_buf,h.pending-k,k)),g(a),k=h.pending,h.pending!==h.pending_buf_size));)i(h,255&h.gzhead.extra[h.gzindex]),h.gzindex++;h.gzhead.hcrc&&h.pending>k&&(a.adler=F(a.adler,h.pending_buf,h.pending-k,k)),h.gzindex===h.gzhead.extra.length&&(h.gzindex=0,h.status=nb)}else h.status=nb;if(h.status===nb)if(h.gzhead.name){k=h.pending;do{if(h.pending===h.pending_buf_size&&(h.gzhead.hcrc&&h.pending>k&&(a.adler=F(a.adler,h.pending_buf,h.pending-k,k)),g(a),k=h.pending,h.pending===h.pending_buf_size)){l=1;break}l=h.gzindexk&&(a.adler=F(a.adler,h.pending_buf,h.pending-k,k)),0===l&&(h.gzindex=0,h.status=ob)}else h.status=ob;if(h.status===ob)if(h.gzhead.comment){k=h.pending;do{if(h.pending===h.pending_buf_size&&(h.gzhead.hcrc&&h.pending>k&&(a.adler=F(a.adler,h.pending_buf,h.pending-k,k)),g(a),k=h.pending,h.pending===h.pending_buf_size)){l=1;break}l=h.gzindexk&&(a.adler=F(a.adler,h.pending_buf,h.pending-k,k)),0===l&&(h.status=pb)}else h.status=pb;if(h.status===pb&&(h.gzhead.hcrc?(h.pending+2>h.pending_buf_size&&g(a),h.pending+2<=h.pending_buf_size&&(i(h,255&a.adler),i(h,a.adler>>8&255),a.adler=0,h.status=qb)):h.status=qb),0!==h.pending){if(g(a),0===a.avail_out)return h.last_flush=-1,M}else if(0===a.avail_in&&e(b)<=e(c)&&b!==K)return d(a,Q);if(h.status===rb&&0!==a.avail_in)return d(a,Q);if(0!==a.avail_in||0!==h.lookahead||b!==H&&h.status!==rb){var o=h.strategy===T?r(h,b):h.strategy===U?q(h,b):B[h.level].func(h,b);if((o===ub||o===vb)&&(h.status=rb),o===sb||o===ub)return 0===a.avail_out&&(h.last_flush=-1),M;if(o===tb&&(b===I?D._tr_align(h):b!==L&&(D._tr_stored_block(h,0,0,!1),b===J&&(f(h.head),0===h.lookahead&&(h.strstart=0,h.block_start=0,h.insert=0))),g(a),0===a.avail_out))return h.last_flush=-1,M}return b!==K?M:h.wrap<=0?N:(2===h.wrap?(i(h,255&a.adler),i(h,a.adler>>8&255),i(h,a.adler>>16&255),i(h,a.adler>>24&255),i(h,255&a.total_in),i(h,a.total_in>>8&255),i(h,a.total_in>>16&255),i(h,a.total_in>>24&255)):(j(h,a.adler>>>16),j(h,65535&a.adler)),g(a),h.wrap>0&&(h.wrap=-h.wrap),0!==h.pending?M:N)}function A(a){var b;return a&&a.state?(b=a.state.status,b!==lb&&b!==mb&&b!==nb&&b!==ob&&b!==pb&&b!==qb&&b!==rb?d(a,O):(a.state=null,b===qb?d(a,P):M)):O}var B,C=a("../utils/common"),D=a("./trees"),E=a("./adler32"),F=a("./crc32"),G=a("./messages"),H=0,I=1,J=3,K=4,L=5,M=0,N=1,O=-2,P=-3,Q=-5,R=-1,S=1,T=2,U=3,V=4,W=0,X=2,Y=8,Z=9,$=15,_=8,ab=29,bb=256,cb=bb+1+ab,db=30,eb=19,fb=2*cb+1,gb=15,hb=3,ib=258,jb=ib+hb+1,kb=32,lb=42,mb=69,nb=73,ob=91,pb=103,qb=113,rb=666,sb=1,tb=2,ub=3,vb=4,wb=3,xb=function(a,b,c,d,e){this.good_length=a,this.max_lazy=b,this.nice_length=c,this.max_chain=d,this.func=e};B=[new xb(0,0,0,0,n),new xb(4,4,8,4,o),new xb(4,5,16,8,o),new xb(4,6,32,32,o),new xb(4,4,16,16,p),new xb(8,16,32,32,p),new xb(8,16,128,128,p),new xb(8,32,128,256,p),new xb(32,128,258,1024,p),new xb(32,258,258,4096,p)],c.deflateInit=y,c.deflateInit2=x,c.deflateReset=v,c.deflateResetKeep=u,c.deflateSetHeader=w,c.deflate=z,c.deflateEnd=A,c.deflateInfo="pako deflate (from Nodeca project)"},{"../utils/common":27,"./adler32":29,"./crc32":31,"./messages":37,"./trees":38}],33:[function(a,b){"use strict";function c(){this.text=0,this.time=0,this.xflags=0,this.os=0,this.extra=null,this.extra_len=0,this.name="",this.comment="",this.hcrc=0,this.done=!1}b.exports=c},{}],34:[function(a,b){"use strict";var c=30,d=12;b.exports=function(a,b){var e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z,A,B,C;e=a.state,f=a.next_in,B=a.input,g=f+(a.avail_in-5),h=a.next_out,C=a.output,i=h-(b-a.avail_out),j=h+(a.avail_out-257),k=e.dmax,l=e.wsize,m=e.whave,n=e.wnext,o=e.window,p=e.hold,q=e.bits,r=e.lencode,s=e.distcode,t=(1<q&&(p+=B[f++]<>>24,p>>>=w,q-=w,w=v>>>16&255,0===w)C[h++]=65535&v;else{if(!(16&w)){if(0===(64&w)){v=r[(65535&v)+(p&(1<q&&(p+=B[f++]<>>=w,q-=w),15>q&&(p+=B[f++]<>>24,p>>>=w,q-=w,w=v>>>16&255,!(16&w)){if(0===(64&w)){v=s[(65535&v)+(p&(1<q&&(p+=B[f++]<q&&(p+=B[f++]<k){a.msg="invalid distance too far back",e.mode=c;break a}if(p>>>=w,q-=w,w=h-i,y>w){if(w=y-w,w>m&&e.sane){a.msg="invalid distance too far back",e.mode=c;break a}if(z=0,A=o,0===n){if(z+=l-w,x>w){x-=w;do C[h++]=o[z++];while(--w);z=h-y,A=C}}else if(w>n){if(z+=l+n-w,w-=n,x>w){x-=w;do C[h++]=o[z++];while(--w);if(z=0,x>n){w=n,x-=w;do C[h++]=o[z++];while(--w);z=h-y,A=C}}}else if(z+=n-w,x>w){x-=w;do C[h++]=o[z++];while(--w);z=h-y,A=C}for(;x>2;)C[h++]=A[z++],C[h++]=A[z++],C[h++]=A[z++],x-=3;x&&(C[h++]=A[z++],x>1&&(C[h++]=A[z++]))}else{z=h-y;do C[h++]=C[z++],C[h++]=C[z++],C[h++]=C[z++],x-=3;while(x>2);x&&(C[h++]=C[z++],x>1&&(C[h++]=C[z++]))}break}}break}}while(g>f&&j>h);x=q>>3,f-=x,q-=x<<3,p&=(1<f?5+(g-f):5-(f-g),a.avail_out=j>h?257+(j-h):257-(h-j),e.hold=p,e.bits=q}},{}],35:[function(a,b,c){"use strict";function d(a){return(a>>>24&255)+(a>>>8&65280)+((65280&a)<<8)+((255&a)<<24)}function e(){this.mode=0,this.last=!1,this.wrap=0,this.havedict=!1,this.flags=0,this.dmax=0,this.check=0,this.total=0,this.head=null,this.wbits=0,this.wsize=0,this.whave=0,this.wnext=0,this.window=null,this.hold=0,this.bits=0,this.length=0,this.offset=0,this.extra=0,this.lencode=null,this.distcode=null,this.lenbits=0,this.distbits=0,this.ncode=0,this.nlen=0,this.ndist=0,this.have=0,this.next=null,this.lens=new r.Buf16(320),this.work=new r.Buf16(288),this.lendyn=null,this.distdyn=null,this.sane=0,this.back=0,this.was=0}function f(a){var b;return a&&a.state?(b=a.state,a.total_in=a.total_out=b.total=0,a.msg="",b.wrap&&(a.adler=1&b.wrap),b.mode=K,b.last=0,b.havedict=0,b.dmax=32768,b.head=null,b.hold=0,b.bits=0,b.lencode=b.lendyn=new r.Buf32(ob),b.distcode=b.distdyn=new r.Buf32(pb),b.sane=1,b.back=-1,C):F}function g(a){var b;return a&&a.state?(b=a.state,b.wsize=0,b.whave=0,b.wnext=0,f(a)):F}function h(a,b){var c,d;return a&&a.state?(d=a.state,0>b?(c=0,b=-b):(c=(b>>4)+1,48>b&&(b&=15)),b&&(8>b||b>15)?F:(null!==d.window&&d.wbits!==b&&(d.window=null),d.wrap=c,d.wbits=b,g(a))):F}function i(a,b){var c,d;return a?(d=new e,a.state=d,d.window=null,c=h(a,b),c!==C&&(a.state=null),c):F}function j(a){return i(a,rb)}function k(a){if(sb){var b;for(p=new r.Buf32(512),q=new r.Buf32(32),b=0;144>b;)a.lens[b++]=8;for(;256>b;)a.lens[b++]=9;for(;280>b;)a.lens[b++]=7;for(;288>b;)a.lens[b++]=8;for(v(x,a.lens,0,288,p,0,a.work,{bits:9}),b=0;32>b;)a.lens[b++]=5;v(y,a.lens,0,32,q,0,a.work,{bits:5}),sb=!1}a.lencode=p,a.lenbits=9,a.distcode=q,a.distbits=5}function l(a,b,c,d){var e,f=a.state;return null===f.window&&(f.wsize=1<=f.wsize?(r.arraySet(f.window,b,c-f.wsize,f.wsize,0),f.wnext=0,f.whave=f.wsize):(e=f.wsize-f.wnext,e>d&&(e=d),r.arraySet(f.window,b,c-d,e,f.wnext),d-=e,d?(r.arraySet(f.window,b,c-d,d,0),f.wnext=d,f.whave=f.wsize):(f.wnext+=e,f.wnext===f.wsize&&(f.wnext=0),f.whaven;){if(0===i)break a;i--,m+=e[g++]<>>8&255,c.check=t(c.check,Bb,2,0),m=0,n=0,c.mode=L;break}if(c.flags=0,c.head&&(c.head.done=!1),!(1&c.wrap)||(((255&m)<<8)+(m>>8))%31){a.msg="incorrect header check",c.mode=lb;break}if((15&m)!==J){a.msg="unknown compression method",c.mode=lb;break}if(m>>>=4,n-=4,wb=(15&m)+8,0===c.wbits)c.wbits=wb;else if(wb>c.wbits){a.msg="invalid window size",c.mode=lb;break}c.dmax=1<n;){if(0===i)break a;i--,m+=e[g++]<>8&1),512&c.flags&&(Bb[0]=255&m,Bb[1]=m>>>8&255,c.check=t(c.check,Bb,2,0)),m=0,n=0,c.mode=M;case M:for(;32>n;){if(0===i)break a;i--,m+=e[g++]<>>8&255,Bb[2]=m>>>16&255,Bb[3]=m>>>24&255,c.check=t(c.check,Bb,4,0)),m=0,n=0,c.mode=N;case N:for(;16>n;){if(0===i)break a;i--,m+=e[g++]<>8),512&c.flags&&(Bb[0]=255&m,Bb[1]=m>>>8&255,c.check=t(c.check,Bb,2,0)),m=0,n=0,c.mode=O;case O:if(1024&c.flags){for(;16>n;){if(0===i)break a;i--,m+=e[g++]<>>8&255,c.check=t(c.check,Bb,2,0)),m=0,n=0}else c.head&&(c.head.extra=null);c.mode=P;case P:if(1024&c.flags&&(q=c.length,q>i&&(q=i),q&&(c.head&&(wb=c.head.extra_len-c.length,c.head.extra||(c.head.extra=new Array(c.head.extra_len)),r.arraySet(c.head.extra,e,g,q,wb)),512&c.flags&&(c.check=t(c.check,e,q,g)),i-=q,g+=q,c.length-=q),c.length))break a;c.length=0,c.mode=Q;case Q:if(2048&c.flags){if(0===i)break a;q=0;do wb=e[g+q++],c.head&&wb&&c.length<65536&&(c.head.name+=String.fromCharCode(wb));while(wb&&i>q);if(512&c.flags&&(c.check=t(c.check,e,q,g)),i-=q,g+=q,wb)break a}else c.head&&(c.head.name=null);c.length=0,c.mode=R;case R:if(4096&c.flags){if(0===i)break a;q=0;do wb=e[g+q++],c.head&&wb&&c.length<65536&&(c.head.comment+=String.fromCharCode(wb));while(wb&&i>q);if(512&c.flags&&(c.check=t(c.check,e,q,g)),i-=q,g+=q,wb)break a}else c.head&&(c.head.comment=null);c.mode=S;case S:if(512&c.flags){for(;16>n;){if(0===i)break a;i--,m+=e[g++]<>9&1,c.head.done=!0),a.adler=c.check=0,c.mode=V;break;case T:for(;32>n;){if(0===i)break a;i--,m+=e[g++]<>>=7&n,n-=7&n,c.mode=ib;break}for(;3>n;){if(0===i)break a;i--,m+=e[g++]<>>=1,n-=1,3&m){case 0:c.mode=X;break;case 1:if(k(c),c.mode=bb,b===B){m>>>=2,n-=2;break a}break;case 2:c.mode=$;break;case 3:a.msg="invalid block type",c.mode=lb}m>>>=2,n-=2;break;case X:for(m>>>=7&n,n-=7&n;32>n;){if(0===i)break a;i--,m+=e[g++]<>>16^65535)){a.msg="invalid stored block lengths",c.mode=lb;break}if(c.length=65535&m,m=0,n=0,c.mode=Y,b===B)break a;case Y:c.mode=Z;case Z:if(q=c.length){if(q>i&&(q=i),q>j&&(q=j),0===q)break a;r.arraySet(f,e,g,q,h),i-=q,g+=q,j-=q,h+=q,c.length-=q;break}c.mode=V;break;case $:for(;14>n;){if(0===i)break a;i--,m+=e[g++]<>>=5,n-=5,c.ndist=(31&m)+1,m>>>=5,n-=5,c.ncode=(15&m)+4,m>>>=4,n-=4,c.nlen>286||c.ndist>30){a.msg="too many length or distance symbols",c.mode=lb;break}c.have=0,c.mode=_;case _:for(;c.haven;){if(0===i)break a;i--,m+=e[g++]<>>=3,n-=3}for(;c.have<19;)c.lens[Cb[c.have++]]=0;if(c.lencode=c.lendyn,c.lenbits=7,yb={bits:c.lenbits},xb=v(w,c.lens,0,19,c.lencode,0,c.work,yb),c.lenbits=yb.bits,xb){a.msg="invalid code lengths set",c.mode=lb;break}c.have=0,c.mode=ab;case ab:for(;c.have>>24,rb=Ab>>>16&255,sb=65535&Ab,!(n>=qb);){if(0===i)break a;i--,m+=e[g++]<sb)m>>>=qb,n-=qb,c.lens[c.have++]=sb;else{if(16===sb){for(zb=qb+2;zb>n;){if(0===i)break a;i--,m+=e[g++]<>>=qb,n-=qb,0===c.have){a.msg="invalid bit length repeat",c.mode=lb;break}wb=c.lens[c.have-1],q=3+(3&m),m>>>=2,n-=2}else if(17===sb){for(zb=qb+3;zb>n;){if(0===i)break a;i--,m+=e[g++]<>>=qb,n-=qb,wb=0,q=3+(7&m),m>>>=3,n-=3}else{for(zb=qb+7;zb>n;){if(0===i)break a;i--,m+=e[g++]<>>=qb,n-=qb,wb=0,q=11+(127&m),m>>>=7,n-=7}if(c.have+q>c.nlen+c.ndist){a.msg="invalid bit length repeat",c.mode=lb;break}for(;q--;)c.lens[c.have++]=wb}}if(c.mode===lb)break;if(0===c.lens[256]){a.msg="invalid code -- missing end-of-block",c.mode=lb;break}if(c.lenbits=9,yb={bits:c.lenbits},xb=v(x,c.lens,0,c.nlen,c.lencode,0,c.work,yb),c.lenbits=yb.bits,xb){a.msg="invalid literal/lengths set",c.mode=lb;break}if(c.distbits=6,c.distcode=c.distdyn,yb={bits:c.distbits},xb=v(y,c.lens,c.nlen,c.ndist,c.distcode,0,c.work,yb),c.distbits=yb.bits,xb){a.msg="invalid distances set",c.mode=lb;break}if(c.mode=bb,b===B)break a;case bb:c.mode=cb;case cb:if(i>=6&&j>=258){a.next_out=h,a.avail_out=j,a.next_in=g,a.avail_in=i,c.hold=m,c.bits=n,u(a,p),h=a.next_out,f=a.output,j=a.avail_out,g=a.next_in,e=a.input,i=a.avail_in,m=c.hold,n=c.bits,c.mode===V&&(c.back=-1); +break}for(c.back=0;Ab=c.lencode[m&(1<>>24,rb=Ab>>>16&255,sb=65535&Ab,!(n>=qb);){if(0===i)break a;i--,m+=e[g++]<>tb)],qb=Ab>>>24,rb=Ab>>>16&255,sb=65535&Ab,!(n>=tb+qb);){if(0===i)break a;i--,m+=e[g++]<>>=tb,n-=tb,c.back+=tb}if(m>>>=qb,n-=qb,c.back+=qb,c.length=sb,0===rb){c.mode=hb;break}if(32&rb){c.back=-1,c.mode=V;break}if(64&rb){a.msg="invalid literal/length code",c.mode=lb;break}c.extra=15&rb,c.mode=db;case db:if(c.extra){for(zb=c.extra;zb>n;){if(0===i)break a;i--,m+=e[g++]<>>=c.extra,n-=c.extra,c.back+=c.extra}c.was=c.length,c.mode=eb;case eb:for(;Ab=c.distcode[m&(1<>>24,rb=Ab>>>16&255,sb=65535&Ab,!(n>=qb);){if(0===i)break a;i--,m+=e[g++]<>tb)],qb=Ab>>>24,rb=Ab>>>16&255,sb=65535&Ab,!(n>=tb+qb);){if(0===i)break a;i--,m+=e[g++]<>>=tb,n-=tb,c.back+=tb}if(m>>>=qb,n-=qb,c.back+=qb,64&rb){a.msg="invalid distance code",c.mode=lb;break}c.offset=sb,c.extra=15&rb,c.mode=fb;case fb:if(c.extra){for(zb=c.extra;zb>n;){if(0===i)break a;i--,m+=e[g++]<>>=c.extra,n-=c.extra,c.back+=c.extra}if(c.offset>c.dmax){a.msg="invalid distance too far back",c.mode=lb;break}c.mode=gb;case gb:if(0===j)break a;if(q=p-j,c.offset>q){if(q=c.offset-q,q>c.whave&&c.sane){a.msg="invalid distance too far back",c.mode=lb;break}q>c.wnext?(q-=c.wnext,ob=c.wsize-q):ob=c.wnext-q,q>c.length&&(q=c.length),pb=c.window}else pb=f,ob=h-c.offset,q=c.length;q>j&&(q=j),j-=q,c.length-=q;do f[h++]=pb[ob++];while(--q);0===c.length&&(c.mode=cb);break;case hb:if(0===j)break a;f[h++]=c.length,j--,c.mode=cb;break;case ib:if(c.wrap){for(;32>n;){if(0===i)break a;i--,m|=e[g++]<n;){if(0===i)break a;i--,m+=e[g++]<=D;D++)P[D]=0;for(E=0;o>E;E++)P[b[n+E]]++;for(H=C,G=d;G>=1&&0===P[G];G--);if(H>G&&(H=G),0===G)return p[q++]=20971520,p[q++]=20971520,s.bits=1,0;for(F=1;G>F&&0===P[F];F++);for(F>H&&(H=F),K=1,D=1;d>=D;D++)if(K<<=1,K-=P[D],0>K)return-1;if(K>0&&(a===g||1!==G))return-1;for(Q[1]=0,D=1;d>D;D++)Q[D+1]=Q[D]+P[D];for(E=0;o>E;E++)0!==b[n+E]&&(r[Q[b[n+E]]++]=E);if(a===g?(N=R=r,y=19):a===h?(N=j,O-=257,R=k,S-=257,y=256):(N=l,R=m,y=-1),M=0,E=0,D=F,x=q,I=H,J=0,v=-1,L=1<e||a===i&&L>f)return 1;for(var T=0;;){T++,z=D-J,r[E]y?(A=R[S+r[E]],B=N[O+r[E]]):(A=96,B=0),t=1<>J)+u]=z<<24|A<<16|B|0;while(0!==u);for(t=1<>=1;if(0!==t?(M&=t-1,M+=t):M=0,E++,0===--P[D]){if(D===G)break;D=b[n+r[E]]}if(D>H&&(M&w)!==v){for(0===J&&(J=H),x+=F,I=D-J,K=1<I+J&&(K-=P[I+J],!(0>=K));)I++,K<<=1;if(L+=1<e||a===i&&L>f)return 1;v=M&w,p[v]=H<<24|I<<16|x-q|0}}return 0!==M&&(p[x+M]=D-J<<24|64<<16|0),s.bits=H,0}},{"../utils/common":27}],37:[function(a,b){"use strict";b.exports={2:"need dictionary",1:"stream end",0:"","-1":"file error","-2":"stream error","-3":"data error","-4":"insufficient memory","-5":"buffer error","-6":"incompatible version"}},{}],38:[function(a,b,c){"use strict";function d(a){for(var b=a.length;--b>=0;)a[b]=0}function e(a){return 256>a?gb[a]:gb[256+(a>>>7)]}function f(a,b){a.pending_buf[a.pending++]=255&b,a.pending_buf[a.pending++]=b>>>8&255}function g(a,b,c){a.bi_valid>V-c?(a.bi_buf|=b<>V-a.bi_valid,a.bi_valid+=c-V):(a.bi_buf|=b<>>=1,c<<=1;while(--b>0);return c>>>1}function j(a){16===a.bi_valid?(f(a,a.bi_buf),a.bi_buf=0,a.bi_valid=0):a.bi_valid>=8&&(a.pending_buf[a.pending++]=255&a.bi_buf,a.bi_buf>>=8,a.bi_valid-=8)}function k(a,b){var c,d,e,f,g,h,i=b.dyn_tree,j=b.max_code,k=b.stat_desc.static_tree,l=b.stat_desc.has_stree,m=b.stat_desc.extra_bits,n=b.stat_desc.extra_base,o=b.stat_desc.max_length,p=0;for(f=0;U>=f;f++)a.bl_count[f]=0;for(i[2*a.heap[a.heap_max]+1]=0,c=a.heap_max+1;T>c;c++)d=a.heap[c],f=i[2*i[2*d+1]+1]+1,f>o&&(f=o,p++),i[2*d+1]=f,d>j||(a.bl_count[f]++,g=0,d>=n&&(g=m[d-n]),h=i[2*d],a.opt_len+=h*(f+g),l&&(a.static_len+=h*(k[2*d+1]+g)));if(0!==p){do{for(f=o-1;0===a.bl_count[f];)f--;a.bl_count[f]--,a.bl_count[f+1]+=2,a.bl_count[o]--,p-=2}while(p>0);for(f=o;0!==f;f--)for(d=a.bl_count[f];0!==d;)e=a.heap[--c],e>j||(i[2*e+1]!==f&&(a.opt_len+=(f-i[2*e+1])*i[2*e],i[2*e+1]=f),d--)}}function l(a,b,c){var d,e,f=new Array(U+1),g=0;for(d=1;U>=d;d++)f[d]=g=g+c[d-1]<<1;for(e=0;b>=e;e++){var h=a[2*e+1];0!==h&&(a[2*e]=i(f[h]++,h))}}function m(){var a,b,c,d,e,f=new Array(U+1);for(c=0,d=0;O-1>d;d++)for(ib[d]=c,a=0;a<1<<_[d];a++)hb[c++]=d;for(hb[c-1]=d,e=0,d=0;16>d;d++)for(jb[d]=e,a=0;a<1<>=7;R>d;d++)for(jb[d]=e<<7,a=0;a<1<=b;b++)f[b]=0;for(a=0;143>=a;)eb[2*a+1]=8,a++,f[8]++;for(;255>=a;)eb[2*a+1]=9,a++,f[9]++;for(;279>=a;)eb[2*a+1]=7,a++,f[7]++;for(;287>=a;)eb[2*a+1]=8,a++,f[8]++;for(l(eb,Q+1,f),a=0;R>a;a++)fb[2*a+1]=5,fb[2*a]=i(a,5);kb=new nb(eb,_,P+1,Q,U),lb=new nb(fb,ab,0,R,U),mb=new nb(new Array(0),bb,0,S,W)}function n(a){var b;for(b=0;Q>b;b++)a.dyn_ltree[2*b]=0;for(b=0;R>b;b++)a.dyn_dtree[2*b]=0;for(b=0;S>b;b++)a.bl_tree[2*b]=0;a.dyn_ltree[2*X]=1,a.opt_len=a.static_len=0,a.last_lit=a.matches=0}function o(a){a.bi_valid>8?f(a,a.bi_buf):a.bi_valid>0&&(a.pending_buf[a.pending++]=a.bi_buf),a.bi_buf=0,a.bi_valid=0}function p(a,b,c,d){o(a),d&&(f(a,c),f(a,~c)),E.arraySet(a.pending_buf,a.window,b,c,a.pending),a.pending+=c}function q(a,b,c,d){var e=2*b,f=2*c;return a[e]c;c++)0!==f[2*c]?(a.heap[++a.heap_len]=j=c,a.depth[c]=0):f[2*c+1]=0;for(;a.heap_len<2;)e=a.heap[++a.heap_len]=2>j?++j:0,f[2*e]=1,a.depth[e]=0,a.opt_len--,h&&(a.static_len-=g[2*e+1]);for(b.max_code=j,c=a.heap_len>>1;c>=1;c--)r(a,f,c);e=i;do c=a.heap[1],a.heap[1]=a.heap[a.heap_len--],r(a,f,1),d=a.heap[1],a.heap[--a.heap_max]=c,a.heap[--a.heap_max]=d,f[2*e]=f[2*c]+f[2*d],a.depth[e]=(a.depth[c]>=a.depth[d]?a.depth[c]:a.depth[d])+1,f[2*c+1]=f[2*d+1]=e,a.heap[1]=e++,r(a,f,1);while(a.heap_len>=2);a.heap[--a.heap_max]=a.heap[1],k(a,b),l(f,j,a.bl_count)}function u(a,b,c){var d,e,f=-1,g=b[1],h=0,i=7,j=4;for(0===g&&(i=138,j=3),b[2*(c+1)+1]=65535,d=0;c>=d;d++)e=g,g=b[2*(d+1)+1],++hh?a.bl_tree[2*e]+=h:0!==e?(e!==f&&a.bl_tree[2*e]++,a.bl_tree[2*Y]++):10>=h?a.bl_tree[2*Z]++:a.bl_tree[2*$]++,h=0,f=e,0===g?(i=138,j=3):e===g?(i=6,j=3):(i=7,j=4))}function v(a,b,c){var d,e,f=-1,i=b[1],j=0,k=7,l=4;for(0===i&&(k=138,l=3),d=0;c>=d;d++)if(e=i,i=b[2*(d+1)+1],!(++jj){do h(a,e,a.bl_tree);while(0!==--j)}else 0!==e?(e!==f&&(h(a,e,a.bl_tree),j--),h(a,Y,a.bl_tree),g(a,j-3,2)):10>=j?(h(a,Z,a.bl_tree),g(a,j-3,3)):(h(a,$,a.bl_tree),g(a,j-11,7));j=0,f=e,0===i?(k=138,l=3):e===i?(k=6,l=3):(k=7,l=4)}}function w(a){var b;for(u(a,a.dyn_ltree,a.l_desc.max_code),u(a,a.dyn_dtree,a.d_desc.max_code),t(a,a.bl_desc),b=S-1;b>=3&&0===a.bl_tree[2*cb[b]+1];b--);return a.opt_len+=3*(b+1)+5+5+4,b}function x(a,b,c,d){var e;for(g(a,b-257,5),g(a,c-1,5),g(a,d-4,4),e=0;d>e;e++)g(a,a.bl_tree[2*cb[e]+1],3);v(a,a.dyn_ltree,b-1),v(a,a.dyn_dtree,c-1)}function y(a){var b,c=4093624447;for(b=0;31>=b;b++,c>>>=1)if(1&c&&0!==a.dyn_ltree[2*b])return G;if(0!==a.dyn_ltree[18]||0!==a.dyn_ltree[20]||0!==a.dyn_ltree[26])return H;for(b=32;P>b;b++)if(0!==a.dyn_ltree[2*b])return H;return G}function z(a){pb||(m(),pb=!0),a.l_desc=new ob(a.dyn_ltree,kb),a.d_desc=new ob(a.dyn_dtree,lb),a.bl_desc=new ob(a.bl_tree,mb),a.bi_buf=0,a.bi_valid=0,n(a)}function A(a,b,c,d){g(a,(J<<1)+(d?1:0),3),p(a,b,c,!0)}function B(a){g(a,K<<1,3),h(a,X,eb),j(a)}function C(a,b,c,d){var e,f,h=0;a.level>0?(a.strm.data_type===I&&(a.strm.data_type=y(a)),t(a,a.l_desc),t(a,a.d_desc),h=w(a),e=a.opt_len+3+7>>>3,f=a.static_len+3+7>>>3,e>=f&&(e=f)):e=f=c+5,e>=c+4&&-1!==b?A(a,b,c,d):a.strategy===F||f===e?(g(a,(K<<1)+(d?1:0),3),s(a,eb,fb)):(g(a,(L<<1)+(d?1:0),3),x(a,a.l_desc.max_code+1,a.d_desc.max_code+1,h+1),s(a,a.dyn_ltree,a.dyn_dtree)),n(a),d&&o(a)}function D(a,b,c){return a.pending_buf[a.d_buf+2*a.last_lit]=b>>>8&255,a.pending_buf[a.d_buf+2*a.last_lit+1]=255&b,a.pending_buf[a.l_buf+a.last_lit]=255&c,a.last_lit++,0===b?a.dyn_ltree[2*c]++:(a.matches++,b--,a.dyn_ltree[2*(hb[c]+P+1)]++,a.dyn_dtree[2*e(b)]++),a.last_lit===a.lit_bufsize-1}var E=a("../utils/common"),F=4,G=0,H=1,I=2,J=0,K=1,L=2,M=3,N=258,O=29,P=256,Q=P+1+O,R=30,S=19,T=2*Q+1,U=15,V=16,W=7,X=256,Y=16,Z=17,$=18,_=[0,0,0,0,0,0,0,0,1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4,5,5,5,5,0],ab=[0,0,0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9,9,10,10,11,11,12,12,13,13],bb=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,3,7],cb=[16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15],db=512,eb=new Array(2*(Q+2));d(eb);var fb=new Array(2*R);d(fb);var gb=new Array(db);d(gb);var hb=new Array(N-M+1);d(hb);var ib=new Array(O);d(ib);var jb=new Array(R);d(jb);var kb,lb,mb,nb=function(a,b,c,d,e){this.static_tree=a,this.extra_bits=b,this.extra_base=c,this.elems=d,this.max_length=e,this.has_stree=a&&a.length},ob=function(a,b){this.dyn_tree=a,this.max_code=0,this.stat_desc=b},pb=!1;c._tr_init=z,c._tr_stored_block=A,c._tr_flush_block=C,c._tr_tally=D,c._tr_align=B},{"../utils/common":27}],39:[function(a,b){"use strict";function c(){this.input=null,this.next_in=0,this.avail_in=0,this.total_in=0,this.output=null,this.next_out=0,this.avail_out=0,this.total_out=0,this.msg="",this.state=null,this.data_type=2,this.adler=0}b.exports=c},{}]},{},[9])(9)}); + +/*! + Copyright 2008-2021 SpryMedia Ltd. + + This source file is free software, available under the following license: + MIT license - http://datatables.net/license + + This source file 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 license files for details. + + For details please refer to: http://www.datatables.net + DataTables 1.11.5 + ©2008-2021 SpryMedia Ltd - datatables.net/license +*/ +var $jscomp=$jscomp||{};$jscomp.scope={};$jscomp.findInternal=function(l,z,A){l instanceof String&&(l=String(l));for(var q=l.length,E=0;E").css({position:"fixed",top:0,left:-1*l(z).scrollLeft(),height:1, +width:1,overflow:"hidden"}).append(l("
").css({position:"absolute",top:1,left:1,width:100,overflow:"scroll"}).append(l("
").css({width:"100%",height:10}))).appendTo("body"),d=c.children(),e=d.children();b.barWidth=d[0].offsetWidth-d[0].clientWidth;b.bScrollOversize=100===e[0].offsetWidth&&100!==d[0].clientWidth;b.bScrollbarLeft=1!==Math.round(e.offset().left);b.bBounding=c[0].getBoundingClientRect().width?!0:!1;c.remove()}l.extend(a.oBrowser,u.__browser);a.oScroll.iBarWidth=u.__browser.barWidth} +function Cb(a,b,c,d,e,h){var f=!1;if(c!==q){var g=c;f=!0}for(;d!==e;)a.hasOwnProperty(d)&&(g=f?b(g,a[d],d,a):a[d],f=!0,d+=h);return g}function Ya(a,b){var c=u.defaults.column,d=a.aoColumns.length;c=l.extend({},u.models.oColumn,c,{nTh:b?b:A.createElement("th"),sTitle:c.sTitle?c.sTitle:b?b.innerHTML:"",aDataSort:c.aDataSort?c.aDataSort:[d],mData:c.mData?c.mData:d,idx:d});a.aoColumns.push(c);c=a.aoPreSearchCols;c[d]=l.extend({},u.models.oSearch,c[d]);Ga(a,d,l(b).data())}function Ga(a,b,c){b=a.aoColumns[b]; +var d=a.oClasses,e=l(b.nTh);if(!b.sWidthOrig){b.sWidthOrig=e.attr("width")||null;var h=(e.attr("style")||"").match(/width:\s*(\d+[pxem%]+)/);h&&(b.sWidthOrig=h[1])}c!==q&&null!==c&&(Ab(c),P(u.defaults.column,c,!0),c.mDataProp===q||c.mData||(c.mData=c.mDataProp),c.sType&&(b._sManualType=c.sType),c.className&&!c.sClass&&(c.sClass=c.className),c.sClass&&e.addClass(c.sClass),l.extend(b,c),X(b,c,"sWidth","sWidthOrig"),c.iDataSort!==q&&(b.aDataSort=[c.iDataSort]),X(b,c,"aDataSort"));var f=b.mData,g=na(f), +k=b.mRender?na(b.mRender):null;c=function(m){return"string"===typeof m&&-1!==m.indexOf("@")};b._bAttrSrc=l.isPlainObject(f)&&(c(f.sort)||c(f.type)||c(f.filter));b._setter=null;b.fnGetData=function(m,n,p){var t=g(m,n,q,p);return k&&n?k(t,n,m,p):t};b.fnSetData=function(m,n,p){return ha(f)(m,n,p)};"number"!==typeof f&&(a._rowReadObject=!0);a.oFeatures.bSort||(b.bSortable=!1,e.addClass(d.sSortableNone));a=-1!==l.inArray("asc",b.asSorting);c=-1!==l.inArray("desc",b.asSorting);b.bSortable&&(a||c)?a&&!c? +(b.sSortingClass=d.sSortableAsc,b.sSortingClassJUI=d.sSortJUIAscAllowed):!a&&c?(b.sSortingClass=d.sSortableDesc,b.sSortingClassJUI=d.sSortJUIDescAllowed):(b.sSortingClass=d.sSortable,b.sSortingClassJUI=d.sSortJUI):(b.sSortingClass=d.sSortableNone,b.sSortingClassJUI="")}function sa(a){if(!1!==a.oFeatures.bAutoWidth){var b=a.aoColumns;Za(a);for(var c=0,d=b.length;cm[n])d(g.length+m[n],k);else if("string"===typeof m[n]){var p=0;for(f=g.length;pb&&a[e]--; -1!=d&&c===q&&a.splice(d,1)}function va(a,b,c,d){var e=a.aoData[b],h,f=function(k,m){for(;k.childNodes.length;)k.removeChild(k.firstChild);k.innerHTML=T(a,b,m,"display")};if("dom"!==c&&(c&&"auto"!==c||"dom"!==e.src)){var g=e.anCells;if(g)if(d!==q)f(g[d],d);else for(c=0,h=g.length;c").appendTo(d));var k=0;for(b=g.length;k=a.fnRecordsDisplay()?0:d,a.iInitDisplayStart=-1);c=F(a,"aoPreDrawCallback","preDraw",[a]);if(-1!==l.inArray(!1,c))V(a,!1);else{c=[];var e=0;d=a.asStripeClasses;var h=d.length,f=a.oLanguage,g="ssp"==Q(a),k=a.aiDisplay,m=a._iDisplayStart,n=a.fnDisplayEnd();a.bDrawing=!0;if(a.bDeferLoading)a.bDeferLoading=!1,a.iDraw++,V(a,!1);else if(!g)a.iDraw++;else if(!a.bDestroying&&!b){Gb(a);return}if(0!==k.length)for(b=g?a.aoData.length:n,f=g?0:m;f",{"class":h?d[0]:""}).append(l("",{valign:"top",colSpan:oa(a),"class":a.oClasses.sRowEmpty}).html(e))[0];F(a,"aoHeaderCallback","header",[l(a.nTHead).children("tr")[0],db(a),m,n,k]);F(a,"aoFooterCallback", +"footer",[l(a.nTFoot).children("tr")[0],db(a),m,n,k]);d=l(a.nTBody);d.children().detach();d.append(l(c));F(a,"aoDrawCallback","draw",[a]);a.bSorted=!1;a.bFiltered=!1;a.bDrawing=!1}}function ka(a,b){var c=a.oFeatures,d=c.bFilter;c.bSort&&Hb(a);d?ya(a,a.oPreviousSearch):a.aiDisplay=a.aiDisplayMaster.slice();!0!==b&&(a._iDisplayStart=0);a._drawHold=b;ja(a);a._drawHold=!1}function Ib(a){var b=a.oClasses,c=l(a.nTable);c=l("
").insertBefore(c);var d=a.oFeatures,e=l("
",{id:a.sTableId+"_wrapper", +"class":b.sWrapper+(a.nTFoot?"":" "+b.sNoFooter)});a.nHolding=c[0];a.nTableWrapper=e[0];a.nTableReinsertBefore=a.nTable.nextSibling;for(var h=a.sDom.split(""),f,g,k,m,n,p,t=0;t")[0];m=h[t+1];if("'"==m||'"'==m){n="";for(p=2;h[t+p]!=m;)n+=h[t+p],p++;"H"==n?n=b.sJUIHeader:"F"==n&&(n=b.sJUIFooter);-1!=n.indexOf(".")?(m=n.split("."),k.id=m[0].substr(1,m[0].length-1),k.className=m[1]):"#"==n.charAt(0)?k.id=n.substr(1,n.length-1):k.className=n;t+=p}e.append(k); +e=l(k)}else if(">"==g)e=e.parent();else if("l"==g&&d.bPaginate&&d.bLengthChange)f=Jb(a);else if("f"==g&&d.bFilter)f=Kb(a);else if("r"==g&&d.bProcessing)f=Lb(a);else if("t"==g)f=Mb(a);else if("i"==g&&d.bInfo)f=Nb(a);else if("p"==g&&d.bPaginate)f=Ob(a);else if(0!==u.ext.feature.length)for(k=u.ext.feature,p=0,m=k.length;p',g=d.sSearch;g=g.match(/_INPUT_/)?g.replace("_INPUT_",f):g+f;b=l("
",{id:h.f?null:c+"_filter","class":b.sFilter}).append(l("
").addClass(b.sLength);a.aanFeatures.l||(k[0].id=c+"_length");k.children().append(a.oLanguage.sLengthMenu.replace("_MENU_",e[0].outerHTML));l("select",k).val(a._iDisplayLength).on("change.DT",function(m){kb(a,l(this).val());ja(a)});l(a.nTable).on("length.dt.DT",function(m,n,p){a===n&&l("select",k).val(p)});return k[0]}function Ob(a){var b=a.sPaginationType,c=u.ext.pager[b],d="function"===typeof c,e=function(f){ja(f)};b=l("
").addClass(a.oClasses.sPaging+b)[0]; +var h=a.aanFeatures;d||c.fnInit(a,b,e);h.p||(b.id=a.sTableId+"_paginate",a.aoDrawCallback.push({fn:function(f){if(d){var g=f._iDisplayStart,k=f._iDisplayLength,m=f.fnRecordsDisplay(),n=-1===k;g=n?0:Math.ceil(g/k);k=n?1:Math.ceil(m/k);m=c(g,k);var p;n=0;for(p=h.p.length;nh&& +(d=0)):"first"==b?d=0:"previous"==b?(d=0<=e?d-e:0,0>d&&(d=0)):"next"==b?d+e",{id:a.aanFeatures.r?null:a.sTableId+"_processing","class":a.oClasses.sProcessing}).html(a.oLanguage.sProcessing).insertBefore(a.nTable)[0]}function V(a,b){a.oFeatures.bProcessing&&l(a.aanFeatures.r).css("display",b?"block":"none"); +F(a,null,"processing",[a,b])}function Mb(a){var b=l(a.nTable),c=a.oScroll;if(""===c.sX&&""===c.sY)return a.nTable;var d=c.sX,e=c.sY,h=a.oClasses,f=b.children("caption"),g=f.length?f[0]._captionSide:null,k=l(b[0].cloneNode(!1)),m=l(b[0].cloneNode(!1)),n=b.children("tfoot");n.length||(n=null);k=l("
",{"class":h.sScrollWrapper}).append(l("
",{"class":h.sScrollHead}).css({overflow:"hidden",position:"relative",border:0,width:d?d?K(d):null:"100%"}).append(l("
",{"class":h.sScrollHeadInner}).css({"box-sizing":"content-box", +width:c.sXInner||"100%"}).append(k.removeAttr("id").css("margin-left",0).append("top"===g?f:null).append(b.children("thead"))))).append(l("
",{"class":h.sScrollBody}).css({position:"relative",overflow:"auto",width:d?K(d):null}).append(b));n&&k.append(l("
",{"class":h.sScrollFoot}).css({overflow:"hidden",border:0,width:d?d?K(d):null:"100%"}).append(l("
",{"class":h.sScrollFootInner}).append(m.removeAttr("id").css("margin-left",0).append("bottom"===g?f:null).append(b.children("tfoot"))))); +b=k.children();var p=b[0];h=b[1];var t=n?b[2]:null;if(d)l(h).on("scroll.DT",function(v){v=this.scrollLeft;p.scrollLeft=v;n&&(t.scrollLeft=v)});l(h).css("max-height",e);c.bCollapse||l(h).css("height",e);a.nScrollHead=p;a.nScrollBody=h;a.nScrollFoot=t;a.aoDrawCallback.push({fn:Ha,sName:"scrolling"});return k[0]}function Ha(a){var b=a.oScroll,c=b.sX,d=b.sXInner,e=b.sY;b=b.iBarWidth;var h=l(a.nScrollHead),f=h[0].style,g=h.children("div"),k=g[0].style,m=g.children("table");g=a.nScrollBody;var n=l(g),p= +g.style,t=l(a.nScrollFoot).children("div"),v=t.children("table"),x=l(a.nTHead),w=l(a.nTable),r=w[0],C=r.style,G=a.nTFoot?l(a.nTFoot):null,aa=a.oBrowser,L=aa.bScrollOversize;U(a.aoColumns,"nTh");var O=[],I=[],H=[],ea=[],Y,Ba=function(D){D=D.style;D.paddingTop="0";D.paddingBottom="0";D.borderTopWidth="0";D.borderBottomWidth="0";D.height=0};var fa=g.scrollHeight>g.clientHeight;if(a.scrollBarVis!==fa&&a.scrollBarVis!==q)a.scrollBarVis=fa,sa(a);else{a.scrollBarVis=fa;w.children("thead, tfoot").remove(); +if(G){var ba=G.clone().prependTo(w);var la=G.find("tr");ba=ba.find("tr")}var mb=x.clone().prependTo(w);x=x.find("tr");fa=mb.find("tr");mb.find("th, td").removeAttr("tabindex");c||(p.width="100%",h[0].style.width="100%");l.each(Na(a,mb),function(D,W){Y=ta(a,D);W.style.width=a.aoColumns[Y].sWidth});G&&ca(function(D){D.style.width=""},ba);h=w.outerWidth();""===c?(C.width="100%",L&&(w.find("tbody").height()>g.offsetHeight||"scroll"==n.css("overflow-y"))&&(C.width=K(w.outerWidth()-b)),h=w.outerWidth()): +""!==d&&(C.width=K(d),h=w.outerWidth());ca(Ba,fa);ca(function(D){var W=z.getComputedStyle?z.getComputedStyle(D).width:K(l(D).width());H.push(D.innerHTML);O.push(W)},fa);ca(function(D,W){D.style.width=O[W]},x);l(fa).css("height",0);G&&(ca(Ba,ba),ca(function(D){ea.push(D.innerHTML);I.push(K(l(D).css("width")))},ba),ca(function(D,W){D.style.width=I[W]},la),l(ba).height(0));ca(function(D,W){D.innerHTML='
'+H[W]+"
";D.childNodes[0].style.height="0";D.childNodes[0].style.overflow= +"hidden";D.style.width=O[W]},fa);G&&ca(function(D,W){D.innerHTML='
'+ea[W]+"
";D.childNodes[0].style.height="0";D.childNodes[0].style.overflow="hidden";D.style.width=I[W]},ba);Math.round(w.outerWidth())g.offsetHeight||"scroll"==n.css("overflow-y")?h+b:h,L&&(g.scrollHeight>g.offsetHeight||"scroll"==n.css("overflow-y"))&&(C.width=K(la-b)),""!==c&&""===d||da(a,1,"Possible column misalignment",6)):la="100%";p.width=K(la);f.width=K(la); +G&&(a.nScrollFoot.style.width=K(la));!e&&L&&(p.height=K(r.offsetHeight+b));c=w.outerWidth();m[0].style.width=K(c);k.width=K(c);d=w.height()>g.clientHeight||"scroll"==n.css("overflow-y");e="padding"+(aa.bScrollbarLeft?"Left":"Right");k[e]=d?b+"px":"0px";G&&(v[0].style.width=K(c),t[0].style.width=K(c),t[0].style[e]=d?b+"px":"0px");w.children("colgroup").insertBefore(w.children("thead"));n.trigger("scroll");!a.bSorted&&!a.bFiltered||a._drawHold||(g.scrollTop=0)}}function ca(a,b,c){for(var d=0,e=0,h= +b.length,f,g;e").appendTo(g.find("tbody"));g.find("thead, tfoot").remove();g.append(l(a.nTHead).clone()).append(l(a.nTFoot).clone());g.find("tfoot th, tfoot td").css("width","");m=Na(a,g.find("thead")[0]);for(v=0;v").css({width:w.sWidthOrig,margin:0,padding:0,border:0,height:1}));if(a.aoData.length)for(v=0;v").css(h||e?{position:"absolute",top:0,left:0,height:1,right:0,overflow:"hidden"}:{}).append(g).appendTo(p);h&&f?g.width(f):h?(g.css("width","auto"),g.removeAttr("width"),g.width()").css("width",K(a)).appendTo(b||A.body);b=a[0].offsetWidth;a.remove();return b}function $b(a,b){var c= +ac(a,b);if(0>c)return null;var d=a.aoData[c];return d.nTr?d.anCells[b]:l("").html(T(a,c,b,"display"))[0]}function ac(a,b){for(var c,d=-1,e=-1,h=0,f=a.aoData.length;hd&&(d=c.length,e=h);return e}function K(a){return null===a?"0px":"number"==typeof a?0>a?"0px":a+"px":a.match(/\d$/)?a+"px":a}function pa(a){var b=[],c=a.aoColumns;var d=a.aaSortingFixed;var e=l.isPlainObject(d);var h=[];var f=function(n){n.length&& +!Array.isArray(n[0])?h.push(n):l.merge(h,n)};Array.isArray(d)&&f(d);e&&d.pre&&f(d.pre);f(a.aaSorting);e&&d.post&&f(d.post);for(a=0;aG?1:0;if(0!==C)return"asc"===r.dir?C:-C}C=c[n];G=c[p];return CG?1:0}):f.sort(function(n,p){var t,v=g.length,x=e[n]._aSortData,w=e[p]._aSortData;for(t=0;tG?1:0})}a.bSorted=!0}function cc(a){var b=a.aoColumns,c=pa(a);a=a.oLanguage.oAria;for(var d=0,e=b.length;d/g,"");var k=h.nTh;k.removeAttribute("aria-sort");h.bSortable&&(0e?e+1:3))}e= +0;for(h=d.length;ee?e+1:3))}a.aLastSort=d}function bc(a,b){var c=a.aoColumns[b],d=u.ext.order[c.sSortDataType],e;d&&(e=d.call(a.oInstance,a,b,ua(a,b)));for(var h,f=u.ext.type.order[c.sType+"-pre"],g=0,k=a.aoData.length;g=e.length?[0,m[1]]:m)}));b.search!==q&&l.extend(a.oPreviousSearch,Wb(b.search));if(b.columns){f=0;for(d=b.columns.length;f=c&&(b=c-d);b-=b%d;if(-1===d||0>b)b=0;a._iDisplayStart=b}function gb(a,b){a=a.renderer;var c=u.ext.renderer[b];return l.isPlainObject(a)&&a[b]?c[a[b]]||c._:"string"===typeof a?c[a]||c._:c._}function Q(a){return a.oFeatures.bServerSide? +"ssp":a.ajax||a.sAjaxSource?"ajax":"dom"}function Da(a,b){var c=ec.numbers_length,d=Math.floor(c/2);b<=c?a=qa(0,b):a<=d?(a=qa(0,c-2),a.push("ellipsis"),a.push(b-1)):(a>=b-1-d?a=qa(b-(c-2),b):(a=qa(a-d+2,a+d-1),a.push("ellipsis"),a.push(b-1)),a.splice(0,0,"ellipsis"),a.splice(0,0,0));a.DT_el="span";return a}function Xa(a){l.each({num:function(b){return Ua(b,a)},"num-fmt":function(b){return Ua(b,a,rb)},"html-num":function(b){return Ua(b,a,Va)},"html-num-fmt":function(b){return Ua(b,a,Va,rb)}},function(b, +c){M.type.order[b+a+"-pre"]=c;b.match(/^html\-/)&&(M.type.search[b+a]=M.type.search.html)})}function fc(a){return function(){var b=[Ta(this[u.ext.iApiIndex])].concat(Array.prototype.slice.call(arguments));return u.ext.internal[a].apply(this,b)}}var u=function(a,b){if(this instanceof u)return l(a).DataTable(b);b=a;this.$=function(f,g){return this.api(!0).$(f,g)};this._=function(f,g){return this.api(!0).rows(f,g).data()};this.api=function(f){return f?new B(Ta(this[M.iApiIndex])):new B(this)};this.fnAddData= +function(f,g){var k=this.api(!0);f=Array.isArray(f)&&(Array.isArray(f[0])||l.isPlainObject(f[0]))?k.rows.add(f):k.row.add(f);(g===q||g)&&k.draw();return f.flatten().toArray()};this.fnAdjustColumnSizing=function(f){var g=this.api(!0).columns.adjust(),k=g.settings()[0],m=k.oScroll;f===q||f?g.draw(!1):(""!==m.sX||""!==m.sY)&&Ha(k)};this.fnClearTable=function(f){var g=this.api(!0).clear();(f===q||f)&&g.draw()};this.fnClose=function(f){this.api(!0).row(f).child.hide()};this.fnDeleteRow=function(f,g,k){var m= +this.api(!0);f=m.rows(f);var n=f.settings()[0],p=n.aoData[f[0][0]];f.remove();g&&g.call(this,n,p);(k===q||k)&&m.draw();return p};this.fnDestroy=function(f){this.api(!0).destroy(f)};this.fnDraw=function(f){this.api(!0).draw(f)};this.fnFilter=function(f,g,k,m,n,p){n=this.api(!0);null===g||g===q?n.search(f,k,m,p):n.column(g).search(f,k,m,p);n.draw()};this.fnGetData=function(f,g){var k=this.api(!0);if(f!==q){var m=f.nodeName?f.nodeName.toLowerCase():"";return g!==q||"td"==m||"th"==m?k.cell(f,g).data(): +k.row(f).data()||null}return k.data().toArray()};this.fnGetNodes=function(f){var g=this.api(!0);return f!==q?g.row(f).node():g.rows().nodes().flatten().toArray()};this.fnGetPosition=function(f){var g=this.api(!0),k=f.nodeName.toUpperCase();return"TR"==k?g.row(f).index():"TD"==k||"TH"==k?(f=g.cell(f).index(),[f.row,f.columnVisible,f.column]):null};this.fnIsOpen=function(f){return this.api(!0).row(f).child.isShown()};this.fnOpen=function(f,g,k){return this.api(!0).row(f).child(g,k).show().child()[0]}; +this.fnPageChange=function(f,g){f=this.api(!0).page(f);(g===q||g)&&f.draw(!1)};this.fnSetColumnVis=function(f,g,k){f=this.api(!0).column(f).visible(g);(k===q||k)&&f.columns.adjust().draw()};this.fnSettings=function(){return Ta(this[M.iApiIndex])};this.fnSort=function(f){this.api(!0).order(f).draw()};this.fnSortListener=function(f,g,k){this.api(!0).order.listener(f,g,k)};this.fnUpdate=function(f,g,k,m,n){var p=this.api(!0);k===q||null===k?p.row(g).data(f):p.cell(g,k).data(f);(n===q||n)&&p.columns.adjust(); +(m===q||m)&&p.draw();return 0};this.fnVersionCheck=M.fnVersionCheck;var c=this,d=b===q,e=this.length;d&&(b={});this.oApi=this.internal=M.internal;for(var h in u.ext.internal)h&&(this[h]=fc(h));this.each(function(){var f={},g=1").appendTo(t));r.nTHead=H[0];var ea=t.children("tbody");0===ea.length&&(ea=l("").insertAfter(H));r.nTBody=ea[0];H=t.children("tfoot");0===H.length&&0").appendTo(t));0===H.length||0===H.children().length?t.addClass(C.sNoFooter):0/g,vc=/^\d{2,4}[\.\/\-]\d{1,2}[\.\/\-]\d{1,2}([T ]{1}\d{1,2}[:\.]\d{2}([\.:]\d{2})?)?$/,wc=/(\/|\.|\*|\+|\?|\||\(|\)|\[|\]|\{|\}|\\|\$|\^|\-)/g,rb=/['\u00A0,$£€¥%\u2009\u202F\u20BD\u20a9\u20BArfkɃΞ]/gi,Z=function(a){return a&&!0!==a&&"-"!==a?!1:!0},hc= +function(a){var b=parseInt(a,10);return!isNaN(b)&&isFinite(a)?b:null},ic=function(a,b){sb[b]||(sb[b]=new RegExp(jb(b),"g"));return"string"===typeof a&&"."!==b?a.replace(/\./g,"").replace(sb[b],"."):a},tb=function(a,b,c){var d="string"===typeof a;if(Z(a))return!0;b&&d&&(a=ic(a,b));c&&d&&(a=a.replace(rb,""));return!isNaN(parseFloat(a))&&isFinite(a)},jc=function(a,b,c){return Z(a)?!0:Z(a)||"string"===typeof a?tb(a.replace(Va,""),b,c)?!0:null:null},U=function(a,b,c){var d=[],e=0,h=a.length;if(c!==q)for(;e< +h;e++)a[e]&&a[e][b]&&d.push(a[e][b][c]);else for(;ea.length)){var b=a.slice().sort();for(var c=b[0],d=1,e=b.length;d< +e;d++){if(b[d]===c){b=!1;break a}c=b[d]}}b=!0}if(b)return a.slice();b=[];e=a.length;var h,f=0;d=0;a:for(;d")[0],tc=Qa.textContent!==q,uc=/<.*?>/g,hb=u.util.throttle,nc=[],N=Array.prototype,xc=function(a){var b,c=u.settings,d=l.map(c,function(h,f){return h.nTable});if(a){if(a.nTable&&a.oApi)return[a];if(a.nodeName&&"table"===a.nodeName.toLowerCase()){var e= +l.inArray(a,d);return-1!==e?[c[e]]:null}if(a&&"function"===typeof a.settings)return a.settings().toArray();"string"===typeof a?b=l(a):a instanceof l&&(b=a)}else return[];if(b)return b.map(function(h){e=l.inArray(this,d);return-1!==e?c[e]:null}).toArray()};var B=function(a,b){if(!(this instanceof B))return new B(a,b);var c=[],d=function(f){(f=xc(f))&&c.push.apply(c,f)};if(Array.isArray(a))for(var e=0,h=a.length;ea?new B(b[a],this[a]):null},filter:function(a){var b=[];if(N.filter)b=N.filter.call(this,a,this);else for(var c=0,d=this.length;c").addClass(g),l("td",k).addClass(g).html(f)[0].colSpan=oa(a),e.push(k[0]))};h(c,d);b._details&&b._details.detach();b._details=l(e);b._detailsShow&&b._details.insertAfter(b.nTr)},qc=u.util.throttle(function(a){Ca(a[0])},500),xb=function(a,b){var c=a.context;c.length&&(a=c[0].aoData[b!== +q?b:a[0]])&&a._details&&(a._details.remove(),a._detailsShow=q,a._details=q,l(a.nTr).removeClass("dt-hasChild"),qc(c))},rc=function(a,b){var c=a.context;if(c.length&&a.length){var d=c[0].aoData[a[0]];d._details&&((d._detailsShow=b)?(d._details.insertAfter(d.nTr),l(d.nTr).addClass("dt-hasChild")):(d._details.detach(),l(d.nTr).removeClass("dt-hasChild")),F(c[0],null,"childRow",[b,a.row(a[0])]),Ac(c[0]),qc(c))}},Ac=function(a){var b=new B(a),c=a.aoData;b.off("draw.dt.DT_details column-visibility.dt.DT_details destroy.dt.DT_details"); +0g){var n=l.map(d,function(p,t){return p.bVisible?t:null});return[n[n.length+g]]}return[ta(a,g)];case "name":return l.map(e,function(p,t){return p===m[1]?t:null});default:return[]}if(f.nodeName&&f._DT_CellIndex)return[f._DT_CellIndex.column];g=l(h).filter(f).map(function(){return l.inArray(this,h)}).toArray();if(g.length||!f.nodeName)return g;g=l(f).closest("*[data-dt-column]");return g.length?[g.data("dt-column")]:[]},a,c)}; +y("columns()",function(a,b){a===q?a="":l.isPlainObject(a)&&(b=a,a="");b=vb(b);var c=this.iterator("table",function(d){return Cc(d,a,b)},1);c.selector.cols=a;c.selector.opts=b;return c});J("columns().header()","column().header()",function(a,b){return this.iterator("column",function(c,d){return c.aoColumns[d].nTh},1)});J("columns().footer()","column().footer()",function(a,b){return this.iterator("column",function(c,d){return c.aoColumns[d].nTf},1)});J("columns().data()","column().data()",function(){return this.iterator("column-rows", +sc,1)});J("columns().dataSrc()","column().dataSrc()",function(){return this.iterator("column",function(a,b){return a.aoColumns[b].mData},1)});J("columns().cache()","column().cache()",function(a){return this.iterator("column-rows",function(b,c,d,e,h){return Ea(b.aoData,h,"search"===a?"_aFilterData":"_aSortData",c)},1)});J("columns().nodes()","column().nodes()",function(){return this.iterator("column-rows",function(a,b,c,d,e){return Ea(a.aoData,e,"anCells",b)},1)});J("columns().visible()","column().visible()", +function(a,b){var c=this,d=this.iterator("column",function(e,h){if(a===q)return e.aoColumns[h].bVisible;var f=e.aoColumns,g=f[h],k=e.aoData,m;if(a!==q&&g.bVisible!==a){if(a){var n=l.inArray(!0,U(f,"bVisible"),h+1);f=0;for(m=k.length;fd;return!0};u.isDataTable=u.fnIsDataTable=function(a){var b=l(a).get(0),c=!1;if(a instanceof u.Api)return!0;l.each(u.settings,function(d,e){d=e.nScrollHead?l("table",e.nScrollHead)[0]:null;var h=e.nScrollFoot?l("table",e.nScrollFoot)[0]:null;if(e.nTable===b||d===b||h===b)c=!0});return c};u.tables=u.fnTables=function(a){var b= +!1;l.isPlainObject(a)&&(b=a.api,a=a.visible);var c=l.map(u.settings,function(d){if(!a||a&&l(d.nTable).is(":visible"))return d.nTable});return b?new B(c):c};u.camelToHungarian=P;y("$()",function(a,b){b=this.rows(b).nodes();b=l(b);return l([].concat(b.filter(a).toArray(),b.find(a).toArray()))});l.each(["on","one","off"],function(a,b){y(b+"()",function(){var c=Array.prototype.slice.call(arguments);c[0]=l.map(c[0].split(/\s/),function(e){return e.match(/\.dt\b/)?e:e+".dt"}).join(" ");var d=l(this.tables().nodes()); +d[b].apply(d,c);return this})});y("clear()",function(){return this.iterator("table",function(a){Ka(a)})});y("settings()",function(){return new B(this.context,this.context)});y("init()",function(){var a=this.context;return a.length?a[0].oInit:null});y("data()",function(){return this.iterator("table",function(a){return U(a.aoData,"_aData")}).flatten()});y("destroy()",function(a){a=a||!1;return this.iterator("table",function(b){var c=b.nTableWrapper.parentNode,d=b.oClasses,e=b.nTable,h=b.nTBody,f=b.nTHead, +g=b.nTFoot,k=l(e);h=l(h);var m=l(b.nTableWrapper),n=l.map(b.aoData,function(t){return t.nTr}),p;b.bDestroying=!0;F(b,"aoDestroyCallback","destroy",[b]);a||(new B(b)).columns().visible(!0);m.off(".DT").find(":not(tbody *)").off(".DT");l(z).off(".DT-"+b.sInstance);e!=f.parentNode&&(k.children("thead").detach(),k.append(f));g&&e!=g.parentNode&&(k.children("tfoot").detach(),k.append(g));b.aaSorting=[];b.aaSortingFixed=[];Sa(b);l(n).removeClass(b.asStripeClasses.join(" "));l("th, td",f).removeClass(d.sSortable+ +" "+d.sSortableAsc+" "+d.sSortableDesc+" "+d.sSortableNone);h.children().detach();h.append(n);f=a?"remove":"detach";k[f]();m[f]();!a&&c&&(c.insertBefore(e,b.nTableReinsertBefore),k.css("width",b.sDestroyWidth).removeClass(d.sTable),(p=b.asDestroyStripes.length)&&h.children().each(function(t){l(this).addClass(b.asDestroyStripes[t%p])}));c=l.inArray(b,u.settings);-1!==c&&u.settings.splice(c,1)})});l.each(["column","row","cell"],function(a,b){y(b+"s().every()",function(c){var d=this.selector.opts,e= +this;return this.iterator(b,function(h,f,g,k,m){c.call(e[b](f,"cell"===b?g:d,"cell"===b?d:q),f,g,k,m)})})});y("i18n()",function(a,b,c){var d=this.context[0];a=na(a)(d.oLanguage);a===q&&(a=b);c!==q&&l.isPlainObject(a)&&(a=a[c]!==q?a[c]:a._);return a.replace("%d",c)});u.version="1.11.5";u.settings=[];u.models={};u.models.oSearch={bCaseInsensitive:!0,sSearch:"",bRegex:!1,bSmart:!0,"return":!1};u.models.oRow={nTr:null,anCells:null,_aData:[],_aSortData:null,_aFilterData:null,_sFilterRow:null,_sRowStripe:"", +src:null,idx:-1};u.models.oColumn={idx:null,aDataSort:null,asSorting:null,bSearchable:null,bSortable:null,bVisible:null,_sManualType:null,_bAttrSrc:!1,fnCreatedCell:null,fnGetData:null,fnSetData:null,mData:null,mRender:null,nTh:null,nTf:null,sClass:null,sContentPadding:null,sDefaultContent:null,sName:null,sSortDataType:"std",sSortingClass:null,sSortingClassJUI:null,sTitle:null,sType:null,sWidth:null,sWidthOrig:null};u.defaults={aaData:null,aaSorting:[[0,"asc"]],aaSortingFixed:[],ajax:null,aLengthMenu:[10, +25,50,100],aoColumns:null,aoColumnDefs:null,aoSearchCols:[],asStripeClasses:null,bAutoWidth:!0,bDeferRender:!1,bDestroy:!1,bFilter:!0,bInfo:!0,bLengthChange:!0,bPaginate:!0,bProcessing:!1,bRetrieve:!1,bScrollCollapse:!1,bServerSide:!1,bSort:!0,bSortMulti:!0,bSortCellsTop:!1,bSortClasses:!0,bStateSave:!1,fnCreatedRow:null,fnDrawCallback:null,fnFooterCallback:null,fnFormatNumber:function(a){return a.toString().replace(/\B(?=(\d{3})+(?!\d))/g,this.oLanguage.sThousands)},fnHeaderCallback:null,fnInfoCallback:null, +fnInitComplete:null,fnPreDrawCallback:null,fnRowCallback:null,fnServerData:null,fnServerParams:null,fnStateLoadCallback:function(a){try{return JSON.parse((-1===a.iStateDuration?sessionStorage:localStorage).getItem("DataTables_"+a.sInstance+"_"+location.pathname))}catch(b){return{}}},fnStateLoadParams:null,fnStateLoaded:null,fnStateSaveCallback:function(a,b){try{(-1===a.iStateDuration?sessionStorage:localStorage).setItem("DataTables_"+a.sInstance+"_"+location.pathname,JSON.stringify(b))}catch(c){}}, +fnStateSaveParams:null,iStateDuration:7200,iDeferLoading:null,iDisplayLength:10,iDisplayStart:0,iTabIndex:0,oClasses:{},oLanguage:{oAria:{sSortAscending:": activate to sort column ascending",sSortDescending:": activate to sort column descending"},oPaginate:{sFirst:"First",sLast:"Last",sNext:"Next",sPrevious:"Previous"},sEmptyTable:"No data available in table",sInfo:"Showing _START_ to _END_ of _TOTAL_ entries",sInfoEmpty:"Showing 0 to 0 of 0 entries",sInfoFiltered:"(filtered from _MAX_ total entries)", +sInfoPostFix:"",sDecimal:"",sThousands:",",sLengthMenu:"Show _MENU_ entries",sLoadingRecords:"Loading...",sProcessing:"Processing...",sSearch:"Search:",sSearchPlaceholder:"",sUrl:"",sZeroRecords:"No matching records found"},oSearch:l.extend({},u.models.oSearch),sAjaxDataProp:"data",sAjaxSource:null,sDom:"lfrtip",searchDelay:null,sPaginationType:"simple_numbers",sScrollX:"",sScrollXInner:"",sScrollY:"",sServerMethod:"GET",renderer:null,rowId:"DT_RowId"};E(u.defaults);u.defaults.column={aDataSort:null, +iDataSort:-1,asSorting:["asc","desc"],bSearchable:!0,bSortable:!0,bVisible:!0,fnCreatedCell:null,mData:null,mRender:null,sCellType:"td",sClass:"",sContentPadding:"",sDefaultContent:null,sName:"",sSortDataType:"std",sTitle:null,sType:null,sWidth:null};E(u.defaults.column);u.models.oSettings={oFeatures:{bAutoWidth:null,bDeferRender:null,bFilter:null,bInfo:null,bLengthChange:null,bPaginate:null,bProcessing:null,bServerSide:null,bSort:null,bSortMulti:null,bSortClasses:null,bStateSave:null},oScroll:{bCollapse:null, +iBarWidth:0,sX:null,sXInner:null,sY:null},oLanguage:{fnInfoCallback:null},oBrowser:{bScrollOversize:!1,bScrollbarLeft:!1,bBounding:!1,barWidth:0},ajax:null,aanFeatures:[],aoData:[],aiDisplay:[],aiDisplayMaster:[],aIds:{},aoColumns:[],aoHeader:[],aoFooter:[],oPreviousSearch:{},aoPreSearchCols:[],aaSorting:null,aaSortingFixed:[],asStripeClasses:null,asDestroyStripes:[],sDestroyWidth:0,aoRowCallback:[],aoHeaderCallback:[],aoFooterCallback:[],aoDrawCallback:[],aoRowCreatedCallback:[],aoPreDrawCallback:[], +aoInitComplete:[],aoStateSaveParams:[],aoStateLoadParams:[],aoStateLoaded:[],sTableId:"",nTable:null,nTHead:null,nTFoot:null,nTBody:null,nTableWrapper:null,bDeferLoading:!1,bInitialised:!1,aoOpenRows:[],sDom:null,searchDelay:null,sPaginationType:"two_button",iStateDuration:0,aoStateSave:[],aoStateLoad:[],oSavedState:null,oLoadedState:null,sAjaxSource:null,sAjaxDataProp:null,jqXHR:null,json:q,oAjaxData:q,fnServerData:null,aoServerParams:[],sServerMethod:null,fnFormatNumber:null,aLengthMenu:null,iDraw:0, +bDrawing:!1,iDrawError:-1,_iDisplayLength:10,_iDisplayStart:0,_iRecordsTotal:0,_iRecordsDisplay:0,oClasses:{},bFiltered:!1,bSorted:!1,bSortCellsTop:null,oInit:null,aoDestroyCallback:[],fnRecordsTotal:function(){return"ssp"==Q(this)?1*this._iRecordsTotal:this.aiDisplayMaster.length},fnRecordsDisplay:function(){return"ssp"==Q(this)?1*this._iRecordsDisplay:this.aiDisplay.length},fnDisplayEnd:function(){var a=this._iDisplayLength,b=this._iDisplayStart,c=b+a,d=this.aiDisplay.length,e=this.oFeatures,h= +e.bPaginate;return e.bServerSide?!1===h||-1===a?b+d:Math.min(b+a,this._iRecordsDisplay):!h||c>d||-1===a?d:c},oInstance:null,sInstance:null,iTabIndex:0,nScrollHead:null,nScrollFoot:null,aLastSort:[],oPlugins:{},rowIdFn:null,rowId:null};u.ext=M={buttons:{},classes:{},builder:"dt/jszip-2.5.0/dt-1.11.5/b-2.2.2/b-colvis-2.2.2/b-html5-2.2.2/b-print-2.2.2/cr-1.5.5/date-1.1.2/fc-4.0.2/fh-3.2.2/kt-2.6.4/r-2.2.9/rg-1.1.4/rr-1.2.8/sc-2.0.5/sb-1.3.2/sp-2.0.0/sl-1.3.4/sr-1.1.0",errMode:"alert",feature:[],search:[],selector:{cell:[],column:[],row:[]},internal:{},legacy:{ajax:null},pager:{},renderer:{pageButton:{},header:{}},order:{},type:{detect:[],search:{},order:{}},_unique:0,fnVersionCheck:u.fnVersionCheck, +iApiIndex:0,oJUIClasses:{},sVersion:u.version};l.extend(M,{afnFiltering:M.search,aTypes:M.type.detect,ofnSearch:M.type.search,oSort:M.type.order,afnSortData:M.order,aoFeatures:M.feature,oApi:M.internal,oStdClasses:M.classes,oPagination:M.pager});l.extend(u.ext.classes,{sTable:"dataTable",sNoFooter:"no-footer",sPageButton:"paginate_button",sPageButtonActive:"current",sPageButtonDisabled:"disabled",sStripeOdd:"odd",sStripeEven:"even",sRowEmpty:"dataTables_empty",sWrapper:"dataTables_wrapper",sFilter:"dataTables_filter", +sInfo:"dataTables_info",sPaging:"dataTables_paginate paging_",sLength:"dataTables_length",sProcessing:"dataTables_processing",sSortAsc:"sorting_asc",sSortDesc:"sorting_desc",sSortable:"sorting",sSortableAsc:"sorting_desc_disabled",sSortableDesc:"sorting_asc_disabled",sSortableNone:"sorting_disabled",sSortColumn:"sorting_",sFilterInput:"",sLengthSelect:"",sScrollWrapper:"dataTables_scroll",sScrollHead:"dataTables_scrollHead",sScrollHeadInner:"dataTables_scrollHeadInner",sScrollBody:"dataTables_scrollBody", +sScrollFoot:"dataTables_scrollFoot",sScrollFootInner:"dataTables_scrollFootInner",sHeaderTH:"",sFooterTH:"",sSortJUIAsc:"",sSortJUIDesc:"",sSortJUI:"",sSortJUIAscAllowed:"",sSortJUIDescAllowed:"",sSortJUIWrapper:"",sSortIcon:"",sJUIHeader:"",sJUIFooter:""});var ec=u.ext.pager;l.extend(ec,{simple:function(a,b){return["previous","next"]},full:function(a,b){return["first","previous","next","last"]},numbers:function(a,b){return[Da(a,b)]},simple_numbers:function(a,b){return["previous",Da(a,b),"next"]}, +full_numbers:function(a,b){return["first","previous",Da(a,b),"next","last"]},first_last_numbers:function(a,b){return["first",Da(a,b),"last"]},_numbers:Da,numbers_length:7});l.extend(!0,u.ext.renderer,{pageButton:{_:function(a,b,c,d,e,h){var f=a.oClasses,g=a.oLanguage.oPaginate,k=a.oLanguage.oAria.paginate||{},m,n,p=0,t=function(x,w){var r,C=f.sPageButtonDisabled,G=function(I){Ra(a,I.data.action,!0)};var aa=0;for(r=w.length;aa").appendTo(x); +t(O,L)}else{m=null;n=L;O=a.iTabIndex;switch(L){case "ellipsis":x.append('');break;case "first":m=g.sFirst;0===e&&(O=-1,n+=" "+C);break;case "previous":m=g.sPrevious;0===e&&(O=-1,n+=" "+C);break;case "next":m=g.sNext;if(0===h||e===h-1)O=-1,n+=" "+C;break;case "last":m=g.sLast;if(0===h||e===h-1)O=-1,n+=" "+C;break;default:m=a.fnFormatNumber(L+1),n=e===L?f.sPageButtonActive:""}null!==m&&(O=l("",{"class":f.sPageButton+" "+n,"aria-controls":a.sTableId,"aria-label":k[L], +"data-dt-idx":p,tabindex:O,id:0===c&&"string"===typeof L?a.sTableId+"_"+L:null}).html(m).appendTo(x),ob(O,{action:L},G),p++)}}};try{var v=l(b).find(A.activeElement).data("dt-idx")}catch(x){}t(l(b).empty(),d);v!==q&&l(b).find("[data-dt-idx="+v+"]").trigger("focus")}}});l.extend(u.ext.type.detect,[function(a,b){b=b.oLanguage.sDecimal;return tb(a,b)?"num"+b:null},function(a,b){if(a&&!(a instanceof Date)&&!vc.test(a))return null;b=Date.parse(a);return null!==b&&!isNaN(b)||Z(a)?"date":null},function(a, +b){b=b.oLanguage.sDecimal;return tb(a,b,!0)?"num-fmt"+b:null},function(a,b){b=b.oLanguage.sDecimal;return jc(a,b)?"html-num"+b:null},function(a,b){b=b.oLanguage.sDecimal;return jc(a,b,!0)?"html-num-fmt"+b:null},function(a,b){return Z(a)||"string"===typeof a&&-1!==a.indexOf("<")?"html":null}]);l.extend(u.ext.type.search,{html:function(a){return Z(a)?a:"string"===typeof a?a.replace(gc," ").replace(Va,""):""},string:function(a){return Z(a)?a:"string"===typeof a?a.replace(gc," "):a}});var Ua=function(a, +b,c,d){if(0!==a&&(!a||"-"===a))return-Infinity;b&&(a=ic(a,b));a.replace&&(c&&(a=a.replace(c,"")),d&&(a=a.replace(d,"")));return 1*a};l.extend(M.type.order,{"date-pre":function(a){a=Date.parse(a);return isNaN(a)?-Infinity:a},"html-pre":function(a){return Z(a)?"":a.replace?a.replace(/<.*?>/g,"").toLowerCase():a+""},"string-pre":function(a){return Z(a)?"":"string"===typeof a?a.toLowerCase():a.toString?a.toString():""},"string-asc":function(a,b){return ab?1:0},"string-desc":function(a,b){return a< +b?1:a>b?-1:0}});Xa("");l.extend(!0,u.ext.renderer,{header:{_:function(a,b,c,d){l(a.nTable).on("order.dt.DT",function(e,h,f,g){a===h&&(e=c.idx,b.removeClass(d.sSortAsc+" "+d.sSortDesc).addClass("asc"==g[e]?d.sSortAsc:"desc"==g[e]?d.sSortDesc:c.sSortingClass))})},jqueryui:function(a,b,c,d){l("
").addClass(d.sSortJUIWrapper).append(b.contents()).append(l("").addClass(d.sSortIcon+" "+c.sSortingClassJUI)).appendTo(b);l(a.nTable).on("order.dt.DT",function(e,h,f,g){a===h&&(e=c.idx,b.removeClass(d.sSortAsc+ +" "+d.sSortDesc).addClass("asc"==g[e]?d.sSortAsc:"desc"==g[e]?d.sSortDesc:c.sSortingClass),b.find("span."+d.sSortIcon).removeClass(d.sSortJUIAsc+" "+d.sSortJUIDesc+" "+d.sSortJUI+" "+d.sSortJUIAscAllowed+" "+d.sSortJUIDescAllowed).addClass("asc"==g[e]?d.sSortJUIAsc:"desc"==g[e]?d.sSortJUIDesc:c.sSortingClassJUI))})}}});var yb=function(a){Array.isArray(a)&&(a=a.join(","));return"string"===typeof a?a.replace(/&/g,"&").replace(//g,">").replace(/"/g,"""):a};u.render= +{number:function(a,b,c,d,e){return{display:function(h){if("number"!==typeof h&&"string"!==typeof h)return h;var f=0>h?"-":"",g=parseFloat(h);if(isNaN(g))return yb(h);g=g.toFixed(c);h=Math.abs(g);g=parseInt(h,10);h=c?b+(h-g).toFixed(c).substring(2):"";0===g&&0===parseFloat(h)&&(f="");return f+(d||"")+g.toString().replace(/\B(?=(\d{3})+(?!\d))/g,a)+h+(e||"")}}},text:function(){return{display:yb,filter:yb}}};l.extend(u.ext.internal,{_fnExternApiFunc:fc,_fnBuildAjax:Oa,_fnAjaxUpdate:Gb,_fnAjaxParameters:Pb, +_fnAjaxUpdateDraw:Qb,_fnAjaxDataSrc:za,_fnAddColumn:Ya,_fnColumnOptions:Ga,_fnAdjustColumnSizing:sa,_fnVisibleToColumnIndex:ta,_fnColumnIndexToVisible:ua,_fnVisbleColumns:oa,_fnGetColumns:Ia,_fnColumnTypes:$a,_fnApplyColumnDefs:Db,_fnHungarianMap:E,_fnCamelToHungarian:P,_fnLanguageCompat:ma,_fnBrowserDetect:Bb,_fnAddData:ia,_fnAddTr:Ja,_fnNodeToDataIndex:function(a,b){return b._DT_RowIndex!==q?b._DT_RowIndex:null},_fnNodeToColumnIndex:function(a,b,c){return l.inArray(c,a.aoData[b].anCells)},_fnGetCellData:T, +_fnSetCellData:Eb,_fnSplitObjNotation:cb,_fnGetObjectDataFn:na,_fnSetObjectDataFn:ha,_fnGetDataMaster:db,_fnClearTable:Ka,_fnDeleteIndex:La,_fnInvalidate:va,_fnGetRowElements:bb,_fnCreateTr:ab,_fnBuildHead:Fb,_fnDrawHead:xa,_fnDraw:ja,_fnReDraw:ka,_fnAddOptionsHtml:Ib,_fnDetectHeader:wa,_fnGetUniqueThs:Na,_fnFeatureHtmlFilter:Kb,_fnFilterComplete:ya,_fnFilterCustom:Tb,_fnFilterColumn:Sb,_fnFilter:Rb,_fnFilterCreateSearch:ib,_fnEscapeRegex:jb,_fnFilterData:Ub,_fnFeatureHtmlInfo:Nb,_fnUpdateInfo:Xb, +_fnInfoMacros:Yb,_fnInitialise:Aa,_fnInitComplete:Pa,_fnLengthChange:kb,_fnFeatureHtmlLength:Jb,_fnFeatureHtmlPaginate:Ob,_fnPageChange:Ra,_fnFeatureHtmlProcessing:Lb,_fnProcessingDisplay:V,_fnFeatureHtmlTable:Mb,_fnScrollDraw:Ha,_fnApplyToChildren:ca,_fnCalculateColumnWidths:Za,_fnThrottle:hb,_fnConvertToWidth:Zb,_fnGetWidestNode:$b,_fnGetMaxLenString:ac,_fnStringToCss:K,_fnSortFlatten:pa,_fnSort:Hb,_fnSortAria:cc,_fnSortListener:nb,_fnSortAttachListener:fb,_fnSortingClasses:Sa,_fnSortData:bc,_fnSaveState:Ca, +_fnLoadState:dc,_fnImplementState:pb,_fnSettingsFromNode:Ta,_fnLog:da,_fnMap:X,_fnBindAction:ob,_fnCallbackReg:R,_fnCallbackFire:F,_fnLengthOverflow:lb,_fnRenderer:gb,_fnDataSource:Q,_fnRowAttributes:eb,_fnExtend:qb,_fnCalculateEnd:function(){}});l.fn.dataTable=u;u.$=l;l.fn.dataTableSettings=u.settings;l.fn.dataTableExt=u.ext;l.fn.DataTable=function(a){return l(this).dataTable(a).api()};l.each(u,function(a,b){l.fn.DataTable[a]=b});return u}); + + +/*! + DataTables styling integration + ©2018 SpryMedia Ltd - datatables.net/license +*/ +(function(c){"function"===typeof define&&define.amd?define(["jquery","datatables.net"],function(a){return c(a,window,document)}):"object"===typeof exports?module.exports=function(a,b){a||(a=window);b&&b.fn.dataTable||(b=require("datatables.net")(a,b).$);return c(b,a,a.document)}:c(jQuery,window,document)})(function(c,a,b,d){return c.fn.dataTable}); + + +/*! + Buttons for DataTables 2.2.2 + ©2016-2022 SpryMedia Ltd - datatables.net/license +*/ +(function(d){"function"===typeof define&&define.amd?define(["jquery","datatables.net"],function(z){return d(z,window,document)}):"object"===typeof exports?module.exports=function(z,B){z||(z=window);B&&B.fn.dataTable||(B=require("datatables.net")(z,B).$);return d(B,z,z.document)}:d(jQuery,window,document)})(function(d,z,B,p){function I(a,b,c){d.fn.animate?a.stop().fadeIn(b,c):(a.css("display","block"),c&&c.call(a))}function J(a,b,c){d.fn.animate?a.stop().fadeOut(b,c):(a.css("display","none"),c&&c.call(a))} +function L(a,b){a=new u.Api(a);b=b?b:a.init().buttons||u.defaults.buttons;return(new x(a,b)).container()}var u=d.fn.dataTable,O=0,P=0,C=u.ext.buttons,x=function(a,b){if(!(this instanceof x))return function(c){return(new x(c,a)).container()};"undefined"===typeof b&&(b={});!0===b&&(b={});Array.isArray(b)&&(b={buttons:b});this.c=d.extend(!0,{},x.defaults,b);b.buttons&&(this.c.buttons=b.buttons);this.s={dt:new u.Api(a),buttons:[],listenKeys:"",namespace:"dtb"+O++};this.dom={container:d("<"+this.c.dom.container.tag+ +"/>").addClass(this.c.dom.container.className)};this._constructor()};d.extend(x.prototype,{action:function(a,b){a=this._nodeToButton(a);if(b===p)return a.conf.action;a.conf.action=b;return this},active:function(a,b){var c=this._nodeToButton(a);a=this.c.dom.button.active;c=d(c.node);if(b===p)return c.hasClass(a);c.toggleClass(a,b===p?!0:b);return this},add:function(a,b,c){var e=this.s.buttons;if("string"===typeof b){b=b.split("-");var h=this.s;e=0;for(var f=b.length-1;e");k.conf._collection=k.collection;if(k.conf.split)for(var t=0;t'+this.c.dom.splitDropdown.text+""));this._expandButton(k.buttons,k.conf.buttons,k.conf.split,!b,b,f,k.conf)}k.conf.parent=g;n.init&&n.init.call(l.button(k.node),l,d(k.node),n);m++}}}},_buildButton:function(a,b,c,e){var h=this.c.dom.button,f=this.c.dom.buttonLiner,g=this.c.dom.collection,l=this.c.dom.splitCollection,m=this.c.dom.splitDropdownButton, +r=this.s.dt,q=function(w){return"function"===typeof w?w(r,k,a):w};if(a.spacer){var n=d("").addClass("dt-button-spacer "+a.style+" "+h.spacerClass).html(q(a.text));return{conf:a,node:n,inserter:n,buttons:[],inCollection:b,isSplit:c,inSplit:e,collection:null}}!c&&e&&l?h=m:!c&&b&&g.button&&(h=g.button);!c&&e&&l.buttonLiner?f=l.buttonLiner:!c&&b&&g.buttonLiner&&(f=g.buttonLiner);if(a.available&&!a.available(r,a)&&!a.hasOwnProperty("html"))return!1;if(a.hasOwnProperty("html"))var k=d(a.html); +else{var t=function(w,D,F,G){G.action.call(D.button(F),w,D,F,G);d(D.table().node()).triggerHandler("buttons-action.dt",[D.button(F),D,F,G])};g=a.tag||h.tag;var y=a.clickBlurs===p?!0:a.clickBlurs;k=d("<"+g+"/>").addClass(h.className).addClass(e?this.c.dom.splitDropdownButton.className:"").attr("tabindex",this.s.dt.settings()[0].iTabIndex).attr("aria-controls",this.s.dt.table().node().id).on("click.dtb",function(w){w.preventDefault();!k.hasClass(h.disabled)&&a.action&&t(w,r,k,a);y&&k.trigger("blur")}).on("keypress.dtb", +function(w){13===w.keyCode&&(w.preventDefault(),!k.hasClass(h.disabled)&&a.action&&t(w,r,k,a))});"a"===g.toLowerCase()&&k.attr("href","#");"button"===g.toLowerCase()&&k.attr("type","button");f.tag?(g=d("<"+f.tag+"/>").html(q(a.text)).addClass(f.className),"a"===f.tag.toLowerCase()&&g.attr("href","#"),k.append(g)):k.html(q(a.text));!1===a.enabled&&k.addClass(h.disabled);a.className&&k.addClass(a.className);a.titleAttr&&k.attr("title",q(a.titleAttr));a.attr&&k.attr(a.attr);a.namespace||(a.namespace= +".dt-button-"+P++);a.config!==p&&a.config.split&&(a.split=a.config.split)}f=(f=this.c.dom.buttonContainer)&&f.tag?d("<"+f.tag+"/>").addClass(f.className).append(k):k;this._addKey(a);this.c.buttonCreated&&(f=this.c.buttonCreated(a,f));if(c){n=d("
").addClass(this.c.dom.splitWrapper.className);n.append(k);var v=d.extend(a,{text:this.c.dom.splitDropdown.text,className:this.c.dom.splitDropdown.className,closeButton:!1,attr:{"aria-haspopup":!0,"aria-expanded":!1},align:this.c.dom.splitDropdown.align, +splitAlignClass:this.c.dom.splitDropdown.splitAlignClass});this._addKey(v);var E=function(w,D,F,G){C.split.action.call(D.button(d("div.dt-btn-split-wrapper")[0]),w,D,F,G);d(D.table().node()).triggerHandler("buttons-action.dt",[D.button(F),D,F,G]);F.attr("aria-expanded",!0)},A=d('").on("click.dtb",function(w){w.preventDefault();w.stopPropagation(); +A.hasClass(h.disabled)||E(w,r,A,v);y&&A.trigger("blur")}).on("keypress.dtb",function(w){13===w.keyCode&&(w.preventDefault(),A.hasClass(h.disabled)||E(w,r,A,v))});0===a.split.length&&A.addClass("dtb-hide-drop");n.append(A).attr(v.attr)}return{conf:a,node:c?n.get(0):k.get(0),inserter:c?n:f,buttons:[],inCollection:b,isSplit:c,inSplit:e,collection:null}},_nodeToButton:function(a,b){b||(b=this.s.buttons);for(var c=0,e=b.length;c").addClass("dt-button-collection").addClass(f.collectionLayout).addClass(f.splitAlignClass).addClass(e).css("display","none");a=d(a).addClass(f.contentClassName).attr("role","menu").appendTo(m);g.attr("aria-expanded","true");g.parents("body")[0]!== +B.body&&(g=B.body.lastChild);f.popoverTitle?m.prepend('
'+f.popoverTitle+"
"):f.collectionTitle&&m.prepend('
'+f.collectionTitle+"
");f.closeButton&&m.prepend('
x
').addClass("dtb-collection-closeable");I(m.insertAfter(g),f.fade);c=d(b.table().container());var r=m.css("position");if("container"===f.span||"dt-container"===f.align)g=g.parent(),m.css("width",c.width());if("absolute"=== +r){var q=d(g[0].offsetParent);c=g.position();e=g.offset();var n=q.offset(),k=q.position(),t=z.getComputedStyle(q[0]);n.height=q.outerHeight();n.width=q.width()+parseFloat(t.paddingLeft);n.right=n.left+n.width;n.bottom=n.top+n.height;q=c.top+g.outerHeight();var y=c.left;m.css({top:q,left:y});t=z.getComputedStyle(m[0]);var v=m.offset();v.height=m.outerHeight();v.width=m.outerWidth();v.right=v.left+v.width;v.bottom=v.top+v.height;v.marginTop=parseFloat(t.marginTop);v.marginBottom=parseFloat(t.marginBottom); +f.dropup&&(q=c.top-v.height-v.marginTop-v.marginBottom);if("button-right"===f.align||m.hasClass(f.rightAlignClassName))y=c.left-v.width+g.outerWidth();if("dt-container"===f.align||"container"===f.align)yn.width&&(y=n.width-v.width);k.left+y+v.width>d(z).width()&&(y=d(z).width()-v.width-k.left);0>e.left+y&&(y=-e.left);k.top+q+v.height>d(z).height()+d(z).scrollTop()&&(q=c.top-v.height-v.marginTop-v.marginBottom);k.top+qE&&(A=E);m.css("marginTop",-1*A)},r(),d(z).on("resize.dtb-collection",function(){r()});f.background&&x.background(!0,f.backgroundClassName,f.fade,f.backgroundHost||g);d("div.dt-button-background").on("click.dtb-collection",function(){});f.autoClose&&setTimeout(function(){b.on("buttons-action.b-internal",function(E,A,w,D){D[0]!==g[0]&&l()})},0);d(m).trigger("buttons-popover.dt");b.on("destroy",l);setTimeout(function(){h=!1;d("body").on("click.dtb-collection", +function(E){if(!h){var A=d.fn.addBack?"addBack":"andSelf",w=d(E.target).parent()[0];(!d(E.target).parents()[A]().filter(a).length&&!d(w).hasClass("dt-buttons")||d(E.target).hasClass("dt-button-background"))&&l()}}).on("keyup.dtb-collection",function(E){27===E.keyCode&&l()})},0)}}});x.background=function(a,b,c,e){c===p&&(c=400);e||(e=B.body);a?I(d("
").addClass(b).css("display","none").insertAfter(e),c):J(d("div."+b),c,function(){d(this).removeClass(b).remove()})};x.instanceSelector=function(a, +b){if(a===p||null===a)return d.map(b,function(f){return f.inst});var c=[],e=d.map(b,function(f){return f.name}),h=function(f){if(Array.isArray(f))for(var g=0,l=f.length;g)<[^<]*)*<\/script>/gi,"");a=a.replace(//g,"");if(!b||b.stripHtml)a=a.replace(/<[^>]*>/g,"");if(!b||b.trim)a=a.replace(/^\s+|\s+$/g,"");if(!b||b.stripNewlines)a=a.replace(/\n/g," ");if(!b||b.decodeEntities)M.innerHTML=a,a=M.value;return a};x.defaults={buttons:["copy","excel","csv","pdf","print"],name:"main",tabIndex:0,dom:{container:{tag:"div",className:"dt-buttons"},collection:{tag:"div",className:""},button:{tag:"button", +className:"dt-button",active:"active",disabled:"disabled",spacerClass:""},buttonLiner:{tag:"span",className:""},split:{tag:"div",className:"dt-button-split"},splitWrapper:{tag:"div",className:"dt-btn-split-wrapper"},splitDropdown:{tag:"button",text:"▼",className:"dt-btn-split-drop",align:"split-right",splitAlignClass:"dt-button-split-left"},splitDropdownButton:{tag:"button",className:"dt-btn-split-drop-button dt-button"},splitCollection:{tag:"div",className:"dt-button-split-collection"}}}; +x.version="2.2.2";d.extend(C,{collection:{text:function(a){return a.i18n("buttons.collection","Collection")},className:"buttons-collection",closeButton:!1,init:function(a,b,c){b.attr("aria-expanded",!1)},action:function(a,b,c,e){e._collection.parents("body").length?this.popover(!1,e):this.popover(e._collection,e)},attr:{"aria-haspopup":!0}},split:{text:function(a){return a.i18n("buttons.split","Split")},className:"buttons-split",closeButton:!1,init:function(a,b,c){return b.attr("aria-expanded",!1)}, +action:function(a,b,c,e){this.popover(e._collection,e)},attr:{"aria-haspopup":!0}},copy:function(a,b){if(C.copyHtml5)return"copyHtml5"},csv:function(a,b){if(C.csvHtml5&&C.csvHtml5.available(a,b))return"csvHtml5"},excel:function(a,b){if(C.excelHtml5&&C.excelHtml5.available(a,b))return"excelHtml5"},pdf:function(a,b){if(C.pdfHtml5&&C.pdfHtml5.available(a,b))return"pdfHtml5"},pageLength:function(a){a=a.settings()[0].aLengthMenu;var b=[],c=[];if(Array.isArray(a[0]))b=a[0],c=a[1];else for(var e=0;e"+a+"":"";I(d('
').html(a).append(d("
")["string"=== +typeof b?"html":"append"](b)).css("display","none").appendTo("body"));c!==p&&0!==c&&(H=setTimeout(function(){e.buttons.info(!1)},c));this.on("destroy.btn-info",function(){e.buttons.info(!1)});return this});u.Api.register("buttons.exportData()",function(a){if(this.context.length)return Q(new u.Api(this.context[0]),a)});u.Api.register("buttons.exportInfo()",function(a){a||(a={});var b=a;var c="*"===b.filename&&"*"!==b.title&&b.title!==p&&null!==b.title&&""!==b.title?b.title:b.filename;"function"=== +typeof c&&(c=c());c===p||null===c?c=null:(-1!==c.indexOf("*")&&(c=c.replace("*",d("head > title").text()).trim()),c=c.replace(/[^a-zA-Z0-9_\u00A1-\uFFFF\.,\-_ !\(\)]/g,""),(b=K(b.extension))||(b=""),c+=b);b=K(a.title);b=null===b?null:-1!==b.indexOf("*")?b.replace("*",d("head > title").text()||"Exported data"):b;return{filename:c,title:b,messageTop:N(this,a.message||a.messageTop,"top"),messageBottom:N(this,a.messageBottom,"bottom")}});var K=function(a){return null===a||a===p?null:"function"===typeof a? +a():a},N=function(a,b,c){b=K(b);if(null===b)return null;a=d("caption",a.table().container()).eq(0);return"*"===b?a.css("caption-side")!==c?null:a.length?a.text():"":b},M=d(" + +
+ modalState->main = 'notes'; ?> + modalState->one = 'tags'; ?> + modalState->oneText = JText::_('COM_GETBIBLE_TAGS'); ?> + modalState->two = 'sharing'; ?> + modalState->twoText = JText::_('COM_GETBIBLE_SHARE'); ?> + loadTemplate('getbibleappmodalbottom'); ?> +
+
+ diff --git a/site/views/app/tmpl/default_getbibleappsettings.php b/site/views/app/tmpl/default_getbibleappsettings.php new file mode 100644 index 0000000..021fc29 --- /dev/null +++ b/site/views/app/tmpl/default_getbibleappsettings.php @@ -0,0 +1,159 @@ + + @git Get Bible + @github Get Bible + @support Get Bible + @copyright Copyright (C) 2015. All Rights Reserved + @license GNU/GPL Version 2 or later - http://www.gnu.org/licenses/gpl-2.0.html + +/------------------------------------------------------------------------------------------------------*/ + +// No direct access to this file +defined('_JEXEC') or die('Restricted access'); + +?> +
+
+
+

+ 'getbible-settings-session-linker', 'label' => JText::_('COM_GETBIBLE_SESSION_KEY'), 'class_other' => 'getbible-linker-guid-input uk-text-center', 'value' => $this->linker['guid']]); ?> +

+

+ + +

+
+
+
+
+
+
+

+

+

+
+
+
+
+

+

+

+
+
+
+
+
+ diff --git a/site/views/app/tmpl/default_getbibleappshare.php b/site/views/app/tmpl/default_getbibleappshare.php new file mode 100644 index 0000000..1b9fe22 --- /dev/null +++ b/site/views/app/tmpl/default_getbibleappshare.php @@ -0,0 +1,425 @@ + + @git Get Bible + @github Get Bible + @support Get Bible + @copyright Copyright (C) 2015. All Rights Reserved + @license GNU/GPL Version 2 or later - http://www.gnu.org/licenses/gpl-2.0.html + +/------------------------------------------------------------------------------------------------------*/ + +// No direct access to this file +defined('_JEXEC') or die('Restricted access'); + +?> +
+
+ +
+

chapter->book_name; ?> chapter->chapter; ?>:

+ +
+
+
+
+
+
    +
  • + +
    +
    +
    + + +
    +
    +
    +
    +
    ...
    + +
    +
    +
    +
  • +
  • + +
    +
    +
    +
    + +
    +
    +
    +
  • +
+
+ modalState->main = 'sharing'; ?> + modalState->one = 'notes'; ?> + modalState->oneText = JText::_('COM_GETBIBLE_NOTES'); ?> + modalState->two = 'tags'; ?> + modalState->twoText = JText::_('COM_GETBIBLE_TAGS'); ?> + loadTemplate('getbibleappmodalbottom'); ?> +
+
+ diff --git a/site/views/app/tmpl/default_getbibleapptags.php b/site/views/app/tmpl/default_getbibleapptags.php new file mode 100644 index 0000000..d1ddea8 --- /dev/null +++ b/site/views/app/tmpl/default_getbibleapptags.php @@ -0,0 +1,108 @@ + + @git Get Bible + @github Get Bible + @support Get Bible + @copyright Copyright (C) 2015. All Rights Reserved + @license GNU/GPL Version 2 or later - http://www.gnu.org/licenses/gpl-2.0.html + +/------------------------------------------------------------------------------------------------------*/ + +// No direct access to this file +defined('_JEXEC') or die('Restricted access'); + +?> +
+
+ +
+

chapter->book_name; ?> chapter->chapter; ?>:1

+ +
+
+
+
+
+

+
+
+
+

+
+ +
+
+
+
+

+
+ +
+
+
+
+
+

+
+
+

+
+
+
+ modalState->main = 'tags'; ?> + modalState->one = 'notes'; ?> + modalState->oneText = JText::_('COM_GETBIBLE_NOTES'); ?> + modalState->two = 'sharing'; ?> + modalState->twoText = JText::_('COM_GETBIBLE_SHARE'); ?> + loadTemplate('getbibleappmodalbottom'); ?> +
+
+ diff --git a/site/views/app/tmpl/default_getbibleapptopmenu.php b/site/views/app/tmpl/default_getbibleapptopmenu.php new file mode 100644 index 0000000..c6dc5dc --- /dev/null +++ b/site/views/app/tmpl/default_getbibleapptopmenu.php @@ -0,0 +1,59 @@ + + @git Get Bible + @github Get Bible + @support Get Bible + @copyright Copyright (C) 2015. All Rights Reserved + @license GNU/GPL Version 2 or later - http://www.gnu.org/licenses/gpl-2.0.html + +/------------------------------------------------------------------------------------------------------*/ + +// No direct access to this file +defined('_JEXEC') or die('Restricted access'); + +$type = $this->params->get('top_menu_type'); + +if ($type == 2) +{ + $menu_type = 'class="uk-margin-small uk-flex-center" uk-tab '; +} +else +{ + $menu_type = 'class="el-nav uk-margin-small uk-subnav uk-subnav-pill uk-flex-center" '; +} + +?> + diff --git a/site/views/app/tmpl/default_getbibleappword.php b/site/views/app/tmpl/default_getbibleappword.php new file mode 100644 index 0000000..91e4664 --- /dev/null +++ b/site/views/app/tmpl/default_getbibleappword.php @@ -0,0 +1,172 @@ + + @git Get Bible + @github Get Bible + @support Get Bible + @copyright Copyright (C) 2015. All Rights Reserved + @license GNU/GPL Version 2 or later - http://www.gnu.org/licenses/gpl-2.0.html + +/------------------------------------------------------------------------------------------------------*/ + +// No direct access to this file +defined('_JEXEC') or die('Restricted access'); + +?> +
+
+ +
+ WORD + ... +
+
+ params->get('activate_search') == 1): ?> + + + params->get('enable_open_ai') == 1 && ($buttons = $this->promptIntegration($this->prompts, [1,3])) !== null): ?> + + escape($button->name); ?> + + +
+
+
+ diff --git a/site/views/app/tmpl/default_getbiblebooks.php b/site/views/app/tmpl/default_getbiblebooks.php new file mode 100644 index 0000000..11c0349 --- /dev/null +++ b/site/views/app/tmpl/default_getbiblebooks.php @@ -0,0 +1,38 @@ + + @git Get Bible + @github Get Bible + @support Get Bible + @copyright Copyright (C) 2015. All Rights Reserved + @license GNU/GPL Version 2 or later - http://www.gnu.org/licenses/gpl-2.0.html + +/------------------------------------------------------------------------------------------------------*/ + +// No direct access to this file +defined('_JEXEC') or die('Restricted access'); + +?> +
+ books as $book): ?> +
+
+ nr !== $this->chapter->book_nr): ?> + + name; ?> + + + + name; ?> + + +
+
+ +
diff --git a/site/views/app/tmpl/default_getbiblechapters.php b/site/views/app/tmpl/default_getbiblechapters.php new file mode 100644 index 0000000..b80622b --- /dev/null +++ b/site/views/app/tmpl/default_getbiblechapters.php @@ -0,0 +1,38 @@ + + @git Get Bible + @github Get Bible + @support Get Bible + @copyright Copyright (C) 2015. All Rights Reserved + @license GNU/GPL Version 2 or later - http://www.gnu.org/licenses/gpl-2.0.html + +/------------------------------------------------------------------------------------------------------*/ + +// No direct access to this file +defined('_JEXEC') or die('Restricted access'); + +?> +
+ chapters as $chapter): ?> +
+
+ chapter !== $this->chapter->chapter): ?> + + chapter; ?> + + + + chapter; ?> + + +
+
+ +
diff --git a/site/views/app/tmpl/default_getbiblefavouriteverseselector.php b/site/views/app/tmpl/default_getbiblefavouriteverseselector.php new file mode 100644 index 0000000..64685a2 --- /dev/null +++ b/site/views/app/tmpl/default_getbiblefavouriteverseselector.php @@ -0,0 +1,110 @@ + + @git Get Bible + @github Get Bible + @support Get Bible + @copyright Copyright (C) 2015. All Rights Reserved + @license GNU/GPL Version 2 or later - http://www.gnu.org/licenses/gpl-2.0.html + +/------------------------------------------------------------------------------------------------------*/ + +// No direct access to this file +defined('_JEXEC') or die('Restricted access'); + +// set content +$options = array_map( function ($item) { + return (object) ['key' => $item->nr, 'value' => $item->name]; +}, $this->books); +$content = ''; +$content .= '

' . JText::_('COM_GETBIBLE_YOU_SHOULD_SELECT_ONE_OF_BYOUR_FAVOURITEB_VERSES') . '

'; +$content .= '

' . JText::_('COM_GETBIBLE_THIS_VERSE_IN_COMBINATION_WITH_YOUR_ISESSION_KEYI_WILL_BE_USED_TO_AUTHENTICATE_YOU_IN_THE_FUTURE') . '

'; +$content .= '
'; +$content .= '
'; +$content .= JLayoutHelper::render('selectbox', ['id' => 'getbible_favourite_book', 'label' => JText::_('COM_GETBIBLE_BOOKS'), 'options' => $options, 'default' => $this->chapter->book_nr]); +$content .= '
'; +$options = array_map( function ($item) { + return (object) ['key' => $item, 'value' => $item]; +}, range(1, 150)); +$content .= '
'; +$content .= JLayoutHelper::render('selectbox', ['id' => 'getbible_favourite_chapter', 'label' => JText::_('COM_GETBIBLE_CHAPTERS'), 'options' => $options, 'default' => $this->chapter->chapter]); +$content .= '
'; +$options = array_map( function ($item) { + return (object) ['key' => $item, 'value' => $item]; +}, range(1, 176)); +$content .= '
'; +$content .= JLayoutHelper::render('selectbox', ['id' => 'getbible_favourite_verse', 'label' => JText::_('COM_GETBIBLE_VERSES'), 'options' => $options, 'default' => (string) $this->verses->first]); +$content .= '
'; +$content .= '
'; +$content .= '

' . JText::_('COM_GETBIBLE_THIS_IS_CURRENTLY_THE_ACTIVE_SESSION_KEY') . '

'; +$content .= '
'; +$content .= JLayoutHelper::render('inputbox', ['id' => 'getbible_favourite_linker', 'class_other' => 'getbible-linker-guid-input uk-text-center', 'label' => JText::_('COM_GETBIBLE_SESSION_KEY'), 'placeholder' => JText::_('COM_GETBIBLE_AUTO_GENERATED')]); +$content .= '
'; +$content .= '

' . JText::_('COM_GETBIBLE_SHOULD_YOU_HAVE_BANOTHER_SESSION_KEYB_FROM_A_PREVIOUS_SESSION') . '
' . JText::_('COM_GETBIBLE_YOU_CAN_ADD_IT_HERE_TO_LOAD_YOUR_PREVIOUS_SESSION') . '

'; + +// set buttons +$buttons = [ + ['name' => JText::_('COM_GETBIBLE_SELECT'), 'onclick' => "activeLinkerAccess();", 'class' => 'uk-button uk-button-default uk-width-2-3'], + ['close' => true, 'name' => JText::_('COM_GETBIBLE_CANCEL'), 'class' => 'uk-button uk-button-danger uk-width-1-3'] +]; + + +?> + 'getbible_favourite_verse_selector', + 'header' => JText::_('COM_GETBIBLE_FAVOURITE_VERSE'), + 'header_class_other' => 'uk-text-center', + 'close' => true, + 'content' => $content, + 'buttons_class' => 'uk-button-group uk-width-1-1', + 'buttons_id' => 'getbible-favourite-buttons', + 'buttons' => $buttons +]); ?> + diff --git a/site/views/app/tmpl/default_getbibleinstallbutton.php b/site/views/app/tmpl/default_getbibleinstallbutton.php new file mode 100644 index 0000000..e76326a --- /dev/null +++ b/site/views/app/tmpl/default_getbibleinstallbutton.php @@ -0,0 +1,170 @@ + + @git Get Bible + @github Get Bible + @support Get Bible + @copyright Copyright (C) 2015. All Rights Reserved + @license GNU/GPL Version 2 or later - http://www.gnu.org/licenses/gpl-2.0.html + +/------------------------------------------------------------------------------------------------------*/ + +// No direct access to this file +defined('_JEXEC') or die('Restricted access'); + +?> +params->get('show_install_button') == 1): ?> +' . $this->totalVerse . ''; ?> +

+ + + + + + diff --git a/site/views/app/tmpl/default_getbibletext.php b/site/views/app/tmpl/default_getbibletext.php new file mode 100644 index 0000000..571e948 --- /dev/null +++ b/site/views/app/tmpl/default_getbibletext.php @@ -0,0 +1,63 @@ + + @git Get Bible + @github Get Bible + @support Get Bible + @copyright Copyright (C) 2015. All Rights Reserved + @license GNU/GPL Version 2 or later - http://www.gnu.org/licenses/gpl-2.0.html + +/------------------------------------------------------------------------------------------------------*/ + +// No direct access to this file +defined('_JEXEC') or die('Restricted access'); + +?> +params->get('previous_next_navigation') == 1): ?> +
+ previous); ?> +
+ +params->get('activate_sharing') == 1 || $this->params->get('activate_search') == 1 || empty($this->item['daily'])): ?> + translation->direction) === 'ltr'): ?> +
+ +
+ + item['daily'])): ?> + + + params->get('activate_search') == 1): ?> + + + params->get('activate_sharing') == 1): ?> + + +
+ +params->get('activate_search') == 1 || ($this->params->get('enable_open_ai') == 1 && !empty($this->prompts))): ?> + loadTemplate('getbibleappword'); ?> + +
+ params->get('show_header') == 1): ?> +
+ chapter->name; ?> +
+ + params->get('verse_per_line') == 1): ?> + loadTemplate('versesunorderedlist'); ?> + + loadTemplate('versesparagraph'); ?> + +
+params->get('previous_next_navigation') == 1): ?> +
+ next); ?> +
+ diff --git a/site/views/app/tmpl/default_getbibletranslations.php b/site/views/app/tmpl/default_getbibletranslations.php new file mode 100644 index 0000000..0cb88b5 --- /dev/null +++ b/site/views/app/tmpl/default_getbibletranslations.php @@ -0,0 +1,38 @@ + + @git Get Bible + @github Get Bible + @support Get Bible + @copyright Copyright (C) 2015. All Rights Reserved + @license GNU/GPL Version 2 or later - http://www.gnu.org/licenses/gpl-2.0.html + +/------------------------------------------------------------------------------------------------------*/ + +// No direct access to this file +defined('_JEXEC') or die('Restricted access'); + +?> +
+ translations as $translation): ?> +
+
+ abbreviation !== $this->chapter->abbreviation): ?> + + translation; ?> (abbreviation; ?>) + + + + translation; ?> (abbreviation; ?>) + + +
+
+ +
diff --git a/site/views/app/tmpl/default_versesparagraph.php b/site/views/app/tmpl/default_versesparagraph.php new file mode 100644 index 0000000..3901f30 --- /dev/null +++ b/site/views/app/tmpl/default_versesparagraph.php @@ -0,0 +1,38 @@ + + @git Get Bible + @github Get Bible + @support Get Bible + @copyright Copyright (C) 2015. All Rights Reserved + @license GNU/GPL Version 2 or later - http://www.gnu.org/licenses/gpl-2.0.html + +/------------------------------------------------------------------------------------------------------*/ + +// No direct access to this file +defined('_JEXEC') or die('Restricted access'); + +?> +

+ chapter->html_verses as $verse): ?> + $verse, + 'active' => $this->active, + 'tag' => $this->taggedVerse((int) $verse->verse), + 'selected' => $this->selectedVerse((int) $verse->verse) + ]); + // add note if found + if (($note = $this->getVerseNote((int) $verse->verse)) !== null) + { + echo ' ' . JLayoutHelper::render('getbibleappnotelink', ['number' => $verse->verse, 'note' => $note]); + } + ?> + +

diff --git a/site/views/app/tmpl/default_versesunorderedlist.php b/site/views/app/tmpl/default_versesunorderedlist.php new file mode 100644 index 0000000..d5568f1 --- /dev/null +++ b/site/views/app/tmpl/default_versesunorderedlist.php @@ -0,0 +1,40 @@ + + @git Get Bible + @github Get Bible + @support Get Bible + @copyright Copyright (C) 2015. All Rights Reserved + @license GNU/GPL Version 2 or later - http://www.gnu.org/licenses/gpl-2.0.html + +/------------------------------------------------------------------------------------------------------*/ + +// No direct access to this file +defined('_JEXEC') or die('Restricted access'); + +?> +
+
    + chapter->html_verses as $verse): ?> +
  • $verse, + 'active' => $this->active, + 'tag' => $this->taggedVerse((int) $verse->verse), + 'selected' => $this->selectedVerse((int) $verse->verse) + ]); + // add note if found + if (($note = $this->getVerseNote((int) $verse->verse)) !== null) + { + echo '
    ' . JLayoutHelper::render('getbibleappnote', ['number' => $verse->verse, 'note' => $note]); + } + ?>
  • + +
+
diff --git a/site/views/app/tmpl/index.html b/site/views/app/tmpl/index.html new file mode 100644 index 0000000..fa6d84e --- /dev/null +++ b/site/views/app/tmpl/index.html @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/site/views/app/view.html.php b/site/views/app/view.html.php new file mode 100644 index 0000000..85b33d2 --- /dev/null +++ b/site/views/app/view.html.php @@ -0,0 +1,845 @@ + + @git Get Bible + @github Get Bible + @support Get Bible + @copyright Copyright (C) 2015. All Rights Reserved + @license GNU/GPL Version 2 or later - http://www.gnu.org/licenses/gpl-2.0.html + +/------------------------------------------------------------------------------------------------------*/ + +// No direct access to this file +defined('_JEXEC') or die('Restricted access'); +jimport('joomla.application.module.helper'); + +use Joomla\CMS\MVC\View\HtmlView; +use VDM\Joomla\GetBible\Factory; + +/** + * Getbible Html View class for the App + */ +class GetbibleViewApp extends HtmlView +{ + // Overwriting JView display method + function display($tpl = null) + { + // get combined params of both component and menu + $this->app = JFactory::getApplication(); + $this->params = $this->app->getParams(); + $this->menu = $this->app->getMenu()->getActive(); + // get the user object + $this->user = JFactory::getUser(); + // Initialise variables. + $this->item = $this->get('Item'); + $this->chapter = $this->get('Chapter'); + $this->translations = $this->get('Translations'); + $this->books = $this->get('Books'); + $this->chapters = $this->get('Chapters'); + $this->next = $this->get('Next'); + $this->previous = $this->get('Previous'); + $this->translation = $this->get('Translation'); + $this->notes = $this->get('Notes'); + $this->linkernotes = $this->get('LinkerNotes'); + $this->tags = $this->get('Tags'); + $this->taggedverses = $this->get('TaggedVerses'); + $this->prompts = $this->get('Prompts'); + $this->linkertaggedverses = $this->get('LinkerTaggedVerses'); + $this->linkertags = $this->get('LinkerTags'); + if ($this->item) + { + // get the input values + $this->input = $this->app->input; + + // set the linker + $this->linker = $this->getLinker(); + + // merge the system and linker + $this->mergeNotes(); + $this->mergeTags(); + $this->mergeTaggedVerses(); + + // should we not have tags at this point we should not load the tag feature + if (empty($this->tags)) + { + $this->params->set('activate_tags', null); + } + + // build the tab menu + $this->setTabsMenu(); + + if ($this->params->get('activate_search') == 1) + { + // set the search URL + $this->setSearchUrl(); + } + + // set the base URL + $this->setDailyVerseUrl(); + + // set the selected verses + $this->verses = new \stdClass(); + $this->verses->selected = $this->item['verses'] ? $this->getSelectedVerses($this->item['verses']) : null; + $this->verses->first = 1; + $this->verses->last = 2; + if (!empty($this->verses->selected)) + { + $this->verses->first = reset($this->verses->selected); + $this->verses->last = end($this->verses->selected); + } + // set the last verse in the chapter + $this->last_verse = end($this->chapter->verses)->verse; + + $this->active = new \stdClass(); + $this->active->verse = false; + // check if we have activity active + if ($this->params->get('activate_notes') == 1 || $this->params->get('activate_tags') == 1 || $this->params->get('activate_sharing') == 1) + { + $this->active->verse = true; + $this->active->target = ($this->params->get('activate_sharing') == 1) ? 'sharing' : (($this->params->get('activate_tags') == 1) ? 'tags' : 'notes'); + $this->active->tooltip = JText::_('COM_GETBIBLE_OPEN'); + } + + // start the modal state + $this->modalState = new \stdClass(); + } + else + { + $this->tab_name_placeholders = null; + } + + // we get the verse count if we are going to show the install button + if ($this->params->get('show_install_button') == 1) + { + $this->totalVerse = Factory::_('GetBible.Watcher')->totalVerses($this->translation->abbreviation ?? 'kjv'); + } + + // Set the toolbar + $this->addToolBar(); + + // set the document + $this->_prepareDocument(); + + // Check for errors. + if (count($errors = $this->get('Errors'))) + { + throw new Exception(implode(PHP_EOL, $errors), 500); + } + + parent::display($tpl); + } + + /** + * Set the tabs menu + * + * @return void + * @since 2.0.1 + */ + protected function setTabsMenu() + { + // set the active tab + $this->tab_menu['active_tab'] = $this->input->getWord('tab', 'scripture'); + + // check if we have set this before + if (!isset($this->tab_menu['scripture_icon'])) + { + // set the tab icons + $icon = ($this->params->get('custom_icons') == 1) ? $this->params->get('scripture_icon', 'heart') : 'heart'; + $this->tab_menu['scripture_icon'] = ($this->params->get('show_scripture_icon') == 1) ? ' ' : ''; + $icon = ($this->params->get('custom_icons') == 1) ? $this->params->get('translations_icon', 'world') : 'world'; + $this->tab_menu['translations_icon'] = ($this->params->get('show_translations_icon') == 1) ? ' ' : ''; + $icon = ($this->params->get('custom_icons') == 1) ? $this->params->get('books_icon', 'album') : 'album'; + $this->tab_menu['books_icon'] = ($this->params->get('show_books_icon') == 1) ? ' ' : ''; + $icon = ($this->params->get('custom_icons') == 1) ? $this->params->get('chapters_icon', 'grid') : 'grid'; + $this->tab_menu['chapters_icon'] = ($this->params->get('show_chapters_icon') == 1) ? ' ' : ''; + + // set the tab names + $this->tab_menu['scripture'] = ($this->params->get('show_scripture_tab_text') == 1) ? $this->chapter->name . ' (' . $this->chapter->abbreviation . ')' : ''; + $this->tab_menu['translations'] = ($this->params->get('show_translations_tab_text') == 1) ? '[translations]' : ''; + $this->tab_menu['books'] = ($this->params->get('show_books_tab_text') == 1) ? '[books]' : ''; + $this->tab_menu['chapters'] = ($this->params->get('show_chapters_tab_text') == 1) ? '[chapters]' : ''; + + // use updated tab names + if ($this->params->get('set_default_tab_names') == 1) + { + $this->tab_menu['scripture'] = $this->params->get('scripture_tab') ?? $this->tab_menu['scripture']; + $this->tab_menu['translations'] = $this->params->get('translations_tab') ?? $this->tab_menu['translations']; + $this->tab_menu['books'] = $this->params->get('books_tab') ?? $this->tab_menu['books']; + $this->tab_menu['chapters'] = $this->params->get('chapters_tab') ?? $this->tab_menu['chapters']; + } + + // the dynamic placeholders + $this->tab_name_placeholders = [ + '[translations]' => JText::_('COM_GETBIBLE_TRANSLATIONS'), + '[books]' => JText::_('COM_GETBIBLE_BOOKS'), + '[chapters]' => JText::_('COM_GETBIBLE_CHAPTERS'), + '[details]' => JText::_('COM_GETBIBLE_DETAILS'), + '[settings]' => JText::_('COM_GETBIBLE_SETTINGS'), + '[translation]' => $this->chapter->translation, + '[abbreviation]' => $this->chapter->abbreviation, + '[lang]' => $this->chapter->lang, + '[language]' => $this->chapter->language, + '[book_nr]' => $this->chapter->book_nr, + '[book_name]' => $this->chapter->book_name, + '[chapter]' => $this->chapter->chapter, + '[name]' => $this->chapter->name + ]; + + // we do some placeholder updates for the scripture tab + $this->tab_menu['scripture'] = str_replace( + array_keys($this->tab_name_placeholders), + array_values($this->tab_name_placeholders), + $this->tab_menu['scripture'] + ); + + // we do some placeholder updates for the translations tab + $this->tab_menu['translations'] = str_replace( + array_keys($this->tab_name_placeholders), + array_values($this->tab_name_placeholders), + $this->tab_menu['translations'] + ); + + // we do some placeholder updates for the books tab + $this->tab_menu['books'] = str_replace( + array_keys($this->tab_name_placeholders), + array_values($this->tab_name_placeholders), + $this->tab_menu['books'] + ); + + // we do some placeholder updates for the chapters tab + $this->tab_menu['chapters'] = str_replace( + array_keys($this->tab_name_placeholders), + array_values($this->tab_name_placeholders), + $this->tab_menu['chapters'] + ); + + if ($this->params->get('show_settings') == 1) + { + $icon = ($this->params->get('custom_icons') == 1) ? $this->params->get('settings_icon', 'settings') : 'settings'; + $this->tab_menu['settings_icon'] = ($this->params->get('show_settings_icon') == 1) ? ' ' : ''; + $this->tab_menu['settings'] = ($this->params->get('show_settings_tab_text') == 1) ? $this->params->get('settings_tab') ?? '[settings]' : ''; + // we do some placeholder updates for the settings tab + $this->tab_menu['settings'] = str_replace( + array_keys($this->tab_name_placeholders), + array_values($this->tab_name_placeholders), + $this->tab_menu['settings'] + ); + } + + if ($this->params->get('show_details') == 1) + { + $icon = ($this->params->get('custom_icons') == 1) ? $this->params->get('details_icon', 'info') : 'info'; + $this->tab_menu['details_icon'] = ($this->params->get('show_details_icon') == 1) ? ' ' : ''; + $this->tab_menu['details'] = ($this->params->get('show_details_tab_text') == 1) ? $this->params->get('details_tab') ?? '[details]' : ''; + // we do some placeholder updates for the details tab + $this->tab_menu['details'] = str_replace( + array_keys($this->tab_name_placeholders), + array_values($this->tab_name_placeholders), + $this->tab_menu['details'] + ); + } + } + } + + /** + * Merge system and linker notes + * + * @return void + * @since 2.0.1 + */ + protected function mergeNotes(): void + { + $mergedNotes = []; + + // If $this->notes is an array and is not empty, add its elements to $mergedNotes + if (is_array($this->notes) && $this->notes !== []) + { + foreach ($this->notes as $note) + { + // Use the 'verse' attribute as the key + $mergedNotes[$note->verse] = $note; + } + } + + // If $this->linkernotes is an array and is not empty, add or replace its elements in $mergedNotes + if (is_array($this->linkernotes) && $this->linkernotes !== []) + { + foreach ($this->linkernotes as $note) + { + // If the verse already exists in $mergedNotes, this will replace it + // If it doesn't exist, this will add it + $mergedNotes[$note->verse] = $note; + } + } + + // update the notes array if we have values + if ($mergedNotes !== []) + { + // Reset the keys to be numeric and start from 0 + $this->notes = array_values($mergedNotes); + } + } + + /** + * Merge system and linker tags + * + * @return void + * @since 2.0.1 + */ + protected function mergeTags(): void + { + $mergeTags = []; + + // If $this->tags is an array and is not empty, add its elements to $mergeTags + if (is_array($this->tags) && $this->tags !== []) + { + foreach ($this->tags as $tag) + { + // set the tag url + $tag->url = JRoute::_('index.php?option=com_getbible&view=tag&Itemid=' . $this->params->get('app_menu', 0) . '&guid=' . $tag->guid . '&t=' . $this->translation->abbreviation); + // Use the 'verse' attribute as the key + $mergeTags[$tag->id] = $tag; + } + } + + // If $this->linkertags is an array and is not empty, add or replace its elements in $mergeTags + if (is_array($this->linkertags) && $this->linkertags !== []) + { + foreach ($this->linkertags as $tag) + { + if ($tag->published != 1) + { + // we remove the tag if not published + unset($mergeTags[$tag->id]); + continue; + } + // set the tag url + $tag->url = JRoute::_('index.php?option=com_getbible&view=tag&Itemid=' . $this->params->get('app_menu', 0) . '&guid=' . $tag->guid . '&t=' . $this->translation->abbreviation); + // If the verse already exists in $mergeTags, this will replace it + // If it doesn't exist, this will add it + $mergeTags[$tag->id] = $tag; + } + } + + // update the notes array if we have values + if ($mergeTags !== []) + { + // Reset the keys to be numeric and start from 0 + $this->tags = array_values($mergeTags); + } + } + + /** + * Merge system and linker tagged verses + * + * @return void + * @since 2.0.1 + */ + protected function mergeTaggedVerses(): void + { + $mergeTags = []; + + // If $this->taggedverses is an array and is not empty, add its elements to $mergeTags + if (is_array($this->taggedverses) && $this->taggedverses !== []) + { + foreach ($this->taggedverses as $tag) + { + // we build the key + $key = $tag->tag . '-' . $tag->verse; + // set the tag url + $tag->url = JRoute::_('index.php?option=com_getbible&view=tag&Itemid=' . $this->params->get('app_menu', 0) . '&guid=' . $tag->tag . '&t=' . $this->translation->abbreviation); + // Use the 'verse' attribute as the key + $mergeTags[$key] = $tag; + } + } + + // If $this->linkertaggedverses is an array and is not empty, add or replace its elements in $mergeTags + if (is_array($this->linkertaggedverses) && $this->linkertaggedverses !== []) + { + foreach ($this->linkertaggedverses as $tag) + { + // we build the key + $key = $tag->tag . '-' . $tag->verse; + if ($tag->published != 1) + { + // we remove the tag if not published + unset($mergeTags[$key]); + continue; + } + // set the tag url + $tag->url = JRoute::_('index.php?option=com_getbible&view=tag&Itemid=' . $this->params->get('app_menu', 0) . '&guid=' . $tag->tag . '&t=' . $this->translation->abbreviation); + // If the verse already exists in $mergeTags, this will replace it + // If it doesn't exist, this will add it + $mergeTags[$key] = $tag; + } + } + + // update the notes array if we have values + if ($mergeTags !== []) + { + // Reset the keys to be numeric and start from 0 + $this->taggedverses = array_values($mergeTags); + } + } + + /** + * Set the daily verse url + * + * @return void + * @since 2.0.1 + */ + protected function setDailyVerseUrl() + { + $this->url_daily = JRoute::_('index.php?option=com_getbible&view=app&Itemid=' . $this->params->get('app_menu', 0) . '&t=' . $this->translation->abbreviation); + } + + /** + * Set the search url + * + * @return void + * @since 2.0.1 + */ + protected function setSearchUrl() + { + $words = $this->params->get('search_word', 1); + $match = $this->params->get('search_match', 1); + $case = $this->params->get('search_case', 1); + + // set the current search URL + $this->url_search = JRoute::_('index.php?option=com_getbible&view=search&t=' . $this->translation->abbreviation . '&words=' . $words . '&match=' . $match . '&case=' . $case . '&target=1000'); + } + + /** + * Check if the verse is a selected verse + * + * @param int $number The verse number to check + * + * @return bool True if verse is selected + * @since 2.0.1 + */ + protected function selectedVerse(int $number): bool + { + if ($this->verses->selected && in_array($number, $this->verses->selected)) + { + return true; + } + + return false; + } + + /** + * Check if the verse is a tagged verse + * + * @param int $number The verse number to check + * + * @return int 1 = Active, 0 = no tags, -1 = Inactive + * @since 2.0.1 + */ + protected function taggedVerse(int $number): int + { + // Check the global activation status + if ($this->params->get('activate_tags') != 1) + { + return 0; // Tags are globally inactive + } + + // Check if taggedVerses is a non-empty array + if (!is_array($this->taggedverses) || empty($this->taggedverses)) + { + return -1; // No active tags + } + + // Iterate over taggedVerses to find a match + foreach ($this->taggedverses as $tag) + { + // Check if verse property exists and matches the input number + if (property_exists($tag, 'verse') && is_numeric($tag->verse) && (int) $tag->verse === $number) + { + return 1; // Verse has an active tag active + } + } + + // Verse is inactive if no match is found + return -1; + } + + /** + * Check if the verse has a note + * + * @param int $number The verse number to check + * + * @return string|null True if verse has a note + * @since 2.0.1 + */ + protected function getVerseNote(int $number): ?string + { + if ($this->notes && is_array($this->notes) && $this->notes !== []) + { + foreach ($this->notes as $note) + { + if (isset($note->verse) && is_numeric($note->verse) && (int) $note->verse === $number && + isset($note->note) && strlen($note->note) > 0 && ($this->params->get('activate_notes', 1) == 1)) + { + return $note->note; + } + } + } + + return null; + } + + /** + * Get the selected verses as an array + * + * @param string $verses The string of verses reference + * + * @return array The array of verses + * @since 2.0.1 + */ + protected function getSelectedVerses(string $verses): array + { + $result = []; + + $parts = explode(',', $verses); + foreach ($parts as $part) + { + if (strpos($part, '-') !== false) + { + list($start, $end) = explode('-', $part); + for ($i = (int)$start; $i <= (int)$end; $i++) + { + $result[] = $i; + } + } + else + { + $result[] = (int)$part; + } + } + + return $result; + } + + /** + * Get the targeted integration areas prompts + * + * @param array|null $prompts The array of prompts + * @param array $targets The array targets + * + * @return array|null The targeted prompts + * @since 2.0.1 + */ + protected function promptIntegration($prompts, array $targets): ?array + { + if (is_array($prompts) && $prompts !== [] && $targets !== []) + { + $found = []; + foreach ($prompts as $prompt) + { + if (in_array($prompt->integration, $targets)) + { + $found[] = $prompt; + } + } + + if ($found !== []) + { + return $found; + } + } + + return null; + } + + /** + * Get the Linker Details + * + * @return array The linker array. + * @since 2.0.1 + */ + protected function getLinker(): array + { + return [ + 'guid' => Factory::_('GetBible.Linker')->active(), + 'share' => Factory::_('GetBible.Linker')->share() + ]; + } + + /** + * Prepares the document + */ + protected function _prepareDocument() + { + + // Only load jQuery if needed. (default is true) + if ($this->params->get('add_jquery_framework', 1) == 1) + { + JHtml::_('jquery.framework'); + } + // Load the header checker class. + require_once( JPATH_COMPONENT_SITE.'/helpers/headercheck.php' ); + // Initialize the header checker. + $HeaderCheck = new getbibleHeaderCheck; + + // always load these files. + JHtml::_('stylesheet', "media/com_getbible/nouislider/css/nouislider.min.css", ['version' => 'auto']); + JHtml::_('script', "media/com_getbible/nouislider/js/nouislider.min.js", ['version' => 'auto']); + + // Add View JavaScript File + JHtml::_('script', "components/com_getbible/assets/js/app.js", ['version' => 'auto']); + + // Load uikit options. + $uikit = $this->params->get('uikit_load'); + // Set script size. + $size = $this->params->get('uikit_min'); + // The uikit css. + if ((!$HeaderCheck->css_loaded('uikit.min') || $uikit == 1) && $uikit != 2 && $uikit != 3) + { + JHtml::_('stylesheet', 'media/com_getbible/uikit-v3/css/uikit'.$size.'.css', ['version' => 'auto']); + } + // The uikit js. + if ((!$HeaderCheck->js_loaded('uikit.min') || $uikit == 1) && $uikit != 2 && $uikit != 3) + { + JHtml::_('script', 'media/com_getbible/uikit-v3/js/uikit'.$size.'.js', ['version' => 'auto']); + JHtml::_('script', 'media/com_getbible/uikit-v3/js/uikit-icons'.$size.'.js', ['version' => 'auto']); + } + // load the meta description + if (isset($this->item->metadesc) && $this->item->metadesc) + { + $this->document->setDescription($this->item->metadesc); + } + elseif ($this->params->get('menu-meta_description')) + { + $this->document->setDescription($this->params->get('menu-meta_description')); + } + // load the key words if set + if (isset($this->item->metakey) && $this->item->metakey) + { + $this->document->setMetadata('keywords', $this->item->metakey); + } + elseif ($this->params->get('menu-meta_keywords')) + { + $this->document->setMetadata('keywords', $this->params->get('menu-meta_keywords')); + } + // check the robot params + if (isset($this->item->robots) && $this->item->robots) + { + $this->document->setMetadata('robots', $this->item->robots); + } + elseif ($this->params->get('robots')) + { + $this->document->setMetadata('robots', $this->params->get('robots')); + } + // check if autor is to be set + if (isset($this->item->created_by) && $this->params->get('MetaAuthor') == '1') + { + $this->document->setMetaData('author', $this->item->created_by); + } + // check if metadata is available + if (isset($this->item->metadata) && $this->item->metadata) + { + $mdata = json_decode($this->item->metadata,true); + foreach ($mdata as $k => $v) + { + if ($v) + { + $this->document->setMetadata($k, $v); + } + } + } + // get color + $verse_selected_color = $this->params->get('verse_selected_color', '#4747ff'); + + // get search defaults + $search_words = $this->params->get('search_words', 1); + $search_match = $this->params->get('search_match', 1); + $search_case = $this->params->get('search_case', 1); + + // set the ajax url + $url_ajax = JUri::base() . 'index.php?option=com_getbible&format=json&raw=true&' . JSession::getFormToken() . '=1&task=ajax.'; + + // set some lang + JText::script('COM_GETBIBLE_VIEW_ALL_VERSES_TAGGED'); + // add the document default css file + JHtml::_('stylesheet', 'components/com_getbible/assets/css/app.css', ['version' => 'auto']); + // Set the Custom CSS script to view + $this->document->addStyleDeclaration(" + .getbible-verse-selected { + font-weight: bolder; + color: $verse_selected_color; + } + "); + // Set the Custom JS script to view + $this->document->addScriptDeclaration(" + const UrlAjax = '$url_ajax'; + + const getShareHisWordUrl = (linker, translation, book, chapter) => { + // build share His Word url + return UrlAjax + + 'getShareHisWordUrl&translation=' + translation + + '&linker=' + linker + '&book=' + book + + '&chapter=' + chapter; + }; + + const getCheckValidLinkerUrl = (linker, oldLinker) => { + // build share His Word url + return UrlAjax + + 'checkValidLinker&linker=' + linker + '&old=' + oldLinker; + }; + + const getSearchURL = (search, translation) => { + // build search url + return UrlAjax + + 'getSearchUrl&translation=' + translation + + '&words=$search_words' + '&match=$search_match' + + '&case=$search_case' + '&target=1000' + + '&book=' + 0 + '&search=' + search; + }; + + const getOpenaiURL = (guid, words, verse, chapter, book, translation) => { + // build open ai url + return UrlAjax + + 'getOpenaiURL&translation=' + translation + + '&guid=' + guid + '&book=' + book + + '&chapter=' + chapter + '&verse=' + verse + + '&words=' + words; + }; + + const getSetLinkerURL = (linker) => { + // build set linker url + return UrlAjax + + 'setLinker&linker=' + linker; + }; + + const getSetLinkerAccessURL = (linker, pass, oldPass) => { + // build set linker access url + return UrlAjax + 'setLinkerAccess'; + }; + + const getSetNoteURL = () => { + // build set note url + return UrlAjax + 'setNote'; + }; + + const getSetTagURL = (name) => { + // build create tag url + return UrlAjax + + 'setTag&name=' + name; + }; + + const getTagVerseURL = (translation, book, chapter, verse, tag) => { + // build set tag url + return UrlAjax + + 'tagVerse&translation=' + translation + '&book=' + book + '&chapter=' + chapter + + '&verse=' + verse + '&tag=' + tag; + }; + + const getRemoveTagFromVerseURL = (tag) => { + // build set tag url + return UrlAjax + + 'removeTagFromVerse&tag=' + tag; + }; + + const installBibleChapterURL = (translation, book, chapter) => { + // build load Bible url + return UrlAjax + 'installBibleChapter&translation=' + translation + + '&book=' + book + '&chapter=' + chapter; + }; + "); + } + + /** + * Setting the toolbar + */ + protected function addToolBar() + { + + // set help url for this view if found + $this->help_url = GetbibleHelper::getHelpUrl('app'); + if (GetbibleHelper::checkString($this->help_url)) + { + JToolbarHelper::help('COM_GETBIBLE_HELP_MANAGER', false, $this->help_url); + } + // now initiate the toolbar + $this->toolbar = JToolbar::getInstance(); + } + + /** + * Get the modules published in a position + */ + public function getModules($position, $seperator = '', $class = '') + { + // set default + $found = false; + // check if we aleady have these modules loaded + if (isset($this->setModules[$position])) + { + $found = true; + } + else + { + // this is where you want to load your module position + $modules = JModuleHelper::getModules($position); + if (GetbibleHelper::checkArray($modules, true)) + { + // set the place holder + $this->setModules[$position] = array(); + foreach($modules as $module) + { + $this->setModules[$position][] = JModuleHelper::renderModule($module); + } + $found = true; + } + } + // check if modules were found + if ($found && isset($this->setModules[$position]) && GetbibleHelper::checkArray($this->setModules[$position])) + { + // set class + if (GetbibleHelper::checkString($class)) + { + $class = ' class="'.$class.'" '; + } + // set seperating return values + switch($seperator) + { + case 'none': + return implode('', $this->setModules[$position]); + break; + case 'div': + return ''.implode('
', $this->setModules[$position]).'
'; + break; + case 'list': + return '
  • '.implode('
  • ', $this->setModules[$position]).'
  • '; + break; + case 'array': + case 'Array': + return $this->setModules[$position]; + break; + default: + return implode('
    ', $this->setModules[$position]); + break; + + } + } + return false; + } + + /** + * Escapes a value for output in a view script. + * + * @param mixed $var The output to escape. + * + * @return mixed The escaped value. + */ + public function escape($var, $sorten = false, $length = 40) + { + // use the helper htmlEscape method instead. + return GetbibleHelper::htmlEscape($var, $this->_charset, $sorten, $length); + } +} diff --git a/site/views/index.html b/site/views/index.html new file mode 100644 index 0000000..fa6d84e --- /dev/null +++ b/site/views/index.html @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/site/views/openai/index.html b/site/views/openai/index.html new file mode 100644 index 0000000..fa6d84e --- /dev/null +++ b/site/views/openai/index.html @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/site/views/openai/tmpl/default.php b/site/views/openai/tmpl/default.php new file mode 100644 index 0000000..1d750c6 --- /dev/null +++ b/site/views/openai/tmpl/default.php @@ -0,0 +1,37 @@ + + @git Get Bible + @github Get Bible + @support Get Bible + @copyright Copyright (C) 2015. All Rights Reserved + @license GNU/GPL Version 2 or later - http://www.gnu.org/licenses/gpl-2.0.html + +/------------------------------------------------------------------------------------------------------*/ + +// No direct access to this file +defined('_JEXEC') or die('Restricted access'); + + +?> + +item): ?> + loadTemplate('getbibleai'); ?> + item) > 1) : ?> + loadTemplate('getbibleaifilter'); ?> + + +
    +

    +

    +
    + +params->get('debug') == 1): ?> + loadTemplate('getbibleaidebug'); ?> + diff --git a/site/views/openai/tmpl/default_getbibleai.php b/site/views/openai/tmpl/default_getbibleai.php new file mode 100644 index 0000000..a0b37a0 --- /dev/null +++ b/site/views/openai/tmpl/default_getbibleai.php @@ -0,0 +1,43 @@ + + @git Get Bible + @github Get Bible + @support Get Bible + @copyright Copyright (C) 2015. All Rights Reserved + @license GNU/GPL Version 2 or later - http://www.gnu.org/licenses/gpl-2.0.html + +/------------------------------------------------------------------------------------------------------*/ + +// No direct access to this file +defined('_JEXEC') or die('Restricted access'); + +?> +
    +
    +
    +
    +
    + params->get('show_top_menu') == 1): ?> + loadTemplate('getbibleaitopmenu'); ?> + + loadTemplate('getbibleaibody'); ?> + params->get('show_bottom_menu') == 1): ?> + loadTemplate('getbibleaibottommenu'); ?> + +
    + params->get('show_getbible_link') == 1): ?> +
    + loadTemplate('getbibleaifooter'); ?> +
    + +
    +
    +
    +
    diff --git a/site/views/openai/tmpl/default_getbibleaibody.php b/site/views/openai/tmpl/default_getbibleaibody.php new file mode 100644 index 0000000..bff1495 --- /dev/null +++ b/site/views/openai/tmpl/default_getbibleaibody.php @@ -0,0 +1,73 @@ + + @git Get Bible + @github Get Bible + @support Get Bible + @copyright Copyright (C) 2015. All Rights Reserved + @license GNU/GPL Version 2 or later - http://www.gnu.org/licenses/gpl-2.0.html + +/------------------------------------------------------------------------------------------------------*/ + +// No direct access to this file +defined('_JEXEC') or die('Restricted access'); + +$type = $this->params->get('top_menu_type'); +if ($type == 2) +{ + $menu_type = ' uk-card-body'; +} +else +{ + $menu_type = ' uk-card-small'; +} + +$ai_card = ($this->params->get('show_ai_card') == 1) ? 'uk-card uk-card-' . $this->params->get('ai_card_style', 'default') . ' uk-card-body' : 'uk-card' . $menu_type; +$prompt_card = ($this->params->get('show_prompt_card') == 1) ? 'uk-card uk-card-' . $this->params->get('prompt_card_style', 'default') . ' uk-card-body' : 'uk-card' . $menu_type; + +if ($this->params->get('show_prompt_settings', 1) == 1) +{ + $settings_card = ($this->params->get('show_prompt_settings_card') == 1) ? 'uk-card uk-card-' . $this->params->get('prompt_settings_card_style', 'default') . ' uk-card-body' : 'uk-card' . $menu_type; +} + +if ($this->params->get('show_openai_details', 1) == 1) +{ + $details_card = ($this->params->get('show_openai_details_card') == 1) ? 'uk-card uk-card-' . $this->params->get('openai_details_card_style', 'default') . ' uk-card-body' : 'uk-card' . $menu_type; +} + +?> +
      +
    • +
      + loadTemplate('getbibleaimessages'); ?> +
      +
    • +
    • +
      + loadTemplate('getbibleaipromptmessages'); ?> +
      +
    • + params->get('show_prompt_settings', 1) == 1): ?> +
    • +
      + loadTemplate('getbiblepromptsettings'); ?> +
      +
    • + + params->get('show_openai_details', 1) == 1): ?> +
    • +
      + loadTemplate('getbibleaidetails'); ?> +
      +
    • + + params->get('set_custom_ai_tabs') == 1): ?> + loadTemplate('getbibleaicustomtabs'); ?> + +
    diff --git a/site/views/openai/tmpl/default_getbibleaibottommenu.php b/site/views/openai/tmpl/default_getbibleaibottommenu.php new file mode 100644 index 0000000..67cb83e --- /dev/null +++ b/site/views/openai/tmpl/default_getbibleaibottommenu.php @@ -0,0 +1,53 @@ + + @git Get Bible + @github Get Bible + @support Get Bible + @copyright Copyright (C) 2015. All Rights Reserved + @license GNU/GPL Version 2 or later - http://www.gnu.org/licenses/gpl-2.0.html + +/------------------------------------------------------------------------------------------------------*/ + +// No direct access to this file +defined('_JEXEC') or die('Restricted access'); + +$type = $this->params->get('bottom_menu_type'); + +if ($type == 2) +{ + $menu_type = 'class="uk-margin-small uk-flex-center" uk-tab '; +} +else +{ + $menu_type = 'class="el-nav uk-margin-small uk-subnav uk-subnav-pill uk-flex-center" '; +} + +?> +
      uk-switcher="connect: #get-bible-ai-body; animation: uk-animation-scale-up;"> +
    • + +
    • +
    • + +
    • + params->get('show_prompt_settings', 1) == 1): ?> +
    • + +
    • + + params->get('show_openai_details', 1) == 1): ?> +
    • + +
    • + + params->get('set_custom_ai_tabs') == 1): ?> + loadTemplate('getbibleaicustomtabsmenu'); ?> + +
    diff --git a/site/views/openai/tmpl/default_getbibleaicustomtabs.php b/site/views/openai/tmpl/default_getbibleaicustomtabs.php new file mode 100644 index 0000000..031cdcc --- /dev/null +++ b/site/views/openai/tmpl/default_getbibleaicustomtabs.php @@ -0,0 +1,53 @@ + + @git Get Bible + @github Get Bible + @support Get Bible + @copyright Copyright (C) 2015. All Rights Reserved + @license GNU/GPL Version 2 or later - http://www.gnu.org/licenses/gpl-2.0.html + +/------------------------------------------------------------------------------------------------------*/ + +// No direct access to this file +defined('_JEXEC') or die('Restricted access'); +use VDM\Joomla\Utilities\ObjectHelper; + +$modules = $this->params->get('custom_ai_tabs'); +$tabs = []; +if (ObjectHelper::check($modules)) +{ + foreach ($modules as $module) + { + if (isset($module->position) && strlen($module->position) > 0) + { + if (($content = $this->getModules($module->position, $module->separator ?? '', $module->class ?? '')) !== false) + { + $tabs[$module->position] = $content; + } + else + { + $tabs[$module->position] = JLayoutHelper::render('modulepositionerror', ['position' => $module->position, 'page' => 'GetBible AI']); + } + } + } +} + +$custom_tabs_card = ($this->params->get('show_custom_tabs_card') == 1) ? 'uk-card uk-card-' . $this->params->get('custom_tabs_card_style', 'default') . ' uk-card-body' : ''; + +?> + + +
  • +
    + +
    +
  • + + diff --git a/site/views/openai/tmpl/default_getbibleaicustomtabsmenu.php b/site/views/openai/tmpl/default_getbibleaicustomtabsmenu.php new file mode 100644 index 0000000..fabf1cc --- /dev/null +++ b/site/views/openai/tmpl/default_getbibleaicustomtabsmenu.php @@ -0,0 +1,42 @@ + + @git Get Bible + @github Get Bible + @support Get Bible + @copyright Copyright (C) 2015. All Rights Reserved + @license GNU/GPL Version 2 or later - http://www.gnu.org/licenses/gpl-2.0.html + +/------------------------------------------------------------------------------------------------------*/ + +// No direct access to this file +defined('_JEXEC') or die('Restricted access'); +use VDM\Joomla\Utilities\ObjectHelper; + +$modules = $this->params->get('custom_ai_tabs'); +$menus = []; +if (ObjectHelper::check($modules)) +{ + foreach ($modules as $module) + { + if (isset($module->position) && strlen($module->position) > 0) + { + $menus[$module->position] = $this->escape($module->name); + } + } +} + +?> + + +
  • + +
  • + + diff --git a/site/views/openai/tmpl/default_getbibleaidebug.php b/site/views/openai/tmpl/default_getbibleaidebug.php new file mode 100644 index 0000000..298290a --- /dev/null +++ b/site/views/openai/tmpl/default_getbibleaidebug.php @@ -0,0 +1,34 @@ + + @git Get Bible + @github Get Bible + @support Get Bible + @copyright Copyright (C) 2015. All Rights Reserved + @license GNU/GPL Version 2 or later - http://www.gnu.org/licenses/gpl-2.0.html + +/------------------------------------------------------------------------------------------------------*/ + +// No direct access to this file +defined('_JEXEC') or die('Restricted access'); + +?> +
    +

    +

    +
      +
    • + +
      +
      +item); ?>
      +
      +
      +
    • +
    diff --git a/site/views/openai/tmpl/default_getbibleaidetails.php b/site/views/openai/tmpl/default_getbibleaidetails.php new file mode 100644 index 0000000..127008f --- /dev/null +++ b/site/views/openai/tmpl/default_getbibleaidetails.php @@ -0,0 +1,28 @@ + + @git Get Bible + @github Get Bible + @support Get Bible + @copyright Copyright (C) 2015. All Rights Reserved + @license GNU/GPL Version 2 or later - http://www.gnu.org/licenses/gpl-2.0.html + +/------------------------------------------------------------------------------------------------------*/ + +// No direct access to this file +defined('_JEXEC') or die('Restricted access'); + +?> +
    +item as $response): ?> +
    + +
    + +
    diff --git a/site/views/openai/tmpl/default_getbibleaifilter.php b/site/views/openai/tmpl/default_getbibleaifilter.php new file mode 100644 index 0000000..c188731 --- /dev/null +++ b/site/views/openai/tmpl/default_getbibleaifilter.php @@ -0,0 +1,37 @@ + + @git Get Bible + @github Get Bible + @support Get Bible + @copyright Copyright (C) 2015. All Rights Reserved + @license GNU/GPL Version 2 or later - http://www.gnu.org/licenses/gpl-2.0.html + +/------------------------------------------------------------------------------------------------------*/ + +// No direct access to this file +defined('_JEXEC') or die('Restricted access'); + +?> +
      + item as $response): ?> +
    • + +
    • + response_id; + endforeach; + ?> +
    + + diff --git a/site/views/openai/tmpl/default_getbibleaifooter.php b/site/views/openai/tmpl/default_getbibleaifooter.php new file mode 100644 index 0000000..a851187 --- /dev/null +++ b/site/views/openai/tmpl/default_getbibleaifooter.php @@ -0,0 +1,25 @@ + + @git Get Bible + @github Get Bible + @support Get Bible + @copyright Copyright (C) 2015. All Rights Reserved + @license GNU/GPL Version 2 or later - http://www.gnu.org/licenses/gpl-2.0.html + +/------------------------------------------------------------------------------------------------------*/ + +// No direct access to this file +defined('_JEXEC') or die('Restricted access'); + +?> + $this->params->get('show_getbible_link'), + 'logo' => $this->params->get('show_getbible_logo') +]); ?> diff --git a/site/views/openai/tmpl/default_getbibleaimessages.php b/site/views/openai/tmpl/default_getbibleaimessages.php new file mode 100644 index 0000000..a4dd46c --- /dev/null +++ b/site/views/openai/tmpl/default_getbibleaimessages.php @@ -0,0 +1,34 @@ + + @git Get Bible + @github Get Bible + @support Get Bible + @copyright Copyright (C) 2015. All Rights Reserved + @license GNU/GPL Version 2 or later - http://www.gnu.org/licenses/gpl-2.0.html + +/------------------------------------------------------------------------------------------------------*/ + +// No direct access to this file +defined('_JEXEC') or die('Restricted access'); + +?> +
    +item as $response): ?> + messages)): ?> + messages as $message): ?> + source == 2): ?> +
    + +
    + + + + +
    diff --git a/site/views/openai/tmpl/default_getbibleaipromptmessages.php b/site/views/openai/tmpl/default_getbibleaipromptmessages.php new file mode 100644 index 0000000..b02a40c --- /dev/null +++ b/site/views/openai/tmpl/default_getbibleaipromptmessages.php @@ -0,0 +1,34 @@ + + @git Get Bible + @github Get Bible + @support Get Bible + @copyright Copyright (C) 2015. All Rights Reserved + @license GNU/GPL Version 2 or later - http://www.gnu.org/licenses/gpl-2.0.html + +/------------------------------------------------------------------------------------------------------*/ + +// No direct access to this file +defined('_JEXEC') or die('Restricted access'); + +?> +
    +item as $response): ?> + messages)): ?> + messages as $message): ?> + source == 1): ?> +
    + +
    + + + + +
    diff --git a/site/views/openai/tmpl/default_getbibleaitopmenu.php b/site/views/openai/tmpl/default_getbibleaitopmenu.php new file mode 100644 index 0000000..e7349a8 --- /dev/null +++ b/site/views/openai/tmpl/default_getbibleaitopmenu.php @@ -0,0 +1,53 @@ + + @git Get Bible + @github Get Bible + @support Get Bible + @copyright Copyright (C) 2015. All Rights Reserved + @license GNU/GPL Version 2 or later - http://www.gnu.org/licenses/gpl-2.0.html + +/------------------------------------------------------------------------------------------------------*/ + +// No direct access to this file +defined('_JEXEC') or die('Restricted access'); + +$type = $this->params->get('top_menu_type'); + +if ($type == 2) +{ + $menu_type = 'class="uk-margin-small uk-flex-center" uk-tab '; +} +else +{ + $menu_type = 'class="el-nav uk-margin-small uk-subnav uk-subnav-pill uk-flex-center" '; +} + +?> +
      uk-switcher="connect: #get-bible-ai-body; animation: uk-animation-scale-up;"> +
    • + +
    • +
    • + +
    • + params->get('show_prompt_settings', 1) == 1): ?> +
    • + +
    • + + params->get('show_openai_details', 1) == 1): ?> +
    • + +
    • + + params->get('set_custom_ai_tabs') == 1): ?> + loadTemplate('getbibleaicustomtabsmenu'); ?> + +
    diff --git a/site/views/openai/tmpl/default_getbiblepromptsettings.php b/site/views/openai/tmpl/default_getbiblepromptsettings.php new file mode 100644 index 0000000..1938e2e --- /dev/null +++ b/site/views/openai/tmpl/default_getbiblepromptsettings.php @@ -0,0 +1,28 @@ + + @git Get Bible + @github Get Bible + @support Get Bible + @copyright Copyright (C) 2015. All Rights Reserved + @license GNU/GPL Version 2 or later - http://www.gnu.org/licenses/gpl-2.0.html + +/------------------------------------------------------------------------------------------------------*/ + +// No direct access to this file +defined('_JEXEC') or die('Restricted access'); + +?> +
    +item as $response): ?> +
    + +
    + +
    diff --git a/site/views/openai/tmpl/index.html b/site/views/openai/tmpl/index.html new file mode 100644 index 0000000..fa6d84e --- /dev/null +++ b/site/views/openai/tmpl/index.html @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/site/views/openai/view.html.php b/site/views/openai/view.html.php new file mode 100644 index 0000000..bc49e22 --- /dev/null +++ b/site/views/openai/view.html.php @@ -0,0 +1,183 @@ + + @git Get Bible + @github Get Bible + @support Get Bible + @copyright Copyright (C) 2015. All Rights Reserved + @license GNU/GPL Version 2 or later - http://www.gnu.org/licenses/gpl-2.0.html + +/------------------------------------------------------------------------------------------------------*/ + +// No direct access to this file +defined('_JEXEC') or die('Restricted access'); +jimport('joomla.application.module.helper'); + +use Joomla\CMS\MVC\View\HtmlView; + +/** + * Getbible Html View class for the Openai + */ +class GetbibleViewOpenai extends HtmlView +{ + // Overwriting JView display method + function display($tpl = null) + { + // get combined params of both component and menu + $this->app = JFactory::getApplication(); + $this->params = $this->app->getParams(); + $this->menu = $this->app->getMenu()->getActive(); + // get the user object + $this->user = JFactory::getUser(); + // Initialise variables. + $this->item = $this->get('Item'); + $this->translation = $this->get('Translation'); + + // Set the toolbar + $this->addToolBar(); + + // set the document + $this->_prepareDocument(); + + // Check for errors. + if (count($errors = $this->get('Errors'))) + { + throw new Exception(implode(PHP_EOL, $errors), 500); + } + + parent::display($tpl); + } + + /** + * Prepares the document + */ + protected function _prepareDocument() + { + + // Only load jQuery if needed. (default is true) + if ($this->params->get('add_jquery_framework', 1) == 1) + { + JHtml::_('jquery.framework'); + } + // Load the header checker class. + require_once( JPATH_COMPONENT_SITE.'/helpers/headercheck.php' ); + // Initialize the header checker. + $HeaderCheck = new getbibleHeaderCheck; + + // Add View JavaScript File + JHtml::_('script', "components/com_getbible/assets/js/openai.js", ['version' => 'auto']); + + // Load uikit options. + $uikit = $this->params->get('uikit_load'); + // Set script size. + $size = $this->params->get('uikit_min'); + // The uikit css. + if ((!$HeaderCheck->css_loaded('uikit.min') || $uikit == 1) && $uikit != 2 && $uikit != 3) + { + JHtml::_('stylesheet', 'media/com_getbible/uikit-v3/css/uikit'.$size.'.css', ['version' => 'auto']); + } + // The uikit js. + if ((!$HeaderCheck->js_loaded('uikit.min') || $uikit == 1) && $uikit != 2 && $uikit != 3) + { + JHtml::_('script', 'media/com_getbible/uikit-v3/js/uikit'.$size.'.js', ['version' => 'auto']); + JHtml::_('script', 'media/com_getbible/uikit-v3/js/uikit-icons'.$size.'.js', ['version' => 'auto']); + } + // add the document default css file + JHtml::_('stylesheet', 'components/com_getbible/assets/css/openai.css', ['version' => 'auto']); + } + + /** + * Setting the toolbar + */ + protected function addToolBar() + { + + // set help url for this view if found + $this->help_url = GetbibleHelper::getHelpUrl('openai'); + if (GetbibleHelper::checkString($this->help_url)) + { + JToolbarHelper::help('COM_GETBIBLE_HELP_MANAGER', false, $this->help_url); + } + // now initiate the toolbar + $this->toolbar = JToolbar::getInstance(); + } + + /** + * Get the modules published in a position + */ + public function getModules($position, $seperator = '', $class = '') + { + // set default + $found = false; + // check if we aleady have these modules loaded + if (isset($this->setModules[$position])) + { + $found = true; + } + else + { + // this is where you want to load your module position + $modules = JModuleHelper::getModules($position); + if (GetbibleHelper::checkArray($modules, true)) + { + // set the place holder + $this->setModules[$position] = array(); + foreach($modules as $module) + { + $this->setModules[$position][] = JModuleHelper::renderModule($module); + } + $found = true; + } + } + // check if modules were found + if ($found && isset($this->setModules[$position]) && GetbibleHelper::checkArray($this->setModules[$position])) + { + // set class + if (GetbibleHelper::checkString($class)) + { + $class = ' class="'.$class.'" '; + } + // set seperating return values + switch($seperator) + { + case 'none': + return implode('', $this->setModules[$position]); + break; + case 'div': + return ''.implode('
    ', $this->setModules[$position]).'
    '; + break; + case 'list': + return '
  • '.implode('
  • ', $this->setModules[$position]).'
  • '; + break; + case 'array': + case 'Array': + return $this->setModules[$position]; + break; + default: + return implode('
    ', $this->setModules[$position]); + break; + + } + } + return false; + } + + /** + * Escapes a value for output in a view script. + * + * @param mixed $var The output to escape. + * + * @return mixed The escaped value. + */ + public function escape($var, $sorten = false, $length = 40) + { + // use the helper htmlEscape method instead. + return GetbibleHelper::htmlEscape($var, $this->_charset, $sorten, $length); + } +} diff --git a/site/views/search/index.html b/site/views/search/index.html new file mode 100644 index 0000000..fa6d84e --- /dev/null +++ b/site/views/search/index.html @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/site/views/search/tmpl/default.php b/site/views/search/tmpl/default.php new file mode 100644 index 0000000..9d4f4d5 --- /dev/null +++ b/site/views/search/tmpl/default.php @@ -0,0 +1,30 @@ + + @git Get Bible + @github Get Bible + @support Get Bible + @copyright Copyright (C) 2015. All Rights Reserved + @license GNU/GPL Version 2 or later - http://www.gnu.org/licenses/gpl-2.0.html + +/------------------------------------------------------------------------------------------------------*/ + +// No direct access to this file +defined('_JEXEC') or die('Restricted access'); + + +?> + +params->get('activate_search') == 1): ?> + loadTemplate('getbiblesearch'); ?> + +
    +

    +
    + diff --git a/site/views/search/tmpl/default_getbiblesearch.php b/site/views/search/tmpl/default_getbiblesearch.php new file mode 100644 index 0000000..bc1536c --- /dev/null +++ b/site/views/search/tmpl/default_getbiblesearch.php @@ -0,0 +1,34 @@ + + @git Get Bible + @github Get Bible + @support Get Bible + @copyright Copyright (C) 2015. All Rights Reserved + @license GNU/GPL Version 2 or later - http://www.gnu.org/licenses/gpl-2.0.html + +/------------------------------------------------------------------------------------------------------*/ + +// No direct access to this file +defined('_JEXEC') or die('Restricted access'); + +?> +loadTemplate('getbiblesearchinput'); ?> +loadTemplate('getbiblesearchnotenoughverses'); ?> +items): ?> + loadTemplate('getbiblesearchtable'); ?> + +
    + search) > 0): ?> +

    + +

    + +
    + diff --git a/site/views/search/tmpl/default_getbiblesearchbox.php b/site/views/search/tmpl/default_getbiblesearchbox.php new file mode 100644 index 0000000..4c6da9d --- /dev/null +++ b/site/views/search/tmpl/default_getbiblesearchbox.php @@ -0,0 +1,46 @@ + + @git Get Bible + @github Get Bible + @support Get Bible + @copyright Copyright (C) 2015. All Rights Reserved + @license GNU/GPL Version 2 or later - http://www.gnu.org/licenses/gpl-2.0.html + +/------------------------------------------------------------------------------------------------------*/ + +// No direct access to this file +defined('_JEXEC') or die('Restricted access'); + +?> + + diff --git a/site/views/search/tmpl/default_getbiblesearchinput.php b/site/views/search/tmpl/default_getbiblesearchinput.php new file mode 100644 index 0000000..8d12a29 --- /dev/null +++ b/site/views/search/tmpl/default_getbiblesearchinput.php @@ -0,0 +1,55 @@ + + @git Get Bible + @github Get Bible + @support Get Bible + @copyright Copyright (C) 2015. All Rights Reserved + @license GNU/GPL Version 2 or later - http://www.gnu.org/licenses/gpl-2.0.html + +/------------------------------------------------------------------------------------------------------*/ + +// No direct access to this file +defined('_JEXEC') or die('Restricted access'); + +?> +
    + loadTemplate('getbiblesearchbox'); ?> + loadTemplate('getbiblesearchoptions'); ?> +
    + diff --git a/site/views/search/tmpl/default_getbiblesearchnotenoughverses.php b/site/views/search/tmpl/default_getbiblesearchnotenoughverses.php new file mode 100644 index 0000000..84cad87 --- /dev/null +++ b/site/views/search/tmpl/default_getbiblesearchnotenoughverses.php @@ -0,0 +1,26 @@ + + @git Get Bible + @github Get Bible + @support Get Bible + @copyright Copyright (C) 2015. All Rights Reserved + @license GNU/GPL Version 2 or later - http://www.gnu.org/licenses/gpl-2.0.html + +/------------------------------------------------------------------------------------------------------*/ + +// No direct access to this file +defined('_JEXEC') or die('Restricted access'); + +?> +enoughVerses): ?> +
    +

    translation->translation); ?>

    +
    + diff --git a/site/views/search/tmpl/default_getbiblesearchoptions.php b/site/views/search/tmpl/default_getbiblesearchoptions.php new file mode 100644 index 0000000..387c13d --- /dev/null +++ b/site/views/search/tmpl/default_getbiblesearchoptions.php @@ -0,0 +1,114 @@ + + @git Get Bible + @github Get Bible + @support Get Bible + @copyright Copyright (C) 2015. All Rights Reserved + @license GNU/GPL Version 2 or later - http://www.gnu.org/licenses/gpl-2.0.html + +/------------------------------------------------------------------------------------------------------*/ + +// No direct access to this file +defined('_JEXEC') or die('Restricted access'); + +?> + + diff --git a/site/views/search/tmpl/default_getbiblesearchtable.php b/site/views/search/tmpl/default_getbiblesearchtable.php new file mode 100644 index 0000000..f8e5ce2 --- /dev/null +++ b/site/views/search/tmpl/default_getbiblesearchtable.php @@ -0,0 +1,98 @@ + + @git Get Bible + @github Get Bible + @support Get Bible + @copyright Copyright (C) 2015. All Rights Reserved + @license GNU/GPL Version 2 or later - http://www.gnu.org/licenses/gpl-2.0.html + +/------------------------------------------------------------------------------------------------------*/ + +// No direct access to this file +defined('_JEXEC') or die('Restricted access'); + +$table_id = 'getbible_search_result_table'; +$headers = [ + 'abbreviation' => JText::_('COM_GETBIBLE_TRANSLATION'), + 'book_nr' => JText::_('COM_GETBIBLE_BOOK_NUMBER'), + 'name' => JText::_('COM_GETBIBLE_BOOK_NAME'), + 'chapter' => JText::_('COM_GETBIBLE_CHAPTER'), + 'verse' => JText::_('COM_GETBIBLE_VERSE'), + 'text' => JText::_('COM_GETBIBLE_SCRIPTURE') +]; + +?> +items) >= 1000): ?> + + + $table_id, + 'table_class' => 'uk-table uk-table-hover uk-table-striped uk-width-1-1 direction-' . strtolower($this->translation->direction) . '" dir="' . $this->translation->direction . '"', + 'name' => JText::_('COM_GETBIBLE_SEARCH_RESULTS'), + 'headers' => $headers, + 'items' => $this->items, + 'init' => false + ] +); ?> + diff --git a/site/views/search/tmpl/index.html b/site/views/search/tmpl/index.html new file mode 100644 index 0000000..fa6d84e --- /dev/null +++ b/site/views/search/tmpl/index.html @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/site/views/search/view.html.php b/site/views/search/view.html.php new file mode 100644 index 0000000..752cc51 --- /dev/null +++ b/site/views/search/view.html.php @@ -0,0 +1,224 @@ + + @git Get Bible + @github Get Bible + @support Get Bible + @copyright Copyright (C) 2015. All Rights Reserved + @license GNU/GPL Version 2 or later - http://www.gnu.org/licenses/gpl-2.0.html + +/------------------------------------------------------------------------------------------------------*/ + +// No direct access to this file +defined('_JEXEC') or die('Restricted access'); + +use Joomla\CMS\MVC\View\HtmlView; +use VDM\Joomla\GetBible\Factory; + +/** + * Getbible Html View class for the Search + */ +class GetbibleViewSearch extends HtmlView +{ + // Overwriting JView display method + function display($tpl = null) + { + // get combined params of both component and menu + $this->app = JFactory::getApplication(); + $this->params = $this->app->getParams(); + $this->menu = $this->app->getMenu()->getActive(); + // get the user object + $this->user = JFactory::getUser(); + // Initialise variables. + $this->items = $this->get('Items'); + $this->translations = $this->get('Translations'); + $this->books = $this->get('Books'); + $this->translation = $this->get('Translation'); + if ($this->params->get('activate_search') == 1) + { + $this->input = $this->app->input; + + // set the search Params + $this->setSearchParams(); + + // set the enough verses witch + $this->enoughVerses = Factory::_('GetBible.Watcher')->enoughVerses($this->translation->abbreviation ?? 'kjv'); + } + + // Set the toolbar + $this->addToolBar(); + + // set the document + $this->_prepareDocument(); + + // Check for errors. + if (count($errors = $this->get('Errors'))) + { + throw new Exception(implode(PHP_EOL, $errors), 500); + } + + parent::display($tpl); + } + + /** + * Set the search params + * + * @return void + * @since 2.0.1 + */ + public function setSearchParams() + { + $this->words = $this->input->getInt('words', $this->params->get('search_word', 1)); + $this->match = $this->input->getInt('match', $this->params->get('search_match', 1)); + $this->case = $this->input->getInt('case', $this->params->get('search_case', 1)); + $this->target = $this->input->getInt('target', 1000); + $this->target = ($this->target == 4000) ? $this->input->getInt('book') : $this->target; + $this->search = $this->input->getString('search') ?? $this->input->getString('s') ?? ''; + + // set the value names + $words = [ + 1 => JText::_('COM_GETBIBLE_ALL_WORDS'), + 2 => JText::_('COM_GETBIBLE_ANY_WORDS'), + 3 => JText::_('COM_GETBIBLE_EXACT_WORDS') + ]; + $match = [ + 1 => JText::_('COM_GETBIBLE_EXACT_MATCH'), + 2 => JText::_('COM_GETBIBLE_PARTIAL_MATCH') + ]; + $case = [ + 1 => JText::_('COM_GETBIBLE_CASE_INSENSITIVE'), + 2 => JText::_('COM_GETBIBLE_CASE_SENSITIVE') + ]; + $target = [ + 1000 => JText::_('COM_GETBIBLE_ALL_BOOKS'), + 2000 => JText::_('COM_GETBIBLE_OLD_TESTAMENT'), + 3000 => JText::_('COM_GETBIBLE_NEW_TESTAMENT'), + 4000 => JText::_('COM_GETBIBLE_A_BOOK') + ]; + + $this->options_text = []; + $this->options_text[] = $words[$this->words] ?? JText::_('COM_GETBIBLE_ALL_WORDS'); + $this->options_text[] = $match[$this->match] ?? JText::_('COM_GETBIBLE_EXACT_MATCH'); + $this->options_text[] = $case[$this->case] ?? JText::_('COM_GETBIBLE_CASE_INSENSITIVE'); + $this->options_text[] = $target[$this->target] ?? JText::_('COM_GETBIBLE_A_BOOK'); + + // set the current search URL + $this->url_search = JRoute::_('index.php?option=com_getbible&view=search&t=' . $this->translation->abbreviation . '&words=' . $this->words . '&match=' . $this->match . '&case=' . $this->case . '&target=' . $this->target . '&search=' . $this->search); + $this->url_base = JUri::base(); + $this->url_bible = JRoute::_('index.php?option=com_getbible&view=app&Itemid=' . $this->params->get('app_menu', 0) . '&t=' . $this->translation->abbreviation); + + // referer the referer page + //$referer = $this->input->server->get('HTTP_REFERER', null, 'STRING'); + //if (strpos($referer, $this->url_bible) !== null && strpos($referer, $this->url_base) !== null) + //{ + // $this->url_bible = $referer; // needs more work! + //} + } + + /** + * Prepares the document + */ + protected function _prepareDocument() + { + + // Only load jQuery if needed. (default is true) + if ($this->params->get('add_jquery_framework', 1) == 1) + { + JHtml::_('jquery.framework'); + } + // Load the header checker class. + require_once( JPATH_COMPONENT_SITE.'/helpers/headercheck.php' ); + // Initialize the header checker. + $HeaderCheck = new getbibleHeaderCheck; + + // always load these files. + JHtml::_('stylesheet', "media/com_getbible/datatable/css/datatables.min.css", ['version' => 'auto']); + JHtml::_('script', "media/com_getbible/datatable/js/pdfmake.min.js", ['version' => 'auto']); + JHtml::_('script', "media/com_getbible/datatable/js/vfs_fonts.js", ['version' => 'auto']); + JHtml::_('script', "media/com_getbible/datatable/js/datatables.min.js", ['version' => 'auto']); + + // Add View JavaScript File + JHtml::_('script', "components/com_getbible/assets/js/search.js", ['version' => 'auto']); + + // Load uikit options. + $uikit = $this->params->get('uikit_load'); + // Set script size. + $size = $this->params->get('uikit_min'); + // The uikit css. + if ((!$HeaderCheck->css_loaded('uikit.min') || $uikit == 1) && $uikit != 2 && $uikit != 3) + { + JHtml::_('stylesheet', 'media/com_getbible/uikit-v3/css/uikit'.$size.'.css', ['version' => 'auto']); + } + // The uikit js. + if ((!$HeaderCheck->js_loaded('uikit.min') || $uikit == 1) && $uikit != 2 && $uikit != 3) + { + JHtml::_('script', 'media/com_getbible/uikit-v3/js/uikit'.$size.'.js', ['version' => 'auto']); + JHtml::_('script', 'media/com_getbible/uikit-v3/js/uikit-icons'.$size.'.js', ['version' => 'auto']); + } + $search_found_color = $this->params->get('search_found_color', '#4747ff'); + $table_selection_color = $this->params->get('table_selection_color', '#dfdfdf'); + // add the document default css file + JHtml::_('stylesheet', 'components/com_getbible/assets/css/search.css', ['version' => 'auto']); + // Set the Custom CSS script to view + $this->document->addStyleDeclaration(" + .uk-table tr { + cursor: pointer; + } + .uk-table table.dataTable tbody > tr.selected, .uk-table table.dataTable tbody > tr > .selected { + background-color: $table_selection_color; + } + .uk-table tr.selected td { + background-color: $table_selection_color; + } + .getbible-word-found { + font-weight: bolder; + color: $search_found_color; + } + .direction-rtl { + direction: rtl; + text-align: right; + unicode-bidi: bidi-override; + } + .direction-ltr { + direction: ltr; + text-align: left; + unicode-bidi: bidi-override; + } + "); + } + + /** + * Setting the toolbar + */ + protected function addToolBar() + { + + // set help url for this view if found + $this->help_url = GetbibleHelper::getHelpUrl('search'); + if (GetbibleHelper::checkString($this->help_url)) + { + JToolbarHelper::help('COM_GETBIBLE_HELP_MANAGER', false, $this->help_url); + } + // now initiate the toolbar + $this->toolbar = JToolbar::getInstance(); + } + + /** + * Escapes a value for output in a view script. + * + * @param mixed $var The output to escape. + * + * @return mixed The escaped value. + */ + public function escape($var, $sorten = false, $length = 40) + { + // use the helper htmlEscape method instead. + return GetbibleHelper::htmlEscape($var, $this->_charset, $sorten, $length); + } +} diff --git a/site/views/tag/index.html b/site/views/tag/index.html new file mode 100644 index 0000000..fa6d84e --- /dev/null +++ b/site/views/tag/index.html @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/site/views/tag/tmpl/default.php b/site/views/tag/tmpl/default.php new file mode 100644 index 0000000..b8e1b22 --- /dev/null +++ b/site/views/tag/tmpl/default.php @@ -0,0 +1,38 @@ + + @git Get Bible + @github Get Bible + @support Get Bible + @copyright Copyright (C) 2015. All Rights Reserved + @license GNU/GPL Version 2 or later - http://www.gnu.org/licenses/gpl-2.0.html + +/------------------------------------------------------------------------------------------------------*/ + +// No direct access to this file +defined('_JEXEC') or die('Restricted access'); + + +?> + +params->get('activate_tags') == 1): ?> + items)): ?> + loadTemplate('getbibletag'); ?> + + loadTemplate('getbiblenotag'); ?> + + +
    +

    +

    +
    + +params->get('debug') == 1): ?> + loadTemplate('getbibletagdebug'); ?> + diff --git a/site/views/tag/tmpl/default_getbiblenotag.php b/site/views/tag/tmpl/default_getbiblenotag.php new file mode 100644 index 0000000..c0a2a9d --- /dev/null +++ b/site/views/tag/tmpl/default_getbiblenotag.php @@ -0,0 +1,43 @@ + + @git Get Bible + @github Get Bible + @support Get Bible + @copyright Copyright (C) 2015. All Rights Reserved + @license GNU/GPL Version 2 or later - http://www.gnu.org/licenses/gpl-2.0.html + +/------------------------------------------------------------------------------------------------------*/ + +// No direct access to this file +defined('_JEXEC') or die('Restricted access'); + +?> +
    +
    +
    +
    +
    +

    tag->name ?? JText::_('COM_GETBIBLE_NO_TAG_SELECTED'); ?>

    +

    tag->description ?? ''; ?>

    +
    +

    !

    +

    +
    + loadTemplate('getbibleselecttags'); ?> +
    + params->get('show_getbible_link') == 1): ?> +
    + loadTemplate('getbibletagfooter'); ?> +
    + +
    +
    +
    +
    diff --git a/site/views/tag/tmpl/default_getbibleselecttags.php b/site/views/tag/tmpl/default_getbibleselecttags.php new file mode 100644 index 0000000..73a2547 --- /dev/null +++ b/site/views/tag/tmpl/default_getbibleselecttags.php @@ -0,0 +1,32 @@ + + @git Get Bible + @github Get Bible + @support Get Bible + @copyright Copyright (C) 2015. All Rights Reserved + @license GNU/GPL Version 2 or later - http://www.gnu.org/licenses/gpl-2.0.html + +/------------------------------------------------------------------------------------------------------*/ + +// No direct access to this file +defined('_JEXEC') or die('Restricted access'); + +?> +
    + tags as $tag): ?> +
    + tag) && isset($this->tag->guid) && $tag->guid == $this->tag->guid) :?> + + + name; ?> + +
    + +
    diff --git a/site/views/tag/tmpl/default_getbibletag.php b/site/views/tag/tmpl/default_getbibletag.php new file mode 100644 index 0000000..d6f2058 --- /dev/null +++ b/site/views/tag/tmpl/default_getbibletag.php @@ -0,0 +1,43 @@ + + @git Get Bible + @github Get Bible + @support Get Bible + @copyright Copyright (C) 2015. All Rights Reserved + @license GNU/GPL Version 2 or later - http://www.gnu.org/licenses/gpl-2.0.html + +/------------------------------------------------------------------------------------------------------*/ + +// No direct access to this file +defined('_JEXEC') or die('Restricted access'); + +?> +
    +
    +
    +
    +
    + params->get('show_top_menu') == 1): ?> + loadTemplate('getbibletagtopmenu'); ?> + + loadTemplate('getbibletagbody'); ?> + params->get('show_bottom_menu') == 1): ?> + loadTemplate('getbibletagbottommenu'); ?> + +
    + params->get('show_getbible_link') == 1): ?> +
    + loadTemplate('getbibletagfooter'); ?> +
    + +
    +
    +
    +
    diff --git a/site/views/tag/tmpl/default_getbibletagbody.php b/site/views/tag/tmpl/default_getbibletagbody.php new file mode 100644 index 0000000..57e4c7c --- /dev/null +++ b/site/views/tag/tmpl/default_getbibletagbody.php @@ -0,0 +1,52 @@ + + @git Get Bible + @github Get Bible + @support Get Bible + @copyright Copyright (C) 2015. All Rights Reserved + @license GNU/GPL Version 2 or later - http://www.gnu.org/licenses/gpl-2.0.html + +/------------------------------------------------------------------------------------------------------*/ + +// No direct access to this file +defined('_JEXEC') or die('Restricted access'); + +$type = $this->params->get('top_menu_type'); +if ($type == 2) +{ + $menu_type = ' uk-card-body'; +} +else +{ + $menu_type = ' uk-card-small'; +} + +$tagged_card = ($this->params->get('show_tagged_card') == 1) ? 'uk-card uk-card-' . $this->params->get('tagged_card_style', 'default') . ' uk-card-body' : 'uk-card' . $menu_type; +$tags_card = ($this->params->get('show_tags_card') == 1) ? 'uk-card uk-card-' . $this->params->get('tags_card_style', 'default') . ' uk-card-body' : 'uk-card' . $menu_type; + +?> +
      +
    • +
      +

      tag->name; ?>

      +

      tag->description; ?>

      + loadTemplate('getbibletagparagraphssorter'); ?> + loadTemplate('getbibletagparagraphs'); ?> +
      +
    • +
    • +
      + loadTemplate('getbibleselecttags'); ?> +
      +
    • + params->get('set_custom_tag_tabs') == 1): ?> + loadTemplate('getbibletagcustomtabs'); ?> + +
    diff --git a/site/views/tag/tmpl/default_getbibletagbottommenu.php b/site/views/tag/tmpl/default_getbibletagbottommenu.php new file mode 100644 index 0000000..1437efa --- /dev/null +++ b/site/views/tag/tmpl/default_getbibletagbottommenu.php @@ -0,0 +1,43 @@ + + @git Get Bible + @github Get Bible + @support Get Bible + @copyright Copyright (C) 2015. All Rights Reserved + @license GNU/GPL Version 2 or later - http://www.gnu.org/licenses/gpl-2.0.html + +/------------------------------------------------------------------------------------------------------*/ + +// No direct access to this file +defined('_JEXEC') or die('Restricted access'); + +$type = $this->params->get('bottom_menu_type'); + +if ($type == 2) +{ + $menu_type = 'class="uk-margin-small uk-flex-center" uk-tab '; +} +else +{ + $menu_type = 'class="el-nav uk-margin-small uk-subnav uk-subnav-pill uk-flex-center" '; +} + +?> +
      uk-switcher="connect: #get-bible-tag-body; animation: uk-animation-scale-up;"> +
    • + +
    • +
    • + +
    • + params->get('set_custom_tag_tabs') == 1): ?> + loadTemplate('getbibletagcustomtabsmenu'); ?> + +
    diff --git a/site/views/tag/tmpl/default_getbibletagcustomtabs.php b/site/views/tag/tmpl/default_getbibletagcustomtabs.php new file mode 100644 index 0000000..85e9fd7 --- /dev/null +++ b/site/views/tag/tmpl/default_getbibletagcustomtabs.php @@ -0,0 +1,53 @@ + + @git Get Bible + @github Get Bible + @support Get Bible + @copyright Copyright (C) 2015. All Rights Reserved + @license GNU/GPL Version 2 or later - http://www.gnu.org/licenses/gpl-2.0.html + +/------------------------------------------------------------------------------------------------------*/ + +// No direct access to this file +defined('_JEXEC') or die('Restricted access'); +use VDM\Joomla\Utilities\ObjectHelper; + +$modules = $this->params->get('custom_tag_tabs'); +$tabs = []; +if (ObjectHelper::check($modules)) +{ + foreach ($modules as $module) + { + if (isset($module->position) && strlen($module->position) > 0) + { + if (($content = $this->getModules($module->position, $module->separator ?? '', $module->class ?? '')) !== false) + { + $tabs[$module->position] = $content; + } + else + { + $tabs[$module->position] = JLayoutHelper::render('modulepositionerror', ['position' => $module->position, 'page' => 'GetBible Tag']); + } + } + } +} + +$custom_tabs_card = ($this->params->get('show_custom_tabs_card') == 1) ? 'uk-card uk-card-' . $this->params->get('custom_tabs_card_style', 'default') . ' uk-card-body' : ''; + +?> + + +
  • +
    + +
    +
  • + + diff --git a/site/views/tag/tmpl/default_getbibletagcustomtabsmenu.php b/site/views/tag/tmpl/default_getbibletagcustomtabsmenu.php new file mode 100644 index 0000000..d7910ad --- /dev/null +++ b/site/views/tag/tmpl/default_getbibletagcustomtabsmenu.php @@ -0,0 +1,42 @@ + + @git Get Bible + @github Get Bible + @support Get Bible + @copyright Copyright (C) 2015. All Rights Reserved + @license GNU/GPL Version 2 or later - http://www.gnu.org/licenses/gpl-2.0.html + +/------------------------------------------------------------------------------------------------------*/ + +// No direct access to this file +defined('_JEXEC') or die('Restricted access'); +use VDM\Joomla\Utilities\ObjectHelper; + +$modules = $this->params->get('custom_tag_tabs'); +$menus = []; +if (ObjectHelper::check($modules)) +{ + foreach ($modules as $module) + { + if (isset($module->position) && strlen($module->position) > 0) + { + $menus[$module->position] = $this->escape($module->name); + } + } +} + +?> + + +
  • + +
  • + + diff --git a/site/views/tag/tmpl/default_getbibletagdebug.php b/site/views/tag/tmpl/default_getbibletagdebug.php new file mode 100644 index 0000000..6aa4a56 --- /dev/null +++ b/site/views/tag/tmpl/default_getbibletagdebug.php @@ -0,0 +1,34 @@ + + @git Get Bible + @github Get Bible + @support Get Bible + @copyright Copyright (C) 2015. All Rights Reserved + @license GNU/GPL Version 2 or later - http://www.gnu.org/licenses/gpl-2.0.html + +/------------------------------------------------------------------------------------------------------*/ + +// No direct access to this file +defined('_JEXEC') or die('Restricted access'); + +?> +
    +

    +

    +
      +
    • + +
      +
      +items); ?>
      +
      +
      +
    • +
    diff --git a/site/views/tag/tmpl/default_getbibletagfooter.php b/site/views/tag/tmpl/default_getbibletagfooter.php new file mode 100644 index 0000000..a851187 --- /dev/null +++ b/site/views/tag/tmpl/default_getbibletagfooter.php @@ -0,0 +1,25 @@ + + @git Get Bible + @github Get Bible + @support Get Bible + @copyright Copyright (C) 2015. All Rights Reserved + @license GNU/GPL Version 2 or later - http://www.gnu.org/licenses/gpl-2.0.html + +/------------------------------------------------------------------------------------------------------*/ + +// No direct access to this file +defined('_JEXEC') or die('Restricted access'); + +?> + $this->params->get('show_getbible_link'), + 'logo' => $this->params->get('show_getbible_logo') +]); ?> diff --git a/site/views/tag/tmpl/default_getbibletagparagraphs.php b/site/views/tag/tmpl/default_getbibletagparagraphs.php new file mode 100644 index 0000000..290c058 --- /dev/null +++ b/site/views/tag/tmpl/default_getbibletagparagraphs.php @@ -0,0 +1,31 @@ + + @git Get Bible + @github Get Bible + @support Get Bible + @copyright Copyright (C) 2015. All Rights Reserved + @license GNU/GPL Version 2 or later - http://www.gnu.org/licenses/gpl-2.0.html + +/------------------------------------------------------------------------------------------------------*/ + +// No direct access to this file +defined('_JEXEC') or die('Restricted access'); + +?> +
    + items as $paragraph): ?> +
    +
    +
    + +
    +books) && is_array($this->books) && count($this->books) > 1): ?> +
    + diff --git a/site/views/tag/tmpl/default_getbibletagparagraphssorter.php b/site/views/tag/tmpl/default_getbibletagparagraphssorter.php new file mode 100644 index 0000000..0435e14 --- /dev/null +++ b/site/views/tag/tmpl/default_getbibletagparagraphssorter.php @@ -0,0 +1,30 @@ + + @git Get Bible + @github Get Bible + @support Get Bible + @copyright Copyright (C) 2015. All Rights Reserved + @license GNU/GPL Version 2 or later - http://www.gnu.org/licenses/gpl-2.0.html + +/------------------------------------------------------------------------------------------------------*/ + +// No direct access to this file +defined('_JEXEC') or die('Restricted access'); + +?> +books) && is_array($this->books) && count($this->books) > 1): ?> +
    +
      +
    • + books as $key => $name): ?> +
    • + +
    + diff --git a/site/views/tag/tmpl/default_getbibletagtopmenu.php b/site/views/tag/tmpl/default_getbibletagtopmenu.php new file mode 100644 index 0000000..21c0423 --- /dev/null +++ b/site/views/tag/tmpl/default_getbibletagtopmenu.php @@ -0,0 +1,43 @@ + + @git Get Bible + @github Get Bible + @support Get Bible + @copyright Copyright (C) 2015. All Rights Reserved + @license GNU/GPL Version 2 or later - http://www.gnu.org/licenses/gpl-2.0.html + +/------------------------------------------------------------------------------------------------------*/ + +// No direct access to this file +defined('_JEXEC') or die('Restricted access'); + +$type = $this->params->get('top_menu_type'); + +if ($type == 2) +{ + $menu_type = 'class="uk-margin-small uk-flex-center" uk-tab '; +} +else +{ + $menu_type = 'class="el-nav uk-margin-small uk-subnav uk-subnav-pill uk-flex-center" '; +} + +?> +
      uk-switcher="connect: #get-bible-tag-body; animation: uk-animation-scale-up;"> +
    • + +
    • +
    • + +
    • + params->get('set_custom_tag_tabs') == 1): ?> + loadTemplate('getbibletagcustomtabsmenu'); ?> + +
    diff --git a/site/views/tag/tmpl/index.html b/site/views/tag/tmpl/index.html new file mode 100644 index 0000000..fa6d84e --- /dev/null +++ b/site/views/tag/tmpl/index.html @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/site/views/tag/view.html.php b/site/views/tag/view.html.php new file mode 100644 index 0000000..7e9de1e --- /dev/null +++ b/site/views/tag/view.html.php @@ -0,0 +1,338 @@ + + @git Get Bible + @github Get Bible + @support Get Bible + @copyright Copyright (C) 2015. All Rights Reserved + @license GNU/GPL Version 2 or later - http://www.gnu.org/licenses/gpl-2.0.html + +/------------------------------------------------------------------------------------------------------*/ + +// No direct access to this file +defined('_JEXEC') or die('Restricted access'); +jimport('joomla.application.module.helper'); + +use Joomla\CMS\MVC\View\HtmlView; +use VDM\Joomla\GetBible\Factory; + +/** + * Getbible Html View class for the Tag + */ +class GetbibleViewTag extends HtmlView +{ + // Overwriting JView display method + function display($tpl = null) + { + // get combined params of both component and menu + $this->app = JFactory::getApplication(); + $this->params = $this->app->getParams(); + $this->menu = $this->app->getMenu()->getActive(); + // get the user object + $this->user = JFactory::getUser(); + // Initialise variables. + $this->items = $this->get('Items'); + $this->translation = $this->get('Translation'); + $this->tags = $this->get('Tags'); + $this->linkertags = $this->get('LinkerTags'); + $this->tag = $this->get('Tag'); + $this->linkertagged = $this->get('LinkerTagged'); + // should we not have tags at this point we should not load the tag feature + if (empty($this->tags)) + { + $this->params->set('activate_tags', null); + } + else + { + $this->mergeTags(); + } + + // check if we have some tagged verses + if (!empty($this->items) || !empty($this->linkertagged)) + { + // set the linker + $this->linker = $this->getLinker(); + + // merge the system and linker + $this->mergeTaggedVerses(); + + // see if we have any tagged verses left + if (!empty($this->items)) + { + // sort the tagged verses in to paragraphs + $this->items = Factory::_('GetBible.Tagged.Paragraphs')->get($this->items, $this->translation->abbreviation ?? 'kjv'); + + // set sorting books option + $this->setBooks(); + } + } + + // Set the toolbar + $this->addToolBar(); + + // set the document + $this->_prepareDocument(); + + // Check for errors. + if (count($errors = $this->get('Errors'))) + { + throw new Exception(implode(PHP_EOL, $errors), 500); + } + + parent::display($tpl); + } + + /** + * Merge system and linker tags + * + * @return void + * @since 2.0.1 + */ + protected function mergeTags(): void + { + $mergeTags = []; + + // If $this->tags is an array and is not empty, add its elements to $mergeTags + if (is_array($this->tags) && $this->tags !== []) + { + foreach ($this->tags as $tag) + { + // set the tag url + $tag->url = JRoute::_('index.php?option=com_getbible&view=tag&Itemid=' . $this->params->get('app_menu', 0) . '&guid=' . $tag->guid . '&t=' . $this->translation->abbreviation); + // Use the 'verse' attribute as the key + $mergeTags[$tag->id] = $tag; + } + } + + // If $this->linkertags is an array and is not empty, add or replace its elements in $mergeTags + if (is_array($this->linkertags) && $this->linkertags !== []) + { + foreach ($this->linkertags as $tag) + { + if ($tag->published != 1) + { + // we remove the tag if not published + unset($mergeTags[$tag->id]); + continue; + } + // set the tag url + $tag->url = JRoute::_('index.php?option=com_getbible&view=tag&Itemid=' . $this->params->get('app_menu', 0) . '&guid=' . $tag->guid . '&t=' . $this->translation->abbreviation); + // If the verse already exists in $mergeTags, this will replace it + // If it doesn't exist, this will add it + $mergeTags[$tag->id] = $tag; + } + } + + // update the notes array if we have values + if ($mergeTags !== []) + { + // Reset the keys to be numeric and start from 0 + $this->tags = array_values($mergeTags); + } + } + + /** + * Merge system and linker tagged verses + * + * @return void + * @since 2.0.1 + */ + protected function mergeTaggedVerses(): void + { + $mergeTags = []; + + // If this->items is an array and is not empty, add its elements to $mergeTags + foreach ($this->items as $tag) + { + // we build the key + $key = $tag->book_nr . '-' . $tag->chapter . '-' . $tag->verse . '_' . $tag->tag; + // Use the 'verse' attribute as the key + $mergeTags[$key] = $tag; + } + + // If $this->linkertagged is an array and is not empty, add or replace its elements in $mergeTags + if (is_array($this->linkertagged) && $this->linkertagged !== []) + { + foreach ($this->linkertagged as $tag) + { + // we build the key + $key = $tag->book_nr . '-' . $tag->chapter . '-' . $tag->verse . '_' . $tag->tag; + if ($tag->published != 1) + { + // we remove the tag if not published + unset($mergeTags[$key]); + continue; + } + // If the verse already exists in $mergeTags, this will replace it + // If it doesn't exist, this will add it + $mergeTags[$key] = $tag; + } + } + + // update the notes array if we have values + if ($mergeTags !== []) + { + // Reset the keys to be numeric and start from 0 + $this->items = array_values($mergeTags); + } + } + + /** + * Set the books + * + * @return void + * @since 2.0.1 + */ + protected function setBooks(): void + { + $this->books = []; + if (!empty($this->items)) + { + foreach ($this->items as $item) + { + $this->books[$item['data_book']] = $item['book']; + } + } + } + + /** + * Get the Linker Details + * + * @return array The linker array. + * @since 2.0.1 + */ + protected function getLinker(): array + { + return ['guid' => Factory::_('GetBible.Linker')->active()]; + } + + /** + * Prepares the document + */ + protected function _prepareDocument() + { + + // Only load jQuery if needed. (default is true) + if ($this->params->get('add_jquery_framework', 1) == 1) + { + JHtml::_('jquery.framework'); + } + // Load the header checker class. + require_once( JPATH_COMPONENT_SITE.'/helpers/headercheck.php' ); + // Initialize the header checker. + $HeaderCheck = new getbibleHeaderCheck; + + // Load uikit options. + $uikit = $this->params->get('uikit_load'); + // Set script size. + $size = $this->params->get('uikit_min'); + // The uikit css. + if ((!$HeaderCheck->css_loaded('uikit.min') || $uikit == 1) && $uikit != 2 && $uikit != 3) + { + JHtml::_('stylesheet', 'media/com_getbible/uikit-v3/css/uikit'.$size.'.css', ['version' => 'auto']); + } + // The uikit js. + if ((!$HeaderCheck->js_loaded('uikit.min') || $uikit == 1) && $uikit != 2 && $uikit != 3) + { + JHtml::_('script', 'media/com_getbible/uikit-v3/js/uikit'.$size.'.js', ['version' => 'auto']); + JHtml::_('script', 'media/com_getbible/uikit-v3/js/uikit-icons'.$size.'.js', ['version' => 'auto']); + } + // add the document default css file + JHtml::_('stylesheet', 'components/com_getbible/assets/css/tag.css', ['version' => 'auto']); + } + + /** + * Setting the toolbar + */ + protected function addToolBar() + { + + // set help url for this view if found + $this->help_url = GetbibleHelper::getHelpUrl('tag'); + if (GetbibleHelper::checkString($this->help_url)) + { + JToolbarHelper::help('COM_GETBIBLE_HELP_MANAGER', false, $this->help_url); + } + // now initiate the toolbar + $this->toolbar = JToolbar::getInstance(); + } + + /** + * Get the modules published in a position + */ + public function getModules($position, $seperator = '', $class = '') + { + // set default + $found = false; + // check if we aleady have these modules loaded + if (isset($this->setModules[$position])) + { + $found = true; + } + else + { + // this is where you want to load your module position + $modules = JModuleHelper::getModules($position); + if (GetbibleHelper::checkArray($modules, true)) + { + // set the place holder + $this->setModules[$position] = array(); + foreach($modules as $module) + { + $this->setModules[$position][] = JModuleHelper::renderModule($module); + } + $found = true; + } + } + // check if modules were found + if ($found && isset($this->setModules[$position]) && GetbibleHelper::checkArray($this->setModules[$position])) + { + // set class + if (GetbibleHelper::checkString($class)) + { + $class = ' class="'.$class.'" '; + } + // set seperating return values + switch($seperator) + { + case 'none': + return implode('', $this->setModules[$position]); + break; + case 'div': + return ''.implode('
    ', $this->setModules[$position]).'
    '; + break; + case 'list': + return '
  • '.implode('
  • ', $this->setModules[$position]).'
  • '; + break; + case 'array': + case 'Array': + return $this->setModules[$position]; + break; + default: + return implode('
    ', $this->setModules[$position]); + break; + + } + } + return false; + } + + /** + * Escapes a value for output in a view script. + * + * @param mixed $var The output to escape. + * + * @return mixed The escaped value. + */ + public function escape($var, $sorten = false, $length = 40) + { + // use the helper htmlEscape method instead. + return GetbibleHelper::htmlEscape($var, $this->_charset, $sorten, $length); + } +} diff --git a/update_server.xml b/update_server.xml new file mode 100644 index 0000000..f7b2d69 --- /dev/null +++ b/update_server.xml @@ -0,0 +1,20 @@ + + + Get Bible + The Bible for Joomla + pkg_getbible + package + site + 2.0.1 + https://getbible.net + + https://git.vdm.dev/api/v1/repos/getBible/joomla-pkg/archive/v2.0.1.zip + + + stable + + Llewellyn van der Merwe + https://getbible.net + + + \ No newline at end of file