From 415b8a2e469a0fb7edc6140b61a62e32163b4d3f Mon Sep 17 00:00:00 2001 From: aB0t Date: Tue, 23 Jan 2024 19:16:25 +0200 Subject: [PATCH] Stable release of v5.0.0 Moved to Joomla 4 and 5. --- CHANGELOG.md | 173 +- GetbibleInstallerScript.php | 1820 ++++++++++++++ README.md | 30 +- admin/README.txt | 30 +- admin/assets/css/dashboard.css | 202 +- admin/assets/images/import.gif | Bin 65516 -> 66680 bytes admin/config.xml | 57 +- admin/controller.php | 134 -- admin/{models => }/forms/book.xml | 9 +- admin/{models => }/forms/chapter.xml | 9 +- admin/{models => }/forms/filter_books.xml | 35 +- admin/{models => }/forms/filter_chapters.xml | 37 +- admin/{models => }/forms/filter_linkers.xml | 31 +- admin/{models => }/forms/filter_notes.xml | 27 +- .../forms/filter_open_ai_messages.xml | 33 +- .../forms/filter_open_ai_responses.xml | 31 +- admin/{models => }/forms/filter_passwords.xml | 29 +- admin/{models => }/forms/filter_prompts.xml | 33 +- .../forms/filter_tagged_verses.xml | 43 +- admin/{models => }/forms/filter_tags.xml | 21 +- .../forms/filter_translations.xml | 27 +- admin/{models => }/forms/filter_verses.xml | 33 +- admin/{controllers => forms}/index.html | 0 admin/{models => }/forms/linker.xml | 9 +- admin/{models => }/forms/note.xml | 9 +- admin/{models => }/forms/open_ai_message.xml | 9 +- admin/{models => }/forms/open_ai_response.xml | 9 +- admin/{models => }/forms/password.xml | 9 +- admin/{models => }/forms/prompt.xml | 9 +- admin/{models => }/forms/tag.xml | 9 +- admin/{models => }/forms/tagged_verse.xml | 9 +- admin/{models => }/forms/translation.xml | 9 +- admin/{models => }/forms/verse.xml | 9 +- admin/getbible.php | 94 - admin/helpers/headercheck.php | 95 - admin/helpers/html/batch_.php | 84 - admin/language/en-GB/en-GB.com_getbible.ini | 72 +- .../language/en-GB/en-GB.com_getbible.sys.ini | 1 + admin/layouts/batchselection.php | 55 - admin/layouts/book/details_above.php | 18 +- admin/layouts/book/details_left.php | 2 +- admin/layouts/book/details_right.php | 2 +- admin/layouts/book/publishing.php | 2 +- admin/layouts/book/publlshing.php | 2 +- admin/layouts/chapter/details_above.php | 18 +- admin/layouts/chapter/details_left.php | 2 +- admin/layouts/chapter/details_right.php | 2 +- admin/layouts/chapter/publishing.php | 2 +- admin/layouts/chapter/publlshing.php | 2 +- admin/layouts/linker/details_above.php | 18 +- admin/layouts/linker/details_left.php | 2 +- admin/layouts/linker/details_right.php | 2 +- admin/layouts/linker/notes_fullwidth.php | 12 +- admin/layouts/linker/passwords_fullwidth.php | 12 +- admin/layouts/linker/publishing.php | 2 +- admin/layouts/linker/publlshing.php | 2 +- admin/layouts/linker/tags_fullwidth.php | 12 +- admin/layouts/note/details_above.php | 18 +- admin/layouts/note/details_left.php | 2 +- admin/layouts/note/details_right.php | 2 +- admin/layouts/note/publishing.php | 2 +- admin/layouts/note/publlshing.php | 2 +- .../layouts/open_ai_message/message_above.php | 18 +- .../open_ai_message/message_fullwidth.php | 2 +- .../layouts/open_ai_message/message_left.php | 2 +- .../layouts/open_ai_message/message_right.php | 2 +- admin/layouts/open_ai_message/publishing.php | 2 +- admin/layouts/open_ai_message/publlshing.php | 2 +- admin/layouts/open_ai_response/bible_left.php | 2 +- .../layouts/open_ai_response/bible_right.php | 2 +- .../open_ai_response/details_above.php | 18 +- .../layouts/open_ai_response/details_left.php | 2 +- .../open_ai_response/details_right.php | 2 +- .../open_ai_response/message_fullwidth.php | 12 +- .../layouts/open_ai_response/prompt_left.php | 2 +- .../layouts/open_ai_response/prompt_right.php | 2 +- admin/layouts/open_ai_response/publishing.php | 2 +- admin/layouts/open_ai_response/publlshing.php | 2 +- admin/layouts/password/details_above.php | 18 +- admin/layouts/password/details_left.php | 2 +- admin/layouts/password/details_right.php | 2 +- admin/layouts/password/publishing.php | 2 +- admin/layouts/password/publlshing.php | 2 +- admin/layouts/prompt/open_ai_left.php | 3 +- admin/layouts/prompt/open_ai_right.php | 3 +- admin/layouts/prompt/prompt_above.php | 18 +- admin/layouts/prompt/prompt_fullwidth.php | 2 +- admin/layouts/prompt/prompt_left.php | 2 +- admin/layouts/prompt/prompt_right.php | 2 +- admin/layouts/prompt/publishing.php | 2 +- admin/layouts/prompt/publlshing.php | 2 +- admin/layouts/tag/details_above.php | 18 +- admin/layouts/tag/details_fullwidth.php | 2 +- admin/layouts/tag/details_left.php | 2 +- admin/layouts/tag/publishing.php | 2 +- admin/layouts/tag/publlshing.php | 2 +- admin/layouts/tagged_verse/details_above.php | 18 +- admin/layouts/tagged_verse/details_left.php | 2 +- admin/layouts/tagged_verse/details_right.php | 2 +- admin/layouts/tagged_verse/publishing.php | 2 +- admin/layouts/tagged_verse/publlshing.php | 2 +- admin/layouts/translation/details_above.php | 18 +- .../layouts/translation/details_fullwidth.php | 2 +- admin/layouts/translation/details_left.php | 2 +- admin/layouts/translation/details_right.php | 2 +- admin/layouts/translation/publishing.php | 2 +- admin/layouts/translation/publlshing.php | 2 +- admin/layouts/trashhelper.php | 3 +- admin/layouts/verse/details_above.php | 18 +- admin/layouts/verse/details_fullwidth.php | 2 +- admin/layouts/verse/details_left.php | 2 +- admin/layouts/verse/details_right.php | 2 +- admin/layouts/verse/publishing.php | 2 +- admin/layouts/verse/publlshing.php | 2 +- admin/{helpers/html => presets}/index.html | 0 admin/{helpers => services}/index.html | 0 admin/services/provider.php | 123 + admin/sql/install.mysql.utf8.sql | 4 +- admin/sql/updates/mysql/2.0.1.sql | 1 - admin/sql/updates/mysql/2.0.11.sql | 1 - admin/sql/updates/mysql/2.0.12.sql | 1 - admin/sql/updates/mysql/2.0.13.sql | 1 - admin/sql/updates/mysql/2.0.14.sql | 3 - admin/sql/updates/mysql/2.0.15.sql | 1 - admin/sql/updates/mysql/2.0.16.sql | 1 - admin/sql/updates/mysql/2.0.17.sql | 1 - admin/sql/updates/mysql/2.0.18.sql | 1 - admin/sql/updates/mysql/2.0.19.sql | 1 - admin/sql/updates/mysql/2.0.2.sql | 1 - admin/sql/updates/mysql/2.0.20.sql | 1 - admin/sql/updates/mysql/2.0.21.sql | 1 - admin/sql/updates/mysql/2.0.22.sql | 1 - admin/sql/updates/mysql/2.0.23.sql | 1 - admin/sql/updates/mysql/2.0.25.sql | 1 - admin/sql/updates/mysql/2.0.26.sql | 1 - admin/sql/updates/mysql/2.0.27.sql | 1 - admin/sql/updates/mysql/2.0.28.sql | 1 - admin/sql/updates/mysql/2.0.29.sql | 1 - admin/sql/updates/mysql/2.0.3.sql | 1 - admin/sql/updates/mysql/2.0.30.sql | 1 - admin/sql/updates/mysql/2.0.31.sql | 1 - admin/sql/updates/mysql/2.0.32.sql | 1 - admin/sql/updates/mysql/2.0.4.sql | 1 - admin/sql/updates/mysql/2.0.5.sql | 1 - admin/sql/updates/mysql/2.0.6.sql | 1 - admin/sql/updates/mysql/2.0.7.sql | 1 - admin/sql/updates/mysql/2.0.8.sql | 1 - admin/sql/updates/mysql/2.0.9.sql | 1 - admin/{layouts => sql/xml}/index.html | 0 .../Controller/AjaxController.php} | 85 +- .../Controller/BookController.php} | 50 +- .../Controller/BooksController.php} | 12 +- .../Controller/ChapterController.php} | 50 +- .../Controller/ChaptersController.php} | 12 +- admin/src/Controller/DisplayController.php | 51 + .../Controller/GetbibleController.php} | 6 +- .../Controller/LinkerController.php} | 50 +- .../Controller/LinkersController.php} | 12 +- .../Controller/NoteController.php} | 50 +- .../Controller/NotesController.php} | 12 +- .../Controller/Open_ai_messageController.php} | 50 +- .../Open_ai_messagesController.php} | 12 +- .../Open_ai_responseController.php} | 50 +- .../Open_ai_responsesController.php} | 12 +- .../Controller/PasswordController.php} | 50 +- .../Controller/PasswordsController.php} | 12 +- .../Controller/PromptController.php} | 50 +- .../Controller/PromptsController.php} | 12 +- .../Controller/TagController.php} | 50 +- .../Controller/Tagged_verseController.php} | 50 +- .../Controller/Tagged_versesController.php} | 12 +- .../Controller/TagsController.php} | 12 +- .../Controller/TranslationController.php} | 50 +- .../Controller/TranslationsController.php} | 12 +- .../Controller/VerseController.php} | 50 +- .../Controller/VersesController.php} | 12 +- .../fields => src/Controller}/index.html | 0 admin/src/Extension/GetbibleComponent.php | 81 + .../forms => src/Extension}/index.html | 0 .../Field/BooksfilternameField.php} | 23 +- .../Field/BooksfilternrField.php} | 23 +- .../Field/ChaptersfilterbooknrField.php} | 23 +- .../Field/ChaptersfilterchapterField.php} | 23 +- .../Field/LinkersField.php} | 65 +- .../Field/LinkersfilternameField.php} | 23 +- .../Field/LinkersfilterpublicnotesField.php} | 23 +- .../LinkersfilterpublictaggedversesField.php} | 23 +- .../Field/NotesfilteraccessField.php} | 23 +- .../Field/NotesfilterbooknrField.php} | 23 +- .../Field/NotesfilterchapterField.php} | 23 +- .../Field/NotesfilterverseField.php} | 23 +- .../Field/OpenaimessagesfilterroleField.php} | 23 +- .../OpenaimessagesfiltersourceField.php} | 23 +- .../Field/OpenairesponsesField.php} | 27 +- .../OpenairesponsesfilterresponseidField.php} | 23 +- ...enairesponsesfilterresponsemodelField.php} | 23 +- .../Field/PasswordsfilternameField.php} | 23 +- .../Field/PromptsField.php} | 27 +- .../PromptsfiltercachebehaviourField.php} | 23 +- .../Field/PromptsfiltermodelField.php} | 23 +- .../Field/PromptsfilternameField.php} | 23 +- .../tagers.php => src/Field/TagersField.php} | 65 +- .../Field/TaggedversesfilteraccessField.php} | 23 +- .../Field/TaggedversesfilterbooknrField.php} | 23 +- .../Field/TaggedversesfilterchapterField.php} | 23 +- .../Field/TaggedversesfilterverseField.php} | 23 +- .../Field/TagsfilteraccessField.php} | 23 +- .../Field/TargettranslationsField.php} | 29 +- .../Field/TranslationsField.php} | 31 +- .../TranslationsfilterdirectionField.php} | 23 +- .../Field/VersesfilterbooknrField.php} | 23 +- .../Field/VersesfilterchapterField.php} | 23 +- .../Field/VersesfilterverseField.php} | 23 +- admin/{models => src/Field}/index.html | 0 .../Helper/GetbibleHelper.php} | 141 +- admin/src/Helper/HeaderCheck.php | 136 ++ admin/{models/rules => src/Helper}/index.html | 0 .../ajax.php => src/Model/AjaxModel.php} | 108 +- .../book.php => src/Model/BookModel.php} | 101 +- .../books.php => src/Model/BooksModel.php} | 78 +- .../Model/ChapterModel.php} | 101 +- .../Model/ChaptersModel.php} | 50 +- .../Model/GetbibleModel.php} | 252 +- .../linker.php => src/Model/LinkerModel.php} | 124 +- .../Model/LinkersModel.php} | 44 +- .../note.php => src/Model/NoteModel.php} | 98 +- .../notes.php => src/Model/NotesModel.php} | 46 +- .../Model/Open_ai_messageModel.php} | 101 +- .../Model/Open_ai_messagesModel.php} | 46 +- .../Model/Open_ai_responseModel.php} | 110 +- .../Model/Open_ai_responsesModel.php} | 42 +- .../Model/PasswordModel.php} | 101 +- .../Model/PasswordsModel.php} | 40 +- .../prompt.php => src/Model/PromptModel.php} | 105 +- .../Model/PromptsModel.php} | 46 +- .../tag.php => src/Model/TagModel.php} | 103 +- .../Model/Tagged_verseModel.php} | 98 +- .../Model/Tagged_versesModel.php} | 66 +- .../tags.php => src/Model/TagsModel.php} | 40 +- .../Model/TranslationModel.php} | 103 +- .../Model/TranslationsModel.php} | 40 +- .../verse.php => src/Model/VerseModel.php} | 101 +- .../verses.php => src/Model/VersesModel.php} | 44 +- admin/{tables => src/Model}/index.html | 0 .../rules/guid.php => src/Rule/GuidRule.php} | 7 +- .../rules/int.php => src/Rule/IntRule.php} | 7 +- .../Rule/NumbershyphensRule.php} | 7 +- .../{views/book/tmpl => src/Rule}/index.html | 0 admin/{views/books => src/Service}/index.html | 0 .../book.php => src/Table/BookTable.php} | 215 +- .../Table/ChapterTable.php} | 215 +- .../linker.php => src/Table/LinkerTable.php} | 215 +- .../note.php => src/Table/NoteTable.php} | 216 +- .../Table/Open_ai_messageTable.php} | 216 +- .../Table/Open_ai_responseTable.php} | 216 +- .../Table/PasswordTable.php} | 215 +- .../prompt.php => src/Table/PromptTable.php} | 216 +- .../tag.php => src/Table/TagTable.php} | 216 +- .../Table/Tagged_verseTable.php} | 216 +- .../Table/TranslationTable.php} | 215 +- .../verse.php => src/Table/VerseTable.php} | 215 +- .../books/tmpl => src/Table}/index.html | 0 .../View/Book/HtmlView.php} | 38 +- .../chapter/tmpl => src/View/Book}/index.html | 0 .../View/Books/HtmlView.php} | 152 +- .../chapters => src/View/Books}/index.html | 0 .../View/Chapter/HtmlView.php} | 38 +- .../tmpl => src/View/Chapter}/index.html | 0 .../View/Chapters/HtmlView.php} | 152 +- .../getbible => src/View/Chapters}/index.html | 0 .../View/Getbible/HtmlView.php} | 42 +- .../tmpl => src/View/Getbible}/index.html | 0 .../View/Linker/HtmlView.php} | 41 +- admin/{views => src/View/Linker}/index.html | 0 .../View/Linkers/HtmlView.php} | 152 +- .../tmpl => src/View/Linkers}/index.html | 0 .../View/Note/HtmlView.php} | 41 +- .../linkers => src/View/Note}/index.html | 0 admin/src/View/Notes/HtmlView.php | 204 ++ .../tmpl => src/View/Notes}/index.html | 0 .../View/Open_ai_message/HtmlView.php} | 41 +- .../View/Open_ai_message}/index.html | 0 .../View/Open_ai_messages/HtmlView.php} | 172 +- .../View/Open_ai_messages}/index.html | 0 .../View/Open_ai_response/HtmlView.php} | 41 +- .../View/Open_ai_response}/index.html | 0 .../View/Open_ai_responses/HtmlView.php} | 152 +- .../View/Open_ai_responses}/index.html | 0 .../View/Password/HtmlView.php} | 41 +- .../View/Password}/index.html | 0 .../View/Passwords/HtmlView.php} | 132 +- .../tmpl => src/View/Passwords}/index.html | 0 .../View/Prompt/HtmlView.php} | 41 +- .../tmpl => src/View/Prompt}/index.html | 0 .../View/Prompts/HtmlView.php} | 172 +- .../View/Prompts}/index.html | 0 .../View/Tag/HtmlView.php} | 41 +- .../tmpl => src/View/Tag}/index.html | 0 .../View/Tagged_verse/HtmlView.php} | 41 +- .../tmpl => src/View/Tagged_verse}/index.html | 0 admin/src/View/Tagged_verses/HtmlView.php | 206 ++ .../View/Tagged_verses}/index.html | 0 .../View/Tags/HtmlView.php} | 122 +- .../tmpl => src/View/Tags}/index.html | 0 .../View/Translation/HtmlView.php} | 38 +- .../tmpl => src/View/Translation}/index.html | 0 .../View/Translations/HtmlView.php} | 112 +- .../View/Translations}/index.html | 0 .../View/Verse/HtmlView.php} | 38 +- .../tmpl => src/View/Verse}/index.html | 0 .../View/Verses/HtmlView.php} | 172 +- .../tag/tmpl => src/View/Verses}/index.html | 0 .../tagged_verse/tmpl => src/View}/index.html | 0 admin/{views/tagged_verses => src}/index.html | 0 .../tmpl/edit.php => tmpl/book/default.php} | 74 +- .../tmpl => tmpl/book}/index.html | 0 .../books/tmpl => tmpl/books}/default.php | 26 +- .../books}/default_batch_body.php | 2 +- .../books}/default_batch_footer.php | 2 +- .../tmpl => tmpl/books}/default_body.php | 7 +- .../tmpl => tmpl/books}/default_foot.php | 2 +- .../tmpl => tmpl/books}/default_head.php | 2 +- admin/tmpl/books/default_toolbar.php | 54 + admin/tmpl/books/emptystate.php | 34 + admin/{views/tags => tmpl/books}/index.html | 0 .../edit.php => tmpl/chapter/default.php} | 74 +- .../tags/tmpl => tmpl/chapter}/index.html | 0 .../tmpl => tmpl/chapters}/default.php | 29 +- .../chapters}/default_batch_body.php | 2 +- .../chapters}/default_batch_footer.php | 2 +- .../tmpl => tmpl/chapters}/default_body.php | 7 +- .../tmpl => tmpl/chapters}/default_foot.php | 2 +- .../tmpl => tmpl/chapters}/default_head.php | 2 +- admin/tmpl/chapters/default_toolbar.php | 54 + admin/tmpl/chapters/emptystate.php | 34 + .../tmpl => tmpl/chapters}/index.html | 0 .../tmpl => tmpl/getbible}/default.php | 43 +- .../tmpl => tmpl/getbible}/default_main.php | 4 +- ...t_notice_board_vast_development_method.php | 2 +- .../getbible}/default_readme_information.php | 2 +- .../tmpl => tmpl/getbible}/default_vdm.php | 4 +- .../getbible}/default_wiki_tutorials.php | 2 +- .../translations => tmpl/getbible}/index.html | 0 .../{views/translations => }/tmpl/index.html | 0 .../tmpl/edit.php => tmpl/linker/default.php} | 104 +- .../verse/tmpl => tmpl/linker}/index.html | 0 .../linkers/tmpl => tmpl/linkers}/default.php | 25 +- .../linkers}/default_batch_body.php | 2 +- .../linkers}/default_batch_footer.php | 2 +- .../tmpl => tmpl/linkers}/default_body.php | 7 +- .../tmpl => tmpl/linkers}/default_foot.php | 2 +- .../tmpl => tmpl/linkers}/default_head.php | 2 +- admin/tmpl/linkers/default_toolbar.php | 54 + admin/tmpl/linkers/emptystate.php | 34 + .../{views/verses => tmpl/linkers}/index.html | 0 .../tmpl/edit.php => tmpl/note/default.php} | 74 +- .../verses/tmpl => tmpl/note}/index.html | 0 .../notes/tmpl => tmpl/notes}/default.php | 25 +- .../notes}/default_batch_body.php | 2 +- .../notes}/default_batch_footer.php | 2 +- .../tmpl => tmpl/notes}/default_body.php | 7 +- .../tags/tmpl => tmpl/notes}/default_foot.php | 2 +- .../tmpl => tmpl/notes}/default_head.php | 2 +- admin/tmpl/notes/default_toolbar.php | 54 + admin/tmpl/notes/emptystate.php | 34 + .../tmpl/notes}/index.html | 0 .../open_ai_message/default.php} | 78 +- .../tmpl/open_ai_message}/index.html | 0 .../open_ai_messages}/default.php | 25 +- .../open_ai_messages}/default_batch_body.php | 2 +- .../default_batch_footer.php | 2 +- .../open_ai_messages}/default_body.php | 7 +- .../open_ai_messages}/default_foot.php | 2 +- .../open_ai_messages}/default_head.php | 2 +- .../tmpl/open_ai_messages/default_toolbar.php | 54 + admin/tmpl/open_ai_messages/emptystate.php | 34 + .../tmpl/open_ai_messages}/index.html | 0 .../open_ai_response/default.php} | 104 +- .../tmpl/open_ai_response}/index.html | 0 .../open_ai_responses}/default.php | 25 +- .../open_ai_responses}/default_batch_body.php | 2 +- .../default_batch_footer.php | 2 +- .../open_ai_responses}/default_body.php | 7 +- .../open_ai_responses}/default_foot.php | 2 +- .../open_ai_responses}/default_head.php | 2 +- .../open_ai_responses/default_toolbar.php | 54 + admin/tmpl/open_ai_responses/emptystate.php | 34 + .../tmpl/open_ai_responses}/index.html | 0 .../edit.php => tmpl/password/default.php} | 74 +- .../app => admin/tmpl/password}/index.html | 0 .../tmpl => tmpl/passwords}/default.php | 25 +- .../passwords}/default_batch_body.php | 2 +- .../passwords}/default_batch_footer.php | 2 +- .../tmpl => tmpl/passwords}/default_body.php | 7 +- .../tmpl => tmpl/passwords}/default_foot.php | 2 +- .../tmpl => tmpl/passwords}/default_head.php | 2 +- admin/tmpl/passwords/default_toolbar.php | 54 + admin/tmpl/passwords/emptystate.php | 34 + .../tmpl => admin/tmpl/passwords}/index.html | 0 .../tmpl/edit.php => tmpl/prompt/default.php} | 88 +- {site/views => admin/tmpl/prompt}/index.html | 0 .../prompts/tmpl => tmpl/prompts}/default.php | 25 +- .../prompts}/default_batch_body.php | 2 +- .../prompts}/default_batch_footer.php | 2 +- .../tmpl => tmpl/prompts}/default_body.php | 7 +- .../tmpl => tmpl/prompts}/default_foot.php | 2 +- .../tmpl => tmpl/prompts}/default_head.php | 2 +- admin/tmpl/prompts/default_toolbar.php | 54 + admin/tmpl/prompts/emptystate.php | 34 + .../openai => admin/tmpl/prompts}/index.html | 0 .../tmpl/edit.php => tmpl/tag/default.php} | 76 +- .../openai/tmpl => admin/tmpl/tag}/index.html | 0 .../tagged_verse/default.php} | 74 +- .../tmpl/tagged_verse}/index.html | 0 admin/tmpl/tagged_verses/default.php | 62 + .../tagged_verses}/default_batch_body.php | 2 +- .../tagged_verses}/default_batch_footer.php | 2 +- .../tagged_verses}/default_body.php | 7 +- .../tagged_verses}/default_foot.php | 2 +- .../tagged_verses}/default_head.php | 2 +- admin/tmpl/tagged_verses/default_toolbar.php | 54 + admin/tmpl/tagged_verses/emptystate.php | 34 + .../tmpl/tagged_verses}/index.html | 0 .../tags/tmpl => tmpl/tags}/default.php | 25 +- .../tmpl => tmpl/tags}/default_batch_body.php | 2 +- .../tags}/default_batch_footer.php | 2 +- .../tags/tmpl => tmpl/tags}/default_body.php | 7 +- .../notes/tmpl => tmpl/tags}/default_foot.php | 2 +- .../tags/tmpl => tmpl/tags}/default_head.php | 2 +- admin/tmpl/tags/default_toolbar.php | 54 + admin/tmpl/tags/emptystate.php | 34 + .../views/tag => admin/tmpl/tags}/index.html | 0 .../edit.php => tmpl/translation/default.php} | 78 +- .../tmpl/translation}/index.html | 0 .../tmpl => tmpl/translations}/default.php | 25 +- .../translations}/default_batch_body.php | 2 +- .../translations}/default_batch_footer.php | 2 +- .../translations}/default_body.php | 7 +- .../translations}/default_foot.php | 2 +- .../translations}/default_head.php | 2 +- admin/tmpl/translations/default_toolbar.php | 54 + admin/tmpl/translations/emptystate.php | 34 + admin/tmpl/translations/index.html | 1 + .../tmpl/edit.php => tmpl/verse/default.php} | 78 +- admin/tmpl/verse/index.html | 1 + .../verses/tmpl => tmpl/verses}/default.php | 25 +- .../verses}/default_batch_body.php | 2 +- .../verses}/default_batch_footer.php | 2 +- .../tmpl => tmpl/verses}/default_body.php | 7 +- admin/tmpl/verses/default_foot.php | 24 + .../tmpl => tmpl/verses}/default_head.php | 2 +- admin/tmpl/verses/default_toolbar.php | 54 + admin/tmpl/verses/emptystate.php | 34 + admin/tmpl/verses/index.html | 1 + admin/views/book/submitbutton.js | 31 - admin/views/books/tmpl/default_toolbar.php | 54 - admin/views/chapter/submitbutton.js | 31 - admin/views/chapters/tmpl/default_toolbar.php | 54 - admin/views/linker/submitbutton.js | 31 - admin/views/linkers/tmpl/default_toolbar.php | 54 - admin/views/note/submitbutton.js | 31 - admin/views/notes/tmpl/default_toolbar.php | 54 - admin/views/notes/view.html.php | 332 --- admin/views/open_ai_message/submitbutton.js | 31 - .../open_ai_messages/tmpl/default_toolbar.php | 54 - admin/views/open_ai_response/submitbutton.js | 31 - .../tmpl/default_toolbar.php | 54 - admin/views/password/submitbutton.js | 31 - .../views/passwords/tmpl/default_toolbar.php | 54 - admin/views/prompt/submitbutton.js | 31 - admin/views/prompts/tmpl/default_toolbar.php | 54 - admin/views/tag/submitbutton.js | 31 - admin/views/tagged_verse/submitbutton.js | 31 - admin/views/tagged_verses/tmpl/default.php | 83 - .../tagged_verses/tmpl/default_toolbar.php | 54 - admin/views/tagged_verses/view.html.php | 374 --- admin/views/tags/tmpl/default_toolbar.php | 54 - admin/views/translation/submitbutton.js | 31 - .../translations/tmpl/default_toolbar.php | 54 - admin/views/verse/submitbutton.js | 31 - admin/views/verses/tmpl/default_foot.php | 24 - admin/views/verses/tmpl/default_toolbar.php | 54 - getbible.xml | 47 +- .../src/Utilities/Response.php | 18 +- .../VDM.Joomla.Gitea/src/Utilities/Http.php | 4 +- .../src/Utilities/Response.php | 15 +- .../src/Utilities/Response.php | 13 +- .../VDM.Joomla/src/Abstraction/BaseConfig.php | 6 +- .../VDM.Joomla/src/Abstraction/Database.php | 9 +- .../src/Utilities/Component/Helper.php | 89 +- .../src/Utilities/String/NamespaceHelper.php | 78 + .../VDM.Joomla/src/Utilities/StringHelper.php | 6 +- media/js/book.js | 2 +- media/js/chapter.js | 2 +- media/js/linker.js | 2 +- media/js/note.js | 2 +- media/js/open_ai_message.js | 2 +- media/js/open_ai_response.js | 2 +- media/js/password.js | 2 +- media/js/prompt.js | 2 +- media/js/tag.js | 2 +- media/js/tagged_verse.js | 2 +- media/js/translation.js | 2 +- media/js/verse.js | 2 +- script.php | 2117 ----------------- site/controller.php | 98 - site/forms/index.html | 1 + site/getbible.php | 87 - site/helpers/category.php | 24 - site/helpers/headercheck.php | 95 - site/layouts/aidetails.php | 3 +- site/layouts/airesponsemessage.php | 3 +- site/layouts/getbibleappnote.php | 3 +- site/layouts/getbibleappnotelink.php | 3 +- site/layouts/getbiblefavouriteverse.php | 3 +- site/layouts/getbiblefooter.php | 3 +- site/layouts/getbiblehashdetails.php | 3 +- site/layouts/getbiblelinkers.php | 3 +- site/layouts/getbibleparagraph.php | 3 +- site/layouts/getbibleverse.php | 3 +- site/layouts/getbibleverses.php | 3 +- site/layouts/getbibleversetag.php | 3 +- site/layouts/input.php | 3 +- site/layouts/inputbox.php | 3 +- site/layouts/modal.php | 3 +- site/layouts/modulepositionerror.php | 3 +- site/layouts/nextchapter.php | 3 +- site/layouts/previouschapter.php | 3 +- site/layouts/promptmessage.php | 3 +- site/layouts/promptsettings.php | 3 +- site/layouts/rows.php | 3 +- site/layouts/select.php | 3 +- site/layouts/selectbox.php | 3 +- site/layouts/table.php | 3 +- site/layouts/textarea.php | 3 +- site/layouts/textareabox.php | 3 +- site/router.php | 826 ------- .../Controller/AjaxController.php} | 237 +- site/src/Controller/DisplayController.php | 137 ++ site/src/Controller/index.html | 1 + site/src/Dispatcher/index.html | 1 + site/src/Field/index.html | 1 + .../Helper/GetbibleHelper.php} | 143 +- site/src/Helper/HeaderCheck.php | 136 ++ .../route.php => src/Helper/RouteHelper.php} | 98 +- site/src/Helper/index.html | 1 + .../ajax.php => src/Model/AjaxModel.php} | 6 +- .../api.php => src/Model/ApiModel.php} | 13 +- .../app.php => src/Model/AppModel.php} | 89 +- .../openai.php => src/Model/OpenaiModel.php} | 15 +- .../search.php => src/Model/SearchModel.php} | 48 +- .../tag.php => src/Model/TagModel.php} | 39 +- site/src/Model/index.html | 1 + site/src/Rule/index.html | 1 + site/src/Service/Router.php | 100 + site/src/Service/index.html | 1 + .../View/Api/HtmlView.php} | 21 +- site/src/View/Api/index.html | 1 + .../View/App/HtmlView.php} | 23 +- site/src/View/App/index.html | 1 + .../View/Openai/HtmlView.php} | 23 +- site/src/View/Openai/index.html | 1 + .../View/Search/HtmlView.php} | 23 +- site/src/View/Search/index.html | 1 + .../View/Tag/HtmlView.php} | 23 +- site/src/View/Tag/index.html | 1 + site/src/View/index.html | 1 + site/src/index.html | 1 + site/{views/api/tmpl => tmpl/api}/default.php | 3 +- site/{views/api/tmpl => tmpl/api}/default.xml | 0 site/tmpl/api/index.html | 1 + site/{views/app/tmpl => tmpl/app}/default.php | 3 +- site/{views/app/tmpl => tmpl/app}/default.xml | 4 +- .../tmpl => tmpl/app}/default_getbibleapp.php | 2 +- .../app}/default_getbibleappactivesession.php | 2 +- .../app}/default_getbibleappbody.php | 2 +- .../app}/default_getbibleappbottommenu.php | 2 +- .../app}/default_getbibleappcustomtabs.php | 2 +- .../default_getbibleappcustomtabsmenu.php | 2 +- .../app}/default_getbibleappdebug.php | 2 +- .../app}/default_getbibleappdetails.php | 2 +- .../app}/default_getbibleappfooter.php | 2 +- .../app}/default_getbibleappmodalbottom.php | 2 +- .../app}/default_getbibleappnotes.php | 2 +- .../app}/default_getbibleappsettings.php | 2 +- .../app}/default_getbibleappshare.php | 2 +- .../app}/default_getbibleapptags.php | 2 +- .../app}/default_getbibleapptopmenu.php | 2 +- .../app}/default_getbibleappword.php | 2 +- .../app}/default_getbiblebooks.php | 2 +- .../app}/default_getbiblechapters.php | 2 +- ...default_getbiblefavouriteverseselector.php | 2 +- .../app}/default_getbibleinstallbutton.php | 2 +- .../app}/default_getbiblelinkermanager.php | 2 +- .../app}/default_getbiblemodules.php | 2 +- .../app}/default_getbibletext.php | 2 +- .../app}/default_getbibletranslations.php | 2 +- .../app}/default_versesparagraph.php | 2 +- .../app}/default_versesunorderedlist.php | 2 +- site/tmpl/app/index.html | 1 + site/tmpl/index.html | 1 + .../openai/tmpl => tmpl/openai}/default.php | 3 +- .../openai}/default_getbibleai.php | 2 +- .../openai}/default_getbibleaibody.php | 2 +- .../openai}/default_getbibleaibottommenu.php | 2 +- .../openai}/default_getbibleaicustomtabs.php | 2 +- .../default_getbibleaicustomtabsmenu.php | 2 +- .../openai}/default_getbibleaidebug.php | 2 +- .../openai}/default_getbibleaidetails.php | 2 +- .../openai}/default_getbibleaifilter.php | 2 +- .../openai}/default_getbibleaifooter.php | 2 +- .../openai}/default_getbibleaimessages.php | 2 +- .../default_getbibleaipromptmessages.php | 2 +- .../openai}/default_getbibleaitopmenu.php | 2 +- .../openai}/default_getbiblemodules.php | 2 +- .../default_getbiblepromptsettings.php | 2 +- site/tmpl/openai/index.html | 1 + .../search/tmpl => tmpl/search}/default.php | 3 +- .../search}/default_getbiblemodules.php | 2 +- .../search}/default_getbiblesearch.php | 2 +- .../search}/default_getbiblesearchbox.php | 2 +- .../search}/default_getbiblesearchinput.php | 2 +- .../default_getbiblesearchnotenoughverses.php | 2 +- .../search}/default_getbiblesearchoptions.php | 2 +- .../search}/default_getbiblesearchtable.php | 2 +- site/tmpl/search/index.html | 1 + site/{views/tag/tmpl => tmpl/tag}/default.php | 3 +- .../tag}/default_getbiblemodules.php | 2 +- .../tag}/default_getbiblenotag.php | 2 +- .../tag}/default_getbibleselecttags.php | 2 +- .../tmpl => tmpl/tag}/default_getbibletag.php | 2 +- .../tag}/default_getbibletagbody.php | 2 +- .../tag}/default_getbibletagbottommenu.php | 2 +- .../tag}/default_getbibletagcustomtabs.php | 2 +- .../default_getbibletagcustomtabsmenu.php | 2 +- .../tag}/default_getbibletagdebug.php | 2 +- .../tag}/default_getbibletagfooter.php | 2 +- .../tag}/default_getbibletagparagraphs.php | 2 +- .../default_getbibletagparagraphssorter.php | 2 +- .../tag}/default_getbibletagshare.php | 2 +- .../tag}/default_getbibletagtopmenu.php | 2 +- site/tmpl/tag/index.html | 1 + update_server.xml | 544 +---- 643 files changed, 10753 insertions(+), 12458 deletions(-) create mode 100644 GetbibleInstallerScript.php delete mode 100644 admin/controller.php rename admin/{models => }/forms/book.xml (95%) rename admin/{models => }/forms/chapter.xml (96%) rename admin/{models => }/forms/filter_books.xml (74%) rename admin/{models => }/forms/filter_chapters.xml (74%) rename admin/{models => }/forms/filter_linkers.xml (76%) rename admin/{models => }/forms/filter_notes.xml (78%) rename admin/{models => }/forms/filter_open_ai_messages.xml (77%) rename admin/{models => }/forms/filter_open_ai_responses.xml (79%) rename admin/{models => }/forms/filter_passwords.xml (73%) rename admin/{models => }/forms/filter_prompts.xml (77%) rename admin/{models => }/forms/filter_tagged_verses.xml (74%) rename admin/{models => }/forms/filter_tags.xml (78%) rename admin/{models => }/forms/filter_translations.xml (77%) rename admin/{models => }/forms/filter_verses.xml (77%) rename admin/{controllers => forms}/index.html (100%) rename admin/{models => }/forms/linker.xml (95%) rename admin/{models => }/forms/note.xml (96%) rename admin/{models => }/forms/open_ai_message.xml (96%) rename admin/{models => }/forms/open_ai_response.xml (98%) rename admin/{models => }/forms/password.xml (95%) rename admin/{models => }/forms/prompt.xml (99%) rename admin/{models => }/forms/tag.xml (95%) rename admin/{models => }/forms/tagged_verse.xml (96%) rename admin/{models => }/forms/translation.xml (98%) rename admin/{models => }/forms/verse.xml (96%) delete mode 100644 admin/getbible.php delete mode 100644 admin/helpers/headercheck.php delete mode 100644 admin/helpers/html/batch_.php delete mode 100644 admin/layouts/batchselection.php rename admin/{helpers/html => presets}/index.html (100%) rename admin/{helpers => services}/index.html (100%) create mode 100644 admin/services/provider.php delete mode 100644 admin/sql/updates/mysql/2.0.1.sql delete mode 100644 admin/sql/updates/mysql/2.0.11.sql delete mode 100644 admin/sql/updates/mysql/2.0.12.sql delete mode 100644 admin/sql/updates/mysql/2.0.13.sql delete mode 100644 admin/sql/updates/mysql/2.0.14.sql delete mode 100644 admin/sql/updates/mysql/2.0.15.sql delete mode 100644 admin/sql/updates/mysql/2.0.16.sql delete mode 100644 admin/sql/updates/mysql/2.0.17.sql delete mode 100644 admin/sql/updates/mysql/2.0.18.sql delete mode 100644 admin/sql/updates/mysql/2.0.19.sql delete mode 100644 admin/sql/updates/mysql/2.0.2.sql delete mode 100644 admin/sql/updates/mysql/2.0.20.sql delete mode 100644 admin/sql/updates/mysql/2.0.21.sql delete mode 100644 admin/sql/updates/mysql/2.0.22.sql delete mode 100644 admin/sql/updates/mysql/2.0.23.sql delete mode 100644 admin/sql/updates/mysql/2.0.25.sql delete mode 100644 admin/sql/updates/mysql/2.0.26.sql delete mode 100644 admin/sql/updates/mysql/2.0.27.sql delete mode 100644 admin/sql/updates/mysql/2.0.28.sql delete mode 100644 admin/sql/updates/mysql/2.0.29.sql delete mode 100644 admin/sql/updates/mysql/2.0.3.sql delete mode 100644 admin/sql/updates/mysql/2.0.30.sql delete mode 100644 admin/sql/updates/mysql/2.0.31.sql delete mode 100644 admin/sql/updates/mysql/2.0.32.sql delete mode 100644 admin/sql/updates/mysql/2.0.4.sql delete mode 100644 admin/sql/updates/mysql/2.0.5.sql delete mode 100644 admin/sql/updates/mysql/2.0.6.sql delete mode 100644 admin/sql/updates/mysql/2.0.7.sql delete mode 100644 admin/sql/updates/mysql/2.0.8.sql delete mode 100644 admin/sql/updates/mysql/2.0.9.sql rename admin/{layouts => sql/xml}/index.html (100%) rename admin/{controllers/ajax.json.php => src/Controller/AjaxController.php} (65%) rename admin/{controllers/book.php => src/Controller/BookController.php} (83%) rename admin/{controllers/books.php => src/Controller/BooksController.php} (91%) rename admin/{controllers/chapter.php => src/Controller/ChapterController.php} (83%) rename admin/{controllers/chapters.php => src/Controller/ChaptersController.php} (78%) create mode 100644 admin/src/Controller/DisplayController.php rename admin/{controllers/getbible.php => src/Controller/GetbibleController.php} (82%) rename admin/{controllers/linker.php => src/Controller/LinkerController.php} (83%) rename admin/{controllers/linkers.php => src/Controller/LinkersController.php} (78%) rename admin/{controllers/note.php => src/Controller/NoteController.php} (83%) rename admin/{controllers/notes.php => src/Controller/NotesController.php} (78%) rename admin/{controllers/open_ai_message.php => src/Controller/Open_ai_messageController.php} (83%) rename admin/{controllers/open_ai_messages.php => src/Controller/Open_ai_messagesController.php} (81%) rename admin/{controllers/open_ai_response.php => src/Controller/Open_ai_responseController.php} (83%) rename admin/{controllers/open_ai_responses.php => src/Controller/Open_ai_responsesController.php} (81%) rename admin/{controllers/password.php => src/Controller/PasswordController.php} (83%) rename admin/{controllers/passwords.php => src/Controller/PasswordsController.php} (78%) rename admin/{controllers/prompt.php => src/Controller/PromptController.php} (83%) rename admin/{controllers/prompts.php => src/Controller/PromptsController.php} (78%) rename admin/{controllers/tag.php => src/Controller/TagController.php} (83%) rename admin/{controllers/tagged_verse.php => src/Controller/Tagged_verseController.php} (83%) rename admin/{controllers/tagged_verses.php => src/Controller/Tagged_versesController.php} (77%) rename admin/{controllers/tags.php => src/Controller/TagsController.php} (78%) rename admin/{controllers/translation.php => src/Controller/TranslationController.php} (83%) rename admin/{controllers/translations.php => src/Controller/TranslationsController.php} (91%) rename admin/{controllers/verse.php => src/Controller/VerseController.php} (83%) rename admin/{controllers/verses.php => src/Controller/VersesController.php} (78%) rename admin/{models/fields => src/Controller}/index.html (100%) create mode 100644 admin/src/Extension/GetbibleComponent.php rename admin/{models/forms => src/Extension}/index.html (100%) rename admin/{models/fields/booksfiltername.php => src/Field/BooksfilternameField.php} (78%) rename admin/{models/fields/booksfilternr.php => src/Field/BooksfilternrField.php} (78%) rename admin/{models/fields/chaptersfilterbooknr.php => src/Field/ChaptersfilterbooknrField.php} (77%) rename admin/{models/fields/chaptersfilterchapter.php => src/Field/ChaptersfilterchapterField.php} (77%) rename admin/{models/fields/linkers.php => src/Field/LinkersField.php} (72%) rename admin/{models/fields/linkersfiltername.php => src/Field/LinkersfilternameField.php} (78%) rename admin/{models/fields/linkersfilterpublicnotes.php => src/Field/LinkersfilterpublicnotesField.php} (79%) rename admin/{models/fields/linkersfilterpublictaggedverses.php => src/Field/LinkersfilterpublictaggedversesField.php} (80%) rename admin/{models/fields/notesfilteraccess.php => src/Field/NotesfilteraccessField.php} (79%) rename admin/{models/fields/notesfilterbooknr.php => src/Field/NotesfilterbooknrField.php} (78%) rename admin/{models/fields/notesfilterchapter.php => src/Field/NotesfilterchapterField.php} (78%) rename admin/{models/fields/notesfilterverse.php => src/Field/NotesfilterverseField.php} (78%) rename admin/{models/fields/openaimessagesfilterrole.php => src/Field/OpenaimessagesfilterroleField.php} (79%) rename admin/{models/fields/openaimessagesfiltersource.php => src/Field/OpenaimessagesfiltersourceField.php} (79%) rename admin/{models/fields/openairesponses.php => src/Field/OpenairesponsesField.php} (74%) rename admin/{models/fields/openairesponsesfilterresponseid.php => src/Field/OpenairesponsesfilterresponseidField.php} (78%) rename admin/{models/fields/openairesponsesfilterresponsemodel.php => src/Field/OpenairesponsesfilterresponsemodelField.php} (78%) rename admin/{models/fields/passwordsfiltername.php => src/Field/PasswordsfilternameField.php} (78%) rename admin/{models/fields/prompts.php => src/Field/PromptsField.php} (73%) rename admin/{models/fields/promptsfiltercachebehaviour.php => src/Field/PromptsfiltercachebehaviourField.php} (80%) rename admin/{models/fields/promptsfiltermodel.php => src/Field/PromptsfiltermodelField.php} (79%) rename admin/{models/fields/promptsfiltername.php => src/Field/PromptsfilternameField.php} (78%) rename admin/{models/fields/tagers.php => src/Field/TagersField.php} (71%) rename admin/{models/fields/taggedversesfilteraccess.php => src/Field/TaggedversesfilteraccessField.php} (79%) rename admin/{models/fields/taggedversesfilterbooknr.php => src/Field/TaggedversesfilterbooknrField.php} (77%) rename admin/{models/fields/taggedversesfilterchapter.php => src/Field/TaggedversesfilterchapterField.php} (77%) rename admin/{models/fields/taggedversesfilterverse.php => src/Field/TaggedversesfilterverseField.php} (77%) rename admin/{models/fields/tagsfilteraccess.php => src/Field/TagsfilteraccessField.php} (79%) rename admin/{models/fields/targettranslations.php => src/Field/TargettranslationsField.php} (71%) rename admin/{models/fields/translations.php => src/Field/TranslationsField.php} (70%) rename admin/{models/fields/translationsfilterdirection.php => src/Field/TranslationsfilterdirectionField.php} (79%) rename admin/{models/fields/versesfilterbooknr.php => src/Field/VersesfilterbooknrField.php} (78%) rename admin/{models/fields/versesfilterchapter.php => src/Field/VersesfilterchapterField.php} (78%) rename admin/{models/fields/versesfilterverse.php => src/Field/VersesfilterverseField.php} (78%) rename admin/{models => src/Field}/index.html (100%) rename admin/{helpers/getbible.php => src/Helper/GetbibleHelper.php} (90%) create mode 100644 admin/src/Helper/HeaderCheck.php rename admin/{models/rules => src/Helper}/index.html (100%) rename admin/{models/ajax.php => src/Model/AjaxModel.php} (61%) rename admin/{models/book.php => src/Model/BookModel.php} (91%) rename admin/{models/books.php => src/Model/BooksModel.php} (84%) rename admin/{models/chapter.php => src/Model/ChapterModel.php} (91%) rename admin/{models/chapters.php => src/Model/ChaptersModel.php} (90%) rename admin/{models/getbible.php => src/Model/GetbibleModel.php} (60%) rename admin/{models/linker.php => src/Model/LinkerModel.php} (92%) rename admin/{models/linkers.php => src/Model/LinkersModel.php} (91%) rename admin/{models/note.php => src/Model/NoteModel.php} (92%) rename admin/{models/notes.php => src/Model/NotesModel.php} (91%) rename admin/{models/open_ai_message.php => src/Model/Open_ai_messageModel.php} (92%) rename admin/{models/open_ai_messages.php => src/Model/Open_ai_messagesModel.php} (91%) rename admin/{models/open_ai_response.php => src/Model/Open_ai_responseModel.php} (94%) rename admin/{models/open_ai_responses.php => src/Model/Open_ai_responsesModel.php} (91%) rename admin/{models/password.php => src/Model/PasswordModel.php} (91%) rename admin/{models/passwords.php => src/Model/PasswordsModel.php} (90%) rename admin/{models/prompt.php => src/Model/PromptModel.php} (94%) rename admin/{models/prompts.php => src/Model/PromptsModel.php} (92%) rename admin/{models/tag.php => src/Model/TagModel.php} (91%) rename admin/{models/tagged_verse.php => src/Model/Tagged_verseModel.php} (92%) rename admin/{models/tagged_verses.php => src/Model/Tagged_versesModel.php} (91%) rename admin/{models/tags.php => src/Model/TagsModel.php} (90%) rename admin/{models/translation.php => src/Model/TranslationModel.php} (93%) rename admin/{models/translations.php => src/Model/TranslationsModel.php} (91%) rename admin/{models/verse.php => src/Model/VerseModel.php} (91%) rename admin/{models/verses.php => src/Model/VersesModel.php} (91%) rename admin/{tables => src/Model}/index.html (100%) rename admin/{models/rules/guid.php => src/Rule/GuidRule.php} (90%) rename admin/{models/rules/int.php => src/Rule/IntRule.php} (90%) rename admin/{models/rules/numbershyphens.php => src/Rule/NumbershyphensRule.php} (89%) rename admin/{views/book/tmpl => src/Rule}/index.html (100%) rename admin/{views/books => src/Service}/index.html (100%) rename admin/{tables/book.php => src/Table/BookTable.php} (58%) rename admin/{tables/chapter.php => src/Table/ChapterTable.php} (58%) rename admin/{tables/linker.php => src/Table/LinkerTable.php} (58%) rename admin/{tables/note.php => src/Table/NoteTable.php} (58%) rename admin/{tables/open_ai_message.php => src/Table/Open_ai_messageTable.php} (58%) rename admin/{tables/open_ai_response.php => src/Table/Open_ai_responseTable.php} (58%) rename admin/{tables/password.php => src/Table/PasswordTable.php} (58%) rename admin/{tables/prompt.php => src/Table/PromptTable.php} (58%) rename admin/{tables/tag.php => src/Table/TagTable.php} (58%) rename admin/{tables/tagged_verse.php => src/Table/Tagged_verseTable.php} (58%) rename admin/{tables/translation.php => src/Table/TranslationTable.php} (58%) rename admin/{tables/verse.php => src/Table/VerseTable.php} (58%) rename admin/{views/books/tmpl => src/Table}/index.html (100%) rename admin/{views/book/view.html.php => src/View/Book/HtmlView.php} (82%) rename admin/{views/chapter/tmpl => src/View/Book}/index.html (100%) rename admin/{views/books/view.html.php => src/View/Books/HtmlView.php} (56%) rename admin/{views/chapters => src/View/Books}/index.html (100%) rename admin/{views/chapter/view.html.php => src/View/Chapter/HtmlView.php} (82%) rename admin/{views/chapters/tmpl => src/View/Chapter}/index.html (100%) rename admin/{views/chapters/view.html.php => src/View/Chapters/HtmlView.php} (54%) rename admin/{views/getbible => src/View/Chapters}/index.html (100%) rename admin/{views/getbible/view.html.php => src/View/Getbible/HtmlView.php} (73%) rename admin/{views/getbible/tmpl => src/View/Getbible}/index.html (100%) rename admin/{views/linker/view.html.php => src/View/Linker/HtmlView.php} (88%) rename admin/{views => src/View/Linker}/index.html (100%) rename admin/{views/linkers/view.html.php => src/View/Linkers/HtmlView.php} (53%) rename admin/{views/linker/tmpl => src/View/Linkers}/index.html (100%) rename admin/{views/note/view.html.php => src/View/Note/HtmlView.php} (87%) rename admin/{views/linkers => src/View/Note}/index.html (100%) create mode 100644 admin/src/View/Notes/HtmlView.php rename admin/{views/linkers/tmpl => src/View/Notes}/index.html (100%) rename admin/{views/open_ai_message/view.html.php => src/View/Open_ai_message/HtmlView.php} (87%) rename admin/{views/note/tmpl => src/View/Open_ai_message}/index.html (100%) rename admin/{views/open_ai_messages/view.html.php => src/View/Open_ai_messages/HtmlView.php} (50%) rename admin/{views/notes => src/View/Open_ai_messages}/index.html (100%) rename admin/{views/open_ai_response/view.html.php => src/View/Open_ai_response/HtmlView.php} (88%) rename admin/{views/notes/tmpl => src/View/Open_ai_response}/index.html (100%) rename admin/{views/open_ai_responses/view.html.php => src/View/Open_ai_responses/HtmlView.php} (55%) rename admin/{views/open_ai_message/tmpl => src/View/Open_ai_responses}/index.html (100%) rename admin/{views/password/view.html.php => src/View/Password/HtmlView.php} (87%) rename admin/{views/open_ai_messages => src/View/Password}/index.html (100%) rename admin/{views/passwords/view.html.php => src/View/Passwords/HtmlView.php} (59%) rename admin/{views/open_ai_messages/tmpl => src/View/Passwords}/index.html (100%) rename admin/{views/prompt/view.html.php => src/View/Prompt/HtmlView.php} (87%) rename admin/{views/open_ai_response/tmpl => src/View/Prompt}/index.html (100%) rename admin/{views/prompts/view.html.php => src/View/Prompts/HtmlView.php} (50%) rename admin/{views/open_ai_responses => src/View/Prompts}/index.html (100%) rename admin/{views/tag/view.html.php => src/View/Tag/HtmlView.php} (87%) rename admin/{views/open_ai_responses/tmpl => src/View/Tag}/index.html (100%) rename admin/{views/tagged_verse/view.html.php => src/View/Tagged_verse/HtmlView.php} (87%) rename admin/{views/password/tmpl => src/View/Tagged_verse}/index.html (100%) create mode 100644 admin/src/View/Tagged_verses/HtmlView.php rename admin/{views/passwords => src/View/Tagged_verses}/index.html (100%) rename admin/{views/tags/view.html.php => src/View/Tags/HtmlView.php} (61%) rename admin/{views/passwords/tmpl => src/View/Tags}/index.html (100%) rename admin/{views/translation/view.html.php => src/View/Translation/HtmlView.php} (82%) rename admin/{views/prompt/tmpl => src/View/Translation}/index.html (100%) rename admin/{views/translations/view.html.php => src/View/Translations/HtmlView.php} (67%) rename admin/{views/prompts => src/View/Translations}/index.html (100%) rename admin/{views/verse/view.html.php => src/View/Verse/HtmlView.php} (82%) rename admin/{views/prompts/tmpl => src/View/Verse}/index.html (100%) rename admin/{views/verses/view.html.php => src/View/Verses/HtmlView.php} (50%) rename admin/{views/tag/tmpl => src/View/Verses}/index.html (100%) rename admin/{views/tagged_verse/tmpl => src/View}/index.html (100%) rename admin/{views/tagged_verses => src}/index.html (100%) rename admin/{views/book/tmpl/edit.php => tmpl/book/default.php} (57%) rename admin/{views/tagged_verses/tmpl => tmpl/book}/index.html (100%) rename admin/{views/books/tmpl => tmpl/books}/default.php (76%) rename admin/{views/books/tmpl => tmpl/books}/default_batch_body.php (95%) rename admin/{views/books/tmpl => tmpl/books}/default_batch_footer.php (96%) rename admin/{views/books/tmpl => tmpl/books}/default_body.php (94%) rename admin/{views/passwords/tmpl => tmpl/books}/default_foot.php (95%) rename admin/{views/books/tmpl => tmpl/books}/default_head.php (98%) create mode 100644 admin/tmpl/books/default_toolbar.php create mode 100644 admin/tmpl/books/emptystate.php rename admin/{views/tags => tmpl/books}/index.html (100%) rename admin/{views/chapter/tmpl/edit.php => tmpl/chapter/default.php} (57%) rename admin/{views/tags/tmpl => tmpl/chapter}/index.html (100%) rename admin/{views/chapters/tmpl => tmpl/chapters}/default.php (68%) rename admin/{views/chapters/tmpl => tmpl/chapters}/default_batch_body.php (95%) rename admin/{views/chapters/tmpl => tmpl/chapters}/default_batch_footer.php (96%) rename admin/{views/chapters/tmpl => tmpl/chapters}/default_body.php (94%) rename admin/{views/linkers/tmpl => tmpl/chapters}/default_foot.php (95%) rename admin/{views/chapters/tmpl => tmpl/chapters}/default_head.php (98%) create mode 100644 admin/tmpl/chapters/default_toolbar.php create mode 100644 admin/tmpl/chapters/emptystate.php rename admin/{views/translation/tmpl => tmpl/chapters}/index.html (100%) rename admin/{views/getbible/tmpl => tmpl/getbible}/default.php (74%) rename admin/{views/getbible/tmpl => tmpl/getbible}/default_main.php (95%) rename admin/{views/getbible/tmpl => tmpl/getbible}/default_notice_board_vast_development_method.php (95%) rename admin/{views/getbible/tmpl => tmpl/getbible}/default_readme_information.php (95%) rename admin/{views/getbible/tmpl => tmpl/getbible}/default_vdm.php (93%) rename admin/{views/getbible/tmpl => tmpl/getbible}/default_wiki_tutorials.php (95%) rename admin/{views/translations => tmpl/getbible}/index.html (100%) rename admin/{views/translations => }/tmpl/index.html (100%) rename admin/{views/linker/tmpl/edit.php => tmpl/linker/default.php} (53%) rename admin/{views/verse/tmpl => tmpl/linker}/index.html (100%) rename admin/{views/linkers/tmpl => tmpl/linkers}/default.php (76%) rename admin/{views/linkers/tmpl => tmpl/linkers}/default_batch_body.php (95%) rename admin/{views/linkers/tmpl => tmpl/linkers}/default_batch_footer.php (96%) rename admin/{views/linkers/tmpl => tmpl/linkers}/default_body.php (94%) rename admin/{views/chapters/tmpl => tmpl/linkers}/default_foot.php (95%) rename admin/{views/linkers/tmpl => tmpl/linkers}/default_head.php (98%) create mode 100644 admin/tmpl/linkers/default_toolbar.php create mode 100644 admin/tmpl/linkers/emptystate.php rename admin/{views/verses => tmpl/linkers}/index.html (100%) rename admin/{views/note/tmpl/edit.php => tmpl/note/default.php} (57%) rename admin/{views/verses/tmpl => tmpl/note}/index.html (100%) rename admin/{views/notes/tmpl => tmpl/notes}/default.php (76%) rename admin/{views/notes/tmpl => tmpl/notes}/default_batch_body.php (95%) rename admin/{views/notes/tmpl => tmpl/notes}/default_batch_footer.php (96%) rename admin/{views/notes/tmpl => tmpl/notes}/default_body.php (94%) rename admin/{views/tags/tmpl => tmpl/notes}/default_foot.php (95%) rename admin/{views/notes/tmpl => tmpl/notes}/default_head.php (98%) create mode 100644 admin/tmpl/notes/default_toolbar.php create mode 100644 admin/tmpl/notes/emptystate.php rename {site/controllers => admin/tmpl/notes}/index.html (100%) rename admin/{views/open_ai_message/tmpl/edit.php => tmpl/open_ai_message/default.php} (58%) rename {site/helpers => admin/tmpl/open_ai_message}/index.html (100%) rename admin/{views/open_ai_messages/tmpl => tmpl/open_ai_messages}/default.php (76%) rename admin/{views/open_ai_messages/tmpl => tmpl/open_ai_messages}/default_batch_body.php (95%) rename admin/{views/open_ai_messages/tmpl => tmpl/open_ai_messages}/default_batch_footer.php (96%) rename admin/{views/open_ai_messages/tmpl => tmpl/open_ai_messages}/default_body.php (95%) rename admin/{views/open_ai_messages/tmpl => tmpl/open_ai_messages}/default_foot.php (95%) rename admin/{views/open_ai_messages/tmpl => tmpl/open_ai_messages}/default_head.php (98%) create mode 100644 admin/tmpl/open_ai_messages/default_toolbar.php create mode 100644 admin/tmpl/open_ai_messages/emptystate.php rename {site/models => admin/tmpl/open_ai_messages}/index.html (100%) rename admin/{views/open_ai_response/tmpl/edit.php => tmpl/open_ai_response/default.php} (54%) rename {site/views/api => admin/tmpl/open_ai_response}/index.html (100%) rename admin/{views/open_ai_responses/tmpl => tmpl/open_ai_responses}/default.php (76%) rename admin/{views/open_ai_responses/tmpl => tmpl/open_ai_responses}/default_batch_body.php (95%) rename admin/{views/open_ai_responses/tmpl => tmpl/open_ai_responses}/default_batch_footer.php (96%) rename admin/{views/open_ai_responses/tmpl => tmpl/open_ai_responses}/default_body.php (94%) rename admin/{views/open_ai_responses/tmpl => tmpl/open_ai_responses}/default_foot.php (95%) rename admin/{views/open_ai_responses/tmpl => tmpl/open_ai_responses}/default_head.php (98%) create mode 100644 admin/tmpl/open_ai_responses/default_toolbar.php create mode 100644 admin/tmpl/open_ai_responses/emptystate.php rename {site/views/api/tmpl => admin/tmpl/open_ai_responses}/index.html (100%) rename admin/{views/password/tmpl/edit.php => tmpl/password/default.php} (57%) rename {site/views/app => admin/tmpl/password}/index.html (100%) rename admin/{views/passwords/tmpl => tmpl/passwords}/default.php (76%) rename admin/{views/passwords/tmpl => tmpl/passwords}/default_batch_body.php (95%) rename admin/{views/passwords/tmpl => tmpl/passwords}/default_batch_footer.php (96%) rename admin/{views/passwords/tmpl => tmpl/passwords}/default_body.php (94%) rename admin/{views/books/tmpl => tmpl/passwords}/default_foot.php (95%) rename admin/{views/passwords/tmpl => tmpl/passwords}/default_head.php (98%) create mode 100644 admin/tmpl/passwords/default_toolbar.php create mode 100644 admin/tmpl/passwords/emptystate.php rename {site/views/app/tmpl => admin/tmpl/passwords}/index.html (100%) rename admin/{views/prompt/tmpl/edit.php => tmpl/prompt/default.php} (58%) rename {site/views => admin/tmpl/prompt}/index.html (100%) rename admin/{views/prompts/tmpl => tmpl/prompts}/default.php (76%) rename admin/{views/prompts/tmpl => tmpl/prompts}/default_batch_body.php (95%) rename admin/{views/prompts/tmpl => tmpl/prompts}/default_batch_footer.php (96%) rename admin/{views/prompts/tmpl => tmpl/prompts}/default_body.php (94%) rename admin/{views/prompts/tmpl => tmpl/prompts}/default_foot.php (95%) rename admin/{views/prompts/tmpl => tmpl/prompts}/default_head.php (98%) create mode 100644 admin/tmpl/prompts/default_toolbar.php create mode 100644 admin/tmpl/prompts/emptystate.php rename {site/views/openai => admin/tmpl/prompts}/index.html (100%) rename admin/{views/tag/tmpl/edit.php => tmpl/tag/default.php} (57%) rename {site/views/openai/tmpl => admin/tmpl/tag}/index.html (100%) rename admin/{views/tagged_verse/tmpl/edit.php => tmpl/tagged_verse/default.php} (57%) rename {site/views/search => admin/tmpl/tagged_verse}/index.html (100%) create mode 100644 admin/tmpl/tagged_verses/default.php rename admin/{views/tagged_verses/tmpl => tmpl/tagged_verses}/default_batch_body.php (95%) rename admin/{views/tagged_verses/tmpl => tmpl/tagged_verses}/default_batch_footer.php (96%) rename admin/{views/tagged_verses/tmpl => tmpl/tagged_verses}/default_body.php (95%) rename admin/{views/tagged_verses/tmpl => tmpl/tagged_verses}/default_foot.php (95%) rename admin/{views/tagged_verses/tmpl => tmpl/tagged_verses}/default_head.php (98%) create mode 100644 admin/tmpl/tagged_verses/default_toolbar.php create mode 100644 admin/tmpl/tagged_verses/emptystate.php rename {site/views/search/tmpl => admin/tmpl/tagged_verses}/index.html (100%) rename admin/{views/tags/tmpl => tmpl/tags}/default.php (76%) rename admin/{views/tags/tmpl => tmpl/tags}/default_batch_body.php (95%) rename admin/{views/tags/tmpl => tmpl/tags}/default_batch_footer.php (96%) rename admin/{views/tags/tmpl => tmpl/tags}/default_body.php (93%) rename admin/{views/notes/tmpl => tmpl/tags}/default_foot.php (95%) rename admin/{views/tags/tmpl => tmpl/tags}/default_head.php (98%) create mode 100644 admin/tmpl/tags/default_toolbar.php create mode 100644 admin/tmpl/tags/emptystate.php rename {site/views/tag => admin/tmpl/tags}/index.html (100%) rename admin/{views/translation/tmpl/edit.php => tmpl/translation/default.php} (58%) rename {site/views/tag/tmpl => admin/tmpl/translation}/index.html (100%) rename admin/{views/translations/tmpl => tmpl/translations}/default.php (76%) rename admin/{views/translations/tmpl => tmpl/translations}/default_batch_body.php (95%) rename admin/{views/translations/tmpl => tmpl/translations}/default_batch_footer.php (96%) rename admin/{views/translations/tmpl => tmpl/translations}/default_body.php (94%) rename admin/{views/translations/tmpl => tmpl/translations}/default_foot.php (95%) rename admin/{views/translations/tmpl => tmpl/translations}/default_head.php (98%) create mode 100644 admin/tmpl/translations/default_toolbar.php create mode 100644 admin/tmpl/translations/emptystate.php create mode 100644 admin/tmpl/translations/index.html rename admin/{views/verse/tmpl/edit.php => tmpl/verse/default.php} (57%) create mode 100644 admin/tmpl/verse/index.html rename admin/{views/verses/tmpl => tmpl/verses}/default.php (76%) rename admin/{views/verses/tmpl => tmpl/verses}/default_batch_body.php (95%) rename admin/{views/verses/tmpl => tmpl/verses}/default_batch_footer.php (96%) rename admin/{views/verses/tmpl => tmpl/verses}/default_body.php (94%) create mode 100644 admin/tmpl/verses/default_foot.php rename admin/{views/verses/tmpl => tmpl/verses}/default_head.php (98%) create mode 100644 admin/tmpl/verses/default_toolbar.php create mode 100644 admin/tmpl/verses/emptystate.php create mode 100644 admin/tmpl/verses/index.html delete mode 100644 admin/views/book/submitbutton.js delete mode 100644 admin/views/books/tmpl/default_toolbar.php delete mode 100644 admin/views/chapter/submitbutton.js delete mode 100644 admin/views/chapters/tmpl/default_toolbar.php delete mode 100644 admin/views/linker/submitbutton.js delete mode 100644 admin/views/linkers/tmpl/default_toolbar.php delete mode 100644 admin/views/note/submitbutton.js delete mode 100644 admin/views/notes/tmpl/default_toolbar.php delete mode 100644 admin/views/notes/view.html.php delete mode 100644 admin/views/open_ai_message/submitbutton.js delete mode 100644 admin/views/open_ai_messages/tmpl/default_toolbar.php delete mode 100644 admin/views/open_ai_response/submitbutton.js delete mode 100644 admin/views/open_ai_responses/tmpl/default_toolbar.php delete mode 100644 admin/views/password/submitbutton.js delete mode 100644 admin/views/passwords/tmpl/default_toolbar.php delete mode 100644 admin/views/prompt/submitbutton.js delete mode 100644 admin/views/prompts/tmpl/default_toolbar.php delete mode 100644 admin/views/tag/submitbutton.js delete mode 100644 admin/views/tagged_verse/submitbutton.js delete mode 100644 admin/views/tagged_verses/tmpl/default.php delete mode 100644 admin/views/tagged_verses/tmpl/default_toolbar.php delete mode 100644 admin/views/tagged_verses/view.html.php delete mode 100644 admin/views/tags/tmpl/default_toolbar.php delete mode 100644 admin/views/translation/submitbutton.js delete mode 100644 admin/views/translations/tmpl/default_toolbar.php delete mode 100644 admin/views/verse/submitbutton.js delete mode 100644 admin/views/verses/tmpl/default_foot.php delete mode 100644 admin/views/verses/tmpl/default_toolbar.php create mode 100644 libraries/jcb_powers/VDM.Joomla/src/Utilities/String/NamespaceHelper.php delete mode 100644 script.php delete mode 100644 site/controller.php create mode 100644 site/forms/index.html delete mode 100644 site/getbible.php delete mode 100644 site/helpers/category.php delete mode 100644 site/helpers/headercheck.php delete mode 100644 site/router.php rename site/{controllers/ajax.json.php => src/Controller/AjaxController.php} (75%) create mode 100644 site/src/Controller/DisplayController.php create mode 100644 site/src/Controller/index.html create mode 100644 site/src/Dispatcher/index.html create mode 100644 site/src/Field/index.html rename site/{helpers/getbible.php => src/Helper/GetbibleHelper.php} (90%) create mode 100644 site/src/Helper/HeaderCheck.php rename site/{helpers/route.php => src/Helper/RouteHelper.php} (80%) create mode 100644 site/src/Helper/index.html rename site/{models/ajax.php => src/Model/AjaxModel.php} (95%) rename site/{models/api.php => src/Model/ApiModel.php} (90%) rename site/{models/app.php => src/Model/AppModel.php} (95%) rename site/{models/openai.php => src/Model/OpenaiModel.php} (95%) rename site/{models/search.php => src/Model/SearchModel.php} (92%) rename site/{models/tag.php => src/Model/TagModel.php} (95%) create mode 100644 site/src/Model/index.html create mode 100644 site/src/Rule/index.html create mode 100644 site/src/Service/Router.php create mode 100644 site/src/Service/index.html rename site/{views/api/view.html.php => src/View/Api/HtmlView.php} (87%) create mode 100644 site/src/View/Api/index.html rename site/{views/app/view.html.php => src/View/App/HtmlView.php} (95%) create mode 100644 site/src/View/App/index.html rename site/{views/openai/view.html.php => src/View/Openai/HtmlView.php} (93%) create mode 100644 site/src/View/Openai/index.html rename site/{views/search/view.html.php => src/View/Search/HtmlView.php} (94%) create mode 100644 site/src/View/Search/index.html rename site/{views/tag/view.html.php => src/View/Tag/HtmlView.php} (94%) create mode 100644 site/src/View/Tag/index.html create mode 100644 site/src/View/index.html create mode 100644 site/src/index.html rename site/{views/api/tmpl => tmpl/api}/default.php (91%) rename site/{views/api/tmpl => tmpl/api}/default.xml (100%) create mode 100644 site/tmpl/api/index.html rename site/{views/app/tmpl => tmpl/app}/default.php (92%) rename site/{views/app/tmpl => tmpl/app}/default.xml (99%) rename site/{views/app/tmpl => tmpl/app}/default_getbibleapp.php (97%) rename site/{views/app/tmpl => tmpl/app}/default_getbibleappactivesession.php (97%) rename site/{views/app/tmpl => tmpl/app}/default_getbibleappbody.php (97%) rename site/{views/app/tmpl => tmpl/app}/default_getbibleappbottommenu.php (97%) rename site/{views/app/tmpl => tmpl/app}/default_getbibleappcustomtabs.php (96%) rename site/{views/app/tmpl => tmpl/app}/default_getbibleappcustomtabsmenu.php (95%) rename site/{views/app/tmpl => tmpl/app}/default_getbibleappdebug.php (96%) rename site/{views/app/tmpl => tmpl/app}/default_getbibleappdetails.php (97%) rename site/{views/app/tmpl => tmpl/app}/default_getbibleappfooter.php (98%) rename site/{views/app/tmpl => tmpl/app}/default_getbibleappmodalbottom.php (97%) rename site/{views/app/tmpl => tmpl/app}/default_getbibleappnotes.php (97%) rename site/{views/app/tmpl => tmpl/app}/default_getbibleappsettings.php (96%) rename site/{views/app/tmpl => tmpl/app}/default_getbibleappshare.php (97%) rename site/{views/app/tmpl => tmpl/app}/default_getbibleapptags.php (97%) rename site/{views/app/tmpl => tmpl/app}/default_getbibleapptopmenu.php (97%) rename site/{views/app/tmpl => tmpl/app}/default_getbibleappword.php (97%) rename site/{views/app/tmpl => tmpl/app}/default_getbiblebooks.php (96%) rename site/{views/app/tmpl => tmpl/app}/default_getbiblechapters.php (96%) rename site/{views/app/tmpl => tmpl/app}/default_getbiblefavouriteverseselector.php (97%) rename site/{views/app/tmpl => tmpl/app}/default_getbibleinstallbutton.php (97%) rename site/{views/app/tmpl => tmpl/app}/default_getbiblelinkermanager.php (96%) rename site/{views/app/tmpl => tmpl/app}/default_getbiblemodules.php (96%) rename site/{views/app/tmpl => tmpl/app}/default_getbibletext.php (97%) rename site/{views/app/tmpl => tmpl/app}/default_getbibletranslations.php (97%) rename site/{views/app/tmpl => tmpl/app}/default_versesparagraph.php (95%) rename site/{views/app/tmpl => tmpl/app}/default_versesunorderedlist.php (95%) create mode 100644 site/tmpl/app/index.html create mode 100644 site/tmpl/index.html rename site/{views/openai/tmpl => tmpl/openai}/default.php (93%) rename site/{views/openai/tmpl => tmpl/openai}/default_getbibleai.php (96%) rename site/{views/openai/tmpl => tmpl/openai}/default_getbibleaibody.php (96%) rename site/{views/openai/tmpl => tmpl/openai}/default_getbibleaibottommenu.php (96%) rename site/{views/openai/tmpl => tmpl/openai}/default_getbibleaicustomtabs.php (96%) rename site/{views/openai/tmpl => tmpl/openai}/default_getbibleaicustomtabsmenu.php (95%) rename site/{views/openai/tmpl => tmpl/openai}/default_getbibleaidebug.php (96%) rename site/{views/openai/tmpl => tmpl/openai}/default_getbibleaidetails.php (95%) rename site/{views/openai/tmpl => tmpl/openai}/default_getbibleaifilter.php (95%) rename site/{views/openai/tmpl => tmpl/openai}/default_getbibleaifooter.php (95%) rename site/{views/openai/tmpl => tmpl/openai}/default_getbibleaimessages.php (95%) rename site/{views/openai/tmpl => tmpl/openai}/default_getbibleaipromptmessages.php (95%) rename site/{views/openai/tmpl => tmpl/openai}/default_getbibleaitopmenu.php (96%) rename site/{views/openai/tmpl => tmpl/openai}/default_getbiblemodules.php (96%) rename site/{views/openai/tmpl => tmpl/openai}/default_getbiblepromptsettings.php (95%) create mode 100644 site/tmpl/openai/index.html rename site/{views/search/tmpl => tmpl/search}/default.php (92%) rename site/{views/search/tmpl => tmpl/search}/default_getbiblemodules.php (96%) rename site/{views/search/tmpl => tmpl/search}/default_getbiblesearch.php (96%) rename site/{views/search/tmpl => tmpl/search}/default_getbiblesearchbox.php (96%) rename site/{views/search/tmpl => tmpl/search}/default_getbiblesearchinput.php (96%) rename site/{views/search/tmpl => tmpl/search}/default_getbiblesearchnotenoughverses.php (96%) rename site/{views/search/tmpl => tmpl/search}/default_getbiblesearchoptions.php (97%) rename site/{views/search/tmpl => tmpl/search}/default_getbiblesearchtable.php (96%) create mode 100644 site/tmpl/search/index.html rename site/{views/tag/tmpl => tmpl/tag}/default.php (93%) rename site/{views/tag/tmpl => tmpl/tag}/default_getbiblemodules.php (96%) rename site/{views/tag/tmpl => tmpl/tag}/default_getbiblenotag.php (96%) rename site/{views/tag/tmpl => tmpl/tag}/default_getbibleselecttags.php (96%) rename site/{views/tag/tmpl => tmpl/tag}/default_getbibletag.php (96%) rename site/{views/tag/tmpl => tmpl/tag}/default_getbibletagbody.php (97%) rename site/{views/tag/tmpl => tmpl/tag}/default_getbibletagbottommenu.php (96%) rename site/{views/tag/tmpl => tmpl/tag}/default_getbibletagcustomtabs.php (96%) rename site/{views/tag/tmpl => tmpl/tag}/default_getbibletagcustomtabsmenu.php (95%) rename site/{views/tag/tmpl => tmpl/tag}/default_getbibletagdebug.php (96%) rename site/{views/tag/tmpl => tmpl/tag}/default_getbibletagfooter.php (95%) rename site/{views/tag/tmpl => tmpl/tag}/default_getbibletagparagraphs.php (96%) rename site/{views/tag/tmpl => tmpl/tag}/default_getbibletagparagraphssorter.php (96%) rename site/{views/tag/tmpl => tmpl/tag}/default_getbibletagshare.php (96%) rename site/{views/tag/tmpl => tmpl/tag}/default_getbibletagtopmenu.php (96%) create mode 100644 site/tmpl/tag/index.html diff --git a/CHANGELOG.md b/CHANGELOG.md index 6b7e8f4..68e4252 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,172 +1,3 @@ -# v2.1.0 +# v5.0.0 -- Move all JText to use the namespaced class Text directly. -- Move all JHtml to use the namespaced class Html directly. -- Move all JFactory to use the namespaced class Factory directly. -- Move all JRoute to use the namespaced class Route directly. -- Move all JFormHelper to use the namespaced class FormHelper directly. -- Move all JLayout to use the namespaced class FileLayout directly. -- Move all JLanguageMultilang to use the namespaced class Multilanguage directly. -- Move all JComponentHelper to use the namespaced class ComponentHelper directly. -- Move all JCategoryNode to use the namespaced class CategoryNode directly. -- Move all JComponentHelper to use the namespaced class ComponentHelper directly. -- Move all JToolbar to use the namespaced class Toolbar directly. -- Move all JToolbarHelper to use the namespaced class ToolbarHelper directly. -- Convert all addStyleSheet to make use of Html class instead. -- Convert all addScript to make use of Html class instead. - -# v2.0.32 - -- Fixed other search related issues. - -# v2.0.31 - -- Fixed #10 so that exact search results now work correctly. -- Update scripture loader to version 3.0.3 - -# v2.0.30 - -- Update scripture loader to version 3.0.2 - -# v2.0.29 - -- Update scripture loader to version 3.0.1 - -# v2.0.28 - -- Small xml fix - -# v2.0.27 - -- Improved the load scripture plugin. - -# v2.0.26 - -- Adds few try catch blocks in the API. -- Adds local link to daily scripture module. - -# v2.0.25 - -- Adds getBible Loader Plugin - -# v2.0.23 - -- Refactored all core helper functions to make use of New classes -- Adds open ai meta data to page -- Other JCB fixes - -# v2.0.22 - -- Fixed search redirect bug - -# v2.0.21 - -- Adds Tags meta data to tag pages -- Adds option to share a tag -- Improve the URL creation, and return URL feature for search and tag pages - -# v2.0.20 - -- First step to resolve getBible/support#8 so that the selection works on mobile browsers. -- Fixed the scrolling for mobiles. - -# v2.0.19 - -- Adds metadata to each Bible page to resolve getBible/support#6 -- Adds option to force chapter hash checking. - -# v2.0.18 - -- Adds bottom module position on tag, search, ai and app pages. -- Fixed JavaScript Database Manager some more. - -# v2.0.17 - -- Adds brut-force protection - -# v2.0.16 - -- Fixed JavaScript Database Manager - -# v2.0.15 - -- Adds new session option -- Adds make public switches to back-end - -# v2.0.14 - -- Adds install mysql commands for faster queries on large systems. -- Fixes mobile layout on settings active session tab. -- Making correction to tag descriptions. - -# v2.0.13 - -- Fix tag issues -- Adds Footable to back-end -- Fix chapter issue of app page -- Moves translations tab - -# v2.0.12 - -- Fixes Links to Translations (to use their own book names) - -# v2.0.11 - -- Adds better translation selection by Language - -# v2.0.9 - -- Adds create tags on front-end. -- Adds update tags on front-end. -- Adds delete of tags on front-end. -- Improves verse view in note, and tag modal. -- Other bug fixes. - -# v2.0.8 - -- Adds easy option to update book names in the back-end. -- Adds easy option to sync translations details in the back-end. - -# v2.0.7 - -- Adds force update option -- Improves the book name display on Bible page - -# v2.0.6 - -- Adds updating watchers for book names, and translation details. -- Adds edit option to owned tags -- Better session management that allows sharing sessions. -- Few bug fixes - -# v2.0.5 - -- Adds list of default system tags -- Adds linker session manager -- Adds option to share sessions - -# v2.0.4 - -- Added the option to set the default Translation. -- Fixed sharing of a verse, so its auto selected when verse number is clicked. - -# v2.0.3 - -- Fixed getBible/support#2 so that the view value does not result into Undefined. -- Fixed getBible/support#3 so that empty translations and translations without the selected books better manage the mismatching query. - -# v2.0.2 - -- Adds missing Marked JS file - -# 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 +- Moved to Joomla 4 and 5 \ No newline at end of file diff --git a/GetbibleInstallerScript.php b/GetbibleInstallerScript.php new file mode 100644 index 0000000..9c185d0 --- /dev/null +++ b/GetbibleInstallerScript.php @@ -0,0 +1,1820 @@ + + @git Get Bible + @github Get Bible + @support Get Bible + @copyright Copyright (C) 2015. All Rights Reserved + @license GNU/GPL Version 2 or later - http://www.gnu.org/licenses/gpl-2.0.html + +/------------------------------------------------------------------------------------------------------*/ + +use Joomla\CMS\Factory; +use Joomla\CMS\Language\Text; +use Joomla\CMS\Filesystem\File; +use Joomla\CMS\Installer\InstallerAdapter; +use Joomla\CMS\Installer\InstallerScriptInterface; +use Joomla\CMS\Application\CMSApplication; +use Joomla\CMS\Log\Log; +use Joomla\CMS\Version; +use Joomla\CMS\HTML\HTMLHelper as Html; +use Joomla\Filesystem\Folder; +use Joomla\Database\DatabaseInterface; + +// No direct access to this file +defined('_JEXEC') or die; + +/** + * Script File of Getbible Component + * + * @since 3.6 + */ +class Com_GetbibleInstallerScript implements InstallerScriptInterface +{ + /** + * The CMS Application. + * + * @var CMSApplication + * @since 4.4.2 + */ + protected CMSApplication $app; + + /** + * The database class. + * + * @since 4.4.2 + */ + protected $db; + + /** + * The version number of the extension. + * + * @var string + * @since 3.6 + */ + protected $release; + + /** + * The table the parameters are stored in. + * + * @var string + * @since 3.6 + */ + protected $paramTable; + + /** + * The extension name. This should be set in the installer script. + * + * @var string + * @since 3.6 + */ + protected $extension; + + /** + * A list of files to be deleted + * + * @var array + * @since 3.6 + */ + protected $deleteFiles = []; + + /** + * A list of folders to be deleted + * + * @var array + * @since 3.6 + */ + protected $deleteFolders = []; + + /** + * A list of CLI script files to be copied to the cli directory + * + * @var array + * @since 3.6 + */ + protected $cliScriptFiles = []; + + /** + * Minimum PHP version required to install the extension + * + * @var string + * @since 3.6 + */ + protected $minimumPhp; + + /** + * Minimum Joomla! version required to install the extension + * + * @var string + * @since 3.6 + */ + protected $minimumJoomla; + + /** + * Extension script constructor. + * + * @since 3.0.0 + */ + public function __construct() + { + $this->minimumJoomla = '4.3'; + $this->minimumPhp = JOOMLA_MINIMUM_PHP; + $this->app = Factory::getApplication(); + $this->db = Factory::getContainer()->get(DatabaseInterface::class); + + // check if the files exist + if (is_file(JPATH_ROOT . '/administrator/components/com_getbible/getbible.php')) + { + // remove Joomla 3 files + $this->deleteFiles = [ + '/administrator/components/com_getbible/getbible.php', + '/administrator/components/com_getbible/controller.php', + '/components/com_getbible/getbible.php', + '/components/com_getbible/controller.php', + '/components/com_getbible/router.php', + ]; + } + + // check if the Folders exist + if (is_dir(JPATH_ROOT . '/administrator/components/com_getbible/modules')) + { + // remove Joomla 3 folder + $this->deleteFolders = [ + '/administrator/components/com_getbible/controllers', + '/administrator/components/com_getbible/helpers', + '/administrator/components/com_getbible/modules', + '/administrator/components/com_getbible/tables', + '/administrator/components/com_getbible/views', + '/components/com_getbible/controllers', + '/components/com_getbible/helpers', + '/components/com_getbible/modules', + '/components/com_getbible/views', + ]; + } + } + + /** + * Function called after the extension is installed. + * + * @param InstallerAdapter $adapter The adapter calling this method + * + * @return boolean True on success + * + * @since 4.2.0 + */ + public function install(InstallerAdapter $adapter): bool {return true;} + + /** + * Function called after the extension is updated. + * + * @param InstallerAdapter $adapter The adapter calling this method + * + * @return boolean True on success + * + * @since 4.2.0 + */ + public function update(InstallerAdapter $adapter): bool {return true;} + + /** + * Function called after the extension is uninstalled. + * + * @param InstallerAdapter $adapter The adapter calling this method + * + * @return boolean True on success + * + * @since 4.2.0 + */ + public function uninstall(InstallerAdapter $adapter): bool + { + // Remove Related Component Data. + + // Remove Note Data + $this->removeViewData("com_getbible.note"); + + // Remove Tagged verse Data + $this->removeViewData("com_getbible.tagged_verse"); + + // Remove Prompt Data + $this->removeViewData("com_getbible.prompt"); + + // Remove Open ai response Data + $this->removeViewData("com_getbible.open_ai_response"); + + // Remove Open ai message Data + $this->removeViewData("com_getbible.open_ai_message"); + + // Remove Tag Data + $this->removeViewData("com_getbible.tag"); + + // Remove Asset Data. + $this->removeAssetData(); + + // Revert the assets table rules column back to the default. + $this->removeDatabaseAssetsRulesFix(); + + // Remove component from action logs extensions table. + $this->removeActionLogsExtensions(); + + // Remove Linker from action logs config table. + $this->removeActionLogConfig('com_getbible.linker'); + + // Remove Note from action logs config table. + $this->removeActionLogConfig('com_getbible.note'); + + // Remove Tagged_verse from action logs config table. + $this->removeActionLogConfig('com_getbible.tagged_verse'); + + // Remove Prompt from action logs config table. + $this->removeActionLogConfig('com_getbible.prompt'); + + // Remove Open_ai_response from action logs config table. + $this->removeActionLogConfig('com_getbible.open_ai_response'); + + // Remove Open_ai_message from action logs config table. + $this->removeActionLogConfig('com_getbible.open_ai_message'); + + // Remove Password from action logs config table. + $this->removeActionLogConfig('com_getbible.password'); + + // Remove Tag from action logs config table. + $this->removeActionLogConfig('com_getbible.tag'); + + // Remove Translation from action logs config table. + $this->removeActionLogConfig('com_getbible.translation'); + + // Remove Book from action logs config table. + $this->removeActionLogConfig('com_getbible.book'); + + // Remove Chapter from action logs config table. + $this->removeActionLogConfig('com_getbible.chapter'); + + // Remove Verse from action logs config table. + $this->removeActionLogConfig('com_getbible.verse'); + // little notice as after service, in case of bad experience with component. + echo '
+

Did something go wrong? Are you disappointed?

+

Please let me know at joomla@vdm.io. +
We at Vast Development Method are committed to building extensions that performs proficiently! You can help us, really! +
Send me your thoughts on improvements that is needed, trust me, I will be very grateful! +
Visit us at https://getbible.net today!

'; + + return true; + } + + /** + * Function called before extension installation/update/removal procedure commences. + * + * @param string $type The type of change (install or discover_install, update, uninstall) + * @param InstallerAdapter $adapter The adapter calling this method + * + * @return boolean True on success + * + * @since 4.2.0 + */ + public function preflight(string $type, InstallerAdapter $adapter): bool + { + // Check for the minimum PHP version before continuing + if (!empty($this->minimumPhp) && version_compare(PHP_VERSION, $this->minimumPhp, '<')) + { + Log::add(Text::sprintf('JLIB_INSTALLER_MINIMUM_PHP', $this->minimumPhp), Log::WARNING, 'jerror'); + + return false; + } + + // Check for the minimum Joomla version before continuing + if (!empty($this->minimumJoomla) && version_compare(JVERSION, $this->minimumJoomla, '<')) + { + Log::add(Text::sprintf('JLIB_INSTALLER_MINIMUM_JOOMLA', $this->minimumJoomla), Log::WARNING, 'jerror'); + + return false; + } + + // Extension manifest file version + $this->extension = $adapter->getName(); + $this->release = $adapter->getManifest()->version; + + // do any updates needed + if ($type === 'update') + { + } + + // do any install needed + if ($type === 'install') + { + } + + return true; + } + + /** + * Function called after extension installation/update/removal procedure commences. + * + * @param string $type The type of change (install or discover_install, update, uninstall) + * @param InstallerAdapter $adapter The adapter calling this method + * + * @return boolean True on success + * + * @since 4.2.0 + */ + public function postflight(string $type, InstallerAdapter $adapter): bool + { + // We check if we have dynamic folders to copy + $this->moveFolders($adapter); + + // set the default component settings + if ($type === 'install') + { + + // Install Note Content Types. + $this->setContentType( + // typeTitle + 'Getbible Note', + // typeAlias + 'com_getbible.note', + // table + '{"special": {"dbtable": "#__getbible_note","key": "id","type": "NoteTable","prefix": "TrueChristianChurch\Component\Getbible\Administrator\Table"}}', + // rules + '', + // fieldMappings + '{"common": {"core_content_item_id": "id","core_title": "null","core_state": "published","core_alias": "null","core_created_time": "created","core_modified_time": "modified","core_body": "null","core_hits": "hits","core_publish_up": "null","core_publish_down": "null","core_access": "access","core_params": "params","core_featured": "null","core_metadata": "null","core_language": "null","core_images": "null","core_urls": "null","core_version": "version","core_ordering": "ordering","core_metakey": "null","core_metadesc": "null","core_catid": "null","core_xreference": "null","asset_id": "asset_id"},"special": {"book_nr":"book_nr","linker":"linker","guid":"guid","note":"note","verse":"verse","chapter":"chapter"}}', + // router + '', + // contentHistoryOptions + '{"formFile": "administrator/components/com_getbible/forms/note.xml","hideFields": ["asset_id","checked_out","checked_out_time","version"],"ignoreChanges": ["modified_by","modified","checked_out","checked_out_time","version","hits"],"convertToInt": ["published","ordering","book_nr","access","verse","chapter"],"displayLookup": [{"sourceColumn": "created_by","targetTable": "#__users","targetColumn": "id","displayColumn": "name"},{"sourceColumn": "access","targetTable": "#__viewlevels","targetColumn": "id","displayColumn": "title"},{"sourceColumn": "modified_by","targetTable": "#__users","targetColumn": "id","displayColumn": "name"},{"sourceColumn": "linker","targetTable": "#__getbible_linker","targetColumn": "guid","displayColumn": "name"}]}' + ); + // Install Tagged verse Content Types. + $this->setContentType( + // typeTitle + 'Getbible Tagged_verse', + // typeAlias + 'com_getbible.tagged_verse', + // table + '{"special": {"dbtable": "#__getbible_tagged_verse","key": "id","type": "Tagged_verseTable","prefix": "TrueChristianChurch\Component\Getbible\Administrator\Table"}}', + // rules + '', + // fieldMappings + '{"common": {"core_content_item_id": "id","core_title": "null","core_state": "published","core_alias": "null","core_created_time": "created","core_modified_time": "modified","core_body": "null","core_hits": "hits","core_publish_up": "null","core_publish_down": "null","core_access": "access","core_params": "params","core_featured": "null","core_metadata": "null","core_language": "null","core_images": "null","core_urls": "null","core_version": "version","core_ordering": "ordering","core_metakey": "null","core_metadesc": "null","core_catid": "null","core_xreference": "null","asset_id": "asset_id"},"special": {"book_nr":"book_nr","abbreviation":"abbreviation","linker":"linker","tag":"tag","guid":"guid","verse":"verse","chapter":"chapter"}}', + // router + '', + // contentHistoryOptions + '{"formFile": "administrator/components/com_getbible/forms/tagged_verse.xml","hideFields": ["asset_id","checked_out","checked_out_time","version"],"ignoreChanges": ["modified_by","modified","checked_out","checked_out_time","version","hits"],"convertToInt": ["published","ordering","book_nr","access","verse","chapter"],"displayLookup": [{"sourceColumn": "created_by","targetTable": "#__users","targetColumn": "id","displayColumn": "name"},{"sourceColumn": "access","targetTable": "#__viewlevels","targetColumn": "id","displayColumn": "title"},{"sourceColumn": "modified_by","targetTable": "#__users","targetColumn": "id","displayColumn": "name"},{"sourceColumn": "abbreviation","targetTable": "#__getbible_translation","targetColumn": "abbreviation","displayColumn": "translation"},{"sourceColumn": "linker","targetTable": "#__getbible_linker","targetColumn": "guid","displayColumn": "name"},{"sourceColumn": "tag","targetTable": "#__getbible_tag","targetColumn": "guid","displayColumn": "name"}]}' + ); + // Install Prompt Content Types. + $this->setContentType( + // typeTitle + 'Getbible Prompt', + // typeAlias + 'com_getbible.prompt', + // table + '{"special": {"dbtable": "#__getbible_prompt","key": "id","type": "PromptTable","prefix": "TrueChristianChurch\Component\Getbible\Administrator\Table"}}', + // rules + '', + // fieldMappings + '{"common": {"core_content_item_id": "id","core_title": "name","core_state": "published","core_alias": "null","core_created_time": "created","core_modified_time": "modified","core_body": "null","core_hits": "hits","core_publish_up": "null","core_publish_down": "null","core_access": "access","core_params": "params","core_featured": "null","core_metadata": "null","core_language": "null","core_images": "null","core_urls": "null","core_version": "version","core_ordering": "ordering","core_metakey": "null","core_metadesc": "null","core_catid": "null","core_xreference": "null","asset_id": "asset_id"},"special": {"name":"name","integration":"integration","cache_behaviour":"cache_behaviour","abbreviation":"abbreviation","guid":"guid","model":"model","presence_penalty":"presence_penalty","org_token":"org_token","token":"token","n_override":"n_override","cache_capacity":"cache_capacity","response_retrieval":"response_retrieval","frequency_penalty_override":"frequency_penalty_override","n":"n","max_tokens_override":"max_tokens_override","token_override":"token_override","max_tokens":"max_tokens","ai_org_token_override":"ai_org_token_override","temperature_override":"temperature_override","presence_penalty_override":"presence_penalty_override","top_p_override":"top_p_override","frequency_penalty":"frequency_penalty","top_p":"top_p","temperature":"temperature"}}', + // router + '', + // contentHistoryOptions + '{"formFile": "administrator/components/com_getbible/forms/prompt.xml","hideFields": ["asset_id","checked_out","checked_out_time","version"],"ignoreChanges": ["modified_by","modified","checked_out","checked_out_time","version","hits"],"convertToInt": ["published","ordering","integration","cache_behaviour","n_override","cache_capacity","response_retrieval","frequency_penalty_override","n","max_tokens_override","token_override","max_tokens","ai_org_token_override","temperature_override","presence_penalty_override","top_p_override"],"displayLookup": [{"sourceColumn": "created_by","targetTable": "#__users","targetColumn": "id","displayColumn": "name"},{"sourceColumn": "access","targetTable": "#__viewlevels","targetColumn": "id","displayColumn": "title"},{"sourceColumn": "modified_by","targetTable": "#__users","targetColumn": "id","displayColumn": "name"},{"sourceColumn": "abbreviation","targetTable": "#__getbible_translation","targetColumn": "abbreviation","displayColumn": "translation"}]}' + ); + // Install Open ai response Content Types. + $this->setContentType( + // typeTitle + 'Getbible Open_ai_response', + // typeAlias + 'com_getbible.open_ai_response', + // table + '{"special": {"dbtable": "#__getbible_open_ai_response","key": "id","type": "Open_ai_responseTable","prefix": "TrueChristianChurch\Component\Getbible\Administrator\Table"}}', + // rules + '', + // fieldMappings + '{"common": {"core_content_item_id": "id","core_title": "response_id","core_state": "published","core_alias": "null","core_created_time": "created","core_modified_time": "modified","core_body": "null","core_hits": "hits","core_publish_up": "null","core_publish_down": "null","core_access": "access","core_params": "params","core_featured": "null","core_metadata": "null","core_language": "null","core_images": "null","core_urls": "null","core_version": "version","core_ordering": "ordering","core_metakey": "null","core_metadesc": "null","core_catid": "null","core_xreference": "null","asset_id": "asset_id"},"special": {"response_id":"response_id","prompt":"prompt","response_object":"response_object","response_model":"response_model","total_tokens":"total_tokens","n":"n","frequency_penalty":"frequency_penalty","presence_penalty":"presence_penalty","word":"word","chapter":"chapter","lcsh":"lcsh","completion_tokens":"completion_tokens","prompt_tokens":"prompt_tokens","response_created":"response_created","abbreviation":"abbreviation","language":"language","max_tokens":"max_tokens","book":"book","temperature":"temperature","verse":"verse","top_p":"top_p","selected_word":"selected_word","model":"model"}}', + // router + '', + // contentHistoryOptions + '{"formFile": "administrator/components/com_getbible/forms/open_ai_response.xml","hideFields": ["asset_id","checked_out","checked_out_time","version"],"ignoreChanges": ["modified_by","modified","checked_out","checked_out_time","version","hits"],"convertToInt": ["published","ordering","total_tokens","n","chapter","completion_tokens","prompt_tokens","max_tokens","book"],"displayLookup": [{"sourceColumn": "created_by","targetTable": "#__users","targetColumn": "id","displayColumn": "name"},{"sourceColumn": "access","targetTable": "#__viewlevels","targetColumn": "id","displayColumn": "title"},{"sourceColumn": "modified_by","targetTable": "#__users","targetColumn": "id","displayColumn": "name"},{"sourceColumn": "prompt","targetTable": "#__getbible_prompt","targetColumn": "guid","displayColumn": "name"},{"sourceColumn": "abbreviation","targetTable": "#__getbible_translation","targetColumn": "abbreviation","displayColumn": "translation"}]}' + ); + // Install Open ai message Content Types. + $this->setContentType( + // typeTitle + 'Getbible Open_ai_message', + // typeAlias + 'com_getbible.open_ai_message', + // table + '{"special": {"dbtable": "#__getbible_open_ai_message","key": "id","type": "Open_ai_messageTable","prefix": "TrueChristianChurch\Component\Getbible\Administrator\Table"}}', + // rules + '', + // fieldMappings + '{"common": {"core_content_item_id": "id","core_title": "role","core_state": "published","core_alias": "null","core_created_time": "created","core_modified_time": "modified","core_body": "null","core_hits": "hits","core_publish_up": "null","core_publish_down": "null","core_access": "access","core_params": "params","core_featured": "null","core_metadata": "null","core_language": "null","core_images": "null","core_urls": "null","core_version": "version","core_ordering": "ordering","core_metakey": "null","core_metadesc": "null","core_catid": "null","core_xreference": "null","asset_id": "asset_id"},"special": {"role":"role","open_ai_response":"open_ai_response","prompt":"prompt","source":"source","content":"content","name":"name","index":"index"}}', + // router + '', + // contentHistoryOptions + '{"formFile": "administrator/components/com_getbible/forms/open_ai_message.xml","hideFields": ["asset_id","checked_out","checked_out_time","version"],"ignoreChanges": ["modified_by","modified","checked_out","checked_out_time","version","hits"],"convertToInt": ["published","ordering","source","index"],"displayLookup": [{"sourceColumn": "created_by","targetTable": "#__users","targetColumn": "id","displayColumn": "name"},{"sourceColumn": "access","targetTable": "#__viewlevels","targetColumn": "id","displayColumn": "title"},{"sourceColumn": "modified_by","targetTable": "#__users","targetColumn": "id","displayColumn": "name"},{"sourceColumn": "open_ai_response","targetTable": "#__getbible_open_ai_response","targetColumn": "response_id","displayColumn": "response_id"},{"sourceColumn": "prompt","targetTable": "#__getbible_prompt","targetColumn": "guid","displayColumn": "name"}]}' + ); + // Install Tag Content Types. + $this->setContentType( + // typeTitle + 'Getbible Tag', + // typeAlias + 'com_getbible.tag', + // table + '{"special": {"dbtable": "#__getbible_tag","key": "id","type": "TagTable","prefix": "TrueChristianChurch\Component\Getbible\Administrator\Table"}}', + // rules + '', + // fieldMappings + '{"common": {"core_content_item_id": "id","core_title": "name","core_state": "published","core_alias": "null","core_created_time": "created","core_modified_time": "modified","core_body": "null","core_hits": "hits","core_publish_up": "null","core_publish_down": "null","core_access": "access","core_params": "params","core_featured": "null","core_metadata": "null","core_language": "null","core_images": "null","core_urls": "null","core_version": "version","core_ordering": "ordering","core_metakey": "null","core_metadesc": "null","core_catid": "null","core_xreference": "null","asset_id": "asset_id"},"special": {"name":"name","linker":"linker","guid":"guid","description":"description"}}', + // router + '', + // contentHistoryOptions + '{"formFile": "administrator/components/com_getbible/forms/tag.xml","hideFields": ["asset_id","checked_out","checked_out_time","version"],"ignoreChanges": ["modified_by","modified","checked_out","checked_out_time","version","hits"],"convertToInt": ["published","ordering","access"],"displayLookup": [{"sourceColumn": "created_by","targetTable": "#__users","targetColumn": "id","displayColumn": "name"},{"sourceColumn": "access","targetTable": "#__viewlevels","targetColumn": "id","displayColumn": "title"},{"sourceColumn": "modified_by","targetTable": "#__users","targetColumn": "id","displayColumn": "name"},{"sourceColumn": "linker","targetTable": "#__getbible_linker","targetColumn": "guid","displayColumn": "name"}]}' + ); + + + // Fix the assets table rules column size. + $this->setDatabaseAssetsRulesFix(44480, "TEXT"); + // Install the global extension params. + $this->setExtensionsParams( + '{"autorName":"Llewellyn van der Merwe","autorEmail":"joomla@vdm.io","default_translation":"kjv","show_install_button":"0","show_getbible_logo":"1","show_getbible_link":"1","show_hash_validation":"1","show_api_link":"1","activate_search":"0","search_found_color":"#4747ff","table_selection_color":"#dfdfdf","search_words":"1","search_match":"1","search_case":"1","bottom_search_position":"div","show_bottom_search_position_card":"1","bottom_search_position_card_style":"default","activate_notes":"0","activate_tags":"0","allow_untagging":"0","bottom_tag_position":"div","show_bottom_tag_position_card":"1","bottom_tag_position_card_style":"default","activate_sharing":"1","verse_layout_share":"1","verse_number_share":"1","local_link_share":"1","text_reference_share":"3","type_translation_share":"2","default_format_share":"1","verse_selected_color":"#4747ff","show_header":"1","verse_per_line":"1","show_top_menu":"1","top_menu_type":"1","show_bottom_menu":"0","bottom_menu_type":"1","previous_next_navigation":"1","set_custom_tabs":"0","custom_tabs":"div","set_default_tab_names":"0","custom_icons":"0","show_scripture_tab_text":"1","show_scripture_icon":"1","show_scripture_card":"1","scripture_card_style":"default","show_books_tab_text":"1","show_books_icon":"1","show_books_card":"1","books_card_style":"default","show_chapters_tab_text":"1","show_chapters_icon":"1","show_chapters_card":"1","chapters_card_style":"default","show_translations_tab_text":"1","show_translations_icon":"1","show_translations_card":"1","translations_card_style":"default","show_settings":"0","show_settings_tab_text":"1","show_settings_icon":"1","show_settings_card":"1","settings_card_style":"default","show_details":"1","show_details_tab_text":"1","show_details_icon":"1","show_details_card":"1","details_card_style":"default","bottom_app_position":"div","show_bottom_app_position_card":"1","bottom_app_position_card_style":"default","debug":"0","enable_open_ai":"0","openai_model":"gpt-4","openai_token":"secret","enable_open_ai_org":"0","openai_org_token":"secret","openai_max_tokens":"300","openai_temperature":"1","openai_top_p":"1","openai_n":"1","openai_presence_penalty":"0","openai_frequency_penalty":"0","bottom_ai_position":"div","show_bottom_ai_position_card":"1","bottom_ai_position_card_style":"default","check_in":"-1 day","save_history":"1","history_limit":"10","add_jquery_framework":"1","uikit_load":"1","uikit_min":""}' + ); + + + echo ''; + + // Add component to the action logs extensions table. + $this->setActionLogsExtensions(); + + // Add Linker to the action logs config table. + $this->setActionLogConfig( + // typeTitle + 'LINKER', + // typeAlias + 'com_getbible.linker', + // idHolder + 'id', + // titleHolder + 'name', + // tableName + '#__getbible_linker', + // textPrefix + 'COM_GETBIBLE' + ); + + // Add Note to the action logs config table. + $this->setActionLogConfig( + // typeTitle + 'NOTE', + // typeAlias + 'com_getbible.note', + // idHolder + 'id', + // titleHolder + 'book_nr', + // tableName + '#__getbible_note', + // textPrefix + 'COM_GETBIBLE' + ); + + // Add Tagged_verse to the action logs config table. + $this->setActionLogConfig( + // typeTitle + 'TAGGED_VERSE', + // typeAlias + 'com_getbible.tagged_verse', + // idHolder + 'id', + // titleHolder + 'book_nr', + // tableName + '#__getbible_tagged_verse', + // textPrefix + 'COM_GETBIBLE' + ); + + // Add Prompt to the action logs config table. + $this->setActionLogConfig( + // typeTitle + 'PROMPT', + // typeAlias + 'com_getbible.prompt', + // idHolder + 'id', + // titleHolder + 'name', + // tableName + '#__getbible_prompt', + // textPrefix + 'COM_GETBIBLE' + ); + + // Add Open_ai_response to the action logs config table. + $this->setActionLogConfig( + // typeTitle + 'OPEN_AI_RESPONSE', + // typeAlias + 'com_getbible.open_ai_response', + // idHolder + 'id', + // titleHolder + 'response_id', + // tableName + '#__getbible_open_ai_response', + // textPrefix + 'COM_GETBIBLE' + ); + + // Add Open_ai_message to the action logs config table. + $this->setActionLogConfig( + // typeTitle + 'OPEN_AI_MESSAGE', + // typeAlias + 'com_getbible.open_ai_message', + // idHolder + 'id', + // titleHolder + 'role', + // tableName + '#__getbible_open_ai_message', + // textPrefix + 'COM_GETBIBLE' + ); + + // Add Password to the action logs config table. + $this->setActionLogConfig( + // typeTitle + 'PASSWORD', + // typeAlias + 'com_getbible.password', + // idHolder + 'id', + // titleHolder + 'name', + // tableName + '#__getbible_password', + // textPrefix + 'COM_GETBIBLE' + ); + + // Add Tag to the action logs config table. + $this->setActionLogConfig( + // typeTitle + 'TAG', + // typeAlias + 'com_getbible.tag', + // idHolder + 'id', + // titleHolder + 'name', + // tableName + '#__getbible_tag', + // textPrefix + 'COM_GETBIBLE' + ); + + // Add Translation to the action logs config table. + $this->setActionLogConfig( + // typeTitle + 'TRANSLATION', + // typeAlias + 'com_getbible.translation', + // idHolder + 'id', + // titleHolder + 'translation', + // tableName + '#__getbible_translation', + // textPrefix + 'COM_GETBIBLE' + ); + + // Add Book to the action logs config table. + $this->setActionLogConfig( + // typeTitle + 'BOOK', + // typeAlias + 'com_getbible.book', + // idHolder + 'id', + // titleHolder + 'name', + // tableName + '#__getbible_book', + // textPrefix + 'COM_GETBIBLE' + ); + + // Add Chapter to the action logs config table. + $this->setActionLogConfig( + // typeTitle + 'CHAPTER', + // typeAlias + 'com_getbible.chapter', + // idHolder + 'id', + // titleHolder + 'name', + // tableName + '#__getbible_chapter', + // textPrefix + 'COM_GETBIBLE' + ); + + // Add Verse to the action logs config table. + $this->setActionLogConfig( + // typeTitle + 'VERSE', + // typeAlias + 'com_getbible.verse', + // idHolder + 'id', + // titleHolder + 'book_nr', + // tableName + '#__getbible_verse', + // textPrefix + 'COM_GETBIBLE' + ); + } + + // do any updates needed + if ($type === 'update') + { + + // Update Note Content Types. + $this->setContentType( + // typeTitle + 'Getbible Note', + // typeAlias + 'com_getbible.note', + // table + '{"special": {"dbtable": "#__getbible_note","key": "id","type": "NoteTable","prefix": "TrueChristianChurch\Component\Getbible\Administrator\Table"}}', + // rules + '', + // fieldMappings + '{"common": {"core_content_item_id": "id","core_title": "null","core_state": "published","core_alias": "null","core_created_time": "created","core_modified_time": "modified","core_body": "null","core_hits": "hits","core_publish_up": "null","core_publish_down": "null","core_access": "access","core_params": "params","core_featured": "null","core_metadata": "null","core_language": "null","core_images": "null","core_urls": "null","core_version": "version","core_ordering": "ordering","core_metakey": "null","core_metadesc": "null","core_catid": "null","core_xreference": "null","asset_id": "asset_id"},"special": {"book_nr":"book_nr","linker":"linker","guid":"guid","note":"note","verse":"verse","chapter":"chapter"}}', + // router + '', + // contentHistoryOptions + '{"formFile": "administrator/components/com_getbible/forms/note.xml","hideFields": ["asset_id","checked_out","checked_out_time","version"],"ignoreChanges": ["modified_by","modified","checked_out","checked_out_time","version","hits"],"convertToInt": ["published","ordering","book_nr","access","verse","chapter"],"displayLookup": [{"sourceColumn": "created_by","targetTable": "#__users","targetColumn": "id","displayColumn": "name"},{"sourceColumn": "access","targetTable": "#__viewlevels","targetColumn": "id","displayColumn": "title"},{"sourceColumn": "modified_by","targetTable": "#__users","targetColumn": "id","displayColumn": "name"},{"sourceColumn": "linker","targetTable": "#__getbible_linker","targetColumn": "guid","displayColumn": "name"}]}' + ); + // Update Tagged verse Content Types. + $this->setContentType( + // typeTitle + 'Getbible Tagged_verse', + // typeAlias + 'com_getbible.tagged_verse', + // table + '{"special": {"dbtable": "#__getbible_tagged_verse","key": "id","type": "Tagged_verseTable","prefix": "TrueChristianChurch\Component\Getbible\Administrator\Table"}}', + // rules + '', + // fieldMappings + '{"common": {"core_content_item_id": "id","core_title": "null","core_state": "published","core_alias": "null","core_created_time": "created","core_modified_time": "modified","core_body": "null","core_hits": "hits","core_publish_up": "null","core_publish_down": "null","core_access": "access","core_params": "params","core_featured": "null","core_metadata": "null","core_language": "null","core_images": "null","core_urls": "null","core_version": "version","core_ordering": "ordering","core_metakey": "null","core_metadesc": "null","core_catid": "null","core_xreference": "null","asset_id": "asset_id"},"special": {"book_nr":"book_nr","abbreviation":"abbreviation","linker":"linker","tag":"tag","guid":"guid","verse":"verse","chapter":"chapter"}}', + // router + '', + // contentHistoryOptions + '{"formFile": "administrator/components/com_getbible/forms/tagged_verse.xml","hideFields": ["asset_id","checked_out","checked_out_time","version"],"ignoreChanges": ["modified_by","modified","checked_out","checked_out_time","version","hits"],"convertToInt": ["published","ordering","book_nr","access","verse","chapter"],"displayLookup": [{"sourceColumn": "created_by","targetTable": "#__users","targetColumn": "id","displayColumn": "name"},{"sourceColumn": "access","targetTable": "#__viewlevels","targetColumn": "id","displayColumn": "title"},{"sourceColumn": "modified_by","targetTable": "#__users","targetColumn": "id","displayColumn": "name"},{"sourceColumn": "abbreviation","targetTable": "#__getbible_translation","targetColumn": "abbreviation","displayColumn": "translation"},{"sourceColumn": "linker","targetTable": "#__getbible_linker","targetColumn": "guid","displayColumn": "name"},{"sourceColumn": "tag","targetTable": "#__getbible_tag","targetColumn": "guid","displayColumn": "name"}]}' + ); + // Update Prompt Content Types. + $this->setContentType( + // typeTitle + 'Getbible Prompt', + // typeAlias + 'com_getbible.prompt', + // table + '{"special": {"dbtable": "#__getbible_prompt","key": "id","type": "PromptTable","prefix": "TrueChristianChurch\Component\Getbible\Administrator\Table"}}', + // rules + '', + // fieldMappings + '{"common": {"core_content_item_id": "id","core_title": "name","core_state": "published","core_alias": "null","core_created_time": "created","core_modified_time": "modified","core_body": "null","core_hits": "hits","core_publish_up": "null","core_publish_down": "null","core_access": "access","core_params": "params","core_featured": "null","core_metadata": "null","core_language": "null","core_images": "null","core_urls": "null","core_version": "version","core_ordering": "ordering","core_metakey": "null","core_metadesc": "null","core_catid": "null","core_xreference": "null","asset_id": "asset_id"},"special": {"name":"name","integration":"integration","cache_behaviour":"cache_behaviour","abbreviation":"abbreviation","guid":"guid","model":"model","presence_penalty":"presence_penalty","org_token":"org_token","token":"token","n_override":"n_override","cache_capacity":"cache_capacity","response_retrieval":"response_retrieval","frequency_penalty_override":"frequency_penalty_override","n":"n","max_tokens_override":"max_tokens_override","token_override":"token_override","max_tokens":"max_tokens","ai_org_token_override":"ai_org_token_override","temperature_override":"temperature_override","presence_penalty_override":"presence_penalty_override","top_p_override":"top_p_override","frequency_penalty":"frequency_penalty","top_p":"top_p","temperature":"temperature"}}', + // router + '', + // contentHistoryOptions + '{"formFile": "administrator/components/com_getbible/forms/prompt.xml","hideFields": ["asset_id","checked_out","checked_out_time","version"],"ignoreChanges": ["modified_by","modified","checked_out","checked_out_time","version","hits"],"convertToInt": ["published","ordering","integration","cache_behaviour","n_override","cache_capacity","response_retrieval","frequency_penalty_override","n","max_tokens_override","token_override","max_tokens","ai_org_token_override","temperature_override","presence_penalty_override","top_p_override"],"displayLookup": [{"sourceColumn": "created_by","targetTable": "#__users","targetColumn": "id","displayColumn": "name"},{"sourceColumn": "access","targetTable": "#__viewlevels","targetColumn": "id","displayColumn": "title"},{"sourceColumn": "modified_by","targetTable": "#__users","targetColumn": "id","displayColumn": "name"},{"sourceColumn": "abbreviation","targetTable": "#__getbible_translation","targetColumn": "abbreviation","displayColumn": "translation"}]}' + ); + // Update Open ai response Content Types. + $this->setContentType( + // typeTitle + 'Getbible Open_ai_response', + // typeAlias + 'com_getbible.open_ai_response', + // table + '{"special": {"dbtable": "#__getbible_open_ai_response","key": "id","type": "Open_ai_responseTable","prefix": "TrueChristianChurch\Component\Getbible\Administrator\Table"}}', + // rules + '', + // fieldMappings + '{"common": {"core_content_item_id": "id","core_title": "response_id","core_state": "published","core_alias": "null","core_created_time": "created","core_modified_time": "modified","core_body": "null","core_hits": "hits","core_publish_up": "null","core_publish_down": "null","core_access": "access","core_params": "params","core_featured": "null","core_metadata": "null","core_language": "null","core_images": "null","core_urls": "null","core_version": "version","core_ordering": "ordering","core_metakey": "null","core_metadesc": "null","core_catid": "null","core_xreference": "null","asset_id": "asset_id"},"special": {"response_id":"response_id","prompt":"prompt","response_object":"response_object","response_model":"response_model","total_tokens":"total_tokens","n":"n","frequency_penalty":"frequency_penalty","presence_penalty":"presence_penalty","word":"word","chapter":"chapter","lcsh":"lcsh","completion_tokens":"completion_tokens","prompt_tokens":"prompt_tokens","response_created":"response_created","abbreviation":"abbreviation","language":"language","max_tokens":"max_tokens","book":"book","temperature":"temperature","verse":"verse","top_p":"top_p","selected_word":"selected_word","model":"model"}}', + // router + '', + // contentHistoryOptions + '{"formFile": "administrator/components/com_getbible/forms/open_ai_response.xml","hideFields": ["asset_id","checked_out","checked_out_time","version"],"ignoreChanges": ["modified_by","modified","checked_out","checked_out_time","version","hits"],"convertToInt": ["published","ordering","total_tokens","n","chapter","completion_tokens","prompt_tokens","max_tokens","book"],"displayLookup": [{"sourceColumn": "created_by","targetTable": "#__users","targetColumn": "id","displayColumn": "name"},{"sourceColumn": "access","targetTable": "#__viewlevels","targetColumn": "id","displayColumn": "title"},{"sourceColumn": "modified_by","targetTable": "#__users","targetColumn": "id","displayColumn": "name"},{"sourceColumn": "prompt","targetTable": "#__getbible_prompt","targetColumn": "guid","displayColumn": "name"},{"sourceColumn": "abbreviation","targetTable": "#__getbible_translation","targetColumn": "abbreviation","displayColumn": "translation"}]}' + ); + // Update Open ai message Content Types. + $this->setContentType( + // typeTitle + 'Getbible Open_ai_message', + // typeAlias + 'com_getbible.open_ai_message', + // table + '{"special": {"dbtable": "#__getbible_open_ai_message","key": "id","type": "Open_ai_messageTable","prefix": "TrueChristianChurch\Component\Getbible\Administrator\Table"}}', + // rules + '', + // fieldMappings + '{"common": {"core_content_item_id": "id","core_title": "role","core_state": "published","core_alias": "null","core_created_time": "created","core_modified_time": "modified","core_body": "null","core_hits": "hits","core_publish_up": "null","core_publish_down": "null","core_access": "access","core_params": "params","core_featured": "null","core_metadata": "null","core_language": "null","core_images": "null","core_urls": "null","core_version": "version","core_ordering": "ordering","core_metakey": "null","core_metadesc": "null","core_catid": "null","core_xreference": "null","asset_id": "asset_id"},"special": {"role":"role","open_ai_response":"open_ai_response","prompt":"prompt","source":"source","content":"content","name":"name","index":"index"}}', + // router + '', + // contentHistoryOptions + '{"formFile": "administrator/components/com_getbible/forms/open_ai_message.xml","hideFields": ["asset_id","checked_out","checked_out_time","version"],"ignoreChanges": ["modified_by","modified","checked_out","checked_out_time","version","hits"],"convertToInt": ["published","ordering","source","index"],"displayLookup": [{"sourceColumn": "created_by","targetTable": "#__users","targetColumn": "id","displayColumn": "name"},{"sourceColumn": "access","targetTable": "#__viewlevels","targetColumn": "id","displayColumn": "title"},{"sourceColumn": "modified_by","targetTable": "#__users","targetColumn": "id","displayColumn": "name"},{"sourceColumn": "open_ai_response","targetTable": "#__getbible_open_ai_response","targetColumn": "response_id","displayColumn": "response_id"},{"sourceColumn": "prompt","targetTable": "#__getbible_prompt","targetColumn": "guid","displayColumn": "name"}]}' + ); + // Update Tag Content Types. + $this->setContentType( + // typeTitle + 'Getbible Tag', + // typeAlias + 'com_getbible.tag', + // table + '{"special": {"dbtable": "#__getbible_tag","key": "id","type": "TagTable","prefix": "TrueChristianChurch\Component\Getbible\Administrator\Table"}}', + // rules + '', + // fieldMappings + '{"common": {"core_content_item_id": "id","core_title": "name","core_state": "published","core_alias": "null","core_created_time": "created","core_modified_time": "modified","core_body": "null","core_hits": "hits","core_publish_up": "null","core_publish_down": "null","core_access": "access","core_params": "params","core_featured": "null","core_metadata": "null","core_language": "null","core_images": "null","core_urls": "null","core_version": "version","core_ordering": "ordering","core_metakey": "null","core_metadesc": "null","core_catid": "null","core_xreference": "null","asset_id": "asset_id"},"special": {"name":"name","linker":"linker","guid":"guid","description":"description"}}', + // router + '', + // contentHistoryOptions + '{"formFile": "administrator/components/com_getbible/forms/tag.xml","hideFields": ["asset_id","checked_out","checked_out_time","version"],"ignoreChanges": ["modified_by","modified","checked_out","checked_out_time","version","hits"],"convertToInt": ["published","ordering","access"],"displayLookup": [{"sourceColumn": "created_by","targetTable": "#__users","targetColumn": "id","displayColumn": "name"},{"sourceColumn": "access","targetTable": "#__viewlevels","targetColumn": "id","displayColumn": "title"},{"sourceColumn": "modified_by","targetTable": "#__users","targetColumn": "id","displayColumn": "name"},{"sourceColumn": "linker","targetTable": "#__getbible_linker","targetColumn": "guid","displayColumn": "name"}]}' + ); + + + + echo '
+ + +

Upgrade to Version 5.0.0 Was Successful! Let us know if anything is not working as expected.

'; + + // Add/Update component in the action logs extensions table. + $this->setActionLogsExtensions(); + + // Add/Update Linker in the action logs config table. + $this->setActionLogConfig( + // typeTitle + 'LINKER', + // typeAlias + 'com_getbible.linker', + // idHolder + 'id', + // titleHolder + 'name', + // tableName + '#__getbible_linker', + // textPrefix + 'COM_GETBIBLE' + ); + + // Add/Update Note in the action logs config table. + $this->setActionLogConfig( + // typeTitle + 'NOTE', + // typeAlias + 'com_getbible.note', + // idHolder + 'id', + // titleHolder + 'book_nr', + // tableName + '#__getbible_note', + // textPrefix + 'COM_GETBIBLE' + ); + + // Add/Update Tagged_verse in the action logs config table. + $this->setActionLogConfig( + // typeTitle + 'TAGGED_VERSE', + // typeAlias + 'com_getbible.tagged_verse', + // idHolder + 'id', + // titleHolder + 'book_nr', + // tableName + '#__getbible_tagged_verse', + // textPrefix + 'COM_GETBIBLE' + ); + + // Add/Update Prompt in the action logs config table. + $this->setActionLogConfig( + // typeTitle + 'PROMPT', + // typeAlias + 'com_getbible.prompt', + // idHolder + 'id', + // titleHolder + 'name', + // tableName + '#__getbible_prompt', + // textPrefix + 'COM_GETBIBLE' + ); + + // Add/Update Open_ai_response in the action logs config table. + $this->setActionLogConfig( + // typeTitle + 'OPEN_AI_RESPONSE', + // typeAlias + 'com_getbible.open_ai_response', + // idHolder + 'id', + // titleHolder + 'response_id', + // tableName + '#__getbible_open_ai_response', + // textPrefix + 'COM_GETBIBLE' + ); + + // Add/Update Open_ai_message in the action logs config table. + $this->setActionLogConfig( + // typeTitle + 'OPEN_AI_MESSAGE', + // typeAlias + 'com_getbible.open_ai_message', + // idHolder + 'id', + // titleHolder + 'role', + // tableName + '#__getbible_open_ai_message', + // textPrefix + 'COM_GETBIBLE' + ); + + // Add/Update Password in the action logs config table. + $this->setActionLogConfig( + // typeTitle + 'PASSWORD', + // typeAlias + 'com_getbible.password', + // idHolder + 'id', + // titleHolder + 'name', + // tableName + '#__getbible_password', + // textPrefix + 'COM_GETBIBLE' + ); + + // Add/Update Tag in the action logs config table. + $this->setActionLogConfig( + // typeTitle + 'TAG', + // typeAlias + 'com_getbible.tag', + // idHolder + 'id', + // titleHolder + 'name', + // tableName + '#__getbible_tag', + // textPrefix + 'COM_GETBIBLE' + ); + + // Add/Update Translation in the action logs config table. + $this->setActionLogConfig( + // typeTitle + 'TRANSLATION', + // typeAlias + 'com_getbible.translation', + // idHolder + 'id', + // titleHolder + 'translation', + // tableName + '#__getbible_translation', + // textPrefix + 'COM_GETBIBLE' + ); + + // Add/Update Book in the action logs config table. + $this->setActionLogConfig( + // typeTitle + 'BOOK', + // typeAlias + 'com_getbible.book', + // idHolder + 'id', + // titleHolder + 'name', + // tableName + '#__getbible_book', + // textPrefix + 'COM_GETBIBLE' + ); + + // Add/Update Chapter in the action logs config table. + $this->setActionLogConfig( + // typeTitle + 'CHAPTER', + // typeAlias + 'com_getbible.chapter', + // idHolder + 'id', + // titleHolder + 'name', + // tableName + '#__getbible_chapter', + // textPrefix + 'COM_GETBIBLE' + ); + + // Add/Update Verse in the action logs config table. + $this->setActionLogConfig( + // typeTitle + 'VERSE', + // typeAlias + 'com_getbible.verse', + // idHolder + 'id', + // titleHolder + 'book_nr', + // tableName + '#__getbible_verse', + // textPrefix + 'COM_GETBIBLE' + ); + } + + // move CLI files + $this->moveCliFiles(); + + // remove old files and folders + $this->removeFiles(); + + return true; + } + + /** + * Remove the files and folders in the given array from + * + * @return void + * + * @since 3.6 + */ + protected function removeFiles() + { + if (!empty($this->deleteFiles)) + { + foreach ($this->deleteFiles as $file) + { + if (is_file(JPATH_ROOT . $file) && !File::delete(JPATH_ROOT . $file)) + { + echo Text::sprintf('JLIB_INSTALLER_ERROR_FILE_FOLDER', $file) . '
'; + } + } + } + + if (!empty($this->deleteFolders)) + { + foreach ($this->deleteFolders as $folder) + { + if (is_dir(JPATH_ROOT . $folder) && !Folder::delete(JPATH_ROOT . $folder)) + { + echo Text::sprintf('JLIB_INSTALLER_ERROR_FILE_FOLDER', $folder) . '
'; + } + } + } + } + + /** + * Moves the CLI scripts into the CLI folder in the CMS + * + * @return void + * + * @since 3.6 + */ + protected function moveCliFiles() + { + if (!empty($this->cliScriptFiles)) + { + foreach ($this->cliScriptFiles as $file) + { + $name = basename($file); + + if (file_exists(JPATH_ROOT . $file) && !File::move(JPATH_ROOT . $file, JPATH_ROOT . '/cli/' . $name)) + { + echo Text::sprintf('JLIB_INSTALLER_FILE_ERROR_MOVE', $name); + } + } + } + } + + /** + * Set content type integration + * + * @param string $typeTitle + * @param string $typeAlias + * @param string $table + * @param string $rules + * @param string $fieldMappings + * @param string $router + * @param string $contentHistoryOptions + * + * @return void + * @since 4.4.2 + */ + protected function setContentType( + string $typeTitle, + string $typeAlias, + string $table, + string $rules, + string $fieldMappings, + string $router, + string $contentHistoryOptions): void + { + // Create the content type object. + $content = new stdClass(); + $content->type_title = $typeTitle; + $content->type_alias = $typeAlias; + $content->table = $table; + $content->rules = $rules; + $content->field_mappings = $fieldMappings; + $content->router = $router; + $content->content_history_options = $contentHistoryOptions; + + // Check if content type is already in content_type DB. + $query = $this->db->getQuery(true); + $query->select($this->db->quoteName(array('type_id'))); + $query->from($this->db->quoteName('#__content_types')); + $query->where($this->db->quoteName('type_alias') . ' LIKE '. $this->db->quote($content->type_alias)); + + $this->db->setQuery($query); + $this->db->execute(); + + // Check if the type alias is already in the content types table. + if ($this->db->getNumRows()) + { + $content->type_id = $this->db->loadResult(); + if ($this->db->updateObject('#__content_types', $content, 'type_id')) + { + // If its successfully update. + $this->app->enqueueMessage( + Text::sprintf('The (%s) was found in the #__content_types table, and updated.', $content->type_alias) + ); + } + } + elseif ($this->db->insertObject('#__content_types', $content)) + { + // If its successfully added. + $this->app->enqueueMessage( + Text::sprintf('The (%s) was added to the #__content_types table.', $content->type_alias) + ); + } + } + + /** + * Set action log config integration + * + * @param string $typeTitle + * @param string $typeAlias + * @param string $idHolder + * @param string $titleHolder + * @param string $tableName + * @param string $textPrefix + * + * @return void + * @since 4.4.2 + */ + protected function setActionLogConfig( + string $typeTitle, + string $typeAlias, + string $idHolder, + string $titleHolder, + string $tableName, + string $textPrefix): void + { + // Create the content action log config object. + $content = new stdClass(); + $content->type_title = $typeTitle; + $content->type_alias = $typeAlias; + $content->id_holder = $idHolder; + $content->title_holder = $titleHolder; + $content->table_name = $tableName; + $content->text_prefix = $textPrefix; + + // Check if the action log config is already in action_log_config DB. + $query = $this->db->getQuery(true); + $query->select($this->db->quoteName(['id'])); + $query->from($this->db->quoteName('#__action_log_config')); + $query->where($this->db->quoteName('type_alias') . ' LIKE '. $this->db->quote($content->type_alias)); + + $this->db->setQuery($query); + $this->db->execute(); + + // Check if the type alias is already in the action log config table. + if ($this->db->getNumRows()) + { + $content->id = $this->db->loadResult(); + if ($this->db->updateObject('#__action_log_config', $content, 'id')) + { + // If its successfully update. + $this->app->enqueueMessage( + Text::sprintf('The (%s) was found in the #__action_log_config table, and updated.', $content->type_alias) + ); + } + } + elseif ($this->db->insertObject('#__action_log_config', $content)) + { + // If its successfully added. + $this->app->enqueueMessage( + Text::sprintf('The (%s) was added to the #__action_log_config table.', $content->type_alias) + ); + } + } + + /** + * Set action logs extensions integration + * + * @return void + * @since 4.4.2 + */ + protected function setActionLogsExtensions(): void + { + // Create the extension action logs object. + $data = new stdClass(); + $data->extension = 'com_getbible'; + + // Check if getbible action log extension is already in action logs extensions DB. + $query = $this->db->getQuery(true); + $query->select($this->db->quoteName(['id'])); + $query->from($this->db->quoteName('#__action_logs_extensions')); + $query->where($this->db->quoteName('extension') . ' = '. $this->db->quote($data->extension)); + + $this->db->setQuery($query); + $this->db->execute(); + + // Set the object into the action logs extensions table if not found. + if ($this->db->getNumRows()) + { + // If its already set don't set it again. + $this->app->enqueueMessage( + Text::_('The (com_getbible) is already in the #__action_logs_extensions table.') + ); + } + elseif ($this->db->insertObject('#__action_logs_extensions', $data)) + { + // give a success message + $this->app->enqueueMessage( + Text::_('The (com_getbible) was successfully added to the #__action_logs_extensions table.') + ); + } + } + + /** + * Set global extension assets permission of this component + * (on install only) + * + * @param string $rules The component rules + * + * @return void + * @since 4.4.2 + */ + protected function setAssetsRules(string $rules): void + { + // Condition. + $conditions = [ + $this->db->quoteName('name') . ' = ' . $this->db->quote('com_getbible') + ]; + + // Field to update. + $fields = [ + $this->db->quoteName('rules') . ' = ' . $this->db->quote($rules), + ]; + + $query = $this->db->getQuery(true); + $query->update( + $this->db->quoteName('#__assets') + )->set($fields)->where($conditions); + + $this->db->setQuery($query); + + $done = $this->db->execute(); + if ($done) + { + // give a success message + $this->app->enqueueMessage( + Text::_('The (com_getbible) rules was successfully added to the #__assets table.') + ); + } + } + + /** + * Set global extension params of this component + * (on install only) + * + * @param string $params The component rules + * + * @return void + * @since 4.4.2 + */ + protected function setExtensionsParams(string $params): void + { + // Condition. + $conditions = [ + $this->db->quoteName('element') . ' = ' . $this->db->quote('com_getbible') + ]; + + // Field to update. + $fields = [ + $this->db->quoteName('params') . ' = ' . $this->db->quote($params), + ]; + + $query = $this->db->getQuery(true); + $query->update( + $this->db->quoteName('#__extensions') + )->set($fields)->where($conditions); + + $this->db->setQuery($query); + + $done = $this->db->execute(); + if ($done) + { + // give a success message + $this->app->enqueueMessage( + Text::_('The (com_getbible) params was successfully added to the #__extensions table.') + ); + } + } + + /** + * Set database fix (if needed) + * => WHY DO WE NEED AN ASSET TABLE FIX? + * https://git.vdm.dev/joomla/Component-Builder/issues/616#issuecomment-12085 + * https://www.mysqltutorial.org/mysql-varchar/ + * https://stackoverflow.com/a/15227917/1429677 + * https://forums.mysql.com/read.php?24,105964,105964 + * + * @param int $accessWorseCase This is the max rules column size com_getbible would needs. + * @param string $dataType This datatype we will change the rules column to if it to small. + * + * @return void + * @since 4.4.2 + */ + protected function setDatabaseAssetsRulesFix(int $accessWorseCase, string $dataType): void + { + // Get the biggest rule column in the assets table at this point. + $length = "SELECT CHAR_LENGTH(`rules`) as rule_size FROM #__assets ORDER BY rule_size DESC LIMIT 1"; + $this->db->setQuery($length); + if ($this->db->execute()) + { + $rule_length = $this->db->loadResult(); + // Check the size of the rules column + if ($rule_length <= $accessWorseCase) + { + // Fix the assets table rules column size + $fix = "ALTER TABLE `#__assets` CHANGE `rules` `rules` {$dataType} NOT NULL COMMENT 'JSON encoded access control. Enlarged to {$dataType} by Getbible';"; + $this->db->setQuery($fix); + + $done = $this->db->execute(); + if ($done) + { + $this->app->enqueueMessage( + Text::sprintf('The #__assets table rules column was resized to the %s datatype for the components possible large permission rules.', $dataType) + ); + } + } + } + } + + /** + * Remove remnant data related to this view + * + * @param string $context The view context + * @param bool $fields The switch to also remove related field data + * + * @return void + * @since 4.4.2 + */ + protected function removeViewData(string $context, bool $fields = false): void + { + $this->removeContentTypes($context); + $this->removeViewHistory($context); + $this->removeUcmContent($context); // this might be obsolete... + $this->removeContentItemTagMap($context); + $this->removeActionLogConfig($context); + + if ($fields) + { + $this->removeFields($context); + $this->removeFieldsGroups($context); + } + } + + /** + * Remove content types related to this view + * + * @param string $context The view context + * + * @return void + * @since 4.4.2 + */ + protected function removeContentTypes(string $context): void + { + // Create a new query object. + $query = $this->db->getQuery(true); + + // Select id from content type table + $query->select($this->db->quoteName('type_id')); + $query->from($this->db->quoteName('#__content_types')); + + // Where Item alias is found + $query->where($this->db->quoteName('type_alias') . ' = '. $this->db->quote($context)); + $this->db->setQuery($query); + + // Execute query to see if alias is found + $this->db->execute(); + $found = $this->db->getNumRows(); + + // Now check if there were any rows + if ($found) + { + // Since there are load the needed item type ids + $ids = $this->db->loadColumn(); + + // Remove Item from the content type table + $condition = [ + $this->db->quoteName('type_alias') . ' = '. $this->db->quote($context) + ]; + + // Create a new query object. + $query = $this->db->getQuery(true); + $query->delete($this->db->quoteName('#__content_types')); + $query->where($condition); + $this->db->setQuery($query); + + // Execute the query to remove Item items + $done = $this->db->execute(); + if ($done) + { + // If successfully remove Item add queued success message. + $this->app->enqueueMessage( + Text::sprintf('The (%s) type alias was removed from the #__content_type table.', $context) + ); + } + + // Make sure that all the items are cleared from DB + $this->removeUcmBase($ids); + } + } + + /** + * Remove fields related to this view + * + * @param string $context The view context + * + * @return void + * @since 4.4.2 + */ + protected function removeFields(string $context): void + { + // Create a new query object. + $query = $this->db->getQuery(true); + + // Select ids from fields + $query->select($this->db->quoteName('id')); + $query->from($this->db->quoteName('#__fields')); + + // Where context is found + $query->where( + $this->db->quoteName('context') . ' = '. $this->db->quote($context) + ); + $this->db->setQuery($query); + + // Execute query to see if context is found + $this->db->execute(); + $found = $this->db->getNumRows(); + + // Now check if there were any rows + if ($found) + { + // Since there are load the needed release_check field ids + $ids = $this->db->loadColumn(); + + // Create a new query object. + $query = $this->db->getQuery(true); + + // Remove context from the field table + $condition = [ + $this->db->quoteName('context') . ' = '. $this->db->quote($context) + ]; + + $query->delete($this->db->quoteName('#__fields')); + $query->where($condition); + + $this->db->setQuery($query); + + // Execute the query to remove release_check items + $done = $this->db->execute(); + if ($done) + { + // If successfully remove context add queued success message. + $this->app->enqueueMessage( + Text::sprintf('The fields with context (%s) was removed from the #__fields table.', $context) + ); + } + + // Make sure that all the field values are cleared from DB + $this->removeFieldsValues($context, $ids); + } + } + + /** + * Remove fields values related to fields + * + * @param string $context The view context + * @param array $ids The view context + * + * @return void + * @since 4.4.2 + */ + protected function removeFieldsValues(string $context, array $ids): void + { + $condition = [ + $this->db->quoteName('field_id') . ' IN ('. implode(',', $ids) .')' + ]; + + // Create a new query object. + $query = $this->db->getQuery(true); + $query->delete($this->db->quoteName('#__fields_values')); + $query->where($condition); + $this->db->setQuery($query); + + // Execute the query to remove field values + $done = $this->db->execute(); + if ($done) + { + // If successfully remove release_check add queued success message. + $this->app->enqueueMessage( + Text::sprintf('The fields values for (%s) was removed from the #__fields_values table.', $context) + ); + } + } + + /** + * Remove fields groups related to fields + * + * @param string $context The view context + * + * @return void + * @since 4.4.2 + */ + protected function removeFieldsGroups(string $context): void + { + // Create a new query object. + $query = $this->db->getQuery(true); + + // Select ids from fields + $query->select($this->db->quoteName('id')); + $query->from($this->db->quoteName('#__fields_groups')); + + // Where context is found + $query->where( + $this->db->quoteName('context') . ' = '. $this->db->quote($context) + ); + $this->db->setQuery($query); + + // Execute query to see if context is found + $this->db->execute(); + $found = $this->db->getNumRows(); + + // Now check if there were any rows + if ($found) + { + // Create a new query object. + $query = $this->db->getQuery(true); + + // Remove context from the field table + $condition = [ + $this->db->quoteName('context') . ' = '. $this->db->quote($context) + ]; + + $query->delete($this->db->quoteName('#__fields_groups')); + $query->where($condition); + + $this->db->setQuery($query); + + // Execute the query to remove release_check items + $done = $this->db->execute(); + if ($done) + { + // If successfully remove context add queued success message. + $this->app->enqueueMessage( + Text::sprintf('The fields with context (%s) was removed from the #__fields_groups table.', $context) + ); + } + } + } + + /** + * Remove history related to this view + * + * @param string $context The view context + * + * @return void + * @since 4.4.2 + */ + protected function removeViewHistory(string $context): void + { + // Remove Item items from the ucm content table + $condition = [ + $this->db->quoteName('item_id') . ' LIKE ' . $this->db->quote($context . '.%') + ]; + + // Create a new query object. + $query = $this->db->getQuery(true); + $query->delete($this->db->quoteName('#__history')); + $query->where($condition); + $this->db->setQuery($query); + + // Execute the query to remove Item items + $done = $this->db->execute(); + if ($done) + { + // If successfully removed Items add queued success message. + $this->app->enqueueMessage( + Text::sprintf('The (%s) items were removed from the #__history table.', $context) + ); + } + } + + /** + * Remove ucm base values related to these IDs + * + * @param array $ids The type ids + * + * @return void + * @since 4.4.2 + */ + protected function removeUcmBase(array $ids): void + { + // Make sure that all the items are cleared from DB + foreach ($ids as $type_id) + { + // Remove Item items from the ucm base table + $condition = [ + $this->db->quoteName('ucm_type_id') . ' = ' . $type_id + ]; + + // Create a new query object. + $query = $this->db->getQuery(true); + $query->delete($this->db->quoteName('#__ucm_base')); + $query->where($condition); + $this->db->setQuery($query); + + // Execute the query to remove Item items + $this->db->execute(); + } + + $this->app->enqueueMessage( + Text::_('All related items was removed from the #__ucm_base table.') + ); + } + + /** + * Remove ucm content values related to this view + * + * @param string $context The view context + * + * @return void + * @since 4.4.2 + */ + protected function removeUcmContent(string $context): void + { + // Remove Item items from the ucm content table + $condition = [ + $this->db->quoteName('core_type_alias') . ' = ' . $this->db->quote($context) + ]; + + // Create a new query object. + $query = $this->db->getQuery(true); + $query->delete($this->db->quoteName('#__ucm_content')); + $query->where($condition); + $this->db->setQuery($query); + + // Execute the query to remove Item items + $done = $this->db->execute(); + if ($done) + { + // If successfully removed Item add queued success message. + $this->app->enqueueMessage( + Text::sprintf('The (%s) type alias was removed from the #__ucm_content table.', $context) + ); + } + } + + /** + * Remove content item tag map related to this view + * + * @param string $context The view context + * + * @return void + * @since 4.4.2 + */ + protected function removeContentItemTagMap(string $context): void + { + // Create a new query object. + $query = $this->db->getQuery(true); + + // Remove Item items from the contentitem tag map table + $condition = [ + $this->db->quoteName('type_alias') . ' = '. $this->db->quote($context) + ]; + + // Create a new query object. + $query = $this->db->getQuery(true); + $query->delete($this->db->quoteName('#__contentitem_tag_map')); + $query->where($condition); + $this->db->setQuery($query); + + // Execute the query to remove Item items + $done = $this->db->execute(); + if ($done) + { + // If successfully remove Item add queued success message. + $this->app->enqueueMessage( + Text::sprintf('The (%s) type alias was removed from the #__contentitem_tag_map table.', $context) + ); + } + } + + /** + * Remove action log config related to this view + * + * @param string $context The view context + * + * @return void + * @since 4.4.2 + */ + protected function removeActionLogConfig(string $context): void + { + // Remove getbible view from the action_log_config table + $condition = [ + $this->db->quoteName('type_alias') . ' = '. $this->db->quote($context) + ]; + + // Create a new query object. + $query = $this->db->getQuery(true); + $query->delete($this->db->quoteName('#__action_log_config')); + $query->where($condition); + $this->db->setQuery($query); + + // Execute the query to remove com_getbible.view + $done = $this->db->execute(); + if ($done) + { + // If successfully removed getbible view add queued success message. + $this->app->enqueueMessage( + Text::sprintf('The (%s) type alias was removed from the #__action_log_config table.', $context) + ); + } + } + + /** + * Remove Asset Table Integrated + * + * @return void + * @since 4.4.2 + */ + protected function removeAssetData(): void + { + // Remove getbible assets from the assets table + $condition = [ + $this->db->quoteName('name') . ' LIKE ' . $this->db->quote('com_getbible.%') + ]; + + // Create a new query object. + $query = $this->db->getQuery(true); + $query->delete($this->db->quoteName('#__assets')); + $query->where($condition); + $this->db->setQuery($query); + $done = $this->db->execute(); + if ($done) + { + // If successfully removed getbible add queued success message. + $this->app->enqueueMessage( + Text::_('All related (com_getbible) items was removed from the #__assets table.') + ); + } + } + + /** + * Remove action logs extensions integrated + * + * @return void + * @since 4.4.2 + */ + protected function removeActionLogsExtensions(): void + { + // Remove getbible from the action_logs_extensions table + $extension = [ + $this->db->quoteName('extension') . ' = ' . $this->db->quote('com_getbible') + ]; + + // Create a new query object. + $query = $this->db->getQuery(true); + $query->delete($this->db->quoteName('#__action_logs_extensions')); + $query->where($extension); + $this->db->setQuery($query); + + // Execute the query to remove getbible + $done = $this->db->execute(); + if ($done) + { + // If successfully remove getbible add queued success message. + $this->app->enqueueMessage( + Text::_('The (com_getbible) extension was removed from the #__action_logs_extensions table.') + ); + } + } + + /** + * Remove remove database fix (if possible) + * + * @return void + * @since 4.4.2 + */ + protected function removeDatabaseAssetsRulesFix(): void + { + // Get the biggest rule column in the assets table at this point. + $length = "SELECT CHAR_LENGTH(`rules`) as rule_size FROM #__assets ORDER BY rule_size DESC LIMIT 1"; + $this->db->setQuery($length); + if ($this->db->execute()) + { + $rule_length = $this->db->loadResult(); + // Check the size of the rules column + if ($rule_length < 5120) + { + // Revert the assets table rules column back to the default + $revert_rule = "ALTER TABLE `#__assets` CHANGE `rules` `rules` varchar(5120) NOT NULL COMMENT 'JSON encoded access control.';"; + $this->db->setQuery($revert_rule); + $this->db->execute(); + + $this->app->enqueueMessage( + Text::_('Reverted the #__assets table rules column back to its default size of varchar(5120).') + ); + } + else + { + $this->app->enqueueMessage( + Text::_('Could not revert the #__assets table rules column back to its default size of varchar(5120), since there is still one or more components that still requires the column to be larger.') + ); + } + } + } + + /** + * Method to move folders into place. + * + * @param InstallerAdapter $adapter The adapter calling this method + * + * @return void + * @since 4.4.2 + */ + protected function moveFolders(InstallerAdapter $adapter): void + { + // get the installation path + $installer = $adapter->getParent(); + $installPath = $installer->getPath('source'); + // get all the folders + $folders = Folder::folders($installPath); + // check if we have folders we may want to copy + $doNotCopy = ['media','admin','site']; // Joomla already deals with these + if (count((array) $folders) > 1) + { + foreach ($folders as $folder) + { + // Only copy if not a standard folders + if (!in_array($folder, $doNotCopy)) + { + // set the source path + $src = $installPath.'/'.$folder; + // set the destination path + $dest = JPATH_ROOT.'/'.$folder; + // now try to copy the folder + if (!Folder::copy($src, $dest, '', true)) + { + $this->app->enqueueMessage('Could not copy '.$folder.' folder into place, please make sure destination is writable!', 'error'); + } + } + } + } + } +} diff --git a/README.md b/README.md index fe53dff..fa698d5 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ -# Get Bible (2.1.0) +# Get Bible (5.0.0) - ![Get Bible image](https://git.vdm.dev/getBible/joomla-component/raw/branch/master/admin/assets/images/vdm-component.jpg "GetBible") + ![Get Bible image](https://git.vdm.dev/getBible/joomla-component/raw/branch/5.0/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. @@ -18,38 +18,38 @@ In essence, The Bible for Joomla is designed to transform how the Word of God is + *Author*: [Llewellyn van der Merwe](mailto:joomla@vdm.io) + *Name*: [Get Bible](https://getbible.net) + *First Build*: 3rd December, 2015 -+ *Last Build*: 23rd December, 2023 -+ *Version*: 2.1.0 ++ *Last Build*: 23rd January, 2024 ++ *Version*: 5.0.0 + *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 -**566 Hours** or **71 Eight Hour Days** (actual time the author saved - +**558 Hours** or **70 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*: **202968** -+ *File count*: **1745** -+ *Folder count*: **167** ++ *Line count*: **199899** ++ *File count*: **1710** ++ *Folder count*: **176** -**374 Hours** or **47 Eight Hour Days** (the actual time the author spent) +**368 Hours** or **46 Eight Hour Days** (the actual time the author spent) > (with the following break down: -> **debugging @142hours** = codingtime / 4; -> **planning @81hours** = codingtime / 7; -> **mapping @57hours** = codingtime / 10; -> **office @94hours** = codingtime / 6;) +> **debugging @139hours** = codingtime / 4; +> **planning @80hours** = codingtime / 7; +> **mapping @56hours** = codingtime / 10; +> **office @93hours** = codingtime / 6;) -**940 Hours** or **118 Eight Hour Days** +**926 Hours** or **116 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: **23.6 weeks** or **4.9 months** +Project duration: **23.2 weeks** or **4.8 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) diff --git a/admin/README.txt b/admin/README.txt index fe53dff..fa698d5 100644 --- a/admin/README.txt +++ b/admin/README.txt @@ -1,6 +1,6 @@ -# Get Bible (2.1.0) +# Get Bible (5.0.0) - ![Get Bible image](https://git.vdm.dev/getBible/joomla-component/raw/branch/master/admin/assets/images/vdm-component.jpg "GetBible") + ![Get Bible image](https://git.vdm.dev/getBible/joomla-component/raw/branch/5.0/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. @@ -18,38 +18,38 @@ In essence, The Bible for Joomla is designed to transform how the Word of God is + *Author*: [Llewellyn van der Merwe](mailto:joomla@vdm.io) + *Name*: [Get Bible](https://getbible.net) + *First Build*: 3rd December, 2015 -+ *Last Build*: 23rd December, 2023 -+ *Version*: 2.1.0 ++ *Last Build*: 23rd January, 2024 ++ *Version*: 5.0.0 + *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 -**566 Hours** or **71 Eight Hour Days** (actual time the author saved - +**558 Hours** or **70 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*: **202968** -+ *File count*: **1745** -+ *Folder count*: **167** ++ *Line count*: **199899** ++ *File count*: **1710** ++ *Folder count*: **176** -**374 Hours** or **47 Eight Hour Days** (the actual time the author spent) +**368 Hours** or **46 Eight Hour Days** (the actual time the author spent) > (with the following break down: -> **debugging @142hours** = codingtime / 4; -> **planning @81hours** = codingtime / 7; -> **mapping @57hours** = codingtime / 10; -> **office @94hours** = codingtime / 6;) +> **debugging @139hours** = codingtime / 4; +> **planning @80hours** = codingtime / 7; +> **mapping @56hours** = codingtime / 10; +> **office @93hours** = codingtime / 6;) -**940 Hours** or **118 Eight Hour Days** +**926 Hours** or **116 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: **23.6 weeks** or **4.9 months** +Project duration: **23.2 weeks** or **4.8 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) diff --git a/admin/assets/css/dashboard.css b/admin/assets/css/dashboard.css index 10742d8..169d221 100644 --- a/admin/assets/css/dashboard.css +++ b/admin/assets/css/dashboard.css @@ -17,153 +17,153 @@ /* CSS Document */ .dashboard-container { - margin-left: 10px; - margin-top: 10px; - width: 100%; + margin-left: 10px; + margin-top: 10px; + width: 100%; } .dashboard-container [class*="span"] { - display: block; - float: none; - margin-left: 0; - width: auto; + display: block; + float: none; + margin-left: 0; + width: auto; } .dashboard-container:before, .dashboard-container:after { - content: ""; - display: table; + content: ""; + display: table; } .dashboard-container:after { - clear: both; + clear: both; } .dashboard-container [class*="span"] { - box-sizing: border-box; - display: block; - float: left; - min-height: 145px; - min-width: 96px; - width: 100%; + 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; + 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; + 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; + 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; + 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; + 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; + 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; + display: block; + text-align: center; } .dashboard-info img { - margin: 0 auto; + margin: 0 auto; } .dashboard-table { - border-top: 1px solid hsl(0, 0%, 87%); - margin-top: 5px; - width: 100%; + border-top: 1px solid hsl(0, 0%, 87%); + margin-top: 5px; + width: 100%; } .dashboard-info h5 { - font-size: 11px; - font-weight: bold; + 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; + 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; + 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; + 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; + 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; + 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; + margin-top: 0 !important; } .dashboard-block .dashboard-block-content .dashboard-block-box .dashboard-block-table { - margin-bottom: 0 !important; + 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%; + 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; + 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; + 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/images/import.gif b/admin/assets/images/import.gif index 4371cc618bdc1702aad69fc871a50182a01537ec..10bcb856924dbc48ac739332a40ce1617c88687b 100644 GIT binary patch delta 4162 zcmeHKYgm&<7S5MIE)Xuka1RiIcvnJE7O+;tsI<09tst#biMkbwNRYA?9xV|F0i-rK zRG?77T9sC$DFgJ8b=`u>qQYv?LKbg$tE`I))cRPeXfqf1g8koL=1TA|H z8%G|sPGV#z^1553X>X!OPV(#-Cch~++#&?F1DH`Ma26ngm+B9E#cn_?@F%JCf)ti5 z*v#ey-Gv)zs-2>B1a(_vAt=Z!$OGotSX0z)+XjMCi9cnz{$fUX0;7{H=v~W)BD+%* z{crnHg5K!x^4N3$W95IqM~-t{k;Z^rL!|Yt%*;ZGtmv}{J{kgN9otA0kUV8`1fv|# z=yZ*-Lns&Zfhkik{8MQMiweVfwa(kAf)STXgsaoFlSN^@@T6Nd` zgi#)@G&aF=s~d99GHF``ldTz!?=Xg-F`z7!0j;wL+RNez9433UGi;GXbuv&D>Inu+ zd{|Swo59s`p7JV&XNM1NSm%`M5dHuYE#3PgN$gu<$HqftsRI{}gYeJ(r9jATq18iY z)qeS!)B5=JQh)!o!Z-H67m+hmwiWXX`A4IFxiDV4eupBGFXbpNX)8A@R)i&NpWfe^ zi$U>|;>IMx!SXUHz2NgnwB~R3jj#Y?CyQO8xpYejf%jbzFh+^M{1ab* z?~nA5sPdX38a1<4KQ5|x4!mDGg-7(b)Fry3bbW`8{J*K+#nZ}i4PjAT0%MQdSC6Gh zduovdnfg1F_-;coON{mv-r-Q&_#IuCkYj5|mXc$8$La*^!aIPprW*vY>hDL0@x$UF zY`}-dB^HOmAF74(Pb?-nVD3L@ioNsKe+rV^t$X4M1~B{+T~ zeuDT(?BQ-7^a)nAD+wU4{jBBGy2GT7(M>Bjzkyb@`9kCPsytx$4=U=^b)Ljj@YRco zQT(OtmZYcx5x8(#1PnSc=(r_<6MuB3(6Fwrh>+V|uM%Tc_iMyR?_Nxd@4Ksrp*BTZ z>IiI7!KbD?%B1gkg`iq{s>P_t09jinF7|`V1;q30@)BY!xe~+*B*&!y#9a*{Uc=Qo zVn{aS5Tosy7dGHe*OpuCDzs@`p?6|AkpP=E2T(EhlH?@Pc1!E?nfRbC`8c6V);Q8o zZHlYKst=Z%1S?EcSbbXRWFP;Hn@|ED@CMQsu zzX=3v+eipXwk;>d-EBLF@z)Q(B!*48iWtk&DW)>rg^V<&`w*im-NzSYPVK0PJ*4sT zy{D-@Xn*dIbajbRY;a!Q_Wm5>el(C*x9J1Yy>W|xz z`TQK&9%%lEdRsEXaem0t?in{l-C#>r7LhiT>Rr2_PW)Uf<_yuw$T&T z>Rx9&km{Mg<(DzaD*qJ&S9EI4BApIzAYiXgB>Wlr>BKmspM}q9{=n9>Cxy1mWL)!g z{df4rU~pvIybQfn#bWuzZiYYg?QG>?45-PA#jUquDtI&04fx~>SV^M`)=DyX71Wbb zIt$j)QeG;gr_s7XEjv*~bv}^yv6f(9&Ta`8mlD`pm8Gt?9@k7cB!_o}2wpaXF%d{p z1CJXOBx#(<@7pzJTEqFt?ooDO?uxK>Q%r!t8Uak+L(^lIpQ_exsZ-YQ6)R3G6i8YMe7KfcUNqwu&G2|@ zR=yc{5#iRjFRkGE*-SiJrg*)stgQLArsJ*91;M4rx93sP*wVq|M`>I(n;*{hYmHZA0 Cx!!>Q delta 2752 zcmeHJ`&Z0q81Fl`dYjs2=r+@I9V()tqzh||R_^5zp{20OCY2RS*)Ehzp}eg`+F7hD z9c|u5II%@*J7{wkT1^htC0({XyOhg5&s6Ncu;=*Yb7nrz=lwj-dwbsR%gut8cl?|U zJVMH{EI0un29C5$YsIR$c^pTmJwFpUC2byV&d&4wfZHiNf|R#jc1ak^4Ixd|6B>5K z$T!A$4{1=kHe0I=#cf388aV#sstThi2Ym(OGmRb9?$Om!LSqe8;9F*xfF?d*V#_8P zMPaUTvItOatk38L8Re|TScs82u@*4XwldyB$kl} zTwMu$YhH(DDz$<}xLGiPrM|p4s~a#f$od+@n4?U?8I#SW;pM|8d?_I8s@w{TX|Y); zCGHKW=L}thoPpyjOyUbOQL?>?2oSJ$wwF2dF4Zb%RaQS*(rCsc4%;~?F?h=_eC4fb zU$UrQrkSdf(5~G#VZe4LQ~j=>i=6$e?8G$Pg}(x(Im-dRa}EU@U1SY7wOhp3IFB8tnUHbCA)e5LgAah6^TRnn+e3c6V&+r)nAbP( z^^sOS8BFLgZ$~h;E(twz}@;a>ewmqTE^`5|A3A@-c7uoTv z1z5qpYfG?#s_+v%6)0HKjX-2vZk>m4>n$hzQy-Cxi;FeLSzM$Sa?kJl2)O(1L_p2r zNr0`3#{;gvrvY?q3`N8CsqU<#QG@!B`=0_%jXEqM9*Wv)gmTeaf!Glp1Zc1GLV3?+ z3IHOZ`8c4D6V zDM8`NudMWAb64F1WqjgtKwYAffYc`tX0kdAU82`?{`UZ>X(6?sR@qDGsI^fLE?yf9 z*tK>&VA8sSfXbvmz?dZD&n8&{HYC{tcI(kDSq8rYlI6Y20Qb&?QfkBMlJ&JO|3-;f zX-dk6s*PAzssLGDI&>^HK7D6z)wgNI#&qCEXW)^TpRpQ6H#2el7H^u51}gP9MmA63 z%*oKMEd`vXX5fsr#*E1L&oVMh2#wnk1Je6j+yG6tx{HaZZDr!?Y%%9T=#;G$mLx~Q zS=;95G5=8{dsLr`1(kS-SR(c3{D_v%3-OYk7%F;_ zHDa)~-bEH->MwKhzuYj}BS%OY>^j`Sf@=^KwW*)ij$H4)a4XRq%X zAMWVK9tVf{V~_iv_PA25B^&*)2rpIBqgj9>A9ov*U&PY9E7c}KSDKbIfO*D{nLaJtDRSk*`|(ijE?Di zjU#>EKgBvBVe9_#$4Bkt-|+2147?y_&Q$+=j{5Ikx?2%0@29Ux=sBT6=@;g5L{&SP z2F8vewC&|qsFt3p3->0#R8`(#|sLoAI8_s^c(B5 zo6tqwv6#eL|6Fx;&*kAiC05B|-%f+CE@4fffsoMJcllthjp97PJRjQfY*P~065!;p auROd_WJmG^JT4v-70Em<5+%)iF8^Od#l!;u diff --git a/admin/config.xml b/admin/config.xml index 9a59b16..00597e1 100644 --- a/admin/config.xml +++ b/admin/config.xml @@ -1,8 +1,8 @@
@@ -174,59 +174,6 @@ readonly="true" class="readonly" /> - - - - - - - - - - - - - - - - -
- @git Get Bible - @github Get Bible - @support Get Bible - @copyright Copyright (C) 2015. All Rights Reserved - @license GNU/GPL Version 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; -use Joomla\CMS\Language\Text; -use Joomla\CMS\Router\Route; -use VDM\Joomla\Utilities\ArrayHelper as UtilitiesArrayHelper; -use VDM\Joomla\Utilities\StringHelper; - -/** - * 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 = []) - { - // 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(UtilitiesArrayHelper::check($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(Text::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 && StringHelper::check($ref)) - { - // redirect to item of ref - $this->setRedirect(Route::_('index.php?option=com_getbible&view='.(string)$ref.'&layout=edit&id='.(int)$refid, false)); - } - elseif (StringHelper::check($ref)) - { - - // redirect to ref - $this->setRedirect(Route::_('index.php?option=com_getbible&view='.(string)$ref, false)); - } - else - { - // normal redirect back to the list view - $this->setRedirect(Route::_('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 (StringHelper::check($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/models/forms/book.xml b/admin/forms/book.xml similarity index 95% rename from admin/models/forms/book.xml rename to admin/forms/book.xml index 637d005..a9fbedd 100644 --- a/admin/models/forms/book.xml +++ b/admin/forms/book.xml @@ -1,8 +1,11 @@
+ + +
@@ -159,7 +162,7 @@ message="COM_GETBIBLE_BOOK_SHA_MESSAGE" />
- +
diff --git a/admin/models/forms/chapter.xml b/admin/forms/chapter.xml similarity index 96% rename from admin/models/forms/chapter.xml rename to admin/forms/chapter.xml index 04ebb2a..e335572 100644 --- a/admin/models/forms/chapter.xml +++ b/admin/forms/chapter.xml @@ -1,8 +1,11 @@ + + +
@@ -171,7 +174,7 @@ message="COM_GETBIBLE_CHAPTER_SHA_MESSAGE" />
- +
diff --git a/admin/models/forms/filter_books.xml b/admin/forms/filter_books.xml similarity index 74% rename from admin/models/forms/filter_books.xml rename to admin/forms/filter_books.xml index c28f977..d2d9344 100644 --- a/admin/models/forms/filter_books.xml +++ b/admin/forms/filter_books.xml @@ -1,7 +1,7 @@ @@ -58,9 +60,8 @@ @@ -82,11 +83,9 @@ \ No newline at end of file diff --git a/admin/models/forms/filter_chapters.xml b/admin/forms/filter_chapters.xml similarity index 74% rename from admin/models/forms/filter_chapters.xml rename to admin/forms/filter_chapters.xml index 56653e0..e5299cd 100644 --- a/admin/models/forms/filter_chapters.xml +++ b/admin/forms/filter_chapters.xml @@ -1,7 +1,7 @@
@@ -60,9 +62,8 @@ @@ -86,11 +87,9 @@ \ No newline at end of file diff --git a/admin/models/forms/filter_linkers.xml b/admin/forms/filter_linkers.xml similarity index 76% rename from admin/models/forms/filter_linkers.xml rename to admin/forms/filter_linkers.xml index 43e72be..7f92ccc 100644 --- a/admin/models/forms/filter_linkers.xml +++ b/admin/forms/filter_linkers.xml @@ -1,7 +1,7 @@
@@ -58,9 +58,8 @@ @@ -82,11 +81,9 @@ \ No newline at end of file diff --git a/admin/models/forms/filter_notes.xml b/admin/forms/filter_notes.xml similarity index 78% rename from admin/models/forms/filter_notes.xml rename to admin/forms/filter_notes.xml index eb993ae..f5f5fe0 100644 --- a/admin/models/forms/filter_notes.xml +++ b/admin/forms/filter_notes.xml @@ -1,7 +1,7 @@
@@ -26,35 +26,35 @@ name="book_nr" label="COM_GETBIBLE_NOTE_BOOK_NR_LABEL" multiple="false" - onchange="this.form.submit();" + class="js-select-submit-on-change" /> @@ -63,9 +63,8 @@ @@ -87,11 +86,9 @@ \ No newline at end of file diff --git a/admin/models/forms/filter_open_ai_messages.xml b/admin/forms/filter_open_ai_messages.xml similarity index 77% rename from admin/models/forms/filter_open_ai_messages.xml rename to admin/forms/filter_open_ai_messages.xml index e063789..411e867 100644 --- a/admin/models/forms/filter_open_ai_messages.xml +++ b/admin/forms/filter_open_ai_messages.xml @@ -1,7 +1,7 @@
@@ -65,9 +65,8 @@ @@ -91,11 +90,9 @@ \ No newline at end of file diff --git a/admin/models/forms/filter_open_ai_responses.xml b/admin/forms/filter_open_ai_responses.xml similarity index 79% rename from admin/models/forms/filter_open_ai_responses.xml rename to admin/forms/filter_open_ai_responses.xml index d202ba3..cbc009f 100644 --- a/admin/models/forms/filter_open_ai_responses.xml +++ b/admin/forms/filter_open_ai_responses.xml @@ -1,7 +1,7 @@
@@ -58,9 +58,8 @@ @@ -86,11 +85,9 @@ \ No newline at end of file diff --git a/admin/models/forms/filter_passwords.xml b/admin/forms/filter_passwords.xml similarity index 73% rename from admin/models/forms/filter_passwords.xml rename to admin/forms/filter_passwords.xml index 4e85b64..6c01404 100644 --- a/admin/models/forms/filter_passwords.xml +++ b/admin/forms/filter_passwords.xml @@ -1,7 +1,7 @@
@@ -51,9 +51,8 @@ @@ -73,11 +72,9 @@ \ No newline at end of file diff --git a/admin/models/forms/filter_prompts.xml b/admin/forms/filter_prompts.xml similarity index 77% rename from admin/models/forms/filter_prompts.xml rename to admin/forms/filter_prompts.xml index 5e4de04..afa26b4 100644 --- a/admin/models/forms/filter_prompts.xml +++ b/admin/forms/filter_prompts.xml @@ -1,7 +1,7 @@
@@ -65,9 +65,8 @@ @@ -91,11 +90,9 @@ \ No newline at end of file diff --git a/admin/models/forms/filter_tagged_verses.xml b/admin/forms/filter_tagged_verses.xml similarity index 74% rename from admin/models/forms/filter_tagged_verses.xml rename to admin/forms/filter_tagged_verses.xml index e2b8cc8..c1db105 100644 --- a/admin/models/forms/filter_tagged_verses.xml +++ b/admin/forms/filter_tagged_verses.xml @@ -1,7 +1,7 @@
@@ -25,54 +25,58 @@ type="taggedversesfilterbooknr" name="book_nr" label="COM_GETBIBLE_TAGGED_VERSE_BOOK_NR_LABEL" - class="multipleTaggedversesfilterbooknr" + layout="joomla.form.field.list-fancy-select" multiple="true" - onchange="this.form.submit();" + hint="COM_GETBIBLE_FILTER_SELECT_BOOK_NUMBER" + class="js-select-submit-on-change" /> @@ -81,9 +85,8 @@ @@ -109,11 +112,9 @@ \ No newline at end of file diff --git a/admin/models/forms/filter_tags.xml b/admin/forms/filter_tags.xml similarity index 78% rename from admin/models/forms/filter_tags.xml rename to admin/forms/filter_tags.xml index 3e20fac..347e8e3 100644 --- a/admin/models/forms/filter_tags.xml +++ b/admin/forms/filter_tags.xml @@ -1,7 +1,7 @@
@@ -26,14 +26,14 @@ name="linker" label="COM_GETBIBLE_TAG_LINKER_LABEL" multiple="false" - onchange="this.form.submit();" + class="js-select-submit-on-change" /> @@ -42,9 +42,8 @@ @@ -66,11 +65,9 @@ \ No newline at end of file diff --git a/admin/models/forms/filter_translations.xml b/admin/forms/filter_translations.xml similarity index 77% rename from admin/models/forms/filter_translations.xml rename to admin/forms/filter_translations.xml index d398366..d80c091 100644 --- a/admin/models/forms/filter_translations.xml +++ b/admin/forms/filter_translations.xml @@ -1,7 +1,7 @@
@@ -44,9 +44,8 @@ @@ -70,11 +69,9 @@ \ No newline at end of file diff --git a/admin/models/forms/filter_verses.xml b/admin/forms/filter_verses.xml similarity index 77% rename from admin/models/forms/filter_verses.xml rename to admin/forms/filter_verses.xml index 388c26f..25ab64f 100644 --- a/admin/models/forms/filter_verses.xml +++ b/admin/forms/filter_verses.xml @@ -1,7 +1,7 @@
@@ -65,9 +65,8 @@ @@ -91,11 +90,9 @@ \ No newline at end of file diff --git a/admin/controllers/index.html b/admin/forms/index.html similarity index 100% rename from admin/controllers/index.html rename to admin/forms/index.html diff --git a/admin/models/forms/linker.xml b/admin/forms/linker.xml similarity index 95% rename from admin/models/forms/linker.xml rename to admin/forms/linker.xml index 6a555d1..e8e7109 100644 --- a/admin/models/forms/linker.xml +++ b/admin/forms/linker.xml @@ -1,8 +1,11 @@
+ + +
@@ -151,7 +154,7 @@ COM_GETBIBLE_LINKER_NO
- +
diff --git a/admin/models/forms/note.xml b/admin/forms/note.xml similarity index 96% rename from admin/models/forms/note.xml rename to admin/forms/note.xml index 637b0f6..df3ea58 100644 --- a/admin/models/forms/note.xml +++ b/admin/forms/note.xml @@ -1,8 +1,11 @@ + + +
@@ -175,7 +178,7 @@ step="1" />
- +
diff --git a/admin/models/forms/open_ai_message.xml b/admin/forms/open_ai_message.xml similarity index 96% rename from admin/models/forms/open_ai_message.xml rename to admin/forms/open_ai_message.xml index 8b344ae..bc690c2 100644 --- a/admin/models/forms/open_ai_message.xml +++ b/admin/forms/open_ai_message.xml @@ -1,8 +1,11 @@ + + +
@@ -187,7 +190,7 @@ step="1" />
- +
diff --git a/admin/models/forms/open_ai_response.xml b/admin/forms/open_ai_response.xml similarity index 98% rename from admin/models/forms/open_ai_response.xml rename to admin/forms/open_ai_response.xml index d321225..3f6f132 100644 --- a/admin/models/forms/open_ai_response.xml +++ b/admin/forms/open_ai_response.xml @@ -1,8 +1,11 @@ + + +
@@ -394,7 +397,7 @@ COM_GETBIBLE_OPEN_AI_RESPONSE_GPT35TURBO16K0613
- +
diff --git a/admin/models/forms/password.xml b/admin/forms/password.xml similarity index 95% rename from admin/models/forms/password.xml rename to admin/forms/password.xml index 9617f3e..f9b46a8 100644 --- a/admin/models/forms/password.xml +++ b/admin/forms/password.xml @@ -1,8 +1,11 @@ + + +
@@ -149,7 +152,7 @@ autocomplete="off" />
- +
diff --git a/admin/models/forms/prompt.xml b/admin/forms/prompt.xml similarity index 99% rename from admin/models/forms/prompt.xml rename to admin/forms/prompt.xml index 317ad61..416288d 100644 --- a/admin/models/forms/prompt.xml +++ b/admin/forms/prompt.xml @@ -1,8 +1,11 @@ + + +
@@ -546,7 +549,7 @@
- +
diff --git a/admin/models/forms/tag.xml b/admin/forms/tag.xml similarity index 95% rename from admin/models/forms/tag.xml rename to admin/forms/tag.xml index a65e7f4..9e478ba 100644 --- a/admin/models/forms/tag.xml +++ b/admin/forms/tag.xml @@ -1,8 +1,11 @@ + + +
@@ -153,7 +156,7 @@ hint="COM_GETBIBLE_TAG_DESCRIPTION_HINT" />
- +
diff --git a/admin/models/forms/tagged_verse.xml b/admin/forms/tagged_verse.xml similarity index 96% rename from admin/models/forms/tagged_verse.xml rename to admin/forms/tagged_verse.xml index c19c1e3..d4aa5ec 100644 --- a/admin/models/forms/tagged_verse.xml +++ b/admin/forms/tagged_verse.xml @@ -1,8 +1,11 @@ + + +
@@ -184,7 +187,7 @@ step="1" />
- +
diff --git a/admin/models/forms/translation.xml b/admin/forms/translation.xml similarity index 98% rename from admin/models/forms/translation.xml rename to admin/forms/translation.xml index c253374..cbb20f3 100644 --- a/admin/models/forms/translation.xml +++ b/admin/forms/translation.xml @@ -1,8 +1,11 @@ + + +
@@ -390,7 +393,7 @@ hint="COM_GETBIBLE_TRANSLATION_DISTRIBUTION_ABBREVIATION_HINT" />
- +
diff --git a/admin/models/forms/verse.xml b/admin/forms/verse.xml similarity index 96% rename from admin/models/forms/verse.xml rename to admin/forms/verse.xml index 19d7c39..743540c 100644 --- a/admin/models/forms/verse.xml +++ b/admin/forms/verse.xml @@ -1,8 +1,11 @@ + + +
@@ -184,7 +187,7 @@ hint="COM_GETBIBLE_VERSE_NAME_HINT" />
- +
diff --git a/admin/getbible.php b/admin/getbible.php deleted file mode 100644 index f83f9bc..0000000 --- a/admin/getbible.php +++ /dev/null @@ -1,94 +0,0 @@ - - @git Get Bible - @github Get Bible - @support Get Bible - @copyright Copyright (C) 2015. All Rights Reserved - @license GNU/GPL Version 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\Factory; -use Joomla\CMS\Language\Text; -use Joomla\CMS\Access\Exception\NotAllowed; -use Joomla\CMS\HTML\HTMLHelper as Html; -use Joomla\CMS\MVC\Controller\BaseController; - -// Access check. -if (!Factory::getUser()->authorise('core.manage', 'com_getbible')) -{ - throw new NotAllowed(Text::_('JERROR_ALERTNOAUTHOR'), 403); -} - -// Add CSS file for all pages -Html::_('stylesheet', 'components/com_getbible/assets/css/admin.css', ['version' => 'auto']); -Html::_('script', 'components/com_getbible/assets/js/admin.js', ['version' => 'auto']); - -// 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 = BaseController::getInstance('Getbible'); - -// Perform the Request task -$controller->execute(Factory::getApplication()->input->get('task')); - -// Redirect if set by the controller -$controller->redirect(); diff --git a/admin/helpers/headercheck.php b/admin/helpers/headercheck.php deleted file mode 100644 index 9018ba1..0000000 --- a/admin/helpers/headercheck.php +++ /dev/null @@ -1,95 +0,0 @@ - - @git Get Bible - @github Get Bible - @support Get Bible - @copyright Copyright (C) 2015. All Rights Reserved - @license GNU/GPL Version 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\Factory; - -class getbibleHeaderCheck -{ - protected $document = null; - protected $app = null; - - function js_loaded($script_name) - { - // UIkit check point - if (strpos($script_name,'uikit') !== false) - { - if (!$this->app) - { - $this->app = Factory::getApplication(); - } - - $getTemplateName = $this->app->getTemplate('template')->template; - if (strpos($getTemplateName,'yoo') !== false) - { - return true; - } - } - - if (!$this->document) - { - $this->document = Factory::getDocument(); - } - - $head_data = $this->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) - { - if (!$this->app) - { - $this->app = Factory::getApplication(); - } - - $getTemplateName = $this->app->getTemplate('template')->template; - if (strpos($getTemplateName,'yoo') !== false) - { - return true; - } - } - - if (!$this->document) - { - $this->document = Factory::getDocument(); - } - - $head_data = $this->document->getHeadData(); - foreach (array_keys($head_data['styleSheets']) as $script) - { - if (stristr($script, $script_name)) - { - return true; - } - } - - return false; - } -} diff --git a/admin/helpers/html/batch_.php b/admin/helpers/html/batch_.php deleted file mode 100644 index 8ec5c7e..0000000 --- a/admin/helpers/html/batch_.php +++ /dev/null @@ -1,84 +0,0 @@ - - @git Get Bible - @github Get Bible - @support Get Bible - @copyright Copyright (C) 2015. All Rights 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 = []; - - /** - * 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/language/en-GB/en-GB.com_getbible.ini b/admin/language/en-GB/en-GB.com_getbible.ini index 103d547..8e0f132 100644 --- a/admin/language/en-GB/en-GB.com_getbible.ini +++ b/admin/language/en-GB/en-GB.com_getbible.ini @@ -1,7 +1,7 @@ COM_GETBIBLE="Get Bible" COM_GETBIBLE_ACCESS_ALREADY_EXIST_BUT_COULD_NOT_BE_REACTIVATED="Access already exist, but could not be reactivated." COM_GETBIBLE_ACCESS_REVOKED="Access revoked." -COM_GETBIBLE_ALL_IS_GOOD_PLEASE_CHECK_AGAIN_LATTER="All is good, please check again latter." +COM_GETBIBLE_ALL_IS_GOOD_PLEASE_CHECK_AGAIN_LATER="All is good, please check again later" COM_GETBIBLE_ALL_TRANSLATIONS="All Translations" COM_GETBIBLE_ALL_TRANSLATIONS_WERE_SUCCESSFULLY_UPDATED_AND_THEY_ARE_NOW_IN_SYNC_WITH_THE_GETBIBLE_API="All translations were successfully updated, and they are now in sync with the getBible API." COM_GETBIBLE_ARCHIVED="Archived" @@ -41,6 +41,9 @@ 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_EMPTYSTATE_BUTTON_ADD="Add your first book" +COM_GETBIBLE_BOOKS_EMPTYSTATE_CONTENT="" +COM_GETBIBLE_BOOKS_EMPTYSTATE_TITLE="No books have been created yet." 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." @@ -70,6 +73,7 @@ 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_ERROR_UNIQUE_ALIAS_TRASHED="A trashed Book has the same alias ." COM_GETBIBLE_BOOK_FORCE_HASH_CHECK_BUTTON_ACCESS="Book Force Hash Check Button Access" COM_GETBIBLE_BOOK_FORCE_HASH_CHECK_BUTTON_ACCESS_DESC="Allows the users in this group to access the force hash check button." COM_GETBIBLE_BOOK_ID="Id" @@ -130,6 +134,9 @@ 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_EMPTYSTATE_BUTTON_ADD="Add your first chapter" +COM_GETBIBLE_CHAPTERS_EMPTYSTATE_CONTENT="" +COM_GETBIBLE_CHAPTERS_EMPTYSTATE_TITLE="No chapters have been created yet." 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." @@ -163,6 +170,7 @@ 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_ERROR_UNIQUE_ALIAS_TRASHED="A trashed 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" @@ -252,26 +260,6 @@ 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_CONTRIBUTOR_EMAIL_DESC="The email of this contributor." -COM_GETBIBLE_CONFIG_CONTRIBUTOR_EMAIL_LABEL="Contributor Email" -COM_GETBIBLE_CONFIG_CONTRIBUTOR_LINK_DESC="The link to this contributor's website." -COM_GETBIBLE_CONFIG_CONTRIBUTOR_LINK_LABEL="Contributor Website" -COM_GETBIBLE_CONFIG_CONTRIBUTOR_NAME_DESC="The name of this contributor." -COM_GETBIBLE_CONFIG_CONTRIBUTOR_NAME_LABEL="Contributor Name" -COM_GETBIBLE_CONFIG_CONTRIBUTOR_ONE="Contributor One" -COM_GETBIBLE_CONFIG_CONTRIBUTOR_SHOW_ALL="Both Front & Back-end" -COM_GETBIBLE_CONFIG_CONTRIBUTOR_SHOW_BACK="Back-end" -COM_GETBIBLE_CONFIG_CONTRIBUTOR_SHOW_DESC="Select where you want this contributor's details to show in the component." -COM_GETBIBLE_CONFIG_CONTRIBUTOR_SHOW_FRONT="Front-end" -COM_GETBIBLE_CONFIG_CONTRIBUTOR_SHOW_LABEL="Show" -COM_GETBIBLE_CONFIG_CONTRIBUTOR_SHOW_NONE="Hide" -COM_GETBIBLE_CONFIG_CONTRIBUTOR_TITLE_DESC="The job title that best describes the contributor's relationship to this component." -COM_GETBIBLE_CONFIG_CONTRIBUTOR_TITLE_LABEL="Contributor Job Title" -COM_GETBIBLE_CONFIG_CONTRIBUTOR_USE_DESC="How should we link to this contributor." -COM_GETBIBLE_CONFIG_CONTRIBUTOR_USE_EMAIL="Email" -COM_GETBIBLE_CONFIG_CONTRIBUTOR_USE_LABEL="Use" -COM_GETBIBLE_CONFIG_CONTRIBUTOR_USE_NONE="None" -COM_GETBIBLE_CONFIG_CONTRIBUTOR_USE_WWW="Website" 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" @@ -656,6 +644,9 @@ COM_GETBIBLE_LINKERS_EDIT_PUBLIC_TAGGED_VERSES="Linkers Edit Public Tagged Verse COM_GETBIBLE_LINKERS_EDIT_PUBLIC_TAGGED_VERSES_DESC="Allows the users in this group to edit public tagged verses of linker" 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_EMPTYSTATE_BUTTON_ADD="Add your first linker" +COM_GETBIBLE_LINKERS_EMPTYSTATE_CONTENT="" +COM_GETBIBLE_LINKERS_EMPTYSTATE_TITLE="No linkers have been created yet." 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." @@ -684,6 +675,7 @@ 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_ERROR_UNIQUE_ALIAS_TRASHED="A trashed 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" @@ -753,6 +745,9 @@ 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 the users in this group to edit versions of version notes" +COM_GETBIBLE_NOTES_EMPTYSTATE_BUTTON_ADD="Add your first note" +COM_GETBIBLE_NOTES_EMPTYSTATE_CONTENT="" +COM_GETBIBLE_NOTES_EMPTYSTATE_TITLE="No notes have been created yet." 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." @@ -788,6 +783,7 @@ 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_ERROR_UNIQUE_ALIAS_TRASHED="A trashed 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" @@ -856,6 +852,9 @@ 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 the users in this group to edit versions of version open ai messages" +COM_GETBIBLE_OPEN_AI_MESSAGES_EMPTYSTATE_BUTTON_ADD="Add your first open ai message" +COM_GETBIBLE_OPEN_AI_MESSAGES_EMPTYSTATE_CONTENT="Open AI Messages Received" +COM_GETBIBLE_OPEN_AI_MESSAGES_EMPTYSTATE_TITLE="No open ai messages have been created yet." 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." @@ -884,6 +883,7 @@ COM_GETBIBLE_OPEN_AI_MESSAGE_CREATED_DATE_DESC="The date this Open AI Message wa 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_ERROR_UNIQUE_ALIAS_TRASHED="A trashed 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" @@ -986,6 +986,9 @@ COM_GETBIBLE_OPEN_AI_RESPONSES_EDIT_VERSION="Open Ai Responses Edit Version" COM_GETBIBLE_OPEN_AI_RESPONSES_EDIT_VERSION_DESC="Allows the 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_EMPTYSTATE_BUTTON_ADD="Add your first open ai response" +COM_GETBIBLE_OPEN_AI_RESPONSES_EMPTYSTATE_CONTENT="Open AI Response Received" +COM_GETBIBLE_OPEN_AI_RESPONSES_EMPTYSTATE_TITLE="No open ai responses have been created yet." 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." @@ -1025,6 +1028,7 @@ 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_ERROR_UNIQUE_ALIAS_TRASHED="A trashed 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" @@ -1129,6 +1133,9 @@ 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_EMPTYSTATE_BUTTON_ADD="Add your first password" +COM_GETBIBLE_PASSWORDS_EMPTYSTATE_CONTENT="" +COM_GETBIBLE_PASSWORDS_EMPTYSTATE_TITLE="No passwords have been created yet." 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." @@ -1157,6 +1164,7 @@ 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_ERROR_UNIQUE_ALIAS_TRASHED="A trashed 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" @@ -1182,7 +1190,7 @@ 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_PLEASE_CHECK_AGAIN_LATER="Please check again later" COM_GETBIBLE_PROMPT="Prompt" COM_GETBIBLE_PROMPTS="Prompts" COM_GETBIBLE_PROMPTS_ACCESS="Prompts Access" @@ -1257,6 +1265,9 @@ 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 the users in this group to edit versions of version prompts" +COM_GETBIBLE_PROMPTS_EMPTYSTATE_BUTTON_ADD="Add your first prompt" +COM_GETBIBLE_PROMPTS_EMPTYSTATE_CONTENT="" +COM_GETBIBLE_PROMPTS_EMPTYSTATE_TITLE="No prompts have been created yet." 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." @@ -1306,6 +1317,7 @@ 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_ERROR_UNIQUE_ALIAS_TRASHED="A trashed 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.
" @@ -1474,6 +1486,9 @@ 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 the users in this group to edit versions of version tagged verses" +COM_GETBIBLE_TAGGED_VERSES_EMPTYSTATE_BUTTON_ADD="Add your first tagged verse" +COM_GETBIBLE_TAGGED_VERSES_EMPTYSTATE_CONTENT="" +COM_GETBIBLE_TAGGED_VERSES_EMPTYSTATE_TITLE="No tagged verses have been created yet." 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." @@ -1511,6 +1526,7 @@ 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_ERROR_UNIQUE_ALIAS_TRASHED="A trashed 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" @@ -1569,6 +1585,9 @@ 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 the users in this group to edit versions of version tags" +COM_GETBIBLE_TAGS_EMPTYSTATE_BUTTON_ADD="Add your first tag" +COM_GETBIBLE_TAGS_EMPTYSTATE_CONTENT="" +COM_GETBIBLE_TAGS_EMPTYSTATE_TITLE="No tags have been created yet." 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." @@ -1602,6 +1621,7 @@ 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_ERROR_UNIQUE_ALIAS_TRASHED="A trashed Tag has the same alias ." COM_GETBIBLE_TAG_FOUND_BUT_COULD_NOT_BE_REACTIVATED="Tag found, but could not be reactivated." COM_GETBIBLE_TAG_GUID_DESCRIPTION="Globally Unique Identifier" COM_GETBIBLE_TAG_GUID_HINT="Auto Generated" @@ -1709,6 +1729,9 @@ 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_EMPTYSTATE_BUTTON_ADD="Add your first translation" +COM_GETBIBLE_TRANSLATIONS_EMPTYSTATE_CONTENT="" +COM_GETBIBLE_TRANSLATIONS_EMPTYSTATE_TITLE="No translations have been created yet." 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." @@ -1782,6 +1805,7 @@ 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_ERROR_UNIQUE_ALIAS_TRASHED="A trashed Translation has the same alias ." COM_GETBIBLE_TRANSLATION_ID="Id" COM_GETBIBLE_TRANSLATION_LANGUAGE_DESCRIPTION="The translation language." COM_GETBIBLE_TRANSLATION_LANGUAGE_HINT="English" @@ -1876,6 +1900,9 @@ 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_EMPTYSTATE_BUTTON_ADD="Add your first verse" +COM_GETBIBLE_VERSES_EMPTYSTATE_CONTENT="" +COM_GETBIBLE_VERSES_EMPTYSTATE_TITLE="No verses have been created yet." 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." @@ -1909,6 +1936,7 @@ 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_ERROR_UNIQUE_ALIAS_TRASHED="A trashed 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" diff --git a/admin/language/en-GB/en-GB.com_getbible.sys.ini b/admin/language/en-GB/en-GB.com_getbible.sys.ini index ea6b599..7cd873a 100644 --- a/admin/language/en-GB/en-GB.com_getbible.sys.ini +++ b/admin/language/en-GB/en-GB.com_getbible.sys.ini @@ -111,6 +111,7 @@ 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_DASHBOARD="Dashboard" COM_GETBIBLE_MENU_LINKERS="Linkers" COM_GETBIBLE_MENU_NOTES="Notes" COM_GETBIBLE_MENU_OPEN_AI_RESPONSES="Open AI Responses" diff --git a/admin/layouts/batchselection.php b/admin/layouts/batchselection.php deleted file mode 100644 index abde6dc..0000000 --- a/admin/layouts/batchselection.php +++ /dev/null @@ -1,55 +0,0 @@ - - @git Get Bible - @github Get Bible - @support Get Bible - @copyright Copyright (C) 2015. All Rights 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; - -use Joomla\CMS\Language\Text; -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 index c71d840..f67cda1 100644 --- a/admin/layouts/book/details_above.php +++ b/admin/layouts/book/details_above.php @@ -16,7 +16,7 @@ /------------------------------------------------------------------------------------------------------*/ // No direct access to this file -defined('_JEXEC') or die('Restricted access'); +defined('_JEXEC') or die; // get the form $form = $displayData->getForm(); @@ -31,21 +31,29 @@ $layout_path_array = explode('.', $this->getLayoutId()); $fields_tab_layout = 'fields_' . $layout_path_array[1]; // get the fields -$fields = $displayData->get($fields_tab_layout) ?: array( +$fields = $displayData->get($fields_tab_layout) ?: [ 'name', 'nr' -); +]; + +// Ensure $fields is treated as an array and count its size. +$size = count((array) $fields); + +// Use a ternary operator to determine the class. +// If there are 1 to 4 fields, set the class to divide the 12-grid column equally among the fields. +// For more than 4 fields, default to four columns (3-grid each) for medium and larger screens. +$css_class = ($size > 0 && $size <= 4) ? 'col-12 col-md-' . round(12 / $size) : 'col-12 col-md-3'; $hiddenFields = $displayData->get('hidden_fields') ?: []; ?> -
+
setFieldAttribute($field, 'type', 'hidden'); ?> - renderField($field, null, null, array('class' => 'control-wrapper-' . $field)); ?> + renderField($field, null, null, ['class' => $css_class . ' control-wrapper-' . $field]); ?>
diff --git a/admin/layouts/book/details_left.php b/admin/layouts/book/details_left.php index 0e92e27..184bc46 100644 --- a/admin/layouts/book/details_left.php +++ b/admin/layouts/book/details_left.php @@ -16,7 +16,7 @@ /------------------------------------------------------------------------------------------------------*/ // No direct access to this file -defined('_JEXEC') or die('Restricted access'); +\defined('_JEXEC') or die; // get the form $form = $displayData->getForm(); diff --git a/admin/layouts/book/details_right.php b/admin/layouts/book/details_right.php index e2edc8b..1af3d92 100644 --- a/admin/layouts/book/details_right.php +++ b/admin/layouts/book/details_right.php @@ -16,7 +16,7 @@ /------------------------------------------------------------------------------------------------------*/ // No direct access to this file -defined('_JEXEC') or die('Restricted access'); +\defined('_JEXEC') or die; // get the form $form = $displayData->getForm(); diff --git a/admin/layouts/book/publishing.php b/admin/layouts/book/publishing.php index 79c70bb..9aed60d 100644 --- a/admin/layouts/book/publishing.php +++ b/admin/layouts/book/publishing.php @@ -16,7 +16,7 @@ /------------------------------------------------------------------------------------------------------*/ // No direct access to this file -defined('_JEXEC') or die('Restricted access'); +\defined('_JEXEC') or die; // get the form $form = $displayData->getForm(); diff --git a/admin/layouts/book/publlshing.php b/admin/layouts/book/publlshing.php index ebe4ba7..0a086ef 100644 --- a/admin/layouts/book/publlshing.php +++ b/admin/layouts/book/publlshing.php @@ -16,7 +16,7 @@ /------------------------------------------------------------------------------------------------------*/ // No direct access to this file -defined('_JEXEC') or die('Restricted access'); +\defined('_JEXEC') or die; // get the form $form = $displayData->getForm(); diff --git a/admin/layouts/chapter/details_above.php b/admin/layouts/chapter/details_above.php index 55dc09f..95aa7dc 100644 --- a/admin/layouts/chapter/details_above.php +++ b/admin/layouts/chapter/details_above.php @@ -16,7 +16,7 @@ /------------------------------------------------------------------------------------------------------*/ // No direct access to this file -defined('_JEXEC') or die('Restricted access'); +defined('_JEXEC') or die; // get the form $form = $displayData->getForm(); @@ -31,22 +31,30 @@ $layout_path_array = explode('.', $this->getLayoutId()); $fields_tab_layout = 'fields_' . $layout_path_array[1]; // get the fields -$fields = $displayData->get($fields_tab_layout) ?: array( +$fields = $displayData->get($fields_tab_layout) ?: [ 'name', 'chapter', 'book_nr' -); +]; + +// Ensure $fields is treated as an array and count its size. +$size = count((array) $fields); + +// Use a ternary operator to determine the class. +// If there are 1 to 4 fields, set the class to divide the 12-grid column equally among the fields. +// For more than 4 fields, default to four columns (3-grid each) for medium and larger screens. +$css_class = ($size > 0 && $size <= 4) ? 'col-12 col-md-' . round(12 / $size) : 'col-12 col-md-3'; $hiddenFields = $displayData->get('hidden_fields') ?: []; ?> -
+
setFieldAttribute($field, 'type', 'hidden'); ?> - renderField($field, null, null, array('class' => 'control-wrapper-' . $field)); ?> + renderField($field, null, null, ['class' => $css_class . ' control-wrapper-' . $field]); ?>
diff --git a/admin/layouts/chapter/details_left.php b/admin/layouts/chapter/details_left.php index 0e92e27..184bc46 100644 --- a/admin/layouts/chapter/details_left.php +++ b/admin/layouts/chapter/details_left.php @@ -16,7 +16,7 @@ /------------------------------------------------------------------------------------------------------*/ // No direct access to this file -defined('_JEXEC') or die('Restricted access'); +\defined('_JEXEC') or die; // get the form $form = $displayData->getForm(); diff --git a/admin/layouts/chapter/details_right.php b/admin/layouts/chapter/details_right.php index e2edc8b..1af3d92 100644 --- a/admin/layouts/chapter/details_right.php +++ b/admin/layouts/chapter/details_right.php @@ -16,7 +16,7 @@ /------------------------------------------------------------------------------------------------------*/ // No direct access to this file -defined('_JEXEC') or die('Restricted access'); +\defined('_JEXEC') or die; // get the form $form = $displayData->getForm(); diff --git a/admin/layouts/chapter/publishing.php b/admin/layouts/chapter/publishing.php index 79c70bb..9aed60d 100644 --- a/admin/layouts/chapter/publishing.php +++ b/admin/layouts/chapter/publishing.php @@ -16,7 +16,7 @@ /------------------------------------------------------------------------------------------------------*/ // No direct access to this file -defined('_JEXEC') or die('Restricted access'); +\defined('_JEXEC') or die; // get the form $form = $displayData->getForm(); diff --git a/admin/layouts/chapter/publlshing.php b/admin/layouts/chapter/publlshing.php index ebe4ba7..0a086ef 100644 --- a/admin/layouts/chapter/publlshing.php +++ b/admin/layouts/chapter/publlshing.php @@ -16,7 +16,7 @@ /------------------------------------------------------------------------------------------------------*/ // No direct access to this file -defined('_JEXEC') or die('Restricted access'); +\defined('_JEXEC') or die; // get the form $form = $displayData->getForm(); diff --git a/admin/layouts/linker/details_above.php b/admin/layouts/linker/details_above.php index 68f7be5..941867c 100644 --- a/admin/layouts/linker/details_above.php +++ b/admin/layouts/linker/details_above.php @@ -16,7 +16,7 @@ /------------------------------------------------------------------------------------------------------*/ // No direct access to this file -defined('_JEXEC') or die('Restricted access'); +defined('_JEXEC') or die; // get the form $form = $displayData->getForm(); @@ -31,20 +31,28 @@ $layout_path_array = explode('.', $this->getLayoutId()); $fields_tab_layout = 'fields_' . $layout_path_array[1]; // get the fields -$fields = $displayData->get($fields_tab_layout) ?: array( +$fields = $displayData->get($fields_tab_layout) ?: [ 'name' -); +]; + +// Ensure $fields is treated as an array and count its size. +$size = count((array) $fields); + +// Use a ternary operator to determine the class. +// If there are 1 to 4 fields, set the class to divide the 12-grid column equally among the fields. +// For more than 4 fields, default to four columns (3-grid each) for medium and larger screens. +$css_class = ($size > 0 && $size <= 4) ? 'col-12 col-md-' . round(12 / $size) : 'col-12 col-md-3'; $hiddenFields = $displayData->get('hidden_fields') ?: []; ?> -
+
setFieldAttribute($field, 'type', 'hidden'); ?> - renderField($field, null, null, array('class' => 'control-wrapper-' . $field)); ?> + renderField($field, null, null, ['class' => $css_class . ' control-wrapper-' . $field]); ?>
diff --git a/admin/layouts/linker/details_left.php b/admin/layouts/linker/details_left.php index ed96808..a23d50d 100644 --- a/admin/layouts/linker/details_left.php +++ b/admin/layouts/linker/details_left.php @@ -16,7 +16,7 @@ /------------------------------------------------------------------------------------------------------*/ // No direct access to this file -defined('_JEXEC') or die('Restricted access'); +\defined('_JEXEC') or die; // get the form $form = $displayData->getForm(); diff --git a/admin/layouts/linker/details_right.php b/admin/layouts/linker/details_right.php index 2d6a1ea..0991750 100644 --- a/admin/layouts/linker/details_right.php +++ b/admin/layouts/linker/details_right.php @@ -16,7 +16,7 @@ /------------------------------------------------------------------------------------------------------*/ // No direct access to this file -defined('_JEXEC') or die('Restricted access'); +\defined('_JEXEC') or die; // get the form $form = $displayData->getForm(); diff --git a/admin/layouts/linker/notes_fullwidth.php b/admin/layouts/linker/notes_fullwidth.php index 109ddec..0939bd3 100644 --- a/admin/layouts/linker/notes_fullwidth.php +++ b/admin/layouts/linker/notes_fullwidth.php @@ -16,16 +16,18 @@ /------------------------------------------------------------------------------------------------------*/ // No direct access to this file -defined('_JEXEC') or die('Restricted access'); +\defined('_JEXEC') or die; use Joomla\CMS\Factory; use Joomla\CMS\Language\Text; use Joomla\CMS\HTML\HTMLHelper as Html; +use TrueChristianChurch\Component\Getbible\Administrator\Helper\GetbibleHelper; use VDM\Joomla\Utilities\StringHelper; +use VDM\Joomla\Utilities\ArrayHelper; // set the defaults $items = $displayData->vvwnotes; -$user = Factory::getUser(); +$user = Factory::getApplication()->getIdentity(); $id = $displayData->item->id; // set the edit URL $edit = "index.php?option=com_getbible&view=notes&task=note.edit"; @@ -62,7 +64,7 @@ $can = GetbibleHelper::getActions('note');


- + @@ -87,7 +89,9 @@ $can = GetbibleHelper::getActions('note'); $item): ?> authorise('core.manage', 'com_checkin') || $item->checked_out == $user->id || $item->checked_out == 0; - $userChkOut = Factory::getUser($item->checked_out); + $userChkOut = Factory::getContainer()-> + get(\Joomla\CMS\User\UserFactoryInterface::class)-> + loadUserById($item->checked_out); $canDo = GetbibleHelper::getActions('note',$item,'notes'); ?> diff --git a/admin/layouts/linker/passwords_fullwidth.php b/admin/layouts/linker/passwords_fullwidth.php index ba851c8..b6d3332 100644 --- a/admin/layouts/linker/passwords_fullwidth.php +++ b/admin/layouts/linker/passwords_fullwidth.php @@ -16,16 +16,18 @@ /------------------------------------------------------------------------------------------------------*/ // No direct access to this file -defined('_JEXEC') or die('Restricted access'); +\defined('_JEXEC') or die; use Joomla\CMS\Factory; use Joomla\CMS\Language\Text; use Joomla\CMS\HTML\HTMLHelper as Html; +use TrueChristianChurch\Component\Getbible\Administrator\Helper\GetbibleHelper; use VDM\Joomla\Utilities\StringHelper; +use VDM\Joomla\Utilities\ArrayHelper; // set the defaults $items = $displayData->vvxpasswords; -$user = Factory::getUser(); +$user = Factory::getApplication()->getIdentity(); $id = $displayData->item->id; // set the edit URL $edit = "index.php?option=com_getbible&view=passwords&task=password.edit"; @@ -62,7 +64,7 @@ $can = GetbibleHelper::getActions('password');

- +
@@ -87,7 +89,9 @@ $can = GetbibleHelper::getActions('password'); $item): ?> authorise('core.manage', 'com_checkin') || $item->checked_out == $user->id || $item->checked_out == 0; - $userChkOut = Factory::getUser($item->checked_out); + $userChkOut = Factory::getContainer()-> + get(\Joomla\CMS\User\UserFactoryInterface::class)-> + loadUserById($item->checked_out); $canDo = GetbibleHelper::getActions('password',$item,'passwords'); ?> diff --git a/admin/layouts/linker/publishing.php b/admin/layouts/linker/publishing.php index e7b0b9b..eec45d1 100644 --- a/admin/layouts/linker/publishing.php +++ b/admin/layouts/linker/publishing.php @@ -16,7 +16,7 @@ /------------------------------------------------------------------------------------------------------*/ // No direct access to this file -defined('_JEXEC') or die('Restricted access'); +\defined('_JEXEC') or die; // get the form $form = $displayData->getForm(); diff --git a/admin/layouts/linker/publlshing.php b/admin/layouts/linker/publlshing.php index ebe4ba7..0a086ef 100644 --- a/admin/layouts/linker/publlshing.php +++ b/admin/layouts/linker/publlshing.php @@ -16,7 +16,7 @@ /------------------------------------------------------------------------------------------------------*/ // No direct access to this file -defined('_JEXEC') or die('Restricted access'); +\defined('_JEXEC') or die; // get the form $form = $displayData->getForm(); diff --git a/admin/layouts/linker/tags_fullwidth.php b/admin/layouts/linker/tags_fullwidth.php index 1db2893..f3a6993 100644 --- a/admin/layouts/linker/tags_fullwidth.php +++ b/admin/layouts/linker/tags_fullwidth.php @@ -16,16 +16,18 @@ /------------------------------------------------------------------------------------------------------*/ // No direct access to this file -defined('_JEXEC') or die('Restricted access'); +\defined('_JEXEC') or die; use Joomla\CMS\Factory; use Joomla\CMS\Language\Text; use Joomla\CMS\HTML\HTMLHelper as Html; +use TrueChristianChurch\Component\Getbible\Administrator\Helper\GetbibleHelper; use VDM\Joomla\Utilities\StringHelper; +use VDM\Joomla\Utilities\ArrayHelper; // set the defaults $items = $displayData->vvvtags; -$user = Factory::getUser(); +$user = Factory::getApplication()->getIdentity(); $id = $displayData->item->id; // set the edit URL $edit = "index.php?option=com_getbible&view=tagged_verses&task=tagged_verse.edit"; @@ -62,7 +64,7 @@ $can = GetbibleHelper::getActions('tagged_verse');

- +
@@ -93,7 +95,9 @@ $can = GetbibleHelper::getActions('tagged_verse'); $item): ?> authorise('core.manage', 'com_checkin') || $item->checked_out == $user->id || $item->checked_out == 0; - $userChkOut = Factory::getUser($item->checked_out); + $userChkOut = Factory::getContainer()-> + get(\Joomla\CMS\User\UserFactoryInterface::class)-> + loadUserById($item->checked_out); $canDo = GetbibleHelper::getActions('tagged_verse',$item,'tagged_verses'); ?> diff --git a/admin/layouts/note/details_above.php b/admin/layouts/note/details_above.php index 4f43f69..852df51 100644 --- a/admin/layouts/note/details_above.php +++ b/admin/layouts/note/details_above.php @@ -16,7 +16,7 @@ /------------------------------------------------------------------------------------------------------*/ // No direct access to this file -defined('_JEXEC') or die('Restricted access'); +defined('_JEXEC') or die; // get the form $form = $displayData->getForm(); @@ -31,21 +31,29 @@ $layout_path_array = explode('.', $this->getLayoutId()); $fields_tab_layout = 'fields_' . $layout_path_array[1]; // get the fields -$fields = $displayData->get($fields_tab_layout) ?: array( +$fields = $displayData->get($fields_tab_layout) ?: [ 'access', 'linker' -); +]; + +// Ensure $fields is treated as an array and count its size. +$size = count((array) $fields); + +// Use a ternary operator to determine the class. +// If there are 1 to 4 fields, set the class to divide the 12-grid column equally among the fields. +// For more than 4 fields, default to four columns (3-grid each) for medium and larger screens. +$css_class = ($size > 0 && $size <= 4) ? 'col-12 col-md-' . round(12 / $size) : 'col-12 col-md-3'; $hiddenFields = $displayData->get('hidden_fields') ?: []; ?> -
+
setFieldAttribute($field, 'type', 'hidden'); ?> - renderField($field, null, null, array('class' => 'control-wrapper-' . $field)); ?> + renderField($field, null, null, ['class' => $css_class . ' control-wrapper-' . $field]); ?>
diff --git a/admin/layouts/note/details_left.php b/admin/layouts/note/details_left.php index 5eb89a3..a34c29a 100644 --- a/admin/layouts/note/details_left.php +++ b/admin/layouts/note/details_left.php @@ -16,7 +16,7 @@ /------------------------------------------------------------------------------------------------------*/ // No direct access to this file -defined('_JEXEC') or die('Restricted access'); +\defined('_JEXEC') or die; // get the form $form = $displayData->getForm(); diff --git a/admin/layouts/note/details_right.php b/admin/layouts/note/details_right.php index b997322..357416f 100644 --- a/admin/layouts/note/details_right.php +++ b/admin/layouts/note/details_right.php @@ -16,7 +16,7 @@ /------------------------------------------------------------------------------------------------------*/ // No direct access to this file -defined('_JEXEC') or die('Restricted access'); +\defined('_JEXEC') or die; // get the form $form = $displayData->getForm(); diff --git a/admin/layouts/note/publishing.php b/admin/layouts/note/publishing.php index e7b0b9b..eec45d1 100644 --- a/admin/layouts/note/publishing.php +++ b/admin/layouts/note/publishing.php @@ -16,7 +16,7 @@ /------------------------------------------------------------------------------------------------------*/ // No direct access to this file -defined('_JEXEC') or die('Restricted access'); +\defined('_JEXEC') or die; // get the form $form = $displayData->getForm(); diff --git a/admin/layouts/note/publlshing.php b/admin/layouts/note/publlshing.php index 8501906..38c3c49 100644 --- a/admin/layouts/note/publlshing.php +++ b/admin/layouts/note/publlshing.php @@ -16,7 +16,7 @@ /------------------------------------------------------------------------------------------------------*/ // No direct access to this file -defined('_JEXEC') or die('Restricted access'); +\defined('_JEXEC') or die; // get the form $form = $displayData->getForm(); diff --git a/admin/layouts/open_ai_message/message_above.php b/admin/layouts/open_ai_message/message_above.php index 768add9..b16680f 100644 --- a/admin/layouts/open_ai_message/message_above.php +++ b/admin/layouts/open_ai_message/message_above.php @@ -16,7 +16,7 @@ /------------------------------------------------------------------------------------------------------*/ // No direct access to this file -defined('_JEXEC') or die('Restricted access'); +defined('_JEXEC') or die; // get the form $form = $displayData->getForm(); @@ -31,22 +31,30 @@ $layout_path_array = explode('.', $this->getLayoutId()); $fields_tab_layout = 'fields_' . $layout_path_array[1]; // get the fields -$fields = $displayData->get($fields_tab_layout) ?: array( +$fields = $displayData->get($fields_tab_layout) ?: [ 'role', 'open_ai_response', 'prompt' -); +]; + +// Ensure $fields is treated as an array and count its size. +$size = count((array) $fields); + +// Use a ternary operator to determine the class. +// If there are 1 to 4 fields, set the class to divide the 12-grid column equally among the fields. +// For more than 4 fields, default to four columns (3-grid each) for medium and larger screens. +$css_class = ($size > 0 && $size <= 4) ? 'col-12 col-md-' . round(12 / $size) : 'col-12 col-md-3'; $hiddenFields = $displayData->get('hidden_fields') ?: []; ?> -
+
setFieldAttribute($field, 'type', 'hidden'); ?> - renderField($field, null, null, array('class' => 'control-wrapper-' . $field)); ?> + renderField($field, null, null, ['class' => $css_class . ' control-wrapper-' . $field]); ?>
diff --git a/admin/layouts/open_ai_message/message_fullwidth.php b/admin/layouts/open_ai_message/message_fullwidth.php index 2b3dae8..63a5e05 100644 --- a/admin/layouts/open_ai_message/message_fullwidth.php +++ b/admin/layouts/open_ai_message/message_fullwidth.php @@ -16,7 +16,7 @@ /------------------------------------------------------------------------------------------------------*/ // No direct access to this file -defined('_JEXEC') or die('Restricted access'); +\defined('_JEXEC') or die; // get the form $form = $displayData->getForm(); diff --git a/admin/layouts/open_ai_message/message_left.php b/admin/layouts/open_ai_message/message_left.php index 4afdfbf..f65b965 100644 --- a/admin/layouts/open_ai_message/message_left.php +++ b/admin/layouts/open_ai_message/message_left.php @@ -16,7 +16,7 @@ /------------------------------------------------------------------------------------------------------*/ // No direct access to this file -defined('_JEXEC') or die('Restricted access'); +\defined('_JEXEC') or die; // get the form $form = $displayData->getForm(); diff --git a/admin/layouts/open_ai_message/message_right.php b/admin/layouts/open_ai_message/message_right.php index 18d0070..18fb7f1 100644 --- a/admin/layouts/open_ai_message/message_right.php +++ b/admin/layouts/open_ai_message/message_right.php @@ -16,7 +16,7 @@ /------------------------------------------------------------------------------------------------------*/ // No direct access to this file -defined('_JEXEC') or die('Restricted access'); +\defined('_JEXEC') or die; // get the form $form = $displayData->getForm(); diff --git a/admin/layouts/open_ai_message/publishing.php b/admin/layouts/open_ai_message/publishing.php index 79c70bb..9aed60d 100644 --- a/admin/layouts/open_ai_message/publishing.php +++ b/admin/layouts/open_ai_message/publishing.php @@ -16,7 +16,7 @@ /------------------------------------------------------------------------------------------------------*/ // No direct access to this file -defined('_JEXEC') or die('Restricted access'); +\defined('_JEXEC') or die; // get the form $form = $displayData->getForm(); diff --git a/admin/layouts/open_ai_message/publlshing.php b/admin/layouts/open_ai_message/publlshing.php index ebe4ba7..0a086ef 100644 --- a/admin/layouts/open_ai_message/publlshing.php +++ b/admin/layouts/open_ai_message/publlshing.php @@ -16,7 +16,7 @@ /------------------------------------------------------------------------------------------------------*/ // No direct access to this file -defined('_JEXEC') or die('Restricted access'); +\defined('_JEXEC') or die; // get the form $form = $displayData->getForm(); diff --git a/admin/layouts/open_ai_response/bible_left.php b/admin/layouts/open_ai_response/bible_left.php index 64cf483..5e1da38 100644 --- a/admin/layouts/open_ai_response/bible_left.php +++ b/admin/layouts/open_ai_response/bible_left.php @@ -16,7 +16,7 @@ /------------------------------------------------------------------------------------------------------*/ // No direct access to this file -defined('_JEXEC') or die('Restricted access'); +\defined('_JEXEC') or die; // get the form $form = $displayData->getForm(); diff --git a/admin/layouts/open_ai_response/bible_right.php b/admin/layouts/open_ai_response/bible_right.php index f526c49..63a1fed 100644 --- a/admin/layouts/open_ai_response/bible_right.php +++ b/admin/layouts/open_ai_response/bible_right.php @@ -16,7 +16,7 @@ /------------------------------------------------------------------------------------------------------*/ // No direct access to this file -defined('_JEXEC') or die('Restricted access'); +\defined('_JEXEC') or die; // get the form $form = $displayData->getForm(); diff --git a/admin/layouts/open_ai_response/details_above.php b/admin/layouts/open_ai_response/details_above.php index c387f09..a33571c 100644 --- a/admin/layouts/open_ai_response/details_above.php +++ b/admin/layouts/open_ai_response/details_above.php @@ -16,7 +16,7 @@ /------------------------------------------------------------------------------------------------------*/ // No direct access to this file -defined('_JEXEC') or die('Restricted access'); +defined('_JEXEC') or die; // get the form $form = $displayData->getForm(); @@ -31,21 +31,29 @@ $layout_path_array = explode('.', $this->getLayoutId()); $fields_tab_layout = 'fields_' . $layout_path_array[1]; // get the fields -$fields = $displayData->get($fields_tab_layout) ?: array( +$fields = $displayData->get($fields_tab_layout) ?: [ 'response_id', 'prompt' -); +]; + +// Ensure $fields is treated as an array and count its size. +$size = count((array) $fields); + +// Use a ternary operator to determine the class. +// If there are 1 to 4 fields, set the class to divide the 12-grid column equally among the fields. +// For more than 4 fields, default to four columns (3-grid each) for medium and larger screens. +$css_class = ($size > 0 && $size <= 4) ? 'col-12 col-md-' . round(12 / $size) : 'col-12 col-md-3'; $hiddenFields = $displayData->get('hidden_fields') ?: []; ?> -
+
setFieldAttribute($field, 'type', 'hidden'); ?> - renderField($field, null, null, array('class' => 'control-wrapper-' . $field)); ?> + renderField($field, null, null, ['class' => $css_class . ' control-wrapper-' . $field]); ?>
diff --git a/admin/layouts/open_ai_response/details_left.php b/admin/layouts/open_ai_response/details_left.php index c8b5859..1605b3f 100644 --- a/admin/layouts/open_ai_response/details_left.php +++ b/admin/layouts/open_ai_response/details_left.php @@ -16,7 +16,7 @@ /------------------------------------------------------------------------------------------------------*/ // No direct access to this file -defined('_JEXEC') or die('Restricted access'); +\defined('_JEXEC') or die; // get the form $form = $displayData->getForm(); diff --git a/admin/layouts/open_ai_response/details_right.php b/admin/layouts/open_ai_response/details_right.php index 5090aaa..b82467e 100644 --- a/admin/layouts/open_ai_response/details_right.php +++ b/admin/layouts/open_ai_response/details_right.php @@ -16,7 +16,7 @@ /------------------------------------------------------------------------------------------------------*/ // No direct access to this file -defined('_JEXEC') or die('Restricted access'); +\defined('_JEXEC') or die; // get the form $form = $displayData->getForm(); diff --git a/admin/layouts/open_ai_response/message_fullwidth.php b/admin/layouts/open_ai_response/message_fullwidth.php index 6b87433..69ef911 100644 --- a/admin/layouts/open_ai_response/message_fullwidth.php +++ b/admin/layouts/open_ai_response/message_fullwidth.php @@ -16,16 +16,18 @@ /------------------------------------------------------------------------------------------------------*/ // No direct access to this file -defined('_JEXEC') or die('Restricted access'); +\defined('_JEXEC') or die; use Joomla\CMS\Factory; use Joomla\CMS\Language\Text; use Joomla\CMS\HTML\HTMLHelper as Html; +use TrueChristianChurch\Component\Getbible\Administrator\Helper\GetbibleHelper; use VDM\Joomla\Utilities\StringHelper; +use VDM\Joomla\Utilities\ArrayHelper; // set the defaults $items = $displayData->vvymessage; -$user = Factory::getUser(); +$user = Factory::getApplication()->getIdentity(); $id = $displayData->item->id; // set the edit URL $edit = "index.php?option=com_getbible&view=open_ai_messages&task=open_ai_message.edit"; @@ -50,7 +52,7 @@ else ?>
- +
@@ -78,7 +80,9 @@ else $item): ?> authorise('core.manage', 'com_checkin') || $item->checked_out == $user->id || $item->checked_out == 0; - $userChkOut = Factory::getUser($item->checked_out); + $userChkOut = Factory::getContainer()-> + get(\Joomla\CMS\User\UserFactoryInterface::class)-> + loadUserById($item->checked_out); $canDo = GetbibleHelper::getActions('open_ai_message',$item,'open_ai_messages'); ?> diff --git a/admin/layouts/open_ai_response/prompt_left.php b/admin/layouts/open_ai_response/prompt_left.php index 04abae6..ab27aa3 100644 --- a/admin/layouts/open_ai_response/prompt_left.php +++ b/admin/layouts/open_ai_response/prompt_left.php @@ -16,7 +16,7 @@ /------------------------------------------------------------------------------------------------------*/ // No direct access to this file -defined('_JEXEC') or die('Restricted access'); +\defined('_JEXEC') or die; // get the form $form = $displayData->getForm(); diff --git a/admin/layouts/open_ai_response/prompt_right.php b/admin/layouts/open_ai_response/prompt_right.php index 29ff0e2..dfaa230 100644 --- a/admin/layouts/open_ai_response/prompt_right.php +++ b/admin/layouts/open_ai_response/prompt_right.php @@ -16,7 +16,7 @@ /------------------------------------------------------------------------------------------------------*/ // No direct access to this file -defined('_JEXEC') or die('Restricted access'); +\defined('_JEXEC') or die; // get the form $form = $displayData->getForm(); diff --git a/admin/layouts/open_ai_response/publishing.php b/admin/layouts/open_ai_response/publishing.php index 79c70bb..9aed60d 100644 --- a/admin/layouts/open_ai_response/publishing.php +++ b/admin/layouts/open_ai_response/publishing.php @@ -16,7 +16,7 @@ /------------------------------------------------------------------------------------------------------*/ // No direct access to this file -defined('_JEXEC') or die('Restricted access'); +\defined('_JEXEC') or die; // get the form $form = $displayData->getForm(); diff --git a/admin/layouts/open_ai_response/publlshing.php b/admin/layouts/open_ai_response/publlshing.php index ebe4ba7..0a086ef 100644 --- a/admin/layouts/open_ai_response/publlshing.php +++ b/admin/layouts/open_ai_response/publlshing.php @@ -16,7 +16,7 @@ /------------------------------------------------------------------------------------------------------*/ // No direct access to this file -defined('_JEXEC') or die('Restricted access'); +\defined('_JEXEC') or die; // get the form $form = $displayData->getForm(); diff --git a/admin/layouts/password/details_above.php b/admin/layouts/password/details_above.php index 540c924..2ae135a 100644 --- a/admin/layouts/password/details_above.php +++ b/admin/layouts/password/details_above.php @@ -16,7 +16,7 @@ /------------------------------------------------------------------------------------------------------*/ // No direct access to this file -defined('_JEXEC') or die('Restricted access'); +defined('_JEXEC') or die; // get the form $form = $displayData->getForm(); @@ -31,20 +31,28 @@ $layout_path_array = explode('.', $this->getLayoutId()); $fields_tab_layout = 'fields_' . $layout_path_array[1]; // get the fields -$fields = $displayData->get($fields_tab_layout) ?: array( +$fields = $displayData->get($fields_tab_layout) ?: [ 'linker' -); +]; + +// Ensure $fields is treated as an array and count its size. +$size = count((array) $fields); + +// Use a ternary operator to determine the class. +// If there are 1 to 4 fields, set the class to divide the 12-grid column equally among the fields. +// For more than 4 fields, default to four columns (3-grid each) for medium and larger screens. +$css_class = ($size > 0 && $size <= 4) ? 'col-12 col-md-' . round(12 / $size) : 'col-12 col-md-3'; $hiddenFields = $displayData->get('hidden_fields') ?: []; ?> -
+
setFieldAttribute($field, 'type', 'hidden'); ?> - renderField($field, null, null, array('class' => 'control-wrapper-' . $field)); ?> + renderField($field, null, null, ['class' => $css_class . ' control-wrapper-' . $field]); ?>
diff --git a/admin/layouts/password/details_left.php b/admin/layouts/password/details_left.php index 18d0070..18fb7f1 100644 --- a/admin/layouts/password/details_left.php +++ b/admin/layouts/password/details_left.php @@ -16,7 +16,7 @@ /------------------------------------------------------------------------------------------------------*/ // No direct access to this file -defined('_JEXEC') or die('Restricted access'); +\defined('_JEXEC') or die; // get the form $form = $displayData->getForm(); diff --git a/admin/layouts/password/details_right.php b/admin/layouts/password/details_right.php index bc5fb8f..8342f38 100644 --- a/admin/layouts/password/details_right.php +++ b/admin/layouts/password/details_right.php @@ -16,7 +16,7 @@ /------------------------------------------------------------------------------------------------------*/ // No direct access to this file -defined('_JEXEC') or die('Restricted access'); +\defined('_JEXEC') or die; // get the form $form = $displayData->getForm(); diff --git a/admin/layouts/password/publishing.php b/admin/layouts/password/publishing.php index e7b0b9b..eec45d1 100644 --- a/admin/layouts/password/publishing.php +++ b/admin/layouts/password/publishing.php @@ -16,7 +16,7 @@ /------------------------------------------------------------------------------------------------------*/ // No direct access to this file -defined('_JEXEC') or die('Restricted access'); +\defined('_JEXEC') or die; // get the form $form = $displayData->getForm(); diff --git a/admin/layouts/password/publlshing.php b/admin/layouts/password/publlshing.php index ebe4ba7..0a086ef 100644 --- a/admin/layouts/password/publlshing.php +++ b/admin/layouts/password/publlshing.php @@ -16,7 +16,7 @@ /------------------------------------------------------------------------------------------------------*/ // No direct access to this file -defined('_JEXEC') or die('Restricted access'); +\defined('_JEXEC') or die; // get the form $form = $displayData->getForm(); diff --git a/admin/layouts/prompt/open_ai_left.php b/admin/layouts/prompt/open_ai_left.php index 15735ef..2eb0caa 100644 --- a/admin/layouts/prompt/open_ai_left.php +++ b/admin/layouts/prompt/open_ai_left.php @@ -16,12 +16,13 @@ /------------------------------------------------------------------------------------------------------*/ // No direct access to this file -defined('JPATH_BASE') or die('Restricted access'); +defined('JPATH_BASE') or die; use Joomla\CMS\Factory; use Joomla\CMS\Language\Text; use Joomla\CMS\HTML\HTMLHelper as Html; use Joomla\CMS\Layout\LayoutHelper; +use TrueChristianChurch\Component\Getbible\Administrator\Helper\GetbibleHelper; use VDM\Joomla\Utilities\Component\Helper; // get the form diff --git a/admin/layouts/prompt/open_ai_right.php b/admin/layouts/prompt/open_ai_right.php index 0faad60..0861e58 100644 --- a/admin/layouts/prompt/open_ai_right.php +++ b/admin/layouts/prompt/open_ai_right.php @@ -16,12 +16,13 @@ /------------------------------------------------------------------------------------------------------*/ // No direct access to this file -defined('JPATH_BASE') or die('Restricted access'); +defined('JPATH_BASE') or die; use Joomla\CMS\Factory; use Joomla\CMS\Language\Text; use Joomla\CMS\HTML\HTMLHelper as Html; use Joomla\CMS\Layout\LayoutHelper; +use TrueChristianChurch\Component\Getbible\Administrator\Helper\GetbibleHelper; use VDM\Joomla\Utilities\Component\Helper; // get the form diff --git a/admin/layouts/prompt/prompt_above.php b/admin/layouts/prompt/prompt_above.php index d9c408b..e868398 100644 --- a/admin/layouts/prompt/prompt_above.php +++ b/admin/layouts/prompt/prompt_above.php @@ -16,7 +16,7 @@ /------------------------------------------------------------------------------------------------------*/ // No direct access to this file -defined('_JEXEC') or die('Restricted access'); +defined('_JEXEC') or die; // get the form $form = $displayData->getForm(); @@ -31,21 +31,29 @@ $layout_path_array = explode('.', $this->getLayoutId()); $fields_tab_layout = 'fields_' . $layout_path_array[1]; // get the fields -$fields = $displayData->get($fields_tab_layout) ?: array( +$fields = $displayData->get($fields_tab_layout) ?: [ 'name', 'abbreviation' -); +]; + +// Ensure $fields is treated as an array and count its size. +$size = count((array) $fields); + +// Use a ternary operator to determine the class. +// If there are 1 to 4 fields, set the class to divide the 12-grid column equally among the fields. +// For more than 4 fields, default to four columns (3-grid each) for medium and larger screens. +$css_class = ($size > 0 && $size <= 4) ? 'col-12 col-md-' . round(12 / $size) : 'col-12 col-md-3'; $hiddenFields = $displayData->get('hidden_fields') ?: []; ?> -
+
setFieldAttribute($field, 'type', 'hidden'); ?> - renderField($field, null, null, array('class' => 'control-wrapper-' . $field)); ?> + renderField($field, null, null, ['class' => $css_class . ' control-wrapper-' . $field]); ?>
diff --git a/admin/layouts/prompt/prompt_fullwidth.php b/admin/layouts/prompt/prompt_fullwidth.php index 021fb18..770cf62 100644 --- a/admin/layouts/prompt/prompt_fullwidth.php +++ b/admin/layouts/prompt/prompt_fullwidth.php @@ -16,7 +16,7 @@ /------------------------------------------------------------------------------------------------------*/ // No direct access to this file -defined('_JEXEC') or die('Restricted access'); +\defined('_JEXEC') or die; // get the form $form = $displayData->getForm(); diff --git a/admin/layouts/prompt/prompt_left.php b/admin/layouts/prompt/prompt_left.php index b42537e..8c3862f 100644 --- a/admin/layouts/prompt/prompt_left.php +++ b/admin/layouts/prompt/prompt_left.php @@ -16,7 +16,7 @@ /------------------------------------------------------------------------------------------------------*/ // No direct access to this file -defined('_JEXEC') or die('Restricted access'); +\defined('_JEXEC') or die; // get the form $form = $displayData->getForm(); diff --git a/admin/layouts/prompt/prompt_right.php b/admin/layouts/prompt/prompt_right.php index bd7aa95..723f65d 100644 --- a/admin/layouts/prompt/prompt_right.php +++ b/admin/layouts/prompt/prompt_right.php @@ -16,7 +16,7 @@ /------------------------------------------------------------------------------------------------------*/ // No direct access to this file -defined('_JEXEC') or die('Restricted access'); +\defined('_JEXEC') or die; // get the form $form = $displayData->getForm(); diff --git a/admin/layouts/prompt/publishing.php b/admin/layouts/prompt/publishing.php index e7b0b9b..eec45d1 100644 --- a/admin/layouts/prompt/publishing.php +++ b/admin/layouts/prompt/publishing.php @@ -16,7 +16,7 @@ /------------------------------------------------------------------------------------------------------*/ // No direct access to this file -defined('_JEXEC') or die('Restricted access'); +\defined('_JEXEC') or die; // get the form $form = $displayData->getForm(); diff --git a/admin/layouts/prompt/publlshing.php b/admin/layouts/prompt/publlshing.php index ebe4ba7..0a086ef 100644 --- a/admin/layouts/prompt/publlshing.php +++ b/admin/layouts/prompt/publlshing.php @@ -16,7 +16,7 @@ /------------------------------------------------------------------------------------------------------*/ // No direct access to this file -defined('_JEXEC') or die('Restricted access'); +\defined('_JEXEC') or die; // get the form $form = $displayData->getForm(); diff --git a/admin/layouts/tag/details_above.php b/admin/layouts/tag/details_above.php index 4f43f69..852df51 100644 --- a/admin/layouts/tag/details_above.php +++ b/admin/layouts/tag/details_above.php @@ -16,7 +16,7 @@ /------------------------------------------------------------------------------------------------------*/ // No direct access to this file -defined('_JEXEC') or die('Restricted access'); +defined('_JEXEC') or die; // get the form $form = $displayData->getForm(); @@ -31,21 +31,29 @@ $layout_path_array = explode('.', $this->getLayoutId()); $fields_tab_layout = 'fields_' . $layout_path_array[1]; // get the fields -$fields = $displayData->get($fields_tab_layout) ?: array( +$fields = $displayData->get($fields_tab_layout) ?: [ 'access', 'linker' -); +]; + +// Ensure $fields is treated as an array and count its size. +$size = count((array) $fields); + +// Use a ternary operator to determine the class. +// If there are 1 to 4 fields, set the class to divide the 12-grid column equally among the fields. +// For more than 4 fields, default to four columns (3-grid each) for medium and larger screens. +$css_class = ($size > 0 && $size <= 4) ? 'col-12 col-md-' . round(12 / $size) : 'col-12 col-md-3'; $hiddenFields = $displayData->get('hidden_fields') ?: []; ?> -
+
setFieldAttribute($field, 'type', 'hidden'); ?> - renderField($field, null, null, array('class' => 'control-wrapper-' . $field)); ?> + renderField($field, null, null, ['class' => $css_class . ' control-wrapper-' . $field]); ?>
diff --git a/admin/layouts/tag/details_fullwidth.php b/admin/layouts/tag/details_fullwidth.php index 2cdb5e2..159f35c 100644 --- a/admin/layouts/tag/details_fullwidth.php +++ b/admin/layouts/tag/details_fullwidth.php @@ -16,7 +16,7 @@ /------------------------------------------------------------------------------------------------------*/ // No direct access to this file -defined('_JEXEC') or die('Restricted access'); +\defined('_JEXEC') or die; // get the form $form = $displayData->getForm(); diff --git a/admin/layouts/tag/details_left.php b/admin/layouts/tag/details_left.php index 18d0070..18fb7f1 100644 --- a/admin/layouts/tag/details_left.php +++ b/admin/layouts/tag/details_left.php @@ -16,7 +16,7 @@ /------------------------------------------------------------------------------------------------------*/ // No direct access to this file -defined('_JEXEC') or die('Restricted access'); +\defined('_JEXEC') or die; // get the form $form = $displayData->getForm(); diff --git a/admin/layouts/tag/publishing.php b/admin/layouts/tag/publishing.php index e7b0b9b..eec45d1 100644 --- a/admin/layouts/tag/publishing.php +++ b/admin/layouts/tag/publishing.php @@ -16,7 +16,7 @@ /------------------------------------------------------------------------------------------------------*/ // No direct access to this file -defined('_JEXEC') or die('Restricted access'); +\defined('_JEXEC') or die; // get the form $form = $displayData->getForm(); diff --git a/admin/layouts/tag/publlshing.php b/admin/layouts/tag/publlshing.php index 8501906..38c3c49 100644 --- a/admin/layouts/tag/publlshing.php +++ b/admin/layouts/tag/publlshing.php @@ -16,7 +16,7 @@ /------------------------------------------------------------------------------------------------------*/ // No direct access to this file -defined('_JEXEC') or die('Restricted access'); +\defined('_JEXEC') or die; // get the form $form = $displayData->getForm(); diff --git a/admin/layouts/tagged_verse/details_above.php b/admin/layouts/tagged_verse/details_above.php index 45c96a1..bcec9cb 100644 --- a/admin/layouts/tagged_verse/details_above.php +++ b/admin/layouts/tagged_verse/details_above.php @@ -16,7 +16,7 @@ /------------------------------------------------------------------------------------------------------*/ // No direct access to this file -defined('_JEXEC') or die('Restricted access'); +defined('_JEXEC') or die; // get the form $form = $displayData->getForm(); @@ -31,22 +31,30 @@ $layout_path_array = explode('.', $this->getLayoutId()); $fields_tab_layout = 'fields_' . $layout_path_array[1]; // get the fields -$fields = $displayData->get($fields_tab_layout) ?: array( +$fields = $displayData->get($fields_tab_layout) ?: [ 'tag', 'access', 'linker' -); +]; + +// Ensure $fields is treated as an array and count its size. +$size = count((array) $fields); + +// Use a ternary operator to determine the class. +// If there are 1 to 4 fields, set the class to divide the 12-grid column equally among the fields. +// For more than 4 fields, default to four columns (3-grid each) for medium and larger screens. +$css_class = ($size > 0 && $size <= 4) ? 'col-12 col-md-' . round(12 / $size) : 'col-12 col-md-3'; $hiddenFields = $displayData->get('hidden_fields') ?: []; ?> -
+
setFieldAttribute($field, 'type', 'hidden'); ?> - renderField($field, null, null, array('class' => 'control-wrapper-' . $field)); ?> + renderField($field, null, null, ['class' => $css_class . ' control-wrapper-' . $field]); ?>
diff --git a/admin/layouts/tagged_verse/details_left.php b/admin/layouts/tagged_verse/details_left.php index cd1ba0b..f199ead 100644 --- a/admin/layouts/tagged_verse/details_left.php +++ b/admin/layouts/tagged_verse/details_left.php @@ -16,7 +16,7 @@ /------------------------------------------------------------------------------------------------------*/ // No direct access to this file -defined('_JEXEC') or die('Restricted access'); +\defined('_JEXEC') or die; // get the form $form = $displayData->getForm(); diff --git a/admin/layouts/tagged_verse/details_right.php b/admin/layouts/tagged_verse/details_right.php index 1a1a7a6..94cb3ae 100644 --- a/admin/layouts/tagged_verse/details_right.php +++ b/admin/layouts/tagged_verse/details_right.php @@ -16,7 +16,7 @@ /------------------------------------------------------------------------------------------------------*/ // No direct access to this file -defined('_JEXEC') or die('Restricted access'); +\defined('_JEXEC') or die; // get the form $form = $displayData->getForm(); diff --git a/admin/layouts/tagged_verse/publishing.php b/admin/layouts/tagged_verse/publishing.php index e7b0b9b..eec45d1 100644 --- a/admin/layouts/tagged_verse/publishing.php +++ b/admin/layouts/tagged_verse/publishing.php @@ -16,7 +16,7 @@ /------------------------------------------------------------------------------------------------------*/ // No direct access to this file -defined('_JEXEC') or die('Restricted access'); +\defined('_JEXEC') or die; // get the form $form = $displayData->getForm(); diff --git a/admin/layouts/tagged_verse/publlshing.php b/admin/layouts/tagged_verse/publlshing.php index 8501906..38c3c49 100644 --- a/admin/layouts/tagged_verse/publlshing.php +++ b/admin/layouts/tagged_verse/publlshing.php @@ -16,7 +16,7 @@ /------------------------------------------------------------------------------------------------------*/ // No direct access to this file -defined('_JEXEC') or die('Restricted access'); +\defined('_JEXEC') or die; // get the form $form = $displayData->getForm(); diff --git a/admin/layouts/translation/details_above.php b/admin/layouts/translation/details_above.php index 5a6b83a..ff44189 100644 --- a/admin/layouts/translation/details_above.php +++ b/admin/layouts/translation/details_above.php @@ -16,7 +16,7 @@ /------------------------------------------------------------------------------------------------------*/ // No direct access to this file -defined('_JEXEC') or die('Restricted access'); +defined('_JEXEC') or die; // get the form $form = $displayData->getForm(); @@ -31,22 +31,30 @@ $layout_path_array = explode('.', $this->getLayoutId()); $fields_tab_layout = 'fields_' . $layout_path_array[1]; // get the fields -$fields = $displayData->get($fields_tab_layout) ?: array( +$fields = $displayData->get($fields_tab_layout) ?: [ 'translation', 'abbreviation', 'direction' -); +]; + +// Ensure $fields is treated as an array and count its size. +$size = count((array) $fields); + +// Use a ternary operator to determine the class. +// If there are 1 to 4 fields, set the class to divide the 12-grid column equally among the fields. +// For more than 4 fields, default to four columns (3-grid each) for medium and larger screens. +$css_class = ($size > 0 && $size <= 4) ? 'col-12 col-md-' . round(12 / $size) : 'col-12 col-md-3'; $hiddenFields = $displayData->get('hidden_fields') ?: []; ?> -
+
setFieldAttribute($field, 'type', 'hidden'); ?> - renderField($field, null, null, array('class' => 'control-wrapper-' . $field)); ?> + renderField($field, null, null, ['class' => $css_class . ' control-wrapper-' . $field]); ?>
diff --git a/admin/layouts/translation/details_fullwidth.php b/admin/layouts/translation/details_fullwidth.php index 1e86e6e..6facad9 100644 --- a/admin/layouts/translation/details_fullwidth.php +++ b/admin/layouts/translation/details_fullwidth.php @@ -16,7 +16,7 @@ /------------------------------------------------------------------------------------------------------*/ // No direct access to this file -defined('_JEXEC') or die('Restricted access'); +\defined('_JEXEC') or die; // get the form $form = $displayData->getForm(); diff --git a/admin/layouts/translation/details_left.php b/admin/layouts/translation/details_left.php index de96e91..571cfe3 100644 --- a/admin/layouts/translation/details_left.php +++ b/admin/layouts/translation/details_left.php @@ -16,7 +16,7 @@ /------------------------------------------------------------------------------------------------------*/ // No direct access to this file -defined('_JEXEC') or die('Restricted access'); +\defined('_JEXEC') or die; // get the form $form = $displayData->getForm(); diff --git a/admin/layouts/translation/details_right.php b/admin/layouts/translation/details_right.php index c4b22b0..79cbb44 100644 --- a/admin/layouts/translation/details_right.php +++ b/admin/layouts/translation/details_right.php @@ -16,7 +16,7 @@ /------------------------------------------------------------------------------------------------------*/ // No direct access to this file -defined('_JEXEC') or die('Restricted access'); +\defined('_JEXEC') or die; // get the form $form = $displayData->getForm(); diff --git a/admin/layouts/translation/publishing.php b/admin/layouts/translation/publishing.php index 79c70bb..9aed60d 100644 --- a/admin/layouts/translation/publishing.php +++ b/admin/layouts/translation/publishing.php @@ -16,7 +16,7 @@ /------------------------------------------------------------------------------------------------------*/ // No direct access to this file -defined('_JEXEC') or die('Restricted access'); +\defined('_JEXEC') or die; // get the form $form = $displayData->getForm(); diff --git a/admin/layouts/translation/publlshing.php b/admin/layouts/translation/publlshing.php index ebe4ba7..0a086ef 100644 --- a/admin/layouts/translation/publlshing.php +++ b/admin/layouts/translation/publlshing.php @@ -16,7 +16,7 @@ /------------------------------------------------------------------------------------------------------*/ // No direct access to this file -defined('_JEXEC') or die('Restricted access'); +\defined('_JEXEC') or die; // get the form $form = $displayData->getForm(); diff --git a/admin/layouts/trashhelper.php b/admin/layouts/trashhelper.php index 7312627..aedbcf7 100644 --- a/admin/layouts/trashhelper.php +++ b/admin/layouts/trashhelper.php @@ -16,12 +16,13 @@ /------------------------------------------------------------------------------------------------------*/ // No direct access to this file -defined('JPATH_BASE') or die('Restricted access'); +defined('JPATH_BASE') or die; use Joomla\CMS\Factory; use Joomla\CMS\Language\Text; use Joomla\CMS\HTML\HTMLHelper as Html; use Joomla\CMS\Layout\LayoutHelper; +use TrueChristianChurch\Component\Getbible\Administrator\Helper\GetbibleHelper; diff --git a/admin/layouts/verse/details_above.php b/admin/layouts/verse/details_above.php index af05365..2692bdf 100644 --- a/admin/layouts/verse/details_above.php +++ b/admin/layouts/verse/details_above.php @@ -16,7 +16,7 @@ /------------------------------------------------------------------------------------------------------*/ // No direct access to this file -defined('_JEXEC') or die('Restricted access'); +defined('_JEXEC') or die; // get the form $form = $displayData->getForm(); @@ -31,22 +31,30 @@ $layout_path_array = explode('.', $this->getLayoutId()); $fields_tab_layout = 'fields_' . $layout_path_array[1]; // get the fields -$fields = $displayData->get($fields_tab_layout) ?: array( +$fields = $displayData->get($fields_tab_layout) ?: [ 'book_nr', 'chapter', 'verse' -); +]; + +// Ensure $fields is treated as an array and count its size. +$size = count((array) $fields); + +// Use a ternary operator to determine the class. +// If there are 1 to 4 fields, set the class to divide the 12-grid column equally among the fields. +// For more than 4 fields, default to four columns (3-grid each) for medium and larger screens. +$css_class = ($size > 0 && $size <= 4) ? 'col-12 col-md-' . round(12 / $size) : 'col-12 col-md-3'; $hiddenFields = $displayData->get('hidden_fields') ?: []; ?> -
+
setFieldAttribute($field, 'type', 'hidden'); ?> - renderField($field, null, null, array('class' => 'control-wrapper-' . $field)); ?> + renderField($field, null, null, ['class' => $css_class . ' control-wrapper-' . $field]); ?>
diff --git a/admin/layouts/verse/details_fullwidth.php b/admin/layouts/verse/details_fullwidth.php index 940bf50..264180e 100644 --- a/admin/layouts/verse/details_fullwidth.php +++ b/admin/layouts/verse/details_fullwidth.php @@ -16,7 +16,7 @@ /------------------------------------------------------------------------------------------------------*/ // No direct access to this file -defined('_JEXEC') or die('Restricted access'); +\defined('_JEXEC') or die; // get the form $form = $displayData->getForm(); diff --git a/admin/layouts/verse/details_left.php b/admin/layouts/verse/details_left.php index 0e92e27..184bc46 100644 --- a/admin/layouts/verse/details_left.php +++ b/admin/layouts/verse/details_left.php @@ -16,7 +16,7 @@ /------------------------------------------------------------------------------------------------------*/ // No direct access to this file -defined('_JEXEC') or die('Restricted access'); +\defined('_JEXEC') or die; // get the form $form = $displayData->getForm(); diff --git a/admin/layouts/verse/details_right.php b/admin/layouts/verse/details_right.php index 18d0070..18fb7f1 100644 --- a/admin/layouts/verse/details_right.php +++ b/admin/layouts/verse/details_right.php @@ -16,7 +16,7 @@ /------------------------------------------------------------------------------------------------------*/ // No direct access to this file -defined('_JEXEC') or die('Restricted access'); +\defined('_JEXEC') or die; // get the form $form = $displayData->getForm(); diff --git a/admin/layouts/verse/publishing.php b/admin/layouts/verse/publishing.php index 79c70bb..9aed60d 100644 --- a/admin/layouts/verse/publishing.php +++ b/admin/layouts/verse/publishing.php @@ -16,7 +16,7 @@ /------------------------------------------------------------------------------------------------------*/ // No direct access to this file -defined('_JEXEC') or die('Restricted access'); +\defined('_JEXEC') or die; // get the form $form = $displayData->getForm(); diff --git a/admin/layouts/verse/publlshing.php b/admin/layouts/verse/publlshing.php index ebe4ba7..0a086ef 100644 --- a/admin/layouts/verse/publlshing.php +++ b/admin/layouts/verse/publlshing.php @@ -16,7 +16,7 @@ /------------------------------------------------------------------------------------------------------*/ // No direct access to this file -defined('_JEXEC') or die('Restricted access'); +\defined('_JEXEC') or die; // get the form $form = $displayData->getForm(); diff --git a/admin/helpers/html/index.html b/admin/presets/index.html similarity index 100% rename from admin/helpers/html/index.html rename to admin/presets/index.html diff --git a/admin/helpers/index.html b/admin/services/index.html similarity index 100% rename from admin/helpers/index.html rename to admin/services/index.html diff --git a/admin/services/provider.php b/admin/services/provider.php new file mode 100644 index 0000000..d007002 --- /dev/null +++ b/admin/services/provider.php @@ -0,0 +1,123 @@ + + @git Get Bible + @github Get Bible + @support Get Bible + @copyright Copyright (C) 2015. All Rights Reserved + @license GNU/GPL Version 2 or later - http://www.gnu.org/licenses/gpl-2.0.html + +/------------------------------------------------------------------------------------------------------*/ + +// No direct access to this file +\defined('_JEXEC') or die; + +// register additional 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; + } +}); + +// (soon) use Joomla\CMS\Association\AssociationExtensionInterface; +use Joomla\CMS\Categories\CategoryFactoryInterface; +use Joomla\CMS\Component\Router\RouterFactoryInterface; +use Joomla\CMS\Dispatcher\ComponentDispatcherFactoryInterface; +use Joomla\CMS\Extension\ComponentInterface; +use Joomla\CMS\Extension\Service\Provider\CategoryFactory; +use Joomla\CMS\Extension\Service\Provider\ComponentDispatcherFactory; +use Joomla\CMS\Extension\Service\Provider\MVCFactory; +use Joomla\CMS\Extension\Service\Provider\RouterFactory; +use Joomla\CMS\HTML\Registry; +use Joomla\CMS\MVC\Factory\MVCFactoryInterface; +use TrueChristianChurch\Component\Getbible\Administrator\Extension\GetbibleComponent; +// (soon) use TrueChristianChurch\Component\Getbible\Administrator\Helper\AssociationsHelper; +use Joomla\DI\Container; +use Joomla\DI\ServiceProviderInterface; + +/** + * The TrueChristianChurch Getbible service provider. + * + * @since 4.0.0 + */ +return new class () implements ServiceProviderInterface +{ + /** + * Registers the service provider with a DI container. + * + * @param Container $container The DI container. + * + * @return void + * + * @since 4.0.0 + */ + public function register(Container $container) + { + // (soon) $container->set(AssociationExtensionInterface::class, new AssociationsHelper()); + + $container->registerServiceProvider(new CategoryFactory('\\TrueChristianChurch\\Component\\Getbible')); + $container->registerServiceProvider(new MVCFactory('\\TrueChristianChurch\\Component\\Getbible')); + $container->registerServiceProvider(new ComponentDispatcherFactory('\\TrueChristianChurch\\Component\\Getbible')); + $container->registerServiceProvider(new RouterFactory('\\TrueChristianChurch\\Component\\Getbible')); + + $container->set( + ComponentInterface::class, + function (Container $container) { + $component = new GetbibleComponent($container->get(ComponentDispatcherFactoryInterface::class)); + + $component->setRegistry($container->get(Registry::class)); + $component->setMVCFactory($container->get(MVCFactoryInterface::class)); + $component->setCategoryFactory($container->get(CategoryFactoryInterface::class)); + // (soon) $component->setAssociationExtension($container->get(AssociationExtensionInterface::class)); + $component->setRouterFactory($container->get(RouterFactoryInterface::class)); + + return $component; + } + ); + } +}; diff --git a/admin/sql/install.mysql.utf8.sql b/admin/sql/install.mysql.utf8.sql index bcbc777..a1b6359 100644 --- a/admin/sql/install.mysql.utf8.sql +++ b/admin/sql/install.mysql.utf8.sql @@ -320,8 +320,8 @@ CREATE TABLE IF NOT EXISTS `#__getbible_translation` ( `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_source` TEXT NOT NULL, + `distribution_sourcetype` VARCHAR(255) 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 '', diff --git a/admin/sql/updates/mysql/2.0.1.sql b/admin/sql/updates/mysql/2.0.1.sql deleted file mode 100644 index 8b13789..0000000 --- a/admin/sql/updates/mysql/2.0.1.sql +++ /dev/null @@ -1 +0,0 @@ - diff --git a/admin/sql/updates/mysql/2.0.11.sql b/admin/sql/updates/mysql/2.0.11.sql deleted file mode 100644 index 8b13789..0000000 --- a/admin/sql/updates/mysql/2.0.11.sql +++ /dev/null @@ -1 +0,0 @@ - diff --git a/admin/sql/updates/mysql/2.0.12.sql b/admin/sql/updates/mysql/2.0.12.sql deleted file mode 100644 index 8b13789..0000000 --- a/admin/sql/updates/mysql/2.0.12.sql +++ /dev/null @@ -1 +0,0 @@ - diff --git a/admin/sql/updates/mysql/2.0.13.sql b/admin/sql/updates/mysql/2.0.13.sql deleted file mode 100644 index 8b13789..0000000 --- a/admin/sql/updates/mysql/2.0.13.sql +++ /dev/null @@ -1 +0,0 @@ - diff --git a/admin/sql/updates/mysql/2.0.14.sql b/admin/sql/updates/mysql/2.0.14.sql deleted file mode 100644 index f5792ef..0000000 --- a/admin/sql/updates/mysql/2.0.14.sql +++ /dev/null @@ -1,3 +0,0 @@ -ALTER TABLE `#__getbible_linker` ADD `public_notes` TINYINT(1) NOT NULL DEFAULT 0 AFTER `name`; - -ALTER TABLE `#__getbible_linker` ADD `public_tagged_verses` TINYINT(1) NOT NULL DEFAULT 0 AFTER `public_notes`; diff --git a/admin/sql/updates/mysql/2.0.15.sql b/admin/sql/updates/mysql/2.0.15.sql deleted file mode 100644 index 8b13789..0000000 --- a/admin/sql/updates/mysql/2.0.15.sql +++ /dev/null @@ -1 +0,0 @@ - diff --git a/admin/sql/updates/mysql/2.0.16.sql b/admin/sql/updates/mysql/2.0.16.sql deleted file mode 100644 index 8b13789..0000000 --- a/admin/sql/updates/mysql/2.0.16.sql +++ /dev/null @@ -1 +0,0 @@ - diff --git a/admin/sql/updates/mysql/2.0.17.sql b/admin/sql/updates/mysql/2.0.17.sql deleted file mode 100644 index 8b13789..0000000 --- a/admin/sql/updates/mysql/2.0.17.sql +++ /dev/null @@ -1 +0,0 @@ - diff --git a/admin/sql/updates/mysql/2.0.18.sql b/admin/sql/updates/mysql/2.0.18.sql deleted file mode 100644 index 8b13789..0000000 --- a/admin/sql/updates/mysql/2.0.18.sql +++ /dev/null @@ -1 +0,0 @@ - diff --git a/admin/sql/updates/mysql/2.0.19.sql b/admin/sql/updates/mysql/2.0.19.sql deleted file mode 100644 index 8b13789..0000000 --- a/admin/sql/updates/mysql/2.0.19.sql +++ /dev/null @@ -1 +0,0 @@ - diff --git a/admin/sql/updates/mysql/2.0.2.sql b/admin/sql/updates/mysql/2.0.2.sql deleted file mode 100644 index 8b13789..0000000 --- a/admin/sql/updates/mysql/2.0.2.sql +++ /dev/null @@ -1 +0,0 @@ - diff --git a/admin/sql/updates/mysql/2.0.20.sql b/admin/sql/updates/mysql/2.0.20.sql deleted file mode 100644 index 8b13789..0000000 --- a/admin/sql/updates/mysql/2.0.20.sql +++ /dev/null @@ -1 +0,0 @@ - diff --git a/admin/sql/updates/mysql/2.0.21.sql b/admin/sql/updates/mysql/2.0.21.sql deleted file mode 100644 index 8b13789..0000000 --- a/admin/sql/updates/mysql/2.0.21.sql +++ /dev/null @@ -1 +0,0 @@ - diff --git a/admin/sql/updates/mysql/2.0.22.sql b/admin/sql/updates/mysql/2.0.22.sql deleted file mode 100644 index 8b13789..0000000 --- a/admin/sql/updates/mysql/2.0.22.sql +++ /dev/null @@ -1 +0,0 @@ - diff --git a/admin/sql/updates/mysql/2.0.23.sql b/admin/sql/updates/mysql/2.0.23.sql deleted file mode 100644 index 8b13789..0000000 --- a/admin/sql/updates/mysql/2.0.23.sql +++ /dev/null @@ -1 +0,0 @@ - diff --git a/admin/sql/updates/mysql/2.0.25.sql b/admin/sql/updates/mysql/2.0.25.sql deleted file mode 100644 index 8b13789..0000000 --- a/admin/sql/updates/mysql/2.0.25.sql +++ /dev/null @@ -1 +0,0 @@ - diff --git a/admin/sql/updates/mysql/2.0.26.sql b/admin/sql/updates/mysql/2.0.26.sql deleted file mode 100644 index 8b13789..0000000 --- a/admin/sql/updates/mysql/2.0.26.sql +++ /dev/null @@ -1 +0,0 @@ - diff --git a/admin/sql/updates/mysql/2.0.27.sql b/admin/sql/updates/mysql/2.0.27.sql deleted file mode 100644 index 8b13789..0000000 --- a/admin/sql/updates/mysql/2.0.27.sql +++ /dev/null @@ -1 +0,0 @@ - diff --git a/admin/sql/updates/mysql/2.0.28.sql b/admin/sql/updates/mysql/2.0.28.sql deleted file mode 100644 index 8b13789..0000000 --- a/admin/sql/updates/mysql/2.0.28.sql +++ /dev/null @@ -1 +0,0 @@ - diff --git a/admin/sql/updates/mysql/2.0.29.sql b/admin/sql/updates/mysql/2.0.29.sql deleted file mode 100644 index 8b13789..0000000 --- a/admin/sql/updates/mysql/2.0.29.sql +++ /dev/null @@ -1 +0,0 @@ - diff --git a/admin/sql/updates/mysql/2.0.3.sql b/admin/sql/updates/mysql/2.0.3.sql deleted file mode 100644 index 8b13789..0000000 --- a/admin/sql/updates/mysql/2.0.3.sql +++ /dev/null @@ -1 +0,0 @@ - diff --git a/admin/sql/updates/mysql/2.0.30.sql b/admin/sql/updates/mysql/2.0.30.sql deleted file mode 100644 index 8b13789..0000000 --- a/admin/sql/updates/mysql/2.0.30.sql +++ /dev/null @@ -1 +0,0 @@ - diff --git a/admin/sql/updates/mysql/2.0.31.sql b/admin/sql/updates/mysql/2.0.31.sql deleted file mode 100644 index 8b13789..0000000 --- a/admin/sql/updates/mysql/2.0.31.sql +++ /dev/null @@ -1 +0,0 @@ - diff --git a/admin/sql/updates/mysql/2.0.32.sql b/admin/sql/updates/mysql/2.0.32.sql deleted file mode 100644 index 8b13789..0000000 --- a/admin/sql/updates/mysql/2.0.32.sql +++ /dev/null @@ -1 +0,0 @@ - diff --git a/admin/sql/updates/mysql/2.0.4.sql b/admin/sql/updates/mysql/2.0.4.sql deleted file mode 100644 index 8b13789..0000000 --- a/admin/sql/updates/mysql/2.0.4.sql +++ /dev/null @@ -1 +0,0 @@ - diff --git a/admin/sql/updates/mysql/2.0.5.sql b/admin/sql/updates/mysql/2.0.5.sql deleted file mode 100644 index 8b13789..0000000 --- a/admin/sql/updates/mysql/2.0.5.sql +++ /dev/null @@ -1 +0,0 @@ - diff --git a/admin/sql/updates/mysql/2.0.6.sql b/admin/sql/updates/mysql/2.0.6.sql deleted file mode 100644 index 8b13789..0000000 --- a/admin/sql/updates/mysql/2.0.6.sql +++ /dev/null @@ -1 +0,0 @@ - diff --git a/admin/sql/updates/mysql/2.0.7.sql b/admin/sql/updates/mysql/2.0.7.sql deleted file mode 100644 index 8b13789..0000000 --- a/admin/sql/updates/mysql/2.0.7.sql +++ /dev/null @@ -1 +0,0 @@ - diff --git a/admin/sql/updates/mysql/2.0.8.sql b/admin/sql/updates/mysql/2.0.8.sql deleted file mode 100644 index 8b13789..0000000 --- a/admin/sql/updates/mysql/2.0.8.sql +++ /dev/null @@ -1 +0,0 @@ - diff --git a/admin/sql/updates/mysql/2.0.9.sql b/admin/sql/updates/mysql/2.0.9.sql deleted file mode 100644 index 8b13789..0000000 --- a/admin/sql/updates/mysql/2.0.9.sql +++ /dev/null @@ -1 +0,0 @@ - diff --git a/admin/layouts/index.html b/admin/sql/xml/index.html similarity index 100% rename from admin/layouts/index.html rename to admin/sql/xml/index.html diff --git a/admin/controllers/ajax.json.php b/admin/src/Controller/AjaxController.php similarity index 65% rename from admin/controllers/ajax.json.php rename to admin/src/Controller/AjaxController.php index b8d2e36..cbe5afd 100644 --- a/admin/controllers/ajax.json.php +++ b/admin/src/Controller/AjaxController.php @@ -14,29 +14,44 @@ @license GNU/GPL Version 2 or later - http://www.gnu.org/licenses/gpl-2.0.html /------------------------------------------------------------------------------------------------------*/ +namespace TrueChristianChurch\Component\Getbible\Administrator\Controller; // No direct access to this file -defined('_JEXEC') or die('Restricted access'); +\defined('_JEXEC') or die; use Joomla\CMS\Factory; +use Joomla\CMS\Application\CMSApplication; use Joomla\CMS\MVC\Controller\BaseController; +use Joomla\CMS\MVC\Factory\MVCFactoryInterface; use Joomla\CMS\Session\Session; +use Joomla\Input\Input; use Joomla\Utilities\ArrayHelper; /** * Getbible Ajax Base Controller */ -class GetbibleControllerAjax extends BaseController +class AjaxController extends BaseController { - public function __construct($config) + /** + * 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). + * @param ?MVCFactoryInterface $factory The factory. + * @param ?CMSApplication $app The Application for the dispatcher + * @param ?Input $input Input + * + * @since 3.0 + */ + public function __construct($config = [], ?MVCFactoryInterface $factory = null, ?CMSApplication $app = null, ?Input $input = null) { - parent::__construct($config); + parent::__construct($config, $factory, $app, $input); + // make sure all json stuff are set - Factory::getDocument()->setMimeEncoding( 'application/json' ); - // get the application - $app = Factory::getApplication(); - $app->setHeader('Content-Disposition','attachment;filename="getajax.json"'); - $app->setHeader('Access-Control-Allow-Origin', '*'); + $this->app->getDocument()->setMimeEncoding( 'application/json' ); + $this->app->setHeader('Content-Disposition','attachment;filename="getajax.json"'); + $this->app->setHeader('Access-Control-Allow-Origin', '*'); // load the tasks $this->registerTask('isNew', 'ajax'); $this->registerTask('isRead', 'ajax'); @@ -47,16 +62,16 @@ class GetbibleControllerAjax extends BaseController public function ajax() { // get the user for later use - $user = Factory::getUser(); + $user = $this->app->getIdentity(); // get the input values - $jinput = Factory::getApplication()->input; + $jinput = $this->input ?? $this->app->input; // check if we should return raw - $returnRaw = $jinput->get('raw', false, 'BOOLEAN'); + $returnRaw = $jinput->get('raw', false, 'BOOLEAN'); // return to a callback function - $callback = $jinput->get('callback', null, 'CMD'); + $callback = $jinput->get('callback', null, 'CMD'); // Check Token! - $token = Session::getFormToken(); - $call_token = $jinput->get('token', 0, 'ALNUM'); + $token = Session::getFormToken(); + $call_token = $jinput->get('token', 0, 'ALNUM'); if($jinput->get($token, 0, 'ALNUM') || $token === $call_token) { // get the task @@ -69,7 +84,15 @@ class GetbibleControllerAjax extends BaseController $noticeValue = $jinput->get('notice', NULL, 'STRING'); if($noticeValue && $user->id != 0) { - $result = $this->getModel('ajax')->isNew($noticeValue); + $ajaxModule = $this->getModel('ajax', 'Administrator'); + if ($ajaxModule) + { + $result = $ajaxModule->isNew($noticeValue); + } + else + { + $result = false; + } } else { @@ -110,7 +133,15 @@ class GetbibleControllerAjax extends BaseController $noticeValue = $jinput->get('notice', NULL, 'STRING'); if($noticeValue && $user->id != 0) { - $result = $this->getModel('ajax')->isRead($noticeValue); + $ajaxModule = $this->getModel('ajax', 'Administrator'); + if ($ajaxModule) + { + $result = $ajaxModule->isRead($noticeValue); + } + else + { + $result = false; + } } else { @@ -151,7 +182,15 @@ class GetbibleControllerAjax extends BaseController $nameValue = $jinput->get('name', NULL, 'WORD'); if($nameValue && $user->id != 0) { - $result = $this->getModel('ajax')->getWiki($nameValue); + $ajaxModule = $this->getModel('ajax', 'Administrator'); + if ($ajaxModule) + { + $result = $ajaxModule->getWiki($nameValue); + } + else + { + $result = false; + } } else { @@ -192,7 +231,15 @@ class GetbibleControllerAjax extends BaseController $versionValue = $jinput->get('version', NULL, 'INT'); if($versionValue && $user->id != 0) { - $result = $this->getModel('ajax')->getVersion($versionValue); + $ajaxModule = $this->getModel('ajax', 'Administrator'); + if ($ajaxModule) + { + $result = $ajaxModule->getVersion($versionValue); + } + else + { + $result = false; + } } else { diff --git a/admin/controllers/book.php b/admin/src/Controller/BookController.php similarity index 83% rename from admin/controllers/book.php rename to admin/src/Controller/BookController.php index 6df733b..0265b4a 100644 --- a/admin/controllers/book.php +++ b/admin/src/Controller/BookController.php @@ -14,24 +14,41 @@ @license GNU/GPL Version 2 or later - http://www.gnu.org/licenses/gpl-2.0.html /------------------------------------------------------------------------------------------------------*/ +namespace TrueChristianChurch\Component\Getbible\Administrator\Controller; // No direct access to this file -defined('_JEXEC') or die('Restricted access'); +\defined('_JEXEC') or die; use Joomla\CMS\Factory; use Joomla\CMS\Language\Text; +use Joomla\CMS\Form\FormFactoryInterface; +use Joomla\CMS\Application\CMSApplication; +use Joomla\CMS\MVC\Factory\MVCFactoryInterface; +use Joomla\Input\Input; +use Joomla\CMS\Versioning\VersionableControllerTrait; use Joomla\CMS\MVC\Controller\FormController; use Joomla\CMS\MVC\Model\BaseDatabaseModel; use Joomla\Utilities\ArrayHelper; use Joomla\CMS\Router\Route; use Joomla\CMS\Session\Session; use Joomla\CMS\Uri\Uri; +use TrueChristianChurch\Component\Getbible\Administrator\Helper\GetbibleHelper; /** * Book Form Controller */ -class GetbibleControllerBook extends FormController +class BookController extends FormController { + use VersionableControllerTrait; + + /** + * The prefix to use with controller messages. + * + * @var string + * @since 1.6 + */ + protected $text_prefix = 'COM_GETBIBLE_BOOK'; + /** * Current or most recently performed task. * @@ -42,16 +59,29 @@ class GetbibleControllerBook extends FormController protected $task; /** - * Class constructor. + * Constructor. * - * @param array $config A named array of configuration variables. + * @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). + * @param MVCFactoryInterface|null $factory The factory. + * @param CMSApplication|null $app The Application for the dispatcher + * @param Input|null $input Input + * @param FormFactoryInterface|null $formFactory The form factory. * - * @since 1.6 + * @since 3.0 */ - public function __construct($config = []) - { + public function __construct( + $config = [], + ?MVCFactoryInterface $factory = null, + ?CMSApplication $app = null, + ?Input $input = null, + ?FormFactoryInterface $formFactory = null + ) { + parent::__construct($config, $factory, $app, $input, $formFactory); + $this->view_list = 'Books'; // safeguard for setting the return view listing to the main view. - parent::__construct($config); }###ADMIN_CUSTOM_BUTTONS_CONTROLLER### /** @@ -66,7 +96,7 @@ class GetbibleControllerBook extends FormController protected function allowAdd($data = []) { // Get user object. - $user = Factory::getUser(); + $user = $this->app->getIdentity(); // Access check. $access = $user->authorise('book.access', 'com_getbible'); if (!$access) @@ -91,7 +121,7 @@ class GetbibleControllerBook extends FormController protected function allowEdit($data = [], $key = 'id') { // get user object. - $user = Factory::getUser(); + $user = $this->app->getIdentity(); // get record id. $recordId = (int) isset($data[$key]) ? $data[$key] : 0; diff --git a/admin/controllers/books.php b/admin/src/Controller/BooksController.php similarity index 91% rename from admin/controllers/books.php rename to admin/src/Controller/BooksController.php index 1bafb39..3daa0d1 100644 --- a/admin/controllers/books.php +++ b/admin/src/Controller/BooksController.php @@ -14,9 +14,10 @@ @license GNU/GPL Version 2 or later - http://www.gnu.org/licenses/gpl-2.0.html /------------------------------------------------------------------------------------------------------*/ +namespace TrueChristianChurch\Component\Getbible\Administrator\Controller; // No direct access to this file -defined('_JEXEC') or die('Restricted access'); +\defined('_JEXEC') or die; use Joomla\CMS\Factory; use Joomla\CMS\Language\Text; @@ -24,13 +25,14 @@ use Joomla\CMS\MVC\Controller\AdminController; use Joomla\Utilities\ArrayHelper; use Joomla\CMS\Router\Route; use Joomla\CMS\Session\Session; +use TrueChristianChurch\Component\Getbible\Administrator\Helper\GetbibleHelper; use VDM\Joomla\Utilities\ArrayHelper as UtilitiesArrayHelper; use VDM\Joomla\GetBible\Factory as GetBibleFactory; /** * Books Admin Controller */ -class GetbibleControllerBooks extends AdminController +class BooksController extends AdminController { /** * The prefix to use with controller messages. @@ -41,17 +43,17 @@ class GetbibleControllerBooks extends AdminController protected $text_prefix = 'COM_GETBIBLE_BOOKS'; /** - * Method to get a model object, loading it if required. + * Proxy for getModel. * * @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. + * @return \Joomla\CMS\MVC\Model\BaseDatabaseModel * * @since 1.6 */ - public function getModel($name = 'Book', $prefix = 'GetbibleModel', $config = array('ignore_request' => true)) + public function getModel($name = 'Book', $prefix = 'Administrator', $config = ['ignore_request' => true]) { return parent::getModel($name, $prefix, $config); } diff --git a/admin/controllers/chapter.php b/admin/src/Controller/ChapterController.php similarity index 83% rename from admin/controllers/chapter.php rename to admin/src/Controller/ChapterController.php index e33609f..5b595c2 100644 --- a/admin/controllers/chapter.php +++ b/admin/src/Controller/ChapterController.php @@ -14,24 +14,41 @@ @license GNU/GPL Version 2 or later - http://www.gnu.org/licenses/gpl-2.0.html /------------------------------------------------------------------------------------------------------*/ +namespace TrueChristianChurch\Component\Getbible\Administrator\Controller; // No direct access to this file -defined('_JEXEC') or die('Restricted access'); +\defined('_JEXEC') or die; use Joomla\CMS\Factory; use Joomla\CMS\Language\Text; +use Joomla\CMS\Form\FormFactoryInterface; +use Joomla\CMS\Application\CMSApplication; +use Joomla\CMS\MVC\Factory\MVCFactoryInterface; +use Joomla\Input\Input; +use Joomla\CMS\Versioning\VersionableControllerTrait; use Joomla\CMS\MVC\Controller\FormController; use Joomla\CMS\MVC\Model\BaseDatabaseModel; use Joomla\Utilities\ArrayHelper; use Joomla\CMS\Router\Route; use Joomla\CMS\Session\Session; use Joomla\CMS\Uri\Uri; +use TrueChristianChurch\Component\Getbible\Administrator\Helper\GetbibleHelper; /** * Chapter Form Controller */ -class GetbibleControllerChapter extends FormController +class ChapterController extends FormController { + use VersionableControllerTrait; + + /** + * The prefix to use with controller messages. + * + * @var string + * @since 1.6 + */ + protected $text_prefix = 'COM_GETBIBLE_CHAPTER'; + /** * Current or most recently performed task. * @@ -42,16 +59,29 @@ class GetbibleControllerChapter extends FormController protected $task; /** - * Class constructor. + * Constructor. * - * @param array $config A named array of configuration variables. + * @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). + * @param MVCFactoryInterface|null $factory The factory. + * @param CMSApplication|null $app The Application for the dispatcher + * @param Input|null $input Input + * @param FormFactoryInterface|null $formFactory The form factory. * - * @since 1.6 + * @since 3.0 */ - public function __construct($config = []) - { + public function __construct( + $config = [], + ?MVCFactoryInterface $factory = null, + ?CMSApplication $app = null, + ?Input $input = null, + ?FormFactoryInterface $formFactory = null + ) { + parent::__construct($config, $factory, $app, $input, $formFactory); + $this->view_list = 'Chapters'; // safeguard for setting the return view listing to the main view. - parent::__construct($config); }###ADMIN_CUSTOM_BUTTONS_CONTROLLER### /** @@ -66,7 +96,7 @@ class GetbibleControllerChapter extends FormController protected function allowAdd($data = []) { // Get user object. - $user = Factory::getUser(); + $user = $this->app->getIdentity(); // Access check. $access = $user->authorise('chapter.access', 'com_getbible'); if (!$access) @@ -91,7 +121,7 @@ class GetbibleControllerChapter extends FormController protected function allowEdit($data = [], $key = 'id') { // get user object. - $user = Factory::getUser(); + $user = $this->app->getIdentity(); // get record id. $recordId = (int) isset($data[$key]) ? $data[$key] : 0; diff --git a/admin/controllers/chapters.php b/admin/src/Controller/ChaptersController.php similarity index 78% rename from admin/controllers/chapters.php rename to admin/src/Controller/ChaptersController.php index 5f6a8de..2100ea7 100644 --- a/admin/controllers/chapters.php +++ b/admin/src/Controller/ChaptersController.php @@ -14,9 +14,10 @@ @license GNU/GPL Version 2 or later - http://www.gnu.org/licenses/gpl-2.0.html /------------------------------------------------------------------------------------------------------*/ +namespace TrueChristianChurch\Component\Getbible\Administrator\Controller; // No direct access to this file -defined('_JEXEC') or die('Restricted access'); +\defined('_JEXEC') or die; use Joomla\CMS\Factory; use Joomla\CMS\Language\Text; @@ -24,11 +25,12 @@ use Joomla\CMS\MVC\Controller\AdminController; use Joomla\Utilities\ArrayHelper; use Joomla\CMS\Router\Route; use Joomla\CMS\Session\Session; +use TrueChristianChurch\Component\Getbible\Administrator\Helper\GetbibleHelper; /** * Chapters Admin Controller */ -class GetbibleControllerChapters extends AdminController +class ChaptersController extends AdminController { /** * The prefix to use with controller messages. @@ -39,17 +41,17 @@ class GetbibleControllerChapters extends AdminController protected $text_prefix = 'COM_GETBIBLE_CHAPTERS'; /** - * Method to get a model object, loading it if required. + * Proxy for getModel. * * @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. + * @return \Joomla\CMS\MVC\Model\BaseDatabaseModel * * @since 1.6 */ - public function getModel($name = 'Chapter', $prefix = 'GetbibleModel', $config = array('ignore_request' => true)) + public function getModel($name = 'Chapter', $prefix = 'Administrator', $config = ['ignore_request' => true]) { return parent::getModel($name, $prefix, $config); } diff --git a/admin/src/Controller/DisplayController.php b/admin/src/Controller/DisplayController.php new file mode 100644 index 0000000..0197477 --- /dev/null +++ b/admin/src/Controller/DisplayController.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 + +/------------------------------------------------------------------------------------------------------*/ +namespace TrueChristianChurch\Component\Getbible\Administrator\Controller; + +// No direct access to this file +\defined('_JEXEC') or die; + +use Joomla\CMS\MVC\Controller\BaseController; +use Joomla\Utilities\ArrayHelper; +use Joomla\CMS\Language\Text; +use Joomla\CMS\Router\Route; + +/** + * Getbible master admin display controller. + * + * @since 4.0 + */ +class DisplayController extends BaseController +{ + /** + * The default view. + * + * @var string + * @since 1.0.0 + */ + protected $default_view = 'getbible'; + + /** + * display task + * + * @return void + */ + function display($cachable = false, $urlparams = false) + { + return parent::display($cachable, $urlparams); + } +} diff --git a/admin/controllers/getbible.php b/admin/src/Controller/GetbibleController.php similarity index 82% rename from admin/controllers/getbible.php rename to admin/src/Controller/GetbibleController.php index 43f34e6..382c794 100644 --- a/admin/controllers/getbible.php +++ b/admin/src/Controller/GetbibleController.php @@ -14,9 +14,10 @@ @license GNU/GPL Version 2 or later - http://www.gnu.org/licenses/gpl-2.0.html /------------------------------------------------------------------------------------------------------*/ +namespace TrueChristianChurch\Component\Getbible\Administrator\Controller; // No direct access to this file -defined('_JEXEC') or die('Restricted access'); +\defined('_JEXEC') or die; use Joomla\CMS\Factory; use Joomla\CMS\Language\Text; @@ -24,11 +25,12 @@ use Joomla\CMS\MVC\Controller\AdminController; use Joomla\Utilities\ArrayHelper; use Joomla\CMS\Router\Route; use Joomla\CMS\Session\Session; +use TrueChristianChurch\Component\Getbible\Administrator\Helper\GetbibleHelper; /** * Getbible Admin Controller */ -class GetbibleControllerGetbible extends AdminController +class GetbibleController extends AdminController { } diff --git a/admin/controllers/linker.php b/admin/src/Controller/LinkerController.php similarity index 83% rename from admin/controllers/linker.php rename to admin/src/Controller/LinkerController.php index 6b2d133..ada5c03 100644 --- a/admin/controllers/linker.php +++ b/admin/src/Controller/LinkerController.php @@ -14,24 +14,41 @@ @license GNU/GPL Version 2 or later - http://www.gnu.org/licenses/gpl-2.0.html /------------------------------------------------------------------------------------------------------*/ +namespace TrueChristianChurch\Component\Getbible\Administrator\Controller; // No direct access to this file -defined('_JEXEC') or die('Restricted access'); +\defined('_JEXEC') or die; use Joomla\CMS\Factory; use Joomla\CMS\Language\Text; +use Joomla\CMS\Form\FormFactoryInterface; +use Joomla\CMS\Application\CMSApplication; +use Joomla\CMS\MVC\Factory\MVCFactoryInterface; +use Joomla\Input\Input; +use Joomla\CMS\Versioning\VersionableControllerTrait; use Joomla\CMS\MVC\Controller\FormController; use Joomla\CMS\MVC\Model\BaseDatabaseModel; use Joomla\Utilities\ArrayHelper; use Joomla\CMS\Router\Route; use Joomla\CMS\Session\Session; use Joomla\CMS\Uri\Uri; +use TrueChristianChurch\Component\Getbible\Administrator\Helper\GetbibleHelper; /** * Linker Form Controller */ -class GetbibleControllerLinker extends FormController +class LinkerController extends FormController { + use VersionableControllerTrait; + + /** + * The prefix to use with controller messages. + * + * @var string + * @since 1.6 + */ + protected $text_prefix = 'COM_GETBIBLE_LINKER'; + /** * Current or most recently performed task. * @@ -42,16 +59,29 @@ class GetbibleControllerLinker extends FormController protected $task; /** - * Class constructor. + * Constructor. * - * @param array $config A named array of configuration variables. + * @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). + * @param MVCFactoryInterface|null $factory The factory. + * @param CMSApplication|null $app The Application for the dispatcher + * @param Input|null $input Input + * @param FormFactoryInterface|null $formFactory The form factory. * - * @since 1.6 + * @since 3.0 */ - public function __construct($config = []) - { + public function __construct( + $config = [], + ?MVCFactoryInterface $factory = null, + ?CMSApplication $app = null, + ?Input $input = null, + ?FormFactoryInterface $formFactory = null + ) { + parent::__construct($config, $factory, $app, $input, $formFactory); + $this->view_list = 'Linkers'; // safeguard for setting the return view listing to the main view. - parent::__construct($config); } /** @@ -66,7 +96,7 @@ class GetbibleControllerLinker extends FormController protected function allowAdd($data = []) { // Get user object. - $user = Factory::getUser(); + $user = $this->app->getIdentity(); // Access check. $access = $user->authorise('linker.access', 'com_getbible'); if (!$access) @@ -91,7 +121,7 @@ class GetbibleControllerLinker extends FormController protected function allowEdit($data = [], $key = 'id') { // get user object. - $user = Factory::getUser(); + $user = $this->app->getIdentity(); // get record id. $recordId = (int) isset($data[$key]) ? $data[$key] : 0; diff --git a/admin/controllers/linkers.php b/admin/src/Controller/LinkersController.php similarity index 78% rename from admin/controllers/linkers.php rename to admin/src/Controller/LinkersController.php index 3ea23ee..ae0836d 100644 --- a/admin/controllers/linkers.php +++ b/admin/src/Controller/LinkersController.php @@ -14,9 +14,10 @@ @license GNU/GPL Version 2 or later - http://www.gnu.org/licenses/gpl-2.0.html /------------------------------------------------------------------------------------------------------*/ +namespace TrueChristianChurch\Component\Getbible\Administrator\Controller; // No direct access to this file -defined('_JEXEC') or die('Restricted access'); +\defined('_JEXEC') or die; use Joomla\CMS\Factory; use Joomla\CMS\Language\Text; @@ -24,11 +25,12 @@ use Joomla\CMS\MVC\Controller\AdminController; use Joomla\Utilities\ArrayHelper; use Joomla\CMS\Router\Route; use Joomla\CMS\Session\Session; +use TrueChristianChurch\Component\Getbible\Administrator\Helper\GetbibleHelper; /** * Linkers Admin Controller */ -class GetbibleControllerLinkers extends AdminController +class LinkersController extends AdminController { /** * The prefix to use with controller messages. @@ -39,17 +41,17 @@ class GetbibleControllerLinkers extends AdminController protected $text_prefix = 'COM_GETBIBLE_LINKERS'; /** - * Method to get a model object, loading it if required. + * Proxy for getModel. * * @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. + * @return \Joomla\CMS\MVC\Model\BaseDatabaseModel * * @since 1.6 */ - public function getModel($name = 'Linker', $prefix = 'GetbibleModel', $config = array('ignore_request' => true)) + public function getModel($name = 'Linker', $prefix = 'Administrator', $config = ['ignore_request' => true]) { return parent::getModel($name, $prefix, $config); } diff --git a/admin/controllers/note.php b/admin/src/Controller/NoteController.php similarity index 83% rename from admin/controllers/note.php rename to admin/src/Controller/NoteController.php index 02c7a94..dab7fad 100644 --- a/admin/controllers/note.php +++ b/admin/src/Controller/NoteController.php @@ -14,24 +14,41 @@ @license GNU/GPL Version 2 or later - http://www.gnu.org/licenses/gpl-2.0.html /------------------------------------------------------------------------------------------------------*/ +namespace TrueChristianChurch\Component\Getbible\Administrator\Controller; // No direct access to this file -defined('_JEXEC') or die('Restricted access'); +\defined('_JEXEC') or die; use Joomla\CMS\Factory; use Joomla\CMS\Language\Text; +use Joomla\CMS\Form\FormFactoryInterface; +use Joomla\CMS\Application\CMSApplication; +use Joomla\CMS\MVC\Factory\MVCFactoryInterface; +use Joomla\Input\Input; +use Joomla\CMS\Versioning\VersionableControllerTrait; use Joomla\CMS\MVC\Controller\FormController; use Joomla\CMS\MVC\Model\BaseDatabaseModel; use Joomla\Utilities\ArrayHelper; use Joomla\CMS\Router\Route; use Joomla\CMS\Session\Session; use Joomla\CMS\Uri\Uri; +use TrueChristianChurch\Component\Getbible\Administrator\Helper\GetbibleHelper; /** * Note Form Controller */ -class GetbibleControllerNote extends FormController +class NoteController extends FormController { + use VersionableControllerTrait; + + /** + * The prefix to use with controller messages. + * + * @var string + * @since 1.6 + */ + protected $text_prefix = 'COM_GETBIBLE_NOTE'; + /** * Current or most recently performed task. * @@ -42,16 +59,29 @@ class GetbibleControllerNote extends FormController protected $task; /** - * Class constructor. + * Constructor. * - * @param array $config A named array of configuration variables. + * @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). + * @param MVCFactoryInterface|null $factory The factory. + * @param CMSApplication|null $app The Application for the dispatcher + * @param Input|null $input Input + * @param FormFactoryInterface|null $formFactory The form factory. * - * @since 1.6 + * @since 3.0 */ - public function __construct($config = []) - { + public function __construct( + $config = [], + ?MVCFactoryInterface $factory = null, + ?CMSApplication $app = null, + ?Input $input = null, + ?FormFactoryInterface $formFactory = null + ) { + parent::__construct($config, $factory, $app, $input, $formFactory); + $this->view_list = 'Notes'; // safeguard for setting the return view listing to the main view. - parent::__construct($config); } /** @@ -66,7 +96,7 @@ class GetbibleControllerNote extends FormController protected function allowAdd($data = []) { // Get user object. - $user = Factory::getUser(); + $user = $this->app->getIdentity(); // Access check. $access = $user->authorise('note.access', 'com_getbible'); if (!$access) @@ -91,7 +121,7 @@ class GetbibleControllerNote extends FormController protected function allowEdit($data = [], $key = 'id') { // get user object. - $user = Factory::getUser(); + $user = $this->app->getIdentity(); // get record id. $recordId = (int) isset($data[$key]) ? $data[$key] : 0; diff --git a/admin/controllers/notes.php b/admin/src/Controller/NotesController.php similarity index 78% rename from admin/controllers/notes.php rename to admin/src/Controller/NotesController.php index d32f287..c397950 100644 --- a/admin/controllers/notes.php +++ b/admin/src/Controller/NotesController.php @@ -14,9 +14,10 @@ @license GNU/GPL Version 2 or later - http://www.gnu.org/licenses/gpl-2.0.html /------------------------------------------------------------------------------------------------------*/ +namespace TrueChristianChurch\Component\Getbible\Administrator\Controller; // No direct access to this file -defined('_JEXEC') or die('Restricted access'); +\defined('_JEXEC') or die; use Joomla\CMS\Factory; use Joomla\CMS\Language\Text; @@ -24,11 +25,12 @@ use Joomla\CMS\MVC\Controller\AdminController; use Joomla\Utilities\ArrayHelper; use Joomla\CMS\Router\Route; use Joomla\CMS\Session\Session; +use TrueChristianChurch\Component\Getbible\Administrator\Helper\GetbibleHelper; /** * Notes Admin Controller */ -class GetbibleControllerNotes extends AdminController +class NotesController extends AdminController { /** * The prefix to use with controller messages. @@ -39,17 +41,17 @@ class GetbibleControllerNotes extends AdminController protected $text_prefix = 'COM_GETBIBLE_NOTES'; /** - * Method to get a model object, loading it if required. + * Proxy for getModel. * * @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. + * @return \Joomla\CMS\MVC\Model\BaseDatabaseModel * * @since 1.6 */ - public function getModel($name = 'Note', $prefix = 'GetbibleModel', $config = array('ignore_request' => true)) + public function getModel($name = 'Note', $prefix = 'Administrator', $config = ['ignore_request' => true]) { return parent::getModel($name, $prefix, $config); } diff --git a/admin/controllers/open_ai_message.php b/admin/src/Controller/Open_ai_messageController.php similarity index 83% rename from admin/controllers/open_ai_message.php rename to admin/src/Controller/Open_ai_messageController.php index 82b4585..a6077eb 100644 --- a/admin/controllers/open_ai_message.php +++ b/admin/src/Controller/Open_ai_messageController.php @@ -14,24 +14,41 @@ @license GNU/GPL Version 2 or later - http://www.gnu.org/licenses/gpl-2.0.html /------------------------------------------------------------------------------------------------------*/ +namespace TrueChristianChurch\Component\Getbible\Administrator\Controller; // No direct access to this file -defined('_JEXEC') or die('Restricted access'); +\defined('_JEXEC') or die; use Joomla\CMS\Factory; use Joomla\CMS\Language\Text; +use Joomla\CMS\Form\FormFactoryInterface; +use Joomla\CMS\Application\CMSApplication; +use Joomla\CMS\MVC\Factory\MVCFactoryInterface; +use Joomla\Input\Input; +use Joomla\CMS\Versioning\VersionableControllerTrait; use Joomla\CMS\MVC\Controller\FormController; use Joomla\CMS\MVC\Model\BaseDatabaseModel; use Joomla\Utilities\ArrayHelper; use Joomla\CMS\Router\Route; use Joomla\CMS\Session\Session; use Joomla\CMS\Uri\Uri; +use TrueChristianChurch\Component\Getbible\Administrator\Helper\GetbibleHelper; /** * Open_ai_message Form Controller */ -class GetbibleControllerOpen_ai_message extends FormController +class Open_ai_messageController extends FormController { + use VersionableControllerTrait; + + /** + * The prefix to use with controller messages. + * + * @var string + * @since 1.6 + */ + protected $text_prefix = 'COM_GETBIBLE_OPEN_AI_MESSAGE'; + /** * Current or most recently performed task. * @@ -42,16 +59,29 @@ class GetbibleControllerOpen_ai_message extends FormController protected $task; /** - * Class constructor. + * Constructor. * - * @param array $config A named array of configuration variables. + * @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). + * @param MVCFactoryInterface|null $factory The factory. + * @param CMSApplication|null $app The Application for the dispatcher + * @param Input|null $input Input + * @param FormFactoryInterface|null $formFactory The form factory. * - * @since 1.6 + * @since 3.0 */ - public function __construct($config = []) - { + public function __construct( + $config = [], + ?MVCFactoryInterface $factory = null, + ?CMSApplication $app = null, + ?Input $input = null, + ?FormFactoryInterface $formFactory = null + ) { + parent::__construct($config, $factory, $app, $input, $formFactory); + $this->view_list = 'Open_ai_messages'; // safeguard for setting the return view listing to the main view. - parent::__construct($config); } /** @@ -66,7 +96,7 @@ class GetbibleControllerOpen_ai_message extends FormController protected function allowAdd($data = []) { // Get user object. - $user = Factory::getUser(); + $user = $this->app->getIdentity(); // Access check. $access = $user->authorise('open_ai_message.access', 'com_getbible'); if (!$access) @@ -91,7 +121,7 @@ class GetbibleControllerOpen_ai_message extends FormController protected function allowEdit($data = [], $key = 'id') { // get user object. - $user = Factory::getUser(); + $user = $this->app->getIdentity(); // get record id. $recordId = (int) isset($data[$key]) ? $data[$key] : 0; diff --git a/admin/controllers/open_ai_messages.php b/admin/src/Controller/Open_ai_messagesController.php similarity index 81% rename from admin/controllers/open_ai_messages.php rename to admin/src/Controller/Open_ai_messagesController.php index 8bd56da..d9e7d6b 100644 --- a/admin/controllers/open_ai_messages.php +++ b/admin/src/Controller/Open_ai_messagesController.php @@ -14,9 +14,10 @@ @license GNU/GPL Version 2 or later - http://www.gnu.org/licenses/gpl-2.0.html /------------------------------------------------------------------------------------------------------*/ +namespace TrueChristianChurch\Component\Getbible\Administrator\Controller; // No direct access to this file -defined('_JEXEC') or die('Restricted access'); +\defined('_JEXEC') or die; use Joomla\CMS\Factory; use Joomla\CMS\Language\Text; @@ -24,11 +25,12 @@ use Joomla\CMS\MVC\Controller\AdminController; use Joomla\Utilities\ArrayHelper; use Joomla\CMS\Router\Route; use Joomla\CMS\Session\Session; +use TrueChristianChurch\Component\Getbible\Administrator\Helper\GetbibleHelper; /** * Open_ai_messages Admin Controller */ -class GetbibleControllerOpen_ai_messages extends AdminController +class Open_ai_messagesController extends AdminController { /** * The prefix to use with controller messages. @@ -39,17 +41,17 @@ class GetbibleControllerOpen_ai_messages extends AdminController protected $text_prefix = 'COM_GETBIBLE_OPEN_AI_MESSAGES'; /** - * Method to get a model object, loading it if required. + * Proxy for getModel. * * @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. + * @return \Joomla\CMS\MVC\Model\BaseDatabaseModel * * @since 1.6 */ - public function getModel($name = 'Open_ai_message', $prefix = 'GetbibleModel', $config = array('ignore_request' => true)) + public function getModel($name = 'Open_ai_message', $prefix = 'Administrator', $config = ['ignore_request' => true]) { return parent::getModel($name, $prefix, $config); } diff --git a/admin/controllers/open_ai_response.php b/admin/src/Controller/Open_ai_responseController.php similarity index 83% rename from admin/controllers/open_ai_response.php rename to admin/src/Controller/Open_ai_responseController.php index 82f1d03..c8f6796 100644 --- a/admin/controllers/open_ai_response.php +++ b/admin/src/Controller/Open_ai_responseController.php @@ -14,24 +14,41 @@ @license GNU/GPL Version 2 or later - http://www.gnu.org/licenses/gpl-2.0.html /------------------------------------------------------------------------------------------------------*/ +namespace TrueChristianChurch\Component\Getbible\Administrator\Controller; // No direct access to this file -defined('_JEXEC') or die('Restricted access'); +\defined('_JEXEC') or die; use Joomla\CMS\Factory; use Joomla\CMS\Language\Text; +use Joomla\CMS\Form\FormFactoryInterface; +use Joomla\CMS\Application\CMSApplication; +use Joomla\CMS\MVC\Factory\MVCFactoryInterface; +use Joomla\Input\Input; +use Joomla\CMS\Versioning\VersionableControllerTrait; use Joomla\CMS\MVC\Controller\FormController; use Joomla\CMS\MVC\Model\BaseDatabaseModel; use Joomla\Utilities\ArrayHelper; use Joomla\CMS\Router\Route; use Joomla\CMS\Session\Session; use Joomla\CMS\Uri\Uri; +use TrueChristianChurch\Component\Getbible\Administrator\Helper\GetbibleHelper; /** * Open_ai_response Form Controller */ -class GetbibleControllerOpen_ai_response extends FormController +class Open_ai_responseController extends FormController { + use VersionableControllerTrait; + + /** + * The prefix to use with controller messages. + * + * @var string + * @since 1.6 + */ + protected $text_prefix = 'COM_GETBIBLE_OPEN_AI_RESPONSE'; + /** * Current or most recently performed task. * @@ -42,16 +59,29 @@ class GetbibleControllerOpen_ai_response extends FormController protected $task; /** - * Class constructor. + * Constructor. * - * @param array $config A named array of configuration variables. + * @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). + * @param MVCFactoryInterface|null $factory The factory. + * @param CMSApplication|null $app The Application for the dispatcher + * @param Input|null $input Input + * @param FormFactoryInterface|null $formFactory The form factory. * - * @since 1.6 + * @since 3.0 */ - public function __construct($config = []) - { + public function __construct( + $config = [], + ?MVCFactoryInterface $factory = null, + ?CMSApplication $app = null, + ?Input $input = null, + ?FormFactoryInterface $formFactory = null + ) { + parent::__construct($config, $factory, $app, $input, $formFactory); + $this->view_list = 'Open_ai_responses'; // safeguard for setting the return view listing to the main view. - parent::__construct($config); } /** @@ -66,7 +96,7 @@ class GetbibleControllerOpen_ai_response extends FormController protected function allowAdd($data = []) { // Get user object. - $user = Factory::getUser(); + $user = $this->app->getIdentity(); // Access check. $access = $user->authorise('open_ai_response.access', 'com_getbible'); if (!$access) @@ -91,7 +121,7 @@ class GetbibleControllerOpen_ai_response extends FormController protected function allowEdit($data = [], $key = 'id') { // get user object. - $user = Factory::getUser(); + $user = $this->app->getIdentity(); // get record id. $recordId = (int) isset($data[$key]) ? $data[$key] : 0; diff --git a/admin/controllers/open_ai_responses.php b/admin/src/Controller/Open_ai_responsesController.php similarity index 81% rename from admin/controllers/open_ai_responses.php rename to admin/src/Controller/Open_ai_responsesController.php index e060ae0..94e86fb 100644 --- a/admin/controllers/open_ai_responses.php +++ b/admin/src/Controller/Open_ai_responsesController.php @@ -14,9 +14,10 @@ @license GNU/GPL Version 2 or later - http://www.gnu.org/licenses/gpl-2.0.html /------------------------------------------------------------------------------------------------------*/ +namespace TrueChristianChurch\Component\Getbible\Administrator\Controller; // No direct access to this file -defined('_JEXEC') or die('Restricted access'); +\defined('_JEXEC') or die; use Joomla\CMS\Factory; use Joomla\CMS\Language\Text; @@ -24,11 +25,12 @@ use Joomla\CMS\MVC\Controller\AdminController; use Joomla\Utilities\ArrayHelper; use Joomla\CMS\Router\Route; use Joomla\CMS\Session\Session; +use TrueChristianChurch\Component\Getbible\Administrator\Helper\GetbibleHelper; /** * Open_ai_responses Admin Controller */ -class GetbibleControllerOpen_ai_responses extends AdminController +class Open_ai_responsesController extends AdminController { /** * The prefix to use with controller messages. @@ -39,17 +41,17 @@ class GetbibleControllerOpen_ai_responses extends AdminController protected $text_prefix = 'COM_GETBIBLE_OPEN_AI_RESPONSES'; /** - * Method to get a model object, loading it if required. + * Proxy for getModel. * * @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. + * @return \Joomla\CMS\MVC\Model\BaseDatabaseModel * * @since 1.6 */ - public function getModel($name = 'Open_ai_response', $prefix = 'GetbibleModel', $config = array('ignore_request' => true)) + public function getModel($name = 'Open_ai_response', $prefix = 'Administrator', $config = ['ignore_request' => true]) { return parent::getModel($name, $prefix, $config); } diff --git a/admin/controllers/password.php b/admin/src/Controller/PasswordController.php similarity index 83% rename from admin/controllers/password.php rename to admin/src/Controller/PasswordController.php index c4a428f..eac69fa 100644 --- a/admin/controllers/password.php +++ b/admin/src/Controller/PasswordController.php @@ -14,24 +14,41 @@ @license GNU/GPL Version 2 or later - http://www.gnu.org/licenses/gpl-2.0.html /------------------------------------------------------------------------------------------------------*/ +namespace TrueChristianChurch\Component\Getbible\Administrator\Controller; // No direct access to this file -defined('_JEXEC') or die('Restricted access'); +\defined('_JEXEC') or die; use Joomla\CMS\Factory; use Joomla\CMS\Language\Text; +use Joomla\CMS\Form\FormFactoryInterface; +use Joomla\CMS\Application\CMSApplication; +use Joomla\CMS\MVC\Factory\MVCFactoryInterface; +use Joomla\Input\Input; +use Joomla\CMS\Versioning\VersionableControllerTrait; use Joomla\CMS\MVC\Controller\FormController; use Joomla\CMS\MVC\Model\BaseDatabaseModel; use Joomla\Utilities\ArrayHelper; use Joomla\CMS\Router\Route; use Joomla\CMS\Session\Session; use Joomla\CMS\Uri\Uri; +use TrueChristianChurch\Component\Getbible\Administrator\Helper\GetbibleHelper; /** * Password Form Controller */ -class GetbibleControllerPassword extends FormController +class PasswordController extends FormController { + use VersionableControllerTrait; + + /** + * The prefix to use with controller messages. + * + * @var string + * @since 1.6 + */ + protected $text_prefix = 'COM_GETBIBLE_PASSWORD'; + /** * Current or most recently performed task. * @@ -42,16 +59,29 @@ class GetbibleControllerPassword extends FormController protected $task; /** - * Class constructor. + * Constructor. * - * @param array $config A named array of configuration variables. + * @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). + * @param MVCFactoryInterface|null $factory The factory. + * @param CMSApplication|null $app The Application for the dispatcher + * @param Input|null $input Input + * @param FormFactoryInterface|null $formFactory The form factory. * - * @since 1.6 + * @since 3.0 */ - public function __construct($config = []) - { + public function __construct( + $config = [], + ?MVCFactoryInterface $factory = null, + ?CMSApplication $app = null, + ?Input $input = null, + ?FormFactoryInterface $formFactory = null + ) { + parent::__construct($config, $factory, $app, $input, $formFactory); + $this->view_list = 'Passwords'; // safeguard for setting the return view listing to the main view. - parent::__construct($config); } /** @@ -66,7 +96,7 @@ class GetbibleControllerPassword extends FormController protected function allowAdd($data = []) { // Get user object. - $user = Factory::getUser(); + $user = $this->app->getIdentity(); // Access check. $access = $user->authorise('password.access', 'com_getbible'); if (!$access) @@ -91,7 +121,7 @@ class GetbibleControllerPassword extends FormController protected function allowEdit($data = [], $key = 'id') { // get user object. - $user = Factory::getUser(); + $user = $this->app->getIdentity(); // get record id. $recordId = (int) isset($data[$key]) ? $data[$key] : 0; diff --git a/admin/controllers/passwords.php b/admin/src/Controller/PasswordsController.php similarity index 78% rename from admin/controllers/passwords.php rename to admin/src/Controller/PasswordsController.php index ea0d466..9f13b90 100644 --- a/admin/controllers/passwords.php +++ b/admin/src/Controller/PasswordsController.php @@ -14,9 +14,10 @@ @license GNU/GPL Version 2 or later - http://www.gnu.org/licenses/gpl-2.0.html /------------------------------------------------------------------------------------------------------*/ +namespace TrueChristianChurch\Component\Getbible\Administrator\Controller; // No direct access to this file -defined('_JEXEC') or die('Restricted access'); +\defined('_JEXEC') or die; use Joomla\CMS\Factory; use Joomla\CMS\Language\Text; @@ -24,11 +25,12 @@ use Joomla\CMS\MVC\Controller\AdminController; use Joomla\Utilities\ArrayHelper; use Joomla\CMS\Router\Route; use Joomla\CMS\Session\Session; +use TrueChristianChurch\Component\Getbible\Administrator\Helper\GetbibleHelper; /** * Passwords Admin Controller */ -class GetbibleControllerPasswords extends AdminController +class PasswordsController extends AdminController { /** * The prefix to use with controller messages. @@ -39,17 +41,17 @@ class GetbibleControllerPasswords extends AdminController protected $text_prefix = 'COM_GETBIBLE_PASSWORDS'; /** - * Method to get a model object, loading it if required. + * Proxy for getModel. * * @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. + * @return \Joomla\CMS\MVC\Model\BaseDatabaseModel * * @since 1.6 */ - public function getModel($name = 'Password', $prefix = 'GetbibleModel', $config = array('ignore_request' => true)) + public function getModel($name = 'Password', $prefix = 'Administrator', $config = ['ignore_request' => true]) { return parent::getModel($name, $prefix, $config); } diff --git a/admin/controllers/prompt.php b/admin/src/Controller/PromptController.php similarity index 83% rename from admin/controllers/prompt.php rename to admin/src/Controller/PromptController.php index 182387b..14ea63d 100644 --- a/admin/controllers/prompt.php +++ b/admin/src/Controller/PromptController.php @@ -14,24 +14,41 @@ @license GNU/GPL Version 2 or later - http://www.gnu.org/licenses/gpl-2.0.html /------------------------------------------------------------------------------------------------------*/ +namespace TrueChristianChurch\Component\Getbible\Administrator\Controller; // No direct access to this file -defined('_JEXEC') or die('Restricted access'); +\defined('_JEXEC') or die; use Joomla\CMS\Factory; use Joomla\CMS\Language\Text; +use Joomla\CMS\Form\FormFactoryInterface; +use Joomla\CMS\Application\CMSApplication; +use Joomla\CMS\MVC\Factory\MVCFactoryInterface; +use Joomla\Input\Input; +use Joomla\CMS\Versioning\VersionableControllerTrait; use Joomla\CMS\MVC\Controller\FormController; use Joomla\CMS\MVC\Model\BaseDatabaseModel; use Joomla\Utilities\ArrayHelper; use Joomla\CMS\Router\Route; use Joomla\CMS\Session\Session; use Joomla\CMS\Uri\Uri; +use TrueChristianChurch\Component\Getbible\Administrator\Helper\GetbibleHelper; /** * Prompt Form Controller */ -class GetbibleControllerPrompt extends FormController +class PromptController extends FormController { + use VersionableControllerTrait; + + /** + * The prefix to use with controller messages. + * + * @var string + * @since 1.6 + */ + protected $text_prefix = 'COM_GETBIBLE_PROMPT'; + /** * Current or most recently performed task. * @@ -42,16 +59,29 @@ class GetbibleControllerPrompt extends FormController protected $task; /** - * Class constructor. + * Constructor. * - * @param array $config A named array of configuration variables. + * @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). + * @param MVCFactoryInterface|null $factory The factory. + * @param CMSApplication|null $app The Application for the dispatcher + * @param Input|null $input Input + * @param FormFactoryInterface|null $formFactory The form factory. * - * @since 1.6 + * @since 3.0 */ - public function __construct($config = []) - { + public function __construct( + $config = [], + ?MVCFactoryInterface $factory = null, + ?CMSApplication $app = null, + ?Input $input = null, + ?FormFactoryInterface $formFactory = null + ) { + parent::__construct($config, $factory, $app, $input, $formFactory); + $this->view_list = 'Prompts'; // safeguard for setting the return view listing to the main view. - parent::__construct($config); } /** @@ -66,7 +96,7 @@ class GetbibleControllerPrompt extends FormController protected function allowAdd($data = []) { // Get user object. - $user = Factory::getUser(); + $user = $this->app->getIdentity(); // Access check. $access = $user->authorise('prompt.access', 'com_getbible'); if (!$access) @@ -91,7 +121,7 @@ class GetbibleControllerPrompt extends FormController protected function allowEdit($data = [], $key = 'id') { // get user object. - $user = Factory::getUser(); + $user = $this->app->getIdentity(); // get record id. $recordId = (int) isset($data[$key]) ? $data[$key] : 0; diff --git a/admin/controllers/prompts.php b/admin/src/Controller/PromptsController.php similarity index 78% rename from admin/controllers/prompts.php rename to admin/src/Controller/PromptsController.php index 2d393c3..c3e82a4 100644 --- a/admin/controllers/prompts.php +++ b/admin/src/Controller/PromptsController.php @@ -14,9 +14,10 @@ @license GNU/GPL Version 2 or later - http://www.gnu.org/licenses/gpl-2.0.html /------------------------------------------------------------------------------------------------------*/ +namespace TrueChristianChurch\Component\Getbible\Administrator\Controller; // No direct access to this file -defined('_JEXEC') or die('Restricted access'); +\defined('_JEXEC') or die; use Joomla\CMS\Factory; use Joomla\CMS\Language\Text; @@ -24,11 +25,12 @@ use Joomla\CMS\MVC\Controller\AdminController; use Joomla\Utilities\ArrayHelper; use Joomla\CMS\Router\Route; use Joomla\CMS\Session\Session; +use TrueChristianChurch\Component\Getbible\Administrator\Helper\GetbibleHelper; /** * Prompts Admin Controller */ -class GetbibleControllerPrompts extends AdminController +class PromptsController extends AdminController { /** * The prefix to use with controller messages. @@ -39,17 +41,17 @@ class GetbibleControllerPrompts extends AdminController protected $text_prefix = 'COM_GETBIBLE_PROMPTS'; /** - * Method to get a model object, loading it if required. + * Proxy for getModel. * * @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. + * @return \Joomla\CMS\MVC\Model\BaseDatabaseModel * * @since 1.6 */ - public function getModel($name = 'Prompt', $prefix = 'GetbibleModel', $config = array('ignore_request' => true)) + public function getModel($name = 'Prompt', $prefix = 'Administrator', $config = ['ignore_request' => true]) { return parent::getModel($name, $prefix, $config); } diff --git a/admin/controllers/tag.php b/admin/src/Controller/TagController.php similarity index 83% rename from admin/controllers/tag.php rename to admin/src/Controller/TagController.php index b348481..194b789 100644 --- a/admin/controllers/tag.php +++ b/admin/src/Controller/TagController.php @@ -14,24 +14,41 @@ @license GNU/GPL Version 2 or later - http://www.gnu.org/licenses/gpl-2.0.html /------------------------------------------------------------------------------------------------------*/ +namespace TrueChristianChurch\Component\Getbible\Administrator\Controller; // No direct access to this file -defined('_JEXEC') or die('Restricted access'); +\defined('_JEXEC') or die; use Joomla\CMS\Factory; use Joomla\CMS\Language\Text; +use Joomla\CMS\Form\FormFactoryInterface; +use Joomla\CMS\Application\CMSApplication; +use Joomla\CMS\MVC\Factory\MVCFactoryInterface; +use Joomla\Input\Input; +use Joomla\CMS\Versioning\VersionableControllerTrait; use Joomla\CMS\MVC\Controller\FormController; use Joomla\CMS\MVC\Model\BaseDatabaseModel; use Joomla\Utilities\ArrayHelper; use Joomla\CMS\Router\Route; use Joomla\CMS\Session\Session; use Joomla\CMS\Uri\Uri; +use TrueChristianChurch\Component\Getbible\Administrator\Helper\GetbibleHelper; /** * Tag Form Controller */ -class GetbibleControllerTag extends FormController +class TagController extends FormController { + use VersionableControllerTrait; + + /** + * The prefix to use with controller messages. + * + * @var string + * @since 1.6 + */ + protected $text_prefix = 'COM_GETBIBLE_TAG'; + /** * Current or most recently performed task. * @@ -42,16 +59,29 @@ class GetbibleControllerTag extends FormController protected $task; /** - * Class constructor. + * Constructor. * - * @param array $config A named array of configuration variables. + * @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). + * @param MVCFactoryInterface|null $factory The factory. + * @param CMSApplication|null $app The Application for the dispatcher + * @param Input|null $input Input + * @param FormFactoryInterface|null $formFactory The form factory. * - * @since 1.6 + * @since 3.0 */ - public function __construct($config = []) - { + public function __construct( + $config = [], + ?MVCFactoryInterface $factory = null, + ?CMSApplication $app = null, + ?Input $input = null, + ?FormFactoryInterface $formFactory = null + ) { + parent::__construct($config, $factory, $app, $input, $formFactory); + $this->view_list = 'Tags'; // safeguard for setting the return view listing to the main view. - parent::__construct($config); } /** @@ -66,7 +96,7 @@ class GetbibleControllerTag extends FormController protected function allowAdd($data = []) { // Get user object. - $user = Factory::getUser(); + $user = $this->app->getIdentity(); // Access check. $access = $user->authorise('tag.access', 'com_getbible'); if (!$access) @@ -91,7 +121,7 @@ class GetbibleControllerTag extends FormController protected function allowEdit($data = [], $key = 'id') { // get user object. - $user = Factory::getUser(); + $user = $this->app->getIdentity(); // get record id. $recordId = (int) isset($data[$key]) ? $data[$key] : 0; diff --git a/admin/controllers/tagged_verse.php b/admin/src/Controller/Tagged_verseController.php similarity index 83% rename from admin/controllers/tagged_verse.php rename to admin/src/Controller/Tagged_verseController.php index 0dca6a9..bcc1066 100644 --- a/admin/controllers/tagged_verse.php +++ b/admin/src/Controller/Tagged_verseController.php @@ -14,24 +14,41 @@ @license GNU/GPL Version 2 or later - http://www.gnu.org/licenses/gpl-2.0.html /------------------------------------------------------------------------------------------------------*/ +namespace TrueChristianChurch\Component\Getbible\Administrator\Controller; // No direct access to this file -defined('_JEXEC') or die('Restricted access'); +\defined('_JEXEC') or die; use Joomla\CMS\Factory; use Joomla\CMS\Language\Text; +use Joomla\CMS\Form\FormFactoryInterface; +use Joomla\CMS\Application\CMSApplication; +use Joomla\CMS\MVC\Factory\MVCFactoryInterface; +use Joomla\Input\Input; +use Joomla\CMS\Versioning\VersionableControllerTrait; use Joomla\CMS\MVC\Controller\FormController; use Joomla\CMS\MVC\Model\BaseDatabaseModel; use Joomla\Utilities\ArrayHelper; use Joomla\CMS\Router\Route; use Joomla\CMS\Session\Session; use Joomla\CMS\Uri\Uri; +use TrueChristianChurch\Component\Getbible\Administrator\Helper\GetbibleHelper; /** * Tagged_verse Form Controller */ -class GetbibleControllerTagged_verse extends FormController +class Tagged_verseController extends FormController { + use VersionableControllerTrait; + + /** + * The prefix to use with controller messages. + * + * @var string + * @since 1.6 + */ + protected $text_prefix = 'COM_GETBIBLE_TAGGED_VERSE'; + /** * Current or most recently performed task. * @@ -42,16 +59,29 @@ class GetbibleControllerTagged_verse extends FormController protected $task; /** - * Class constructor. + * Constructor. * - * @param array $config A named array of configuration variables. + * @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). + * @param MVCFactoryInterface|null $factory The factory. + * @param CMSApplication|null $app The Application for the dispatcher + * @param Input|null $input Input + * @param FormFactoryInterface|null $formFactory The form factory. * - * @since 1.6 + * @since 3.0 */ - public function __construct($config = []) - { + public function __construct( + $config = [], + ?MVCFactoryInterface $factory = null, + ?CMSApplication $app = null, + ?Input $input = null, + ?FormFactoryInterface $formFactory = null + ) { + parent::__construct($config, $factory, $app, $input, $formFactory); + $this->view_list = 'Tagged_verses'; // safeguard for setting the return view listing to the main view. - parent::__construct($config); } /** @@ -66,7 +96,7 @@ class GetbibleControllerTagged_verse extends FormController protected function allowAdd($data = []) { // Get user object. - $user = Factory::getUser(); + $user = $this->app->getIdentity(); // Access check. $access = $user->authorise('tagged_verse.access', 'com_getbible'); if (!$access) @@ -91,7 +121,7 @@ class GetbibleControllerTagged_verse extends FormController protected function allowEdit($data = [], $key = 'id') { // get user object. - $user = Factory::getUser(); + $user = $this->app->getIdentity(); // get record id. $recordId = (int) isset($data[$key]) ? $data[$key] : 0; diff --git a/admin/controllers/tagged_verses.php b/admin/src/Controller/Tagged_versesController.php similarity index 77% rename from admin/controllers/tagged_verses.php rename to admin/src/Controller/Tagged_versesController.php index c9da6b0..68cc97a 100644 --- a/admin/controllers/tagged_verses.php +++ b/admin/src/Controller/Tagged_versesController.php @@ -14,9 +14,10 @@ @license GNU/GPL Version 2 or later - http://www.gnu.org/licenses/gpl-2.0.html /------------------------------------------------------------------------------------------------------*/ +namespace TrueChristianChurch\Component\Getbible\Administrator\Controller; // No direct access to this file -defined('_JEXEC') or die('Restricted access'); +\defined('_JEXEC') or die; use Joomla\CMS\Factory; use Joomla\CMS\Language\Text; @@ -24,11 +25,12 @@ use Joomla\CMS\MVC\Controller\AdminController; use Joomla\Utilities\ArrayHelper; use Joomla\CMS\Router\Route; use Joomla\CMS\Session\Session; +use TrueChristianChurch\Component\Getbible\Administrator\Helper\GetbibleHelper; /** * Tagged_verses Admin Controller */ -class GetbibleControllerTagged_verses extends AdminController +class Tagged_versesController extends AdminController { /** * The prefix to use with controller messages. @@ -39,17 +41,17 @@ class GetbibleControllerTagged_verses extends AdminController protected $text_prefix = 'COM_GETBIBLE_TAGGED_VERSES'; /** - * Method to get a model object, loading it if required. + * Proxy for getModel. * * @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. + * @return \Joomla\CMS\MVC\Model\BaseDatabaseModel * * @since 1.6 */ - public function getModel($name = 'Tagged_verse', $prefix = 'GetbibleModel', $config = array('ignore_request' => true)) + public function getModel($name = 'Tagged_verse', $prefix = 'Administrator', $config = ['ignore_request' => true]) { return parent::getModel($name, $prefix, $config); } diff --git a/admin/controllers/tags.php b/admin/src/Controller/TagsController.php similarity index 78% rename from admin/controllers/tags.php rename to admin/src/Controller/TagsController.php index 3e89d2b..852b4c8 100644 --- a/admin/controllers/tags.php +++ b/admin/src/Controller/TagsController.php @@ -14,9 +14,10 @@ @license GNU/GPL Version 2 or later - http://www.gnu.org/licenses/gpl-2.0.html /------------------------------------------------------------------------------------------------------*/ +namespace TrueChristianChurch\Component\Getbible\Administrator\Controller; // No direct access to this file -defined('_JEXEC') or die('Restricted access'); +\defined('_JEXEC') or die; use Joomla\CMS\Factory; use Joomla\CMS\Language\Text; @@ -24,11 +25,12 @@ use Joomla\CMS\MVC\Controller\AdminController; use Joomla\Utilities\ArrayHelper; use Joomla\CMS\Router\Route; use Joomla\CMS\Session\Session; +use TrueChristianChurch\Component\Getbible\Administrator\Helper\GetbibleHelper; /** * Tags Admin Controller */ -class GetbibleControllerTags extends AdminController +class TagsController extends AdminController { /** * The prefix to use with controller messages. @@ -39,17 +41,17 @@ class GetbibleControllerTags extends AdminController protected $text_prefix = 'COM_GETBIBLE_TAGS'; /** - * Method to get a model object, loading it if required. + * Proxy for getModel. * * @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. + * @return \Joomla\CMS\MVC\Model\BaseDatabaseModel * * @since 1.6 */ - public function getModel($name = 'Tag', $prefix = 'GetbibleModel', $config = array('ignore_request' => true)) + public function getModel($name = 'Tag', $prefix = 'Administrator', $config = ['ignore_request' => true]) { return parent::getModel($name, $prefix, $config); } diff --git a/admin/controllers/translation.php b/admin/src/Controller/TranslationController.php similarity index 83% rename from admin/controllers/translation.php rename to admin/src/Controller/TranslationController.php index f60ceb6..12c0b5e 100644 --- a/admin/controllers/translation.php +++ b/admin/src/Controller/TranslationController.php @@ -14,24 +14,41 @@ @license GNU/GPL Version 2 or later - http://www.gnu.org/licenses/gpl-2.0.html /------------------------------------------------------------------------------------------------------*/ +namespace TrueChristianChurch\Component\Getbible\Administrator\Controller; // No direct access to this file -defined('_JEXEC') or die('Restricted access'); +\defined('_JEXEC') or die; use Joomla\CMS\Factory; use Joomla\CMS\Language\Text; +use Joomla\CMS\Form\FormFactoryInterface; +use Joomla\CMS\Application\CMSApplication; +use Joomla\CMS\MVC\Factory\MVCFactoryInterface; +use Joomla\Input\Input; +use Joomla\CMS\Versioning\VersionableControllerTrait; use Joomla\CMS\MVC\Controller\FormController; use Joomla\CMS\MVC\Model\BaseDatabaseModel; use Joomla\Utilities\ArrayHelper; use Joomla\CMS\Router\Route; use Joomla\CMS\Session\Session; use Joomla\CMS\Uri\Uri; +use TrueChristianChurch\Component\Getbible\Administrator\Helper\GetbibleHelper; /** * Translation Form Controller */ -class GetbibleControllerTranslation extends FormController +class TranslationController extends FormController { + use VersionableControllerTrait; + + /** + * The prefix to use with controller messages. + * + * @var string + * @since 1.6 + */ + protected $text_prefix = 'COM_GETBIBLE_TRANSLATION'; + /** * Current or most recently performed task. * @@ -42,16 +59,29 @@ class GetbibleControllerTranslation extends FormController protected $task; /** - * Class constructor. + * Constructor. * - * @param array $config A named array of configuration variables. + * @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). + * @param MVCFactoryInterface|null $factory The factory. + * @param CMSApplication|null $app The Application for the dispatcher + * @param Input|null $input Input + * @param FormFactoryInterface|null $formFactory The form factory. * - * @since 1.6 + * @since 3.0 */ - public function __construct($config = []) - { + public function __construct( + $config = [], + ?MVCFactoryInterface $factory = null, + ?CMSApplication $app = null, + ?Input $input = null, + ?FormFactoryInterface $formFactory = null + ) { + parent::__construct($config, $factory, $app, $input, $formFactory); + $this->view_list = 'Translations'; // safeguard for setting the return view listing to the main view. - parent::__construct($config); }###ADMIN_CUSTOM_BUTTONS_CONTROLLER### /** @@ -66,7 +96,7 @@ class GetbibleControllerTranslation extends FormController protected function allowAdd($data = []) { // Get user object. - $user = Factory::getUser(); + $user = $this->app->getIdentity(); // Access check. $access = $user->authorise('translation.access', 'com_getbible'); if (!$access) @@ -91,7 +121,7 @@ class GetbibleControllerTranslation extends FormController protected function allowEdit($data = [], $key = 'id') { // get user object. - $user = Factory::getUser(); + $user = $this->app->getIdentity(); // get record id. $recordId = (int) isset($data[$key]) ? $data[$key] : 0; diff --git a/admin/controllers/translations.php b/admin/src/Controller/TranslationsController.php similarity index 91% rename from admin/controllers/translations.php rename to admin/src/Controller/TranslationsController.php index 5f8b446..c4d890d 100644 --- a/admin/controllers/translations.php +++ b/admin/src/Controller/TranslationsController.php @@ -14,9 +14,10 @@ @license GNU/GPL Version 2 or later - http://www.gnu.org/licenses/gpl-2.0.html /------------------------------------------------------------------------------------------------------*/ +namespace TrueChristianChurch\Component\Getbible\Administrator\Controller; // No direct access to this file -defined('_JEXEC') or die('Restricted access'); +\defined('_JEXEC') or die; use Joomla\CMS\Factory; use Joomla\CMS\Language\Text; @@ -24,13 +25,14 @@ use Joomla\CMS\MVC\Controller\AdminController; use Joomla\Utilities\ArrayHelper; use Joomla\CMS\Router\Route; use Joomla\CMS\Session\Session; +use TrueChristianChurch\Component\Getbible\Administrator\Helper\GetbibleHelper; use VDM\Joomla\GetBible\Factory as GetBibleFactory; use VDM\Joomla\Utilities\ArrayHelper as UtilitiesArrayHelper; /** * Translations Admin Controller */ -class GetbibleControllerTranslations extends AdminController +class TranslationsController extends AdminController { /** * The prefix to use with controller messages. @@ -41,17 +43,17 @@ class GetbibleControllerTranslations extends AdminController protected $text_prefix = 'COM_GETBIBLE_TRANSLATIONS'; /** - * Method to get a model object, loading it if required. + * Proxy for getModel. * * @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. + * @return \Joomla\CMS\MVC\Model\BaseDatabaseModel * * @since 1.6 */ - public function getModel($name = 'Translation', $prefix = 'GetbibleModel', $config = array('ignore_request' => true)) + public function getModel($name = 'Translation', $prefix = 'Administrator', $config = ['ignore_request' => true]) { return parent::getModel($name, $prefix, $config); } diff --git a/admin/controllers/verse.php b/admin/src/Controller/VerseController.php similarity index 83% rename from admin/controllers/verse.php rename to admin/src/Controller/VerseController.php index c8ce1df..baf6591 100644 --- a/admin/controllers/verse.php +++ b/admin/src/Controller/VerseController.php @@ -14,24 +14,41 @@ @license GNU/GPL Version 2 or later - http://www.gnu.org/licenses/gpl-2.0.html /------------------------------------------------------------------------------------------------------*/ +namespace TrueChristianChurch\Component\Getbible\Administrator\Controller; // No direct access to this file -defined('_JEXEC') or die('Restricted access'); +\defined('_JEXEC') or die; use Joomla\CMS\Factory; use Joomla\CMS\Language\Text; +use Joomla\CMS\Form\FormFactoryInterface; +use Joomla\CMS\Application\CMSApplication; +use Joomla\CMS\MVC\Factory\MVCFactoryInterface; +use Joomla\Input\Input; +use Joomla\CMS\Versioning\VersionableControllerTrait; use Joomla\CMS\MVC\Controller\FormController; use Joomla\CMS\MVC\Model\BaseDatabaseModel; use Joomla\Utilities\ArrayHelper; use Joomla\CMS\Router\Route; use Joomla\CMS\Session\Session; use Joomla\CMS\Uri\Uri; +use TrueChristianChurch\Component\Getbible\Administrator\Helper\GetbibleHelper; /** * Verse Form Controller */ -class GetbibleControllerVerse extends FormController +class VerseController extends FormController { + use VersionableControllerTrait; + + /** + * The prefix to use with controller messages. + * + * @var string + * @since 1.6 + */ + protected $text_prefix = 'COM_GETBIBLE_VERSE'; + /** * Current or most recently performed task. * @@ -42,16 +59,29 @@ class GetbibleControllerVerse extends FormController protected $task; /** - * Class constructor. + * Constructor. * - * @param array $config A named array of configuration variables. + * @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). + * @param MVCFactoryInterface|null $factory The factory. + * @param CMSApplication|null $app The Application for the dispatcher + * @param Input|null $input Input + * @param FormFactoryInterface|null $formFactory The form factory. * - * @since 1.6 + * @since 3.0 */ - public function __construct($config = []) - { + public function __construct( + $config = [], + ?MVCFactoryInterface $factory = null, + ?CMSApplication $app = null, + ?Input $input = null, + ?FormFactoryInterface $formFactory = null + ) { + parent::__construct($config, $factory, $app, $input, $formFactory); + $this->view_list = 'Verses'; // safeguard for setting the return view listing to the main view. - parent::__construct($config); }###ADMIN_CUSTOM_BUTTONS_CONTROLLER### /** @@ -66,7 +96,7 @@ class GetbibleControllerVerse extends FormController protected function allowAdd($data = []) { // Get user object. - $user = Factory::getUser(); + $user = $this->app->getIdentity(); // Access check. $access = $user->authorise('verse.access', 'com_getbible'); if (!$access) @@ -91,7 +121,7 @@ class GetbibleControllerVerse extends FormController protected function allowEdit($data = [], $key = 'id') { // get user object. - $user = Factory::getUser(); + $user = $this->app->getIdentity(); // get record id. $recordId = (int) isset($data[$key]) ? $data[$key] : 0; diff --git a/admin/controllers/verses.php b/admin/src/Controller/VersesController.php similarity index 78% rename from admin/controllers/verses.php rename to admin/src/Controller/VersesController.php index 51afd0f..639e60f 100644 --- a/admin/controllers/verses.php +++ b/admin/src/Controller/VersesController.php @@ -14,9 +14,10 @@ @license GNU/GPL Version 2 or later - http://www.gnu.org/licenses/gpl-2.0.html /------------------------------------------------------------------------------------------------------*/ +namespace TrueChristianChurch\Component\Getbible\Administrator\Controller; // No direct access to this file -defined('_JEXEC') or die('Restricted access'); +\defined('_JEXEC') or die; use Joomla\CMS\Factory; use Joomla\CMS\Language\Text; @@ -24,11 +25,12 @@ use Joomla\CMS\MVC\Controller\AdminController; use Joomla\Utilities\ArrayHelper; use Joomla\CMS\Router\Route; use Joomla\CMS\Session\Session; +use TrueChristianChurch\Component\Getbible\Administrator\Helper\GetbibleHelper; /** * Verses Admin Controller */ -class GetbibleControllerVerses extends AdminController +class VersesController extends AdminController { /** * The prefix to use with controller messages. @@ -39,17 +41,17 @@ class GetbibleControllerVerses extends AdminController protected $text_prefix = 'COM_GETBIBLE_VERSES'; /** - * Method to get a model object, loading it if required. + * Proxy for getModel. * * @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. + * @return \Joomla\CMS\MVC\Model\BaseDatabaseModel * * @since 1.6 */ - public function getModel($name = 'Verse', $prefix = 'GetbibleModel', $config = array('ignore_request' => true)) + public function getModel($name = 'Verse', $prefix = 'Administrator', $config = ['ignore_request' => true]) { return parent::getModel($name, $prefix, $config); } diff --git a/admin/models/fields/index.html b/admin/src/Controller/index.html similarity index 100% rename from admin/models/fields/index.html rename to admin/src/Controller/index.html diff --git a/admin/src/Extension/GetbibleComponent.php b/admin/src/Extension/GetbibleComponent.php new file mode 100644 index 0000000..083be9f --- /dev/null +++ b/admin/src/Extension/GetbibleComponent.php @@ -0,0 +1,81 @@ + + @git Get Bible + @github Get Bible + @support Get Bible + @copyright Copyright (C) 2015. All Rights Reserved + @license GNU/GPL Version 2 or later - http://www.gnu.org/licenses/gpl-2.0.html + +/------------------------------------------------------------------------------------------------------*/ +namespace TrueChristianChurch\Component\Getbible\Administrator\Extension; + +// No direct access to this file +\defined('_JEXEC') or die; + +use Joomla\CMS\Association\AssociationServiceInterface; +use Joomla\CMS\Association\AssociationServiceTrait; +use Joomla\CMS\Categories\CategoryServiceInterface; +use Joomla\CMS\Categories\CategoryServiceTrait; +use Joomla\CMS\Component\Router\RouterServiceInterface; +use Joomla\CMS\Component\Router\RouterServiceTrait; +use Joomla\CMS\Extension\BootableExtensionInterface; +use Joomla\CMS\Extension\MVCComponent; +use Joomla\CMS\Factory; +use Joomla\CMS\Fields\FieldsServiceInterface; +use Joomla\CMS\Form\Form; +use Joomla\CMS\HTML\HTMLRegistryAwareTrait; +use Joomla\CMS\Language\Text; +use Joomla\CMS\Tag\TagServiceInterface; +use Joomla\CMS\Tag\TagServiceTrait; +use Joomla\CMS\User\UserFactoryInterface; +// (soon) use TrueChristianChurch\Component\Getbible\Administrator\Service\HTML\AdministratorService; +use Psr\Container\ContainerInterface; + +/** + * Component class for com_getbible + * + * @since 4.0.0 + */ +class GetbibleComponent extends MVCComponent implements + BootableExtensionInterface, + CategoryServiceInterface, + RouterServiceInterface +{ + use AssociationServiceTrait; + use HTMLRegistryAwareTrait; + use RouterServiceTrait; + use CategoryServiceTrait, TagServiceTrait { + CategoryServiceTrait::getTableNameForSection insteadof TagServiceTrait; + CategoryServiceTrait::getStateColumnForSection insteadof TagServiceTrait; + } + + /** + * Booting the extension. This is the function to set up the environment of the extension like + * registering new class loaders, etc. + * + * If required, some initial set up can be done from services of the container, eg. + * registering HTML services. + * + * @param ContainerInterface $container The container + * + * @return void + * + * @since 4.0.0 + */ + public function boot(ContainerInterface $container) + { + // (soon) $this->getRegistry()->register('getbibleadministrator', new AdministratorService()); + } + + // will fix these soon + protected function getTableNameForSection(string $section = null){} + public function countItems(array $items, string $section){} + +} diff --git a/admin/models/forms/index.html b/admin/src/Extension/index.html similarity index 100% rename from admin/models/forms/index.html rename to admin/src/Extension/index.html diff --git a/admin/models/fields/booksfiltername.php b/admin/src/Field/BooksfilternameField.php similarity index 78% rename from admin/models/fields/booksfiltername.php rename to admin/src/Field/BooksfilternameField.php index 930421d..3483cde 100644 --- a/admin/models/fields/booksfiltername.php +++ b/admin/src/Field/BooksfilternameField.php @@ -14,39 +14,40 @@ @license GNU/GPL Version 2 or later - http://www.gnu.org/licenses/gpl-2.0.html /------------------------------------------------------------------------------------------------------*/ +namespace TrueChristianChurch\Component\Getbible\Administrator\Field; // No direct access to this file -defined('_JEXEC') or die('Restricted access'); +\defined('_JEXEC') or die; use Joomla\CMS\Factory; +use Joomla\CMS\Form\Field\ListField; use Joomla\CMS\Language\Text; use Joomla\CMS\HTML\HTMLHelper as Html; - -// import the list field type -jimport('joomla.form.helper'); -JFormHelper::loadFieldClass('list'); +use Joomla\CMS\Component\ComponentHelper; +use TrueChristianChurch\Component\Getbible\Administrator\Helper\GetbibleHelper; /** * Booksfiltername Form Field class for the Getbible component */ -class JFormFieldBooksfiltername extends JFormFieldList +class BooksfilternameField extends ListField { /** * The booksfiltername field type. * - * @var string + * @var string */ - public $type = 'booksfiltername'; + public $type = 'Booksfiltername'; /** * Method to get a list of options for a list input. * - * @return array An array of JHtml options. + * @return array An array of Html options. + * @since 1.6 */ protected function getOptions() { // Get a db connection. - $db = Factory::getDbo(); + $db = Factory::getContainer()->get(\Joomla\Database\DatabaseInterface::class); // Create a new query object. $query = $db->getQuery(true); @@ -60,7 +61,7 @@ class JFormFieldBooksfiltername extends JFormFieldList $db->setQuery($query); $_results = $db->loadColumn(); - $_filter = array(); + $_filter = []; $_filter[] = Html::_('select.option', '', '- ' . Text::_('COM_GETBIBLE_FILTER_SELECT_NAME') . ' -'); if ($_results) diff --git a/admin/models/fields/booksfilternr.php b/admin/src/Field/BooksfilternrField.php similarity index 78% rename from admin/models/fields/booksfilternr.php rename to admin/src/Field/BooksfilternrField.php index 749f93e..154d7c4 100644 --- a/admin/models/fields/booksfilternr.php +++ b/admin/src/Field/BooksfilternrField.php @@ -14,39 +14,40 @@ @license GNU/GPL Version 2 or later - http://www.gnu.org/licenses/gpl-2.0.html /------------------------------------------------------------------------------------------------------*/ +namespace TrueChristianChurch\Component\Getbible\Administrator\Field; // No direct access to this file -defined('_JEXEC') or die('Restricted access'); +\defined('_JEXEC') or die; use Joomla\CMS\Factory; +use Joomla\CMS\Form\Field\ListField; use Joomla\CMS\Language\Text; use Joomla\CMS\HTML\HTMLHelper as Html; - -// import the list field type -jimport('joomla.form.helper'); -JFormHelper::loadFieldClass('list'); +use Joomla\CMS\Component\ComponentHelper; +use TrueChristianChurch\Component\Getbible\Administrator\Helper\GetbibleHelper; /** * Booksfilternr Form Field class for the Getbible component */ -class JFormFieldBooksfilternr extends JFormFieldList +class BooksfilternrField extends ListField { /** * The booksfilternr field type. * - * @var string + * @var string */ - public $type = 'booksfilternr'; + public $type = 'Booksfilternr'; /** * Method to get a list of options for a list input. * - * @return array An array of JHtml options. + * @return array An array of Html options. + * @since 1.6 */ protected function getOptions() { // Get a db connection. - $db = Factory::getDbo(); + $db = Factory::getContainer()->get(\Joomla\Database\DatabaseInterface::class); // Create a new query object. $query = $db->getQuery(true); @@ -60,7 +61,7 @@ class JFormFieldBooksfilternr extends JFormFieldList $db->setQuery($query); $_results = $db->loadColumn(); - $_filter = array(); + $_filter = []; $_filter[] = Html::_('select.option', '', '- ' . Text::_('COM_GETBIBLE_FILTER_SELECT_NUMBER') . ' -'); if ($_results) diff --git a/admin/models/fields/chaptersfilterbooknr.php b/admin/src/Field/ChaptersfilterbooknrField.php similarity index 77% rename from admin/models/fields/chaptersfilterbooknr.php rename to admin/src/Field/ChaptersfilterbooknrField.php index d509ae9..dad4c6b 100644 --- a/admin/models/fields/chaptersfilterbooknr.php +++ b/admin/src/Field/ChaptersfilterbooknrField.php @@ -14,39 +14,40 @@ @license GNU/GPL Version 2 or later - http://www.gnu.org/licenses/gpl-2.0.html /------------------------------------------------------------------------------------------------------*/ +namespace TrueChristianChurch\Component\Getbible\Administrator\Field; // No direct access to this file -defined('_JEXEC') or die('Restricted access'); +\defined('_JEXEC') or die; use Joomla\CMS\Factory; +use Joomla\CMS\Form\Field\ListField; use Joomla\CMS\Language\Text; use Joomla\CMS\HTML\HTMLHelper as Html; - -// import the list field type -jimport('joomla.form.helper'); -JFormHelper::loadFieldClass('list'); +use Joomla\CMS\Component\ComponentHelper; +use TrueChristianChurch\Component\Getbible\Administrator\Helper\GetbibleHelper; /** * Chaptersfilterbooknr Form Field class for the Getbible component */ -class JFormFieldChaptersfilterbooknr extends JFormFieldList +class ChaptersfilterbooknrField extends ListField { /** * The chaptersfilterbooknr field type. * - * @var string + * @var string */ - public $type = 'chaptersfilterbooknr'; + public $type = 'Chaptersfilterbooknr'; /** * Method to get a list of options for a list input. * - * @return array An array of JHtml options. + * @return array An array of Html options. + * @since 1.6 */ protected function getOptions() { // Get a db connection. - $db = Factory::getDbo(); + $db = Factory::getContainer()->get(\Joomla\Database\DatabaseInterface::class); // Create a new query object. $query = $db->getQuery(true); @@ -60,7 +61,7 @@ class JFormFieldChaptersfilterbooknr extends JFormFieldList $db->setQuery($query); $_results = $db->loadColumn(); - $_filter = array(); + $_filter = []; if ($_results) { diff --git a/admin/models/fields/chaptersfilterchapter.php b/admin/src/Field/ChaptersfilterchapterField.php similarity index 77% rename from admin/models/fields/chaptersfilterchapter.php rename to admin/src/Field/ChaptersfilterchapterField.php index 65e6f42..df02adc 100644 --- a/admin/models/fields/chaptersfilterchapter.php +++ b/admin/src/Field/ChaptersfilterchapterField.php @@ -14,39 +14,40 @@ @license GNU/GPL Version 2 or later - http://www.gnu.org/licenses/gpl-2.0.html /------------------------------------------------------------------------------------------------------*/ +namespace TrueChristianChurch\Component\Getbible\Administrator\Field; // No direct access to this file -defined('_JEXEC') or die('Restricted access'); +\defined('_JEXEC') or die; use Joomla\CMS\Factory; +use Joomla\CMS\Form\Field\ListField; use Joomla\CMS\Language\Text; use Joomla\CMS\HTML\HTMLHelper as Html; - -// import the list field type -jimport('joomla.form.helper'); -JFormHelper::loadFieldClass('list'); +use Joomla\CMS\Component\ComponentHelper; +use TrueChristianChurch\Component\Getbible\Administrator\Helper\GetbibleHelper; /** * Chaptersfilterchapter Form Field class for the Getbible component */ -class JFormFieldChaptersfilterchapter extends JFormFieldList +class ChaptersfilterchapterField extends ListField { /** * The chaptersfilterchapter field type. * - * @var string + * @var string */ - public $type = 'chaptersfilterchapter'; + public $type = 'Chaptersfilterchapter'; /** * Method to get a list of options for a list input. * - * @return array An array of JHtml options. + * @return array An array of Html options. + * @since 1.6 */ protected function getOptions() { // Get a db connection. - $db = Factory::getDbo(); + $db = Factory::getContainer()->get(\Joomla\Database\DatabaseInterface::class); // Create a new query object. $query = $db->getQuery(true); @@ -60,7 +61,7 @@ class JFormFieldChaptersfilterchapter extends JFormFieldList $db->setQuery($query); $_results = $db->loadColumn(); - $_filter = array(); + $_filter = []; if ($_results) { diff --git a/admin/models/fields/linkers.php b/admin/src/Field/LinkersField.php similarity index 72% rename from admin/models/fields/linkers.php rename to admin/src/Field/LinkersField.php index 64bbca3..6516246 100644 --- a/admin/models/fields/linkers.php +++ b/admin/src/Field/LinkersField.php @@ -14,29 +14,29 @@ @license GNU/GPL Version 2 or later - http://www.gnu.org/licenses/gpl-2.0.html /------------------------------------------------------------------------------------------------------*/ +namespace TrueChristianChurch\Component\Getbible\Administrator\Field; // No direct access to this file -defined('_JEXEC') or die('Restricted access'); +\defined('_JEXEC') or die; use Joomla\CMS\Factory; +use Joomla\CMS\Form\Field\ListField; use Joomla\CMS\Language\Text; use Joomla\CMS\HTML\HTMLHelper as Html; - -// import the list field type -jimport('joomla.form.helper'); -JFormHelper::loadFieldClass('list'); +use Joomla\CMS\Component\ComponentHelper; +use TrueChristianChurch\Component\Getbible\Administrator\Helper\GetbibleHelper; /** * Linkers Form Field class for the Getbible component */ -class JFormFieldLinkers extends JFormFieldList +class LinkersField extends ListField { /** * The linkers field type. * - * @var string + * @var string */ - public $type = 'linkers'; + public $type = 'Linkers'; /** * Override to add new button @@ -74,7 +74,7 @@ class JFormFieldLinkers extends JFormFieldList $ref = '&ref=' . $values['view'] . '&refid=' . $values['id']; $refJ = '&ref=' . $values['view'] . '&refid=' . $values['id']; // get the return value. - $_uri = (string) JUri::getInstance(); + $_uri = (string) \Joomla\CMS\Uri\Uri::getInstance(); $_return = urlencode(base64_encode($_uri)); // load return value. $ref .= '&return=' . $_return; @@ -87,45 +87,47 @@ class JFormFieldLinkers extends JFormFieldList $button_label = preg_replace("/[^A-Za-z ]/", '', $button_label); $button_label = ucfirst(strtolower($button_label)); // get user object - $user = Factory::getUser(); + $user = Factory::getApplication()->getIdentity(); // only add if user allowed to create linker - if ($user->authorise('linker.create', 'com_getbible') && $app->isAdmin()) // TODO for now only in admin area. + if ($user->authorise('linker.create', 'com_getbible') && $app->isClient('administrator')) // 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. + if ($user->authorise('linker.edit', 'com_getbible') && $app->isClient('administrator')) // 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) { + document.addEventListener('DOMContentLoaded', function() { + document.getElementById('jform_".$button_code_name."').addEventListener('change', function(e) { e.preventDefault(); - var ".$button_code_name."Value = jQuery('#jform_".$button_code_name."').val(); + let ".$button_code_name."Value = this.value; ".$button_code_name."Button(".$button_code_name."Value); }); - var ".$button_code_name."Value = jQuery('#jform_".$button_code_name."').val(); + let ".$button_code_name."Value = document.getElementById('jform_".$button_code_name."').value; ".$button_code_name."Button(".$button_code_name."Value); }); function ".$button_code_name."Button(value) { + var createButton = document.getElementById('".$button_code_name."Create'); + var editButton = document.getElementById('".$button_code_name."Edit'); if (value > 0) { // hide the create button - jQuery('#".$button_code_name."Create').hide(); + createButton.style.display = 'none'; // 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); + editButton.style.display = 'block'; + let url = 'index.php?option=com_getbible&view=linkers&task=linker.edit&id='+value+'".$refJ."'; + editButton.setAttribute('href', url); } else { // show the create button - jQuery('#".$button_code_name."Create').show(); + createButton.style.display = 'block'; // hide edit button - jQuery('#".$button_code_name."Edit').hide(); + editButton.style.display = 'none'; } }"; } @@ -133,10 +135,10 @@ class JFormFieldLinkers extends JFormFieldList if (is_array($button) && count($button) > 0) { // Load the needed script. - $document = Factory::getDocument(); + $document = Factory::getApplication()->getDocument(); $document->addScriptDeclaration(implode(' ',$script)); // return the button attached to input field. - return '
' .$html . implode('',$button).'
'; + return '
' .$html . implode('',$button).'
'; } } return $html; @@ -145,14 +147,15 @@ class JFormFieldLinkers extends JFormFieldList /** * Method to get a list of options for a list input. * - * @return array An array of JHtml options. + * @return array An array of Html options. + * @since 1.6 */ protected function getOptions() { // Get the user object. - $user = JFactory::getUser(); + $user = Factory::getUser(); // Get the databse object. - $db = JFactory::getDBO(); + $db = Factory::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')); @@ -175,11 +178,11 @@ class JFormFieldLinkers extends JFormFieldList { if ($this->multiple === false) { - $options[] = JHtml::_('select.option', '', JText::_('COM_GETBIBLE_SELECT_AN_OPTION')); + $options[] = Html::_('select.option', '', Text::_('COM_GETBIBLE_SELECT_AN_OPTION')); } foreach($items as $item) { - $options[] = JHtml::_('select.option', $item->guid, $item->linker_name . ' (' . substr($item->guid, 0, 8) . ')'); + $options[] = Html::_('select.option', $item->guid, $item->linker_name . ' (' . substr($item->guid, 0, 8) . ')'); } } return $options; diff --git a/admin/models/fields/linkersfiltername.php b/admin/src/Field/LinkersfilternameField.php similarity index 78% rename from admin/models/fields/linkersfiltername.php rename to admin/src/Field/LinkersfilternameField.php index e938497..ecb5bf0 100644 --- a/admin/models/fields/linkersfiltername.php +++ b/admin/src/Field/LinkersfilternameField.php @@ -14,39 +14,40 @@ @license GNU/GPL Version 2 or later - http://www.gnu.org/licenses/gpl-2.0.html /------------------------------------------------------------------------------------------------------*/ +namespace TrueChristianChurch\Component\Getbible\Administrator\Field; // No direct access to this file -defined('_JEXEC') or die('Restricted access'); +\defined('_JEXEC') or die; use Joomla\CMS\Factory; +use Joomla\CMS\Form\Field\ListField; use Joomla\CMS\Language\Text; use Joomla\CMS\HTML\HTMLHelper as Html; - -// import the list field type -jimport('joomla.form.helper'); -JFormHelper::loadFieldClass('list'); +use Joomla\CMS\Component\ComponentHelper; +use TrueChristianChurch\Component\Getbible\Administrator\Helper\GetbibleHelper; /** * Linkersfiltername Form Field class for the Getbible component */ -class JFormFieldLinkersfiltername extends JFormFieldList +class LinkersfilternameField extends ListField { /** * The linkersfiltername field type. * - * @var string + * @var string */ - public $type = 'linkersfiltername'; + public $type = 'Linkersfiltername'; /** * Method to get a list of options for a list input. * - * @return array An array of JHtml options. + * @return array An array of Html options. + * @since 1.6 */ protected function getOptions() { // Get a db connection. - $db = Factory::getDbo(); + $db = Factory::getContainer()->get(\Joomla\Database\DatabaseInterface::class); // Create a new query object. $query = $db->getQuery(true); @@ -60,7 +61,7 @@ class JFormFieldLinkersfiltername extends JFormFieldList $db->setQuery($query); $_results = $db->loadColumn(); - $_filter = array(); + $_filter = []; $_filter[] = Html::_('select.option', '', '- ' . Text::_('COM_GETBIBLE_FILTER_SELECT_NAME') . ' -'); if ($_results) diff --git a/admin/models/fields/linkersfilterpublicnotes.php b/admin/src/Field/LinkersfilterpublicnotesField.php similarity index 79% rename from admin/models/fields/linkersfilterpublicnotes.php rename to admin/src/Field/LinkersfilterpublicnotesField.php index 84a4b7b..ae49e6f 100644 --- a/admin/models/fields/linkersfilterpublicnotes.php +++ b/admin/src/Field/LinkersfilterpublicnotesField.php @@ -14,39 +14,40 @@ @license GNU/GPL Version 2 or later - http://www.gnu.org/licenses/gpl-2.0.html /------------------------------------------------------------------------------------------------------*/ +namespace TrueChristianChurch\Component\Getbible\Administrator\Field; // No direct access to this file -defined('_JEXEC') or die('Restricted access'); +\defined('_JEXEC') or die; use Joomla\CMS\Factory; +use Joomla\CMS\Form\Field\ListField; use Joomla\CMS\Language\Text; use Joomla\CMS\HTML\HTMLHelper as Html; - -// import the list field type -jimport('joomla.form.helper'); -JFormHelper::loadFieldClass('list'); +use Joomla\CMS\Component\ComponentHelper; +use TrueChristianChurch\Component\Getbible\Administrator\Helper\GetbibleHelper; /** * Linkersfilterpublicnotes Form Field class for the Getbible component */ -class JFormFieldLinkersfilterpublicnotes extends JFormFieldList +class LinkersfilterpublicnotesField extends ListField { /** * The linkersfilterpublicnotes field type. * - * @var string + * @var string */ - public $type = 'linkersfilterpublicnotes'; + public $type = 'Linkersfilterpublicnotes'; /** * Method to get a list of options for a list input. * - * @return array An array of JHtml options. + * @return array An array of Html options. + * @since 1.6 */ protected function getOptions() { // Get a db connection. - $db = Factory::getDbo(); + $db = Factory::getContainer()->get(\Joomla\Database\DatabaseInterface::class); // Create a new query object. $query = $db->getQuery(true); @@ -60,7 +61,7 @@ class JFormFieldLinkersfilterpublicnotes extends JFormFieldList $db->setQuery($query); $_results = $db->loadColumn(); - $_filter = array(); + $_filter = []; $_filter[] = Html::_('select.option', '', '- ' . Text::_('COM_GETBIBLE_FILTER_SELECT_PUBLIC_NOTES') . ' -'); if ($_results) diff --git a/admin/models/fields/linkersfilterpublictaggedverses.php b/admin/src/Field/LinkersfilterpublictaggedversesField.php similarity index 80% rename from admin/models/fields/linkersfilterpublictaggedverses.php rename to admin/src/Field/LinkersfilterpublictaggedversesField.php index 8e525df..cda337e 100644 --- a/admin/models/fields/linkersfilterpublictaggedverses.php +++ b/admin/src/Field/LinkersfilterpublictaggedversesField.php @@ -14,39 +14,40 @@ @license GNU/GPL Version 2 or later - http://www.gnu.org/licenses/gpl-2.0.html /------------------------------------------------------------------------------------------------------*/ +namespace TrueChristianChurch\Component\Getbible\Administrator\Field; // No direct access to this file -defined('_JEXEC') or die('Restricted access'); +\defined('_JEXEC') or die; use Joomla\CMS\Factory; +use Joomla\CMS\Form\Field\ListField; use Joomla\CMS\Language\Text; use Joomla\CMS\HTML\HTMLHelper as Html; - -// import the list field type -jimport('joomla.form.helper'); -JFormHelper::loadFieldClass('list'); +use Joomla\CMS\Component\ComponentHelper; +use TrueChristianChurch\Component\Getbible\Administrator\Helper\GetbibleHelper; /** * Linkersfilterpublictaggedverses Form Field class for the Getbible component */ -class JFormFieldLinkersfilterpublictaggedverses extends JFormFieldList +class LinkersfilterpublictaggedversesField extends ListField { /** * The linkersfilterpublictaggedverses field type. * - * @var string + * @var string */ - public $type = 'linkersfilterpublictaggedverses'; + public $type = 'Linkersfilterpublictaggedverses'; /** * Method to get a list of options for a list input. * - * @return array An array of JHtml options. + * @return array An array of Html options. + * @since 1.6 */ protected function getOptions() { // Get a db connection. - $db = Factory::getDbo(); + $db = Factory::getContainer()->get(\Joomla\Database\DatabaseInterface::class); // Create a new query object. $query = $db->getQuery(true); @@ -60,7 +61,7 @@ class JFormFieldLinkersfilterpublictaggedverses extends JFormFieldList $db->setQuery($query); $_results = $db->loadColumn(); - $_filter = array(); + $_filter = []; $_filter[] = Html::_('select.option', '', '- ' . Text::_('COM_GETBIBLE_FILTER_SELECT_PUBLIC_TAGGED_VERSES') . ' -'); if ($_results) diff --git a/admin/models/fields/notesfilteraccess.php b/admin/src/Field/NotesfilteraccessField.php similarity index 79% rename from admin/models/fields/notesfilteraccess.php rename to admin/src/Field/NotesfilteraccessField.php index 9f1481f..667b24a 100644 --- a/admin/models/fields/notesfilteraccess.php +++ b/admin/src/Field/NotesfilteraccessField.php @@ -14,39 +14,40 @@ @license GNU/GPL Version 2 or later - http://www.gnu.org/licenses/gpl-2.0.html /------------------------------------------------------------------------------------------------------*/ +namespace TrueChristianChurch\Component\Getbible\Administrator\Field; // No direct access to this file -defined('_JEXEC') or die('Restricted access'); +\defined('_JEXEC') or die; use Joomla\CMS\Factory; +use Joomla\CMS\Form\Field\ListField; use Joomla\CMS\Language\Text; use Joomla\CMS\HTML\HTMLHelper as Html; - -// import the list field type -jimport('joomla.form.helper'); -JFormHelper::loadFieldClass('list'); +use Joomla\CMS\Component\ComponentHelper; +use TrueChristianChurch\Component\Getbible\Administrator\Helper\GetbibleHelper; /** * Notesfilteraccess Form Field class for the Getbible component */ -class JFormFieldNotesfilteraccess extends JFormFieldList +class NotesfilteraccessField extends ListField { /** * The notesfilteraccess field type. * - * @var string + * @var string */ - public $type = 'notesfilteraccess'; + public $type = 'Notesfilteraccess'; /** * Method to get a list of options for a list input. * - * @return array An array of JHtml options. + * @return array An array of Html options. + * @since 1.6 */ protected function getOptions() { // Get a db connection. - $db = Factory::getDbo(); + $db = Factory::getContainer()->get(\Joomla\Database\DatabaseInterface::class); // Create a new query object. $query = $db->getQuery(true); @@ -60,7 +61,7 @@ class JFormFieldNotesfilteraccess extends JFormFieldList $db->setQuery($query); $_results = $db->loadColumn(); - $_filter = array(); + $_filter = []; $_filter[] = Html::_('select.option', '', '- ' . Text::_('COM_GETBIBLE_FILTER_SELECT_ACCESS') . ' -'); if ($_results) diff --git a/admin/models/fields/notesfilterbooknr.php b/admin/src/Field/NotesfilterbooknrField.php similarity index 78% rename from admin/models/fields/notesfilterbooknr.php rename to admin/src/Field/NotesfilterbooknrField.php index d6c84e6..fb89a65 100644 --- a/admin/models/fields/notesfilterbooknr.php +++ b/admin/src/Field/NotesfilterbooknrField.php @@ -14,39 +14,40 @@ @license GNU/GPL Version 2 or later - http://www.gnu.org/licenses/gpl-2.0.html /------------------------------------------------------------------------------------------------------*/ +namespace TrueChristianChurch\Component\Getbible\Administrator\Field; // No direct access to this file -defined('_JEXEC') or die('Restricted access'); +\defined('_JEXEC') or die; use Joomla\CMS\Factory; +use Joomla\CMS\Form\Field\ListField; use Joomla\CMS\Language\Text; use Joomla\CMS\HTML\HTMLHelper as Html; - -// import the list field type -jimport('joomla.form.helper'); -JFormHelper::loadFieldClass('list'); +use Joomla\CMS\Component\ComponentHelper; +use TrueChristianChurch\Component\Getbible\Administrator\Helper\GetbibleHelper; /** * Notesfilterbooknr Form Field class for the Getbible component */ -class JFormFieldNotesfilterbooknr extends JFormFieldList +class NotesfilterbooknrField extends ListField { /** * The notesfilterbooknr field type. * - * @var string + * @var string */ - public $type = 'notesfilterbooknr'; + public $type = 'Notesfilterbooknr'; /** * Method to get a list of options for a list input. * - * @return array An array of JHtml options. + * @return array An array of Html options. + * @since 1.6 */ protected function getOptions() { // Get a db connection. - $db = Factory::getDbo(); + $db = Factory::getContainer()->get(\Joomla\Database\DatabaseInterface::class); // Create a new query object. $query = $db->getQuery(true); @@ -60,7 +61,7 @@ class JFormFieldNotesfilterbooknr extends JFormFieldList $db->setQuery($query); $_results = $db->loadColumn(); - $_filter = array(); + $_filter = []; $_filter[] = Html::_('select.option', '', '- ' . Text::_('COM_GETBIBLE_FILTER_SELECT_BOOK_NUMBER') . ' -'); if ($_results) diff --git a/admin/models/fields/notesfilterchapter.php b/admin/src/Field/NotesfilterchapterField.php similarity index 78% rename from admin/models/fields/notesfilterchapter.php rename to admin/src/Field/NotesfilterchapterField.php index 4efc73d..bcb3c10 100644 --- a/admin/models/fields/notesfilterchapter.php +++ b/admin/src/Field/NotesfilterchapterField.php @@ -14,39 +14,40 @@ @license GNU/GPL Version 2 or later - http://www.gnu.org/licenses/gpl-2.0.html /------------------------------------------------------------------------------------------------------*/ +namespace TrueChristianChurch\Component\Getbible\Administrator\Field; // No direct access to this file -defined('_JEXEC') or die('Restricted access'); +\defined('_JEXEC') or die; use Joomla\CMS\Factory; +use Joomla\CMS\Form\Field\ListField; use Joomla\CMS\Language\Text; use Joomla\CMS\HTML\HTMLHelper as Html; - -// import the list field type -jimport('joomla.form.helper'); -JFormHelper::loadFieldClass('list'); +use Joomla\CMS\Component\ComponentHelper; +use TrueChristianChurch\Component\Getbible\Administrator\Helper\GetbibleHelper; /** * Notesfilterchapter Form Field class for the Getbible component */ -class JFormFieldNotesfilterchapter extends JFormFieldList +class NotesfilterchapterField extends ListField { /** * The notesfilterchapter field type. * - * @var string + * @var string */ - public $type = 'notesfilterchapter'; + public $type = 'Notesfilterchapter'; /** * Method to get a list of options for a list input. * - * @return array An array of JHtml options. + * @return array An array of Html options. + * @since 1.6 */ protected function getOptions() { // Get a db connection. - $db = Factory::getDbo(); + $db = Factory::getContainer()->get(\Joomla\Database\DatabaseInterface::class); // Create a new query object. $query = $db->getQuery(true); @@ -60,7 +61,7 @@ class JFormFieldNotesfilterchapter extends JFormFieldList $db->setQuery($query); $_results = $db->loadColumn(); - $_filter = array(); + $_filter = []; $_filter[] = Html::_('select.option', '', '- ' . Text::_('COM_GETBIBLE_FILTER_SELECT_CHAPTER') . ' -'); if ($_results) diff --git a/admin/models/fields/notesfilterverse.php b/admin/src/Field/NotesfilterverseField.php similarity index 78% rename from admin/models/fields/notesfilterverse.php rename to admin/src/Field/NotesfilterverseField.php index 0a5f119..66596f7 100644 --- a/admin/models/fields/notesfilterverse.php +++ b/admin/src/Field/NotesfilterverseField.php @@ -14,39 +14,40 @@ @license GNU/GPL Version 2 or later - http://www.gnu.org/licenses/gpl-2.0.html /------------------------------------------------------------------------------------------------------*/ +namespace TrueChristianChurch\Component\Getbible\Administrator\Field; // No direct access to this file -defined('_JEXEC') or die('Restricted access'); +\defined('_JEXEC') or die; use Joomla\CMS\Factory; +use Joomla\CMS\Form\Field\ListField; use Joomla\CMS\Language\Text; use Joomla\CMS\HTML\HTMLHelper as Html; - -// import the list field type -jimport('joomla.form.helper'); -JFormHelper::loadFieldClass('list'); +use Joomla\CMS\Component\ComponentHelper; +use TrueChristianChurch\Component\Getbible\Administrator\Helper\GetbibleHelper; /** * Notesfilterverse Form Field class for the Getbible component */ -class JFormFieldNotesfilterverse extends JFormFieldList +class NotesfilterverseField extends ListField { /** * The notesfilterverse field type. * - * @var string + * @var string */ - public $type = 'notesfilterverse'; + public $type = 'Notesfilterverse'; /** * Method to get a list of options for a list input. * - * @return array An array of JHtml options. + * @return array An array of Html options. + * @since 1.6 */ protected function getOptions() { // Get a db connection. - $db = Factory::getDbo(); + $db = Factory::getContainer()->get(\Joomla\Database\DatabaseInterface::class); // Create a new query object. $query = $db->getQuery(true); @@ -60,7 +61,7 @@ class JFormFieldNotesfilterverse extends JFormFieldList $db->setQuery($query); $_results = $db->loadColumn(); - $_filter = array(); + $_filter = []; $_filter[] = Html::_('select.option', '', '- ' . Text::_('COM_GETBIBLE_FILTER_SELECT_VERSE') . ' -'); if ($_results) diff --git a/admin/models/fields/openaimessagesfilterrole.php b/admin/src/Field/OpenaimessagesfilterroleField.php similarity index 79% rename from admin/models/fields/openaimessagesfilterrole.php rename to admin/src/Field/OpenaimessagesfilterroleField.php index 4f13a97..5a2bd62 100644 --- a/admin/models/fields/openaimessagesfilterrole.php +++ b/admin/src/Field/OpenaimessagesfilterroleField.php @@ -14,39 +14,40 @@ @license GNU/GPL Version 2 or later - http://www.gnu.org/licenses/gpl-2.0.html /------------------------------------------------------------------------------------------------------*/ +namespace TrueChristianChurch\Component\Getbible\Administrator\Field; // No direct access to this file -defined('_JEXEC') or die('Restricted access'); +\defined('_JEXEC') or die; use Joomla\CMS\Factory; +use Joomla\CMS\Form\Field\ListField; use Joomla\CMS\Language\Text; use Joomla\CMS\HTML\HTMLHelper as Html; - -// import the list field type -jimport('joomla.form.helper'); -JFormHelper::loadFieldClass('list'); +use Joomla\CMS\Component\ComponentHelper; +use TrueChristianChurch\Component\Getbible\Administrator\Helper\GetbibleHelper; /** * Openaimessagesfilterrole Form Field class for the Getbible component */ -class JFormFieldOpenaimessagesfilterrole extends JFormFieldList +class OpenaimessagesfilterroleField extends ListField { /** * The openaimessagesfilterrole field type. * - * @var string + * @var string */ - public $type = 'openaimessagesfilterrole'; + public $type = 'Openaimessagesfilterrole'; /** * Method to get a list of options for a list input. * - * @return array An array of JHtml options. + * @return array An array of Html options. + * @since 1.6 */ protected function getOptions() { // Get a db connection. - $db = Factory::getDbo(); + $db = Factory::getContainer()->get(\Joomla\Database\DatabaseInterface::class); // Create a new query object. $query = $db->getQuery(true); @@ -60,7 +61,7 @@ class JFormFieldOpenaimessagesfilterrole extends JFormFieldList $db->setQuery($query); $_results = $db->loadColumn(); - $_filter = array(); + $_filter = []; $_filter[] = Html::_('select.option', '', '- ' . Text::_('COM_GETBIBLE_FILTER_SELECT_ROLE') . ' -'); if ($_results) diff --git a/admin/models/fields/openaimessagesfiltersource.php b/admin/src/Field/OpenaimessagesfiltersourceField.php similarity index 79% rename from admin/models/fields/openaimessagesfiltersource.php rename to admin/src/Field/OpenaimessagesfiltersourceField.php index 77400c4..a2be836 100644 --- a/admin/models/fields/openaimessagesfiltersource.php +++ b/admin/src/Field/OpenaimessagesfiltersourceField.php @@ -14,39 +14,40 @@ @license GNU/GPL Version 2 or later - http://www.gnu.org/licenses/gpl-2.0.html /------------------------------------------------------------------------------------------------------*/ +namespace TrueChristianChurch\Component\Getbible\Administrator\Field; // No direct access to this file -defined('_JEXEC') or die('Restricted access'); +\defined('_JEXEC') or die; use Joomla\CMS\Factory; +use Joomla\CMS\Form\Field\ListField; use Joomla\CMS\Language\Text; use Joomla\CMS\HTML\HTMLHelper as Html; - -// import the list field type -jimport('joomla.form.helper'); -JFormHelper::loadFieldClass('list'); +use Joomla\CMS\Component\ComponentHelper; +use TrueChristianChurch\Component\Getbible\Administrator\Helper\GetbibleHelper; /** * Openaimessagesfiltersource Form Field class for the Getbible component */ -class JFormFieldOpenaimessagesfiltersource extends JFormFieldList +class OpenaimessagesfiltersourceField extends ListField { /** * The openaimessagesfiltersource field type. * - * @var string + * @var string */ - public $type = 'openaimessagesfiltersource'; + public $type = 'Openaimessagesfiltersource'; /** * Method to get a list of options for a list input. * - * @return array An array of JHtml options. + * @return array An array of Html options. + * @since 1.6 */ protected function getOptions() { // Get a db connection. - $db = Factory::getDbo(); + $db = Factory::getContainer()->get(\Joomla\Database\DatabaseInterface::class); // Create a new query object. $query = $db->getQuery(true); @@ -60,7 +61,7 @@ class JFormFieldOpenaimessagesfiltersource extends JFormFieldList $db->setQuery($query); $_results = $db->loadColumn(); - $_filter = array(); + $_filter = []; $_filter[] = Html::_('select.option', '', '- ' . Text::_('COM_GETBIBLE_FILTER_SELECT_SOURCE') . ' -'); if ($_results) diff --git a/admin/models/fields/openairesponses.php b/admin/src/Field/OpenairesponsesField.php similarity index 74% rename from admin/models/fields/openairesponses.php rename to admin/src/Field/OpenairesponsesField.php index 0a592d3..01c54ff 100644 --- a/admin/models/fields/openairesponses.php +++ b/admin/src/Field/OpenairesponsesField.php @@ -14,41 +14,42 @@ @license GNU/GPL Version 2 or later - http://www.gnu.org/licenses/gpl-2.0.html /------------------------------------------------------------------------------------------------------*/ +namespace TrueChristianChurch\Component\Getbible\Administrator\Field; // No direct access to this file -defined('_JEXEC') or die('Restricted access'); +\defined('_JEXEC') or die; use Joomla\CMS\Factory; +use Joomla\CMS\Form\Field\ListField; use Joomla\CMS\Language\Text; use Joomla\CMS\HTML\HTMLHelper as Html; - -// import the list field type -jimport('joomla.form.helper'); -JFormHelper::loadFieldClass('list'); +use Joomla\CMS\Component\ComponentHelper; +use TrueChristianChurch\Component\Getbible\Administrator\Helper\GetbibleHelper; /** * Openairesponses Form Field class for the Getbible component */ -class JFormFieldOpenairesponses extends JFormFieldList +class OpenairesponsesField extends ListField { /** * The openairesponses field type. * - * @var string + * @var string */ - public $type = 'openairesponses'; + public $type = 'Openairesponses'; /** * Method to get a list of options for a list input. * - * @return array An array of JHtml options. + * @return array An array of Html options. + * @since 1.6 */ protected function getOptions() { // Get the user object. - $user = JFactory::getUser(); + $user = Factory::getUser(); // Get the databse object. - $db = JFactory::getDBO(); + $db = Factory::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')); @@ -70,11 +71,11 @@ class JFormFieldOpenairesponses extends JFormFieldList { if ($this->multiple === false) { - $options[] = JHtml::_('select.option', '', JText::_('COM_GETBIBLE_SELECT_AN_OPTION')); + $options[] = Html::_('select.option', '', Text::_('COM_GETBIBLE_SELECT_AN_OPTION')); } foreach($items as $item) { - $options[] = JHtml::_('select.option', $item->response_id, $item->open_ai_response_response_id); + $options[] = Html::_('select.option', $item->response_id, $item->open_ai_response_response_id); } } return $options; diff --git a/admin/models/fields/openairesponsesfilterresponseid.php b/admin/src/Field/OpenairesponsesfilterresponseidField.php similarity index 78% rename from admin/models/fields/openairesponsesfilterresponseid.php rename to admin/src/Field/OpenairesponsesfilterresponseidField.php index 2865746..6ca43b2 100644 --- a/admin/models/fields/openairesponsesfilterresponseid.php +++ b/admin/src/Field/OpenairesponsesfilterresponseidField.php @@ -14,39 +14,40 @@ @license GNU/GPL Version 2 or later - http://www.gnu.org/licenses/gpl-2.0.html /------------------------------------------------------------------------------------------------------*/ +namespace TrueChristianChurch\Component\Getbible\Administrator\Field; // No direct access to this file -defined('_JEXEC') or die('Restricted access'); +\defined('_JEXEC') or die; use Joomla\CMS\Factory; +use Joomla\CMS\Form\Field\ListField; use Joomla\CMS\Language\Text; use Joomla\CMS\HTML\HTMLHelper as Html; - -// import the list field type -jimport('joomla.form.helper'); -JFormHelper::loadFieldClass('list'); +use Joomla\CMS\Component\ComponentHelper; +use TrueChristianChurch\Component\Getbible\Administrator\Helper\GetbibleHelper; /** * Openairesponsesfilterresponseid Form Field class for the Getbible component */ -class JFormFieldOpenairesponsesfilterresponseid extends JFormFieldList +class OpenairesponsesfilterresponseidField extends ListField { /** * The openairesponsesfilterresponseid field type. * - * @var string + * @var string */ - public $type = 'openairesponsesfilterresponseid'; + public $type = 'Openairesponsesfilterresponseid'; /** * Method to get a list of options for a list input. * - * @return array An array of JHtml options. + * @return array An array of Html options. + * @since 1.6 */ protected function getOptions() { // Get a db connection. - $db = Factory::getDbo(); + $db = Factory::getContainer()->get(\Joomla\Database\DatabaseInterface::class); // Create a new query object. $query = $db->getQuery(true); @@ -60,7 +61,7 @@ class JFormFieldOpenairesponsesfilterresponseid extends JFormFieldList $db->setQuery($query); $_results = $db->loadColumn(); - $_filter = array(); + $_filter = []; $_filter[] = Html::_('select.option', '', '- ' . Text::_('COM_GETBIBLE_FILTER_SELECT_RESPONSE_ID') . ' -'); if ($_results) diff --git a/admin/models/fields/openairesponsesfilterresponsemodel.php b/admin/src/Field/OpenairesponsesfilterresponsemodelField.php similarity index 78% rename from admin/models/fields/openairesponsesfilterresponsemodel.php rename to admin/src/Field/OpenairesponsesfilterresponsemodelField.php index 01cab9e..f2359f8 100644 --- a/admin/models/fields/openairesponsesfilterresponsemodel.php +++ b/admin/src/Field/OpenairesponsesfilterresponsemodelField.php @@ -14,39 +14,40 @@ @license GNU/GPL Version 2 or later - http://www.gnu.org/licenses/gpl-2.0.html /------------------------------------------------------------------------------------------------------*/ +namespace TrueChristianChurch\Component\Getbible\Administrator\Field; // No direct access to this file -defined('_JEXEC') or die('Restricted access'); +\defined('_JEXEC') or die; use Joomla\CMS\Factory; +use Joomla\CMS\Form\Field\ListField; use Joomla\CMS\Language\Text; use Joomla\CMS\HTML\HTMLHelper as Html; - -// import the list field type -jimport('joomla.form.helper'); -JFormHelper::loadFieldClass('list'); +use Joomla\CMS\Component\ComponentHelper; +use TrueChristianChurch\Component\Getbible\Administrator\Helper\GetbibleHelper; /** * Openairesponsesfilterresponsemodel Form Field class for the Getbible component */ -class JFormFieldOpenairesponsesfilterresponsemodel extends JFormFieldList +class OpenairesponsesfilterresponsemodelField extends ListField { /** * The openairesponsesfilterresponsemodel field type. * - * @var string + * @var string */ - public $type = 'openairesponsesfilterresponsemodel'; + public $type = 'Openairesponsesfilterresponsemodel'; /** * Method to get a list of options for a list input. * - * @return array An array of JHtml options. + * @return array An array of Html options. + * @since 1.6 */ protected function getOptions() { // Get a db connection. - $db = Factory::getDbo(); + $db = Factory::getContainer()->get(\Joomla\Database\DatabaseInterface::class); // Create a new query object. $query = $db->getQuery(true); @@ -60,7 +61,7 @@ class JFormFieldOpenairesponsesfilterresponsemodel extends JFormFieldList $db->setQuery($query); $_results = $db->loadColumn(); - $_filter = array(); + $_filter = []; $_filter[] = Html::_('select.option', '', '- ' . Text::_('COM_GETBIBLE_FILTER_SELECT_RESPONSE_MODEL') . ' -'); if ($_results) diff --git a/admin/models/fields/passwordsfiltername.php b/admin/src/Field/PasswordsfilternameField.php similarity index 78% rename from admin/models/fields/passwordsfiltername.php rename to admin/src/Field/PasswordsfilternameField.php index 2f8f85d..22b0d21 100644 --- a/admin/models/fields/passwordsfiltername.php +++ b/admin/src/Field/PasswordsfilternameField.php @@ -14,39 +14,40 @@ @license GNU/GPL Version 2 or later - http://www.gnu.org/licenses/gpl-2.0.html /------------------------------------------------------------------------------------------------------*/ +namespace TrueChristianChurch\Component\Getbible\Administrator\Field; // No direct access to this file -defined('_JEXEC') or die('Restricted access'); +\defined('_JEXEC') or die; use Joomla\CMS\Factory; +use Joomla\CMS\Form\Field\ListField; use Joomla\CMS\Language\Text; use Joomla\CMS\HTML\HTMLHelper as Html; - -// import the list field type -jimport('joomla.form.helper'); -JFormHelper::loadFieldClass('list'); +use Joomla\CMS\Component\ComponentHelper; +use TrueChristianChurch\Component\Getbible\Administrator\Helper\GetbibleHelper; /** * Passwordsfiltername Form Field class for the Getbible component */ -class JFormFieldPasswordsfiltername extends JFormFieldList +class PasswordsfilternameField extends ListField { /** * The passwordsfiltername field type. * - * @var string + * @var string */ - public $type = 'passwordsfiltername'; + public $type = 'Passwordsfiltername'; /** * Method to get a list of options for a list input. * - * @return array An array of JHtml options. + * @return array An array of Html options. + * @since 1.6 */ protected function getOptions() { // Get a db connection. - $db = Factory::getDbo(); + $db = Factory::getContainer()->get(\Joomla\Database\DatabaseInterface::class); // Create a new query object. $query = $db->getQuery(true); @@ -60,7 +61,7 @@ class JFormFieldPasswordsfiltername extends JFormFieldList $db->setQuery($query); $_results = $db->loadColumn(); - $_filter = array(); + $_filter = []; $_filter[] = Html::_('select.option', '', '- ' . Text::_('COM_GETBIBLE_FILTER_SELECT_NAME') . ' -'); if ($_results) diff --git a/admin/models/fields/prompts.php b/admin/src/Field/PromptsField.php similarity index 73% rename from admin/models/fields/prompts.php rename to admin/src/Field/PromptsField.php index 9663eb6..5b0d47d 100644 --- a/admin/models/fields/prompts.php +++ b/admin/src/Field/PromptsField.php @@ -14,41 +14,42 @@ @license GNU/GPL Version 2 or later - http://www.gnu.org/licenses/gpl-2.0.html /------------------------------------------------------------------------------------------------------*/ +namespace TrueChristianChurch\Component\Getbible\Administrator\Field; // No direct access to this file -defined('_JEXEC') or die('Restricted access'); +\defined('_JEXEC') or die; use Joomla\CMS\Factory; +use Joomla\CMS\Form\Field\ListField; use Joomla\CMS\Language\Text; use Joomla\CMS\HTML\HTMLHelper as Html; - -// import the list field type -jimport('joomla.form.helper'); -JFormHelper::loadFieldClass('list'); +use Joomla\CMS\Component\ComponentHelper; +use TrueChristianChurch\Component\Getbible\Administrator\Helper\GetbibleHelper; /** * Prompts Form Field class for the Getbible component */ -class JFormFieldPrompts extends JFormFieldList +class PromptsField extends ListField { /** * The prompts field type. * - * @var string + * @var string */ - public $type = 'prompts'; + public $type = 'Prompts'; /** * Method to get a list of options for a list input. * - * @return array An array of JHtml options. + * @return array An array of Html options. + * @since 1.6 */ protected function getOptions() { // Get the user object. - $user = JFactory::getUser(); + $user = Factory::getUser(); // Get the databse object. - $db = JFactory::getDBO(); + $db = Factory::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')); @@ -70,11 +71,11 @@ class JFormFieldPrompts extends JFormFieldList { if ($this->multiple === false) { - $options[] = JHtml::_('select.option', '', JText::_('COM_GETBIBLE_SELECT_AN_OPTION')); + $options[] = Html::_('select.option', '', Text::_('COM_GETBIBLE_SELECT_AN_OPTION')); } foreach($items as $item) { - $options[] = JHtml::_('select.option', $item->guid, $item->prompt_name . ' (' . $item->guid . ')'); + $options[] = Html::_('select.option', $item->guid, $item->prompt_name . ' (' . $item->guid . ')'); } } return $options; diff --git a/admin/models/fields/promptsfiltercachebehaviour.php b/admin/src/Field/PromptsfiltercachebehaviourField.php similarity index 80% rename from admin/models/fields/promptsfiltercachebehaviour.php rename to admin/src/Field/PromptsfiltercachebehaviourField.php index 229db2b..2c49863 100644 --- a/admin/models/fields/promptsfiltercachebehaviour.php +++ b/admin/src/Field/PromptsfiltercachebehaviourField.php @@ -14,39 +14,40 @@ @license GNU/GPL Version 2 or later - http://www.gnu.org/licenses/gpl-2.0.html /------------------------------------------------------------------------------------------------------*/ +namespace TrueChristianChurch\Component\Getbible\Administrator\Field; // No direct access to this file -defined('_JEXEC') or die('Restricted access'); +\defined('_JEXEC') or die; use Joomla\CMS\Factory; +use Joomla\CMS\Form\Field\ListField; use Joomla\CMS\Language\Text; use Joomla\CMS\HTML\HTMLHelper as Html; - -// import the list field type -jimport('joomla.form.helper'); -JFormHelper::loadFieldClass('list'); +use Joomla\CMS\Component\ComponentHelper; +use TrueChristianChurch\Component\Getbible\Administrator\Helper\GetbibleHelper; /** * Promptsfiltercachebehaviour Form Field class for the Getbible component */ -class JFormFieldPromptsfiltercachebehaviour extends JFormFieldList +class PromptsfiltercachebehaviourField extends ListField { /** * The promptsfiltercachebehaviour field type. * - * @var string + * @var string */ - public $type = 'promptsfiltercachebehaviour'; + public $type = 'Promptsfiltercachebehaviour'; /** * Method to get a list of options for a list input. * - * @return array An array of JHtml options. + * @return array An array of Html options. + * @since 1.6 */ protected function getOptions() { // Get a db connection. - $db = Factory::getDbo(); + $db = Factory::getContainer()->get(\Joomla\Database\DatabaseInterface::class); // Create a new query object. $query = $db->getQuery(true); @@ -60,7 +61,7 @@ class JFormFieldPromptsfiltercachebehaviour extends JFormFieldList $db->setQuery($query); $_results = $db->loadColumn(); - $_filter = array(); + $_filter = []; $_filter[] = Html::_('select.option', '', '- ' . Text::_('COM_GETBIBLE_FILTER_SELECT_CACHE_BEHAVIOUR') . ' -'); if ($_results) diff --git a/admin/models/fields/promptsfiltermodel.php b/admin/src/Field/PromptsfiltermodelField.php similarity index 79% rename from admin/models/fields/promptsfiltermodel.php rename to admin/src/Field/PromptsfiltermodelField.php index eebfc14..4979e53 100644 --- a/admin/models/fields/promptsfiltermodel.php +++ b/admin/src/Field/PromptsfiltermodelField.php @@ -14,39 +14,40 @@ @license GNU/GPL Version 2 or later - http://www.gnu.org/licenses/gpl-2.0.html /------------------------------------------------------------------------------------------------------*/ +namespace TrueChristianChurch\Component\Getbible\Administrator\Field; // No direct access to this file -defined('_JEXEC') or die('Restricted access'); +\defined('_JEXEC') or die; use Joomla\CMS\Factory; +use Joomla\CMS\Form\Field\ListField; use Joomla\CMS\Language\Text; use Joomla\CMS\HTML\HTMLHelper as Html; - -// import the list field type -jimport('joomla.form.helper'); -JFormHelper::loadFieldClass('list'); +use Joomla\CMS\Component\ComponentHelper; +use TrueChristianChurch\Component\Getbible\Administrator\Helper\GetbibleHelper; /** * Promptsfiltermodel Form Field class for the Getbible component */ -class JFormFieldPromptsfiltermodel extends JFormFieldList +class PromptsfiltermodelField extends ListField { /** * The promptsfiltermodel field type. * - * @var string + * @var string */ - public $type = 'promptsfiltermodel'; + public $type = 'Promptsfiltermodel'; /** * Method to get a list of options for a list input. * - * @return array An array of JHtml options. + * @return array An array of Html options. + * @since 1.6 */ protected function getOptions() { // Get a db connection. - $db = Factory::getDbo(); + $db = Factory::getContainer()->get(\Joomla\Database\DatabaseInterface::class); // Create a new query object. $query = $db->getQuery(true); @@ -60,7 +61,7 @@ class JFormFieldPromptsfiltermodel extends JFormFieldList $db->setQuery($query); $_results = $db->loadColumn(); - $_filter = array(); + $_filter = []; $_filter[] = Html::_('select.option', '', '- ' . Text::_('COM_GETBIBLE_FILTER_SELECT_MODEL') . ' -'); if ($_results) diff --git a/admin/models/fields/promptsfiltername.php b/admin/src/Field/PromptsfilternameField.php similarity index 78% rename from admin/models/fields/promptsfiltername.php rename to admin/src/Field/PromptsfilternameField.php index b50e321..7430d1f 100644 --- a/admin/models/fields/promptsfiltername.php +++ b/admin/src/Field/PromptsfilternameField.php @@ -14,39 +14,40 @@ @license GNU/GPL Version 2 or later - http://www.gnu.org/licenses/gpl-2.0.html /------------------------------------------------------------------------------------------------------*/ +namespace TrueChristianChurch\Component\Getbible\Administrator\Field; // No direct access to this file -defined('_JEXEC') or die('Restricted access'); +\defined('_JEXEC') or die; use Joomla\CMS\Factory; +use Joomla\CMS\Form\Field\ListField; use Joomla\CMS\Language\Text; use Joomla\CMS\HTML\HTMLHelper as Html; - -// import the list field type -jimport('joomla.form.helper'); -JFormHelper::loadFieldClass('list'); +use Joomla\CMS\Component\ComponentHelper; +use TrueChristianChurch\Component\Getbible\Administrator\Helper\GetbibleHelper; /** * Promptsfiltername Form Field class for the Getbible component */ -class JFormFieldPromptsfiltername extends JFormFieldList +class PromptsfilternameField extends ListField { /** * The promptsfiltername field type. * - * @var string + * @var string */ - public $type = 'promptsfiltername'; + public $type = 'Promptsfiltername'; /** * Method to get a list of options for a list input. * - * @return array An array of JHtml options. + * @return array An array of Html options. + * @since 1.6 */ protected function getOptions() { // Get a db connection. - $db = Factory::getDbo(); + $db = Factory::getContainer()->get(\Joomla\Database\DatabaseInterface::class); // Create a new query object. $query = $db->getQuery(true); @@ -60,7 +61,7 @@ class JFormFieldPromptsfiltername extends JFormFieldList $db->setQuery($query); $_results = $db->loadColumn(); - $_filter = array(); + $_filter = []; $_filter[] = Html::_('select.option', '', '- ' . Text::_('COM_GETBIBLE_FILTER_SELECT_NAME') . ' -'); if ($_results) diff --git a/admin/models/fields/tagers.php b/admin/src/Field/TagersField.php similarity index 71% rename from admin/models/fields/tagers.php rename to admin/src/Field/TagersField.php index bf0e188..219d0c1 100644 --- a/admin/models/fields/tagers.php +++ b/admin/src/Field/TagersField.php @@ -14,29 +14,29 @@ @license GNU/GPL Version 2 or later - http://www.gnu.org/licenses/gpl-2.0.html /------------------------------------------------------------------------------------------------------*/ +namespace TrueChristianChurch\Component\Getbible\Administrator\Field; // No direct access to this file -defined('_JEXEC') or die('Restricted access'); +\defined('_JEXEC') or die; use Joomla\CMS\Factory; +use Joomla\CMS\Form\Field\ListField; use Joomla\CMS\Language\Text; use Joomla\CMS\HTML\HTMLHelper as Html; - -// import the list field type -jimport('joomla.form.helper'); -JFormHelper::loadFieldClass('list'); +use Joomla\CMS\Component\ComponentHelper; +use TrueChristianChurch\Component\Getbible\Administrator\Helper\GetbibleHelper; /** * Tagers Form Field class for the Getbible component */ -class JFormFieldTagers extends JFormFieldList +class TagersField extends ListField { /** * The tagers field type. * - * @var string + * @var string */ - public $type = 'tagers'; + public $type = 'Tagers'; /** * Override to add new button @@ -74,7 +74,7 @@ class JFormFieldTagers extends JFormFieldList $ref = '&ref=' . $values['view'] . '&refid=' . $values['id']; $refJ = '&ref=' . $values['view'] . '&refid=' . $values['id']; // get the return value. - $_uri = (string) JUri::getInstance(); + $_uri = (string) \Joomla\CMS\Uri\Uri::getInstance(); $_return = urlencode(base64_encode($_uri)); // load return value. $ref .= '&return=' . $_return; @@ -87,45 +87,47 @@ class JFormFieldTagers extends JFormFieldList $button_label = preg_replace("/[^A-Za-z ]/", '', $button_label); $button_label = ucfirst(strtolower($button_label)); // get user object - $user = Factory::getUser(); + $user = Factory::getApplication()->getIdentity(); // only add if user allowed to create tag - if ($user->authorise('tag.create', 'com_getbible') && $app->isAdmin()) // TODO for now only in admin area. + if ($user->authorise('tag.create', 'com_getbible') && $app->isClient('administrator')) // 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. + if ($user->authorise('tag.edit', 'com_getbible') && $app->isClient('administrator')) // 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) { + document.addEventListener('DOMContentLoaded', function() { + document.getElementById('jform_".$button_code_name."').addEventListener('change', function(e) { e.preventDefault(); - var ".$button_code_name."Value = jQuery('#jform_".$button_code_name."').val(); + let ".$button_code_name."Value = this.value; ".$button_code_name."Button(".$button_code_name."Value); }); - var ".$button_code_name."Value = jQuery('#jform_".$button_code_name."').val(); + let ".$button_code_name."Value = document.getElementById('jform_".$button_code_name."').value; ".$button_code_name."Button(".$button_code_name."Value); }); function ".$button_code_name."Button(value) { + var createButton = document.getElementById('".$button_code_name."Create'); + var editButton = document.getElementById('".$button_code_name."Edit'); if (value > 0) { // hide the create button - jQuery('#".$button_code_name."Create').hide(); + createButton.style.display = 'none'; // 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); + editButton.style.display = 'block'; + let url = 'index.php?option=com_getbible&view=tags&task=tag.edit&id='+value+'".$refJ."'; + editButton.setAttribute('href', url); } else { // show the create button - jQuery('#".$button_code_name."Create').show(); + createButton.style.display = 'block'; // hide edit button - jQuery('#".$button_code_name."Edit').hide(); + editButton.style.display = 'none'; } }"; } @@ -133,10 +135,10 @@ class JFormFieldTagers extends JFormFieldList if (is_array($button) && count($button) > 0) { // Load the needed script. - $document = Factory::getDocument(); + $document = Factory::getApplication()->getDocument(); $document->addScriptDeclaration(implode(' ',$script)); // return the button attached to input field. - return '
' .$html . implode('',$button).'
'; + return '
' .$html . implode('',$button).'
'; } } return $html; @@ -145,14 +147,15 @@ class JFormFieldTagers extends JFormFieldList /** * Method to get a list of options for a list input. * - * @return array An array of JHtml options. + * @return array An array of Html options. + * @since 1.6 */ protected function getOptions() { // Get the user object. - $user = JFactory::getUser(); + $user = Factory::getUser(); // Get the databse object. - $db = JFactory::getDBO(); + $db = Factory::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')); @@ -175,11 +178,11 @@ class JFormFieldTagers extends JFormFieldList { if ($this->multiple === false) { - $options[] = JHtml::_('select.option', '', JText::_('COM_GETBIBLE_SELECT_AN_OPTION')); + $options[] = Html::_('select.option', '', Text::_('COM_GETBIBLE_SELECT_AN_OPTION')); } foreach($items as $item) { - $options[] = JHtml::_('select.option', $item->guid, $item->tag_name . ' (' . substr($item->guid, 0, 8) . ')'); + $options[] = Html::_('select.option', $item->guid, $item->tag_name . ' (' . substr($item->guid, 0, 8) . ')'); } } return $options; diff --git a/admin/models/fields/taggedversesfilteraccess.php b/admin/src/Field/TaggedversesfilteraccessField.php similarity index 79% rename from admin/models/fields/taggedversesfilteraccess.php rename to admin/src/Field/TaggedversesfilteraccessField.php index e4f2945..299274b 100644 --- a/admin/models/fields/taggedversesfilteraccess.php +++ b/admin/src/Field/TaggedversesfilteraccessField.php @@ -14,39 +14,40 @@ @license GNU/GPL Version 2 or later - http://www.gnu.org/licenses/gpl-2.0.html /------------------------------------------------------------------------------------------------------*/ +namespace TrueChristianChurch\Component\Getbible\Administrator\Field; // No direct access to this file -defined('_JEXEC') or die('Restricted access'); +\defined('_JEXEC') or die; use Joomla\CMS\Factory; +use Joomla\CMS\Form\Field\ListField; use Joomla\CMS\Language\Text; use Joomla\CMS\HTML\HTMLHelper as Html; - -// import the list field type -jimport('joomla.form.helper'); -JFormHelper::loadFieldClass('list'); +use Joomla\CMS\Component\ComponentHelper; +use TrueChristianChurch\Component\Getbible\Administrator\Helper\GetbibleHelper; /** * Taggedversesfilteraccess Form Field class for the Getbible component */ -class JFormFieldTaggedversesfilteraccess extends JFormFieldList +class TaggedversesfilteraccessField extends ListField { /** * The taggedversesfilteraccess field type. * - * @var string + * @var string */ - public $type = 'taggedversesfilteraccess'; + public $type = 'Taggedversesfilteraccess'; /** * Method to get a list of options for a list input. * - * @return array An array of JHtml options. + * @return array An array of Html options. + * @since 1.6 */ protected function getOptions() { // Get a db connection. - $db = Factory::getDbo(); + $db = Factory::getContainer()->get(\Joomla\Database\DatabaseInterface::class); // Create a new query object. $query = $db->getQuery(true); @@ -60,7 +61,7 @@ class JFormFieldTaggedversesfilteraccess extends JFormFieldList $db->setQuery($query); $_results = $db->loadColumn(); - $_filter = array(); + $_filter = []; $_filter[] = Html::_('select.option', '', '- ' . Text::_('COM_GETBIBLE_FILTER_SELECT_ACCESS') . ' -'); if ($_results) diff --git a/admin/models/fields/taggedversesfilterbooknr.php b/admin/src/Field/TaggedversesfilterbooknrField.php similarity index 77% rename from admin/models/fields/taggedversesfilterbooknr.php rename to admin/src/Field/TaggedversesfilterbooknrField.php index 76944f5..a514e60 100644 --- a/admin/models/fields/taggedversesfilterbooknr.php +++ b/admin/src/Field/TaggedversesfilterbooknrField.php @@ -14,39 +14,40 @@ @license GNU/GPL Version 2 or later - http://www.gnu.org/licenses/gpl-2.0.html /------------------------------------------------------------------------------------------------------*/ +namespace TrueChristianChurch\Component\Getbible\Administrator\Field; // No direct access to this file -defined('_JEXEC') or die('Restricted access'); +\defined('_JEXEC') or die; use Joomla\CMS\Factory; +use Joomla\CMS\Form\Field\ListField; use Joomla\CMS\Language\Text; use Joomla\CMS\HTML\HTMLHelper as Html; - -// import the list field type -jimport('joomla.form.helper'); -JFormHelper::loadFieldClass('list'); +use Joomla\CMS\Component\ComponentHelper; +use TrueChristianChurch\Component\Getbible\Administrator\Helper\GetbibleHelper; /** * Taggedversesfilterbooknr Form Field class for the Getbible component */ -class JFormFieldTaggedversesfilterbooknr extends JFormFieldList +class TaggedversesfilterbooknrField extends ListField { /** * The taggedversesfilterbooknr field type. * - * @var string + * @var string */ - public $type = 'taggedversesfilterbooknr'; + public $type = 'Taggedversesfilterbooknr'; /** * Method to get a list of options for a list input. * - * @return array An array of JHtml options. + * @return array An array of Html options. + * @since 1.6 */ protected function getOptions() { // Get a db connection. - $db = Factory::getDbo(); + $db = Factory::getContainer()->get(\Joomla\Database\DatabaseInterface::class); // Create a new query object. $query = $db->getQuery(true); @@ -60,7 +61,7 @@ class JFormFieldTaggedversesfilterbooknr extends JFormFieldList $db->setQuery($query); $_results = $db->loadColumn(); - $_filter = array(); + $_filter = []; if ($_results) { diff --git a/admin/models/fields/taggedversesfilterchapter.php b/admin/src/Field/TaggedversesfilterchapterField.php similarity index 77% rename from admin/models/fields/taggedversesfilterchapter.php rename to admin/src/Field/TaggedversesfilterchapterField.php index 086dc6a..4761866 100644 --- a/admin/models/fields/taggedversesfilterchapter.php +++ b/admin/src/Field/TaggedversesfilterchapterField.php @@ -14,39 +14,40 @@ @license GNU/GPL Version 2 or later - http://www.gnu.org/licenses/gpl-2.0.html /------------------------------------------------------------------------------------------------------*/ +namespace TrueChristianChurch\Component\Getbible\Administrator\Field; // No direct access to this file -defined('_JEXEC') or die('Restricted access'); +\defined('_JEXEC') or die; use Joomla\CMS\Factory; +use Joomla\CMS\Form\Field\ListField; use Joomla\CMS\Language\Text; use Joomla\CMS\HTML\HTMLHelper as Html; - -// import the list field type -jimport('joomla.form.helper'); -JFormHelper::loadFieldClass('list'); +use Joomla\CMS\Component\ComponentHelper; +use TrueChristianChurch\Component\Getbible\Administrator\Helper\GetbibleHelper; /** * Taggedversesfilterchapter Form Field class for the Getbible component */ -class JFormFieldTaggedversesfilterchapter extends JFormFieldList +class TaggedversesfilterchapterField extends ListField { /** * The taggedversesfilterchapter field type. * - * @var string + * @var string */ - public $type = 'taggedversesfilterchapter'; + public $type = 'Taggedversesfilterchapter'; /** * Method to get a list of options for a list input. * - * @return array An array of JHtml options. + * @return array An array of Html options. + * @since 1.6 */ protected function getOptions() { // Get a db connection. - $db = Factory::getDbo(); + $db = Factory::getContainer()->get(\Joomla\Database\DatabaseInterface::class); // Create a new query object. $query = $db->getQuery(true); @@ -60,7 +61,7 @@ class JFormFieldTaggedversesfilterchapter extends JFormFieldList $db->setQuery($query); $_results = $db->loadColumn(); - $_filter = array(); + $_filter = []; if ($_results) { diff --git a/admin/models/fields/taggedversesfilterverse.php b/admin/src/Field/TaggedversesfilterverseField.php similarity index 77% rename from admin/models/fields/taggedversesfilterverse.php rename to admin/src/Field/TaggedversesfilterverseField.php index 1dc7f6f..2e88525 100644 --- a/admin/models/fields/taggedversesfilterverse.php +++ b/admin/src/Field/TaggedversesfilterverseField.php @@ -14,39 +14,40 @@ @license GNU/GPL Version 2 or later - http://www.gnu.org/licenses/gpl-2.0.html /------------------------------------------------------------------------------------------------------*/ +namespace TrueChristianChurch\Component\Getbible\Administrator\Field; // No direct access to this file -defined('_JEXEC') or die('Restricted access'); +\defined('_JEXEC') or die; use Joomla\CMS\Factory; +use Joomla\CMS\Form\Field\ListField; use Joomla\CMS\Language\Text; use Joomla\CMS\HTML\HTMLHelper as Html; - -// import the list field type -jimport('joomla.form.helper'); -JFormHelper::loadFieldClass('list'); +use Joomla\CMS\Component\ComponentHelper; +use TrueChristianChurch\Component\Getbible\Administrator\Helper\GetbibleHelper; /** * Taggedversesfilterverse Form Field class for the Getbible component */ -class JFormFieldTaggedversesfilterverse extends JFormFieldList +class TaggedversesfilterverseField extends ListField { /** * The taggedversesfilterverse field type. * - * @var string + * @var string */ - public $type = 'taggedversesfilterverse'; + public $type = 'Taggedversesfilterverse'; /** * Method to get a list of options for a list input. * - * @return array An array of JHtml options. + * @return array An array of Html options. + * @since 1.6 */ protected function getOptions() { // Get a db connection. - $db = Factory::getDbo(); + $db = Factory::getContainer()->get(\Joomla\Database\DatabaseInterface::class); // Create a new query object. $query = $db->getQuery(true); @@ -60,7 +61,7 @@ class JFormFieldTaggedversesfilterverse extends JFormFieldList $db->setQuery($query); $_results = $db->loadColumn(); - $_filter = array(); + $_filter = []; if ($_results) { diff --git a/admin/models/fields/tagsfilteraccess.php b/admin/src/Field/TagsfilteraccessField.php similarity index 79% rename from admin/models/fields/tagsfilteraccess.php rename to admin/src/Field/TagsfilteraccessField.php index 6c87148..5e0d75c 100644 --- a/admin/models/fields/tagsfilteraccess.php +++ b/admin/src/Field/TagsfilteraccessField.php @@ -14,39 +14,40 @@ @license GNU/GPL Version 2 or later - http://www.gnu.org/licenses/gpl-2.0.html /------------------------------------------------------------------------------------------------------*/ +namespace TrueChristianChurch\Component\Getbible\Administrator\Field; // No direct access to this file -defined('_JEXEC') or die('Restricted access'); +\defined('_JEXEC') or die; use Joomla\CMS\Factory; +use Joomla\CMS\Form\Field\ListField; use Joomla\CMS\Language\Text; use Joomla\CMS\HTML\HTMLHelper as Html; - -// import the list field type -jimport('joomla.form.helper'); -JFormHelper::loadFieldClass('list'); +use Joomla\CMS\Component\ComponentHelper; +use TrueChristianChurch\Component\Getbible\Administrator\Helper\GetbibleHelper; /** * Tagsfilteraccess Form Field class for the Getbible component */ -class JFormFieldTagsfilteraccess extends JFormFieldList +class TagsfilteraccessField extends ListField { /** * The tagsfilteraccess field type. * - * @var string + * @var string */ - public $type = 'tagsfilteraccess'; + public $type = 'Tagsfilteraccess'; /** * Method to get a list of options for a list input. * - * @return array An array of JHtml options. + * @return array An array of Html options. + * @since 1.6 */ protected function getOptions() { // Get a db connection. - $db = Factory::getDbo(); + $db = Factory::getContainer()->get(\Joomla\Database\DatabaseInterface::class); // Create a new query object. $query = $db->getQuery(true); @@ -60,7 +61,7 @@ class JFormFieldTagsfilteraccess extends JFormFieldList $db->setQuery($query); $_results = $db->loadColumn(); - $_filter = array(); + $_filter = []; $_filter[] = Html::_('select.option', '', '- ' . Text::_('COM_GETBIBLE_FILTER_SELECT_ACCESS') . ' -'); if ($_results) diff --git a/admin/models/fields/targettranslations.php b/admin/src/Field/TargettranslationsField.php similarity index 71% rename from admin/models/fields/targettranslations.php rename to admin/src/Field/TargettranslationsField.php index a2e0bd0..a6ba03d 100644 --- a/admin/models/fields/targettranslations.php +++ b/admin/src/Field/TargettranslationsField.php @@ -14,41 +14,42 @@ @license GNU/GPL Version 2 or later - http://www.gnu.org/licenses/gpl-2.0.html /------------------------------------------------------------------------------------------------------*/ +namespace TrueChristianChurch\Component\Getbible\Administrator\Field; // No direct access to this file -defined('_JEXEC') or die('Restricted access'); +\defined('_JEXEC') or die; use Joomla\CMS\Factory; +use Joomla\CMS\Form\Field\ListField; use Joomla\CMS\Language\Text; use Joomla\CMS\HTML\HTMLHelper as Html; - -// import the list field type -jimport('joomla.form.helper'); -JFormHelper::loadFieldClass('list'); +use Joomla\CMS\Component\ComponentHelper; +use TrueChristianChurch\Component\Getbible\Administrator\Helper\GetbibleHelper; /** * Targettranslations Form Field class for the Getbible component */ -class JFormFieldTargettranslations extends JFormFieldList +class TargettranslationsField extends ListField { /** * The targettranslations field type. * - * @var string + * @var string */ - public $type = 'targettranslations'; + public $type = 'Targettranslations'; /** * Method to get a list of options for a list input. * - * @return array An array of JHtml options. + * @return array An array of Html options. + * @since 1.6 */ protected function getOptions() { // Get the user object. - $user = JFactory::getUser(); + $user = Factory::getUser(); // Get the databse object. - $db = JFactory::getDBO(); + $db = Factory::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')); @@ -71,12 +72,12 @@ class JFormFieldTargettranslations extends JFormFieldList { if ($this->multiple === false) { - $options[] = JHtml::_('select.option', '', JText::_('COM_GETBIBLE_SELECT_AN_OPTION')); + $options[] = Html::_('select.option', '', Text::_('COM_GETBIBLE_SELECT_AN_OPTION')); } - $options[] = JHtml::_('select.option', 'all', JText::_('COM_GETBIBLE_ALL_TRANSLATIONS')); + $options[] = Html::_('select.option', 'all', Text::_('COM_GETBIBLE_ALL_TRANSLATIONS')); foreach($items as $item) { - $options[] = JHtml::_('select.option', $item->abbreviation, $item->abbreviation_translation.' (' .$item->abbreviation.')'); + $options[] = Html::_('select.option', $item->abbreviation, $item->abbreviation_translation.' (' .$item->abbreviation.')'); } } return $options; diff --git a/admin/models/fields/translations.php b/admin/src/Field/TranslationsField.php similarity index 70% rename from admin/models/fields/translations.php rename to admin/src/Field/TranslationsField.php index 1cc600c..7817c16 100644 --- a/admin/models/fields/translations.php +++ b/admin/src/Field/TranslationsField.php @@ -14,41 +14,42 @@ @license GNU/GPL Version 2 or later - http://www.gnu.org/licenses/gpl-2.0.html /------------------------------------------------------------------------------------------------------*/ +namespace TrueChristianChurch\Component\Getbible\Administrator\Field; // No direct access to this file -defined('_JEXEC') or die('Restricted access'); +\defined('_JEXEC') or die; use Joomla\CMS\Factory; +use Joomla\CMS\Form\Field\ListField; use Joomla\CMS\Language\Text; use Joomla\CMS\HTML\HTMLHelper as Html; - -// import the list field type -jimport('joomla.form.helper'); -JFormHelper::loadFieldClass('list'); +use Joomla\CMS\Component\ComponentHelper; +use TrueChristianChurch\Component\Getbible\Administrator\Helper\GetbibleHelper; /** * Translations Form Field class for the Getbible component */ -class JFormFieldTranslations extends JFormFieldList +class TranslationsField extends ListField { /** * The translations field type. * - * @var string + * @var string */ - public $type = 'translations'; + public $type = 'Translations'; /** * Method to get a list of options for a list input. * - * @return array An array of JHtml options. + * @return array An array of Html options. + * @since 1.6 */ protected function getOptions() { // Get the user object. - $user = JFactory::getUser(); + $user = Factory::getUser(); // Get the databse object. - $db = JFactory::getDBO(); + $db = Factory::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')); @@ -71,11 +72,11 @@ class JFormFieldTranslations extends JFormFieldList { if ($this->multiple === false) { - $options[] = JHtml::_('select.option', '', JText::_('COM_GETBIBLE_SELECT_AN_OPTION')); + $options[] = Html::_('select.option', '', Text::_('COM_GETBIBLE_SELECT_AN_OPTION')); } foreach($items as $item) { - $options[] = JHtml::_('select.option', $item->abbreviation, $item->abbreviation_translation.' (' .$item->abbreviation.')'); + $options[] = Html::_('select.option', $item->abbreviation, $item->abbreviation_translation.' (' .$item->abbreviation.')'); } } @@ -85,9 +86,9 @@ class JFormFieldTranslations extends JFormFieldList $options = []; if ($this->multiple === false) { - $options[] = JHtml::_('select.option', '', JText::_('COM_GETBIBLE_SELECT_AN_OPTION')); + $options[] = Html::_('select.option', '', Text::_('COM_GETBIBLE_SELECT_AN_OPTION')); } - $options[] = JHtml::_('select.option', 'kjv', 'King James Version (kjv)'); // this is the default at all times. + $options[] = Html::_('select.option', 'kjv', 'King James Version (kjv)'); // this is the default at all times. } return $options; diff --git a/admin/models/fields/translationsfilterdirection.php b/admin/src/Field/TranslationsfilterdirectionField.php similarity index 79% rename from admin/models/fields/translationsfilterdirection.php rename to admin/src/Field/TranslationsfilterdirectionField.php index 2cf7e6b..17b5559 100644 --- a/admin/models/fields/translationsfilterdirection.php +++ b/admin/src/Field/TranslationsfilterdirectionField.php @@ -14,39 +14,40 @@ @license GNU/GPL Version 2 or later - http://www.gnu.org/licenses/gpl-2.0.html /------------------------------------------------------------------------------------------------------*/ +namespace TrueChristianChurch\Component\Getbible\Administrator\Field; // No direct access to this file -defined('_JEXEC') or die('Restricted access'); +\defined('_JEXEC') or die; use Joomla\CMS\Factory; +use Joomla\CMS\Form\Field\ListField; use Joomla\CMS\Language\Text; use Joomla\CMS\HTML\HTMLHelper as Html; - -// import the list field type -jimport('joomla.form.helper'); -JFormHelper::loadFieldClass('list'); +use Joomla\CMS\Component\ComponentHelper; +use TrueChristianChurch\Component\Getbible\Administrator\Helper\GetbibleHelper; /** * Translationsfilterdirection Form Field class for the Getbible component */ -class JFormFieldTranslationsfilterdirection extends JFormFieldList +class TranslationsfilterdirectionField extends ListField { /** * The translationsfilterdirection field type. * - * @var string + * @var string */ - public $type = 'translationsfilterdirection'; + public $type = 'Translationsfilterdirection'; /** * Method to get a list of options for a list input. * - * @return array An array of JHtml options. + * @return array An array of Html options. + * @since 1.6 */ protected function getOptions() { // Get a db connection. - $db = Factory::getDbo(); + $db = Factory::getContainer()->get(\Joomla\Database\DatabaseInterface::class); // Create a new query object. $query = $db->getQuery(true); @@ -60,7 +61,7 @@ class JFormFieldTranslationsfilterdirection extends JFormFieldList $db->setQuery($query); $_results = $db->loadColumn(); - $_filter = array(); + $_filter = []; $_filter[] = Html::_('select.option', '', '- ' . Text::_('COM_GETBIBLE_FILTER_SELECT_DIRECTIONAL') . ' -'); if ($_results) diff --git a/admin/models/fields/versesfilterbooknr.php b/admin/src/Field/VersesfilterbooknrField.php similarity index 78% rename from admin/models/fields/versesfilterbooknr.php rename to admin/src/Field/VersesfilterbooknrField.php index dbc5e91..23b9036 100644 --- a/admin/models/fields/versesfilterbooknr.php +++ b/admin/src/Field/VersesfilterbooknrField.php @@ -14,39 +14,40 @@ @license GNU/GPL Version 2 or later - http://www.gnu.org/licenses/gpl-2.0.html /------------------------------------------------------------------------------------------------------*/ +namespace TrueChristianChurch\Component\Getbible\Administrator\Field; // No direct access to this file -defined('_JEXEC') or die('Restricted access'); +\defined('_JEXEC') or die; use Joomla\CMS\Factory; +use Joomla\CMS\Form\Field\ListField; use Joomla\CMS\Language\Text; use Joomla\CMS\HTML\HTMLHelper as Html; - -// import the list field type -jimport('joomla.form.helper'); -JFormHelper::loadFieldClass('list'); +use Joomla\CMS\Component\ComponentHelper; +use TrueChristianChurch\Component\Getbible\Administrator\Helper\GetbibleHelper; /** * Versesfilterbooknr Form Field class for the Getbible component */ -class JFormFieldVersesfilterbooknr extends JFormFieldList +class VersesfilterbooknrField extends ListField { /** * The versesfilterbooknr field type. * - * @var string + * @var string */ - public $type = 'versesfilterbooknr'; + public $type = 'Versesfilterbooknr'; /** * Method to get a list of options for a list input. * - * @return array An array of JHtml options. + * @return array An array of Html options. + * @since 1.6 */ protected function getOptions() { // Get a db connection. - $db = Factory::getDbo(); + $db = Factory::getContainer()->get(\Joomla\Database\DatabaseInterface::class); // Create a new query object. $query = $db->getQuery(true); @@ -60,7 +61,7 @@ class JFormFieldVersesfilterbooknr extends JFormFieldList $db->setQuery($query); $_results = $db->loadColumn(); - $_filter = array(); + $_filter = []; $_filter[] = Html::_('select.option', '', '- ' . Text::_('COM_GETBIBLE_FILTER_SELECT_BOOK_NUMBER') . ' -'); if ($_results) diff --git a/admin/models/fields/versesfilterchapter.php b/admin/src/Field/VersesfilterchapterField.php similarity index 78% rename from admin/models/fields/versesfilterchapter.php rename to admin/src/Field/VersesfilterchapterField.php index 1ffb7e8..2c38ada 100644 --- a/admin/models/fields/versesfilterchapter.php +++ b/admin/src/Field/VersesfilterchapterField.php @@ -14,39 +14,40 @@ @license GNU/GPL Version 2 or later - http://www.gnu.org/licenses/gpl-2.0.html /------------------------------------------------------------------------------------------------------*/ +namespace TrueChristianChurch\Component\Getbible\Administrator\Field; // No direct access to this file -defined('_JEXEC') or die('Restricted access'); +\defined('_JEXEC') or die; use Joomla\CMS\Factory; +use Joomla\CMS\Form\Field\ListField; use Joomla\CMS\Language\Text; use Joomla\CMS\HTML\HTMLHelper as Html; - -// import the list field type -jimport('joomla.form.helper'); -JFormHelper::loadFieldClass('list'); +use Joomla\CMS\Component\ComponentHelper; +use TrueChristianChurch\Component\Getbible\Administrator\Helper\GetbibleHelper; /** * Versesfilterchapter Form Field class for the Getbible component */ -class JFormFieldVersesfilterchapter extends JFormFieldList +class VersesfilterchapterField extends ListField { /** * The versesfilterchapter field type. * - * @var string + * @var string */ - public $type = 'versesfilterchapter'; + public $type = 'Versesfilterchapter'; /** * Method to get a list of options for a list input. * - * @return array An array of JHtml options. + * @return array An array of Html options. + * @since 1.6 */ protected function getOptions() { // Get a db connection. - $db = Factory::getDbo(); + $db = Factory::getContainer()->get(\Joomla\Database\DatabaseInterface::class); // Create a new query object. $query = $db->getQuery(true); @@ -60,7 +61,7 @@ class JFormFieldVersesfilterchapter extends JFormFieldList $db->setQuery($query); $_results = $db->loadColumn(); - $_filter = array(); + $_filter = []; $_filter[] = Html::_('select.option', '', '- ' . Text::_('COM_GETBIBLE_FILTER_SELECT_CHAPTER') . ' -'); if ($_results) diff --git a/admin/models/fields/versesfilterverse.php b/admin/src/Field/VersesfilterverseField.php similarity index 78% rename from admin/models/fields/versesfilterverse.php rename to admin/src/Field/VersesfilterverseField.php index f106b6f..3d7e466 100644 --- a/admin/models/fields/versesfilterverse.php +++ b/admin/src/Field/VersesfilterverseField.php @@ -14,39 +14,40 @@ @license GNU/GPL Version 2 or later - http://www.gnu.org/licenses/gpl-2.0.html /------------------------------------------------------------------------------------------------------*/ +namespace TrueChristianChurch\Component\Getbible\Administrator\Field; // No direct access to this file -defined('_JEXEC') or die('Restricted access'); +\defined('_JEXEC') or die; use Joomla\CMS\Factory; +use Joomla\CMS\Form\Field\ListField; use Joomla\CMS\Language\Text; use Joomla\CMS\HTML\HTMLHelper as Html; - -// import the list field type -jimport('joomla.form.helper'); -JFormHelper::loadFieldClass('list'); +use Joomla\CMS\Component\ComponentHelper; +use TrueChristianChurch\Component\Getbible\Administrator\Helper\GetbibleHelper; /** * Versesfilterverse Form Field class for the Getbible component */ -class JFormFieldVersesfilterverse extends JFormFieldList +class VersesfilterverseField extends ListField { /** * The versesfilterverse field type. * - * @var string + * @var string */ - public $type = 'versesfilterverse'; + public $type = 'Versesfilterverse'; /** * Method to get a list of options for a list input. * - * @return array An array of JHtml options. + * @return array An array of Html options. + * @since 1.6 */ protected function getOptions() { // Get a db connection. - $db = Factory::getDbo(); + $db = Factory::getContainer()->get(\Joomla\Database\DatabaseInterface::class); // Create a new query object. $query = $db->getQuery(true); @@ -60,7 +61,7 @@ class JFormFieldVersesfilterverse extends JFormFieldList $db->setQuery($query); $_results = $db->loadColumn(); - $_filter = array(); + $_filter = []; $_filter[] = Html::_('select.option', '', '- ' . Text::_('COM_GETBIBLE_FILTER_SELECT_VERSE') . ' -'); if ($_results) diff --git a/admin/models/index.html b/admin/src/Field/index.html similarity index 100% rename from admin/models/index.html rename to admin/src/Field/index.html diff --git a/admin/helpers/getbible.php b/admin/src/Helper/GetbibleHelper.php similarity index 90% rename from admin/helpers/getbible.php rename to admin/src/Helper/GetbibleHelper.php index 00e144d..248482f 100644 --- a/admin/helpers/getbible.php +++ b/admin/src/Helper/GetbibleHelper.php @@ -14,12 +14,13 @@ @license GNU/GPL Version 2 or later - http://www.gnu.org/licenses/gpl-2.0.html /------------------------------------------------------------------------------------------------------*/ +namespace TrueChristianChurch\Component\Getbible\Administrator\Helper; // No direct access to this file -defined('_JEXEC') or die('Restricted access'); +\defined('_JEXEC') or die; -// register this component namespace -spl_autoload_register(function ($class) { +// register additional namespace +\spl_autoload_register(function ($class) { // project-specific base directories and namespace prefix $search = [ 'libraries/jcb_powers/VDM.Joomla.GetBible' => 'VDM\\Joomla\\GetBible', @@ -73,9 +74,11 @@ use Joomla\CMS\Filesystem\File; use Joomla\CMS\Language\Language; use Joomla\CMS\MVC\Model\BaseDatabaseModel; use Joomla\CMS\Object\CMSObject; +use Joomla\CMS\Session\Session; use Joomla\CMS\Table\Table; use Joomla\CMS\Uri\Uri; use Joomla\CMS\Version; +use Joomla\Database\DatabaseInterface; use Joomla\Registry\Registry; use Joomla\String\StringHelper; use Joomla\Utilities\ArrayHelper; @@ -182,18 +185,18 @@ abstract class GetbibleHelper public static function getContributors() { // get params - $params = ComponentHelper::getParams('com_getbible'); + $params = ComponentHelper::getParams('com_getbible'); // start contributors array $contributors = []; // 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 = ''; } @@ -207,8 +210,8 @@ abstract class GetbibleHelper $link_front = ''; $link_back = ''; } - $contributors[$nr]['title'] = UtilitiesStringHelper::html($params->get("titleContributor".$nr)); - $contributors[$nr]['name'] = $link_front.UtilitiesStringHelper::html($params->get("nameContributor".$nr)).$link_back; + $contributors[$nr]['title'] = UtilitiesStringHelper::html($params->get("titleContributor".$nr)); + $contributors[$nr]['name'] = $link_front.UtilitiesStringHelper::html($params->get("nameContributor".$nr)).$link_back; } } return $contributors; @@ -228,7 +231,7 @@ abstract class GetbibleHelper public static function addSubmenu($submenu) { // load user for access menus - $user = Factory::getUser(); + $user = Factory::getApplication()->getIdentity(); // load the submenus to sidebar JHtmlSidebar::addEntry(Text::_('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')) @@ -350,7 +353,7 @@ abstract class GetbibleHelper { $type = 'item'; } - $db = Factory::getDbo(); + $db = Factory::getContainer()->get(DatabaseInterface::class); $query = $db->getQuery(true); $query->select(array('a.published')); $query->from('#__getbible_'.$type.' AS a'); @@ -368,7 +371,7 @@ abstract class GetbibleHelper public static function getGroupName($id) { - $db = Factory::getDBO(); + $db = Factory::getContainer()->get(DatabaseInterface::class); $query = $db->getQuery(true); $query->select(array('a.title')); $query->from('#__usergroups AS a'); @@ -377,7 +380,7 @@ abstract class GetbibleHelper $db->execute(); $found = $db->getNumRows(); if($found) - { + { return $db->loadResult(); } return $id; @@ -402,7 +405,7 @@ abstract class GetbibleHelper if (!ObjectHelper::check($user)) { // get the user object - $user = Factory::getUser(); + $user = Factory::getApplication()->getIdentity(); } // load the CMSObject $result = new CMSObject; @@ -411,7 +414,7 @@ abstract class GetbibleHelper if (UtilitiesStringHelper::check($views)) { $views = UtilitiesStringHelper::safe($views); - } + } // get all actions from component $actions = Access::getActionsFromFile( JPATH_ADMINISTRATOR . '/components/com_' . $component . '/access.xml', @@ -582,51 +585,55 @@ abstract class GetbibleHelper } /** - * Get any component's model + * Returns any Model object. + * + * @param string $type The model type to instantiate + * @param string $prefix Prefix for the model class name. Optional. + * @param string $component Component name the model belongs to. Optional. + * @param array $config Configuration array for model. Optional. + * + * @return \Joomla\CMS\MVC\Model\BaseDatabaseModel + * @throws \Exception + * @since 4.4 */ - public static function getModel($name, $path = JPATH_COMPONENT_ADMINISTRATOR, $Component = 'Getbible', $config = []) + public static function getModel(string $type, string $prefix = 'Administrator', + string $component = 'getbible', array $config = []) { - // fix the name - $name = UtilitiesStringHelper::safe($name); - // full path to models - $fullPathModels = $path . '/models'; - // load the model file - BaseDatabaseModel::addIncludePath($fullPathModels, $Component . 'Model'); - // make sure the table path is loaded - if (!isset($config['table_path']) || !UtilitiesStringHelper::check($config['table_path'])) + // make sure the name is correct + $type = UtilitiesStringHelper::safe($type, 'F'); + $component = strtolower($component); + + if ($prefix !== 'Site' && $prefix !== 'Administrator') { - // This is the JCB default path to tables in Joomla 3.x - $config['table_path'] = JPATH_ADMINISTRATOR . '/components/com_' . strtolower($Component) . '/tables'; + $prefix = self::getPrefixFromModelPath($prefix); } - // get instance - $model = BaseDatabaseModel::getInstance($name, $Component . 'Model', $config); - // if model not found (strange) - if ($model == false) + + // Get the model through the MVCFactory + return Factory::getApplication()->bootComponent('com_' . $component)->getMVCFactory()->createModel($type, $prefix, $config); + } + + /** + * Get the prefix from the model path + * + * @param string $path The model path + * + * @return string The prefix value + * @since 4.4 + */ + protected static function getPrefixFromModelPath(string $path): string + { + // Check if $path starts with JPATH_ADMINISTRATOR path + if (str_starts_with($path, JPATH_ADMINISTRATOR . '/components/')) { - 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 'Administrator'; } - return $model; + // Check if $path starts with JPATH_SITE path + elseif (str_starts_with($path, JPATH_SITE . '/components/')) + { + return 'Site'; + } + + return 'Administrator'; } /** @@ -678,7 +685,7 @@ abstract class GetbibleHelper else { // Create an asset_id or heal one that is corrupted. - $object = new stdClass(); + $object = new \StdClass(); // Must be a valid primary key value. $object->id = $id; @@ -702,7 +709,7 @@ abstract class GetbibleHelper if (!$inherit) { // Need to find the asset id by the name of the component. - $db = Factory::getDbo(); + $db = Factory::getContainer()->get(DatabaseInterface::class); $query = $db->getQuery(true) ->select($db->quoteName('id')) ->from($db->quoteName('#__assets')) @@ -872,7 +879,7 @@ abstract class GetbibleHelper /** * Check if have an json string * - * @input string The json string to check + * @input string The json string to check * * @returns bool true on success * @deprecated 3.3 Use JsonHelper::check($string); @@ -885,7 +892,7 @@ abstract class GetbibleHelper /** * Check if have an object with a length * - * @input object The object to check + * @input object The object to check * * @returns bool true on success * @deprecated 3.3 Use ObjectHelper::check($object); @@ -898,7 +905,7 @@ abstract class GetbibleHelper /** * Check if have an array with a length * - * @input array The array to check + * @input array The array to check * * @returns bool/int number of items in array on success * @deprecated 3.3 Use UtilitiesArrayHelper::check($array, $removeEmptyString); @@ -911,7 +918,7 @@ abstract class GetbibleHelper /** * Check if have a string with a length * - * @input string The string to check + * @input string The string to check * * @returns bool true on success * @deprecated 3.3 Use UtilitiesStringHelper::check($string); @@ -931,7 +938,7 @@ abstract class GetbibleHelper { // 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) + // website, port (try 80 or 443) if ($connected) { //action when connected @@ -949,7 +956,7 @@ abstract class GetbibleHelper /** * Merge an array of array's * - * @input array The arrays you would like to merge + * @input array The arrays you would like to merge * * @returns array on success * @deprecated 3.3 Use UtilitiesArrayHelper::merge($arrays); @@ -968,7 +975,7 @@ abstract class GetbibleHelper /** * Shorten a string * - * @input string The you would like to shorten + * @input string The you would like to shorten * * @returns string on success * @deprecated 3.3 Use UtilitiesStringHelper::shorten(...); @@ -981,7 +988,7 @@ abstract class GetbibleHelper /** * Making strings safe (various ways) * - * @input string The you would like to make safe + * @input string The you would like to make safe * * @returns string on success * @deprecated 3.3 Use UtilitiesStringHelper::safe(...); @@ -1000,7 +1007,7 @@ abstract class GetbibleHelper /** * Convert none English strings to code usable string * - * @input an string + * @input an string * * @returns a string * @deprecated 3.3 Use UtilitiesStringHelper::transliterate($string); @@ -1013,7 +1020,7 @@ abstract class GetbibleHelper /** * make sure a string is HTML save * - * @input an html string + * @input an html string * * @returns a string * @deprecated 3.3 Use UtilitiesStringHelper::html(...); @@ -1031,7 +1038,7 @@ abstract class GetbibleHelper /** * Convert all int in a string to an English word string * - * @input an string with numbers + * @input an string with numbers * * @returns a string * @deprecated 3.3 Use UtilitiesStringHelper::numbers($string); @@ -1045,7 +1052,7 @@ abstract class GetbibleHelper * Convert an integer into an English word string * Thanks to Tom Nicholson * - * @input an int + * @input an int * @returns a string * @deprecated 3.3 Use UtilitiesStringHelper::number($x); */ diff --git a/admin/src/Helper/HeaderCheck.php b/admin/src/Helper/HeaderCheck.php new file mode 100644 index 0000000..2afd413 --- /dev/null +++ b/admin/src/Helper/HeaderCheck.php @@ -0,0 +1,136 @@ + + @git Get Bible + @github Get Bible + @support Get Bible + @copyright Copyright (C) 2015. All Rights Reserved + @license GNU/GPL Version 2 or later - http://www.gnu.org/licenses/gpl-2.0.html + +/------------------------------------------------------------------------------------------------------*/ +namespace TrueChristianChurch\Component\Getbible\Administrator\Helper; + +// No direct access to this file +\defined('_JEXEC') or die; + +use Joomla\CMS\Factory; +use Joomla\CMS\Document\Document; +use Joomla\CMS\Application\CMSApplication; + +/** + * Helper class for checking loaded scripts and styles in the document header. + * + * @since 3.2.0 + */ +class HeaderCheck +{ + /** + * @var CMSApplication Application object + * + * @since 3.2.0 + */ + protected CMSApplication $app; + + /** + * @var Document object + * + * @since 3.2.0 + */ + protected Document $document; + + /** + * Construct the app and document + * + * @since 3.2.0 + */ + public function __construct() + { + // Initializes the application object. + $this->app = Factory::getApplication(); + + // Initializes the document object. + $this->document = $this->app->getDocument(); + } + + /** + * Check if a JavaScript file is loaded in the document head. + * + * @param string $scriptName Name of the script to check. + * + * @return bool True if the script is loaded, false otherwise. + * @since 3.2.0 + */ + public function js_loaded(string $scriptName): bool + { + return $this->isLoaded($scriptName, 'scripts'); + } + + /** + * Check if a CSS file is loaded in the document head. + * + * @param string $scriptName Name of the stylesheet to check. + * + * @return bool True if the stylesheet is loaded, false otherwise. + * @since 3.2.0 + */ + public function css_loaded(string $scriptName): bool + { + return $this->isLoaded($scriptName, 'styleSheets'); + } + + /** + * Abstract method to check if a given script or stylesheet is loaded. + * + * @param string $scriptName Name of the script or stylesheet. + * @param string $type Type of asset to check ('scripts' or 'styleSheets'). + * + * @return bool True if the asset is loaded, false otherwise. + * @since 3.2.0 + */ + private function isLoaded(string $scriptName, string $type): bool + { + // UIkit specific check + if ($this->isUIkit($scriptName)) + { + return true; + } + + $head_data = $this->document->getHeadData(); + foreach (array_keys($head_data[$type]) as $script) + { + if (stristr($script, $scriptName)) + { + return true; + } + } + + return false; + } + + /** + * Check for UIkit framework specific conditions. + * + * @param string $scriptName Name of the script or stylesheet. + * + * @return bool True if UIkit specific conditions are met, false otherwise. + * @since 3.2.0 + */ + private function isUIkit(string $scriptName): bool + { + if (strpos($scriptName, 'uikit') !== false) + { + $get_template_name = $this->app->getTemplate('template')->template; + if (strpos($get_template_name, 'yoo') !== false) + { + return true; + } + } + return false; + } +} diff --git a/admin/models/rules/index.html b/admin/src/Helper/index.html similarity index 100% rename from admin/models/rules/index.html rename to admin/src/Helper/index.html diff --git a/admin/models/ajax.php b/admin/src/Model/AjaxModel.php similarity index 61% rename from admin/models/ajax.php rename to admin/src/Model/AjaxModel.php index 8ee23b6..32df447 100644 --- a/admin/models/ajax.php +++ b/admin/src/Model/AjaxModel.php @@ -14,9 +14,10 @@ @license GNU/GPL Version 2 or later - http://www.gnu.org/licenses/gpl-2.0.html /------------------------------------------------------------------------------------------------------*/ +namespace TrueChristianChurch\Component\Getbible\Administrator\Model; // No direct access to this file -defined('_JEXEC') or die('Restricted access'); +\defined('_JEXEC') or die; use Joomla\CMS\Factory; use Joomla\CMS\Language\Text; @@ -24,6 +25,7 @@ use Joomla\CMS\Component\ComponentHelper; use Joomla\CMS\MVC\Model\ListModel; use Joomla\CMS\Plugin\PluginHelper; use Joomla\Utilities\ArrayHelper; +use TrueChristianChurch\Component\Getbible\Administrator\Helper\GetbibleHelper; use Joomla\Registry\Registry; use VDM\Joomla\Utilities\FileHelper; use VDM\Joomla\Gitea\Factory as GiteaFactory; @@ -31,11 +33,11 @@ use VDM\Joomla\Gitea\Factory as GiteaFactory; /** * Getbible Ajax List Model */ -class GetbibleModelAjax extends ListModel +class AjaxModel extends ListModel { protected $app_params; - public function __construct() + public function __construct() { parent::__construct(); // get params @@ -104,64 +106,54 @@ class GetbibleModelAjax extends ListModel */ public function getVersion($version = null) { - // get the token if set - $token = $this->app_params->get('gitea_token'); - - // only add if token is set - if ($token) + try { - try - { - // load the API details - GiteaFactory::_('Gitea.Repository.Tags')->load_('https://git.vdm.dev', $token); + // get the repository tags + $tags = GiteaFactory::_('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'); - // get the repository tags - $tags = GiteaFactory::_('Gitea.Repository.Tags')->list('getBible', 'joomla-component'); - } - catch (DomainException $e) + // now check if this version is out dated + if ($current_version === $local_version) { - return $this->getTokenForVersion($e->getMessage()); + return ['notice' => '' . Text::_('COM_GETBIBLE_UP_TO_DATE') . '']; } - catch (InvalidArgumentException $e) + else { - 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) + // 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_UP_TO_DATE') . '']; + return ['notice' => '' . Text::_('COM_GETBIBLE_BETA_RELEASE') . '']; } 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/getBible/joomla-component/archive/" . $tags[0]->name . ".zip?access_token=" . $token; + // download link of the latest version + $download = "https://git.vdm.dev/api/v1/repos/getBible/joomla-component/archive/" . $tags[0]->name . ".zip?access_token=" . $token; - return ['notice' => '' . Text::_('COM_GETBIBLE_OUT_OF_DATE') . '! ' . Text::_('COM_GETBIBLE_DOWNLOAD_UPDATE') . '!']; - } + return ['notice' => '' . Text::_('COM_GETBIBLE_OUT_OF_DATE') . '! ' . Text::_('COM_GETBIBLE_DOWNLOAD_UPDATE') . '!']; } } } @@ -207,27 +199,21 @@ class GetbibleModelAjax extends ListModel { try { - // get the token if set - $token = $this->app_params->get('gitea_token'); - - // load the API details - GiteaFactory::_('Gitea.Repository.Wiki')->load_('https://git.vdm.dev', $token); - // get the gitea wiki page im markdown $wiki = GiteaFactory::_('Gitea.Repository.Wiki')->get('getBible', 'support', $name); // now render the page in HTML - $page = GiteaFactory::_('Gitea.Miscellaneous.Markdown')->render($wiki->content, true); + $page = $wiki->content ?? null; } - catch (DomainException $e) + catch (\DomainException $e) { return $this->getTokenForWiki($e->getMessage()); } - catch (InvalidArgumentException $e) + catch (\InvalidArgumentException $e) { return $this->getTokenForWiki($e->getMessage()); } - catch (Exception $e) + catch (\Exception $e) { return $this->getTokenForWiki($e->getMessage()); } diff --git a/admin/models/book.php b/admin/src/Model/BookModel.php similarity index 91% rename from admin/models/book.php rename to admin/src/Model/BookModel.php index 96882a8..30d7f34 100644 --- a/admin/models/book.php +++ b/admin/src/Model/BookModel.php @@ -14,27 +14,35 @@ @license GNU/GPL Version 2 or later - http://www.gnu.org/licenses/gpl-2.0.html /------------------------------------------------------------------------------------------------------*/ +namespace TrueChristianChurch\Component\Getbible\Administrator\Model; // No direct access to this file -defined('_JEXEC') or die('Restricted access'); +\defined('_JEXEC') or die; use Joomla\CMS\Factory; use Joomla\CMS\Language\Text; +use Joomla\CMS\Form\Form; use Joomla\CMS\Filter\InputFilter; +use Joomla\CMS\Filter\OutputFilter; use Joomla\CMS\MVC\Model\AdminModel; use Joomla\CMS\Table\Table; use Joomla\CMS\UCM\UCMType; -use Joomla\Filter\OutputFilter; +use Joomla\CMS\Versioning\VersionableModelTrait; use Joomla\Registry\Registry; use Joomla\String\StringHelper; use Joomla\Utilities\ArrayHelper; +use Joomla\CMS\Helper\TagsHelper; +use TrueChristianChurch\Component\Getbible\Administrator\Helper\GetbibleHelper; +use VDM\Joomla\Utilities\StringHelper as UtilitiesStringHelper; use VDM\Joomla\Utilities\ArrayHelper as UtilitiesArrayHelper; /** * Getbible Book Admin Model */ -class GetbibleModelBook extends AdminModel +class BookModel extends AdminModel { + use VersionableModelTrait; + /** * The tab layout fields array. * @@ -78,14 +86,13 @@ class GetbibleModelBook extends AdminModel * * @return Table A database object * - * @since 1.6 + * @since 3.0 + * @throws \Exception */ - public function getTable($type = 'book', $prefix = 'GetbibleTable', $config = []) + public function getTable($type = 'book', $prefix = 'Administrator', $config = []) { - // 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 Table::getInstance($type, $prefix, $config); + return parent::getTable($type, $prefix, $config); }###ADMIN_CUSTOM_BUTTONS_METHOD### /** @@ -128,11 +135,11 @@ class GetbibleModelBook extends AdminModel * @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 + * @return Form|boolean A Form object on success, false on failure * * @since 1.6 */ - public function getForm($data = [], $loadData = true, $options = array('control' => 'jform')) + public function getForm($data = [], $loadData = true, $options = ['control' => 'jform']) { // set load data option $options['load_data'] = $loadData; @@ -172,7 +179,7 @@ class GetbibleModelBook extends AdminModel $id = $jinput->get('id', 0, 'INT'); } - $user = Factory::getUser(); + $user = Factory::getApplication()->getIdentity(); // Check for existing item. // Modify the form based on Edit State access controls. @@ -303,7 +310,7 @@ class GetbibleModelBook extends AdminModel /** * Method to get the script that have to be included on the form * - * @return string script files + * @return string script files */ public function getScript() { @@ -321,18 +328,13 @@ class GetbibleModelBook extends AdminModel */ protected function canDelete($record) { - if (!empty($record->id)) + if (empty($record->id) || ($record->state != -2)) { - if ($record->published != -2) - { - return; - } - - $user = Factory::getUser(); - // The record has been set. Check the record permissions. - return $user->authorise('book.delete', 'com_getbible.book.' . (int) $record->id); + return false; } - return false; + + // The record has been set. Check the record permissions. + return $this->getCurrentUser()->authorise('book.delete', 'com_getbible.book.' . (int) $record->id); } /** @@ -346,8 +348,8 @@ class GetbibleModelBook extends AdminModel */ protected function canEditState($record) { - $user = Factory::getUser(); - $recordId = (!empty($record->id)) ? $record->id : 0; + $user = $this->getCurrentUser(); + $recordId = $record->id ?? 0; if ($recordId) { @@ -365,16 +367,16 @@ class GetbibleModelBook extends AdminModel /** * 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. + * @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 + * @return boolean + * @since 2.5 */ protected function allowEdit($data = [], $key = 'id') { // Check specific edit permission then general edit permission. - $user = Factory::getUser(); + $user = Factory::getApplication()->getIdentity(); return $user->authorise('book.edit', 'com_getbible.book.'. ((int) isset($data[$key]) ? $data[$key] : 0)) or $user->authorise('book.edit', 'com_getbible'); } @@ -391,11 +393,11 @@ class GetbibleModelBook extends AdminModel protected function prepareTable($table) { $date = Factory::getDate(); - $user = Factory::getUser(); + $user = $this->getCurrentUser(); if (isset($table->name)) { - $table->name = htmlspecialchars_decode($table->name, ENT_QUOTES); + $table->name = \htmlspecialchars_decode($table->name, ENT_QUOTES); } if (isset($table->alias) && empty($table->alias)) @@ -414,7 +416,7 @@ class GetbibleModelBook extends AdminModel // Set ordering to the last item if not set if (empty($table->ordering)) { - $db = Factory::getDbo(); + $db = $this->getDatabase(); $query = $db->getQuery(true) ->select('MAX(ordering)') ->from($db->quoteName('#__getbible_book')); @@ -444,7 +446,7 @@ class GetbibleModelBook extends AdminModel * * @since 1.6 */ - protected function loadFormData() + protected function loadFormData() { // Check the session for previously entered form data. $data = Factory::getApplication()->getUserState('com_getbible.edit.book.data', []); @@ -452,10 +454,11 @@ class GetbibleModelBook extends AdminModel if (empty($data)) { $data = $this->getItem(); - // run the perprocess of the data - $this->preprocessData('com_getbible.book', $data); } + // run the perprocess of the data + $this->preprocessData('com_getbible.book', $data); + return $data; } @@ -542,7 +545,7 @@ class GetbibleModelBook extends AdminModel $done = false; // Set some needed variables. - $this->user = Factory::getUser(); + $this->user = $this->getCurrentUser(); $this->table = $this->getTable(); $this->tableClassName = get_class($this->table); $this->contentType = new UCMType; @@ -621,7 +624,7 @@ class GetbibleModelBook extends AdminModel if (empty($this->batchSet)) { // Set some needed variables. - $this->user = Factory::getUser(); + $this->user = Factory::getApplication()->getIdentity(); $this->table = $this->getTable(); $this->tableClassName = get_class($this->table); $this->canDo = GetbibleHelper::getActions('book'); @@ -647,7 +650,7 @@ class GetbibleModelBook extends AdminModel $values['published'] = 0; } - $newIds = array(); + $newIds = []; // Parent exists so let's proceed while (!empty($pks)) { @@ -682,13 +685,13 @@ class GetbibleModelBook extends AdminModel } // Only for strings - if (GetbibleHelper::checkString($this->table->name) && !is_numeric($this->table->name)) + if (UtilitiesStringHelper::check($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)) + if (UtilitiesArrayHelper::check($values)) { foreach ($values as $key => $value) { @@ -700,7 +703,7 @@ class GetbibleModelBook extends AdminModel } // update all unique fields - if (GetbibleHelper::checkArray($uniqueFields)) + if (UtilitiesArrayHelper::check($uniqueFields)) { foreach ($uniqueFields as $uniqueField) { @@ -764,7 +767,7 @@ class GetbibleModelBook extends AdminModel if (empty($this->batchSet)) { // Set some needed variables. - $this->user = Factory::getUser(); + $this->user = Factory::getApplication()->getIdentity(); $this->table = $this->getTable(); $this->tableClassName = get_class($this->table); $this->canDo = GetbibleHelper::getActions('book'); @@ -811,7 +814,7 @@ class GetbibleModelBook extends AdminModel } // insert all set values. - if (GetbibleHelper::checkArray($values)) + if (UtilitiesArrayHelper::check($values)) { foreach ($values as $key => $value) { @@ -867,14 +870,14 @@ class GetbibleModelBook extends AdminModel */ public function save($data) { - $input = Factory::getApplication()->input; - $filter = InputFilter::getInstance(); + $input = Factory::getApplication()->input; + $filter = InputFilter::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 Registry; $metadata->loadArray($data['metadata']); $data['metadata'] = (string) $metadata; @@ -919,12 +922,12 @@ class GetbibleModelBook extends AdminModel * * @since 3.0 */ - protected function generateUnique($field,$value) + protected function generateUnique($field, $value) { // set field value unique $table = $this->getTable(); - while ($table->load(array($field => $value))) + while ($table->load([$field => $value])) { $value = StringHelper::increment($value); } @@ -946,7 +949,7 @@ class GetbibleModelBook extends AdminModel // Alter the title $table = $this->getTable(); - while ($table->load(array('title' => $title))) + while ($table->load(['title' => $title])) { $title = StringHelper::increment($title); } diff --git a/admin/models/books.php b/admin/src/Model/BooksModel.php similarity index 84% rename from admin/models/books.php rename to admin/src/Model/BooksModel.php index ceb944d..6c8c7ce 100644 --- a/admin/models/books.php +++ b/admin/src/Model/BooksModel.php @@ -14,9 +14,10 @@ @license GNU/GPL Version 2 or later - http://www.gnu.org/licenses/gpl-2.0.html /------------------------------------------------------------------------------------------------------*/ +namespace TrueChristianChurch\Component\Getbible\Administrator\Model; // No direct access to this file -defined('_JEXEC') or die('Restricted access'); +\defined('_JEXEC') or die; use Joomla\CMS\Factory; use Joomla\CMS\Language\Text; @@ -24,6 +25,8 @@ use Joomla\CMS\Component\ComponentHelper; use Joomla\CMS\MVC\Model\ListModel; use Joomla\CMS\Plugin\PluginHelper; use Joomla\Utilities\ArrayHelper; +use Joomla\CMS\Helper\TagsHelper; +use TrueChristianChurch\Component\Getbible\Administrator\Helper\GetbibleHelper; use VDM\Joomla\Utilities\ArrayHelper as UtilitiesArrayHelper; use VDM\Joomla\Utilities\ObjectHelper; use VDM\Joomla\Utilities\StringHelper; @@ -31,12 +34,12 @@ use VDM\Joomla\Utilities\StringHelper; /** * Books List Model */ -class GetbibleModelBooks extends ListModel +class BooksModel extends ListModel { public function __construct($config = []) { if (empty($config['filter_fields'])) - { + { $config['filter_fields'] = array( 'a.id','id', 'a.published','published', @@ -143,7 +146,7 @@ class GetbibleModelBooks extends ListModel // Get the user object if not set. if (!isset($user) || !ObjectHelper::check($user)) { - $user = Factory::getUser(); + $user = $this->getCurrentUser(); } foreach ($items as $nr => &$item) { @@ -165,14 +168,14 @@ class GetbibleModelBooks extends ListModel /** * Method to build an SQL query to load the list data. * - * @return string An SQL query + * @return string An SQL query */ protected function getListQuery() { // Get the user object. - $user = Factory::getUser(); + $user = $this->getCurrentUser(); // Create a new query object. - $db = Factory::getDBO(); + $db = $this->getDatabase(); $query = $db->getQuery(true); // Select some fields @@ -205,7 +208,7 @@ class GetbibleModelBooks extends ListModel { $query->where('a.access = ' . (int) $_access); } - elseif (GetbibleHelper::checkArray($_access)) + elseif (UtilitiesArrayHelper::check($_access)) { // Secure the array for the query $_access = ArrayHelper::toInteger($_access); @@ -246,7 +249,7 @@ class GetbibleModelBooks extends ListModel $query->where('a.name = ' . (int) $_name); } } - elseif (GetbibleHelper::checkString($_name)) + elseif (StringHelper::check($_name)) { $query->where('a.name = ' . $db->quote($db->escape($_name))); } @@ -263,10 +266,33 @@ class GetbibleModelBooks extends ListModel $query->where('a.abbreviation = ' . (int) $_abbreviation); } } - elseif (GetbibleHelper::checkString($_abbreviation)) + elseif (StringHelper::check($_abbreviation)) { $query->where('a.abbreviation = ' . $db->quote($db->escape($_abbreviation))); } + elseif (UtilitiesArrayHelper::check($_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 (StringHelper::check($val)) + { + return $db->quote($db->escape($val)); + } + }, $_abbreviation); + // Filter by the Abbreviation Array. + $query->where('a.abbreviation IN (' . implode(',', $_abbreviation) . ')'); + } // Filter by Nr. $_nr = $this->getState('filter.nr'); if (is_numeric($_nr)) @@ -280,16 +306,18 @@ class GetbibleModelBooks extends ListModel $query->where('a.nr = ' . (int) $_nr); } } - elseif (GetbibleHelper::checkString($_nr)) + elseif (StringHelper::check($_nr)) { $query->where('a.nr = ' . $db->quote($db->escape($_nr))); } // Add the list ordering clause. - $orderCol = $this->state->get('list.ordering', 'g.translation'); - $orderDirn = $this->state->get('list.direction', 'asc'); + $orderCol = $this->getState('list.ordering', 'g.translation'); + $orderDirn = $this->getState('list.direction', 'asc'); if ($orderCol != '') { + // Check that the order direction is valid encase we have a field called direction as part of filers. + $orderDirn = (is_string($orderDirn) && in_array(strtolower($orderDirn), ['asc', 'desc'])) ? $orderDirn : 'asc'; $query->order($db->escape($orderCol . ' ' . $orderDirn)); } @@ -327,7 +355,18 @@ class GetbibleModelBooks extends ListModel $id .= ':' . $this->getState('filter.created_by'); $id .= ':' . $this->getState('filter.modified_by'); $id .= ':' . $this->getState('filter.name'); - $id .= ':' . $this->getState('filter.abbreviation'); + // Check if the value is an array + $_abbreviation = $this->getState('filter.abbreviation'); + if (UtilitiesArrayHelper::check($_abbreviation)) + { + $id .= ':' . implode(':', $_abbreviation); + } + // Check if this is only an number or string + elseif (is_numeric($_abbreviation) + || StringHelper::check($_abbreviation)) + { + $id .= ':' . $_abbreviation; + } $id .= ':' . $this->getState('filter.nr'); return parent::getStoreId($id); @@ -336,19 +375,18 @@ class GetbibleModelBooks extends ListModel /** * Build an SQL query to checkin all items left checked out longer then a set time. * - * @return a bool - * + * @return bool + * @since 3.2.0 */ - protected function checkInNow() + protected function checkInNow(): bool { // Get set check in time $time = ComponentHelper::getParams('com_getbible')->get('check_in'); if ($time) { - // Get a db connection. - $db = Factory::getDbo(); + $db = $this->getDatabase(); // Reset query. $query = $db->getQuery(true); $query->select('*'); @@ -381,7 +419,7 @@ class GetbibleModelBooks extends ListModel $db->setQuery($query); - $db->execute(); + return $db->execute(); } } diff --git a/admin/models/chapter.php b/admin/src/Model/ChapterModel.php similarity index 91% rename from admin/models/chapter.php rename to admin/src/Model/ChapterModel.php index 1867590..bd973f9 100644 --- a/admin/models/chapter.php +++ b/admin/src/Model/ChapterModel.php @@ -14,27 +14,35 @@ @license GNU/GPL Version 2 or later - http://www.gnu.org/licenses/gpl-2.0.html /------------------------------------------------------------------------------------------------------*/ +namespace TrueChristianChurch\Component\Getbible\Administrator\Model; // No direct access to this file -defined('_JEXEC') or die('Restricted access'); +\defined('_JEXEC') or die; use Joomla\CMS\Factory; use Joomla\CMS\Language\Text; +use Joomla\CMS\Form\Form; use Joomla\CMS\Filter\InputFilter; +use Joomla\CMS\Filter\OutputFilter; use Joomla\CMS\MVC\Model\AdminModel; use Joomla\CMS\Table\Table; use Joomla\CMS\UCM\UCMType; -use Joomla\Filter\OutputFilter; +use Joomla\CMS\Versioning\VersionableModelTrait; use Joomla\Registry\Registry; use Joomla\String\StringHelper; use Joomla\Utilities\ArrayHelper; +use Joomla\CMS\Helper\TagsHelper; +use TrueChristianChurch\Component\Getbible\Administrator\Helper\GetbibleHelper; +use VDM\Joomla\Utilities\StringHelper as UtilitiesStringHelper; use VDM\Joomla\Utilities\ArrayHelper as UtilitiesArrayHelper; /** * Getbible Chapter Admin Model */ -class GetbibleModelChapter extends AdminModel +class ChapterModel extends AdminModel { + use VersionableModelTrait; + /** * The tab layout fields array. * @@ -79,14 +87,13 @@ class GetbibleModelChapter extends AdminModel * * @return Table A database object * - * @since 1.6 + * @since 3.0 + * @throws \Exception */ - public function getTable($type = 'chapter', $prefix = 'GetbibleTable', $config = []) + public function getTable($type = 'chapter', $prefix = 'Administrator', $config = []) { - // 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 Table::getInstance($type, $prefix, $config); + return parent::getTable($type, $prefix, $config); }###ADMIN_CUSTOM_BUTTONS_METHOD### /** @@ -129,11 +136,11 @@ class GetbibleModelChapter extends AdminModel * @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 + * @return Form|boolean A Form object on success, false on failure * * @since 1.6 */ - public function getForm($data = [], $loadData = true, $options = array('control' => 'jform')) + public function getForm($data = [], $loadData = true, $options = ['control' => 'jform']) { // set load data option $options['load_data'] = $loadData; @@ -173,7 +180,7 @@ class GetbibleModelChapter extends AdminModel $id = $jinput->get('id', 0, 'INT'); } - $user = Factory::getUser(); + $user = Factory::getApplication()->getIdentity(); // Check for existing item. // Modify the form based on Edit State access controls. @@ -321,7 +328,7 @@ class GetbibleModelChapter extends AdminModel /** * Method to get the script that have to be included on the form * - * @return string script files + * @return string script files */ public function getScript() { @@ -339,18 +346,13 @@ class GetbibleModelChapter extends AdminModel */ protected function canDelete($record) { - if (!empty($record->id)) + if (empty($record->id) || ($record->state != -2)) { - if ($record->published != -2) - { - return; - } - - $user = Factory::getUser(); - // The record has been set. Check the record permissions. - return $user->authorise('chapter.delete', 'com_getbible.chapter.' . (int) $record->id); + return false; } - return false; + + // The record has been set. Check the record permissions. + return $this->getCurrentUser()->authorise('chapter.delete', 'com_getbible.chapter.' . (int) $record->id); } /** @@ -364,8 +366,8 @@ class GetbibleModelChapter extends AdminModel */ protected function canEditState($record) { - $user = Factory::getUser(); - $recordId = (!empty($record->id)) ? $record->id : 0; + $user = $this->getCurrentUser(); + $recordId = $record->id ?? 0; if ($recordId) { @@ -383,16 +385,16 @@ class GetbibleModelChapter extends AdminModel /** * 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. + * @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 + * @return boolean + * @since 2.5 */ protected function allowEdit($data = [], $key = 'id') { // Check specific edit permission then general edit permission. - $user = Factory::getUser(); + $user = Factory::getApplication()->getIdentity(); return $user->authorise('chapter.edit', 'com_getbible.chapter.'. ((int) isset($data[$key]) ? $data[$key] : 0)) or $user->authorise('chapter.edit', 'com_getbible'); } @@ -409,11 +411,11 @@ class GetbibleModelChapter extends AdminModel protected function prepareTable($table) { $date = Factory::getDate(); - $user = Factory::getUser(); + $user = $this->getCurrentUser(); if (isset($table->name)) { - $table->name = htmlspecialchars_decode($table->name, ENT_QUOTES); + $table->name = \htmlspecialchars_decode($table->name, ENT_QUOTES); } if (isset($table->alias) && empty($table->alias)) @@ -432,7 +434,7 @@ class GetbibleModelChapter extends AdminModel // Set ordering to the last item if not set if (empty($table->ordering)) { - $db = Factory::getDbo(); + $db = $this->getDatabase(); $query = $db->getQuery(true) ->select('MAX(ordering)') ->from($db->quoteName('#__getbible_chapter')); @@ -462,7 +464,7 @@ class GetbibleModelChapter extends AdminModel * * @since 1.6 */ - protected function loadFormData() + protected function loadFormData() { // Check the session for previously entered form data. $data = Factory::getApplication()->getUserState('com_getbible.edit.chapter.data', []); @@ -470,10 +472,11 @@ class GetbibleModelChapter extends AdminModel if (empty($data)) { $data = $this->getItem(); - // run the perprocess of the data - $this->preprocessData('com_getbible.chapter', $data); } + // run the perprocess of the data + $this->preprocessData('com_getbible.chapter', $data); + return $data; } @@ -560,7 +563,7 @@ class GetbibleModelChapter extends AdminModel $done = false; // Set some needed variables. - $this->user = Factory::getUser(); + $this->user = $this->getCurrentUser(); $this->table = $this->getTable(); $this->tableClassName = get_class($this->table); $this->contentType = new UCMType; @@ -639,7 +642,7 @@ class GetbibleModelChapter extends AdminModel if (empty($this->batchSet)) { // Set some needed variables. - $this->user = Factory::getUser(); + $this->user = Factory::getApplication()->getIdentity(); $this->table = $this->getTable(); $this->tableClassName = get_class($this->table); $this->canDo = GetbibleHelper::getActions('chapter'); @@ -665,7 +668,7 @@ class GetbibleModelChapter extends AdminModel $values['published'] = 0; } - $newIds = array(); + $newIds = []; // Parent exists so let's proceed while (!empty($pks)) { @@ -700,13 +703,13 @@ class GetbibleModelChapter extends AdminModel } // Only for strings - if (GetbibleHelper::checkString($this->table->name) && !is_numeric($this->table->name)) + if (UtilitiesStringHelper::check($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)) + if (UtilitiesArrayHelper::check($values)) { foreach ($values as $key => $value) { @@ -718,7 +721,7 @@ class GetbibleModelChapter extends AdminModel } // update all unique fields - if (GetbibleHelper::checkArray($uniqueFields)) + if (UtilitiesArrayHelper::check($uniqueFields)) { foreach ($uniqueFields as $uniqueField) { @@ -782,7 +785,7 @@ class GetbibleModelChapter extends AdminModel if (empty($this->batchSet)) { // Set some needed variables. - $this->user = Factory::getUser(); + $this->user = Factory::getApplication()->getIdentity(); $this->table = $this->getTable(); $this->tableClassName = get_class($this->table); $this->canDo = GetbibleHelper::getActions('chapter'); @@ -829,7 +832,7 @@ class GetbibleModelChapter extends AdminModel } // insert all set values. - if (GetbibleHelper::checkArray($values)) + if (UtilitiesArrayHelper::check($values)) { foreach ($values as $key => $value) { @@ -885,14 +888,14 @@ class GetbibleModelChapter extends AdminModel */ public function save($data) { - $input = Factory::getApplication()->input; - $filter = InputFilter::getInstance(); + $input = Factory::getApplication()->input; + $filter = InputFilter::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 Registry; $metadata->loadArray($data['metadata']); $data['metadata'] = (string) $metadata; @@ -937,12 +940,12 @@ class GetbibleModelChapter extends AdminModel * * @since 3.0 */ - protected function generateUnique($field,$value) + protected function generateUnique($field, $value) { // set field value unique $table = $this->getTable(); - while ($table->load(array($field => $value))) + while ($table->load([$field => $value])) { $value = StringHelper::increment($value); } @@ -964,7 +967,7 @@ class GetbibleModelChapter extends AdminModel // Alter the title $table = $this->getTable(); - while ($table->load(array('title' => $title))) + while ($table->load(['title' => $title])) { $title = StringHelper::increment($title); } diff --git a/admin/models/chapters.php b/admin/src/Model/ChaptersModel.php similarity index 90% rename from admin/models/chapters.php rename to admin/src/Model/ChaptersModel.php index c5b2390..e8fda32 100644 --- a/admin/models/chapters.php +++ b/admin/src/Model/ChaptersModel.php @@ -14,9 +14,10 @@ @license GNU/GPL Version 2 or later - http://www.gnu.org/licenses/gpl-2.0.html /------------------------------------------------------------------------------------------------------*/ +namespace TrueChristianChurch\Component\Getbible\Administrator\Model; // No direct access to this file -defined('_JEXEC') or die('Restricted access'); +\defined('_JEXEC') or die; use Joomla\CMS\Factory; use Joomla\CMS\Language\Text; @@ -24,6 +25,8 @@ use Joomla\CMS\Component\ComponentHelper; use Joomla\CMS\MVC\Model\ListModel; use Joomla\CMS\Plugin\PluginHelper; use Joomla\Utilities\ArrayHelper; +use Joomla\CMS\Helper\TagsHelper; +use TrueChristianChurch\Component\Getbible\Administrator\Helper\GetbibleHelper; use VDM\Joomla\Utilities\ArrayHelper as UtilitiesArrayHelper; use VDM\Joomla\Utilities\ObjectHelper; use VDM\Joomla\Utilities\StringHelper; @@ -31,12 +34,12 @@ use VDM\Joomla\Utilities\StringHelper; /** * Chapters List Model */ -class GetbibleModelChapters extends ListModel +class ChaptersModel extends ListModel { public function __construct($config = []) { if (empty($config['filter_fields'])) - { + { $config['filter_fields'] = array( 'a.id','id', 'a.published','published', @@ -151,7 +154,7 @@ class GetbibleModelChapters extends ListModel // Get the user object if not set. if (!isset($user) || !ObjectHelper::check($user)) { - $user = Factory::getUser(); + $user = $this->getCurrentUser(); } foreach ($items as $nr => &$item) { @@ -173,14 +176,14 @@ class GetbibleModelChapters extends ListModel /** * Method to build an SQL query to load the list data. * - * @return string An SQL query + * @return string An SQL query */ protected function getListQuery() { // Get the user object. - $user = Factory::getUser(); + $user = $this->getCurrentUser(); // Create a new query object. - $db = Factory::getDBO(); + $db = $this->getDatabase(); $query = $db->getQuery(true); // Select some fields @@ -213,7 +216,7 @@ class GetbibleModelChapters extends ListModel { $query->where('a.access = ' . (int) $_access); } - elseif (GetbibleHelper::checkArray($_access)) + elseif (UtilitiesArrayHelper::check($_access)) { // Secure the array for the query $_access = ArrayHelper::toInteger($_access); @@ -254,11 +257,11 @@ class GetbibleModelChapters extends ListModel $query->where('a.chapter = ' . (int) $_chapter); } } - elseif (GetbibleHelper::checkString($_chapter)) + elseif (StringHelper::check($_chapter)) { $query->where('a.chapter = ' . $db->quote($db->escape($_chapter))); } - elseif (GetbibleHelper::checkArray($_chapter)) + elseif (UtilitiesArrayHelper::check($_chapter)) { // Secure the array for the query $_chapter = array_map( function ($val) use(&$db) { @@ -273,7 +276,7 @@ class GetbibleModelChapters extends ListModel return (int) $val; } } - elseif (GetbibleHelper::checkString($val)) + elseif (StringHelper::check($val)) { return $db->quote($db->escape($val)); } @@ -294,11 +297,11 @@ class GetbibleModelChapters extends ListModel $query->where('a.book_nr = ' . (int) $_book_nr); } } - elseif (GetbibleHelper::checkString($_book_nr)) + elseif (StringHelper::check($_book_nr)) { $query->where('a.book_nr = ' . $db->quote($db->escape($_book_nr))); } - elseif (GetbibleHelper::checkArray($_book_nr)) + elseif (UtilitiesArrayHelper::check($_book_nr)) { // Secure the array for the query $_book_nr = array_map( function ($val) use(&$db) { @@ -313,7 +316,7 @@ class GetbibleModelChapters extends ListModel return (int) $val; } } - elseif (GetbibleHelper::checkString($val)) + elseif (StringHelper::check($val)) { return $db->quote($db->escape($val)); } @@ -334,16 +337,18 @@ class GetbibleModelChapters extends ListModel $query->where('a.abbreviation = ' . (int) $_abbreviation); } } - elseif (GetbibleHelper::checkString($_abbreviation)) + elseif (StringHelper::check($_abbreviation)) { $query->where('a.abbreviation = ' . $db->quote($db->escape($_abbreviation))); } // Add the list ordering clause. - $orderCol = $this->state->get('list.ordering', 'g.translation'); - $orderDirn = $this->state->get('list.direction', 'asc'); + $orderCol = $this->getState('list.ordering', 'g.translation'); + $orderDirn = $this->getState('list.direction', 'asc'); if ($orderCol != '') { + // Check that the order direction is valid encase we have a field called direction as part of filers. + $orderDirn = (is_string($orderDirn) && in_array(strtolower($orderDirn), ['asc', 'desc'])) ? $orderDirn : 'asc'; $query->order($db->escape($orderCol . ' ' . $orderDirn)); } @@ -416,19 +421,18 @@ class GetbibleModelChapters extends ListModel /** * Build an SQL query to checkin all items left checked out longer then a set time. * - * @return a bool - * + * @return bool + * @since 3.2.0 */ - protected function checkInNow() + protected function checkInNow(): bool { // Get set check in time $time = ComponentHelper::getParams('com_getbible')->get('check_in'); if ($time) { - // Get a db connection. - $db = Factory::getDbo(); + $db = $this->getDatabase(); // Reset query. $query = $db->getQuery(true); $query->select('*'); @@ -461,7 +465,7 @@ class GetbibleModelChapters extends ListModel $db->setQuery($query); - $db->execute(); + return $db->execute(); } } diff --git a/admin/models/getbible.php b/admin/src/Model/GetbibleModel.php similarity index 60% rename from admin/models/getbible.php rename to admin/src/Model/GetbibleModel.php index 96d30df..5a3a6bb 100644 --- a/admin/models/getbible.php +++ b/admin/src/Model/GetbibleModel.php @@ -14,16 +14,21 @@ @license GNU/GPL Version 2 or later - http://www.gnu.org/licenses/gpl-2.0.html /------------------------------------------------------------------------------------------------------*/ +namespace TrueChristianChurch\Component\Getbible\Administrator\Model; // No direct access to this file -defined('_JEXEC') or die('Restricted access'); +\defined('_JEXEC') or die; use Joomla\CMS\Factory; use Joomla\CMS\Language\Text; +use Joomla\CMS\HTML\HTMLHelper as Html; +use Joomla\CMS\Session\Session; +use Joomla\CMS\Uri\Uri; use Joomla\CMS\Component\ComponentHelper; use Joomla\CMS\MVC\Model\ListModel; use Joomla\CMS\Plugin\PluginHelper; use Joomla\Utilities\ArrayHelper; +use TrueChristianChurch\Component\Getbible\Administrator\Helper\GetbibleHelper; use Joomla\Registry\Registry; use VDM\Joomla\Utilities\ArrayHelper as UtilitiesArrayHelper; use VDM\Joomla\Utilities\StringHelper; @@ -31,12 +36,12 @@ use VDM\Joomla\Utilities\StringHelper; /** * Getbible List Model */ -class GetbibleModelGetbible extends ListModel +class GetbibleModel extends ListModel { public function getIcons() { // load user for access menus - $user = Factory::getUser(); + $user = Factory::getApplication()->getIdentity(); // reset icon array $icons = []; // view groups array @@ -118,11 +123,11 @@ class GetbibleModelGetbible extends ListModel if (count($dwd) == 3) { list($type, $name, $url) = $dwd; - $viewName = $name; - $alt = $name; - $url = $url; - $image = $name . '.' . $type; - $name = 'COM_GETBIBLE_DASHBOARD_' . StringHelper::safe($name,'U'); + $viewName = $name; + $alt = $name; + $url = $url; + $image = $name . '.' . $type; + $name = 'COM_GETBIBLE_DASHBOARD_' . StringHelper::safe($name,'U'); } } // internal views @@ -144,11 +149,11 @@ class GetbibleModelGetbible extends ListModel 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_'.StringHelper::safe($name,'U').'_ADD'; - $add = true; + $url = 'index.php?option=com_getbible&view=' . $name . '&layout=edit'; + $image = $name . '_' . $action. '.' . $type; + $alt = $name . ' ' . $action; + $name = 'COM_GETBIBLE_DASHBOARD_'.StringHelper::safe($name,'U').'_ADD'; + $add = true; break; default: // check for new convention (more stable) @@ -161,31 +166,31 @@ class GetbibleModelGetbible extends ListModel { $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_' . StringHelper::safe($name,'U') . '_' . StringHelper::safe($action,'U'); + $url = 'index.php?option=com_categories&view=categories&extension=' . $extension; + $image = $name . '_' . $action . '.' . $type; + $alt = $viewName . ' ' . $action; + $name = 'COM_GETBIBLE_DASHBOARD_' . StringHelper::safe($name,'U') . '_' . StringHelper::safe($action,'U'); break; } } else { - $viewName = $name; - $alt = $name; - $url = 'index.php?option=com_getbible&view=' . $name; - $image = $name . '.' . $type; - $name = 'COM_GETBIBLE_DASHBOARD_' . StringHelper::safe($name,'U'); - $hover = false; + $viewName = $name; + $alt = $name; + $url = 'index.php?option=com_getbible&view=' . $name; + $image = $name . '.' . $type; + $name = 'COM_GETBIBLE_DASHBOARD_' . StringHelper::safe($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; + $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 (UtilitiesArrayHelper::check($viewAccess)) @@ -218,7 +223,7 @@ class GetbibleModelGetbible extends ListModel // set main access controllers if ($accessDashboard_add) { - $dashboard_add = $user->authorise($viewAccess[$viewName.'.dashboard_add'], 'com_getbible'); + $dashboard_add = $user->authorise($viewAccess[$viewName.'.dashboard_add'], 'com_getbible'); } if ($accessDashboard_list) { @@ -229,11 +234,11 @@ class GetbibleModelGetbible extends ListModel // 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; + $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 (StringHelper::check($accessTo)) @@ -241,11 +246,11 @@ class GetbibleModelGetbible extends ListModel // 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; + $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 (StringHelper::check($accessAdd)) @@ -253,29 +258,29 @@ class GetbibleModelGetbible extends ListModel // 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; + $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; + $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; + $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++; } @@ -292,18 +297,17 @@ class GetbibleModelGetbible extends ListModel 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'; + $call_url = Uri::base() . 'index.php?option=com_getbible&task=ajax.getWiki&format=json&raw=true&' . Session::getFormToken() . '=1&name=Home'; $document = Factory::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; + document.getElementById("wiki-md").innerHTML = marked.parse(result.page); } else if (typeof result.error !== "undefined") { document.getElementById("wiki-md-error").innerHTML = result.error } @@ -319,26 +323,36 @@ class GetbibleModelGetbible extends ListModel { // get the document to load the scripts $document = Factory::getDocument(); - $document->addScript(JURI::root() . "media/com_getbible/js/marked.js"); + Html::_('script', "media/com_getbible/js/marked.js", ['version' => 'auto']); $document->addScriptDeclaration(' - var token = "'.JSession::getFormToken().'"; + var token = "' . Session::getFormToken() . '"; var noticeboard = "https://vdm.bz/getbible-noticeboard-md"; - jQuery(document).ready(function () { - jQuery.get(noticeboard) - .success(function(board) { + document.addEventListener("DOMContentLoaded", function() { + fetch(noticeboard) + .then(response => { + if (!response.ok) { + throw new Error("Network response was not ok"); + } + return response.text(); + }) + .then(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); + document.getElementById("noticeboard-md").innerHTML = marked.parse(board); + getIS(1, board) + .then(result => { + if (result) { + document.querySelectorAll("#cpanel_tabTabs a").forEach(link => { + if (link.href.includes("#vast_development_method") || link.href.includes("#notice_board")) { + var textVDM = link.textContent; + link.innerHTML = "1 " + textVDM; + link.id = "vdm-new-notice"; + document.getElementById("vdm-new-notice").addEventListener("click", () => { + getIS(2, board) + .then(result => { + if (result) { + document.querySelectorAll(".vdm-new-notice").forEach(element => { + element.style.opacity = 0; + }); } }); }); @@ -347,43 +361,50 @@ class GetbibleModelGetbible extends ListModel } }); } else { - jQuery("#noticeboard-md").html("'.Text::_('COM_GETBIBLE_ALL_IS_GOOD_PLEASE_CHECK_AGAIN_LATTER').'"); + document.getElementById("noticeboard-md").innerHTML = "'.Text::_('COM_GETBIBLE_ALL_IS_GOOD_PLEASE_CHECK_AGAIN_LATER').'."; } }) - .error(function(jqXHR, textStatus, errorThrown) { - jQuery("#noticeboard-md").html("'.Text::_('COM_GETBIBLE_ALL_IS_GOOD_PLEASE_CHECK_AGAIN_LATTER').'"); + .catch(error => { + console.error("There was an error!", error); + document.getElementById("noticeboard-md").innerHTML = "'.Text::_('COM_GETBIBLE_ALL_IS_GOOD_PLEASE_CHECK_AGAIN_LATER').'."; }); }); + // 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; + function getIS(type, notice) { + let getUrl = ""; + if (type === 1) { + getUrl = "index.php?option=com_getbible&task=ajax.isNew&format=json&raw=true"; + } else if (type === 2) { + getUrl = "index.php?option=com_getbible&task=ajax.isRead&format=json&raw=true"; } - return jQuery.ajax({ - type: "POST", - url: getUrl, - dataType: "json", - data: request, - jsonp: false - }); + let request = new URLSearchParams(); + if (token.length > 0 && notice.length) { + request.append(token, "1"); + request.append("notice", notice); + } + return fetch(getUrl, { + method: "POST", + headers: { + "Content-Type": "application/x-www-form-urlencoded;charset=UTF-8" + }, + body: request + }).then(response => response.json()); } -// 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); +document.addEventListener("DOMContentLoaded", function() { + document.querySelectorAll(".loading-dots").forEach(function(loading_dots) { + let x = 0; + let intervalId = setInterval(function() { + if (!loading_dots.classList.contains("loading-dots")) { + clearInterval(intervalId); + return; + } + let dots = ".".repeat(x % 8); + loading_dots.textContent = dots; + x++; + }, 500); + }); });'); return '
'.Text::_('COM_GETBIBLE_THE_NOTICE_BOARD_IS_LOADING').'..
'; @@ -393,14 +414,21 @@ jQuery(document).ready( function($) { { $document = Factory::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)); + var getreadme = "'. Uri::root() . 'administrator/components/com_getbible/README.txt"; + document.addEventListener("DOMContentLoaded", function () { + fetch(getreadme) + .then(response => { + if (!response.ok) { + throw new Error("Network response was not ok"); + } + return response.text(); }) - .error(function(jqXHR, textStatus, errorThrown) { - jQuery("#readme-md").html("'.Text::_('COM_GETBIBLE_PLEASE_CHECK_AGAIN_LATTER').'"); + .then(readme => { + document.getElementById("readme-md").innerHTML = marked.parse(readme); + }) + .catch(error => { + console.error("There has been a problem with your fetch operation:", error); + document.getElementById("readme-md").innerHTML = "'.Text::_('COM_GETBIBLE_PLEASE_CHECK_AGAIN_LATER').'."; }); });'); @@ -416,7 +444,7 @@ jQuery(document).ready( function($) { 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'; + $call_url = Uri::base() . 'index.php?option=com_getbible&task=ajax.getVersion&format=json&raw=true&' . Session::getFormToken() . '=1&version=1'; $document = Factory::getDocument(); $document->addScriptDeclaration(' function getComponentVersionStatus() { diff --git a/admin/models/linker.php b/admin/src/Model/LinkerModel.php similarity index 92% rename from admin/models/linker.php rename to admin/src/Model/LinkerModel.php index 1f977d6..f0b7da2 100644 --- a/admin/models/linker.php +++ b/admin/src/Model/LinkerModel.php @@ -14,20 +14,25 @@ @license GNU/GPL Version 2 or later - http://www.gnu.org/licenses/gpl-2.0.html /------------------------------------------------------------------------------------------------------*/ +namespace TrueChristianChurch\Component\Getbible\Administrator\Model; // No direct access to this file -defined('_JEXEC') or die('Restricted access'); +\defined('_JEXEC') or die; use Joomla\CMS\Factory; use Joomla\CMS\Language\Text; +use Joomla\CMS\Form\Form; use Joomla\CMS\Filter\InputFilter; +use Joomla\CMS\Filter\OutputFilter; use Joomla\CMS\MVC\Model\AdminModel; use Joomla\CMS\Table\Table; use Joomla\CMS\UCM\UCMType; -use Joomla\Filter\OutputFilter; +use Joomla\CMS\Versioning\VersionableModelTrait; use Joomla\Registry\Registry; use Joomla\String\StringHelper; use Joomla\Utilities\ArrayHelper; +use Joomla\CMS\Helper\TagsHelper; +use TrueChristianChurch\Component\Getbible\Administrator\Helper\GetbibleHelper; use VDM\Joomla\Utilities\ArrayHelper as UtilitiesArrayHelper; use VDM\Joomla\Utilities\ObjectHelper; use VDM\Joomla\Utilities\StringHelper as UtilitiesStringHelper; @@ -37,8 +42,10 @@ use VDM\Joomla\Utilities\GetHelper; /** * Getbible Linker Admin Model */ -class GetbibleModelLinker extends AdminModel +class LinkerModel extends AdminModel { + use VersionableModelTrait; + /** * The tab layout fields array. * @@ -81,14 +88,13 @@ class GetbibleModelLinker extends AdminModel * * @return Table A database object * - * @since 1.6 + * @since 3.0 + * @throws \Exception */ - public function getTable($type = 'linker', $prefix = 'GetbibleTable', $config = []) + public function getTable($type = 'linker', $prefix = 'Administrator', $config = []) { - // 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 Table::getInstance($type, $prefix, $config); + return parent::getTable($type, $prefix, $config); } /** @@ -135,9 +141,9 @@ class GetbibleModelLinker extends AdminModel public function getVvvtags() { // Get the user object. - $user = Factory::getUser(); + $user = Factory::getApplication()->getIdentity(); // Create a new query object. - $db = Factory::getDBO(); + $db = $this->getDatabase(); $query = $db->getQuery(true); // Select some fields @@ -200,7 +206,7 @@ class GetbibleModelLinker extends AdminModel // Get the user object if not set. if (!isset($user) || !ObjectHelper::check($user)) { - $user = Factory::getUser(); + $user = $this->getCurrentUser(); } foreach ($items as $nr => &$item) { @@ -234,7 +240,7 @@ class GetbibleModelLinker extends AdminModel /** * Method to convert selection values to translatable string. * - * @return translatable string + * @return string The translatable string. */ public function selectionTranslationVvvtags($value,$name) { @@ -262,9 +268,9 @@ class GetbibleModelLinker extends AdminModel public function getVvwnotes() { // Get the user object. - $user = Factory::getUser(); + $user = Factory::getApplication()->getIdentity(); // Create a new query object. - $db = Factory::getDBO(); + $db = $this->getDatabase(); $query = $db->getQuery(true); // Select some fields @@ -319,7 +325,7 @@ class GetbibleModelLinker extends AdminModel // Get the user object if not set. if (!isset($user) || !ObjectHelper::check($user)) { - $user = Factory::getUser(); + $user = $this->getCurrentUser(); } foreach ($items as $nr => &$item) { @@ -353,7 +359,7 @@ class GetbibleModelLinker extends AdminModel /** * Method to convert selection values to translatable string. * - * @return translatable string + * @return string The translatable string. */ public function selectionTranslationVvwnotes($value,$name) { @@ -381,9 +387,9 @@ class GetbibleModelLinker extends AdminModel public function getVvxpasswords() { // Get the user object. - $user = Factory::getUser(); + $user = Factory::getApplication()->getIdentity(); // Create a new query object. - $db = Factory::getDBO(); + $db = $this->getDatabase(); $query = $db->getQuery(true); // Select some fields @@ -420,7 +426,7 @@ class GetbibleModelLinker extends AdminModel { $query->where('a.access = ' . (int) $_access); } - elseif (GetbibleHelper::checkArray($_access)) + elseif (UtilitiesArrayHelper::check($_access)) { // Secure the array for the query $_access = ArrayHelper::toInteger($_access); @@ -451,7 +457,7 @@ class GetbibleModelLinker extends AdminModel // Get the user object if not set. if (!isset($user) || !ObjectHelper::check($user)) { - $user = Factory::getUser(); + $user = $this->getCurrentUser(); } foreach ($items as $nr => &$item) { @@ -477,11 +483,11 @@ class GetbibleModelLinker extends AdminModel * @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 + * @return Form|boolean A Form object on success, false on failure * * @since 1.6 */ - public function getForm($data = [], $loadData = true, $options = array('control' => 'jform')) + public function getForm($data = [], $loadData = true, $options = ['control' => 'jform']) { // set load data option $options['load_data'] = $loadData; @@ -521,7 +527,7 @@ class GetbibleModelLinker extends AdminModel $id = $jinput->get('id', 0, 'INT'); } - $user = Factory::getUser(); + $user = Factory::getApplication()->getIdentity(); // Check for existing item. // Modify the form based on Edit State access controls. @@ -665,7 +671,7 @@ class GetbibleModelLinker extends AdminModel /** * Method to get the script that have to be included on the form * - * @return string script files + * @return string script files */ public function getScript() { @@ -683,18 +689,13 @@ class GetbibleModelLinker extends AdminModel */ protected function canDelete($record) { - if (!empty($record->id)) + if (empty($record->id) || ($record->state != -2)) { - if ($record->published != -2) - { - return; - } - - $user = Factory::getUser(); - // The record has been set. Check the record permissions. - return $user->authorise('linker.delete', 'com_getbible.linker.' . (int) $record->id); + return false; } - return false; + + // The record has been set. Check the record permissions. + return $this->getCurrentUser()->authorise('linker.delete', 'com_getbible.linker.' . (int) $record->id); } /** @@ -708,8 +709,8 @@ class GetbibleModelLinker extends AdminModel */ protected function canEditState($record) { - $user = Factory::getUser(); - $recordId = (!empty($record->id)) ? $record->id : 0; + $user = $this->getCurrentUser(); + $recordId = $record->id ?? 0; if ($recordId) { @@ -727,16 +728,16 @@ class GetbibleModelLinker extends AdminModel /** * 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. + * @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 + * @return boolean + * @since 2.5 */ protected function allowEdit($data = [], $key = 'id') { // Check specific edit permission then general edit permission. - $user = Factory::getUser(); + $user = Factory::getApplication()->getIdentity(); return $user->authorise('linker.edit', 'com_getbible.linker.'. ((int) isset($data[$key]) ? $data[$key] : 0)) or $user->authorise('linker.edit', 'com_getbible'); } @@ -753,11 +754,11 @@ class GetbibleModelLinker extends AdminModel protected function prepareTable($table) { $date = Factory::getDate(); - $user = Factory::getUser(); + $user = $this->getCurrentUser(); if (isset($table->name)) { - $table->name = htmlspecialchars_decode($table->name, ENT_QUOTES); + $table->name = \htmlspecialchars_decode($table->name, ENT_QUOTES); } if (isset($table->alias) && empty($table->alias)) @@ -776,7 +777,7 @@ class GetbibleModelLinker extends AdminModel // Set ordering to the last item if not set if (empty($table->ordering)) { - $db = Factory::getDbo(); + $db = $this->getDatabase(); $query = $db->getQuery(true) ->select('MAX(ordering)') ->from($db->quoteName('#__getbible_linker')); @@ -806,7 +807,7 @@ class GetbibleModelLinker extends AdminModel * * @since 1.6 */ - protected function loadFormData() + protected function loadFormData() { // Check the session for previously entered form data. $data = Factory::getApplication()->getUserState('com_getbible.edit.linker.data', []); @@ -814,10 +815,11 @@ class GetbibleModelLinker extends AdminModel if (empty($data)) { $data = $this->getItem(); - // run the perprocess of the data - $this->preprocessData('com_getbible.linker', $data); } + // run the perprocess of the data + $this->preprocessData('com_getbible.linker', $data); + return $data; } @@ -904,7 +906,7 @@ class GetbibleModelLinker extends AdminModel $done = false; // Set some needed variables. - $this->user = Factory::getUser(); + $this->user = $this->getCurrentUser(); $this->table = $this->getTable(); $this->tableClassName = get_class($this->table); $this->contentType = new UCMType; @@ -983,7 +985,7 @@ class GetbibleModelLinker extends AdminModel if (empty($this->batchSet)) { // Set some needed variables. - $this->user = Factory::getUser(); + $this->user = Factory::getApplication()->getIdentity(); $this->table = $this->getTable(); $this->tableClassName = get_class($this->table); $this->canDo = GetbibleHelper::getActions('linker'); @@ -1009,7 +1011,7 @@ class GetbibleModelLinker extends AdminModel $values['published'] = 0; } - $newIds = array(); + $newIds = []; // Parent exists so let's proceed while (!empty($pks)) { @@ -1044,13 +1046,13 @@ class GetbibleModelLinker extends AdminModel } // Only for strings - if (GetbibleHelper::checkString($this->table->name) && !is_numeric($this->table->name)) + if (UtilitiesStringHelper::check($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)) + if (UtilitiesArrayHelper::check($values)) { foreach ($values as $key => $value) { @@ -1062,7 +1064,7 @@ class GetbibleModelLinker extends AdminModel } // update all unique fields - if (GetbibleHelper::checkArray($uniqueFields)) + if (UtilitiesArrayHelper::check($uniqueFields)) { foreach ($uniqueFields as $uniqueField) { @@ -1126,7 +1128,7 @@ class GetbibleModelLinker extends AdminModel if (empty($this->batchSet)) { // Set some needed variables. - $this->user = Factory::getUser(); + $this->user = Factory::getApplication()->getIdentity(); $this->table = $this->getTable(); $this->tableClassName = get_class($this->table); $this->canDo = GetbibleHelper::getActions('linker'); @@ -1173,7 +1175,7 @@ class GetbibleModelLinker extends AdminModel } // insert all set values. - if (GetbibleHelper::checkArray($values)) + if (UtilitiesArrayHelper::check($values)) { foreach ($values as $key => $value) { @@ -1229,14 +1231,14 @@ class GetbibleModelLinker extends AdminModel */ public function save($data) { - $input = Factory::getApplication()->input; - $filter = InputFilter::getInstance(); + $input = Factory::getApplication()->input; + $filter = InputFilter::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 Registry; $metadata->loadArray($data['metadata']); $data['metadata'] = (string) $metadata; @@ -1296,12 +1298,12 @@ class GetbibleModelLinker extends AdminModel * * @since 3.0 */ - protected function generateUnique($field,$value) + protected function generateUnique($field, $value) { // set field value unique $table = $this->getTable(); - while ($table->load(array($field => $value))) + while ($table->load([$field => $value])) { $value = StringHelper::increment($value); } @@ -1323,7 +1325,7 @@ class GetbibleModelLinker extends AdminModel // Alter the title $table = $this->getTable(); - while ($table->load(array('title' => $title))) + while ($table->load(['title' => $title])) { $title = StringHelper::increment($title); } diff --git a/admin/models/linkers.php b/admin/src/Model/LinkersModel.php similarity index 91% rename from admin/models/linkers.php rename to admin/src/Model/LinkersModel.php index aaace2e..8c69300 100644 --- a/admin/models/linkers.php +++ b/admin/src/Model/LinkersModel.php @@ -14,9 +14,10 @@ @license GNU/GPL Version 2 or later - http://www.gnu.org/licenses/gpl-2.0.html /------------------------------------------------------------------------------------------------------*/ +namespace TrueChristianChurch\Component\Getbible\Administrator\Model; // No direct access to this file -defined('_JEXEC') or die('Restricted access'); +\defined('_JEXEC') or die; use Joomla\CMS\Factory; use Joomla\CMS\Language\Text; @@ -24,6 +25,8 @@ use Joomla\CMS\Component\ComponentHelper; use Joomla\CMS\MVC\Model\ListModel; use Joomla\CMS\Plugin\PluginHelper; use Joomla\Utilities\ArrayHelper; +use Joomla\CMS\Helper\TagsHelper; +use TrueChristianChurch\Component\Getbible\Administrator\Helper\GetbibleHelper; use VDM\Joomla\Utilities\ArrayHelper as UtilitiesArrayHelper; use VDM\Joomla\Utilities\ObjectHelper; use VDM\Joomla\Utilities\StringHelper; @@ -31,12 +34,12 @@ use VDM\Joomla\Utilities\StringHelper; /** * Linkers List Model */ -class GetbibleModelLinkers extends ListModel +class LinkersModel extends ListModel { public function __construct($config = []) { if (empty($config['filter_fields'])) - { + { $config['filter_fields'] = array( 'a.id','id', 'a.published','published', @@ -143,7 +146,7 @@ class GetbibleModelLinkers extends ListModel // Get the user object if not set. if (!isset($user) || !ObjectHelper::check($user)) { - $user = Factory::getUser(); + $user = $this->getCurrentUser(); } foreach ($items as $nr => &$item) { @@ -178,7 +181,7 @@ class GetbibleModelLinkers extends ListModel /** * Method to convert selection values to translatable string. * - * @return translatable string + * @return string The translatable string. */ public function selectionTranslation($value,$name) { @@ -214,14 +217,14 @@ class GetbibleModelLinkers extends ListModel /** * Method to build an SQL query to load the list data. * - * @return string An SQL query + * @return string An SQL query */ protected function getListQuery() { // Get the user object. - $user = Factory::getUser(); + $user = $this->getCurrentUser(); // Create a new query object. - $db = Factory::getDBO(); + $db = $this->getDatabase(); $query = $db->getQuery(true); // Select some fields @@ -250,7 +253,7 @@ class GetbibleModelLinkers extends ListModel { $query->where('a.access = ' . (int) $_access); } - elseif (GetbibleHelper::checkArray($_access)) + elseif (UtilitiesArrayHelper::check($_access)) { // Secure the array for the query $_access = ArrayHelper::toInteger($_access); @@ -291,7 +294,7 @@ class GetbibleModelLinkers extends ListModel $query->where('a.name = ' . (int) $_name); } } - elseif (GetbibleHelper::checkString($_name)) + elseif (StringHelper::check($_name)) { $query->where('a.name = ' . $db->quote($db->escape($_name))); } @@ -308,7 +311,7 @@ class GetbibleModelLinkers extends ListModel $query->where('a.public_tagged_verses = ' . (int) $_public_tagged_verses); } } - elseif (GetbibleHelper::checkString($_public_tagged_verses)) + elseif (StringHelper::check($_public_tagged_verses)) { $query->where('a.public_tagged_verses = ' . $db->quote($db->escape($_public_tagged_verses))); } @@ -325,16 +328,18 @@ class GetbibleModelLinkers extends ListModel $query->where('a.public_notes = ' . (int) $_public_notes); } } - elseif (GetbibleHelper::checkString($_public_notes)) + elseif (StringHelper::check($_public_notes)) { $query->where('a.public_notes = ' . $db->quote($db->escape($_public_notes))); } // Add the list ordering clause. - $orderCol = $this->state->get('list.ordering', 'a.id'); - $orderDirn = $this->state->get('list.direction', 'desc'); + $orderCol = $this->getState('list.ordering', 'a.id'); + $orderDirn = $this->getState('list.direction', 'desc'); if ($orderCol != '') { + // Check that the order direction is valid encase we have a field called direction as part of filers. + $orderDirn = (is_string($orderDirn) && in_array(strtolower($orderDirn), ['asc', 'desc'])) ? $orderDirn : 'desc'; $query->order($db->escape($orderCol . ' ' . $orderDirn)); } @@ -378,19 +383,18 @@ class GetbibleModelLinkers extends ListModel /** * Build an SQL query to checkin all items left checked out longer then a set time. * - * @return a bool - * + * @return bool + * @since 3.2.0 */ - protected function checkInNow() + protected function checkInNow(): bool { // Get set check in time $time = ComponentHelper::getParams('com_getbible')->get('check_in'); if ($time) { - // Get a db connection. - $db = Factory::getDbo(); + $db = $this->getDatabase(); // Reset query. $query = $db->getQuery(true); $query->select('*'); @@ -423,7 +427,7 @@ class GetbibleModelLinkers extends ListModel $db->setQuery($query); - $db->execute(); + return $db->execute(); } } diff --git a/admin/models/note.php b/admin/src/Model/NoteModel.php similarity index 92% rename from admin/models/note.php rename to admin/src/Model/NoteModel.php index 2f3eb4f..236f260 100644 --- a/admin/models/note.php +++ b/admin/src/Model/NoteModel.php @@ -14,29 +14,36 @@ @license GNU/GPL Version 2 or later - http://www.gnu.org/licenses/gpl-2.0.html /------------------------------------------------------------------------------------------------------*/ +namespace TrueChristianChurch\Component\Getbible\Administrator\Model; // No direct access to this file -defined('_JEXEC') or die('Restricted access'); +\defined('_JEXEC') or die; use Joomla\CMS\Factory; use Joomla\CMS\Language\Text; +use Joomla\CMS\Form\Form; use Joomla\CMS\Filter\InputFilter; +use Joomla\CMS\Filter\OutputFilter; use Joomla\CMS\MVC\Model\AdminModel; use Joomla\CMS\Table\Table; use Joomla\CMS\UCM\UCMType; -use Joomla\Filter\OutputFilter; +use Joomla\CMS\Versioning\VersionableModelTrait; use Joomla\Registry\Registry; use Joomla\String\StringHelper; use Joomla\Utilities\ArrayHelper; +use Joomla\CMS\Helper\TagsHelper; +use TrueChristianChurch\Component\Getbible\Administrator\Helper\GetbibleHelper; use VDM\Joomla\Utilities\GuidHelper; -use VDM\Joomla\Utilities\GetHelper; use VDM\Joomla\Utilities\ArrayHelper as UtilitiesArrayHelper; +use VDM\Joomla\Utilities\GetHelper; /** * Getbible Note Admin Model */ -class GetbibleModelNote extends AdminModel +class NoteModel extends AdminModel { + use VersionableModelTrait; + /** * The tab layout fields array. * @@ -82,14 +89,13 @@ class GetbibleModelNote extends AdminModel * * @return Table A database object * - * @since 1.6 + * @since 3.0 + * @throws \Exception */ - public function getTable($type = 'note', $prefix = 'GetbibleTable', $config = []) + public function getTable($type = 'note', $prefix = 'Administrator', $config = []) { - // 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 Table::getInstance($type, $prefix, $config); + return parent::getTable($type, $prefix, $config); } /** @@ -132,11 +138,11 @@ class GetbibleModelNote extends AdminModel * @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 + * @return Form|boolean A Form object on success, false on failure * * @since 1.6 */ - public function getForm($data = [], $loadData = true, $options = array('control' => 'jform')) + public function getForm($data = [], $loadData = true, $options = ['control' => 'jform']) { // set load data option $options['load_data'] = $loadData; @@ -176,7 +182,7 @@ class GetbibleModelNote extends AdminModel $id = $jinput->get('id', 0, 'INT'); } - $user = Factory::getUser(); + $user = Factory::getApplication()->getIdentity(); // Check for existing item. // Modify the form based on Edit State access controls. @@ -357,7 +363,7 @@ class GetbibleModelNote extends AdminModel /** * Method to get the script that have to be included on the form * - * @return string script files + * @return string script files */ public function getScript() { @@ -375,18 +381,13 @@ class GetbibleModelNote extends AdminModel */ protected function canDelete($record) { - if (!empty($record->id)) + if (empty($record->id) || ($record->state != -2)) { - if ($record->published != -2) - { - return; - } - - $user = Factory::getUser(); - // The record has been set. Check the record permissions. - return $user->authorise('note.delete', 'com_getbible.note.' . (int) $record->id); + return false; } - return false; + + // The record has been set. Check the record permissions. + return $this->getCurrentUser()->authorise('note.delete', 'com_getbible.note.' . (int) $record->id); } /** @@ -400,8 +401,8 @@ class GetbibleModelNote extends AdminModel */ protected function canEditState($record) { - $user = Factory::getUser(); - $recordId = (!empty($record->id)) ? $record->id : 0; + $user = $this->getCurrentUser(); + $recordId = $record->id ?? 0; if ($recordId) { @@ -419,16 +420,16 @@ class GetbibleModelNote extends AdminModel /** * 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. + * @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 + * @return boolean + * @since 2.5 */ protected function allowEdit($data = [], $key = 'id') { // Check specific edit permission then general edit permission. - $user = Factory::getUser(); + $user = Factory::getApplication()->getIdentity(); return $user->authorise('note.edit', 'com_getbible.note.'. ((int) isset($data[$key]) ? $data[$key] : 0)) or $user->authorise('note.edit', 'com_getbible'); } @@ -445,11 +446,11 @@ class GetbibleModelNote extends AdminModel protected function prepareTable($table) { $date = Factory::getDate(); - $user = Factory::getUser(); + $user = $this->getCurrentUser(); if (isset($table->name)) { - $table->name = htmlspecialchars_decode($table->name, ENT_QUOTES); + $table->name = \htmlspecialchars_decode($table->name, ENT_QUOTES); } if (isset($table->alias) && empty($table->alias)) @@ -468,7 +469,7 @@ class GetbibleModelNote extends AdminModel // Set ordering to the last item if not set if (empty($table->ordering)) { - $db = Factory::getDbo(); + $db = $this->getDatabase(); $query = $db->getQuery(true) ->select('MAX(ordering)') ->from($db->quoteName('#__getbible_note')); @@ -498,7 +499,7 @@ class GetbibleModelNote extends AdminModel * * @since 1.6 */ - protected function loadFormData() + protected function loadFormData() { // Check the session for previously entered form data. $data = Factory::getApplication()->getUserState('com_getbible.edit.note.data', []); @@ -506,10 +507,11 @@ class GetbibleModelNote extends AdminModel if (empty($data)) { $data = $this->getItem(); - // run the perprocess of the data - $this->preprocessData('com_getbible.note', $data); } + // run the perprocess of the data + $this->preprocessData('com_getbible.note', $data); + return $data; } @@ -596,7 +598,7 @@ class GetbibleModelNote extends AdminModel $done = false; // Set some needed variables. - $this->user = Factory::getUser(); + $this->user = $this->getCurrentUser(); $this->table = $this->getTable(); $this->tableClassName = get_class($this->table); $this->contentType = new UCMType; @@ -675,7 +677,7 @@ class GetbibleModelNote extends AdminModel if (empty($this->batchSet)) { // Set some needed variables. - $this->user = Factory::getUser(); + $this->user = Factory::getApplication()->getIdentity(); $this->table = $this->getTable(); $this->tableClassName = get_class($this->table); $this->canDo = GetbibleHelper::getActions('note'); @@ -701,7 +703,7 @@ class GetbibleModelNote extends AdminModel $values['published'] = 0; } - $newIds = array(); + $newIds = []; // Parent exists so let's proceed while (!empty($pks)) { @@ -736,7 +738,7 @@ class GetbibleModelNote extends AdminModel } // insert all set values - if (GetbibleHelper::checkArray($values)) + if (UtilitiesArrayHelper::check($values)) { foreach ($values as $key => $value) { @@ -748,7 +750,7 @@ class GetbibleModelNote extends AdminModel } // update all unique fields - if (GetbibleHelper::checkArray($uniqueFields)) + if (UtilitiesArrayHelper::check($uniqueFields)) { foreach ($uniqueFields as $uniqueField) { @@ -812,7 +814,7 @@ class GetbibleModelNote extends AdminModel if (empty($this->batchSet)) { // Set some needed variables. - $this->user = Factory::getUser(); + $this->user = Factory::getApplication()->getIdentity(); $this->table = $this->getTable(); $this->tableClassName = get_class($this->table); $this->canDo = GetbibleHelper::getActions('note'); @@ -859,7 +861,7 @@ class GetbibleModelNote extends AdminModel } // insert all set values. - if (GetbibleHelper::checkArray($values)) + if (UtilitiesArrayHelper::check($values)) { foreach ($values as $key => $value) { @@ -915,14 +917,14 @@ class GetbibleModelNote extends AdminModel */ public function save($data) { - $input = Factory::getApplication()->input; - $filter = InputFilter::getInstance(); + $input = Factory::getApplication()->input; + $filter = InputFilter::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 Registry; $metadata->loadArray($data['metadata']); $data['metadata'] = (string) $metadata; @@ -982,12 +984,12 @@ class GetbibleModelNote extends AdminModel * * @since 3.0 */ - protected function generateUnique($field,$value) + protected function generateUnique($field, $value) { // set field value unique $table = $this->getTable(); - while ($table->load(array($field => $value))) + while ($table->load([$field => $value])) { $value = StringHelper::increment($value); } diff --git a/admin/models/notes.php b/admin/src/Model/NotesModel.php similarity index 91% rename from admin/models/notes.php rename to admin/src/Model/NotesModel.php index 99d0aa3..595256c 100644 --- a/admin/models/notes.php +++ b/admin/src/Model/NotesModel.php @@ -14,9 +14,10 @@ @license GNU/GPL Version 2 or later - http://www.gnu.org/licenses/gpl-2.0.html /------------------------------------------------------------------------------------------------------*/ +namespace TrueChristianChurch\Component\Getbible\Administrator\Model; // No direct access to this file -defined('_JEXEC') or die('Restricted access'); +\defined('_JEXEC') or die; use Joomla\CMS\Factory; use Joomla\CMS\Language\Text; @@ -24,6 +25,8 @@ use Joomla\CMS\Component\ComponentHelper; use Joomla\CMS\MVC\Model\ListModel; use Joomla\CMS\Plugin\PluginHelper; use Joomla\Utilities\ArrayHelper; +use Joomla\CMS\Helper\TagsHelper; +use TrueChristianChurch\Component\Getbible\Administrator\Helper\GetbibleHelper; use VDM\Joomla\Utilities\ArrayHelper as UtilitiesArrayHelper; use VDM\Joomla\Utilities\ObjectHelper; use VDM\Joomla\Utilities\StringHelper; @@ -31,12 +34,12 @@ use VDM\Joomla\Utilities\StringHelper; /** * Notes List Model */ -class GetbibleModelNotes extends ListModel +class NotesModel extends ListModel { public function __construct($config = []) { if (empty($config['filter_fields'])) - { + { $config['filter_fields'] = array( 'a.id','id', 'a.published','published', @@ -151,7 +154,7 @@ class GetbibleModelNotes extends ListModel // Get the user object if not set. if (!isset($user) || !ObjectHelper::check($user)) { - $user = Factory::getUser(); + $user = $this->getCurrentUser(); } foreach ($items as $nr => &$item) { @@ -185,7 +188,7 @@ class GetbibleModelNotes extends ListModel /** * Method to convert selection values to translatable string. * - * @return translatable string + * @return string The translatable string. */ public function selectionTranslation($value,$name) { @@ -208,14 +211,14 @@ class GetbibleModelNotes extends ListModel /** * Method to build an SQL query to load the list data. * - * @return string An SQL query + * @return string An SQL query */ protected function getListQuery() { // Get the user object. - $user = Factory::getUser(); + $user = $this->getCurrentUser(); // Create a new query object. - $db = Factory::getDBO(); + $db = $this->getDatabase(); $query = $db->getQuery(true); // Select some fields @@ -276,7 +279,7 @@ class GetbibleModelNotes extends ListModel $query->where('a.book_nr = ' . (int) $_book_nr); } } - elseif (GetbibleHelper::checkString($_book_nr)) + elseif (StringHelper::check($_book_nr)) { $query->where('a.book_nr = ' . $db->quote($db->escape($_book_nr))); } @@ -293,7 +296,7 @@ class GetbibleModelNotes extends ListModel $query->where('a.linker = ' . (int) $_linker); } } - elseif (GetbibleHelper::checkString($_linker)) + elseif (StringHelper::check($_linker)) { $query->where('a.linker = ' . $db->quote($db->escape($_linker))); } @@ -310,7 +313,7 @@ class GetbibleModelNotes extends ListModel $query->where('a.access = ' . (int) $_access); } } - elseif (GetbibleHelper::checkString($_access)) + elseif (StringHelper::check($_access)) { $query->where('a.access = ' . $db->quote($db->escape($_access))); } @@ -327,7 +330,7 @@ class GetbibleModelNotes extends ListModel $query->where('a.verse = ' . (int) $_verse); } } - elseif (GetbibleHelper::checkString($_verse)) + elseif (StringHelper::check($_verse)) { $query->where('a.verse = ' . $db->quote($db->escape($_verse))); } @@ -344,16 +347,18 @@ class GetbibleModelNotes extends ListModel $query->where('a.chapter = ' . (int) $_chapter); } } - elseif (GetbibleHelper::checkString($_chapter)) + elseif (StringHelper::check($_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'); + $orderCol = $this->getState('list.ordering', 'a.id'); + $orderDirn = $this->getState('list.direction', 'desc'); if ($orderCol != '') { + // Check that the order direction is valid encase we have a field called direction as part of filers. + $orderDirn = (is_string($orderDirn) && in_array(strtolower($orderDirn), ['asc', 'desc'])) ? $orderDirn : 'desc'; $query->order($db->escape($orderCol . ' ' . $orderDirn)); } @@ -386,19 +391,18 @@ class GetbibleModelNotes extends ListModel /** * Build an SQL query to checkin all items left checked out longer then a set time. * - * @return a bool - * + * @return bool + * @since 3.2.0 */ - protected function checkInNow() + protected function checkInNow(): bool { // Get set check in time $time = ComponentHelper::getParams('com_getbible')->get('check_in'); if ($time) { - // Get a db connection. - $db = Factory::getDbo(); + $db = $this->getDatabase(); // Reset query. $query = $db->getQuery(true); $query->select('*'); @@ -431,7 +435,7 @@ class GetbibleModelNotes extends ListModel $db->setQuery($query); - $db->execute(); + return $db->execute(); } } diff --git a/admin/models/open_ai_message.php b/admin/src/Model/Open_ai_messageModel.php similarity index 92% rename from admin/models/open_ai_message.php rename to admin/src/Model/Open_ai_messageModel.php index b3091af..758af91 100644 --- a/admin/models/open_ai_message.php +++ b/admin/src/Model/Open_ai_messageModel.php @@ -14,27 +14,35 @@ @license GNU/GPL Version 2 or later - http://www.gnu.org/licenses/gpl-2.0.html /------------------------------------------------------------------------------------------------------*/ +namespace TrueChristianChurch\Component\Getbible\Administrator\Model; // No direct access to this file -defined('_JEXEC') or die('Restricted access'); +\defined('_JEXEC') or die; use Joomla\CMS\Factory; use Joomla\CMS\Language\Text; +use Joomla\CMS\Form\Form; use Joomla\CMS\Filter\InputFilter; +use Joomla\CMS\Filter\OutputFilter; use Joomla\CMS\MVC\Model\AdminModel; use Joomla\CMS\Table\Table; use Joomla\CMS\UCM\UCMType; -use Joomla\Filter\OutputFilter; +use Joomla\CMS\Versioning\VersionableModelTrait; use Joomla\Registry\Registry; use Joomla\String\StringHelper; use Joomla\Utilities\ArrayHelper; +use Joomla\CMS\Helper\TagsHelper; +use TrueChristianChurch\Component\Getbible\Administrator\Helper\GetbibleHelper; +use VDM\Joomla\Utilities\StringHelper as UtilitiesStringHelper; use VDM\Joomla\Utilities\ArrayHelper as UtilitiesArrayHelper; /** * Getbible Open_ai_message Admin Model */ -class GetbibleModelOpen_ai_message extends AdminModel +class Open_ai_messageModel extends AdminModel { + use VersionableModelTrait; + /** * The tab layout fields array. * @@ -83,14 +91,13 @@ class GetbibleModelOpen_ai_message extends AdminModel * * @return Table A database object * - * @since 1.6 + * @since 3.0 + * @throws \Exception */ - public function getTable($type = 'open_ai_message', $prefix = 'GetbibleTable', $config = []) + public function getTable($type = 'open_ai_message', $prefix = 'Administrator', $config = []) { - // 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 Table::getInstance($type, $prefix, $config); + return parent::getTable($type, $prefix, $config); } /** @@ -133,11 +140,11 @@ class GetbibleModelOpen_ai_message extends AdminModel * @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 + * @return Form|boolean A Form object on success, false on failure * * @since 1.6 */ - public function getForm($data = [], $loadData = true, $options = array('control' => 'jform')) + public function getForm($data = [], $loadData = true, $options = ['control' => 'jform']) { // set load data option $options['load_data'] = $loadData; @@ -177,7 +184,7 @@ class GetbibleModelOpen_ai_message extends AdminModel $id = $jinput->get('id', 0, 'INT'); } - $user = Factory::getUser(); + $user = Factory::getApplication()->getIdentity(); // Check for existing item. // Modify the form based on Edit State access controls. @@ -362,7 +369,7 @@ class GetbibleModelOpen_ai_message extends AdminModel /** * Method to get the script that have to be included on the form * - * @return string script files + * @return string script files */ public function getScript() { @@ -380,18 +387,13 @@ class GetbibleModelOpen_ai_message extends AdminModel */ protected function canDelete($record) { - if (!empty($record->id)) + if (empty($record->id) || ($record->state != -2)) { - if ($record->published != -2) - { - return; - } - - $user = Factory::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; } - return false; + + // The record has been set. Check the record permissions. + return $this->getCurrentUser()->authorise('open_ai_message.delete', 'com_getbible.open_ai_message.' . (int) $record->id); } /** @@ -405,8 +407,8 @@ class GetbibleModelOpen_ai_message extends AdminModel */ protected function canEditState($record) { - $user = Factory::getUser(); - $recordId = (!empty($record->id)) ? $record->id : 0; + $user = $this->getCurrentUser(); + $recordId = $record->id ?? 0; if ($recordId) { @@ -424,16 +426,16 @@ class GetbibleModelOpen_ai_message extends AdminModel /** * 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. + * @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 + * @return boolean + * @since 2.5 */ protected function allowEdit($data = [], $key = 'id') { // Check specific edit permission then general edit permission. - $user = Factory::getUser(); + $user = Factory::getApplication()->getIdentity(); 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'); } @@ -450,11 +452,11 @@ class GetbibleModelOpen_ai_message extends AdminModel protected function prepareTable($table) { $date = Factory::getDate(); - $user = Factory::getUser(); + $user = $this->getCurrentUser(); if (isset($table->name)) { - $table->name = htmlspecialchars_decode($table->name, ENT_QUOTES); + $table->name = \htmlspecialchars_decode($table->name, ENT_QUOTES); } if (isset($table->alias) && empty($table->alias)) @@ -473,7 +475,7 @@ class GetbibleModelOpen_ai_message extends AdminModel // Set ordering to the last item if not set if (empty($table->ordering)) { - $db = Factory::getDbo(); + $db = $this->getDatabase(); $query = $db->getQuery(true) ->select('MAX(ordering)') ->from($db->quoteName('#__getbible_open_ai_message')); @@ -503,7 +505,7 @@ class GetbibleModelOpen_ai_message extends AdminModel * * @since 1.6 */ - protected function loadFormData() + protected function loadFormData() { // Check the session for previously entered form data. $data = Factory::getApplication()->getUserState('com_getbible.edit.open_ai_message.data', []); @@ -511,10 +513,11 @@ class GetbibleModelOpen_ai_message extends AdminModel if (empty($data)) { $data = $this->getItem(); - // run the perprocess of the data - $this->preprocessData('com_getbible.open_ai_message', $data); } + // run the perprocess of the data + $this->preprocessData('com_getbible.open_ai_message', $data); + return $data; } @@ -601,7 +604,7 @@ class GetbibleModelOpen_ai_message extends AdminModel $done = false; // Set some needed variables. - $this->user = Factory::getUser(); + $this->user = $this->getCurrentUser(); $this->table = $this->getTable(); $this->tableClassName = get_class($this->table); $this->contentType = new UCMType; @@ -680,7 +683,7 @@ class GetbibleModelOpen_ai_message extends AdminModel if (empty($this->batchSet)) { // Set some needed variables. - $this->user = Factory::getUser(); + $this->user = Factory::getApplication()->getIdentity(); $this->table = $this->getTable(); $this->tableClassName = get_class($this->table); $this->canDo = GetbibleHelper::getActions('open_ai_message'); @@ -706,7 +709,7 @@ class GetbibleModelOpen_ai_message extends AdminModel $values['published'] = 0; } - $newIds = array(); + $newIds = []; // Parent exists so let's proceed while (!empty($pks)) { @@ -741,13 +744,13 @@ class GetbibleModelOpen_ai_message extends AdminModel } // Only for strings - if (GetbibleHelper::checkString($this->table->role) && !is_numeric($this->table->role)) + if (UtilitiesStringHelper::check($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)) + if (UtilitiesArrayHelper::check($values)) { foreach ($values as $key => $value) { @@ -759,7 +762,7 @@ class GetbibleModelOpen_ai_message extends AdminModel } // update all unique fields - if (GetbibleHelper::checkArray($uniqueFields)) + if (UtilitiesArrayHelper::check($uniqueFields)) { foreach ($uniqueFields as $uniqueField) { @@ -823,7 +826,7 @@ class GetbibleModelOpen_ai_message extends AdminModel if (empty($this->batchSet)) { // Set some needed variables. - $this->user = Factory::getUser(); + $this->user = Factory::getApplication()->getIdentity(); $this->table = $this->getTable(); $this->tableClassName = get_class($this->table); $this->canDo = GetbibleHelper::getActions('open_ai_message'); @@ -870,7 +873,7 @@ class GetbibleModelOpen_ai_message extends AdminModel } // insert all set values. - if (GetbibleHelper::checkArray($values)) + if (UtilitiesArrayHelper::check($values)) { foreach ($values as $key => $value) { @@ -926,14 +929,14 @@ class GetbibleModelOpen_ai_message extends AdminModel */ public function save($data) { - $input = Factory::getApplication()->input; - $filter = InputFilter::getInstance(); + $input = Factory::getApplication()->input; + $filter = InputFilter::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 Registry; $metadata->loadArray($data['metadata']); $data['metadata'] = (string) $metadata; @@ -978,12 +981,12 @@ class GetbibleModelOpen_ai_message extends AdminModel * * @since 3.0 */ - protected function generateUnique($field,$value) + protected function generateUnique($field, $value) { // set field value unique $table = $this->getTable(); - while ($table->load(array($field => $value))) + while ($table->load([$field => $value])) { $value = StringHelper::increment($value); } @@ -1005,7 +1008,7 @@ class GetbibleModelOpen_ai_message extends AdminModel // Alter the title $table = $this->getTable(); - while ($table->load(array('title' => $title))) + while ($table->load(['title' => $title])) { $title = StringHelper::increment($title); } diff --git a/admin/models/open_ai_messages.php b/admin/src/Model/Open_ai_messagesModel.php similarity index 91% rename from admin/models/open_ai_messages.php rename to admin/src/Model/Open_ai_messagesModel.php index f6f3fd7..bbec339 100644 --- a/admin/models/open_ai_messages.php +++ b/admin/src/Model/Open_ai_messagesModel.php @@ -14,9 +14,10 @@ @license GNU/GPL Version 2 or later - http://www.gnu.org/licenses/gpl-2.0.html /------------------------------------------------------------------------------------------------------*/ +namespace TrueChristianChurch\Component\Getbible\Administrator\Model; // No direct access to this file -defined('_JEXEC') or die('Restricted access'); +\defined('_JEXEC') or die; use Joomla\CMS\Factory; use Joomla\CMS\Language\Text; @@ -24,6 +25,8 @@ use Joomla\CMS\Component\ComponentHelper; use Joomla\CMS\MVC\Model\ListModel; use Joomla\CMS\Plugin\PluginHelper; use Joomla\Utilities\ArrayHelper; +use Joomla\CMS\Helper\TagsHelper; +use TrueChristianChurch\Component\Getbible\Administrator\Helper\GetbibleHelper; use VDM\Joomla\Utilities\ArrayHelper as UtilitiesArrayHelper; use VDM\Joomla\Utilities\ObjectHelper; use VDM\Joomla\Utilities\StringHelper; @@ -31,12 +34,12 @@ use VDM\Joomla\Utilities\StringHelper; /** * Open_ai_messages List Model */ -class GetbibleModelOpen_ai_messages extends ListModel +class Open_ai_messagesModel extends ListModel { public function __construct($config = []) { if (empty($config['filter_fields'])) - { + { $config['filter_fields'] = array( 'a.id','id', 'a.published','published', @@ -151,7 +154,7 @@ class GetbibleModelOpen_ai_messages extends ListModel // Get the user object if not set. if (!isset($user) || !ObjectHelper::check($user)) { - $user = Factory::getUser(); + $user = $this->getCurrentUser(); } foreach ($items as $nr => &$item) { @@ -186,7 +189,7 @@ class GetbibleModelOpen_ai_messages extends ListModel /** * Method to convert selection values to translatable string. * - * @return translatable string + * @return string The translatable string. */ public function selectionTranslation($value,$name) { @@ -224,14 +227,14 @@ class GetbibleModelOpen_ai_messages extends ListModel /** * Method to build an SQL query to load the list data. * - * @return string An SQL query + * @return string An SQL query */ protected function getListQuery() { // Get the user object. - $user = Factory::getUser(); + $user = $this->getCurrentUser(); // Create a new query object. - $db = Factory::getDBO(); + $db = $this->getDatabase(); $query = $db->getQuery(true); // Select some fields @@ -268,7 +271,7 @@ class GetbibleModelOpen_ai_messages extends ListModel { $query->where('a.access = ' . (int) $_access); } - elseif (GetbibleHelper::checkArray($_access)) + elseif (UtilitiesArrayHelper::check($_access)) { // Secure the array for the query $_access = ArrayHelper::toInteger($_access); @@ -309,7 +312,7 @@ class GetbibleModelOpen_ai_messages extends ListModel $query->where('a.role = ' . (int) $_role); } } - elseif (GetbibleHelper::checkString($_role)) + elseif (StringHelper::check($_role)) { $query->where('a.role = ' . $db->quote($db->escape($_role))); } @@ -326,7 +329,7 @@ class GetbibleModelOpen_ai_messages extends ListModel $query->where('a.open_ai_response = ' . (int) $_open_ai_response); } } - elseif (GetbibleHelper::checkString($_open_ai_response)) + elseif (StringHelper::check($_open_ai_response)) { $query->where('a.open_ai_response = ' . $db->quote($db->escape($_open_ai_response))); } @@ -343,7 +346,7 @@ class GetbibleModelOpen_ai_messages extends ListModel $query->where('a.prompt = ' . (int) $_prompt); } } - elseif (GetbibleHelper::checkString($_prompt)) + elseif (StringHelper::check($_prompt)) { $query->where('a.prompt = ' . $db->quote($db->escape($_prompt))); } @@ -360,16 +363,18 @@ class GetbibleModelOpen_ai_messages extends ListModel $query->where('a.source = ' . (int) $_source); } } - elseif (GetbibleHelper::checkString($_source)) + elseif (StringHelper::check($_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'); + $orderCol = $this->getState('list.ordering', 'a.id'); + $orderDirn = $this->getState('list.direction', 'desc'); if ($orderCol != '') { + // Check that the order direction is valid encase we have a field called direction as part of filers. + $orderDirn = (is_string($orderDirn) && in_array(strtolower($orderDirn), ['asc', 'desc'])) ? $orderDirn : 'desc'; $query->order($db->escape($orderCol . ' ' . $orderDirn)); } @@ -414,19 +419,18 @@ class GetbibleModelOpen_ai_messages extends ListModel /** * Build an SQL query to checkin all items left checked out longer then a set time. * - * @return a bool - * + * @return bool + * @since 3.2.0 */ - protected function checkInNow() + protected function checkInNow(): bool { // Get set check in time $time = ComponentHelper::getParams('com_getbible')->get('check_in'); if ($time) { - // Get a db connection. - $db = Factory::getDbo(); + $db = $this->getDatabase(); // Reset query. $query = $db->getQuery(true); $query->select('*'); @@ -459,7 +463,7 @@ class GetbibleModelOpen_ai_messages extends ListModel $db->setQuery($query); - $db->execute(); + return $db->execute(); } } diff --git a/admin/models/open_ai_response.php b/admin/src/Model/Open_ai_responseModel.php similarity index 94% rename from admin/models/open_ai_response.php rename to admin/src/Model/Open_ai_responseModel.php index b5003d8..1f5d6e8 100644 --- a/admin/models/open_ai_response.php +++ b/admin/src/Model/Open_ai_responseModel.php @@ -14,20 +14,25 @@ @license GNU/GPL Version 2 or later - http://www.gnu.org/licenses/gpl-2.0.html /------------------------------------------------------------------------------------------------------*/ +namespace TrueChristianChurch\Component\Getbible\Administrator\Model; // No direct access to this file -defined('_JEXEC') or die('Restricted access'); +\defined('_JEXEC') or die; use Joomla\CMS\Factory; use Joomla\CMS\Language\Text; +use Joomla\CMS\Form\Form; use Joomla\CMS\Filter\InputFilter; +use Joomla\CMS\Filter\OutputFilter; use Joomla\CMS\MVC\Model\AdminModel; use Joomla\CMS\Table\Table; use Joomla\CMS\UCM\UCMType; -use Joomla\Filter\OutputFilter; +use Joomla\CMS\Versioning\VersionableModelTrait; use Joomla\Registry\Registry; use Joomla\String\StringHelper; use Joomla\Utilities\ArrayHelper; +use Joomla\CMS\Helper\TagsHelper; +use TrueChristianChurch\Component\Getbible\Administrator\Helper\GetbibleHelper; use VDM\Joomla\Utilities\ArrayHelper as UtilitiesArrayHelper; use VDM\Joomla\Utilities\ObjectHelper; use VDM\Joomla\Utilities\StringHelper as UtilitiesStringHelper; @@ -35,8 +40,10 @@ use VDM\Joomla\Utilities\StringHelper as UtilitiesStringHelper; /** * Getbible Open_ai_response Admin Model */ -class GetbibleModelOpen_ai_response extends AdminModel +class Open_ai_responseModel extends AdminModel { + use VersionableModelTrait; + /** * The tab layout fields array. * @@ -111,14 +118,13 @@ class GetbibleModelOpen_ai_response extends AdminModel * * @return Table A database object * - * @since 1.6 + * @since 3.0 + * @throws \Exception */ - public function getTable($type = 'open_ai_response', $prefix = 'GetbibleTable', $config = []) + public function getTable($type = 'open_ai_response', $prefix = 'Administrator', $config = []) { - // 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 Table::getInstance($type, $prefix, $config); + return parent::getTable($type, $prefix, $config); } /** @@ -163,9 +169,9 @@ class GetbibleModelOpen_ai_response extends AdminModel public function getVvymessage() { // Get the user object. - $user = Factory::getUser(); + $user = Factory::getApplication()->getIdentity(); // Create a new query object. - $db = Factory::getDBO(); + $db = $this->getDatabase(); $query = $db->getQuery(true); // Select some fields @@ -206,7 +212,7 @@ class GetbibleModelOpen_ai_response extends AdminModel { $query->where('a.access = ' . (int) $_access); } - elseif (GetbibleHelper::checkArray($_access)) + elseif (UtilitiesArrayHelper::check($_access)) { // Secure the array for the query $_access = ArrayHelper::toInteger($_access); @@ -237,7 +243,7 @@ class GetbibleModelOpen_ai_response extends AdminModel // Get the user object if not set. if (!isset($user) || !ObjectHelper::check($user)) { - $user = Factory::getUser(); + $user = $this->getCurrentUser(); } foreach ($items as $nr => &$item) { @@ -272,7 +278,7 @@ class GetbibleModelOpen_ai_response extends AdminModel /** * Method to convert selection values to translatable string. * - * @return translatable string + * @return string The translatable string. */ public function selectionTranslationVvymessage($value,$name) { @@ -314,11 +320,11 @@ class GetbibleModelOpen_ai_response extends AdminModel * @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 + * @return Form|boolean A Form object on success, false on failure * * @since 1.6 */ - public function getForm($data = [], $loadData = true, $options = array('control' => 'jform')) + public function getForm($data = [], $loadData = true, $options = ['control' => 'jform']) { // set load data option $options['load_data'] = $loadData; @@ -358,7 +364,7 @@ class GetbibleModelOpen_ai_response extends AdminModel $id = $jinput->get('id', 0, 'INT'); } - $user = Factory::getUser(); + $user = Factory::getApplication()->getIdentity(); // Check for existing item. // Modify the form based on Edit State access controls. @@ -812,7 +818,7 @@ class GetbibleModelOpen_ai_response extends AdminModel /** * Method to get the script that have to be included on the form * - * @return string script files + * @return string script files */ public function getScript() { @@ -830,18 +836,13 @@ class GetbibleModelOpen_ai_response extends AdminModel */ protected function canDelete($record) { - if (!empty($record->id)) + if (empty($record->id) || ($record->state != -2)) { - if ($record->published != -2) - { - return; - } - - $user = Factory::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; } - return false; + + // The record has been set. Check the record permissions. + return $this->getCurrentUser()->authorise('open_ai_response.delete', 'com_getbible.open_ai_response.' . (int) $record->id); } /** @@ -855,8 +856,8 @@ class GetbibleModelOpen_ai_response extends AdminModel */ protected function canEditState($record) { - $user = Factory::getUser(); - $recordId = (!empty($record->id)) ? $record->id : 0; + $user = $this->getCurrentUser(); + $recordId = $record->id ?? 0; if ($recordId) { @@ -874,16 +875,16 @@ class GetbibleModelOpen_ai_response extends AdminModel /** * 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. + * @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 + * @return boolean + * @since 2.5 */ protected function allowEdit($data = [], $key = 'id') { // Check specific edit permission then general edit permission. - $user = Factory::getUser(); + $user = Factory::getApplication()->getIdentity(); 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'); } @@ -900,11 +901,11 @@ class GetbibleModelOpen_ai_response extends AdminModel protected function prepareTable($table) { $date = Factory::getDate(); - $user = Factory::getUser(); + $user = $this->getCurrentUser(); if (isset($table->name)) { - $table->name = htmlspecialchars_decode($table->name, ENT_QUOTES); + $table->name = \htmlspecialchars_decode($table->name, ENT_QUOTES); } if (isset($table->alias) && empty($table->alias)) @@ -923,7 +924,7 @@ class GetbibleModelOpen_ai_response extends AdminModel // Set ordering to the last item if not set if (empty($table->ordering)) { - $db = Factory::getDbo(); + $db = $this->getDatabase(); $query = $db->getQuery(true) ->select('MAX(ordering)') ->from($db->quoteName('#__getbible_open_ai_response')); @@ -953,7 +954,7 @@ class GetbibleModelOpen_ai_response extends AdminModel * * @since 1.6 */ - protected function loadFormData() + protected function loadFormData() { // Check the session for previously entered form data. $data = Factory::getApplication()->getUserState('com_getbible.edit.open_ai_response.data', []); @@ -961,10 +962,11 @@ class GetbibleModelOpen_ai_response extends AdminModel if (empty($data)) { $data = $this->getItem(); - // run the perprocess of the data - $this->preprocessData('com_getbible.open_ai_response', $data); } + // run the perprocess of the data + $this->preprocessData('com_getbible.open_ai_response', $data); + return $data; } @@ -1051,7 +1053,7 @@ class GetbibleModelOpen_ai_response extends AdminModel $done = false; // Set some needed variables. - $this->user = Factory::getUser(); + $this->user = $this->getCurrentUser(); $this->table = $this->getTable(); $this->tableClassName = get_class($this->table); $this->contentType = new UCMType; @@ -1130,7 +1132,7 @@ class GetbibleModelOpen_ai_response extends AdminModel if (empty($this->batchSet)) { // Set some needed variables. - $this->user = Factory::getUser(); + $this->user = Factory::getApplication()->getIdentity(); $this->table = $this->getTable(); $this->tableClassName = get_class($this->table); $this->canDo = GetbibleHelper::getActions('open_ai_response'); @@ -1156,7 +1158,7 @@ class GetbibleModelOpen_ai_response extends AdminModel $values['published'] = 0; } - $newIds = array(); + $newIds = []; // Parent exists so let's proceed while (!empty($pks)) { @@ -1191,13 +1193,13 @@ class GetbibleModelOpen_ai_response extends AdminModel } // Only for strings - if (GetbibleHelper::checkString($this->table->response_id) && !is_numeric($this->table->response_id)) + if (UtilitiesStringHelper::check($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)) + if (UtilitiesArrayHelper::check($values)) { foreach ($values as $key => $value) { @@ -1209,7 +1211,7 @@ class GetbibleModelOpen_ai_response extends AdminModel } // update all unique fields - if (GetbibleHelper::checkArray($uniqueFields)) + if (UtilitiesArrayHelper::check($uniqueFields)) { foreach ($uniqueFields as $uniqueField) { @@ -1273,7 +1275,7 @@ class GetbibleModelOpen_ai_response extends AdminModel if (empty($this->batchSet)) { // Set some needed variables. - $this->user = Factory::getUser(); + $this->user = Factory::getApplication()->getIdentity(); $this->table = $this->getTable(); $this->tableClassName = get_class($this->table); $this->canDo = GetbibleHelper::getActions('open_ai_response'); @@ -1320,7 +1322,7 @@ class GetbibleModelOpen_ai_response extends AdminModel } // insert all set values. - if (GetbibleHelper::checkArray($values)) + if (UtilitiesArrayHelper::check($values)) { foreach ($values as $key => $value) { @@ -1376,14 +1378,14 @@ class GetbibleModelOpen_ai_response extends AdminModel */ public function save($data) { - $input = Factory::getApplication()->input; - $filter = InputFilter::getInstance(); + $input = Factory::getApplication()->input; + $filter = InputFilter::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 Registry; $metadata->loadArray($data['metadata']); $data['metadata'] = (string) $metadata; @@ -1428,12 +1430,12 @@ class GetbibleModelOpen_ai_response extends AdminModel * * @since 3.0 */ - protected function generateUnique($field,$value) + protected function generateUnique($field, $value) { // set field value unique $table = $this->getTable(); - while ($table->load(array($field => $value))) + while ($table->load([$field => $value])) { $value = StringHelper::increment($value); } @@ -1455,7 +1457,7 @@ class GetbibleModelOpen_ai_response extends AdminModel // Alter the title $table = $this->getTable(); - while ($table->load(array('title' => $title))) + while ($table->load(['title' => $title])) { $title = StringHelper::increment($title); } diff --git a/admin/models/open_ai_responses.php b/admin/src/Model/Open_ai_responsesModel.php similarity index 91% rename from admin/models/open_ai_responses.php rename to admin/src/Model/Open_ai_responsesModel.php index 10254cb..3fe651d 100644 --- a/admin/models/open_ai_responses.php +++ b/admin/src/Model/Open_ai_responsesModel.php @@ -14,9 +14,10 @@ @license GNU/GPL Version 2 or later - http://www.gnu.org/licenses/gpl-2.0.html /------------------------------------------------------------------------------------------------------*/ +namespace TrueChristianChurch\Component\Getbible\Administrator\Model; // No direct access to this file -defined('_JEXEC') or die('Restricted access'); +\defined('_JEXEC') or die; use Joomla\CMS\Factory; use Joomla\CMS\Language\Text; @@ -24,6 +25,8 @@ use Joomla\CMS\Component\ComponentHelper; use Joomla\CMS\MVC\Model\ListModel; use Joomla\CMS\Plugin\PluginHelper; use Joomla\Utilities\ArrayHelper; +use Joomla\CMS\Helper\TagsHelper; +use TrueChristianChurch\Component\Getbible\Administrator\Helper\GetbibleHelper; use VDM\Joomla\Utilities\ArrayHelper as UtilitiesArrayHelper; use VDM\Joomla\Utilities\ObjectHelper; use VDM\Joomla\Utilities\StringHelper; @@ -31,12 +34,12 @@ use VDM\Joomla\Utilities\StringHelper; /** * Open_ai_responses List Model */ -class GetbibleModelOpen_ai_responses extends ListModel +class Open_ai_responsesModel extends ListModel { public function __construct($config = []) { if (empty($config['filter_fields'])) - { + { $config['filter_fields'] = array( 'a.id','id', 'a.published','published', @@ -159,7 +162,7 @@ class GetbibleModelOpen_ai_responses extends ListModel // Get the user object if not set. if (!isset($user) || !ObjectHelper::check($user)) { - $user = Factory::getUser(); + $user = $this->getCurrentUser(); } foreach ($items as $nr => &$item) { @@ -181,14 +184,14 @@ class GetbibleModelOpen_ai_responses extends ListModel /** * Method to build an SQL query to load the list data. * - * @return string An SQL query + * @return string An SQL query */ protected function getListQuery() { // Get the user object. - $user = Factory::getUser(); + $user = $this->getCurrentUser(); // Create a new query object. - $db = Factory::getDBO(); + $db = $this->getDatabase(); $query = $db->getQuery(true); // Select some fields @@ -221,7 +224,7 @@ class GetbibleModelOpen_ai_responses extends ListModel { $query->where('a.access = ' . (int) $_access); } - elseif (GetbibleHelper::checkArray($_access)) + elseif (UtilitiesArrayHelper::check($_access)) { // Secure the array for the query $_access = ArrayHelper::toInteger($_access); @@ -262,7 +265,7 @@ class GetbibleModelOpen_ai_responses extends ListModel $query->where('a.response_id = ' . (int) $_response_id); } } - elseif (GetbibleHelper::checkString($_response_id)) + elseif (StringHelper::check($_response_id)) { $query->where('a.response_id = ' . $db->quote($db->escape($_response_id))); } @@ -279,7 +282,7 @@ class GetbibleModelOpen_ai_responses extends ListModel $query->where('a.prompt = ' . (int) $_prompt); } } - elseif (GetbibleHelper::checkString($_prompt)) + elseif (StringHelper::check($_prompt)) { $query->where('a.prompt = ' . $db->quote($db->escape($_prompt))); } @@ -296,16 +299,18 @@ class GetbibleModelOpen_ai_responses extends ListModel $query->where('a.response_model = ' . (int) $_response_model); } } - elseif (GetbibleHelper::checkString($_response_model)) + elseif (StringHelper::check($_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'); + $orderCol = $this->getState('list.ordering', 'a.id'); + $orderDirn = $this->getState('list.direction', 'desc'); if ($orderCol != '') { + // Check that the order direction is valid encase we have a field called direction as part of filers. + $orderDirn = (is_string($orderDirn) && in_array(strtolower($orderDirn), ['asc', 'desc'])) ? $orderDirn : 'desc'; $query->order($db->escape($orderCol . ' ' . $orderDirn)); } @@ -351,19 +356,18 @@ class GetbibleModelOpen_ai_responses extends ListModel /** * Build an SQL query to checkin all items left checked out longer then a set time. * - * @return a bool - * + * @return bool + * @since 3.2.0 */ - protected function checkInNow() + protected function checkInNow(): bool { // Get set check in time $time = ComponentHelper::getParams('com_getbible')->get('check_in'); if ($time) { - // Get a db connection. - $db = Factory::getDbo(); + $db = $this->getDatabase(); // Reset query. $query = $db->getQuery(true); $query->select('*'); @@ -396,7 +400,7 @@ class GetbibleModelOpen_ai_responses extends ListModel $db->setQuery($query); - $db->execute(); + return $db->execute(); } } diff --git a/admin/models/password.php b/admin/src/Model/PasswordModel.php similarity index 91% rename from admin/models/password.php rename to admin/src/Model/PasswordModel.php index dd3293f..4c76e0b 100644 --- a/admin/models/password.php +++ b/admin/src/Model/PasswordModel.php @@ -14,29 +14,37 @@ @license GNU/GPL Version 2 or later - http://www.gnu.org/licenses/gpl-2.0.html /------------------------------------------------------------------------------------------------------*/ +namespace TrueChristianChurch\Component\Getbible\Administrator\Model; // No direct access to this file -defined('_JEXEC') or die('Restricted access'); +\defined('_JEXEC') or die; use Joomla\CMS\Factory; use Joomla\CMS\Language\Text; +use Joomla\CMS\Form\Form; use Joomla\CMS\Filter\InputFilter; +use Joomla\CMS\Filter\OutputFilter; use Joomla\CMS\MVC\Model\AdminModel; use Joomla\CMS\Table\Table; use Joomla\CMS\UCM\UCMType; -use Joomla\Filter\OutputFilter; +use Joomla\CMS\Versioning\VersionableModelTrait; use Joomla\Registry\Registry; use Joomla\String\StringHelper; use Joomla\Utilities\ArrayHelper; +use Joomla\CMS\Helper\TagsHelper; +use TrueChristianChurch\Component\Getbible\Administrator\Helper\GetbibleHelper; use VDM\Joomla\Utilities\ArrayHelper as UtilitiesArrayHelper; use VDM\Joomla\Utilities\GuidHelper; +use VDM\Joomla\Utilities\StringHelper as UtilitiesStringHelper; use VDM\Joomla\Utilities\GetHelper; /** * Getbible Password Admin Model */ -class GetbibleModelPassword extends AdminModel +class PasswordModel extends AdminModel { + use VersionableModelTrait; + /** * The tab layout fields array. * @@ -79,14 +87,13 @@ class GetbibleModelPassword extends AdminModel * * @return Table A database object * - * @since 1.6 + * @since 3.0 + * @throws \Exception */ - public function getTable($type = 'password', $prefix = 'GetbibleTable', $config = []) + public function getTable($type = 'password', $prefix = 'Administrator', $config = []) { - // 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 Table::getInstance($type, $prefix, $config); + return parent::getTable($type, $prefix, $config); } /** @@ -129,11 +136,11 @@ class GetbibleModelPassword extends AdminModel * @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 + * @return Form|boolean A Form object on success, false on failure * * @since 1.6 */ - public function getForm($data = [], $loadData = true, $options = array('control' => 'jform')) + public function getForm($data = [], $loadData = true, $options = ['control' => 'jform']) { // set load data option $options['load_data'] = $loadData; @@ -173,7 +180,7 @@ class GetbibleModelPassword extends AdminModel $id = $jinput->get('id', 0, 'INT'); } - $user = Factory::getUser(); + $user = Factory::getApplication()->getIdentity(); // Check for existing item. // Modify the form based on Edit State access controls. @@ -342,7 +349,7 @@ class GetbibleModelPassword extends AdminModel /** * Method to get the script that have to be included on the form * - * @return string script files + * @return string script files */ public function getScript() { @@ -360,18 +367,13 @@ class GetbibleModelPassword extends AdminModel */ protected function canDelete($record) { - if (!empty($record->id)) + if (empty($record->id) || ($record->state != -2)) { - if ($record->published != -2) - { - return; - } - - $user = Factory::getUser(); - // The record has been set. Check the record permissions. - return $user->authorise('password.delete', 'com_getbible.password.' . (int) $record->id); + return false; } - return false; + + // The record has been set. Check the record permissions. + return $this->getCurrentUser()->authorise('password.delete', 'com_getbible.password.' . (int) $record->id); } /** @@ -385,8 +387,8 @@ class GetbibleModelPassword extends AdminModel */ protected function canEditState($record) { - $user = Factory::getUser(); - $recordId = (!empty($record->id)) ? $record->id : 0; + $user = $this->getCurrentUser(); + $recordId = $record->id ?? 0; if ($recordId) { @@ -404,16 +406,16 @@ class GetbibleModelPassword extends AdminModel /** * 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. + * @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 + * @return boolean + * @since 2.5 */ protected function allowEdit($data = [], $key = 'id') { // Check specific edit permission then general edit permission. - $user = Factory::getUser(); + $user = Factory::getApplication()->getIdentity(); return $user->authorise('password.edit', 'com_getbible.password.'. ((int) isset($data[$key]) ? $data[$key] : 0)) or $user->authorise('password.edit', 'com_getbible'); } @@ -430,11 +432,11 @@ class GetbibleModelPassword extends AdminModel protected function prepareTable($table) { $date = Factory::getDate(); - $user = Factory::getUser(); + $user = $this->getCurrentUser(); if (isset($table->name)) { - $table->name = htmlspecialchars_decode($table->name, ENT_QUOTES); + $table->name = \htmlspecialchars_decode($table->name, ENT_QUOTES); } if (isset($table->alias) && empty($table->alias)) @@ -453,7 +455,7 @@ class GetbibleModelPassword extends AdminModel // Set ordering to the last item if not set if (empty($table->ordering)) { - $db = Factory::getDbo(); + $db = $this->getDatabase(); $query = $db->getQuery(true) ->select('MAX(ordering)') ->from($db->quoteName('#__getbible_password')); @@ -483,7 +485,7 @@ class GetbibleModelPassword extends AdminModel * * @since 1.6 */ - protected function loadFormData() + protected function loadFormData() { // Check the session for previously entered form data. $data = Factory::getApplication()->getUserState('com_getbible.edit.password.data', []); @@ -491,10 +493,11 @@ class GetbibleModelPassword extends AdminModel if (empty($data)) { $data = $this->getItem(); - // run the perprocess of the data - $this->preprocessData('com_getbible.password', $data); } + // run the perprocess of the data + $this->preprocessData('com_getbible.password', $data); + return $data; } @@ -581,7 +584,7 @@ class GetbibleModelPassword extends AdminModel $done = false; // Set some needed variables. - $this->user = Factory::getUser(); + $this->user = $this->getCurrentUser(); $this->table = $this->getTable(); $this->tableClassName = get_class($this->table); $this->contentType = new UCMType; @@ -660,7 +663,7 @@ class GetbibleModelPassword extends AdminModel if (empty($this->batchSet)) { // Set some needed variables. - $this->user = Factory::getUser(); + $this->user = Factory::getApplication()->getIdentity(); $this->table = $this->getTable(); $this->tableClassName = get_class($this->table); $this->canDo = GetbibleHelper::getActions('password'); @@ -686,7 +689,7 @@ class GetbibleModelPassword extends AdminModel $values['published'] = 0; } - $newIds = array(); + $newIds = []; // Parent exists so let's proceed while (!empty($pks)) { @@ -721,13 +724,13 @@ class GetbibleModelPassword extends AdminModel } // Only for strings - if (GetbibleHelper::checkString($this->table->name) && !is_numeric($this->table->name)) + if (UtilitiesStringHelper::check($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)) + if (UtilitiesArrayHelper::check($values)) { foreach ($values as $key => $value) { @@ -739,7 +742,7 @@ class GetbibleModelPassword extends AdminModel } // update all unique fields - if (GetbibleHelper::checkArray($uniqueFields)) + if (UtilitiesArrayHelper::check($uniqueFields)) { foreach ($uniqueFields as $uniqueField) { @@ -803,7 +806,7 @@ class GetbibleModelPassword extends AdminModel if (empty($this->batchSet)) { // Set some needed variables. - $this->user = Factory::getUser(); + $this->user = Factory::getApplication()->getIdentity(); $this->table = $this->getTable(); $this->tableClassName = get_class($this->table); $this->canDo = GetbibleHelper::getActions('password'); @@ -850,7 +853,7 @@ class GetbibleModelPassword extends AdminModel } // insert all set values. - if (GetbibleHelper::checkArray($values)) + if (UtilitiesArrayHelper::check($values)) { foreach ($values as $key => $value) { @@ -906,14 +909,14 @@ class GetbibleModelPassword extends AdminModel */ public function save($data) { - $input = Factory::getApplication()->input; - $filter = InputFilter::getInstance(); + $input = Factory::getApplication()->input; + $filter = InputFilter::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 Registry; $metadata->loadArray($data['metadata']); $data['metadata'] = (string) $metadata; @@ -973,12 +976,12 @@ class GetbibleModelPassword extends AdminModel * * @since 3.0 */ - protected function generateUnique($field,$value) + protected function generateUnique($field, $value) { // set field value unique $table = $this->getTable(); - while ($table->load(array($field => $value))) + while ($table->load([$field => $value])) { $value = StringHelper::increment($value); } @@ -1000,7 +1003,7 @@ class GetbibleModelPassword extends AdminModel // Alter the title $table = $this->getTable(); - while ($table->load(array('title' => $title))) + while ($table->load(['title' => $title])) { $title = StringHelper::increment($title); } diff --git a/admin/models/passwords.php b/admin/src/Model/PasswordsModel.php similarity index 90% rename from admin/models/passwords.php rename to admin/src/Model/PasswordsModel.php index a45f9ed..652797e 100644 --- a/admin/models/passwords.php +++ b/admin/src/Model/PasswordsModel.php @@ -14,9 +14,10 @@ @license GNU/GPL Version 2 or later - http://www.gnu.org/licenses/gpl-2.0.html /------------------------------------------------------------------------------------------------------*/ +namespace TrueChristianChurch\Component\Getbible\Administrator\Model; // No direct access to this file -defined('_JEXEC') or die('Restricted access'); +\defined('_JEXEC') or die; use Joomla\CMS\Factory; use Joomla\CMS\Language\Text; @@ -24,6 +25,8 @@ use Joomla\CMS\Component\ComponentHelper; use Joomla\CMS\MVC\Model\ListModel; use Joomla\CMS\Plugin\PluginHelper; use Joomla\Utilities\ArrayHelper; +use Joomla\CMS\Helper\TagsHelper; +use TrueChristianChurch\Component\Getbible\Administrator\Helper\GetbibleHelper; use VDM\Joomla\Utilities\ArrayHelper as UtilitiesArrayHelper; use VDM\Joomla\Utilities\ObjectHelper; use VDM\Joomla\Utilities\StringHelper; @@ -31,12 +34,12 @@ use VDM\Joomla\Utilities\StringHelper; /** * Passwords List Model */ -class GetbibleModelPasswords extends ListModel +class PasswordsModel extends ListModel { public function __construct($config = []) { if (empty($config['filter_fields'])) - { + { $config['filter_fields'] = array( 'a.id','id', 'a.published','published', @@ -135,7 +138,7 @@ class GetbibleModelPasswords extends ListModel // Get the user object if not set. if (!isset($user) || !ObjectHelper::check($user)) { - $user = Factory::getUser(); + $user = $this->getCurrentUser(); } foreach ($items as $nr => &$item) { @@ -157,14 +160,14 @@ class GetbibleModelPasswords extends ListModel /** * Method to build an SQL query to load the list data. * - * @return string An SQL query + * @return string An SQL query */ protected function getListQuery() { // Get the user object. - $user = Factory::getUser(); + $user = $this->getCurrentUser(); // Create a new query object. - $db = Factory::getDBO(); + $db = $this->getDatabase(); $query = $db->getQuery(true); // Select some fields @@ -197,7 +200,7 @@ class GetbibleModelPasswords extends ListModel { $query->where('a.access = ' . (int) $_access); } - elseif (GetbibleHelper::checkArray($_access)) + elseif (UtilitiesArrayHelper::check($_access)) { // Secure the array for the query $_access = ArrayHelper::toInteger($_access); @@ -238,7 +241,7 @@ class GetbibleModelPasswords extends ListModel $query->where('a.name = ' . (int) $_name); } } - elseif (GetbibleHelper::checkString($_name)) + elseif (StringHelper::check($_name)) { $query->where('a.name = ' . $db->quote($db->escape($_name))); } @@ -255,16 +258,18 @@ class GetbibleModelPasswords extends ListModel $query->where('a.linker = ' . (int) $_linker); } } - elseif (GetbibleHelper::checkString($_linker)) + elseif (StringHelper::check($_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'); + $orderCol = $this->getState('list.ordering', 'a.id'); + $orderDirn = $this->getState('list.direction', 'desc'); if ($orderCol != '') { + // Check that the order direction is valid encase we have a field called direction as part of filers. + $orderDirn = (is_string($orderDirn) && in_array(strtolower($orderDirn), ['asc', 'desc'])) ? $orderDirn : 'desc'; $query->order($db->escape($orderCol . ' ' . $orderDirn)); } @@ -307,19 +312,18 @@ class GetbibleModelPasswords extends ListModel /** * Build an SQL query to checkin all items left checked out longer then a set time. * - * @return a bool - * + * @return bool + * @since 3.2.0 */ - protected function checkInNow() + protected function checkInNow(): bool { // Get set check in time $time = ComponentHelper::getParams('com_getbible')->get('check_in'); if ($time) { - // Get a db connection. - $db = Factory::getDbo(); + $db = $this->getDatabase(); // Reset query. $query = $db->getQuery(true); $query->select('*'); @@ -352,7 +356,7 @@ class GetbibleModelPasswords extends ListModel $db->setQuery($query); - $db->execute(); + return $db->execute(); } } diff --git a/admin/models/prompt.php b/admin/src/Model/PromptModel.php similarity index 94% rename from admin/models/prompt.php rename to admin/src/Model/PromptModel.php index ba79778..289412f 100644 --- a/admin/models/prompt.php +++ b/admin/src/Model/PromptModel.php @@ -14,29 +14,37 @@ @license GNU/GPL Version 2 or later - http://www.gnu.org/licenses/gpl-2.0.html /------------------------------------------------------------------------------------------------------*/ +namespace TrueChristianChurch\Component\Getbible\Administrator\Model; // No direct access to this file -defined('_JEXEC') or die('Restricted access'); +\defined('_JEXEC') or die; use Joomla\CMS\Factory; use Joomla\CMS\Language\Text; +use Joomla\CMS\Form\Form; use Joomla\CMS\Filter\InputFilter; +use Joomla\CMS\Filter\OutputFilter; use Joomla\CMS\MVC\Model\AdminModel; use Joomla\CMS\Table\Table; use Joomla\CMS\UCM\UCMType; -use Joomla\Filter\OutputFilter; +use Joomla\CMS\Versioning\VersionableModelTrait; use Joomla\Registry\Registry; use Joomla\String\StringHelper; use Joomla\Utilities\ArrayHelper; +use Joomla\CMS\Helper\TagsHelper; +use TrueChristianChurch\Component\Getbible\Administrator\Helper\GetbibleHelper; use VDM\Joomla\Utilities\GuidHelper; -use VDM\Joomla\Utilities\GetHelper; +use VDM\Joomla\Utilities\StringHelper as UtilitiesStringHelper; use VDM\Joomla\Utilities\ArrayHelper as UtilitiesArrayHelper; +use VDM\Joomla\Utilities\GetHelper; /** * Getbible Prompt Admin Model */ -class GetbibleModelPrompt extends AdminModel +class PromptModel extends AdminModel { + use VersionableModelTrait; + /** * The tab layout fields array. * @@ -124,14 +132,13 @@ class GetbibleModelPrompt extends AdminModel * * @return Table A database object * - * @since 1.6 + * @since 3.0 + * @throws \Exception */ - public function getTable($type = 'prompt', $prefix = 'GetbibleTable', $config = []) + public function getTable($type = 'prompt', $prefix = 'Administrator', $config = []) { - // 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 Table::getInstance($type, $prefix, $config); + return parent::getTable($type, $prefix, $config); } /** @@ -182,11 +189,11 @@ class GetbibleModelPrompt extends AdminModel * @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 + * @return Form|boolean A Form object on success, false on failure * * @since 1.6 */ - public function getForm($data = [], $loadData = true, $options = array('control' => 'jform')) + public function getForm($data = [], $loadData = true, $options = ['control' => 'jform']) { // set load data option $options['load_data'] = $loadData; @@ -226,7 +233,7 @@ class GetbibleModelPrompt extends AdminModel $id = $jinput->get('id', 0, 'INT'); } - $user = Factory::getUser(); + $user = Factory::getApplication()->getIdentity(); // Check for existing item. // Modify the form based on Edit State access controls. @@ -718,7 +725,7 @@ class GetbibleModelPrompt extends AdminModel /** * Method to get the script that have to be included on the form * - * @return string script files + * @return string script files */ public function getScript() { @@ -736,18 +743,13 @@ class GetbibleModelPrompt extends AdminModel */ protected function canDelete($record) { - if (!empty($record->id)) + if (empty($record->id) || ($record->state != -2)) { - if ($record->published != -2) - { - return; - } - - $user = Factory::getUser(); - // The record has been set. Check the record permissions. - return $user->authorise('prompt.delete', 'com_getbible.prompt.' . (int) $record->id); + return false; } - return false; + + // The record has been set. Check the record permissions. + return $this->getCurrentUser()->authorise('prompt.delete', 'com_getbible.prompt.' . (int) $record->id); } /** @@ -761,8 +763,8 @@ class GetbibleModelPrompt extends AdminModel */ protected function canEditState($record) { - $user = Factory::getUser(); - $recordId = (!empty($record->id)) ? $record->id : 0; + $user = $this->getCurrentUser(); + $recordId = $record->id ?? 0; if ($recordId) { @@ -780,16 +782,16 @@ class GetbibleModelPrompt extends AdminModel /** * 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. + * @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 + * @return boolean + * @since 2.5 */ protected function allowEdit($data = [], $key = 'id') { // Check specific edit permission then general edit permission. - $user = Factory::getUser(); + $user = Factory::getApplication()->getIdentity(); return $user->authorise('prompt.edit', 'com_getbible.prompt.'. ((int) isset($data[$key]) ? $data[$key] : 0)) or $user->authorise('prompt.edit', 'com_getbible'); } @@ -806,11 +808,11 @@ class GetbibleModelPrompt extends AdminModel protected function prepareTable($table) { $date = Factory::getDate(); - $user = Factory::getUser(); + $user = $this->getCurrentUser(); if (isset($table->name)) { - $table->name = htmlspecialchars_decode($table->name, ENT_QUOTES); + $table->name = \htmlspecialchars_decode($table->name, ENT_QUOTES); } if (isset($table->alias) && empty($table->alias)) @@ -829,7 +831,7 @@ class GetbibleModelPrompt extends AdminModel // Set ordering to the last item if not set if (empty($table->ordering)) { - $db = Factory::getDbo(); + $db = $this->getDatabase(); $query = $db->getQuery(true) ->select('MAX(ordering)') ->from($db->quoteName('#__getbible_prompt')); @@ -859,7 +861,7 @@ class GetbibleModelPrompt extends AdminModel * * @since 1.6 */ - protected function loadFormData() + protected function loadFormData() { // Check the session for previously entered form data. $data = Factory::getApplication()->getUserState('com_getbible.edit.prompt.data', []); @@ -867,10 +869,11 @@ class GetbibleModelPrompt extends AdminModel if (empty($data)) { $data = $this->getItem(); - // run the perprocess of the data - $this->preprocessData('com_getbible.prompt', $data); } + // run the perprocess of the data + $this->preprocessData('com_getbible.prompt', $data); + return $data; } @@ -957,7 +960,7 @@ class GetbibleModelPrompt extends AdminModel $done = false; // Set some needed variables. - $this->user = Factory::getUser(); + $this->user = $this->getCurrentUser(); $this->table = $this->getTable(); $this->tableClassName = get_class($this->table); $this->contentType = new UCMType; @@ -1036,7 +1039,7 @@ class GetbibleModelPrompt extends AdminModel if (empty($this->batchSet)) { // Set some needed variables. - $this->user = Factory::getUser(); + $this->user = Factory::getApplication()->getIdentity(); $this->table = $this->getTable(); $this->tableClassName = get_class($this->table); $this->canDo = GetbibleHelper::getActions('prompt'); @@ -1062,7 +1065,7 @@ class GetbibleModelPrompt extends AdminModel $values['published'] = 0; } - $newIds = array(); + $newIds = []; // Parent exists so let's proceed while (!empty($pks)) { @@ -1097,13 +1100,13 @@ class GetbibleModelPrompt extends AdminModel } // Only for strings - if (GetbibleHelper::checkString($this->table->name) && !is_numeric($this->table->name)) + if (UtilitiesStringHelper::check($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)) + if (UtilitiesArrayHelper::check($values)) { foreach ($values as $key => $value) { @@ -1115,7 +1118,7 @@ class GetbibleModelPrompt extends AdminModel } // update all unique fields - if (GetbibleHelper::checkArray($uniqueFields)) + if (UtilitiesArrayHelper::check($uniqueFields)) { foreach ($uniqueFields as $uniqueField) { @@ -1179,7 +1182,7 @@ class GetbibleModelPrompt extends AdminModel if (empty($this->batchSet)) { // Set some needed variables. - $this->user = Factory::getUser(); + $this->user = Factory::getApplication()->getIdentity(); $this->table = $this->getTable(); $this->tableClassName = get_class($this->table); $this->canDo = GetbibleHelper::getActions('prompt'); @@ -1226,7 +1229,7 @@ class GetbibleModelPrompt extends AdminModel } // insert all set values. - if (GetbibleHelper::checkArray($values)) + if (UtilitiesArrayHelper::check($values)) { foreach ($values as $key => $value) { @@ -1282,14 +1285,14 @@ class GetbibleModelPrompt extends AdminModel */ public function save($data) { - $input = Factory::getApplication()->input; - $filter = InputFilter::getInstance(); + $input = Factory::getApplication()->input; + $filter = InputFilter::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 Registry; $metadata->loadArray($data['metadata']); $data['metadata'] = (string) $metadata; @@ -1320,7 +1323,7 @@ class GetbibleModelPrompt extends AdminModel // 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']) - && Factory::getUser()->authorise('prompt.edit.messages', 'com_getbible')) + && Factory::getApplication()->getIdentity()->authorise('prompt.edit.messages', 'com_getbible')) { // Set the empty messages to data $data['messages'] = ''; @@ -1365,12 +1368,12 @@ class GetbibleModelPrompt extends AdminModel * * @since 3.0 */ - protected function generateUnique($field,$value) + protected function generateUnique($field, $value) { // set field value unique $table = $this->getTable(); - while ($table->load(array($field => $value))) + while ($table->load([$field => $value])) { $value = StringHelper::increment($value); } @@ -1392,7 +1395,7 @@ class GetbibleModelPrompt extends AdminModel // Alter the title $table = $this->getTable(); - while ($table->load(array('title' => $title))) + while ($table->load(['title' => $title])) { $title = StringHelper::increment($title); } diff --git a/admin/models/prompts.php b/admin/src/Model/PromptsModel.php similarity index 92% rename from admin/models/prompts.php rename to admin/src/Model/PromptsModel.php index 270fd47..a4d08aa 100644 --- a/admin/models/prompts.php +++ b/admin/src/Model/PromptsModel.php @@ -14,9 +14,10 @@ @license GNU/GPL Version 2 or later - http://www.gnu.org/licenses/gpl-2.0.html /------------------------------------------------------------------------------------------------------*/ +namespace TrueChristianChurch\Component\Getbible\Administrator\Model; // No direct access to this file -defined('_JEXEC') or die('Restricted access'); +\defined('_JEXEC') or die; use Joomla\CMS\Factory; use Joomla\CMS\Language\Text; @@ -24,6 +25,8 @@ use Joomla\CMS\Component\ComponentHelper; use Joomla\CMS\MVC\Model\ListModel; use Joomla\CMS\Plugin\PluginHelper; use Joomla\Utilities\ArrayHelper; +use Joomla\CMS\Helper\TagsHelper; +use TrueChristianChurch\Component\Getbible\Administrator\Helper\GetbibleHelper; use VDM\Joomla\Utilities\ArrayHelper as UtilitiesArrayHelper; use VDM\Joomla\Utilities\ObjectHelper; use VDM\Joomla\Utilities\StringHelper; @@ -31,12 +34,12 @@ use VDM\Joomla\Utilities\StringHelper; /** * Prompts List Model */ -class GetbibleModelPrompts extends ListModel +class PromptsModel extends ListModel { public function __construct($config = []) { if (empty($config['filter_fields'])) - { + { $config['filter_fields'] = array( 'a.id','id', 'a.published','published', @@ -159,7 +162,7 @@ class GetbibleModelPrompts extends ListModel // Get the user object if not set. if (!isset($user) || !ObjectHelper::check($user)) { - $user = Factory::getUser(); + $user = $this->getCurrentUser(); } foreach ($items as $nr => &$item) { @@ -196,7 +199,7 @@ class GetbibleModelPrompts extends ListModel /** * Method to convert selection values to translatable string. * - * @return translatable string + * @return string The translatable string. */ public function selectionTranslation($value,$name) { @@ -254,14 +257,14 @@ class GetbibleModelPrompts extends ListModel /** * Method to build an SQL query to load the list data. * - * @return string An SQL query + * @return string An SQL query */ protected function getListQuery() { // Get the user object. - $user = Factory::getUser(); + $user = $this->getCurrentUser(); // Create a new query object. - $db = Factory::getDBO(); + $db = $this->getDatabase(); $query = $db->getQuery(true); // Select some fields @@ -294,7 +297,7 @@ class GetbibleModelPrompts extends ListModel { $query->where('a.access = ' . (int) $_access); } - elseif (GetbibleHelper::checkArray($_access)) + elseif (UtilitiesArrayHelper::check($_access)) { // Secure the array for the query $_access = ArrayHelper::toInteger($_access); @@ -335,7 +338,7 @@ class GetbibleModelPrompts extends ListModel $query->where('a.name = ' . (int) $_name); } } - elseif (GetbibleHelper::checkString($_name)) + elseif (StringHelper::check($_name)) { $query->where('a.name = ' . $db->quote($db->escape($_name))); } @@ -352,7 +355,7 @@ class GetbibleModelPrompts extends ListModel $query->where('a.cache_behaviour = ' . (int) $_cache_behaviour); } } - elseif (GetbibleHelper::checkString($_cache_behaviour)) + elseif (StringHelper::check($_cache_behaviour)) { $query->where('a.cache_behaviour = ' . $db->quote($db->escape($_cache_behaviour))); } @@ -369,7 +372,7 @@ class GetbibleModelPrompts extends ListModel $query->where('a.abbreviation = ' . (int) $_abbreviation); } } - elseif (GetbibleHelper::checkString($_abbreviation)) + elseif (StringHelper::check($_abbreviation)) { $query->where('a.abbreviation = ' . $db->quote($db->escape($_abbreviation))); } @@ -386,16 +389,18 @@ class GetbibleModelPrompts extends ListModel $query->where('a.model = ' . (int) $_model); } } - elseif (GetbibleHelper::checkString($_model)) + elseif (StringHelper::check($_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'); + $orderCol = $this->getState('list.ordering', 'a.id'); + $orderDirn = $this->getState('list.direction', 'desc'); if ($orderCol != '') { + // Check that the order direction is valid encase we have a field called direction as part of filers. + $orderDirn = (is_string($orderDirn) && in_array(strtolower($orderDirn), ['asc', 'desc'])) ? $orderDirn : 'desc'; $query->order($db->escape($orderCol . ' ' . $orderDirn)); } @@ -441,19 +446,18 @@ class GetbibleModelPrompts extends ListModel /** * Build an SQL query to checkin all items left checked out longer then a set time. * - * @return a bool - * + * @return bool + * @since 3.2.0 */ - protected function checkInNow() + protected function checkInNow(): bool { // Get set check in time $time = ComponentHelper::getParams('com_getbible')->get('check_in'); if ($time) { - // Get a db connection. - $db = Factory::getDbo(); + $db = $this->getDatabase(); // Reset query. $query = $db->getQuery(true); $query->select('*'); @@ -486,7 +490,7 @@ class GetbibleModelPrompts extends ListModel $db->setQuery($query); - $db->execute(); + return $db->execute(); } } diff --git a/admin/models/tag.php b/admin/src/Model/TagModel.php similarity index 91% rename from admin/models/tag.php rename to admin/src/Model/TagModel.php index 8c1c873..1204fe5 100644 --- a/admin/models/tag.php +++ b/admin/src/Model/TagModel.php @@ -14,29 +14,37 @@ @license GNU/GPL Version 2 or later - http://www.gnu.org/licenses/gpl-2.0.html /------------------------------------------------------------------------------------------------------*/ +namespace TrueChristianChurch\Component\Getbible\Administrator\Model; // No direct access to this file -defined('_JEXEC') or die('Restricted access'); +\defined('_JEXEC') or die; use Joomla\CMS\Factory; use Joomla\CMS\Language\Text; +use Joomla\CMS\Form\Form; use Joomla\CMS\Filter\InputFilter; +use Joomla\CMS\Filter\OutputFilter; use Joomla\CMS\MVC\Model\AdminModel; use Joomla\CMS\Table\Table; use Joomla\CMS\UCM\UCMType; -use Joomla\Filter\OutputFilter; +use Joomla\CMS\Versioning\VersionableModelTrait; use Joomla\Registry\Registry; use Joomla\String\StringHelper; use Joomla\Utilities\ArrayHelper; +use Joomla\CMS\Helper\TagsHelper; +use TrueChristianChurch\Component\Getbible\Administrator\Helper\GetbibleHelper; use VDM\Joomla\Utilities\GuidHelper; -use VDM\Joomla\Utilities\GetHelper; +use VDM\Joomla\Utilities\StringHelper as UtilitiesStringHelper; use VDM\Joomla\Utilities\ArrayHelper as UtilitiesArrayHelper; +use VDM\Joomla\Utilities\GetHelper; /** * Getbible Tag Admin Model */ -class GetbibleModelTag extends AdminModel +class TagModel extends AdminModel { + use VersionableModelTrait; + /** * The tab layout fields array. * @@ -80,14 +88,13 @@ class GetbibleModelTag extends AdminModel * * @return Table A database object * - * @since 1.6 + * @since 3.0 + * @throws \Exception */ - public function getTable($type = 'tag', $prefix = 'GetbibleTable', $config = []) + public function getTable($type = 'tag', $prefix = 'Administrator', $config = []) { - // 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 Table::getInstance($type, $prefix, $config); + return parent::getTable($type, $prefix, $config); } /** @@ -130,11 +137,11 @@ class GetbibleModelTag extends AdminModel * @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 + * @return Form|boolean A Form object on success, false on failure * * @since 1.6 */ - public function getForm($data = [], $loadData = true, $options = array('control' => 'jform')) + public function getForm($data = [], $loadData = true, $options = ['control' => 'jform']) { // set load data option $options['load_data'] = $loadData; @@ -174,7 +181,7 @@ class GetbibleModelTag extends AdminModel $id = $jinput->get('id', 0, 'INT'); } - $user = Factory::getUser(); + $user = Factory::getApplication()->getIdentity(); // Check for existing item. // Modify the form based on Edit State access controls. @@ -321,7 +328,7 @@ class GetbibleModelTag extends AdminModel /** * Method to get the script that have to be included on the form * - * @return string script files + * @return string script files */ public function getScript() { @@ -339,18 +346,13 @@ class GetbibleModelTag extends AdminModel */ protected function canDelete($record) { - if (!empty($record->id)) + if (empty($record->id) || ($record->state != -2)) { - if ($record->published != -2) - { - return; - } - - $user = Factory::getUser(); - // The record has been set. Check the record permissions. - return $user->authorise('tag.delete', 'com_getbible.tag.' . (int) $record->id); + return false; } - return false; + + // The record has been set. Check the record permissions. + return $this->getCurrentUser()->authorise('tag.delete', 'com_getbible.tag.' . (int) $record->id); } /** @@ -364,8 +366,8 @@ class GetbibleModelTag extends AdminModel */ protected function canEditState($record) { - $user = Factory::getUser(); - $recordId = (!empty($record->id)) ? $record->id : 0; + $user = $this->getCurrentUser(); + $recordId = $record->id ?? 0; if ($recordId) { @@ -383,16 +385,16 @@ class GetbibleModelTag extends AdminModel /** * 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. + * @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 + * @return boolean + * @since 2.5 */ protected function allowEdit($data = [], $key = 'id') { // Check specific edit permission then general edit permission. - $user = Factory::getUser(); + $user = Factory::getApplication()->getIdentity(); return $user->authorise('tag.edit', 'com_getbible.tag.'. ((int) isset($data[$key]) ? $data[$key] : 0)) or $user->authorise('tag.edit', 'com_getbible'); } @@ -409,11 +411,11 @@ class GetbibleModelTag extends AdminModel protected function prepareTable($table) { $date = Factory::getDate(); - $user = Factory::getUser(); + $user = $this->getCurrentUser(); if (isset($table->name)) { - $table->name = htmlspecialchars_decode($table->name, ENT_QUOTES); + $table->name = \htmlspecialchars_decode($table->name, ENT_QUOTES); } if (isset($table->alias) && empty($table->alias)) @@ -432,7 +434,7 @@ class GetbibleModelTag extends AdminModel // Set ordering to the last item if not set if (empty($table->ordering)) { - $db = Factory::getDbo(); + $db = $this->getDatabase(); $query = $db->getQuery(true) ->select('MAX(ordering)') ->from($db->quoteName('#__getbible_tag')); @@ -462,7 +464,7 @@ class GetbibleModelTag extends AdminModel * * @since 1.6 */ - protected function loadFormData() + protected function loadFormData() { // Check the session for previously entered form data. $data = Factory::getApplication()->getUserState('com_getbible.edit.tag.data', []); @@ -470,10 +472,11 @@ class GetbibleModelTag extends AdminModel if (empty($data)) { $data = $this->getItem(); - // run the perprocess of the data - $this->preprocessData('com_getbible.tag', $data); } + // run the perprocess of the data + $this->preprocessData('com_getbible.tag', $data); + return $data; } @@ -560,7 +563,7 @@ class GetbibleModelTag extends AdminModel $done = false; // Set some needed variables. - $this->user = Factory::getUser(); + $this->user = $this->getCurrentUser(); $this->table = $this->getTable(); $this->tableClassName = get_class($this->table); $this->contentType = new UCMType; @@ -639,7 +642,7 @@ class GetbibleModelTag extends AdminModel if (empty($this->batchSet)) { // Set some needed variables. - $this->user = Factory::getUser(); + $this->user = Factory::getApplication()->getIdentity(); $this->table = $this->getTable(); $this->tableClassName = get_class($this->table); $this->canDo = GetbibleHelper::getActions('tag'); @@ -665,7 +668,7 @@ class GetbibleModelTag extends AdminModel $values['published'] = 0; } - $newIds = array(); + $newIds = []; // Parent exists so let's proceed while (!empty($pks)) { @@ -700,13 +703,13 @@ class GetbibleModelTag extends AdminModel } // Only for strings - if (GetbibleHelper::checkString($this->table->name) && !is_numeric($this->table->name)) + if (UtilitiesStringHelper::check($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)) + if (UtilitiesArrayHelper::check($values)) { foreach ($values as $key => $value) { @@ -718,7 +721,7 @@ class GetbibleModelTag extends AdminModel } // update all unique fields - if (GetbibleHelper::checkArray($uniqueFields)) + if (UtilitiesArrayHelper::check($uniqueFields)) { foreach ($uniqueFields as $uniqueField) { @@ -782,7 +785,7 @@ class GetbibleModelTag extends AdminModel if (empty($this->batchSet)) { // Set some needed variables. - $this->user = Factory::getUser(); + $this->user = Factory::getApplication()->getIdentity(); $this->table = $this->getTable(); $this->tableClassName = get_class($this->table); $this->canDo = GetbibleHelper::getActions('tag'); @@ -829,7 +832,7 @@ class GetbibleModelTag extends AdminModel } // insert all set values. - if (GetbibleHelper::checkArray($values)) + if (UtilitiesArrayHelper::check($values)) { foreach ($values as $key => $value) { @@ -885,14 +888,14 @@ class GetbibleModelTag extends AdminModel */ public function save($data) { - $input = Factory::getApplication()->input; - $filter = InputFilter::getInstance(); + $input = Factory::getApplication()->input; + $filter = InputFilter::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 Registry; $metadata->loadArray($data['metadata']); $data['metadata'] = (string) $metadata; @@ -952,12 +955,12 @@ class GetbibleModelTag extends AdminModel * * @since 3.0 */ - protected function generateUnique($field,$value) + protected function generateUnique($field, $value) { // set field value unique $table = $this->getTable(); - while ($table->load(array($field => $value))) + while ($table->load([$field => $value])) { $value = StringHelper::increment($value); } @@ -979,7 +982,7 @@ class GetbibleModelTag extends AdminModel // Alter the title $table = $this->getTable(); - while ($table->load(array('title' => $title))) + while ($table->load(['title' => $title])) { $title = StringHelper::increment($title); } diff --git a/admin/models/tagged_verse.php b/admin/src/Model/Tagged_verseModel.php similarity index 92% rename from admin/models/tagged_verse.php rename to admin/src/Model/Tagged_verseModel.php index d894fa0..edc6238 100644 --- a/admin/models/tagged_verse.php +++ b/admin/src/Model/Tagged_verseModel.php @@ -14,29 +14,36 @@ @license GNU/GPL Version 2 or later - http://www.gnu.org/licenses/gpl-2.0.html /------------------------------------------------------------------------------------------------------*/ +namespace TrueChristianChurch\Component\Getbible\Administrator\Model; // No direct access to this file -defined('_JEXEC') or die('Restricted access'); +\defined('_JEXEC') or die; use Joomla\CMS\Factory; use Joomla\CMS\Language\Text; +use Joomla\CMS\Form\Form; use Joomla\CMS\Filter\InputFilter; +use Joomla\CMS\Filter\OutputFilter; use Joomla\CMS\MVC\Model\AdminModel; use Joomla\CMS\Table\Table; use Joomla\CMS\UCM\UCMType; -use Joomla\Filter\OutputFilter; +use Joomla\CMS\Versioning\VersionableModelTrait; use Joomla\Registry\Registry; use Joomla\String\StringHelper; use Joomla\Utilities\ArrayHelper; +use Joomla\CMS\Helper\TagsHelper; +use TrueChristianChurch\Component\Getbible\Administrator\Helper\GetbibleHelper; use VDM\Joomla\Utilities\GuidHelper; -use VDM\Joomla\Utilities\GetHelper; use VDM\Joomla\Utilities\ArrayHelper as UtilitiesArrayHelper; +use VDM\Joomla\Utilities\GetHelper; /** * Getbible Tagged_verse Admin Model */ -class GetbibleModelTagged_verse extends AdminModel +class Tagged_verseModel extends AdminModel { + use VersionableModelTrait; + /** * The tab layout fields array. * @@ -83,14 +90,13 @@ class GetbibleModelTagged_verse extends AdminModel * * @return Table A database object * - * @since 1.6 + * @since 3.0 + * @throws \Exception */ - public function getTable($type = 'tagged_verse', $prefix = 'GetbibleTable', $config = []) + public function getTable($type = 'tagged_verse', $prefix = 'Administrator', $config = []) { - // 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 Table::getInstance($type, $prefix, $config); + return parent::getTable($type, $prefix, $config); } /** @@ -133,11 +139,11 @@ class GetbibleModelTagged_verse extends AdminModel * @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 + * @return Form|boolean A Form object on success, false on failure * * @since 1.6 */ - public function getForm($data = [], $loadData = true, $options = array('control' => 'jform')) + public function getForm($data = [], $loadData = true, $options = ['control' => 'jform']) { // set load data option $options['load_data'] = $loadData; @@ -177,7 +183,7 @@ class GetbibleModelTagged_verse extends AdminModel $id = $jinput->get('id', 0, 'INT'); } - $user = Factory::getUser(); + $user = Factory::getApplication()->getIdentity(); // Check for existing item. // Modify the form based on Edit State access controls. @@ -375,7 +381,7 @@ class GetbibleModelTagged_verse extends AdminModel /** * Method to get the script that have to be included on the form * - * @return string script files + * @return string script files */ public function getScript() { @@ -393,18 +399,13 @@ class GetbibleModelTagged_verse extends AdminModel */ protected function canDelete($record) { - if (!empty($record->id)) + if (empty($record->id) || ($record->state != -2)) { - if ($record->published != -2) - { - return; - } - - $user = Factory::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; } - return false; + + // The record has been set. Check the record permissions. + return $this->getCurrentUser()->authorise('tagged_verse.delete', 'com_getbible.tagged_verse.' . (int) $record->id); } /** @@ -418,8 +419,8 @@ class GetbibleModelTagged_verse extends AdminModel */ protected function canEditState($record) { - $user = Factory::getUser(); - $recordId = (!empty($record->id)) ? $record->id : 0; + $user = $this->getCurrentUser(); + $recordId = $record->id ?? 0; if ($recordId) { @@ -437,16 +438,16 @@ class GetbibleModelTagged_verse extends AdminModel /** * 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. + * @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 + * @return boolean + * @since 2.5 */ protected function allowEdit($data = [], $key = 'id') { // Check specific edit permission then general edit permission. - $user = Factory::getUser(); + $user = Factory::getApplication()->getIdentity(); 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'); } @@ -463,11 +464,11 @@ class GetbibleModelTagged_verse extends AdminModel protected function prepareTable($table) { $date = Factory::getDate(); - $user = Factory::getUser(); + $user = $this->getCurrentUser(); if (isset($table->name)) { - $table->name = htmlspecialchars_decode($table->name, ENT_QUOTES); + $table->name = \htmlspecialchars_decode($table->name, ENT_QUOTES); } if (isset($table->alias) && empty($table->alias)) @@ -486,7 +487,7 @@ class GetbibleModelTagged_verse extends AdminModel // Set ordering to the last item if not set if (empty($table->ordering)) { - $db = Factory::getDbo(); + $db = $this->getDatabase(); $query = $db->getQuery(true) ->select('MAX(ordering)') ->from($db->quoteName('#__getbible_tagged_verse')); @@ -516,7 +517,7 @@ class GetbibleModelTagged_verse extends AdminModel * * @since 1.6 */ - protected function loadFormData() + protected function loadFormData() { // Check the session for previously entered form data. $data = Factory::getApplication()->getUserState('com_getbible.edit.tagged_verse.data', []); @@ -524,10 +525,11 @@ class GetbibleModelTagged_verse extends AdminModel if (empty($data)) { $data = $this->getItem(); - // run the perprocess of the data - $this->preprocessData('com_getbible.tagged_verse', $data); } + // run the perprocess of the data + $this->preprocessData('com_getbible.tagged_verse', $data); + return $data; } @@ -614,7 +616,7 @@ class GetbibleModelTagged_verse extends AdminModel $done = false; // Set some needed variables. - $this->user = Factory::getUser(); + $this->user = $this->getCurrentUser(); $this->table = $this->getTable(); $this->tableClassName = get_class($this->table); $this->contentType = new UCMType; @@ -693,7 +695,7 @@ class GetbibleModelTagged_verse extends AdminModel if (empty($this->batchSet)) { // Set some needed variables. - $this->user = Factory::getUser(); + $this->user = Factory::getApplication()->getIdentity(); $this->table = $this->getTable(); $this->tableClassName = get_class($this->table); $this->canDo = GetbibleHelper::getActions('tagged_verse'); @@ -719,7 +721,7 @@ class GetbibleModelTagged_verse extends AdminModel $values['published'] = 0; } - $newIds = array(); + $newIds = []; // Parent exists so let's proceed while (!empty($pks)) { @@ -754,7 +756,7 @@ class GetbibleModelTagged_verse extends AdminModel } // insert all set values - if (GetbibleHelper::checkArray($values)) + if (UtilitiesArrayHelper::check($values)) { foreach ($values as $key => $value) { @@ -766,7 +768,7 @@ class GetbibleModelTagged_verse extends AdminModel } // update all unique fields - if (GetbibleHelper::checkArray($uniqueFields)) + if (UtilitiesArrayHelper::check($uniqueFields)) { foreach ($uniqueFields as $uniqueField) { @@ -830,7 +832,7 @@ class GetbibleModelTagged_verse extends AdminModel if (empty($this->batchSet)) { // Set some needed variables. - $this->user = Factory::getUser(); + $this->user = Factory::getApplication()->getIdentity(); $this->table = $this->getTable(); $this->tableClassName = get_class($this->table); $this->canDo = GetbibleHelper::getActions('tagged_verse'); @@ -877,7 +879,7 @@ class GetbibleModelTagged_verse extends AdminModel } // insert all set values. - if (GetbibleHelper::checkArray($values)) + if (UtilitiesArrayHelper::check($values)) { foreach ($values as $key => $value) { @@ -933,14 +935,14 @@ class GetbibleModelTagged_verse extends AdminModel */ public function save($data) { - $input = Factory::getApplication()->input; - $filter = InputFilter::getInstance(); + $input = Factory::getApplication()->input; + $filter = InputFilter::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 Registry; $metadata->loadArray($data['metadata']); $data['metadata'] = (string) $metadata; @@ -1000,12 +1002,12 @@ class GetbibleModelTagged_verse extends AdminModel * * @since 3.0 */ - protected function generateUnique($field,$value) + protected function generateUnique($field, $value) { // set field value unique $table = $this->getTable(); - while ($table->load(array($field => $value))) + while ($table->load([$field => $value])) { $value = StringHelper::increment($value); } diff --git a/admin/models/tagged_verses.php b/admin/src/Model/Tagged_versesModel.php similarity index 91% rename from admin/models/tagged_verses.php rename to admin/src/Model/Tagged_versesModel.php index 6d56c7b..8f99dd4 100644 --- a/admin/models/tagged_verses.php +++ b/admin/src/Model/Tagged_versesModel.php @@ -14,9 +14,10 @@ @license GNU/GPL Version 2 or later - http://www.gnu.org/licenses/gpl-2.0.html /------------------------------------------------------------------------------------------------------*/ +namespace TrueChristianChurch\Component\Getbible\Administrator\Model; // No direct access to this file -defined('_JEXEC') or die('Restricted access'); +\defined('_JEXEC') or die; use Joomla\CMS\Factory; use Joomla\CMS\Language\Text; @@ -24,6 +25,8 @@ use Joomla\CMS\Component\ComponentHelper; use Joomla\CMS\MVC\Model\ListModel; use Joomla\CMS\Plugin\PluginHelper; use Joomla\Utilities\ArrayHelper; +use Joomla\CMS\Helper\TagsHelper; +use TrueChristianChurch\Component\Getbible\Administrator\Helper\GetbibleHelper; use VDM\Joomla\Utilities\ArrayHelper as UtilitiesArrayHelper; use VDM\Joomla\Utilities\ObjectHelper; use VDM\Joomla\Utilities\StringHelper; @@ -31,12 +34,12 @@ use VDM\Joomla\Utilities\StringHelper; /** * Tagged_verses List Model */ -class GetbibleModelTagged_verses extends ListModel +class Tagged_versesModel extends ListModel { public function __construct($config = []) { if (empty($config['filter_fields'])) - { + { $config['filter_fields'] = array( 'a.id','id', 'a.published','published', @@ -167,7 +170,7 @@ class GetbibleModelTagged_verses extends ListModel // Get the user object if not set. if (!isset($user) || !ObjectHelper::check($user)) { - $user = Factory::getUser(); + $user = $this->getCurrentUser(); } foreach ($items as $nr => &$item) { @@ -201,7 +204,7 @@ class GetbibleModelTagged_verses extends ListModel /** * Method to convert selection values to translatable string. * - * @return translatable string + * @return string The translatable string. */ public function selectionTranslation($value,$name) { @@ -224,14 +227,14 @@ class GetbibleModelTagged_verses extends ListModel /** * Method to build an SQL query to load the list data. * - * @return string An SQL query + * @return string An SQL query */ protected function getListQuery() { // Get the user object. - $user = Factory::getUser(); + $user = $this->getCurrentUser(); // Create a new query object. - $db = Factory::getDBO(); + $db = $this->getDatabase(); $query = $db->getQuery(true); // Select some fields @@ -300,11 +303,11 @@ class GetbibleModelTagged_verses extends ListModel $query->where('a.book_nr = ' . (int) $_book_nr); } } - elseif (GetbibleHelper::checkString($_book_nr)) + elseif (StringHelper::check($_book_nr)) { $query->where('a.book_nr = ' . $db->quote($db->escape($_book_nr))); } - elseif (GetbibleHelper::checkArray($_book_nr)) + elseif (UtilitiesArrayHelper::check($_book_nr)) { // Secure the array for the query $_book_nr = array_map( function ($val) use(&$db) { @@ -319,7 +322,7 @@ class GetbibleModelTagged_verses extends ListModel return (int) $val; } } - elseif (GetbibleHelper::checkString($val)) + elseif (StringHelper::check($val)) { return $db->quote($db->escape($val)); } @@ -340,11 +343,11 @@ class GetbibleModelTagged_verses extends ListModel $query->where('a.abbreviation = ' . (int) $_abbreviation); } } - elseif (GetbibleHelper::checkString($_abbreviation)) + elseif (StringHelper::check($_abbreviation)) { $query->where('a.abbreviation = ' . $db->quote($db->escape($_abbreviation))); } - elseif (GetbibleHelper::checkArray($_abbreviation)) + elseif (UtilitiesArrayHelper::check($_abbreviation)) { // Secure the array for the query $_abbreviation = array_map( function ($val) use(&$db) { @@ -359,7 +362,7 @@ class GetbibleModelTagged_verses extends ListModel return (int) $val; } } - elseif (GetbibleHelper::checkString($val)) + elseif (StringHelper::check($val)) { return $db->quote($db->escape($val)); } @@ -380,7 +383,7 @@ class GetbibleModelTagged_verses extends ListModel $query->where('a.access = ' . (int) $_access); } } - elseif (GetbibleHelper::checkString($_access)) + elseif (StringHelper::check($_access)) { $query->where('a.access = ' . $db->quote($db->escape($_access))); } @@ -397,7 +400,7 @@ class GetbibleModelTagged_verses extends ListModel $query->where('a.linker = ' . (int) $_linker); } } - elseif (GetbibleHelper::checkString($_linker)) + elseif (StringHelper::check($_linker)) { $query->where('a.linker = ' . $db->quote($db->escape($_linker))); } @@ -414,7 +417,7 @@ class GetbibleModelTagged_verses extends ListModel $query->where('a.tag = ' . (int) $_tag); } } - elseif (GetbibleHelper::checkString($_tag)) + elseif (StringHelper::check($_tag)) { $query->where('a.tag = ' . $db->quote($db->escape($_tag))); } @@ -431,11 +434,11 @@ class GetbibleModelTagged_verses extends ListModel $query->where('a.verse = ' . (int) $_verse); } } - elseif (GetbibleHelper::checkString($_verse)) + elseif (StringHelper::check($_verse)) { $query->where('a.verse = ' . $db->quote($db->escape($_verse))); } - elseif (GetbibleHelper::checkArray($_verse)) + elseif (UtilitiesArrayHelper::check($_verse)) { // Secure the array for the query $_verse = array_map( function ($val) use(&$db) { @@ -450,7 +453,7 @@ class GetbibleModelTagged_verses extends ListModel return (int) $val; } } - elseif (GetbibleHelper::checkString($val)) + elseif (StringHelper::check($val)) { return $db->quote($db->escape($val)); } @@ -471,11 +474,11 @@ class GetbibleModelTagged_verses extends ListModel $query->where('a.chapter = ' . (int) $_chapter); } } - elseif (GetbibleHelper::checkString($_chapter)) + elseif (StringHelper::check($_chapter)) { $query->where('a.chapter = ' . $db->quote($db->escape($_chapter))); } - elseif (GetbibleHelper::checkArray($_chapter)) + elseif (UtilitiesArrayHelper::check($_chapter)) { // Secure the array for the query $_chapter = array_map( function ($val) use(&$db) { @@ -490,7 +493,7 @@ class GetbibleModelTagged_verses extends ListModel return (int) $val; } } - elseif (GetbibleHelper::checkString($val)) + elseif (StringHelper::check($val)) { return $db->quote($db->escape($val)); } @@ -500,10 +503,12 @@ class GetbibleModelTagged_verses extends ListModel } // Add the list ordering clause. - $orderCol = $this->state->get('list.ordering', 'a.id'); - $orderDirn = $this->state->get('list.direction', 'desc'); + $orderCol = $this->getState('list.ordering', 'a.id'); + $orderDirn = $this->getState('list.direction', 'desc'); if ($orderCol != '') { + // Check that the order direction is valid encase we have a field called direction as part of filers. + $orderDirn = (is_string($orderDirn) && in_array(strtolower($orderDirn), ['asc', 'desc'])) ? $orderDirn : 'desc'; $query->order($db->escape($orderCol . ' ' . $orderDirn)); } @@ -582,19 +587,18 @@ class GetbibleModelTagged_verses extends ListModel /** * Build an SQL query to checkin all items left checked out longer then a set time. * - * @return a bool - * + * @return bool + * @since 3.2.0 */ - protected function checkInNow() + protected function checkInNow(): bool { // Get set check in time $time = ComponentHelper::getParams('com_getbible')->get('check_in'); if ($time) { - // Get a db connection. - $db = Factory::getDbo(); + $db = $this->getDatabase(); // Reset query. $query = $db->getQuery(true); $query->select('*'); @@ -627,7 +631,7 @@ class GetbibleModelTagged_verses extends ListModel $db->setQuery($query); - $db->execute(); + return $db->execute(); } } diff --git a/admin/models/tags.php b/admin/src/Model/TagsModel.php similarity index 90% rename from admin/models/tags.php rename to admin/src/Model/TagsModel.php index bacd9ac..e4d799a 100644 --- a/admin/models/tags.php +++ b/admin/src/Model/TagsModel.php @@ -14,9 +14,10 @@ @license GNU/GPL Version 2 or later - http://www.gnu.org/licenses/gpl-2.0.html /------------------------------------------------------------------------------------------------------*/ +namespace TrueChristianChurch\Component\Getbible\Administrator\Model; // No direct access to this file -defined('_JEXEC') or die('Restricted access'); +\defined('_JEXEC') or die; use Joomla\CMS\Factory; use Joomla\CMS\Language\Text; @@ -24,6 +25,8 @@ use Joomla\CMS\Component\ComponentHelper; use Joomla\CMS\MVC\Model\ListModel; use Joomla\CMS\Plugin\PluginHelper; use Joomla\Utilities\ArrayHelper; +use Joomla\CMS\Helper\TagsHelper; +use TrueChristianChurch\Component\Getbible\Administrator\Helper\GetbibleHelper; use VDM\Joomla\Utilities\ArrayHelper as UtilitiesArrayHelper; use VDM\Joomla\Utilities\ObjectHelper; use VDM\Joomla\Utilities\StringHelper; @@ -31,12 +34,12 @@ use VDM\Joomla\Utilities\StringHelper; /** * Tags List Model */ -class GetbibleModelTags extends ListModel +class TagsModel extends ListModel { public function __construct($config = []) { if (empty($config['filter_fields'])) - { + { $config['filter_fields'] = array( 'a.id','id', 'a.published','published', @@ -135,7 +138,7 @@ class GetbibleModelTags extends ListModel // Get the user object if not set. if (!isset($user) || !ObjectHelper::check($user)) { - $user = Factory::getUser(); + $user = $this->getCurrentUser(); } foreach ($items as $nr => &$item) { @@ -168,7 +171,7 @@ class GetbibleModelTags extends ListModel /** * Method to convert selection values to translatable string. * - * @return translatable string + * @return string The translatable string. */ public function selectionTranslation($value,$name) { @@ -191,14 +194,14 @@ class GetbibleModelTags extends ListModel /** * Method to build an SQL query to load the list data. * - * @return string An SQL query + * @return string An SQL query */ protected function getListQuery() { // Get the user object. - $user = Factory::getUser(); + $user = $this->getCurrentUser(); // Create a new query object. - $db = Factory::getDBO(); + $db = $this->getDatabase(); $query = $db->getQuery(true); // Select some fields @@ -259,7 +262,7 @@ class GetbibleModelTags extends ListModel $query->where('a.linker = ' . (int) $_linker); } } - elseif (GetbibleHelper::checkString($_linker)) + elseif (StringHelper::check($_linker)) { $query->where('a.linker = ' . $db->quote($db->escape($_linker))); } @@ -276,16 +279,18 @@ class GetbibleModelTags extends ListModel $query->where('a.access = ' . (int) $_access); } } - elseif (GetbibleHelper::checkString($_access)) + elseif (StringHelper::check($_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'); + $orderCol = $this->getState('list.ordering', 'a.id'); + $orderDirn = $this->getState('list.direction', 'desc'); if ($orderCol != '') { + // Check that the order direction is valid encase we have a field called direction as part of filers. + $orderDirn = (is_string($orderDirn) && in_array(strtolower($orderDirn), ['asc', 'desc'])) ? $orderDirn : 'desc'; $query->order($db->escape($orderCol . ' ' . $orderDirn)); } @@ -316,19 +321,18 @@ class GetbibleModelTags extends ListModel /** * Build an SQL query to checkin all items left checked out longer then a set time. * - * @return a bool - * + * @return bool + * @since 3.2.0 */ - protected function checkInNow() + protected function checkInNow(): bool { // Get set check in time $time = ComponentHelper::getParams('com_getbible')->get('check_in'); if ($time) { - // Get a db connection. - $db = Factory::getDbo(); + $db = $this->getDatabase(); // Reset query. $query = $db->getQuery(true); $query->select('*'); @@ -361,7 +365,7 @@ class GetbibleModelTags extends ListModel $db->setQuery($query); - $db->execute(); + return $db->execute(); } } diff --git a/admin/models/translation.php b/admin/src/Model/TranslationModel.php similarity index 93% rename from admin/models/translation.php rename to admin/src/Model/TranslationModel.php index cfa245f..e8c225d 100644 --- a/admin/models/translation.php +++ b/admin/src/Model/TranslationModel.php @@ -14,27 +14,35 @@ @license GNU/GPL Version 2 or later - http://www.gnu.org/licenses/gpl-2.0.html /------------------------------------------------------------------------------------------------------*/ +namespace TrueChristianChurch\Component\Getbible\Administrator\Model; // No direct access to this file -defined('_JEXEC') or die('Restricted access'); +\defined('_JEXEC') or die; use Joomla\CMS\Factory; use Joomla\CMS\Language\Text; +use Joomla\CMS\Form\Form; use Joomla\CMS\Filter\InputFilter; +use Joomla\CMS\Filter\OutputFilter; use Joomla\CMS\MVC\Model\AdminModel; use Joomla\CMS\Table\Table; use Joomla\CMS\UCM\UCMType; -use Joomla\Filter\OutputFilter; +use Joomla\CMS\Versioning\VersionableModelTrait; use Joomla\Registry\Registry; use Joomla\String\StringHelper; use Joomla\Utilities\ArrayHelper; +use Joomla\CMS\Helper\TagsHelper; +use TrueChristianChurch\Component\Getbible\Administrator\Helper\GetbibleHelper; +use VDM\Joomla\Utilities\StringHelper as UtilitiesStringHelper; use VDM\Joomla\Utilities\ArrayHelper as UtilitiesArrayHelper; /** * Getbible Translation Admin Model */ -class GetbibleModelTranslation extends AdminModel +class TranslationModel extends AdminModel { + use VersionableModelTrait; + /** * The tab layout fields array. * @@ -93,14 +101,13 @@ class GetbibleModelTranslation extends AdminModel * * @return Table A database object * - * @since 1.6 + * @since 3.0 + * @throws \Exception */ - public function getTable($type = 'translation', $prefix = 'GetbibleTable', $config = []) + public function getTable($type = 'translation', $prefix = 'Administrator', $config = []) { - // 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 Table::getInstance($type, $prefix, $config); + return parent::getTable($type, $prefix, $config); }###ADMIN_CUSTOM_BUTTONS_METHOD### /** @@ -151,11 +158,11 @@ class GetbibleModelTranslation extends AdminModel * @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 + * @return Form|boolean A Form object on success, false on failure * * @since 1.6 */ - public function getForm($data = [], $loadData = true, $options = array('control' => 'jform')) + public function getForm($data = [], $loadData = true, $options = ['control' => 'jform']) { // set load data option $options['load_data'] = $loadData; @@ -195,7 +202,7 @@ class GetbibleModelTranslation extends AdminModel $id = $jinput->get('id', 0, 'INT'); } - $user = Factory::getUser(); + $user = Factory::getApplication()->getIdentity(); // Check for existing item. // Modify the form based on Edit State access controls. @@ -550,7 +557,7 @@ class GetbibleModelTranslation extends AdminModel /** * Method to get the script that have to be included on the form * - * @return string script files + * @return string script files */ public function getScript() { @@ -568,18 +575,13 @@ class GetbibleModelTranslation extends AdminModel */ protected function canDelete($record) { - if (!empty($record->id)) + if (empty($record->id) || ($record->state != -2)) { - if ($record->published != -2) - { - return; - } - - $user = Factory::getUser(); - // The record has been set. Check the record permissions. - return $user->authorise('translation.delete', 'com_getbible.translation.' . (int) $record->id); + return false; } - return false; + + // The record has been set. Check the record permissions. + return $this->getCurrentUser()->authorise('translation.delete', 'com_getbible.translation.' . (int) $record->id); } /** @@ -593,8 +595,8 @@ class GetbibleModelTranslation extends AdminModel */ protected function canEditState($record) { - $user = Factory::getUser(); - $recordId = (!empty($record->id)) ? $record->id : 0; + $user = $this->getCurrentUser(); + $recordId = $record->id ?? 0; if ($recordId) { @@ -612,16 +614,16 @@ class GetbibleModelTranslation extends AdminModel /** * 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. + * @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 + * @return boolean + * @since 2.5 */ protected function allowEdit($data = [], $key = 'id') { // Check specific edit permission then general edit permission. - $user = Factory::getUser(); + $user = Factory::getApplication()->getIdentity(); return $user->authorise('translation.edit', 'com_getbible.translation.'. ((int) isset($data[$key]) ? $data[$key] : 0)) or $user->authorise('translation.edit', 'com_getbible'); } @@ -638,11 +640,11 @@ class GetbibleModelTranslation extends AdminModel protected function prepareTable($table) { $date = Factory::getDate(); - $user = Factory::getUser(); + $user = $this->getCurrentUser(); if (isset($table->name)) { - $table->name = htmlspecialchars_decode($table->name, ENT_QUOTES); + $table->name = \htmlspecialchars_decode($table->name, ENT_QUOTES); } if (isset($table->alias) && empty($table->alias)) @@ -661,7 +663,7 @@ class GetbibleModelTranslation extends AdminModel // Set ordering to the last item if not set if (empty($table->ordering)) { - $db = Factory::getDbo(); + $db = $this->getDatabase(); $query = $db->getQuery(true) ->select('MAX(ordering)') ->from($db->quoteName('#__getbible_translation')); @@ -691,7 +693,7 @@ class GetbibleModelTranslation extends AdminModel * * @since 1.6 */ - protected function loadFormData() + protected function loadFormData() { // Check the session for previously entered form data. $data = Factory::getApplication()->getUserState('com_getbible.edit.translation.data', []); @@ -699,10 +701,11 @@ class GetbibleModelTranslation extends AdminModel if (empty($data)) { $data = $this->getItem(); - // run the perprocess of the data - $this->preprocessData('com_getbible.translation', $data); } + // run the perprocess of the data + $this->preprocessData('com_getbible.translation', $data); + return $data; } @@ -789,7 +792,7 @@ class GetbibleModelTranslation extends AdminModel $done = false; // Set some needed variables. - $this->user = Factory::getUser(); + $this->user = $this->getCurrentUser(); $this->table = $this->getTable(); $this->tableClassName = get_class($this->table); $this->contentType = new UCMType; @@ -868,7 +871,7 @@ class GetbibleModelTranslation extends AdminModel if (empty($this->batchSet)) { // Set some needed variables. - $this->user = Factory::getUser(); + $this->user = Factory::getApplication()->getIdentity(); $this->table = $this->getTable(); $this->tableClassName = get_class($this->table); $this->canDo = GetbibleHelper::getActions('translation'); @@ -894,7 +897,7 @@ class GetbibleModelTranslation extends AdminModel $values['published'] = 0; } - $newIds = array(); + $newIds = []; // Parent exists so let's proceed while (!empty($pks)) { @@ -929,13 +932,13 @@ class GetbibleModelTranslation extends AdminModel } // Only for strings - if (GetbibleHelper::checkString($this->table->translation) && !is_numeric($this->table->translation)) + if (UtilitiesStringHelper::check($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)) + if (UtilitiesArrayHelper::check($values)) { foreach ($values as $key => $value) { @@ -947,7 +950,7 @@ class GetbibleModelTranslation extends AdminModel } // update all unique fields - if (GetbibleHelper::checkArray($uniqueFields)) + if (UtilitiesArrayHelper::check($uniqueFields)) { foreach ($uniqueFields as $uniqueField) { @@ -1011,7 +1014,7 @@ class GetbibleModelTranslation extends AdminModel if (empty($this->batchSet)) { // Set some needed variables. - $this->user = Factory::getUser(); + $this->user = Factory::getApplication()->getIdentity(); $this->table = $this->getTable(); $this->tableClassName = get_class($this->table); $this->canDo = GetbibleHelper::getActions('translation'); @@ -1058,7 +1061,7 @@ class GetbibleModelTranslation extends AdminModel } // insert all set values. - if (GetbibleHelper::checkArray($values)) + if (UtilitiesArrayHelper::check($values)) { foreach ($values as $key => $value) { @@ -1114,14 +1117,14 @@ class GetbibleModelTranslation extends AdminModel */ public function save($data) { - $input = Factory::getApplication()->input; - $filter = InputFilter::getInstance(); + $input = Factory::getApplication()->input; + $filter = InputFilter::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 Registry; $metadata->loadArray($data['metadata']); $data['metadata'] = (string) $metadata; @@ -1137,7 +1140,7 @@ class GetbibleModelTranslation extends AdminModel // 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']) - && Factory::getUser()->authorise('translation.edit.distribution_history', 'com_getbible')) + && Factory::getApplication()->getIdentity()->authorise('translation.edit.distribution_history', 'com_getbible')) { // Set the empty distribution_history to data $data['distribution_history'] = ''; @@ -1182,12 +1185,12 @@ class GetbibleModelTranslation extends AdminModel * * @since 3.0 */ - protected function generateUnique($field,$value) + protected function generateUnique($field, $value) { // set field value unique $table = $this->getTable(); - while ($table->load(array($field => $value))) + while ($table->load([$field => $value])) { $value = StringHelper::increment($value); } @@ -1209,7 +1212,7 @@ class GetbibleModelTranslation extends AdminModel // Alter the title $table = $this->getTable(); - while ($table->load(array('title' => $title))) + while ($table->load(['title' => $title])) { $title = StringHelper::increment($title); } diff --git a/admin/models/translations.php b/admin/src/Model/TranslationsModel.php similarity index 91% rename from admin/models/translations.php rename to admin/src/Model/TranslationsModel.php index 5058003..157214e 100644 --- a/admin/models/translations.php +++ b/admin/src/Model/TranslationsModel.php @@ -14,9 +14,10 @@ @license GNU/GPL Version 2 or later - http://www.gnu.org/licenses/gpl-2.0.html /------------------------------------------------------------------------------------------------------*/ +namespace TrueChristianChurch\Component\Getbible\Administrator\Model; // No direct access to this file -defined('_JEXEC') or die('Restricted access'); +\defined('_JEXEC') or die; use Joomla\CMS\Factory; use Joomla\CMS\Language\Text; @@ -24,6 +25,8 @@ use Joomla\CMS\Component\ComponentHelper; use Joomla\CMS\MVC\Model\ListModel; use Joomla\CMS\Plugin\PluginHelper; use Joomla\Utilities\ArrayHelper; +use Joomla\CMS\Helper\TagsHelper; +use TrueChristianChurch\Component\Getbible\Administrator\Helper\GetbibleHelper; use VDM\Joomla\Utilities\ArrayHelper as UtilitiesArrayHelper; use VDM\Joomla\Utilities\ObjectHelper; use VDM\Joomla\Utilities\StringHelper; @@ -31,12 +34,12 @@ use VDM\Joomla\Utilities\StringHelper; /** * Translations List Model */ -class GetbibleModelTranslations extends ListModel +class TranslationsModel extends ListModel { public function __construct($config = []) { if (empty($config['filter_fields'])) - { + { $config['filter_fields'] = array( 'a.id','id', 'a.published','published', @@ -151,7 +154,7 @@ class GetbibleModelTranslations extends ListModel // Get the user object if not set. if (!isset($user) || !ObjectHelper::check($user)) { - $user = Factory::getUser(); + $user = $this->getCurrentUser(); } foreach ($items as $nr => &$item) { @@ -184,7 +187,7 @@ class GetbibleModelTranslations extends ListModel /** * Method to convert selection values to translatable string. * - * @return translatable string + * @return string The translatable string. */ public function selectionTranslation($value,$name) { @@ -207,14 +210,14 @@ class GetbibleModelTranslations extends ListModel /** * Method to build an SQL query to load the list data. * - * @return string An SQL query + * @return string An SQL query */ protected function getListQuery() { // Get the user object. - $user = Factory::getUser(); + $user = $this->getCurrentUser(); // Create a new query object. - $db = Factory::getDBO(); + $db = $this->getDatabase(); $query = $db->getQuery(true); // Select some fields @@ -243,7 +246,7 @@ class GetbibleModelTranslations extends ListModel { $query->where('a.access = ' . (int) $_access); } - elseif (GetbibleHelper::checkArray($_access)) + elseif (UtilitiesArrayHelper::check($_access)) { // Secure the array for the query $_access = ArrayHelper::toInteger($_access); @@ -284,16 +287,18 @@ class GetbibleModelTranslations extends ListModel $query->where('a.direction = ' . (int) $_direction); } } - elseif (GetbibleHelper::checkString($_direction)) + elseif (StringHelper::check($_direction)) { $query->where('a.direction = ' . $db->quote($db->escape($_direction))); } // Add the list ordering clause. - $orderCol = $this->state->get('list.ordering', 'a.language'); - $orderDirn = $this->state->get('list.direction', 'asc'); + $orderCol = $this->getState('list.ordering', 'a.language'); + $orderDirn = $this->getState('list.direction', 'asc'); if ($orderCol != '') { + // Check that the order direction is valid encase we have a field called direction as part of filers. + $orderDirn = (is_string($orderDirn) && in_array(strtolower($orderDirn), ['asc', 'desc'])) ? $orderDirn : 'asc'; $query->order($db->escape($orderCol . ' ' . $orderDirn)); } @@ -341,19 +346,18 @@ class GetbibleModelTranslations extends ListModel /** * Build an SQL query to checkin all items left checked out longer then a set time. * - * @return a bool - * + * @return bool + * @since 3.2.0 */ - protected function checkInNow() + protected function checkInNow(): bool { // Get set check in time $time = ComponentHelper::getParams('com_getbible')->get('check_in'); if ($time) { - // Get a db connection. - $db = Factory::getDbo(); + $db = $this->getDatabase(); // Reset query. $query = $db->getQuery(true); $query->select('*'); @@ -386,7 +390,7 @@ class GetbibleModelTranslations extends ListModel $db->setQuery($query); - $db->execute(); + return $db->execute(); } } diff --git a/admin/models/verse.php b/admin/src/Model/VerseModel.php similarity index 91% rename from admin/models/verse.php rename to admin/src/Model/VerseModel.php index 16169b7..b812216 100644 --- a/admin/models/verse.php +++ b/admin/src/Model/VerseModel.php @@ -14,27 +14,35 @@ @license GNU/GPL Version 2 or later - http://www.gnu.org/licenses/gpl-2.0.html /------------------------------------------------------------------------------------------------------*/ +namespace TrueChristianChurch\Component\Getbible\Administrator\Model; // No direct access to this file -defined('_JEXEC') or die('Restricted access'); +\defined('_JEXEC') or die; use Joomla\CMS\Factory; use Joomla\CMS\Language\Text; +use Joomla\CMS\Form\Form; use Joomla\CMS\Filter\InputFilter; +use Joomla\CMS\Filter\OutputFilter; use Joomla\CMS\MVC\Model\AdminModel; use Joomla\CMS\Table\Table; use Joomla\CMS\UCM\UCMType; -use Joomla\Filter\OutputFilter; +use Joomla\CMS\Versioning\VersionableModelTrait; use Joomla\Registry\Registry; use Joomla\String\StringHelper; use Joomla\Utilities\ArrayHelper; +use Joomla\CMS\Helper\TagsHelper; +use TrueChristianChurch\Component\Getbible\Administrator\Helper\GetbibleHelper; +use VDM\Joomla\Utilities\StringHelper as UtilitiesStringHelper; use VDM\Joomla\Utilities\ArrayHelper as UtilitiesArrayHelper; /** * Getbible Verse Admin Model */ -class GetbibleModelVerse extends AdminModel +class VerseModel extends AdminModel { + use VersionableModelTrait; + /** * The tab layout fields array. * @@ -82,14 +90,13 @@ class GetbibleModelVerse extends AdminModel * * @return Table A database object * - * @since 1.6 + * @since 3.0 + * @throws \Exception */ - public function getTable($type = 'verse', $prefix = 'GetbibleTable', $config = []) + public function getTable($type = 'verse', $prefix = 'Administrator', $config = []) { - // 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 Table::getInstance($type, $prefix, $config); + return parent::getTable($type, $prefix, $config); }###ADMIN_CUSTOM_BUTTONS_METHOD### /** @@ -132,11 +139,11 @@ class GetbibleModelVerse extends AdminModel * @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 + * @return Form|boolean A Form object on success, false on failure * * @since 1.6 */ - public function getForm($data = [], $loadData = true, $options = array('control' => 'jform')) + public function getForm($data = [], $loadData = true, $options = ['control' => 'jform']) { // set load data option $options['load_data'] = $loadData; @@ -176,7 +183,7 @@ class GetbibleModelVerse extends AdminModel $id = $jinput->get('id', 0, 'INT'); } - $user = Factory::getUser(); + $user = Factory::getApplication()->getIdentity(); // Check for existing item. // Modify the form based on Edit State access controls. @@ -341,7 +348,7 @@ class GetbibleModelVerse extends AdminModel /** * Method to get the script that have to be included on the form * - * @return string script files + * @return string script files */ public function getScript() { @@ -359,18 +366,13 @@ class GetbibleModelVerse extends AdminModel */ protected function canDelete($record) { - if (!empty($record->id)) + if (empty($record->id) || ($record->state != -2)) { - if ($record->published != -2) - { - return; - } - - $user = Factory::getUser(); - // The record has been set. Check the record permissions. - return $user->authorise('verse.delete', 'com_getbible.verse.' . (int) $record->id); + return false; } - return false; + + // The record has been set. Check the record permissions. + return $this->getCurrentUser()->authorise('verse.delete', 'com_getbible.verse.' . (int) $record->id); } /** @@ -384,8 +386,8 @@ class GetbibleModelVerse extends AdminModel */ protected function canEditState($record) { - $user = Factory::getUser(); - $recordId = (!empty($record->id)) ? $record->id : 0; + $user = $this->getCurrentUser(); + $recordId = $record->id ?? 0; if ($recordId) { @@ -403,16 +405,16 @@ class GetbibleModelVerse extends AdminModel /** * 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. + * @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 + * @return boolean + * @since 2.5 */ protected function allowEdit($data = [], $key = 'id') { // Check specific edit permission then general edit permission. - $user = Factory::getUser(); + $user = Factory::getApplication()->getIdentity(); return $user->authorise('verse.edit', 'com_getbible.verse.'. ((int) isset($data[$key]) ? $data[$key] : 0)) or $user->authorise('verse.edit', 'com_getbible'); } @@ -429,11 +431,11 @@ class GetbibleModelVerse extends AdminModel protected function prepareTable($table) { $date = Factory::getDate(); - $user = Factory::getUser(); + $user = $this->getCurrentUser(); if (isset($table->name)) { - $table->name = htmlspecialchars_decode($table->name, ENT_QUOTES); + $table->name = \htmlspecialchars_decode($table->name, ENT_QUOTES); } if (isset($table->alias) && empty($table->alias)) @@ -452,7 +454,7 @@ class GetbibleModelVerse extends AdminModel // Set ordering to the last item if not set if (empty($table->ordering)) { - $db = Factory::getDbo(); + $db = $this->getDatabase(); $query = $db->getQuery(true) ->select('MAX(ordering)') ->from($db->quoteName('#__getbible_verse')); @@ -482,7 +484,7 @@ class GetbibleModelVerse extends AdminModel * * @since 1.6 */ - protected function loadFormData() + protected function loadFormData() { // Check the session for previously entered form data. $data = Factory::getApplication()->getUserState('com_getbible.edit.verse.data', []); @@ -490,10 +492,11 @@ class GetbibleModelVerse extends AdminModel if (empty($data)) { $data = $this->getItem(); - // run the perprocess of the data - $this->preprocessData('com_getbible.verse', $data); } + // run the perprocess of the data + $this->preprocessData('com_getbible.verse', $data); + return $data; } @@ -580,7 +583,7 @@ class GetbibleModelVerse extends AdminModel $done = false; // Set some needed variables. - $this->user = Factory::getUser(); + $this->user = $this->getCurrentUser(); $this->table = $this->getTable(); $this->tableClassName = get_class($this->table); $this->contentType = new UCMType; @@ -659,7 +662,7 @@ class GetbibleModelVerse extends AdminModel if (empty($this->batchSet)) { // Set some needed variables. - $this->user = Factory::getUser(); + $this->user = Factory::getApplication()->getIdentity(); $this->table = $this->getTable(); $this->tableClassName = get_class($this->table); $this->canDo = GetbibleHelper::getActions('verse'); @@ -685,7 +688,7 @@ class GetbibleModelVerse extends AdminModel $values['published'] = 0; } - $newIds = array(); + $newIds = []; // Parent exists so let's proceed while (!empty($pks)) { @@ -720,13 +723,13 @@ class GetbibleModelVerse extends AdminModel } // Only for strings - if (GetbibleHelper::checkString($this->table->book_nr) && !is_numeric($this->table->book_nr)) + if (UtilitiesStringHelper::check($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)) + if (UtilitiesArrayHelper::check($values)) { foreach ($values as $key => $value) { @@ -738,7 +741,7 @@ class GetbibleModelVerse extends AdminModel } // update all unique fields - if (GetbibleHelper::checkArray($uniqueFields)) + if (UtilitiesArrayHelper::check($uniqueFields)) { foreach ($uniqueFields as $uniqueField) { @@ -802,7 +805,7 @@ class GetbibleModelVerse extends AdminModel if (empty($this->batchSet)) { // Set some needed variables. - $this->user = Factory::getUser(); + $this->user = Factory::getApplication()->getIdentity(); $this->table = $this->getTable(); $this->tableClassName = get_class($this->table); $this->canDo = GetbibleHelper::getActions('verse'); @@ -849,7 +852,7 @@ class GetbibleModelVerse extends AdminModel } // insert all set values. - if (GetbibleHelper::checkArray($values)) + if (UtilitiesArrayHelper::check($values)) { foreach ($values as $key => $value) { @@ -905,14 +908,14 @@ class GetbibleModelVerse extends AdminModel */ public function save($data) { - $input = Factory::getApplication()->input; - $filter = InputFilter::getInstance(); + $input = Factory::getApplication()->input; + $filter = InputFilter::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 Registry; $metadata->loadArray($data['metadata']); $data['metadata'] = (string) $metadata; @@ -957,12 +960,12 @@ class GetbibleModelVerse extends AdminModel * * @since 3.0 */ - protected function generateUnique($field,$value) + protected function generateUnique($field, $value) { // set field value unique $table = $this->getTable(); - while ($table->load(array($field => $value))) + while ($table->load([$field => $value])) { $value = StringHelper::increment($value); } @@ -984,7 +987,7 @@ class GetbibleModelVerse extends AdminModel // Alter the title $table = $this->getTable(); - while ($table->load(array('title' => $title))) + while ($table->load(['title' => $title])) { $title = StringHelper::increment($title); } diff --git a/admin/models/verses.php b/admin/src/Model/VersesModel.php similarity index 91% rename from admin/models/verses.php rename to admin/src/Model/VersesModel.php index a540b66..dc7eaa5 100644 --- a/admin/models/verses.php +++ b/admin/src/Model/VersesModel.php @@ -14,9 +14,10 @@ @license GNU/GPL Version 2 or later - http://www.gnu.org/licenses/gpl-2.0.html /------------------------------------------------------------------------------------------------------*/ +namespace TrueChristianChurch\Component\Getbible\Administrator\Model; // No direct access to this file -defined('_JEXEC') or die('Restricted access'); +\defined('_JEXEC') or die; use Joomla\CMS\Factory; use Joomla\CMS\Language\Text; @@ -24,6 +25,8 @@ use Joomla\CMS\Component\ComponentHelper; use Joomla\CMS\MVC\Model\ListModel; use Joomla\CMS\Plugin\PluginHelper; use Joomla\Utilities\ArrayHelper; +use Joomla\CMS\Helper\TagsHelper; +use TrueChristianChurch\Component\Getbible\Administrator\Helper\GetbibleHelper; use VDM\Joomla\Utilities\ArrayHelper as UtilitiesArrayHelper; use VDM\Joomla\Utilities\ObjectHelper; use VDM\Joomla\Utilities\StringHelper; @@ -31,12 +34,12 @@ use VDM\Joomla\Utilities\StringHelper; /** * Verses List Model */ -class GetbibleModelVerses extends ListModel +class VersesModel extends ListModel { public function __construct($config = []) { if (empty($config['filter_fields'])) - { + { $config['filter_fields'] = array( 'a.id','id', 'a.published','published', @@ -151,7 +154,7 @@ class GetbibleModelVerses extends ListModel // Get the user object if not set. if (!isset($user) || !ObjectHelper::check($user)) { - $user = Factory::getUser(); + $user = $this->getCurrentUser(); } foreach ($items as $nr => &$item) { @@ -173,14 +176,14 @@ class GetbibleModelVerses extends ListModel /** * Method to build an SQL query to load the list data. * - * @return string An SQL query + * @return string An SQL query */ protected function getListQuery() { // Get the user object. - $user = Factory::getUser(); + $user = $this->getCurrentUser(); // Create a new query object. - $db = Factory::getDBO(); + $db = $this->getDatabase(); $query = $db->getQuery(true); // Select some fields @@ -213,7 +216,7 @@ class GetbibleModelVerses extends ListModel { $query->where('a.access = ' . (int) $_access); } - elseif (GetbibleHelper::checkArray($_access)) + elseif (UtilitiesArrayHelper::check($_access)) { // Secure the array for the query $_access = ArrayHelper::toInteger($_access); @@ -254,7 +257,7 @@ class GetbibleModelVerses extends ListModel $query->where('a.book_nr = ' . (int) $_book_nr); } } - elseif (GetbibleHelper::checkString($_book_nr)) + elseif (StringHelper::check($_book_nr)) { $query->where('a.book_nr = ' . $db->quote($db->escape($_book_nr))); } @@ -271,7 +274,7 @@ class GetbibleModelVerses extends ListModel $query->where('a.chapter = ' . (int) $_chapter); } } - elseif (GetbibleHelper::checkString($_chapter)) + elseif (StringHelper::check($_chapter)) { $query->where('a.chapter = ' . $db->quote($db->escape($_chapter))); } @@ -288,7 +291,7 @@ class GetbibleModelVerses extends ListModel $query->where('a.verse = ' . (int) $_verse); } } - elseif (GetbibleHelper::checkString($_verse)) + elseif (StringHelper::check($_verse)) { $query->where('a.verse = ' . $db->quote($db->escape($_verse))); } @@ -305,16 +308,18 @@ class GetbibleModelVerses extends ListModel $query->where('a.abbreviation = ' . (int) $_abbreviation); } } - elseif (GetbibleHelper::checkString($_abbreviation)) + elseif (StringHelper::check($_abbreviation)) { $query->where('a.abbreviation = ' . $db->quote($db->escape($_abbreviation))); } // Add the list ordering clause. - $orderCol = $this->state->get('list.ordering', 'g.translation'); - $orderDirn = $this->state->get('list.direction', 'asc'); + $orderCol = $this->getState('list.ordering', 'g.translation'); + $orderDirn = $this->getState('list.direction', 'asc'); if ($orderCol != '') { + // Check that the order direction is valid encase we have a field called direction as part of filers. + $orderDirn = (is_string($orderDirn) && in_array(strtolower($orderDirn), ['asc', 'desc'])) ? $orderDirn : 'asc'; $query->order($db->escape($orderCol . ' ' . $orderDirn)); } @@ -368,19 +373,18 @@ class GetbibleModelVerses extends ListModel /** * Build an SQL query to checkin all items left checked out longer then a set time. * - * @return a bool - * + * @return bool + * @since 3.2.0 */ - protected function checkInNow() + protected function checkInNow(): bool { // Get set check in time $time = ComponentHelper::getParams('com_getbible')->get('check_in'); if ($time) { - // Get a db connection. - $db = Factory::getDbo(); + $db = $this->getDatabase(); // Reset query. $query = $db->getQuery(true); $query->select('*'); @@ -413,7 +417,7 @@ class GetbibleModelVerses extends ListModel $db->setQuery($query); - $db->execute(); + return $db->execute(); } } diff --git a/admin/tables/index.html b/admin/src/Model/index.html similarity index 100% rename from admin/tables/index.html rename to admin/src/Model/index.html diff --git a/admin/models/rules/guid.php b/admin/src/Rule/GuidRule.php similarity index 90% rename from admin/models/rules/guid.php rename to admin/src/Rule/GuidRule.php index 6d7886e..f1edbaf 100644 --- a/admin/models/rules/guid.php +++ b/admin/src/Rule/GuidRule.php @@ -14,9 +14,10 @@ @license GNU/GPL Version 2 or later - http://www.gnu.org/licenses/gpl-2.0.html /------------------------------------------------------------------------------------------------------*/ +namespace TrueChristianChurch\Component\Getbible\Administrator\Rule; // No direct access to this file -defined('JPATH_PLATFORM') or die; +\defined('JPATH_PLATFORM') or die; use Joomla\CMS\Factory; use Joomla\CMS\Language\Text; @@ -24,11 +25,13 @@ use Joomla\CMS\Form\Form; use Joomla\CMS\Form\FormRule; use Joomla\Registry\Registry; use Joomla\CMS\HTML\HTMLHelper as Html; +use Joomla\CMS\Component\ComponentHelper; +use TrueChristianChurch\Component\Getbible\Administrator\Helper\GetbibleHelper; /** * Form Rule (Guid) class for the Joomla Platform. */ -class JFormRuleGuid extends FormRule +class GuidRule extends FormRule { /** * Method to test for a Globally Unique Identifier. diff --git a/admin/models/rules/int.php b/admin/src/Rule/IntRule.php similarity index 90% rename from admin/models/rules/int.php rename to admin/src/Rule/IntRule.php index 4a8a228..eeae034 100644 --- a/admin/models/rules/int.php +++ b/admin/src/Rule/IntRule.php @@ -14,9 +14,10 @@ @license GNU/GPL Version 2 or later - http://www.gnu.org/licenses/gpl-2.0.html /------------------------------------------------------------------------------------------------------*/ +namespace TrueChristianChurch\Component\Getbible\Administrator\Rule; // No direct access to this file -defined('JPATH_PLATFORM') or die; +\defined('JPATH_PLATFORM') or die; use Joomla\CMS\Factory; use Joomla\CMS\Language\Text; @@ -24,11 +25,13 @@ use Joomla\CMS\Form\Form; use Joomla\CMS\Form\FormRule; use Joomla\Registry\Registry; use Joomla\CMS\HTML\HTMLHelper as Html; +use Joomla\CMS\Component\ComponentHelper; +use TrueChristianChurch\Component\Getbible\Administrator\Helper\GetbibleHelper; /** * Form Rule (Int) class for the Joomla Platform. */ -class JFormRuleInt extends FormRule +class IntRule extends FormRule { /** * Method to test that an integer value was added. diff --git a/admin/models/rules/numbershyphens.php b/admin/src/Rule/NumbershyphensRule.php similarity index 89% rename from admin/models/rules/numbershyphens.php rename to admin/src/Rule/NumbershyphensRule.php index d98d100..476e91e 100644 --- a/admin/models/rules/numbershyphens.php +++ b/admin/src/Rule/NumbershyphensRule.php @@ -14,9 +14,10 @@ @license GNU/GPL Version 2 or later - http://www.gnu.org/licenses/gpl-2.0.html /------------------------------------------------------------------------------------------------------*/ +namespace TrueChristianChurch\Component\Getbible\Administrator\Rule; // No direct access to this file -defined('JPATH_PLATFORM') or die; +\defined('JPATH_PLATFORM') or die; use Joomla\CMS\Factory; use Joomla\CMS\Language\Text; @@ -24,11 +25,13 @@ use Joomla\CMS\Form\Form; use Joomla\CMS\Form\FormRule; use Joomla\Registry\Registry; use Joomla\CMS\HTML\HTMLHelper as Html; +use Joomla\CMS\Component\ComponentHelper; +use TrueChristianChurch\Component\Getbible\Administrator\Helper\GetbibleHelper; /** * Form Rule (Numbershyphens) class for the Joomla Platform. */ -class JFormRuleNumbershyphens extends FormRule +class NumbershyphensRule extends FormRule { /** * Method to test if the input is a number or a sequence of numbers separated by hyphens. diff --git a/admin/views/book/tmpl/index.html b/admin/src/Rule/index.html similarity index 100% rename from admin/views/book/tmpl/index.html rename to admin/src/Rule/index.html diff --git a/admin/views/books/index.html b/admin/src/Service/index.html similarity index 100% rename from admin/views/books/index.html rename to admin/src/Service/index.html diff --git a/admin/tables/book.php b/admin/src/Table/BookTable.php similarity index 58% rename from admin/tables/book.php rename to admin/src/Table/BookTable.php index 0e0b1eb..fc0cbcd 100644 --- a/admin/tables/book.php +++ b/admin/src/Table/BookTable.php @@ -14,88 +14,106 @@ @license GNU/GPL Version 2 or later - http://www.gnu.org/licenses/gpl-2.0.html /------------------------------------------------------------------------------------------------------*/ +namespace TrueChristianChurch\Component\Getbible\Administrator\Table; // No direct access to this file -defined('_JEXEC') or die('Restricted access'); +\defined('_JEXEC') or die; use Joomla\CMS\Factory; use Joomla\CMS\Table\Table; +use Joomla\CMS\Language\Text; +use Joomla\CMS\String\PunycodeHelper; use Joomla\CMS\Access\Access as AccessRules; use Joomla\CMS\Access\Rules; +use Joomla\CMS\Tag\TaggableTableInterface; +use Joomla\CMS\Tag\TaggableTableTrait; +use Joomla\CMS\User\CurrentUserInterface; +use Joomla\CMS\User\CurrentUserTrait; +use Joomla\CMS\Versioning\VersionableTableInterface; +use Joomla\CMS\Application\ApplicationHelper; +use Joomla\Database\DatabaseInterface; use Joomla\Registry\Registry; +use Joomla\Database\DatabaseDriver; +use Joomla\Event\DispatcherInterface; use Joomla\String\StringHelper; use Joomla\Utilities\ArrayHelper; -use Joomla\CMS\String\PunycodeHelper; -use Joomla\CMS\Table\Observer\Tags as TableObserverTags; -use Joomla\CMS\Table\Observer\ContentHistory as TableObserverContenthistory; -use Joomla\CMS\Application\ApplicationHelper; +use TrueChristianChurch\Component\Getbible\Administrator\Helper\GetbibleHelper; /** * Books Table class */ -class GetbibleTableBook extends Table +class BookTable extends Table implements VersionableTableInterface, TaggableTableInterface, CurrentUserInterface { - /** - * Ensure the params and metadata in json encoded in the bind method - * - * @var array - * @since 3.3 - */ - protected $_jsonEncode = array('params', 'metadata'); - + use TaggableTableTrait; + use CurrentUserTrait; + /** * Constructor * + * @param DatabaseDriver $db Database connector object + * @param ?DispatcherInterface $dispatcher Event dispatcher for this table + * * @param object Database connector object + * @since 4.0 */ - function __construct(&$db) + function __construct(DatabaseDriver $db, ?DispatcherInterface $dispatcher = null) { - parent::__construct('#__getbible_book', 'id', $db); - } - + // The type alias generally is the internal component name with the + // content type. Ex.: com_content.article + $this->typeAlias = 'com_getbible.book'; + + // Ensure the params and metadata in json encoded in the bind method + $this->_jsonEncode = ['params', 'metadata']; + + // Indicates that columns fully support the NULL value in the database + // $this->_supportNullValue = true; // hmmm will keep an eye on this ;) + + parent::__construct('#__getbible_book', 'id', $db, $dispatcher); + } + + /** + * Method to bind an associative array or object to the Table instance.This + * method only binds properties that are publicly accessible and optionally + * takes an array of properties to ignore when binding. + * + * @param array|object $src An associative array or object to bind to the Table instance. + * @param array|string $ignore An optional array or space separated list of properties to ignore while binding. + * + * @return boolean True on success. + * + * @since 1.7.0 + * @throws \InvalidArgumentException + */ public function bind($array, $ignore = '') { - - if (isset($array['params']) && is_array($array['params'])) + // Bind the rules. + if (isset($array['rules']) && is_array($array['rules'])) { - $registry = new Registry; - $registry->loadArray($array['params']); - $array['params'] = (string) $registry; + $rules = new AccessRules($array['rules']); + $this->setRules($rules); } - if (isset($array['metadata']) && is_array($array['metadata'])) - { - $registry = new Registry; - $registry->loadArray($array['metadata']); - $array['metadata'] = (string) $registry; - } - - // Bind the rules. - if (isset($array['rules']) && is_array($array['rules'])) - { - $rules = new AccessRules($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. + * @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 = Factory::getDate(); - $user = Factory::getUser(); + $date = Factory::getDate()->toSql(); + $userId = $this->getCurrentUser()->id; if ($this->id) { // Existing item - $this->modified = $date->toSql(); - $this->modified_by = $user->get('id'); + $this->modified = $date; + $this->modified_by = $userId; } else { @@ -103,31 +121,38 @@ class GetbibleTableBook extends Table // so we don't touch either of these if they are set. if (!(int) $this->created) { - $this->created = $date->toSql(); + $this->created = $date; } if (empty($this->created_by)) { - $this->created_by = $user->get('id'); + $this->created_by = $userId; } } - + if (isset($this->alias)) { // Verify that the alias is unique - $table = Table::getInstance('book', 'GetbibleTable'); + $table = new self($this->getDbo(), $this->getDispatcher()); - if ($table->load(array('alias' => $this->alias)) && ($table->id != $this->id || $this->id == 0)) + if ($table->load(['alias' => $this->alias]) && ($table->id != $this->id || $this->id == 0)) { $this->setError(Text::_('COM_GETBIBLE_BOOK_ERROR_UNIQUE_ALIAS')); + + if ($table->published === -2) + { + $this->setError(Text::_('COM_GETBIBLE_BOOK_ERROR_UNIQUE_ALIAS_TRASHED')); + } + return false; } } - + if (isset($this->url)) { // Convert IDN urls to punycode $this->url = PunycodeHelper::urlToPunycode($this->url); } + if (isset($this->website)) { // Convert IDN urls to punycode @@ -136,32 +161,42 @@ class GetbibleTableBook extends Table return parent::store($updateNulls); } - + /** * Overloaded check method to ensure data integrity. * * @return boolean True on success. + * + * @see \Joomla\CMS\Table\Table::check + * @since 1.5 */ public function check() { + try { + parent::check(); + } catch (\Exception $e) { + $this->setError($e->getMessage()); + return false; + } + if (isset($this->alias)) { // Generate a valid alias $this->generateAlias(); - - $table = Table::getInstance('book', 'getbibleTable'); - while ($table->load(array('alias' => $this->alias)) && ($table->id != $this->id || $this->id == 0)) + $table = new self($this->getDbo(), $this->getDispatcher()); + + while ($table->load(['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. @@ -201,7 +236,7 @@ class GetbibleTableBook extends Table $rules = $this->getDefaultAssetValues('com_getbible.book.'.$this->id); $this->setRules($rules); } - + // Set ordering if ($this->published < 0) { @@ -222,7 +257,7 @@ class GetbibleTableBook extends Table protected function getDefaultAssetValues($component, $try = true) { // Need to find the asset id by the name of the component. - $db = Factory::getDbo(); + $db = Factory::getContainer()->get(DatabaseInterface::class); $query = $db->getQuery(true) ->select($db->quoteName('id')) ->from($db->quoteName('#__assets')) @@ -233,7 +268,7 @@ class GetbibleTableBook extends Table { // asset already set so use saved rules $assetId = (int) $db->loadResult(); - return Access::getAssetRules($assetId); // (TODO) instead of keeping inherited Allowed it becomes Allowed. + return AccessRules::getAssetRules($assetId); // (TODO) instead of keeping inherited Allowed it becomes Allowed. } // try again elseif ($try) @@ -275,50 +310,63 @@ class GetbibleTableBook extends Table return $result; } } - return Access::getAssetRules(0); + return AccessRules::getAssetRules(0); + } + + /** + * Get the type alias for the history table + * + * The type alias generally is the internal component name with the + * content type. Ex.: com_content.article + * + * @return string The alias as described above + * + * @since 3.10.0 + */ + public function getTypeAlias() + { + return $this->typeAlias; } /** * Method to compute the default name of the asset. - * The default name is in the form 'table_name.id' + * 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 + * @return string + * + * @since 1.7.0 */ protected function _getAssetName() { $k = $this->_tbl_key; - return 'com_getbible.book.'.(int) $this->$k; + + return $this->getTypeAlias() . '.' . (int) $this->$k; } /** - * Method to return the title to use for the asset table. + * Method to get the parent asset under which to register this one. * - * @return string - * @since 2.5 - */ - protected function _getAssetTitle() - { - if (isset($this->title)) - { - return $this->title; - } - return ''; - } - - /** - * Get the parent asset id for the record + * By default, all assets are registered to the ROOT node with ID, which will default to 1 if none exists. + * An extended class can define a table and ID to lookup. If the asset does not exist it will be created. * - * @return int - * @since 2.5 + * @param Table $table A Table object for the asset parent. + * @param integer $id Id to look up + * + * @return integer + * + * @since 1.7.0 */ - protected function _getAssetParentId(?Table $table = null, $id = null) + protected function _getAssetParentId(Table $table = null, $id = null) { - $asset = Table::getInstance('Asset'); - $asset->loadByName('com_getbible'); + /** @var Asset $assets */ + $assets = self::getInstance('Asset', 'JTable', ['dbo' => $this->getDbo()]); + $rootId = $assets->getRootId(); - return $asset->id; + // load the getbible asset + $assets->loadByName('com_getbible'); + + return $assets->id ?? $rootId ?? 1; } /** @@ -330,5 +378,4 @@ class GetbibleTableBook extends Table { return false; } - } diff --git a/admin/tables/chapter.php b/admin/src/Table/ChapterTable.php similarity index 58% rename from admin/tables/chapter.php rename to admin/src/Table/ChapterTable.php index ae57058..05793d2 100644 --- a/admin/tables/chapter.php +++ b/admin/src/Table/ChapterTable.php @@ -14,88 +14,106 @@ @license GNU/GPL Version 2 or later - http://www.gnu.org/licenses/gpl-2.0.html /------------------------------------------------------------------------------------------------------*/ +namespace TrueChristianChurch\Component\Getbible\Administrator\Table; // No direct access to this file -defined('_JEXEC') or die('Restricted access'); +\defined('_JEXEC') or die; use Joomla\CMS\Factory; use Joomla\CMS\Table\Table; +use Joomla\CMS\Language\Text; +use Joomla\CMS\String\PunycodeHelper; use Joomla\CMS\Access\Access as AccessRules; use Joomla\CMS\Access\Rules; +use Joomla\CMS\Tag\TaggableTableInterface; +use Joomla\CMS\Tag\TaggableTableTrait; +use Joomla\CMS\User\CurrentUserInterface; +use Joomla\CMS\User\CurrentUserTrait; +use Joomla\CMS\Versioning\VersionableTableInterface; +use Joomla\CMS\Application\ApplicationHelper; +use Joomla\Database\DatabaseInterface; use Joomla\Registry\Registry; +use Joomla\Database\DatabaseDriver; +use Joomla\Event\DispatcherInterface; use Joomla\String\StringHelper; use Joomla\Utilities\ArrayHelper; -use Joomla\CMS\String\PunycodeHelper; -use Joomla\CMS\Table\Observer\Tags as TableObserverTags; -use Joomla\CMS\Table\Observer\ContentHistory as TableObserverContenthistory; -use Joomla\CMS\Application\ApplicationHelper; +use TrueChristianChurch\Component\Getbible\Administrator\Helper\GetbibleHelper; /** * Chapters Table class */ -class GetbibleTableChapter extends Table +class ChapterTable extends Table implements VersionableTableInterface, TaggableTableInterface, CurrentUserInterface { - /** - * Ensure the params and metadata in json encoded in the bind method - * - * @var array - * @since 3.3 - */ - protected $_jsonEncode = array('params', 'metadata'); - + use TaggableTableTrait; + use CurrentUserTrait; + /** * Constructor * + * @param DatabaseDriver $db Database connector object + * @param ?DispatcherInterface $dispatcher Event dispatcher for this table + * * @param object Database connector object + * @since 4.0 */ - function __construct(&$db) + function __construct(DatabaseDriver $db, ?DispatcherInterface $dispatcher = null) { - parent::__construct('#__getbible_chapter', 'id', $db); - } - + // The type alias generally is the internal component name with the + // content type. Ex.: com_content.article + $this->typeAlias = 'com_getbible.chapter'; + + // Ensure the params and metadata in json encoded in the bind method + $this->_jsonEncode = ['params', 'metadata']; + + // Indicates that columns fully support the NULL value in the database + // $this->_supportNullValue = true; // hmmm will keep an eye on this ;) + + parent::__construct('#__getbible_chapter', 'id', $db, $dispatcher); + } + + /** + * Method to bind an associative array or object to the Table instance.This + * method only binds properties that are publicly accessible and optionally + * takes an array of properties to ignore when binding. + * + * @param array|object $src An associative array or object to bind to the Table instance. + * @param array|string $ignore An optional array or space separated list of properties to ignore while binding. + * + * @return boolean True on success. + * + * @since 1.7.0 + * @throws \InvalidArgumentException + */ public function bind($array, $ignore = '') { - - if (isset($array['params']) && is_array($array['params'])) + // Bind the rules. + if (isset($array['rules']) && is_array($array['rules'])) { - $registry = new Registry; - $registry->loadArray($array['params']); - $array['params'] = (string) $registry; + $rules = new AccessRules($array['rules']); + $this->setRules($rules); } - if (isset($array['metadata']) && is_array($array['metadata'])) - { - $registry = new Registry; - $registry->loadArray($array['metadata']); - $array['metadata'] = (string) $registry; - } - - // Bind the rules. - if (isset($array['rules']) && is_array($array['rules'])) - { - $rules = new AccessRules($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. + * @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 = Factory::getDate(); - $user = Factory::getUser(); + $date = Factory::getDate()->toSql(); + $userId = $this->getCurrentUser()->id; if ($this->id) { // Existing item - $this->modified = $date->toSql(); - $this->modified_by = $user->get('id'); + $this->modified = $date; + $this->modified_by = $userId; } else { @@ -103,31 +121,38 @@ class GetbibleTableChapter extends Table // so we don't touch either of these if they are set. if (!(int) $this->created) { - $this->created = $date->toSql(); + $this->created = $date; } if (empty($this->created_by)) { - $this->created_by = $user->get('id'); + $this->created_by = $userId; } } - + if (isset($this->alias)) { // Verify that the alias is unique - $table = Table::getInstance('chapter', 'GetbibleTable'); + $table = new self($this->getDbo(), $this->getDispatcher()); - if ($table->load(array('alias' => $this->alias)) && ($table->id != $this->id || $this->id == 0)) + if ($table->load(['alias' => $this->alias]) && ($table->id != $this->id || $this->id == 0)) { $this->setError(Text::_('COM_GETBIBLE_CHAPTER_ERROR_UNIQUE_ALIAS')); + + if ($table->published === -2) + { + $this->setError(Text::_('COM_GETBIBLE_CHAPTER_ERROR_UNIQUE_ALIAS_TRASHED')); + } + return false; } } - + if (isset($this->url)) { // Convert IDN urls to punycode $this->url = PunycodeHelper::urlToPunycode($this->url); } + if (isset($this->website)) { // Convert IDN urls to punycode @@ -136,32 +161,42 @@ class GetbibleTableChapter extends Table return parent::store($updateNulls); } - + /** * Overloaded check method to ensure data integrity. * * @return boolean True on success. + * + * @see \Joomla\CMS\Table\Table::check + * @since 1.5 */ public function check() { + try { + parent::check(); + } catch (\Exception $e) { + $this->setError($e->getMessage()); + return false; + } + if (isset($this->alias)) { // Generate a valid alias $this->generateAlias(); - - $table = Table::getInstance('chapter', 'getbibleTable'); - while ($table->load(array('alias' => $this->alias)) && ($table->id != $this->id || $this->id == 0)) + $table = new self($this->getDbo(), $this->getDispatcher()); + + while ($table->load(['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. @@ -201,7 +236,7 @@ class GetbibleTableChapter extends Table $rules = $this->getDefaultAssetValues('com_getbible.chapter.'.$this->id); $this->setRules($rules); } - + // Set ordering if ($this->published < 0) { @@ -222,7 +257,7 @@ class GetbibleTableChapter extends Table protected function getDefaultAssetValues($component, $try = true) { // Need to find the asset id by the name of the component. - $db = Factory::getDbo(); + $db = Factory::getContainer()->get(DatabaseInterface::class); $query = $db->getQuery(true) ->select($db->quoteName('id')) ->from($db->quoteName('#__assets')) @@ -233,7 +268,7 @@ class GetbibleTableChapter extends Table { // asset already set so use saved rules $assetId = (int) $db->loadResult(); - return Access::getAssetRules($assetId); // (TODO) instead of keeping inherited Allowed it becomes Allowed. + return AccessRules::getAssetRules($assetId); // (TODO) instead of keeping inherited Allowed it becomes Allowed. } // try again elseif ($try) @@ -275,50 +310,63 @@ class GetbibleTableChapter extends Table return $result; } } - return Access::getAssetRules(0); + return AccessRules::getAssetRules(0); + } + + /** + * Get the type alias for the history table + * + * The type alias generally is the internal component name with the + * content type. Ex.: com_content.article + * + * @return string The alias as described above + * + * @since 3.10.0 + */ + public function getTypeAlias() + { + return $this->typeAlias; } /** * Method to compute the default name of the asset. - * The default name is in the form 'table_name.id' + * 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 + * @return string + * + * @since 1.7.0 */ protected function _getAssetName() { $k = $this->_tbl_key; - return 'com_getbible.chapter.'.(int) $this->$k; + + return $this->getTypeAlias() . '.' . (int) $this->$k; } /** - * Method to return the title to use for the asset table. + * Method to get the parent asset under which to register this one. * - * @return string - * @since 2.5 - */ - protected function _getAssetTitle() - { - if (isset($this->title)) - { - return $this->title; - } - return ''; - } - - /** - * Get the parent asset id for the record + * By default, all assets are registered to the ROOT node with ID, which will default to 1 if none exists. + * An extended class can define a table and ID to lookup. If the asset does not exist it will be created. * - * @return int - * @since 2.5 + * @param Table $table A Table object for the asset parent. + * @param integer $id Id to look up + * + * @return integer + * + * @since 1.7.0 */ - protected function _getAssetParentId(?Table $table = null, $id = null) + protected function _getAssetParentId(Table $table = null, $id = null) { - $asset = Table::getInstance('Asset'); - $asset->loadByName('com_getbible'); + /** @var Asset $assets */ + $assets = self::getInstance('Asset', 'JTable', ['dbo' => $this->getDbo()]); + $rootId = $assets->getRootId(); - return $asset->id; + // load the getbible asset + $assets->loadByName('com_getbible'); + + return $assets->id ?? $rootId ?? 1; } /** @@ -330,5 +378,4 @@ class GetbibleTableChapter extends Table { return false; } - } diff --git a/admin/tables/linker.php b/admin/src/Table/LinkerTable.php similarity index 58% rename from admin/tables/linker.php rename to admin/src/Table/LinkerTable.php index c6b4381..3ae9d70 100644 --- a/admin/tables/linker.php +++ b/admin/src/Table/LinkerTable.php @@ -14,88 +14,106 @@ @license GNU/GPL Version 2 or later - http://www.gnu.org/licenses/gpl-2.0.html /------------------------------------------------------------------------------------------------------*/ +namespace TrueChristianChurch\Component\Getbible\Administrator\Table; // No direct access to this file -defined('_JEXEC') or die('Restricted access'); +\defined('_JEXEC') or die; use Joomla\CMS\Factory; use Joomla\CMS\Table\Table; +use Joomla\CMS\Language\Text; +use Joomla\CMS\String\PunycodeHelper; use Joomla\CMS\Access\Access as AccessRules; use Joomla\CMS\Access\Rules; +use Joomla\CMS\Tag\TaggableTableInterface; +use Joomla\CMS\Tag\TaggableTableTrait; +use Joomla\CMS\User\CurrentUserInterface; +use Joomla\CMS\User\CurrentUserTrait; +use Joomla\CMS\Versioning\VersionableTableInterface; +use Joomla\CMS\Application\ApplicationHelper; +use Joomla\Database\DatabaseInterface; use Joomla\Registry\Registry; +use Joomla\Database\DatabaseDriver; +use Joomla\Event\DispatcherInterface; use Joomla\String\StringHelper; use Joomla\Utilities\ArrayHelper; -use Joomla\CMS\String\PunycodeHelper; -use Joomla\CMS\Table\Observer\Tags as TableObserverTags; -use Joomla\CMS\Table\Observer\ContentHistory as TableObserverContenthistory; -use Joomla\CMS\Application\ApplicationHelper; +use TrueChristianChurch\Component\Getbible\Administrator\Helper\GetbibleHelper; /** * Linkers Table class */ -class GetbibleTableLinker extends Table +class LinkerTable extends Table implements VersionableTableInterface, TaggableTableInterface, CurrentUserInterface { - /** - * Ensure the params and metadata in json encoded in the bind method - * - * @var array - * @since 3.3 - */ - protected $_jsonEncode = array('params', 'metadata'); - + use TaggableTableTrait; + use CurrentUserTrait; + /** * Constructor * + * @param DatabaseDriver $db Database connector object + * @param ?DispatcherInterface $dispatcher Event dispatcher for this table + * * @param object Database connector object + * @since 4.0 */ - function __construct(&$db) + function __construct(DatabaseDriver $db, ?DispatcherInterface $dispatcher = null) { - parent::__construct('#__getbible_linker', 'id', $db); - } - + // The type alias generally is the internal component name with the + // content type. Ex.: com_content.article + $this->typeAlias = 'com_getbible.linker'; + + // Ensure the params and metadata in json encoded in the bind method + $this->_jsonEncode = ['params', 'metadata']; + + // Indicates that columns fully support the NULL value in the database + // $this->_supportNullValue = true; // hmmm will keep an eye on this ;) + + parent::__construct('#__getbible_linker', 'id', $db, $dispatcher); + } + + /** + * Method to bind an associative array or object to the Table instance.This + * method only binds properties that are publicly accessible and optionally + * takes an array of properties to ignore when binding. + * + * @param array|object $src An associative array or object to bind to the Table instance. + * @param array|string $ignore An optional array or space separated list of properties to ignore while binding. + * + * @return boolean True on success. + * + * @since 1.7.0 + * @throws \InvalidArgumentException + */ public function bind($array, $ignore = '') { - - if (isset($array['params']) && is_array($array['params'])) + // Bind the rules. + if (isset($array['rules']) && is_array($array['rules'])) { - $registry = new Registry; - $registry->loadArray($array['params']); - $array['params'] = (string) $registry; + $rules = new AccessRules($array['rules']); + $this->setRules($rules); } - if (isset($array['metadata']) && is_array($array['metadata'])) - { - $registry = new Registry; - $registry->loadArray($array['metadata']); - $array['metadata'] = (string) $registry; - } - - // Bind the rules. - if (isset($array['rules']) && is_array($array['rules'])) - { - $rules = new AccessRules($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. + * @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 = Factory::getDate(); - $user = Factory::getUser(); + $date = Factory::getDate()->toSql(); + $userId = $this->getCurrentUser()->id; if ($this->id) { // Existing item - $this->modified = $date->toSql(); - $this->modified_by = $user->get('id'); + $this->modified = $date; + $this->modified_by = $userId; } else { @@ -103,31 +121,38 @@ class GetbibleTableLinker extends Table // so we don't touch either of these if they are set. if (!(int) $this->created) { - $this->created = $date->toSql(); + $this->created = $date; } if (empty($this->created_by)) { - $this->created_by = $user->get('id'); + $this->created_by = $userId; } } - + if (isset($this->alias)) { // Verify that the alias is unique - $table = Table::getInstance('linker', 'GetbibleTable'); + $table = new self($this->getDbo(), $this->getDispatcher()); - if ($table->load(array('alias' => $this->alias)) && ($table->id != $this->id || $this->id == 0)) + if ($table->load(['alias' => $this->alias]) && ($table->id != $this->id || $this->id == 0)) { $this->setError(Text::_('COM_GETBIBLE_LINKER_ERROR_UNIQUE_ALIAS')); + + if ($table->published === -2) + { + $this->setError(Text::_('COM_GETBIBLE_LINKER_ERROR_UNIQUE_ALIAS_TRASHED')); + } + return false; } } - + if (isset($this->url)) { // Convert IDN urls to punycode $this->url = PunycodeHelper::urlToPunycode($this->url); } + if (isset($this->website)) { // Convert IDN urls to punycode @@ -136,32 +161,42 @@ class GetbibleTableLinker extends Table return parent::store($updateNulls); } - + /** * Overloaded check method to ensure data integrity. * * @return boolean True on success. + * + * @see \Joomla\CMS\Table\Table::check + * @since 1.5 */ public function check() { + try { + parent::check(); + } catch (\Exception $e) { + $this->setError($e->getMessage()); + return false; + } + if (isset($this->alias)) { // Generate a valid alias $this->generateAlias(); - - $table = Table::getInstance('linker', 'getbibleTable'); - while ($table->load(array('alias' => $this->alias)) && ($table->id != $this->id || $this->id == 0)) + $table = new self($this->getDbo(), $this->getDispatcher()); + + while ($table->load(['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. @@ -201,7 +236,7 @@ class GetbibleTableLinker extends Table $rules = $this->getDefaultAssetValues('com_getbible.linker.'.$this->id); $this->setRules($rules); } - + // Set ordering if ($this->published < 0) { @@ -222,7 +257,7 @@ class GetbibleTableLinker extends Table protected function getDefaultAssetValues($component, $try = true) { // Need to find the asset id by the name of the component. - $db = Factory::getDbo(); + $db = Factory::getContainer()->get(DatabaseInterface::class); $query = $db->getQuery(true) ->select($db->quoteName('id')) ->from($db->quoteName('#__assets')) @@ -233,7 +268,7 @@ class GetbibleTableLinker extends Table { // asset already set so use saved rules $assetId = (int) $db->loadResult(); - return Access::getAssetRules($assetId); // (TODO) instead of keeping inherited Allowed it becomes Allowed. + return AccessRules::getAssetRules($assetId); // (TODO) instead of keeping inherited Allowed it becomes Allowed. } // try again elseif ($try) @@ -275,50 +310,63 @@ class GetbibleTableLinker extends Table return $result; } } - return Access::getAssetRules(0); + return AccessRules::getAssetRules(0); + } + + /** + * Get the type alias for the history table + * + * The type alias generally is the internal component name with the + * content type. Ex.: com_content.article + * + * @return string The alias as described above + * + * @since 3.10.0 + */ + public function getTypeAlias() + { + return $this->typeAlias; } /** * Method to compute the default name of the asset. - * The default name is in the form 'table_name.id' + * 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 + * @return string + * + * @since 1.7.0 */ protected function _getAssetName() { $k = $this->_tbl_key; - return 'com_getbible.linker.'.(int) $this->$k; + + return $this->getTypeAlias() . '.' . (int) $this->$k; } /** - * Method to return the title to use for the asset table. + * Method to get the parent asset under which to register this one. * - * @return string - * @since 2.5 - */ - protected function _getAssetTitle() - { - if (isset($this->title)) - { - return $this->title; - } - return ''; - } - - /** - * Get the parent asset id for the record + * By default, all assets are registered to the ROOT node with ID, which will default to 1 if none exists. + * An extended class can define a table and ID to lookup. If the asset does not exist it will be created. * - * @return int - * @since 2.5 + * @param Table $table A Table object for the asset parent. + * @param integer $id Id to look up + * + * @return integer + * + * @since 1.7.0 */ - protected function _getAssetParentId(?Table $table = null, $id = null) + protected function _getAssetParentId(Table $table = null, $id = null) { - $asset = Table::getInstance('Asset'); - $asset->loadByName('com_getbible'); + /** @var Asset $assets */ + $assets = self::getInstance('Asset', 'JTable', ['dbo' => $this->getDbo()]); + $rootId = $assets->getRootId(); - return $asset->id; + // load the getbible asset + $assets->loadByName('com_getbible'); + + return $assets->id ?? $rootId ?? 1; } /** @@ -330,5 +378,4 @@ class GetbibleTableLinker extends Table { return false; } - } diff --git a/admin/tables/note.php b/admin/src/Table/NoteTable.php similarity index 58% rename from admin/tables/note.php rename to admin/src/Table/NoteTable.php index e29ac7d..b18387d 100644 --- a/admin/tables/note.php +++ b/admin/src/Table/NoteTable.php @@ -14,91 +14,106 @@ @license GNU/GPL Version 2 or later - http://www.gnu.org/licenses/gpl-2.0.html /------------------------------------------------------------------------------------------------------*/ +namespace TrueChristianChurch\Component\Getbible\Administrator\Table; // No direct access to this file -defined('_JEXEC') or die('Restricted access'); +\defined('_JEXEC') or die; use Joomla\CMS\Factory; use Joomla\CMS\Table\Table; +use Joomla\CMS\Language\Text; +use Joomla\CMS\String\PunycodeHelper; use Joomla\CMS\Access\Access as AccessRules; use Joomla\CMS\Access\Rules; +use Joomla\CMS\Tag\TaggableTableInterface; +use Joomla\CMS\Tag\TaggableTableTrait; +use Joomla\CMS\User\CurrentUserInterface; +use Joomla\CMS\User\CurrentUserTrait; +use Joomla\CMS\Versioning\VersionableTableInterface; +use Joomla\CMS\Application\ApplicationHelper; +use Joomla\Database\DatabaseInterface; use Joomla\Registry\Registry; +use Joomla\Database\DatabaseDriver; +use Joomla\Event\DispatcherInterface; use Joomla\String\StringHelper; use Joomla\Utilities\ArrayHelper; -use Joomla\CMS\String\PunycodeHelper; -use Joomla\CMS\Table\Observer\Tags as TableObserverTags; -use Joomla\CMS\Table\Observer\ContentHistory as TableObserverContenthistory; -use Joomla\CMS\Application\ApplicationHelper; +use TrueChristianChurch\Component\Getbible\Administrator\Helper\GetbibleHelper; /** * Notes Table class */ -class GetbibleTableNote extends Table +class NoteTable extends Table implements VersionableTableInterface, TaggableTableInterface, CurrentUserInterface { - /** - * Ensure the params and metadata in json encoded in the bind method - * - * @var array - * @since 3.3 - */ - protected $_jsonEncode = array('params', 'metadata'); - + use TaggableTableTrait; + use CurrentUserTrait; + /** * Constructor * + * @param DatabaseDriver $db Database connector object + * @param ?DispatcherInterface $dispatcher Event dispatcher for this table + * * @param object Database connector object + * @since 4.0 */ - function __construct(&$db) + function __construct(DatabaseDriver $db, ?DispatcherInterface $dispatcher = null) { - parent::__construct('#__getbible_note', 'id', $db); + // The type alias generally is the internal component name with the + // content type. Ex.: com_content.article + $this->typeAlias = 'com_getbible.note'; - // Adding History Options - TableObserverContenthistory::createObserver($this, array('typeAlias' => 'com_getbible.note')); - } - + // Ensure the params and metadata in json encoded in the bind method + $this->_jsonEncode = ['params', 'metadata']; + + // Indicates that columns fully support the NULL value in the database + // $this->_supportNullValue = true; // hmmm will keep an eye on this ;) + + parent::__construct('#__getbible_note', 'id', $db, $dispatcher); + } + + /** + * Method to bind an associative array or object to the Table instance.This + * method only binds properties that are publicly accessible and optionally + * takes an array of properties to ignore when binding. + * + * @param array|object $src An associative array or object to bind to the Table instance. + * @param array|string $ignore An optional array or space separated list of properties to ignore while binding. + * + * @return boolean True on success. + * + * @since 1.7.0 + * @throws \InvalidArgumentException + */ public function bind($array, $ignore = '') { - - if (isset($array['params']) && is_array($array['params'])) + // Bind the rules. + if (isset($array['rules']) && is_array($array['rules'])) { - $registry = new Registry; - $registry->loadArray($array['params']); - $array['params'] = (string) $registry; + $rules = new AccessRules($array['rules']); + $this->setRules($rules); } - if (isset($array['metadata']) && is_array($array['metadata'])) - { - $registry = new Registry; - $registry->loadArray($array['metadata']); - $array['metadata'] = (string) $registry; - } - - // Bind the rules. - if (isset($array['rules']) && is_array($array['rules'])) - { - $rules = new AccessRules($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. + * @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 = Factory::getDate(); - $user = Factory::getUser(); + $date = Factory::getDate()->toSql(); + $userId = $this->getCurrentUser()->id; if ($this->id) { // Existing item - $this->modified = $date->toSql(); - $this->modified_by = $user->get('id'); + $this->modified = $date; + $this->modified_by = $userId; } else { @@ -106,31 +121,38 @@ class GetbibleTableNote extends Table // so we don't touch either of these if they are set. if (!(int) $this->created) { - $this->created = $date->toSql(); + $this->created = $date; } if (empty($this->created_by)) { - $this->created_by = $user->get('id'); + $this->created_by = $userId; } } - + if (isset($this->alias)) { // Verify that the alias is unique - $table = Table::getInstance('note', 'GetbibleTable'); + $table = new self($this->getDbo(), $this->getDispatcher()); - if ($table->load(array('alias' => $this->alias)) && ($table->id != $this->id || $this->id == 0)) + if ($table->load(['alias' => $this->alias]) && ($table->id != $this->id || $this->id == 0)) { $this->setError(Text::_('COM_GETBIBLE_NOTE_ERROR_UNIQUE_ALIAS')); + + if ($table->published === -2) + { + $this->setError(Text::_('COM_GETBIBLE_NOTE_ERROR_UNIQUE_ALIAS_TRASHED')); + } + return false; } } - + if (isset($this->url)) { // Convert IDN urls to punycode $this->url = PunycodeHelper::urlToPunycode($this->url); } + if (isset($this->website)) { // Convert IDN urls to punycode @@ -139,32 +161,42 @@ class GetbibleTableNote extends Table return parent::store($updateNulls); } - + /** * Overloaded check method to ensure data integrity. * * @return boolean True on success. + * + * @see \Joomla\CMS\Table\Table::check + * @since 1.5 */ public function check() { + try { + parent::check(); + } catch (\Exception $e) { + $this->setError($e->getMessage()); + return false; + } + if (isset($this->alias)) { // Generate a valid alias $this->generateAlias(); - - $table = Table::getInstance('note', 'getbibleTable'); - while ($table->load(array('alias' => $this->alias)) && ($table->id != $this->id || $this->id == 0)) + $table = new self($this->getDbo(), $this->getDispatcher()); + + while ($table->load(['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. @@ -204,7 +236,7 @@ class GetbibleTableNote extends Table $rules = $this->getDefaultAssetValues('com_getbible.note.'.$this->id); $this->setRules($rules); } - + // Set ordering if ($this->published < 0) { @@ -225,7 +257,7 @@ class GetbibleTableNote extends Table protected function getDefaultAssetValues($component, $try = true) { // Need to find the asset id by the name of the component. - $db = Factory::getDbo(); + $db = Factory::getContainer()->get(DatabaseInterface::class); $query = $db->getQuery(true) ->select($db->quoteName('id')) ->from($db->quoteName('#__assets')) @@ -236,7 +268,7 @@ class GetbibleTableNote extends Table { // asset already set so use saved rules $assetId = (int) $db->loadResult(); - return Access::getAssetRules($assetId); // (TODO) instead of keeping inherited Allowed it becomes Allowed. + return AccessRules::getAssetRules($assetId); // (TODO) instead of keeping inherited Allowed it becomes Allowed. } // try again elseif ($try) @@ -278,50 +310,63 @@ class GetbibleTableNote extends Table return $result; } } - return Access::getAssetRules(0); + return AccessRules::getAssetRules(0); + } + + /** + * Get the type alias for the history table + * + * The type alias generally is the internal component name with the + * content type. Ex.: com_content.article + * + * @return string The alias as described above + * + * @since 3.10.0 + */ + public function getTypeAlias() + { + return $this->typeAlias; } /** * Method to compute the default name of the asset. - * The default name is in the form 'table_name.id' + * 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 + * @return string + * + * @since 1.7.0 */ protected function _getAssetName() { $k = $this->_tbl_key; - return 'com_getbible.note.'.(int) $this->$k; + + return $this->getTypeAlias() . '.' . (int) $this->$k; } /** - * Method to return the title to use for the asset table. + * Method to get the parent asset under which to register this one. * - * @return string - * @since 2.5 - */ - protected function _getAssetTitle() - { - if (isset($this->title)) - { - return $this->title; - } - return ''; - } - - /** - * Get the parent asset id for the record + * By default, all assets are registered to the ROOT node with ID, which will default to 1 if none exists. + * An extended class can define a table and ID to lookup. If the asset does not exist it will be created. * - * @return int - * @since 2.5 + * @param Table $table A Table object for the asset parent. + * @param integer $id Id to look up + * + * @return integer + * + * @since 1.7.0 */ - protected function _getAssetParentId(?Table $table = null, $id = null) + protected function _getAssetParentId(Table $table = null, $id = null) { - $asset = Table::getInstance('Asset'); - $asset->loadByName('com_getbible'); + /** @var Asset $assets */ + $assets = self::getInstance('Asset', 'JTable', ['dbo' => $this->getDbo()]); + $rootId = $assets->getRootId(); - return $asset->id; + // load the getbible asset + $assets->loadByName('com_getbible'); + + return $assets->id ?? $rootId ?? 1; } /** @@ -333,5 +378,4 @@ class GetbibleTableNote extends Table { return false; } - } diff --git a/admin/tables/open_ai_message.php b/admin/src/Table/Open_ai_messageTable.php similarity index 58% rename from admin/tables/open_ai_message.php rename to admin/src/Table/Open_ai_messageTable.php index 6094fbf..d2c2610 100644 --- a/admin/tables/open_ai_message.php +++ b/admin/src/Table/Open_ai_messageTable.php @@ -14,91 +14,106 @@ @license GNU/GPL Version 2 or later - http://www.gnu.org/licenses/gpl-2.0.html /------------------------------------------------------------------------------------------------------*/ +namespace TrueChristianChurch\Component\Getbible\Administrator\Table; // No direct access to this file -defined('_JEXEC') or die('Restricted access'); +\defined('_JEXEC') or die; use Joomla\CMS\Factory; use Joomla\CMS\Table\Table; +use Joomla\CMS\Language\Text; +use Joomla\CMS\String\PunycodeHelper; use Joomla\CMS\Access\Access as AccessRules; use Joomla\CMS\Access\Rules; +use Joomla\CMS\Tag\TaggableTableInterface; +use Joomla\CMS\Tag\TaggableTableTrait; +use Joomla\CMS\User\CurrentUserInterface; +use Joomla\CMS\User\CurrentUserTrait; +use Joomla\CMS\Versioning\VersionableTableInterface; +use Joomla\CMS\Application\ApplicationHelper; +use Joomla\Database\DatabaseInterface; use Joomla\Registry\Registry; +use Joomla\Database\DatabaseDriver; +use Joomla\Event\DispatcherInterface; use Joomla\String\StringHelper; use Joomla\Utilities\ArrayHelper; -use Joomla\CMS\String\PunycodeHelper; -use Joomla\CMS\Table\Observer\Tags as TableObserverTags; -use Joomla\CMS\Table\Observer\ContentHistory as TableObserverContenthistory; -use Joomla\CMS\Application\ApplicationHelper; +use TrueChristianChurch\Component\Getbible\Administrator\Helper\GetbibleHelper; /** * Open_ai_messages Table class */ -class GetbibleTableOpen_ai_message extends Table +class Open_ai_messageTable extends Table implements VersionableTableInterface, TaggableTableInterface, CurrentUserInterface { - /** - * Ensure the params and metadata in json encoded in the bind method - * - * @var array - * @since 3.3 - */ - protected $_jsonEncode = array('params', 'metadata'); - + use TaggableTableTrait; + use CurrentUserTrait; + /** * Constructor * + * @param DatabaseDriver $db Database connector object + * @param ?DispatcherInterface $dispatcher Event dispatcher for this table + * * @param object Database connector object + * @since 4.0 */ - function __construct(&$db) + function __construct(DatabaseDriver $db, ?DispatcherInterface $dispatcher = null) { - parent::__construct('#__getbible_open_ai_message', 'id', $db); + // The type alias generally is the internal component name with the + // content type. Ex.: com_content.article + $this->typeAlias = 'com_getbible.open_ai_message'; - // Adding History Options - TableObserverContenthistory::createObserver($this, array('typeAlias' => 'com_getbible.open_ai_message')); - } - + // Ensure the params and metadata in json encoded in the bind method + $this->_jsonEncode = ['params', 'metadata']; + + // Indicates that columns fully support the NULL value in the database + // $this->_supportNullValue = true; // hmmm will keep an eye on this ;) + + parent::__construct('#__getbible_open_ai_message', 'id', $db, $dispatcher); + } + + /** + * Method to bind an associative array or object to the Table instance.This + * method only binds properties that are publicly accessible and optionally + * takes an array of properties to ignore when binding. + * + * @param array|object $src An associative array or object to bind to the Table instance. + * @param array|string $ignore An optional array or space separated list of properties to ignore while binding. + * + * @return boolean True on success. + * + * @since 1.7.0 + * @throws \InvalidArgumentException + */ public function bind($array, $ignore = '') { - - if (isset($array['params']) && is_array($array['params'])) + // Bind the rules. + if (isset($array['rules']) && is_array($array['rules'])) { - $registry = new Registry; - $registry->loadArray($array['params']); - $array['params'] = (string) $registry; + $rules = new AccessRules($array['rules']); + $this->setRules($rules); } - if (isset($array['metadata']) && is_array($array['metadata'])) - { - $registry = new Registry; - $registry->loadArray($array['metadata']); - $array['metadata'] = (string) $registry; - } - - // Bind the rules. - if (isset($array['rules']) && is_array($array['rules'])) - { - $rules = new AccessRules($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. + * @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 = Factory::getDate(); - $user = Factory::getUser(); + $date = Factory::getDate()->toSql(); + $userId = $this->getCurrentUser()->id; if ($this->id) { // Existing item - $this->modified = $date->toSql(); - $this->modified_by = $user->get('id'); + $this->modified = $date; + $this->modified_by = $userId; } else { @@ -106,31 +121,38 @@ class GetbibleTableOpen_ai_message extends Table // so we don't touch either of these if they are set. if (!(int) $this->created) { - $this->created = $date->toSql(); + $this->created = $date; } if (empty($this->created_by)) { - $this->created_by = $user->get('id'); + $this->created_by = $userId; } } - + if (isset($this->alias)) { // Verify that the alias is unique - $table = Table::getInstance('open_ai_message', 'GetbibleTable'); + $table = new self($this->getDbo(), $this->getDispatcher()); - if ($table->load(array('alias' => $this->alias)) && ($table->id != $this->id || $this->id == 0)) + if ($table->load(['alias' => $this->alias]) && ($table->id != $this->id || $this->id == 0)) { $this->setError(Text::_('COM_GETBIBLE_OPEN_AI_MESSAGE_ERROR_UNIQUE_ALIAS')); + + if ($table->published === -2) + { + $this->setError(Text::_('COM_GETBIBLE_OPEN_AI_MESSAGE_ERROR_UNIQUE_ALIAS_TRASHED')); + } + return false; } } - + if (isset($this->url)) { // Convert IDN urls to punycode $this->url = PunycodeHelper::urlToPunycode($this->url); } + if (isset($this->website)) { // Convert IDN urls to punycode @@ -139,32 +161,42 @@ class GetbibleTableOpen_ai_message extends Table return parent::store($updateNulls); } - + /** * Overloaded check method to ensure data integrity. * * @return boolean True on success. + * + * @see \Joomla\CMS\Table\Table::check + * @since 1.5 */ public function check() { + try { + parent::check(); + } catch (\Exception $e) { + $this->setError($e->getMessage()); + return false; + } + if (isset($this->alias)) { // Generate a valid alias $this->generateAlias(); - - $table = Table::getInstance('open_ai_message', 'getbibleTable'); - while ($table->load(array('alias' => $this->alias)) && ($table->id != $this->id || $this->id == 0)) + $table = new self($this->getDbo(), $this->getDispatcher()); + + while ($table->load(['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. @@ -204,7 +236,7 @@ class GetbibleTableOpen_ai_message extends Table $rules = $this->getDefaultAssetValues('com_getbible.open_ai_message.'.$this->id); $this->setRules($rules); } - + // Set ordering if ($this->published < 0) { @@ -225,7 +257,7 @@ class GetbibleTableOpen_ai_message extends Table protected function getDefaultAssetValues($component, $try = true) { // Need to find the asset id by the name of the component. - $db = Factory::getDbo(); + $db = Factory::getContainer()->get(DatabaseInterface::class); $query = $db->getQuery(true) ->select($db->quoteName('id')) ->from($db->quoteName('#__assets')) @@ -236,7 +268,7 @@ class GetbibleTableOpen_ai_message extends Table { // asset already set so use saved rules $assetId = (int) $db->loadResult(); - return Access::getAssetRules($assetId); // (TODO) instead of keeping inherited Allowed it becomes Allowed. + return AccessRules::getAssetRules($assetId); // (TODO) instead of keeping inherited Allowed it becomes Allowed. } // try again elseif ($try) @@ -278,50 +310,63 @@ class GetbibleTableOpen_ai_message extends Table return $result; } } - return Access::getAssetRules(0); + return AccessRules::getAssetRules(0); + } + + /** + * Get the type alias for the history table + * + * The type alias generally is the internal component name with the + * content type. Ex.: com_content.article + * + * @return string The alias as described above + * + * @since 3.10.0 + */ + public function getTypeAlias() + { + return $this->typeAlias; } /** * Method to compute the default name of the asset. - * The default name is in the form 'table_name.id' + * 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 + * @return string + * + * @since 1.7.0 */ protected function _getAssetName() { $k = $this->_tbl_key; - return 'com_getbible.open_ai_message.'.(int) $this->$k; + + return $this->getTypeAlias() . '.' . (int) $this->$k; } /** - * Method to return the title to use for the asset table. + * Method to get the parent asset under which to register this one. * - * @return string - * @since 2.5 - */ - protected function _getAssetTitle() - { - if (isset($this->title)) - { - return $this->title; - } - return ''; - } - - /** - * Get the parent asset id for the record + * By default, all assets are registered to the ROOT node with ID, which will default to 1 if none exists. + * An extended class can define a table and ID to lookup. If the asset does not exist it will be created. * - * @return int - * @since 2.5 + * @param Table $table A Table object for the asset parent. + * @param integer $id Id to look up + * + * @return integer + * + * @since 1.7.0 */ - protected function _getAssetParentId(?Table $table = null, $id = null) + protected function _getAssetParentId(Table $table = null, $id = null) { - $asset = Table::getInstance('Asset'); - $asset->loadByName('com_getbible'); + /** @var Asset $assets */ + $assets = self::getInstance('Asset', 'JTable', ['dbo' => $this->getDbo()]); + $rootId = $assets->getRootId(); - return $asset->id; + // load the getbible asset + $assets->loadByName('com_getbible'); + + return $assets->id ?? $rootId ?? 1; } /** @@ -333,5 +378,4 @@ class GetbibleTableOpen_ai_message extends Table { return false; } - } diff --git a/admin/tables/open_ai_response.php b/admin/src/Table/Open_ai_responseTable.php similarity index 58% rename from admin/tables/open_ai_response.php rename to admin/src/Table/Open_ai_responseTable.php index 4c87c4e..8cb831e 100644 --- a/admin/tables/open_ai_response.php +++ b/admin/src/Table/Open_ai_responseTable.php @@ -14,91 +14,106 @@ @license GNU/GPL Version 2 or later - http://www.gnu.org/licenses/gpl-2.0.html /------------------------------------------------------------------------------------------------------*/ +namespace TrueChristianChurch\Component\Getbible\Administrator\Table; // No direct access to this file -defined('_JEXEC') or die('Restricted access'); +\defined('_JEXEC') or die; use Joomla\CMS\Factory; use Joomla\CMS\Table\Table; +use Joomla\CMS\Language\Text; +use Joomla\CMS\String\PunycodeHelper; use Joomla\CMS\Access\Access as AccessRules; use Joomla\CMS\Access\Rules; +use Joomla\CMS\Tag\TaggableTableInterface; +use Joomla\CMS\Tag\TaggableTableTrait; +use Joomla\CMS\User\CurrentUserInterface; +use Joomla\CMS\User\CurrentUserTrait; +use Joomla\CMS\Versioning\VersionableTableInterface; +use Joomla\CMS\Application\ApplicationHelper; +use Joomla\Database\DatabaseInterface; use Joomla\Registry\Registry; +use Joomla\Database\DatabaseDriver; +use Joomla\Event\DispatcherInterface; use Joomla\String\StringHelper; use Joomla\Utilities\ArrayHelper; -use Joomla\CMS\String\PunycodeHelper; -use Joomla\CMS\Table\Observer\Tags as TableObserverTags; -use Joomla\CMS\Table\Observer\ContentHistory as TableObserverContenthistory; -use Joomla\CMS\Application\ApplicationHelper; +use TrueChristianChurch\Component\Getbible\Administrator\Helper\GetbibleHelper; /** * Open_ai_responses Table class */ -class GetbibleTableOpen_ai_response extends Table +class Open_ai_responseTable extends Table implements VersionableTableInterface, TaggableTableInterface, CurrentUserInterface { - /** - * Ensure the params and metadata in json encoded in the bind method - * - * @var array - * @since 3.3 - */ - protected $_jsonEncode = array('params', 'metadata'); - + use TaggableTableTrait; + use CurrentUserTrait; + /** * Constructor * + * @param DatabaseDriver $db Database connector object + * @param ?DispatcherInterface $dispatcher Event dispatcher for this table + * * @param object Database connector object + * @since 4.0 */ - function __construct(&$db) + function __construct(DatabaseDriver $db, ?DispatcherInterface $dispatcher = null) { - parent::__construct('#__getbible_open_ai_response', 'id', $db); + // The type alias generally is the internal component name with the + // content type. Ex.: com_content.article + $this->typeAlias = 'com_getbible.open_ai_response'; - // Adding History Options - TableObserverContenthistory::createObserver($this, array('typeAlias' => 'com_getbible.open_ai_response')); - } - + // Ensure the params and metadata in json encoded in the bind method + $this->_jsonEncode = ['params', 'metadata']; + + // Indicates that columns fully support the NULL value in the database + // $this->_supportNullValue = true; // hmmm will keep an eye on this ;) + + parent::__construct('#__getbible_open_ai_response', 'id', $db, $dispatcher); + } + + /** + * Method to bind an associative array or object to the Table instance.This + * method only binds properties that are publicly accessible and optionally + * takes an array of properties to ignore when binding. + * + * @param array|object $src An associative array or object to bind to the Table instance. + * @param array|string $ignore An optional array or space separated list of properties to ignore while binding. + * + * @return boolean True on success. + * + * @since 1.7.0 + * @throws \InvalidArgumentException + */ public function bind($array, $ignore = '') { - - if (isset($array['params']) && is_array($array['params'])) + // Bind the rules. + if (isset($array['rules']) && is_array($array['rules'])) { - $registry = new Registry; - $registry->loadArray($array['params']); - $array['params'] = (string) $registry; + $rules = new AccessRules($array['rules']); + $this->setRules($rules); } - if (isset($array['metadata']) && is_array($array['metadata'])) - { - $registry = new Registry; - $registry->loadArray($array['metadata']); - $array['metadata'] = (string) $registry; - } - - // Bind the rules. - if (isset($array['rules']) && is_array($array['rules'])) - { - $rules = new AccessRules($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. + * @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 = Factory::getDate(); - $user = Factory::getUser(); + $date = Factory::getDate()->toSql(); + $userId = $this->getCurrentUser()->id; if ($this->id) { // Existing item - $this->modified = $date->toSql(); - $this->modified_by = $user->get('id'); + $this->modified = $date; + $this->modified_by = $userId; } else { @@ -106,31 +121,38 @@ class GetbibleTableOpen_ai_response extends Table // so we don't touch either of these if they are set. if (!(int) $this->created) { - $this->created = $date->toSql(); + $this->created = $date; } if (empty($this->created_by)) { - $this->created_by = $user->get('id'); + $this->created_by = $userId; } } - + if (isset($this->alias)) { // Verify that the alias is unique - $table = Table::getInstance('open_ai_response', 'GetbibleTable'); + $table = new self($this->getDbo(), $this->getDispatcher()); - if ($table->load(array('alias' => $this->alias)) && ($table->id != $this->id || $this->id == 0)) + if ($table->load(['alias' => $this->alias]) && ($table->id != $this->id || $this->id == 0)) { $this->setError(Text::_('COM_GETBIBLE_OPEN_AI_RESPONSE_ERROR_UNIQUE_ALIAS')); + + if ($table->published === -2) + { + $this->setError(Text::_('COM_GETBIBLE_OPEN_AI_RESPONSE_ERROR_UNIQUE_ALIAS_TRASHED')); + } + return false; } } - + if (isset($this->url)) { // Convert IDN urls to punycode $this->url = PunycodeHelper::urlToPunycode($this->url); } + if (isset($this->website)) { // Convert IDN urls to punycode @@ -139,32 +161,42 @@ class GetbibleTableOpen_ai_response extends Table return parent::store($updateNulls); } - + /** * Overloaded check method to ensure data integrity. * * @return boolean True on success. + * + * @see \Joomla\CMS\Table\Table::check + * @since 1.5 */ public function check() { + try { + parent::check(); + } catch (\Exception $e) { + $this->setError($e->getMessage()); + return false; + } + if (isset($this->alias)) { // Generate a valid alias $this->generateAlias(); - - $table = Table::getInstance('open_ai_response', 'getbibleTable'); - while ($table->load(array('alias' => $this->alias)) && ($table->id != $this->id || $this->id == 0)) + $table = new self($this->getDbo(), $this->getDispatcher()); + + while ($table->load(['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. @@ -204,7 +236,7 @@ class GetbibleTableOpen_ai_response extends Table $rules = $this->getDefaultAssetValues('com_getbible.open_ai_response.'.$this->id); $this->setRules($rules); } - + // Set ordering if ($this->published < 0) { @@ -225,7 +257,7 @@ class GetbibleTableOpen_ai_response extends Table protected function getDefaultAssetValues($component, $try = true) { // Need to find the asset id by the name of the component. - $db = Factory::getDbo(); + $db = Factory::getContainer()->get(DatabaseInterface::class); $query = $db->getQuery(true) ->select($db->quoteName('id')) ->from($db->quoteName('#__assets')) @@ -236,7 +268,7 @@ class GetbibleTableOpen_ai_response extends Table { // asset already set so use saved rules $assetId = (int) $db->loadResult(); - return Access::getAssetRules($assetId); // (TODO) instead of keeping inherited Allowed it becomes Allowed. + return AccessRules::getAssetRules($assetId); // (TODO) instead of keeping inherited Allowed it becomes Allowed. } // try again elseif ($try) @@ -278,50 +310,63 @@ class GetbibleTableOpen_ai_response extends Table return $result; } } - return Access::getAssetRules(0); + return AccessRules::getAssetRules(0); + } + + /** + * Get the type alias for the history table + * + * The type alias generally is the internal component name with the + * content type. Ex.: com_content.article + * + * @return string The alias as described above + * + * @since 3.10.0 + */ + public function getTypeAlias() + { + return $this->typeAlias; } /** * Method to compute the default name of the asset. - * The default name is in the form 'table_name.id' + * 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 + * @return string + * + * @since 1.7.0 */ protected function _getAssetName() { $k = $this->_tbl_key; - return 'com_getbible.open_ai_response.'.(int) $this->$k; + + return $this->getTypeAlias() . '.' . (int) $this->$k; } /** - * Method to return the title to use for the asset table. + * Method to get the parent asset under which to register this one. * - * @return string - * @since 2.5 - */ - protected function _getAssetTitle() - { - if (isset($this->title)) - { - return $this->title; - } - return ''; - } - - /** - * Get the parent asset id for the record + * By default, all assets are registered to the ROOT node with ID, which will default to 1 if none exists. + * An extended class can define a table and ID to lookup. If the asset does not exist it will be created. * - * @return int - * @since 2.5 + * @param Table $table A Table object for the asset parent. + * @param integer $id Id to look up + * + * @return integer + * + * @since 1.7.0 */ - protected function _getAssetParentId(?Table $table = null, $id = null) + protected function _getAssetParentId(Table $table = null, $id = null) { - $asset = Table::getInstance('Asset'); - $asset->loadByName('com_getbible'); + /** @var Asset $assets */ + $assets = self::getInstance('Asset', 'JTable', ['dbo' => $this->getDbo()]); + $rootId = $assets->getRootId(); - return $asset->id; + // load the getbible asset + $assets->loadByName('com_getbible'); + + return $assets->id ?? $rootId ?? 1; } /** @@ -333,5 +378,4 @@ class GetbibleTableOpen_ai_response extends Table { return false; } - } diff --git a/admin/tables/password.php b/admin/src/Table/PasswordTable.php similarity index 58% rename from admin/tables/password.php rename to admin/src/Table/PasswordTable.php index cc8cb45..77d5dfc 100644 --- a/admin/tables/password.php +++ b/admin/src/Table/PasswordTable.php @@ -14,88 +14,106 @@ @license GNU/GPL Version 2 or later - http://www.gnu.org/licenses/gpl-2.0.html /------------------------------------------------------------------------------------------------------*/ +namespace TrueChristianChurch\Component\Getbible\Administrator\Table; // No direct access to this file -defined('_JEXEC') or die('Restricted access'); +\defined('_JEXEC') or die; use Joomla\CMS\Factory; use Joomla\CMS\Table\Table; +use Joomla\CMS\Language\Text; +use Joomla\CMS\String\PunycodeHelper; use Joomla\CMS\Access\Access as AccessRules; use Joomla\CMS\Access\Rules; +use Joomla\CMS\Tag\TaggableTableInterface; +use Joomla\CMS\Tag\TaggableTableTrait; +use Joomla\CMS\User\CurrentUserInterface; +use Joomla\CMS\User\CurrentUserTrait; +use Joomla\CMS\Versioning\VersionableTableInterface; +use Joomla\CMS\Application\ApplicationHelper; +use Joomla\Database\DatabaseInterface; use Joomla\Registry\Registry; +use Joomla\Database\DatabaseDriver; +use Joomla\Event\DispatcherInterface; use Joomla\String\StringHelper; use Joomla\Utilities\ArrayHelper; -use Joomla\CMS\String\PunycodeHelper; -use Joomla\CMS\Table\Observer\Tags as TableObserverTags; -use Joomla\CMS\Table\Observer\ContentHistory as TableObserverContenthistory; -use Joomla\CMS\Application\ApplicationHelper; +use TrueChristianChurch\Component\Getbible\Administrator\Helper\GetbibleHelper; /** * Passwords Table class */ -class GetbibleTablePassword extends Table +class PasswordTable extends Table implements VersionableTableInterface, TaggableTableInterface, CurrentUserInterface { - /** - * Ensure the params and metadata in json encoded in the bind method - * - * @var array - * @since 3.3 - */ - protected $_jsonEncode = array('params', 'metadata'); - + use TaggableTableTrait; + use CurrentUserTrait; + /** * Constructor * + * @param DatabaseDriver $db Database connector object + * @param ?DispatcherInterface $dispatcher Event dispatcher for this table + * * @param object Database connector object + * @since 4.0 */ - function __construct(&$db) + function __construct(DatabaseDriver $db, ?DispatcherInterface $dispatcher = null) { - parent::__construct('#__getbible_password', 'id', $db); - } - + // The type alias generally is the internal component name with the + // content type. Ex.: com_content.article + $this->typeAlias = 'com_getbible.password'; + + // Ensure the params and metadata in json encoded in the bind method + $this->_jsonEncode = ['params', 'metadata']; + + // Indicates that columns fully support the NULL value in the database + // $this->_supportNullValue = true; // hmmm will keep an eye on this ;) + + parent::__construct('#__getbible_password', 'id', $db, $dispatcher); + } + + /** + * Method to bind an associative array or object to the Table instance.This + * method only binds properties that are publicly accessible and optionally + * takes an array of properties to ignore when binding. + * + * @param array|object $src An associative array or object to bind to the Table instance. + * @param array|string $ignore An optional array or space separated list of properties to ignore while binding. + * + * @return boolean True on success. + * + * @since 1.7.0 + * @throws \InvalidArgumentException + */ public function bind($array, $ignore = '') { - - if (isset($array['params']) && is_array($array['params'])) + // Bind the rules. + if (isset($array['rules']) && is_array($array['rules'])) { - $registry = new Registry; - $registry->loadArray($array['params']); - $array['params'] = (string) $registry; + $rules = new AccessRules($array['rules']); + $this->setRules($rules); } - if (isset($array['metadata']) && is_array($array['metadata'])) - { - $registry = new Registry; - $registry->loadArray($array['metadata']); - $array['metadata'] = (string) $registry; - } - - // Bind the rules. - if (isset($array['rules']) && is_array($array['rules'])) - { - $rules = new AccessRules($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. + * @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 = Factory::getDate(); - $user = Factory::getUser(); + $date = Factory::getDate()->toSql(); + $userId = $this->getCurrentUser()->id; if ($this->id) { // Existing item - $this->modified = $date->toSql(); - $this->modified_by = $user->get('id'); + $this->modified = $date; + $this->modified_by = $userId; } else { @@ -103,31 +121,38 @@ class GetbibleTablePassword extends Table // so we don't touch either of these if they are set. if (!(int) $this->created) { - $this->created = $date->toSql(); + $this->created = $date; } if (empty($this->created_by)) { - $this->created_by = $user->get('id'); + $this->created_by = $userId; } } - + if (isset($this->alias)) { // Verify that the alias is unique - $table = Table::getInstance('password', 'GetbibleTable'); + $table = new self($this->getDbo(), $this->getDispatcher()); - if ($table->load(array('alias' => $this->alias)) && ($table->id != $this->id || $this->id == 0)) + if ($table->load(['alias' => $this->alias]) && ($table->id != $this->id || $this->id == 0)) { $this->setError(Text::_('COM_GETBIBLE_PASSWORD_ERROR_UNIQUE_ALIAS')); + + if ($table->published === -2) + { + $this->setError(Text::_('COM_GETBIBLE_PASSWORD_ERROR_UNIQUE_ALIAS_TRASHED')); + } + return false; } } - + if (isset($this->url)) { // Convert IDN urls to punycode $this->url = PunycodeHelper::urlToPunycode($this->url); } + if (isset($this->website)) { // Convert IDN urls to punycode @@ -136,32 +161,42 @@ class GetbibleTablePassword extends Table return parent::store($updateNulls); } - + /** * Overloaded check method to ensure data integrity. * * @return boolean True on success. + * + * @see \Joomla\CMS\Table\Table::check + * @since 1.5 */ public function check() { + try { + parent::check(); + } catch (\Exception $e) { + $this->setError($e->getMessage()); + return false; + } + if (isset($this->alias)) { // Generate a valid alias $this->generateAlias(); - - $table = Table::getInstance('password', 'getbibleTable'); - while ($table->load(array('alias' => $this->alias)) && ($table->id != $this->id || $this->id == 0)) + $table = new self($this->getDbo(), $this->getDispatcher()); + + while ($table->load(['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. @@ -201,7 +236,7 @@ class GetbibleTablePassword extends Table $rules = $this->getDefaultAssetValues('com_getbible.password.'.$this->id); $this->setRules($rules); } - + // Set ordering if ($this->published < 0) { @@ -222,7 +257,7 @@ class GetbibleTablePassword extends Table protected function getDefaultAssetValues($component, $try = true) { // Need to find the asset id by the name of the component. - $db = Factory::getDbo(); + $db = Factory::getContainer()->get(DatabaseInterface::class); $query = $db->getQuery(true) ->select($db->quoteName('id')) ->from($db->quoteName('#__assets')) @@ -233,7 +268,7 @@ class GetbibleTablePassword extends Table { // asset already set so use saved rules $assetId = (int) $db->loadResult(); - return Access::getAssetRules($assetId); // (TODO) instead of keeping inherited Allowed it becomes Allowed. + return AccessRules::getAssetRules($assetId); // (TODO) instead of keeping inherited Allowed it becomes Allowed. } // try again elseif ($try) @@ -275,50 +310,63 @@ class GetbibleTablePassword extends Table return $result; } } - return Access::getAssetRules(0); + return AccessRules::getAssetRules(0); + } + + /** + * Get the type alias for the history table + * + * The type alias generally is the internal component name with the + * content type. Ex.: com_content.article + * + * @return string The alias as described above + * + * @since 3.10.0 + */ + public function getTypeAlias() + { + return $this->typeAlias; } /** * Method to compute the default name of the asset. - * The default name is in the form 'table_name.id' + * 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 + * @return string + * + * @since 1.7.0 */ protected function _getAssetName() { $k = $this->_tbl_key; - return 'com_getbible.password.'.(int) $this->$k; + + return $this->getTypeAlias() . '.' . (int) $this->$k; } /** - * Method to return the title to use for the asset table. + * Method to get the parent asset under which to register this one. * - * @return string - * @since 2.5 - */ - protected function _getAssetTitle() - { - if (isset($this->title)) - { - return $this->title; - } - return ''; - } - - /** - * Get the parent asset id for the record + * By default, all assets are registered to the ROOT node with ID, which will default to 1 if none exists. + * An extended class can define a table and ID to lookup. If the asset does not exist it will be created. * - * @return int - * @since 2.5 + * @param Table $table A Table object for the asset parent. + * @param integer $id Id to look up + * + * @return integer + * + * @since 1.7.0 */ - protected function _getAssetParentId(?Table $table = null, $id = null) + protected function _getAssetParentId(Table $table = null, $id = null) { - $asset = Table::getInstance('Asset'); - $asset->loadByName('com_getbible'); + /** @var Asset $assets */ + $assets = self::getInstance('Asset', 'JTable', ['dbo' => $this->getDbo()]); + $rootId = $assets->getRootId(); - return $asset->id; + // load the getbible asset + $assets->loadByName('com_getbible'); + + return $assets->id ?? $rootId ?? 1; } /** @@ -330,5 +378,4 @@ class GetbibleTablePassword extends Table { return false; } - } diff --git a/admin/tables/prompt.php b/admin/src/Table/PromptTable.php similarity index 58% rename from admin/tables/prompt.php rename to admin/src/Table/PromptTable.php index 3f4bbdf..3b43941 100644 --- a/admin/tables/prompt.php +++ b/admin/src/Table/PromptTable.php @@ -14,91 +14,106 @@ @license GNU/GPL Version 2 or later - http://www.gnu.org/licenses/gpl-2.0.html /------------------------------------------------------------------------------------------------------*/ +namespace TrueChristianChurch\Component\Getbible\Administrator\Table; // No direct access to this file -defined('_JEXEC') or die('Restricted access'); +\defined('_JEXEC') or die; use Joomla\CMS\Factory; use Joomla\CMS\Table\Table; +use Joomla\CMS\Language\Text; +use Joomla\CMS\String\PunycodeHelper; use Joomla\CMS\Access\Access as AccessRules; use Joomla\CMS\Access\Rules; +use Joomla\CMS\Tag\TaggableTableInterface; +use Joomla\CMS\Tag\TaggableTableTrait; +use Joomla\CMS\User\CurrentUserInterface; +use Joomla\CMS\User\CurrentUserTrait; +use Joomla\CMS\Versioning\VersionableTableInterface; +use Joomla\CMS\Application\ApplicationHelper; +use Joomla\Database\DatabaseInterface; use Joomla\Registry\Registry; +use Joomla\Database\DatabaseDriver; +use Joomla\Event\DispatcherInterface; use Joomla\String\StringHelper; use Joomla\Utilities\ArrayHelper; -use Joomla\CMS\String\PunycodeHelper; -use Joomla\CMS\Table\Observer\Tags as TableObserverTags; -use Joomla\CMS\Table\Observer\ContentHistory as TableObserverContenthistory; -use Joomla\CMS\Application\ApplicationHelper; +use TrueChristianChurch\Component\Getbible\Administrator\Helper\GetbibleHelper; /** * Prompts Table class */ -class GetbibleTablePrompt extends Table +class PromptTable extends Table implements VersionableTableInterface, TaggableTableInterface, CurrentUserInterface { - /** - * Ensure the params and metadata in json encoded in the bind method - * - * @var array - * @since 3.3 - */ - protected $_jsonEncode = array('params', 'metadata'); - + use TaggableTableTrait; + use CurrentUserTrait; + /** * Constructor * + * @param DatabaseDriver $db Database connector object + * @param ?DispatcherInterface $dispatcher Event dispatcher for this table + * * @param object Database connector object + * @since 4.0 */ - function __construct(&$db) + function __construct(DatabaseDriver $db, ?DispatcherInterface $dispatcher = null) { - parent::__construct('#__getbible_prompt', 'id', $db); + // The type alias generally is the internal component name with the + // content type. Ex.: com_content.article + $this->typeAlias = 'com_getbible.prompt'; - // Adding History Options - TableObserverContenthistory::createObserver($this, array('typeAlias' => 'com_getbible.prompt')); - } - + // Ensure the params and metadata in json encoded in the bind method + $this->_jsonEncode = ['params', 'metadata']; + + // Indicates that columns fully support the NULL value in the database + // $this->_supportNullValue = true; // hmmm will keep an eye on this ;) + + parent::__construct('#__getbible_prompt', 'id', $db, $dispatcher); + } + + /** + * Method to bind an associative array or object to the Table instance.This + * method only binds properties that are publicly accessible and optionally + * takes an array of properties to ignore when binding. + * + * @param array|object $src An associative array or object to bind to the Table instance. + * @param array|string $ignore An optional array or space separated list of properties to ignore while binding. + * + * @return boolean True on success. + * + * @since 1.7.0 + * @throws \InvalidArgumentException + */ public function bind($array, $ignore = '') { - - if (isset($array['params']) && is_array($array['params'])) + // Bind the rules. + if (isset($array['rules']) && is_array($array['rules'])) { - $registry = new Registry; - $registry->loadArray($array['params']); - $array['params'] = (string) $registry; + $rules = new AccessRules($array['rules']); + $this->setRules($rules); } - if (isset($array['metadata']) && is_array($array['metadata'])) - { - $registry = new Registry; - $registry->loadArray($array['metadata']); - $array['metadata'] = (string) $registry; - } - - // Bind the rules. - if (isset($array['rules']) && is_array($array['rules'])) - { - $rules = new AccessRules($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. + * @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 = Factory::getDate(); - $user = Factory::getUser(); + $date = Factory::getDate()->toSql(); + $userId = $this->getCurrentUser()->id; if ($this->id) { // Existing item - $this->modified = $date->toSql(); - $this->modified_by = $user->get('id'); + $this->modified = $date; + $this->modified_by = $userId; } else { @@ -106,31 +121,38 @@ class GetbibleTablePrompt extends Table // so we don't touch either of these if they are set. if (!(int) $this->created) { - $this->created = $date->toSql(); + $this->created = $date; } if (empty($this->created_by)) { - $this->created_by = $user->get('id'); + $this->created_by = $userId; } } - + if (isset($this->alias)) { // Verify that the alias is unique - $table = Table::getInstance('prompt', 'GetbibleTable'); + $table = new self($this->getDbo(), $this->getDispatcher()); - if ($table->load(array('alias' => $this->alias)) && ($table->id != $this->id || $this->id == 0)) + if ($table->load(['alias' => $this->alias]) && ($table->id != $this->id || $this->id == 0)) { $this->setError(Text::_('COM_GETBIBLE_PROMPT_ERROR_UNIQUE_ALIAS')); + + if ($table->published === -2) + { + $this->setError(Text::_('COM_GETBIBLE_PROMPT_ERROR_UNIQUE_ALIAS_TRASHED')); + } + return false; } } - + if (isset($this->url)) { // Convert IDN urls to punycode $this->url = PunycodeHelper::urlToPunycode($this->url); } + if (isset($this->website)) { // Convert IDN urls to punycode @@ -139,32 +161,42 @@ class GetbibleTablePrompt extends Table return parent::store($updateNulls); } - + /** * Overloaded check method to ensure data integrity. * * @return boolean True on success. + * + * @see \Joomla\CMS\Table\Table::check + * @since 1.5 */ public function check() { + try { + parent::check(); + } catch (\Exception $e) { + $this->setError($e->getMessage()); + return false; + } + if (isset($this->alias)) { // Generate a valid alias $this->generateAlias(); - - $table = Table::getInstance('prompt', 'getbibleTable'); - while ($table->load(array('alias' => $this->alias)) && ($table->id != $this->id || $this->id == 0)) + $table = new self($this->getDbo(), $this->getDispatcher()); + + while ($table->load(['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. @@ -204,7 +236,7 @@ class GetbibleTablePrompt extends Table $rules = $this->getDefaultAssetValues('com_getbible.prompt.'.$this->id); $this->setRules($rules); } - + // Set ordering if ($this->published < 0) { @@ -225,7 +257,7 @@ class GetbibleTablePrompt extends Table protected function getDefaultAssetValues($component, $try = true) { // Need to find the asset id by the name of the component. - $db = Factory::getDbo(); + $db = Factory::getContainer()->get(DatabaseInterface::class); $query = $db->getQuery(true) ->select($db->quoteName('id')) ->from($db->quoteName('#__assets')) @@ -236,7 +268,7 @@ class GetbibleTablePrompt extends Table { // asset already set so use saved rules $assetId = (int) $db->loadResult(); - return Access::getAssetRules($assetId); // (TODO) instead of keeping inherited Allowed it becomes Allowed. + return AccessRules::getAssetRules($assetId); // (TODO) instead of keeping inherited Allowed it becomes Allowed. } // try again elseif ($try) @@ -278,50 +310,63 @@ class GetbibleTablePrompt extends Table return $result; } } - return Access::getAssetRules(0); + return AccessRules::getAssetRules(0); + } + + /** + * Get the type alias for the history table + * + * The type alias generally is the internal component name with the + * content type. Ex.: com_content.article + * + * @return string The alias as described above + * + * @since 3.10.0 + */ + public function getTypeAlias() + { + return $this->typeAlias; } /** * Method to compute the default name of the asset. - * The default name is in the form 'table_name.id' + * 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 + * @return string + * + * @since 1.7.0 */ protected function _getAssetName() { $k = $this->_tbl_key; - return 'com_getbible.prompt.'.(int) $this->$k; + + return $this->getTypeAlias() . '.' . (int) $this->$k; } /** - * Method to return the title to use for the asset table. + * Method to get the parent asset under which to register this one. * - * @return string - * @since 2.5 - */ - protected function _getAssetTitle() - { - if (isset($this->title)) - { - return $this->title; - } - return ''; - } - - /** - * Get the parent asset id for the record + * By default, all assets are registered to the ROOT node with ID, which will default to 1 if none exists. + * An extended class can define a table and ID to lookup. If the asset does not exist it will be created. * - * @return int - * @since 2.5 + * @param Table $table A Table object for the asset parent. + * @param integer $id Id to look up + * + * @return integer + * + * @since 1.7.0 */ - protected function _getAssetParentId(?Table $table = null, $id = null) + protected function _getAssetParentId(Table $table = null, $id = null) { - $asset = Table::getInstance('Asset'); - $asset->loadByName('com_getbible'); + /** @var Asset $assets */ + $assets = self::getInstance('Asset', 'JTable', ['dbo' => $this->getDbo()]); + $rootId = $assets->getRootId(); - return $asset->id; + // load the getbible asset + $assets->loadByName('com_getbible'); + + return $assets->id ?? $rootId ?? 1; } /** @@ -333,5 +378,4 @@ class GetbibleTablePrompt extends Table { return false; } - } diff --git a/admin/tables/tag.php b/admin/src/Table/TagTable.php similarity index 58% rename from admin/tables/tag.php rename to admin/src/Table/TagTable.php index 7da97fd..e6dccd4 100644 --- a/admin/tables/tag.php +++ b/admin/src/Table/TagTable.php @@ -14,91 +14,106 @@ @license GNU/GPL Version 2 or later - http://www.gnu.org/licenses/gpl-2.0.html /------------------------------------------------------------------------------------------------------*/ +namespace TrueChristianChurch\Component\Getbible\Administrator\Table; // No direct access to this file -defined('_JEXEC') or die('Restricted access'); +\defined('_JEXEC') or die; use Joomla\CMS\Factory; use Joomla\CMS\Table\Table; +use Joomla\CMS\Language\Text; +use Joomla\CMS\String\PunycodeHelper; use Joomla\CMS\Access\Access as AccessRules; use Joomla\CMS\Access\Rules; +use Joomla\CMS\Tag\TaggableTableInterface; +use Joomla\CMS\Tag\TaggableTableTrait; +use Joomla\CMS\User\CurrentUserInterface; +use Joomla\CMS\User\CurrentUserTrait; +use Joomla\CMS\Versioning\VersionableTableInterface; +use Joomla\CMS\Application\ApplicationHelper; +use Joomla\Database\DatabaseInterface; use Joomla\Registry\Registry; +use Joomla\Database\DatabaseDriver; +use Joomla\Event\DispatcherInterface; use Joomla\String\StringHelper; use Joomla\Utilities\ArrayHelper; -use Joomla\CMS\String\PunycodeHelper; -use Joomla\CMS\Table\Observer\Tags as TableObserverTags; -use Joomla\CMS\Table\Observer\ContentHistory as TableObserverContenthistory; -use Joomla\CMS\Application\ApplicationHelper; +use TrueChristianChurch\Component\Getbible\Administrator\Helper\GetbibleHelper; /** * Tags Table class */ -class GetbibleTableTag extends Table +class TagTable extends Table implements VersionableTableInterface, TaggableTableInterface, CurrentUserInterface { - /** - * Ensure the params and metadata in json encoded in the bind method - * - * @var array - * @since 3.3 - */ - protected $_jsonEncode = array('params', 'metadata'); - + use TaggableTableTrait; + use CurrentUserTrait; + /** * Constructor * + * @param DatabaseDriver $db Database connector object + * @param ?DispatcherInterface $dispatcher Event dispatcher for this table + * * @param object Database connector object + * @since 4.0 */ - function __construct(&$db) + function __construct(DatabaseDriver $db, ?DispatcherInterface $dispatcher = null) { - parent::__construct('#__getbible_tag', 'id', $db); + // The type alias generally is the internal component name with the + // content type. Ex.: com_content.article + $this->typeAlias = 'com_getbible.tag'; - // Adding History Options - TableObserverContenthistory::createObserver($this, array('typeAlias' => 'com_getbible.tag')); - } - + // Ensure the params and metadata in json encoded in the bind method + $this->_jsonEncode = ['params', 'metadata']; + + // Indicates that columns fully support the NULL value in the database + // $this->_supportNullValue = true; // hmmm will keep an eye on this ;) + + parent::__construct('#__getbible_tag', 'id', $db, $dispatcher); + } + + /** + * Method to bind an associative array or object to the Table instance.This + * method only binds properties that are publicly accessible and optionally + * takes an array of properties to ignore when binding. + * + * @param array|object $src An associative array or object to bind to the Table instance. + * @param array|string $ignore An optional array or space separated list of properties to ignore while binding. + * + * @return boolean True on success. + * + * @since 1.7.0 + * @throws \InvalidArgumentException + */ public function bind($array, $ignore = '') { - - if (isset($array['params']) && is_array($array['params'])) + // Bind the rules. + if (isset($array['rules']) && is_array($array['rules'])) { - $registry = new Registry; - $registry->loadArray($array['params']); - $array['params'] = (string) $registry; + $rules = new AccessRules($array['rules']); + $this->setRules($rules); } - if (isset($array['metadata']) && is_array($array['metadata'])) - { - $registry = new Registry; - $registry->loadArray($array['metadata']); - $array['metadata'] = (string) $registry; - } - - // Bind the rules. - if (isset($array['rules']) && is_array($array['rules'])) - { - $rules = new AccessRules($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. + * @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 = Factory::getDate(); - $user = Factory::getUser(); + $date = Factory::getDate()->toSql(); + $userId = $this->getCurrentUser()->id; if ($this->id) { // Existing item - $this->modified = $date->toSql(); - $this->modified_by = $user->get('id'); + $this->modified = $date; + $this->modified_by = $userId; } else { @@ -106,31 +121,38 @@ class GetbibleTableTag extends Table // so we don't touch either of these if they are set. if (!(int) $this->created) { - $this->created = $date->toSql(); + $this->created = $date; } if (empty($this->created_by)) { - $this->created_by = $user->get('id'); + $this->created_by = $userId; } } - + if (isset($this->alias)) { // Verify that the alias is unique - $table = Table::getInstance('tag', 'GetbibleTable'); + $table = new self($this->getDbo(), $this->getDispatcher()); - if ($table->load(array('alias' => $this->alias)) && ($table->id != $this->id || $this->id == 0)) + if ($table->load(['alias' => $this->alias]) && ($table->id != $this->id || $this->id == 0)) { $this->setError(Text::_('COM_GETBIBLE_TAG_ERROR_UNIQUE_ALIAS')); + + if ($table->published === -2) + { + $this->setError(Text::_('COM_GETBIBLE_TAG_ERROR_UNIQUE_ALIAS_TRASHED')); + } + return false; } } - + if (isset($this->url)) { // Convert IDN urls to punycode $this->url = PunycodeHelper::urlToPunycode($this->url); } + if (isset($this->website)) { // Convert IDN urls to punycode @@ -139,32 +161,42 @@ class GetbibleTableTag extends Table return parent::store($updateNulls); } - + /** * Overloaded check method to ensure data integrity. * * @return boolean True on success. + * + * @see \Joomla\CMS\Table\Table::check + * @since 1.5 */ public function check() { + try { + parent::check(); + } catch (\Exception $e) { + $this->setError($e->getMessage()); + return false; + } + if (isset($this->alias)) { // Generate a valid alias $this->generateAlias(); - - $table = Table::getInstance('tag', 'getbibleTable'); - while ($table->load(array('alias' => $this->alias)) && ($table->id != $this->id || $this->id == 0)) + $table = new self($this->getDbo(), $this->getDispatcher()); + + while ($table->load(['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. @@ -204,7 +236,7 @@ class GetbibleTableTag extends Table $rules = $this->getDefaultAssetValues('com_getbible.tag.'.$this->id); $this->setRules($rules); } - + // Set ordering if ($this->published < 0) { @@ -225,7 +257,7 @@ class GetbibleTableTag extends Table protected function getDefaultAssetValues($component, $try = true) { // Need to find the asset id by the name of the component. - $db = Factory::getDbo(); + $db = Factory::getContainer()->get(DatabaseInterface::class); $query = $db->getQuery(true) ->select($db->quoteName('id')) ->from($db->quoteName('#__assets')) @@ -236,7 +268,7 @@ class GetbibleTableTag extends Table { // asset already set so use saved rules $assetId = (int) $db->loadResult(); - return Access::getAssetRules($assetId); // (TODO) instead of keeping inherited Allowed it becomes Allowed. + return AccessRules::getAssetRules($assetId); // (TODO) instead of keeping inherited Allowed it becomes Allowed. } // try again elseif ($try) @@ -278,50 +310,63 @@ class GetbibleTableTag extends Table return $result; } } - return Access::getAssetRules(0); + return AccessRules::getAssetRules(0); + } + + /** + * Get the type alias for the history table + * + * The type alias generally is the internal component name with the + * content type. Ex.: com_content.article + * + * @return string The alias as described above + * + * @since 3.10.0 + */ + public function getTypeAlias() + { + return $this->typeAlias; } /** * Method to compute the default name of the asset. - * The default name is in the form 'table_name.id' + * 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 + * @return string + * + * @since 1.7.0 */ protected function _getAssetName() { $k = $this->_tbl_key; - return 'com_getbible.tag.'.(int) $this->$k; + + return $this->getTypeAlias() . '.' . (int) $this->$k; } /** - * Method to return the title to use for the asset table. + * Method to get the parent asset under which to register this one. * - * @return string - * @since 2.5 - */ - protected function _getAssetTitle() - { - if (isset($this->title)) - { - return $this->title; - } - return ''; - } - - /** - * Get the parent asset id for the record + * By default, all assets are registered to the ROOT node with ID, which will default to 1 if none exists. + * An extended class can define a table and ID to lookup. If the asset does not exist it will be created. * - * @return int - * @since 2.5 + * @param Table $table A Table object for the asset parent. + * @param integer $id Id to look up + * + * @return integer + * + * @since 1.7.0 */ - protected function _getAssetParentId(?Table $table = null, $id = null) + protected function _getAssetParentId(Table $table = null, $id = null) { - $asset = Table::getInstance('Asset'); - $asset->loadByName('com_getbible'); + /** @var Asset $assets */ + $assets = self::getInstance('Asset', 'JTable', ['dbo' => $this->getDbo()]); + $rootId = $assets->getRootId(); - return $asset->id; + // load the getbible asset + $assets->loadByName('com_getbible'); + + return $assets->id ?? $rootId ?? 1; } /** @@ -333,5 +378,4 @@ class GetbibleTableTag extends Table { return false; } - } diff --git a/admin/tables/tagged_verse.php b/admin/src/Table/Tagged_verseTable.php similarity index 58% rename from admin/tables/tagged_verse.php rename to admin/src/Table/Tagged_verseTable.php index 045626e..fa43aab 100644 --- a/admin/tables/tagged_verse.php +++ b/admin/src/Table/Tagged_verseTable.php @@ -14,91 +14,106 @@ @license GNU/GPL Version 2 or later - http://www.gnu.org/licenses/gpl-2.0.html /------------------------------------------------------------------------------------------------------*/ +namespace TrueChristianChurch\Component\Getbible\Administrator\Table; // No direct access to this file -defined('_JEXEC') or die('Restricted access'); +\defined('_JEXEC') or die; use Joomla\CMS\Factory; use Joomla\CMS\Table\Table; +use Joomla\CMS\Language\Text; +use Joomla\CMS\String\PunycodeHelper; use Joomla\CMS\Access\Access as AccessRules; use Joomla\CMS\Access\Rules; +use Joomla\CMS\Tag\TaggableTableInterface; +use Joomla\CMS\Tag\TaggableTableTrait; +use Joomla\CMS\User\CurrentUserInterface; +use Joomla\CMS\User\CurrentUserTrait; +use Joomla\CMS\Versioning\VersionableTableInterface; +use Joomla\CMS\Application\ApplicationHelper; +use Joomla\Database\DatabaseInterface; use Joomla\Registry\Registry; +use Joomla\Database\DatabaseDriver; +use Joomla\Event\DispatcherInterface; use Joomla\String\StringHelper; use Joomla\Utilities\ArrayHelper; -use Joomla\CMS\String\PunycodeHelper; -use Joomla\CMS\Table\Observer\Tags as TableObserverTags; -use Joomla\CMS\Table\Observer\ContentHistory as TableObserverContenthistory; -use Joomla\CMS\Application\ApplicationHelper; +use TrueChristianChurch\Component\Getbible\Administrator\Helper\GetbibleHelper; /** * Tagged_verses Table class */ -class GetbibleTableTagged_verse extends Table +class Tagged_verseTable extends Table implements VersionableTableInterface, TaggableTableInterface, CurrentUserInterface { - /** - * Ensure the params and metadata in json encoded in the bind method - * - * @var array - * @since 3.3 - */ - protected $_jsonEncode = array('params', 'metadata'); - + use TaggableTableTrait; + use CurrentUserTrait; + /** * Constructor * + * @param DatabaseDriver $db Database connector object + * @param ?DispatcherInterface $dispatcher Event dispatcher for this table + * * @param object Database connector object + * @since 4.0 */ - function __construct(&$db) + function __construct(DatabaseDriver $db, ?DispatcherInterface $dispatcher = null) { - parent::__construct('#__getbible_tagged_verse', 'id', $db); + // The type alias generally is the internal component name with the + // content type. Ex.: com_content.article + $this->typeAlias = 'com_getbible.tagged_verse'; - // Adding History Options - TableObserverContenthistory::createObserver($this, array('typeAlias' => 'com_getbible.tagged_verse')); - } - + // Ensure the params and metadata in json encoded in the bind method + $this->_jsonEncode = ['params', 'metadata']; + + // Indicates that columns fully support the NULL value in the database + // $this->_supportNullValue = true; // hmmm will keep an eye on this ;) + + parent::__construct('#__getbible_tagged_verse', 'id', $db, $dispatcher); + } + + /** + * Method to bind an associative array or object to the Table instance.This + * method only binds properties that are publicly accessible and optionally + * takes an array of properties to ignore when binding. + * + * @param array|object $src An associative array or object to bind to the Table instance. + * @param array|string $ignore An optional array or space separated list of properties to ignore while binding. + * + * @return boolean True on success. + * + * @since 1.7.0 + * @throws \InvalidArgumentException + */ public function bind($array, $ignore = '') { - - if (isset($array['params']) && is_array($array['params'])) + // Bind the rules. + if (isset($array['rules']) && is_array($array['rules'])) { - $registry = new Registry; - $registry->loadArray($array['params']); - $array['params'] = (string) $registry; + $rules = new AccessRules($array['rules']); + $this->setRules($rules); } - if (isset($array['metadata']) && is_array($array['metadata'])) - { - $registry = new Registry; - $registry->loadArray($array['metadata']); - $array['metadata'] = (string) $registry; - } - - // Bind the rules. - if (isset($array['rules']) && is_array($array['rules'])) - { - $rules = new AccessRules($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. + * @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 = Factory::getDate(); - $user = Factory::getUser(); + $date = Factory::getDate()->toSql(); + $userId = $this->getCurrentUser()->id; if ($this->id) { // Existing item - $this->modified = $date->toSql(); - $this->modified_by = $user->get('id'); + $this->modified = $date; + $this->modified_by = $userId; } else { @@ -106,31 +121,38 @@ class GetbibleTableTagged_verse extends Table // so we don't touch either of these if they are set. if (!(int) $this->created) { - $this->created = $date->toSql(); + $this->created = $date; } if (empty($this->created_by)) { - $this->created_by = $user->get('id'); + $this->created_by = $userId; } } - + if (isset($this->alias)) { // Verify that the alias is unique - $table = Table::getInstance('tagged_verse', 'GetbibleTable'); + $table = new self($this->getDbo(), $this->getDispatcher()); - if ($table->load(array('alias' => $this->alias)) && ($table->id != $this->id || $this->id == 0)) + if ($table->load(['alias' => $this->alias]) && ($table->id != $this->id || $this->id == 0)) { $this->setError(Text::_('COM_GETBIBLE_TAGGED_VERSE_ERROR_UNIQUE_ALIAS')); + + if ($table->published === -2) + { + $this->setError(Text::_('COM_GETBIBLE_TAGGED_VERSE_ERROR_UNIQUE_ALIAS_TRASHED')); + } + return false; } } - + if (isset($this->url)) { // Convert IDN urls to punycode $this->url = PunycodeHelper::urlToPunycode($this->url); } + if (isset($this->website)) { // Convert IDN urls to punycode @@ -139,32 +161,42 @@ class GetbibleTableTagged_verse extends Table return parent::store($updateNulls); } - + /** * Overloaded check method to ensure data integrity. * * @return boolean True on success. + * + * @see \Joomla\CMS\Table\Table::check + * @since 1.5 */ public function check() { + try { + parent::check(); + } catch (\Exception $e) { + $this->setError($e->getMessage()); + return false; + } + if (isset($this->alias)) { // Generate a valid alias $this->generateAlias(); - - $table = Table::getInstance('tagged_verse', 'getbibleTable'); - while ($table->load(array('alias' => $this->alias)) && ($table->id != $this->id || $this->id == 0)) + $table = new self($this->getDbo(), $this->getDispatcher()); + + while ($table->load(['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. @@ -204,7 +236,7 @@ class GetbibleTableTagged_verse extends Table $rules = $this->getDefaultAssetValues('com_getbible.tagged_verse.'.$this->id); $this->setRules($rules); } - + // Set ordering if ($this->published < 0) { @@ -225,7 +257,7 @@ class GetbibleTableTagged_verse extends Table protected function getDefaultAssetValues($component, $try = true) { // Need to find the asset id by the name of the component. - $db = Factory::getDbo(); + $db = Factory::getContainer()->get(DatabaseInterface::class); $query = $db->getQuery(true) ->select($db->quoteName('id')) ->from($db->quoteName('#__assets')) @@ -236,7 +268,7 @@ class GetbibleTableTagged_verse extends Table { // asset already set so use saved rules $assetId = (int) $db->loadResult(); - return Access::getAssetRules($assetId); // (TODO) instead of keeping inherited Allowed it becomes Allowed. + return AccessRules::getAssetRules($assetId); // (TODO) instead of keeping inherited Allowed it becomes Allowed. } // try again elseif ($try) @@ -278,50 +310,63 @@ class GetbibleTableTagged_verse extends Table return $result; } } - return Access::getAssetRules(0); + return AccessRules::getAssetRules(0); + } + + /** + * Get the type alias for the history table + * + * The type alias generally is the internal component name with the + * content type. Ex.: com_content.article + * + * @return string The alias as described above + * + * @since 3.10.0 + */ + public function getTypeAlias() + { + return $this->typeAlias; } /** * Method to compute the default name of the asset. - * The default name is in the form 'table_name.id' + * 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 + * @return string + * + * @since 1.7.0 */ protected function _getAssetName() { $k = $this->_tbl_key; - return 'com_getbible.tagged_verse.'.(int) $this->$k; + + return $this->getTypeAlias() . '.' . (int) $this->$k; } /** - * Method to return the title to use for the asset table. + * Method to get the parent asset under which to register this one. * - * @return string - * @since 2.5 - */ - protected function _getAssetTitle() - { - if (isset($this->title)) - { - return $this->title; - } - return ''; - } - - /** - * Get the parent asset id for the record + * By default, all assets are registered to the ROOT node with ID, which will default to 1 if none exists. + * An extended class can define a table and ID to lookup. If the asset does not exist it will be created. * - * @return int - * @since 2.5 + * @param Table $table A Table object for the asset parent. + * @param integer $id Id to look up + * + * @return integer + * + * @since 1.7.0 */ - protected function _getAssetParentId(?Table $table = null, $id = null) + protected function _getAssetParentId(Table $table = null, $id = null) { - $asset = Table::getInstance('Asset'); - $asset->loadByName('com_getbible'); + /** @var Asset $assets */ + $assets = self::getInstance('Asset', 'JTable', ['dbo' => $this->getDbo()]); + $rootId = $assets->getRootId(); - return $asset->id; + // load the getbible asset + $assets->loadByName('com_getbible'); + + return $assets->id ?? $rootId ?? 1; } /** @@ -333,5 +378,4 @@ class GetbibleTableTagged_verse extends Table { return false; } - } diff --git a/admin/tables/translation.php b/admin/src/Table/TranslationTable.php similarity index 58% rename from admin/tables/translation.php rename to admin/src/Table/TranslationTable.php index 82d28fc..cef66cf 100644 --- a/admin/tables/translation.php +++ b/admin/src/Table/TranslationTable.php @@ -14,88 +14,106 @@ @license GNU/GPL Version 2 or later - http://www.gnu.org/licenses/gpl-2.0.html /------------------------------------------------------------------------------------------------------*/ +namespace TrueChristianChurch\Component\Getbible\Administrator\Table; // No direct access to this file -defined('_JEXEC') or die('Restricted access'); +\defined('_JEXEC') or die; use Joomla\CMS\Factory; use Joomla\CMS\Table\Table; +use Joomla\CMS\Language\Text; +use Joomla\CMS\String\PunycodeHelper; use Joomla\CMS\Access\Access as AccessRules; use Joomla\CMS\Access\Rules; +use Joomla\CMS\Tag\TaggableTableInterface; +use Joomla\CMS\Tag\TaggableTableTrait; +use Joomla\CMS\User\CurrentUserInterface; +use Joomla\CMS\User\CurrentUserTrait; +use Joomla\CMS\Versioning\VersionableTableInterface; +use Joomla\CMS\Application\ApplicationHelper; +use Joomla\Database\DatabaseInterface; use Joomla\Registry\Registry; +use Joomla\Database\DatabaseDriver; +use Joomla\Event\DispatcherInterface; use Joomla\String\StringHelper; use Joomla\Utilities\ArrayHelper; -use Joomla\CMS\String\PunycodeHelper; -use Joomla\CMS\Table\Observer\Tags as TableObserverTags; -use Joomla\CMS\Table\Observer\ContentHistory as TableObserverContenthistory; -use Joomla\CMS\Application\ApplicationHelper; +use TrueChristianChurch\Component\Getbible\Administrator\Helper\GetbibleHelper; /** * Translations Table class */ -class GetbibleTableTranslation extends Table +class TranslationTable extends Table implements VersionableTableInterface, TaggableTableInterface, CurrentUserInterface { - /** - * Ensure the params and metadata in json encoded in the bind method - * - * @var array - * @since 3.3 - */ - protected $_jsonEncode = array('params', 'metadata'); - + use TaggableTableTrait; + use CurrentUserTrait; + /** * Constructor * + * @param DatabaseDriver $db Database connector object + * @param ?DispatcherInterface $dispatcher Event dispatcher for this table + * * @param object Database connector object + * @since 4.0 */ - function __construct(&$db) + function __construct(DatabaseDriver $db, ?DispatcherInterface $dispatcher = null) { - parent::__construct('#__getbible_translation', 'id', $db); - } - + // The type alias generally is the internal component name with the + // content type. Ex.: com_content.article + $this->typeAlias = 'com_getbible.translation'; + + // Ensure the params and metadata in json encoded in the bind method + $this->_jsonEncode = ['params', 'metadata']; + + // Indicates that columns fully support the NULL value in the database + // $this->_supportNullValue = true; // hmmm will keep an eye on this ;) + + parent::__construct('#__getbible_translation', 'id', $db, $dispatcher); + } + + /** + * Method to bind an associative array or object to the Table instance.This + * method only binds properties that are publicly accessible and optionally + * takes an array of properties to ignore when binding. + * + * @param array|object $src An associative array or object to bind to the Table instance. + * @param array|string $ignore An optional array or space separated list of properties to ignore while binding. + * + * @return boolean True on success. + * + * @since 1.7.0 + * @throws \InvalidArgumentException + */ public function bind($array, $ignore = '') { - - if (isset($array['params']) && is_array($array['params'])) + // Bind the rules. + if (isset($array['rules']) && is_array($array['rules'])) { - $registry = new Registry; - $registry->loadArray($array['params']); - $array['params'] = (string) $registry; + $rules = new AccessRules($array['rules']); + $this->setRules($rules); } - if (isset($array['metadata']) && is_array($array['metadata'])) - { - $registry = new Registry; - $registry->loadArray($array['metadata']); - $array['metadata'] = (string) $registry; - } - - // Bind the rules. - if (isset($array['rules']) && is_array($array['rules'])) - { - $rules = new AccessRules($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. + * @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 = Factory::getDate(); - $user = Factory::getUser(); + $date = Factory::getDate()->toSql(); + $userId = $this->getCurrentUser()->id; if ($this->id) { // Existing item - $this->modified = $date->toSql(); - $this->modified_by = $user->get('id'); + $this->modified = $date; + $this->modified_by = $userId; } else { @@ -103,31 +121,38 @@ class GetbibleTableTranslation extends Table // so we don't touch either of these if they are set. if (!(int) $this->created) { - $this->created = $date->toSql(); + $this->created = $date; } if (empty($this->created_by)) { - $this->created_by = $user->get('id'); + $this->created_by = $userId; } } - + if (isset($this->alias)) { // Verify that the alias is unique - $table = Table::getInstance('translation', 'GetbibleTable'); + $table = new self($this->getDbo(), $this->getDispatcher()); - if ($table->load(array('alias' => $this->alias)) && ($table->id != $this->id || $this->id == 0)) + if ($table->load(['alias' => $this->alias]) && ($table->id != $this->id || $this->id == 0)) { $this->setError(Text::_('COM_GETBIBLE_TRANSLATION_ERROR_UNIQUE_ALIAS')); + + if ($table->published === -2) + { + $this->setError(Text::_('COM_GETBIBLE_TRANSLATION_ERROR_UNIQUE_ALIAS_TRASHED')); + } + return false; } } - + if (isset($this->url)) { // Convert IDN urls to punycode $this->url = PunycodeHelper::urlToPunycode($this->url); } + if (isset($this->website)) { // Convert IDN urls to punycode @@ -136,32 +161,42 @@ class GetbibleTableTranslation extends Table return parent::store($updateNulls); } - + /** * Overloaded check method to ensure data integrity. * * @return boolean True on success. + * + * @see \Joomla\CMS\Table\Table::check + * @since 1.5 */ public function check() { + try { + parent::check(); + } catch (\Exception $e) { + $this->setError($e->getMessage()); + return false; + } + if (isset($this->alias)) { // Generate a valid alias $this->generateAlias(); - - $table = Table::getInstance('translation', 'getbibleTable'); - while ($table->load(array('alias' => $this->alias)) && ($table->id != $this->id || $this->id == 0)) + $table = new self($this->getDbo(), $this->getDispatcher()); + + while ($table->load(['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. @@ -201,7 +236,7 @@ class GetbibleTableTranslation extends Table $rules = $this->getDefaultAssetValues('com_getbible.translation.'.$this->id); $this->setRules($rules); } - + // Set ordering if ($this->published < 0) { @@ -222,7 +257,7 @@ class GetbibleTableTranslation extends Table protected function getDefaultAssetValues($component, $try = true) { // Need to find the asset id by the name of the component. - $db = Factory::getDbo(); + $db = Factory::getContainer()->get(DatabaseInterface::class); $query = $db->getQuery(true) ->select($db->quoteName('id')) ->from($db->quoteName('#__assets')) @@ -233,7 +268,7 @@ class GetbibleTableTranslation extends Table { // asset already set so use saved rules $assetId = (int) $db->loadResult(); - return Access::getAssetRules($assetId); // (TODO) instead of keeping inherited Allowed it becomes Allowed. + return AccessRules::getAssetRules($assetId); // (TODO) instead of keeping inherited Allowed it becomes Allowed. } // try again elseif ($try) @@ -275,50 +310,63 @@ class GetbibleTableTranslation extends Table return $result; } } - return Access::getAssetRules(0); + return AccessRules::getAssetRules(0); + } + + /** + * Get the type alias for the history table + * + * The type alias generally is the internal component name with the + * content type. Ex.: com_content.article + * + * @return string The alias as described above + * + * @since 3.10.0 + */ + public function getTypeAlias() + { + return $this->typeAlias; } /** * Method to compute the default name of the asset. - * The default name is in the form 'table_name.id' + * 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 + * @return string + * + * @since 1.7.0 */ protected function _getAssetName() { $k = $this->_tbl_key; - return 'com_getbible.translation.'.(int) $this->$k; + + return $this->getTypeAlias() . '.' . (int) $this->$k; } /** - * Method to return the title to use for the asset table. + * Method to get the parent asset under which to register this one. * - * @return string - * @since 2.5 - */ - protected function _getAssetTitle() - { - if (isset($this->title)) - { - return $this->title; - } - return ''; - } - - /** - * Get the parent asset id for the record + * By default, all assets are registered to the ROOT node with ID, which will default to 1 if none exists. + * An extended class can define a table and ID to lookup. If the asset does not exist it will be created. * - * @return int - * @since 2.5 + * @param Table $table A Table object for the asset parent. + * @param integer $id Id to look up + * + * @return integer + * + * @since 1.7.0 */ - protected function _getAssetParentId(?Table $table = null, $id = null) + protected function _getAssetParentId(Table $table = null, $id = null) { - $asset = Table::getInstance('Asset'); - $asset->loadByName('com_getbible'); + /** @var Asset $assets */ + $assets = self::getInstance('Asset', 'JTable', ['dbo' => $this->getDbo()]); + $rootId = $assets->getRootId(); - return $asset->id; + // load the getbible asset + $assets->loadByName('com_getbible'); + + return $assets->id ?? $rootId ?? 1; } /** @@ -330,5 +378,4 @@ class GetbibleTableTranslation extends Table { return false; } - } diff --git a/admin/tables/verse.php b/admin/src/Table/VerseTable.php similarity index 58% rename from admin/tables/verse.php rename to admin/src/Table/VerseTable.php index 7438e4d..178d11c 100644 --- a/admin/tables/verse.php +++ b/admin/src/Table/VerseTable.php @@ -14,88 +14,106 @@ @license GNU/GPL Version 2 or later - http://www.gnu.org/licenses/gpl-2.0.html /------------------------------------------------------------------------------------------------------*/ +namespace TrueChristianChurch\Component\Getbible\Administrator\Table; // No direct access to this file -defined('_JEXEC') or die('Restricted access'); +\defined('_JEXEC') or die; use Joomla\CMS\Factory; use Joomla\CMS\Table\Table; +use Joomla\CMS\Language\Text; +use Joomla\CMS\String\PunycodeHelper; use Joomla\CMS\Access\Access as AccessRules; use Joomla\CMS\Access\Rules; +use Joomla\CMS\Tag\TaggableTableInterface; +use Joomla\CMS\Tag\TaggableTableTrait; +use Joomla\CMS\User\CurrentUserInterface; +use Joomla\CMS\User\CurrentUserTrait; +use Joomla\CMS\Versioning\VersionableTableInterface; +use Joomla\CMS\Application\ApplicationHelper; +use Joomla\Database\DatabaseInterface; use Joomla\Registry\Registry; +use Joomla\Database\DatabaseDriver; +use Joomla\Event\DispatcherInterface; use Joomla\String\StringHelper; use Joomla\Utilities\ArrayHelper; -use Joomla\CMS\String\PunycodeHelper; -use Joomla\CMS\Table\Observer\Tags as TableObserverTags; -use Joomla\CMS\Table\Observer\ContentHistory as TableObserverContenthistory; -use Joomla\CMS\Application\ApplicationHelper; +use TrueChristianChurch\Component\Getbible\Administrator\Helper\GetbibleHelper; /** * Verses Table class */ -class GetbibleTableVerse extends Table +class VerseTable extends Table implements VersionableTableInterface, TaggableTableInterface, CurrentUserInterface { - /** - * Ensure the params and metadata in json encoded in the bind method - * - * @var array - * @since 3.3 - */ - protected $_jsonEncode = array('params', 'metadata'); - + use TaggableTableTrait; + use CurrentUserTrait; + /** * Constructor * + * @param DatabaseDriver $db Database connector object + * @param ?DispatcherInterface $dispatcher Event dispatcher for this table + * * @param object Database connector object + * @since 4.0 */ - function __construct(&$db) + function __construct(DatabaseDriver $db, ?DispatcherInterface $dispatcher = null) { - parent::__construct('#__getbible_verse', 'id', $db); - } - + // The type alias generally is the internal component name with the + // content type. Ex.: com_content.article + $this->typeAlias = 'com_getbible.verse'; + + // Ensure the params and metadata in json encoded in the bind method + $this->_jsonEncode = ['params', 'metadata']; + + // Indicates that columns fully support the NULL value in the database + // $this->_supportNullValue = true; // hmmm will keep an eye on this ;) + + parent::__construct('#__getbible_verse', 'id', $db, $dispatcher); + } + + /** + * Method to bind an associative array or object to the Table instance.This + * method only binds properties that are publicly accessible and optionally + * takes an array of properties to ignore when binding. + * + * @param array|object $src An associative array or object to bind to the Table instance. + * @param array|string $ignore An optional array or space separated list of properties to ignore while binding. + * + * @return boolean True on success. + * + * @since 1.7.0 + * @throws \InvalidArgumentException + */ public function bind($array, $ignore = '') { - - if (isset($array['params']) && is_array($array['params'])) + // Bind the rules. + if (isset($array['rules']) && is_array($array['rules'])) { - $registry = new Registry; - $registry->loadArray($array['params']); - $array['params'] = (string) $registry; + $rules = new AccessRules($array['rules']); + $this->setRules($rules); } - if (isset($array['metadata']) && is_array($array['metadata'])) - { - $registry = new Registry; - $registry->loadArray($array['metadata']); - $array['metadata'] = (string) $registry; - } - - // Bind the rules. - if (isset($array['rules']) && is_array($array['rules'])) - { - $rules = new AccessRules($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. + * @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 = Factory::getDate(); - $user = Factory::getUser(); + $date = Factory::getDate()->toSql(); + $userId = $this->getCurrentUser()->id; if ($this->id) { // Existing item - $this->modified = $date->toSql(); - $this->modified_by = $user->get('id'); + $this->modified = $date; + $this->modified_by = $userId; } else { @@ -103,31 +121,38 @@ class GetbibleTableVerse extends Table // so we don't touch either of these if they are set. if (!(int) $this->created) { - $this->created = $date->toSql(); + $this->created = $date; } if (empty($this->created_by)) { - $this->created_by = $user->get('id'); + $this->created_by = $userId; } } - + if (isset($this->alias)) { // Verify that the alias is unique - $table = Table::getInstance('verse', 'GetbibleTable'); + $table = new self($this->getDbo(), $this->getDispatcher()); - if ($table->load(array('alias' => $this->alias)) && ($table->id != $this->id || $this->id == 0)) + if ($table->load(['alias' => $this->alias]) && ($table->id != $this->id || $this->id == 0)) { $this->setError(Text::_('COM_GETBIBLE_VERSE_ERROR_UNIQUE_ALIAS')); + + if ($table->published === -2) + { + $this->setError(Text::_('COM_GETBIBLE_VERSE_ERROR_UNIQUE_ALIAS_TRASHED')); + } + return false; } } - + if (isset($this->url)) { // Convert IDN urls to punycode $this->url = PunycodeHelper::urlToPunycode($this->url); } + if (isset($this->website)) { // Convert IDN urls to punycode @@ -136,32 +161,42 @@ class GetbibleTableVerse extends Table return parent::store($updateNulls); } - + /** * Overloaded check method to ensure data integrity. * * @return boolean True on success. + * + * @see \Joomla\CMS\Table\Table::check + * @since 1.5 */ public function check() { + try { + parent::check(); + } catch (\Exception $e) { + $this->setError($e->getMessage()); + return false; + } + if (isset($this->alias)) { // Generate a valid alias $this->generateAlias(); - - $table = Table::getInstance('verse', 'getbibleTable'); - while ($table->load(array('alias' => $this->alias)) && ($table->id != $this->id || $this->id == 0)) + $table = new self($this->getDbo(), $this->getDispatcher()); + + while ($table->load(['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. @@ -201,7 +236,7 @@ class GetbibleTableVerse extends Table $rules = $this->getDefaultAssetValues('com_getbible.verse.'.$this->id); $this->setRules($rules); } - + // Set ordering if ($this->published < 0) { @@ -222,7 +257,7 @@ class GetbibleTableVerse extends Table protected function getDefaultAssetValues($component, $try = true) { // Need to find the asset id by the name of the component. - $db = Factory::getDbo(); + $db = Factory::getContainer()->get(DatabaseInterface::class); $query = $db->getQuery(true) ->select($db->quoteName('id')) ->from($db->quoteName('#__assets')) @@ -233,7 +268,7 @@ class GetbibleTableVerse extends Table { // asset already set so use saved rules $assetId = (int) $db->loadResult(); - return Access::getAssetRules($assetId); // (TODO) instead of keeping inherited Allowed it becomes Allowed. + return AccessRules::getAssetRules($assetId); // (TODO) instead of keeping inherited Allowed it becomes Allowed. } // try again elseif ($try) @@ -275,50 +310,63 @@ class GetbibleTableVerse extends Table return $result; } } - return Access::getAssetRules(0); + return AccessRules::getAssetRules(0); + } + + /** + * Get the type alias for the history table + * + * The type alias generally is the internal component name with the + * content type. Ex.: com_content.article + * + * @return string The alias as described above + * + * @since 3.10.0 + */ + public function getTypeAlias() + { + return $this->typeAlias; } /** * Method to compute the default name of the asset. - * The default name is in the form 'table_name.id' + * 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 + * @return string + * + * @since 1.7.0 */ protected function _getAssetName() { $k = $this->_tbl_key; - return 'com_getbible.verse.'.(int) $this->$k; + + return $this->getTypeAlias() . '.' . (int) $this->$k; } /** - * Method to return the title to use for the asset table. + * Method to get the parent asset under which to register this one. * - * @return string - * @since 2.5 - */ - protected function _getAssetTitle() - { - if (isset($this->title)) - { - return $this->title; - } - return ''; - } - - /** - * Get the parent asset id for the record + * By default, all assets are registered to the ROOT node with ID, which will default to 1 if none exists. + * An extended class can define a table and ID to lookup. If the asset does not exist it will be created. * - * @return int - * @since 2.5 + * @param Table $table A Table object for the asset parent. + * @param integer $id Id to look up + * + * @return integer + * + * @since 1.7.0 */ - protected function _getAssetParentId(?Table $table = null, $id = null) + protected function _getAssetParentId(Table $table = null, $id = null) { - $asset = Table::getInstance('Asset'); - $asset->loadByName('com_getbible'); + /** @var Asset $assets */ + $assets = self::getInstance('Asset', 'JTable', ['dbo' => $this->getDbo()]); + $rootId = $assets->getRootId(); - return $asset->id; + // load the getbible asset + $assets->loadByName('com_getbible'); + + return $assets->id ?? $rootId ?? 1; } /** @@ -330,5 +378,4 @@ class GetbibleTableVerse extends Table { return false; } - } diff --git a/admin/views/books/tmpl/index.html b/admin/src/Table/index.html similarity index 100% rename from admin/views/books/tmpl/index.html rename to admin/src/Table/index.html diff --git a/admin/views/book/view.html.php b/admin/src/View/Book/HtmlView.php similarity index 82% rename from admin/views/book/view.html.php rename to admin/src/View/Book/HtmlView.php index 2f0a160..a9d5523 100644 --- a/admin/views/book/view.html.php +++ b/admin/src/View/Book/HtmlView.php @@ -14,28 +14,31 @@ @license GNU/GPL Version 2 or later - http://www.gnu.org/licenses/gpl-2.0.html /------------------------------------------------------------------------------------------------------*/ +namespace TrueChristianChurch\Component\Getbible\Administrator\View\Book; // No direct access to this file -defined('_JEXEC') or die('Restricted access'); +\defined('_JEXEC') or die; use Joomla\CMS\Factory; use Joomla\CMS\Language\Text; +use Joomla\CMS\Toolbar\Toolbar; use Joomla\CMS\Form\FormHelper; use Joomla\CMS\Session\Session; use Joomla\CMS\Uri\Uri; -use Joomla\CMS\Toolbar\Toolbar; use Joomla\CMS\Component\ComponentHelper; use Joomla\CMS\HTML\HTMLHelper as Html; use Joomla\CMS\Layout\FileLayout; -use Joomla\CMS\MVC\View\HtmlView; +use Joomla\CMS\MVC\View\HtmlView as BaseHtmlView; use Joomla\CMS\Plugin\PluginHelper; use Joomla\CMS\Toolbar\ToolbarHelper; +use Joomla\CMS\Document\Document; +use TrueChristianChurch\Component\Getbible\Administrator\Helper\GetbibleHelper; use VDM\Joomla\Utilities\StringHelper; /** * Book Html View class */ -class GetbibleViewBook extends HtmlView +class HtmlView extends BaseHtmlView { /** * display method of View @@ -78,18 +81,18 @@ class GetbibleViewBook extends HtmlView // Set the toolbar $this->addToolBar(); - + // Check for errors. if (count($errors = $this->get('Errors'))) { - throw new Exception(implode("\n", $errors), 500); + throw new \Exception(implode("\n", $errors), 500); } // Display the template parent::display($tpl); - // Set the document - $this->setDocument(); + // Set the html view document stuff + $this->setHtmlViewDoc(); } @@ -112,9 +115,13 @@ class GetbibleViewBook extends HtmlView */ public function escape($var) { - if(strlen($var) > 30) + if (!is_string($var)) { - // use the helper htmlEscape method instead and shorten the string + return $var; + } + elseif(strlen($var) > 30) + { + // use the helper htmlEscape method instead and shorten the string return StringHelper::html($var, $this->_charset, true, 30); } // use the helper htmlEscape method instead. @@ -122,18 +129,15 @@ class GetbibleViewBook extends HtmlView } /** - * Method to set up the document properties + * Set this html view document related stuff. * * @return void + * @since 4.4.0 */ - protected function setDocument() + protected function setHtmlViewDoc(): void { $isNew = ($this->item->id < 1); - if (!isset($this->document)) - { - $this->document = Factory::getDocument(); - } - $this->document->setTitle(Text::_($isNew ? 'COM_GETBIBLE_BOOK_NEW' : 'COM_GETBIBLE_BOOK_EDIT')); + $this->getDocument()->setTitle(Text::_($isNew ? 'COM_GETBIBLE_BOOK_NEW' : 'COM_GETBIBLE_BOOK_EDIT')); Html::_('stylesheet', "administrator/components/com_getbible/assets/css/book.css", ['version' => 'auto']); Html::_('script', $this->script, ['version' => 'auto']); Html::_('script', "administrator/components/com_getbible/views/book/submitbutton.js", ['version' => 'auto']); diff --git a/admin/views/chapter/tmpl/index.html b/admin/src/View/Book/index.html similarity index 100% rename from admin/views/chapter/tmpl/index.html rename to admin/src/View/Book/index.html diff --git a/admin/views/books/view.html.php b/admin/src/View/Books/HtmlView.php similarity index 56% rename from admin/views/books/view.html.php rename to admin/src/View/Books/HtmlView.php index 4b58168..65cc198 100644 --- a/admin/views/books/view.html.php +++ b/admin/src/View/Books/HtmlView.php @@ -14,29 +14,32 @@ @license GNU/GPL Version 2 or later - http://www.gnu.org/licenses/gpl-2.0.html /------------------------------------------------------------------------------------------------------*/ +namespace TrueChristianChurch\Component\Getbible\Administrator\View\Books; // No direct access to this file -defined('_JEXEC') or die('Restricted access'); +\defined('_JEXEC') or die; use Joomla\CMS\Factory; use Joomla\CMS\Language\Text; +use Joomla\CMS\Toolbar\Toolbar; use Joomla\CMS\Form\FormHelper; use Joomla\CMS\Session\Session; use Joomla\CMS\Uri\Uri; -use Joomla\CMS\Toolbar\Toolbar; use Joomla\CMS\Component\ComponentHelper; use Joomla\CMS\HTML\HTMLHelper as Html; use Joomla\CMS\Layout\FileLayout; -use Joomla\CMS\MVC\View\HtmlView; +use Joomla\CMS\MVC\View\HtmlView as BaseHtmlView; use Joomla\CMS\Plugin\PluginHelper; use Joomla\CMS\Toolbar\ToolbarHelper; +use Joomla\CMS\Document\Document; +use TrueChristianChurch\Component\Getbible\Administrator\Helper\GetbibleHelper; use VDM\Joomla\Utilities\ArrayHelper; use VDM\Joomla\Utilities\StringHelper; /** * Getbible Html View class for the Books */ -class GetbibleViewBooks extends HtmlView +class HtmlView extends BaseHtmlView { /** * Books view display method @@ -44,17 +47,11 @@ class GetbibleViewBooks extends HtmlView */ 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 = Factory::getUser(); + $this->user = Factory::getApplication()->getIdentity(); // Load the filter form from xml. $this->filterForm = $this->get('FilterForm'); // Load the active filters. @@ -73,29 +70,29 @@ class GetbibleViewBooks extends HtmlView $this->canDelete = $this->canDo->get('book.delete'); $this->canBatch = ($this->canDo->get('book.batch') && $this->canDo->get('core.batch')); + // If we don't have items we load the empty state + if (is_array($this->items) && !count((array) $this->items) && $this->isEmptyState = $this->get('IsEmptyState')) + { + $this->setLayout('emptystate'); + } + // 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); + throw new \Exception(implode("\n", $errors), 500); } // Display the template parent::display($tpl); - // Set the document - $this->setDocument(); + // Set the html view document stuff + $this->setHtmlViewDoc(); } /** @@ -103,9 +100,7 @@ class GetbibleViewBooks extends HtmlView */ protected function addToolBar() { - JHtmlSidebar::setAction('index.php?option=com_getbible&view=books'); ToolbarHelper::title(Text::_('COM_GETBIBLE_BOOKS'), 'generic'); - FormHelper::addFieldPath(JPATH_COMPONENT . '/models/fields'); if ($this->canCreate) { @@ -131,20 +126,6 @@ class GetbibleViewBooks extends HtmlView ToolbarHelper::checkin('books.checkin'); } } - - // Add a batch button - if ($this->canBatch && $this->canCreate && $this->canEdit && $this->canState) - { - // Get the toolbar object instance - $bar = Toolbar::getInstance('toolbar'); - // set the batch button name - $title = Text::_('JTOOLBAR_BATCH'); - // Instantiate a new JLayoutFile instance and render the batch button - $layout = new FileLayout('joomla.toolbar.batch'); - // add the button to the page - $dhtml = $layout->render(array('title' => $title)); - $bar->appendButton('Custom', $dhtml, 'batch'); - } if ($this->user->authorise('book.update_chapters_names', 'com_getbible')) { // add Update Chapters Names button. @@ -178,100 +159,17 @@ class GetbibleViewBooks extends HtmlView { ToolbarHelper::preferences('com_getbible'); } - - // Only load published batch if state and batch is allowed - if ($this->canState && $this->canBatch) - { - JHtmlBatch_::addListSelection( - Text::_('COM_GETBIBLE_KEEP_ORIGINAL_STATE'), - 'batch[published]', - Html::_('select.options', Html::_('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( - Text::_('COM_GETBIBLE_KEEP_ORIGINAL_ACCESS'), - 'batch[access]', - Html::_('select.options', Html::_('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 = FormHelper::loadFieldType('booksfiltername')->options; - // We do some sanitation for Name filter - if (ArrayHelper::check($this->nameOptions) && - isset($this->nameOptions[0]->value) && - !StringHelper::check($this->nameOptions[0]->value)) - { - unset($this->nameOptions[0]); - } - // Name Batch Selection - JHtmlBatch_::addListSelection( - '- Keep Original '.Text::_('COM_GETBIBLE_BOOK_NAME_LABEL').' -', - 'batch[name]', - Html::_('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 = FormHelper::loadFieldType('Translations')->options; - // We do some sanitation for Abbreviation Translation filter - if (ArrayHelper::check($this->abbreviationTranslationOptions) && - isset($this->abbreviationTranslationOptions[0]->value) && - !StringHelper::check($this->abbreviationTranslationOptions[0]->value)) - { - unset($this->abbreviationTranslationOptions[0]); - } - // Abbreviation Translation Batch Selection - JHtmlBatch_::addListSelection( - '- Keep Original '.Text::_('COM_GETBIBLE_BOOK_ABBREVIATION_LABEL').' -', - 'batch[abbreviation]', - Html::_('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 = FormHelper::loadFieldType('booksfilternr')->options; - // We do some sanitation for Nr filter - if (ArrayHelper::check($this->nrOptions) && - isset($this->nrOptions[0]->value) && - !StringHelper::check($this->nrOptions[0]->value)) - { - unset($this->nrOptions[0]); - } - // Nr Batch Selection - JHtmlBatch_::addListSelection( - '- Keep Original '.Text::_('COM_GETBIBLE_BOOK_NR_LABEL').' -', - 'batch[nr]', - Html::_('select.options', $this->nrOptions, 'value', 'text') - ); - } } /** - * Method to set up the document properties + * Set this html view document related stuff. * * @return void + * @since 4.4.0 */ - protected function setDocument() + protected function setHtmlViewDoc(): void { - if (!isset($this->document)) - { - $this->document = Factory::getDocument(); - } - $this->document->setTitle(Text::_('COM_GETBIBLE_BOOKS')); + $this->getDocument()->setTitle(Text::_('COM_GETBIBLE_BOOKS')); Html::_('stylesheet', "administrator/components/com_getbible/assets/css/books.css", ['version' => 'auto']); } @@ -284,7 +182,11 @@ class GetbibleViewBooks extends HtmlView */ public function escape($var) { - if(strlen($var) > 50) + if (!is_string($var)) + { + return $var; + } + elseif(strlen($var) > 50) { // use the helper htmlEscape method instead and shorten the string return StringHelper::html($var, $this->_charset, true); diff --git a/admin/views/chapters/index.html b/admin/src/View/Books/index.html similarity index 100% rename from admin/views/chapters/index.html rename to admin/src/View/Books/index.html diff --git a/admin/views/chapter/view.html.php b/admin/src/View/Chapter/HtmlView.php similarity index 82% rename from admin/views/chapter/view.html.php rename to admin/src/View/Chapter/HtmlView.php index 39c69eb..95f804b 100644 --- a/admin/views/chapter/view.html.php +++ b/admin/src/View/Chapter/HtmlView.php @@ -14,28 +14,31 @@ @license GNU/GPL Version 2 or later - http://www.gnu.org/licenses/gpl-2.0.html /------------------------------------------------------------------------------------------------------*/ +namespace TrueChristianChurch\Component\Getbible\Administrator\View\Chapter; // No direct access to this file -defined('_JEXEC') or die('Restricted access'); +\defined('_JEXEC') or die; use Joomla\CMS\Factory; use Joomla\CMS\Language\Text; +use Joomla\CMS\Toolbar\Toolbar; use Joomla\CMS\Form\FormHelper; use Joomla\CMS\Session\Session; use Joomla\CMS\Uri\Uri; -use Joomla\CMS\Toolbar\Toolbar; use Joomla\CMS\Component\ComponentHelper; use Joomla\CMS\HTML\HTMLHelper as Html; use Joomla\CMS\Layout\FileLayout; -use Joomla\CMS\MVC\View\HtmlView; +use Joomla\CMS\MVC\View\HtmlView as BaseHtmlView; use Joomla\CMS\Plugin\PluginHelper; use Joomla\CMS\Toolbar\ToolbarHelper; +use Joomla\CMS\Document\Document; +use TrueChristianChurch\Component\Getbible\Administrator\Helper\GetbibleHelper; use VDM\Joomla\Utilities\StringHelper; /** * Chapter Html View class */ -class GetbibleViewChapter extends HtmlView +class HtmlView extends BaseHtmlView { /** * display method of View @@ -78,18 +81,18 @@ class GetbibleViewChapter extends HtmlView // Set the toolbar $this->addToolBar(); - + // Check for errors. if (count($errors = $this->get('Errors'))) { - throw new Exception(implode("\n", $errors), 500); + throw new \Exception(implode("\n", $errors), 500); } // Display the template parent::display($tpl); - // Set the document - $this->setDocument(); + // Set the html view document stuff + $this->setHtmlViewDoc(); } @@ -112,9 +115,13 @@ class GetbibleViewChapter extends HtmlView */ public function escape($var) { - if(strlen($var) > 30) + if (!is_string($var)) { - // use the helper htmlEscape method instead and shorten the string + return $var; + } + elseif(strlen($var) > 30) + { + // use the helper htmlEscape method instead and shorten the string return StringHelper::html($var, $this->_charset, true, 30); } // use the helper htmlEscape method instead. @@ -122,18 +129,15 @@ class GetbibleViewChapter extends HtmlView } /** - * Method to set up the document properties + * Set this html view document related stuff. * * @return void + * @since 4.4.0 */ - protected function setDocument() + protected function setHtmlViewDoc(): void { $isNew = ($this->item->id < 1); - if (!isset($this->document)) - { - $this->document = Factory::getDocument(); - } - $this->document->setTitle(Text::_($isNew ? 'COM_GETBIBLE_CHAPTER_NEW' : 'COM_GETBIBLE_CHAPTER_EDIT')); + $this->getDocument()->setTitle(Text::_($isNew ? 'COM_GETBIBLE_CHAPTER_NEW' : 'COM_GETBIBLE_CHAPTER_EDIT')); Html::_('stylesheet', "administrator/components/com_getbible/assets/css/chapter.css", ['version' => 'auto']); Html::_('script', $this->script, ['version' => 'auto']); Html::_('script', "administrator/components/com_getbible/views/chapter/submitbutton.js", ['version' => 'auto']); diff --git a/admin/views/chapters/tmpl/index.html b/admin/src/View/Chapter/index.html similarity index 100% rename from admin/views/chapters/tmpl/index.html rename to admin/src/View/Chapter/index.html diff --git a/admin/views/chapters/view.html.php b/admin/src/View/Chapters/HtmlView.php similarity index 54% rename from admin/views/chapters/view.html.php rename to admin/src/View/Chapters/HtmlView.php index 47198a7..40b36d2 100644 --- a/admin/views/chapters/view.html.php +++ b/admin/src/View/Chapters/HtmlView.php @@ -14,29 +14,32 @@ @license GNU/GPL Version 2 or later - http://www.gnu.org/licenses/gpl-2.0.html /------------------------------------------------------------------------------------------------------*/ +namespace TrueChristianChurch\Component\Getbible\Administrator\View\Chapters; // No direct access to this file -defined('_JEXEC') or die('Restricted access'); +\defined('_JEXEC') or die; use Joomla\CMS\Factory; use Joomla\CMS\Language\Text; +use Joomla\CMS\Toolbar\Toolbar; use Joomla\CMS\Form\FormHelper; use Joomla\CMS\Session\Session; use Joomla\CMS\Uri\Uri; -use Joomla\CMS\Toolbar\Toolbar; use Joomla\CMS\Component\ComponentHelper; use Joomla\CMS\HTML\HTMLHelper as Html; use Joomla\CMS\Layout\FileLayout; -use Joomla\CMS\MVC\View\HtmlView; +use Joomla\CMS\MVC\View\HtmlView as BaseHtmlView; use Joomla\CMS\Plugin\PluginHelper; use Joomla\CMS\Toolbar\ToolbarHelper; +use Joomla\CMS\Document\Document; +use TrueChristianChurch\Component\Getbible\Administrator\Helper\GetbibleHelper; use VDM\Joomla\Utilities\ArrayHelper; use VDM\Joomla\Utilities\StringHelper; /** * Getbible Html View class for the Chapters */ -class GetbibleViewChapters extends HtmlView +class HtmlView extends BaseHtmlView { /** * Chapters view display method @@ -44,17 +47,11 @@ class GetbibleViewChapters extends HtmlView */ 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 = Factory::getUser(); + $this->user = Factory::getApplication()->getIdentity(); // Load the filter form from xml. $this->filterForm = $this->get('FilterForm'); // Load the active filters. @@ -73,29 +70,29 @@ class GetbibleViewChapters extends HtmlView $this->canDelete = $this->canDo->get('chapter.delete'); $this->canBatch = ($this->canDo->get('chapter.batch') && $this->canDo->get('core.batch')); + // If we don't have items we load the empty state + if (is_array($this->items) && !count((array) $this->items) && $this->isEmptyState = $this->get('IsEmptyState')) + { + $this->setLayout('emptystate'); + } + // 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); + throw new \Exception(implode("\n", $errors), 500); } // Display the template parent::display($tpl); - // Set the document - $this->setDocument(); + // Set the html view document stuff + $this->setHtmlViewDoc(); } /** @@ -103,9 +100,7 @@ class GetbibleViewChapters extends HtmlView */ protected function addToolBar() { - JHtmlSidebar::setAction('index.php?option=com_getbible&view=chapters'); ToolbarHelper::title(Text::_('COM_GETBIBLE_CHAPTERS'), 'generic'); - FormHelper::addFieldPath(JPATH_COMPONENT . '/models/fields'); if ($this->canCreate) { @@ -132,20 +127,6 @@ class GetbibleViewChapters extends HtmlView } } - // Add a batch button - if ($this->canBatch && $this->canCreate && $this->canEdit && $this->canState) - { - // Get the toolbar object instance - $bar = Toolbar::getInstance('toolbar'); - // set the batch button name - $title = Text::_('JTOOLBAR_BATCH'); - // Instantiate a new JLayoutFile instance and render the batch button - $layout = new FileLayout('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)) { ToolbarHelper::deleteList('', 'chapters.delete', 'JTOOLBAR_EMPTY_TRASH'); @@ -168,100 +149,17 @@ class GetbibleViewChapters extends HtmlView { ToolbarHelper::preferences('com_getbible'); } - - // Only load published batch if state and batch is allowed - if ($this->canState && $this->canBatch) - { - JHtmlBatch_::addListSelection( - Text::_('COM_GETBIBLE_KEEP_ORIGINAL_STATE'), - 'batch[published]', - Html::_('select.options', Html::_('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( - Text::_('COM_GETBIBLE_KEEP_ORIGINAL_ACCESS'), - 'batch[access]', - Html::_('select.options', Html::_('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 = FormHelper::loadFieldType('chaptersfilterchapter')->options; - // We do some sanitation for Chapter filter - if (ArrayHelper::check($this->chapterOptions) && - isset($this->chapterOptions[0]->value) && - !StringHelper::check($this->chapterOptions[0]->value)) - { - unset($this->chapterOptions[0]); - } - // Chapter Batch Selection - JHtmlBatch_::addListSelection( - '- Keep Original '.Text::_('COM_GETBIBLE_CHAPTER_CHAPTER_LABEL').' -', - 'batch[chapter]', - Html::_('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 = FormHelper::loadFieldType('chaptersfilterbooknr')->options; - // We do some sanitation for Book Nr filter - if (ArrayHelper::check($this->book_nrOptions) && - isset($this->book_nrOptions[0]->value) && - !StringHelper::check($this->book_nrOptions[0]->value)) - { - unset($this->book_nrOptions[0]); - } - // Book Nr Batch Selection - JHtmlBatch_::addListSelection( - '- Keep Original '.Text::_('COM_GETBIBLE_CHAPTER_BOOK_NR_LABEL').' -', - 'batch[book_nr]', - Html::_('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 = FormHelper::loadFieldType('Translations')->options; - // We do some sanitation for Abbreviation Translation filter - if (ArrayHelper::check($this->abbreviationTranslationOptions) && - isset($this->abbreviationTranslationOptions[0]->value) && - !StringHelper::check($this->abbreviationTranslationOptions[0]->value)) - { - unset($this->abbreviationTranslationOptions[0]); - } - // Abbreviation Translation Batch Selection - JHtmlBatch_::addListSelection( - '- Keep Original '.Text::_('COM_GETBIBLE_CHAPTER_ABBREVIATION_LABEL').' -', - 'batch[abbreviation]', - Html::_('select.options', $this->abbreviationTranslationOptions, 'value', 'text') - ); - } } /** - * Method to set up the document properties + * Set this html view document related stuff. * * @return void + * @since 4.4.0 */ - protected function setDocument() + protected function setHtmlViewDoc(): void { - if (!isset($this->document)) - { - $this->document = Factory::getDocument(); - } - $this->document->setTitle(Text::_('COM_GETBIBLE_CHAPTERS')); + $this->getDocument()->setTitle(Text::_('COM_GETBIBLE_CHAPTERS')); Html::_('stylesheet', "administrator/components/com_getbible/assets/css/chapters.css", ['version' => 'auto']); } @@ -274,7 +172,11 @@ class GetbibleViewChapters extends HtmlView */ public function escape($var) { - if(strlen($var) > 50) + if (!is_string($var)) + { + return $var; + } + elseif(strlen($var) > 50) { // use the helper htmlEscape method instead and shorten the string return StringHelper::html($var, $this->_charset, true); diff --git a/admin/views/getbible/index.html b/admin/src/View/Chapters/index.html similarity index 100% rename from admin/views/getbible/index.html rename to admin/src/View/Chapters/index.html diff --git a/admin/views/getbible/view.html.php b/admin/src/View/Getbible/HtmlView.php similarity index 73% rename from admin/views/getbible/view.html.php rename to admin/src/View/Getbible/HtmlView.php index 1e2c05d..3628264 100644 --- a/admin/views/getbible/view.html.php +++ b/admin/src/View/Getbible/HtmlView.php @@ -14,21 +14,24 @@ @license GNU/GPL Version 2 or later - http://www.gnu.org/licenses/gpl-2.0.html /------------------------------------------------------------------------------------------------------*/ +namespace TrueChristianChurch\Component\Getbible\Administrator\View\Getbible; // No direct access to this file -defined('_JEXEC') or die('Restricted access'); +\defined('_JEXEC') or die; use Joomla\CMS\Factory; use Joomla\CMS\Language\Text; use Joomla\CMS\HTML\HTMLHelper as Html; -use Joomla\CMS\MVC\View\HtmlView; +use Joomla\CMS\MVC\View\HtmlView as BaseHtmlView; use Joomla\CMS\Toolbar\ToolbarHelper; +use Joomla\CMS\Document\Document; +use TrueChristianChurch\Component\Getbible\Administrator\Helper\GetbibleHelper; use VDM\Joomla\Utilities\StringHelper; /** * Getbible View class */ -class GetbibleViewGetbible extends HtmlView +class HtmlView extends BaseHtmlView { /** * View display method @@ -37,30 +40,30 @@ class GetbibleViewGetbible extends HtmlView function display($tpl = null) { // Assign data to the view - $this->icons = $this->get('Icons'); - $this->contributors = GetbibleHelper::getContributors(); + $this->icons = $this->get('Icons'); + $this->contributors = GetbibleHelper::getContributors(); + + // get the manifest details of the component + $this->manifest = GetbibleHelper::manifest(); $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); + throw new \Exception(implode("\n", $errors), 500); } // Display the template parent::display($tpl); - // Set the document - $this->setDocument(); + // Set the html view document stuff + $this->setHtmlViewDoc(); } /** @@ -85,21 +88,18 @@ class GetbibleViewGetbible extends HtmlView } /** - * Method to set up the document properties + * Set this html view document related stuff. * * @return void + * @since 4.4.0 */ - protected function setDocument() + protected function setHtmlViewDoc(): void { - if (!isset($this->document)) - { - $this->document = Factory::getDocument(); - } // set page title - $this->document->setTitle(Text::_('COM_GETBIBLE_DASHBOARD')); + $this->getDocument()->setTitle(Text::_('COM_GETBIBLE_DASHBOARD')); // add manifest to page JavaScript - $this->document->addScriptDeclaration("var manifest = jQuery.parseJSON('" . json_encode($this->manifest) . "');", "text/javascript"); + $this->getDocument()->addScriptDeclaration("var manifest = JSON.parse('" . json_encode($this->manifest) . "');", "text/javascript"); // add dashboard style sheets Html::_('stylesheet', "administrator/components/com_getbible/assets/css/dashboard.css", ['version' => 'auto']); diff --git a/admin/views/getbible/tmpl/index.html b/admin/src/View/Getbible/index.html similarity index 100% rename from admin/views/getbible/tmpl/index.html rename to admin/src/View/Getbible/index.html diff --git a/admin/views/linker/view.html.php b/admin/src/View/Linker/HtmlView.php similarity index 88% rename from admin/views/linker/view.html.php rename to admin/src/View/Linker/HtmlView.php index 926a2be..12c68ca 100644 --- a/admin/views/linker/view.html.php +++ b/admin/src/View/Linker/HtmlView.php @@ -14,28 +14,31 @@ @license GNU/GPL Version 2 or later - http://www.gnu.org/licenses/gpl-2.0.html /------------------------------------------------------------------------------------------------------*/ +namespace TrueChristianChurch\Component\Getbible\Administrator\View\Linker; // No direct access to this file -defined('_JEXEC') or die('Restricted access'); +\defined('_JEXEC') or die; use Joomla\CMS\Factory; use Joomla\CMS\Language\Text; +use Joomla\CMS\Toolbar\Toolbar; use Joomla\CMS\Form\FormHelper; use Joomla\CMS\Session\Session; use Joomla\CMS\Uri\Uri; -use Joomla\CMS\Toolbar\Toolbar; use Joomla\CMS\Component\ComponentHelper; use Joomla\CMS\HTML\HTMLHelper as Html; use Joomla\CMS\Layout\FileLayout; -use Joomla\CMS\MVC\View\HtmlView; +use Joomla\CMS\MVC\View\HtmlView as BaseHtmlView; use Joomla\CMS\Plugin\PluginHelper; use Joomla\CMS\Toolbar\ToolbarHelper; +use Joomla\CMS\Document\Document; +use TrueChristianChurch\Component\Getbible\Administrator\Helper\GetbibleHelper; use VDM\Joomla\Utilities\StringHelper; /** * Linker Html View class */ -class GetbibleViewLinker extends HtmlView +class HtmlView extends BaseHtmlView { /** * display method of View @@ -87,18 +90,18 @@ class GetbibleViewLinker extends HtmlView // Set the toolbar $this->addToolBar(); - + // Check for errors. if (count($errors = $this->get('Errors'))) { - throw new Exception(implode("\n", $errors), 500); + throw new \Exception(implode("\n", $errors), 500); } // Display the template parent::display($tpl); - // Set the document - $this->setDocument(); + // Set the html view document stuff + $this->setHtmlViewDoc(); } @@ -108,7 +111,7 @@ class GetbibleViewLinker extends HtmlView protected function addToolBar() { Factory::getApplication()->input->set('hidemainmenu', true); - $user = Factory::getUser(); + $user = Factory::getApplication()->getIdentity(); $userId = $user->id; $isNew = $this->item->id == 0; @@ -172,6 +175,7 @@ class GetbibleViewLinker extends HtmlView } } ToolbarHelper::divider(); + ToolbarHelper::inlinehelp(); // set help url for this view if found $this->help_url = GetbibleHelper::getHelpUrl('linker'); if (StringHelper::check($this->help_url)) @@ -189,9 +193,13 @@ class GetbibleViewLinker extends HtmlView */ public function escape($var) { - if(strlen($var) > 30) + if (!is_string($var)) { - // use the helper htmlEscape method instead and shorten the string + return $var; + } + elseif(strlen($var) > 30) + { + // use the helper htmlEscape method instead and shorten the string return StringHelper::html($var, $this->_charset, true, 30); } // use the helper htmlEscape method instead. @@ -199,18 +207,15 @@ class GetbibleViewLinker extends HtmlView } /** - * Method to set up the document properties + * Set this html view document related stuff. * * @return void + * @since 4.4.0 */ - protected function setDocument() + protected function setHtmlViewDoc(): void { $isNew = ($this->item->id < 1); - if (!isset($this->document)) - { - $this->document = Factory::getDocument(); - } - $this->document->setTitle(Text::_($isNew ? 'COM_GETBIBLE_LINKER_NEW' : 'COM_GETBIBLE_LINKER_EDIT')); + $this->getDocument()->setTitle(Text::_($isNew ? 'COM_GETBIBLE_LINKER_NEW' : 'COM_GETBIBLE_LINKER_EDIT')); Html::_('stylesheet', "administrator/components/com_getbible/assets/css/linker.css", ['version' => 'auto']); // Add the CSS for Footable diff --git a/admin/views/index.html b/admin/src/View/Linker/index.html similarity index 100% rename from admin/views/index.html rename to admin/src/View/Linker/index.html diff --git a/admin/views/linkers/view.html.php b/admin/src/View/Linkers/HtmlView.php similarity index 53% rename from admin/views/linkers/view.html.php rename to admin/src/View/Linkers/HtmlView.php index b3fdad4..7fbba20 100644 --- a/admin/views/linkers/view.html.php +++ b/admin/src/View/Linkers/HtmlView.php @@ -14,29 +14,32 @@ @license GNU/GPL Version 2 or later - http://www.gnu.org/licenses/gpl-2.0.html /------------------------------------------------------------------------------------------------------*/ +namespace TrueChristianChurch\Component\Getbible\Administrator\View\Linkers; // No direct access to this file -defined('_JEXEC') or die('Restricted access'); +\defined('_JEXEC') or die; use Joomla\CMS\Factory; use Joomla\CMS\Language\Text; +use Joomla\CMS\Toolbar\Toolbar; use Joomla\CMS\Form\FormHelper; use Joomla\CMS\Session\Session; use Joomla\CMS\Uri\Uri; -use Joomla\CMS\Toolbar\Toolbar; use Joomla\CMS\Component\ComponentHelper; use Joomla\CMS\HTML\HTMLHelper as Html; use Joomla\CMS\Layout\FileLayout; -use Joomla\CMS\MVC\View\HtmlView; +use Joomla\CMS\MVC\View\HtmlView as BaseHtmlView; use Joomla\CMS\Plugin\PluginHelper; use Joomla\CMS\Toolbar\ToolbarHelper; +use Joomla\CMS\Document\Document; +use TrueChristianChurch\Component\Getbible\Administrator\Helper\GetbibleHelper; use VDM\Joomla\Utilities\ArrayHelper; use VDM\Joomla\Utilities\StringHelper; /** * Getbible Html View class for the Linkers */ -class GetbibleViewLinkers extends HtmlView +class HtmlView extends BaseHtmlView { /** * Linkers view display method @@ -44,17 +47,11 @@ class GetbibleViewLinkers extends HtmlView */ 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 = Factory::getUser(); + $this->user = Factory::getApplication()->getIdentity(); // Load the filter form from xml. $this->filterForm = $this->get('FilterForm'); // Load the active filters. @@ -73,29 +70,29 @@ class GetbibleViewLinkers extends HtmlView $this->canDelete = $this->canDo->get('linker.delete'); $this->canBatch = ($this->canDo->get('linker.batch') && $this->canDo->get('core.batch')); + // If we don't have items we load the empty state + if (is_array($this->items) && !count((array) $this->items) && $this->isEmptyState = $this->get('IsEmptyState')) + { + $this->setLayout('emptystate'); + } + // 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); + throw new \Exception(implode("\n", $errors), 500); } // Display the template parent::display($tpl); - // Set the document - $this->setDocument(); + // Set the html view document stuff + $this->setHtmlViewDoc(); } /** @@ -103,9 +100,7 @@ class GetbibleViewLinkers extends HtmlView */ protected function addToolBar() { - JHtmlSidebar::setAction('index.php?option=com_getbible&view=linkers'); ToolbarHelper::title(Text::_('COM_GETBIBLE_LINKERS'), 'joomla'); - FormHelper::addFieldPath(JPATH_COMPONENT . '/models/fields'); if ($this->canCreate) { @@ -132,20 +127,6 @@ class GetbibleViewLinkers extends HtmlView } } - // Add a batch button - if ($this->canBatch && $this->canCreate && $this->canEdit && $this->canState) - { - // Get the toolbar object instance - $bar = Toolbar::getInstance('toolbar'); - // set the batch button name - $title = Text::_('JTOOLBAR_BATCH'); - // Instantiate a new JLayoutFile instance and render the batch button - $layout = new FileLayout('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)) { ToolbarHelper::deleteList('', 'linkers.delete', 'JTOOLBAR_EMPTY_TRASH'); @@ -168,100 +149,17 @@ class GetbibleViewLinkers extends HtmlView { ToolbarHelper::preferences('com_getbible'); } - - // Only load published batch if state and batch is allowed - if ($this->canState && $this->canBatch) - { - JHtmlBatch_::addListSelection( - Text::_('COM_GETBIBLE_KEEP_ORIGINAL_STATE'), - 'batch[published]', - Html::_('select.options', Html::_('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( - Text::_('COM_GETBIBLE_KEEP_ORIGINAL_ACCESS'), - 'batch[access]', - Html::_('select.options', Html::_('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 = FormHelper::loadFieldType('linkersfiltername')->options; - // We do some sanitation for Name filter - if (ArrayHelper::check($this->nameOptions) && - isset($this->nameOptions[0]->value) && - !StringHelper::check($this->nameOptions[0]->value)) - { - unset($this->nameOptions[0]); - } - // Name Batch Selection - JHtmlBatch_::addListSelection( - '- Keep Original '.Text::_('COM_GETBIBLE_LINKER_NAME_LABEL').' -', - 'batch[name]', - Html::_('select.options', $this->nameOptions, 'value', 'text') - ); - } - - // Only load Public Tagged Verses batch if create, edit, and batch is allowed - if ($this->canBatch && $this->canCreate && $this->canEdit) - { - // Set Public Tagged Verses Selection - $this->public_tagged_versesOptions = FormHelper::loadFieldType('linkersfilterpublictaggedverses')->options; - // We do some sanitation for Public Tagged Verses filter - if (ArrayHelper::check($this->public_tagged_versesOptions) && - isset($this->public_tagged_versesOptions[0]->value) && - !StringHelper::check($this->public_tagged_versesOptions[0]->value)) - { - unset($this->public_tagged_versesOptions[0]); - } - // Public Tagged Verses Batch Selection - JHtmlBatch_::addListSelection( - '- Keep Original '.Text::_('COM_GETBIBLE_LINKER_PUBLIC_TAGGED_VERSES_LABEL').' -', - 'batch[public_tagged_verses]', - Html::_('select.options', $this->public_tagged_versesOptions, 'value', 'text') - ); - } - - // Only load Public Notes batch if create, edit, and batch is allowed - if ($this->canBatch && $this->canCreate && $this->canEdit) - { - // Set Public Notes Selection - $this->public_notesOptions = FormHelper::loadFieldType('linkersfilterpublicnotes')->options; - // We do some sanitation for Public Notes filter - if (ArrayHelper::check($this->public_notesOptions) && - isset($this->public_notesOptions[0]->value) && - !StringHelper::check($this->public_notesOptions[0]->value)) - { - unset($this->public_notesOptions[0]); - } - // Public Notes Batch Selection - JHtmlBatch_::addListSelection( - '- Keep Original '.Text::_('COM_GETBIBLE_LINKER_PUBLIC_NOTES_LABEL').' -', - 'batch[public_notes]', - Html::_('select.options', $this->public_notesOptions, 'value', 'text') - ); - } } /** - * Method to set up the document properties + * Set this html view document related stuff. * * @return void + * @since 4.4.0 */ - protected function setDocument() + protected function setHtmlViewDoc(): void { - if (!isset($this->document)) - { - $this->document = Factory::getDocument(); - } - $this->document->setTitle(Text::_('COM_GETBIBLE_LINKERS')); + $this->getDocument()->setTitle(Text::_('COM_GETBIBLE_LINKERS')); Html::_('stylesheet', "administrator/components/com_getbible/assets/css/linkers.css", ['version' => 'auto']); } @@ -274,7 +172,11 @@ class GetbibleViewLinkers extends HtmlView */ public function escape($var) { - if(strlen($var) > 50) + if (!is_string($var)) + { + return $var; + } + elseif(strlen($var) > 50) { // use the helper htmlEscape method instead and shorten the string return StringHelper::html($var, $this->_charset, true); diff --git a/admin/views/linker/tmpl/index.html b/admin/src/View/Linkers/index.html similarity index 100% rename from admin/views/linker/tmpl/index.html rename to admin/src/View/Linkers/index.html diff --git a/admin/views/note/view.html.php b/admin/src/View/Note/HtmlView.php similarity index 87% rename from admin/views/note/view.html.php rename to admin/src/View/Note/HtmlView.php index 1ab3086..e0ba93d 100644 --- a/admin/views/note/view.html.php +++ b/admin/src/View/Note/HtmlView.php @@ -14,28 +14,31 @@ @license GNU/GPL Version 2 or later - http://www.gnu.org/licenses/gpl-2.0.html /------------------------------------------------------------------------------------------------------*/ +namespace TrueChristianChurch\Component\Getbible\Administrator\View\Note; // No direct access to this file -defined('_JEXEC') or die('Restricted access'); +\defined('_JEXEC') or die; use Joomla\CMS\Factory; use Joomla\CMS\Language\Text; +use Joomla\CMS\Toolbar\Toolbar; use Joomla\CMS\Form\FormHelper; use Joomla\CMS\Session\Session; use Joomla\CMS\Uri\Uri; -use Joomla\CMS\Toolbar\Toolbar; use Joomla\CMS\Component\ComponentHelper; use Joomla\CMS\HTML\HTMLHelper as Html; use Joomla\CMS\Layout\FileLayout; -use Joomla\CMS\MVC\View\HtmlView; +use Joomla\CMS\MVC\View\HtmlView as BaseHtmlView; use Joomla\CMS\Plugin\PluginHelper; use Joomla\CMS\Toolbar\ToolbarHelper; +use Joomla\CMS\Document\Document; +use TrueChristianChurch\Component\Getbible\Administrator\Helper\GetbibleHelper; use VDM\Joomla\Utilities\StringHelper; /** * Note Html View class */ -class GetbibleViewNote extends HtmlView +class HtmlView extends BaseHtmlView { /** * display method of View @@ -78,18 +81,18 @@ class GetbibleViewNote extends HtmlView // Set the toolbar $this->addToolBar(); - + // Check for errors. if (count($errors = $this->get('Errors'))) { - throw new Exception(implode("\n", $errors), 500); + throw new \Exception(implode("\n", $errors), 500); } // Display the template parent::display($tpl); - // Set the document - $this->setDocument(); + // Set the html view document stuff + $this->setHtmlViewDoc(); } @@ -99,7 +102,7 @@ class GetbibleViewNote extends HtmlView protected function addToolBar() { Factory::getApplication()->input->set('hidemainmenu', true); - $user = Factory::getUser(); + $user = Factory::getApplication()->getIdentity(); $userId = $user->id; $isNew = $this->item->id == 0; @@ -168,6 +171,7 @@ class GetbibleViewNote extends HtmlView } } ToolbarHelper::divider(); + ToolbarHelper::inlinehelp(); // set help url for this view if found $this->help_url = GetbibleHelper::getHelpUrl('note'); if (StringHelper::check($this->help_url)) @@ -185,9 +189,13 @@ class GetbibleViewNote extends HtmlView */ public function escape($var) { - if(strlen($var) > 30) + if (!is_string($var)) { - // use the helper htmlEscape method instead and shorten the string + return $var; + } + elseif(strlen($var) > 30) + { + // use the helper htmlEscape method instead and shorten the string return StringHelper::html($var, $this->_charset, true, 30); } // use the helper htmlEscape method instead. @@ -195,18 +203,15 @@ class GetbibleViewNote extends HtmlView } /** - * Method to set up the document properties + * Set this html view document related stuff. * * @return void + * @since 4.4.0 */ - protected function setDocument() + protected function setHtmlViewDoc(): void { $isNew = ($this->item->id < 1); - if (!isset($this->document)) - { - $this->document = Factory::getDocument(); - } - $this->document->setTitle(Text::_($isNew ? 'COM_GETBIBLE_NOTE_NEW' : 'COM_GETBIBLE_NOTE_EDIT')); + $this->getDocument()->setTitle(Text::_($isNew ? 'COM_GETBIBLE_NOTE_NEW' : 'COM_GETBIBLE_NOTE_EDIT')); Html::_('stylesheet', "administrator/components/com_getbible/assets/css/note.css", ['version' => 'auto']); Html::_('script', $this->script, ['version' => 'auto']); Html::_('script', "administrator/components/com_getbible/views/note/submitbutton.js", ['version' => 'auto']); diff --git a/admin/views/linkers/index.html b/admin/src/View/Note/index.html similarity index 100% rename from admin/views/linkers/index.html rename to admin/src/View/Note/index.html diff --git a/admin/src/View/Notes/HtmlView.php b/admin/src/View/Notes/HtmlView.php new file mode 100644 index 0000000..8925beb --- /dev/null +++ b/admin/src/View/Notes/HtmlView.php @@ -0,0 +1,204 @@ + + @git Get Bible + @github Get Bible + @support Get Bible + @copyright Copyright (C) 2015. All Rights Reserved + @license GNU/GPL Version 2 or later - http://www.gnu.org/licenses/gpl-2.0.html + +/------------------------------------------------------------------------------------------------------*/ +namespace TrueChristianChurch\Component\Getbible\Administrator\View\Notes; + +// No direct access to this file +\defined('_JEXEC') or die; + +use Joomla\CMS\Factory; +use Joomla\CMS\Language\Text; +use Joomla\CMS\Toolbar\Toolbar; +use Joomla\CMS\Form\FormHelper; +use Joomla\CMS\Session\Session; +use Joomla\CMS\Uri\Uri; +use Joomla\CMS\Component\ComponentHelper; +use Joomla\CMS\HTML\HTMLHelper as Html; +use Joomla\CMS\Layout\FileLayout; +use Joomla\CMS\MVC\View\HtmlView as BaseHtmlView; +use Joomla\CMS\Plugin\PluginHelper; +use Joomla\CMS\Toolbar\ToolbarHelper; +use Joomla\CMS\Document\Document; +use TrueChristianChurch\Component\Getbible\Administrator\Helper\GetbibleHelper; +use VDM\Joomla\Utilities\ArrayHelper; +use VDM\Joomla\Utilities\StringHelper; + +/** + * Getbible Html View class for the Notes + */ +class HtmlView extends BaseHtmlView +{ + /** + * Notes view display method + * @return void + */ + function display($tpl = null) + { + // Assign data to the view + $this->items = $this->get('Items'); + $this->pagination = $this->get('Pagination'); + $this->state = $this->get('State'); + $this->user = Factory::getApplication()->getIdentity(); + // 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) Uri::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('note.batch') && $this->canDo->get('core.batch')); + + // If we don't have items we load the empty state + if (is_array($this->items) && !count((array) $this->items) && $this->isEmptyState = $this->get('IsEmptyState')) + { + $this->setLayout('emptystate'); + } + + // We don't need toolbar in the modal window. + if ($this->getLayout() !== 'modal') + { + $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 html view document stuff + $this->setHtmlViewDoc(); + } + + /** + * Setting the toolbar + */ + protected function addToolBar() + { + ToolbarHelper::title(Text::_('COM_GETBIBLE_NOTES'), 'file'); + + if ($this->canCreate) + { + ToolbarHelper::addNew('note.add'); + } + + // Only load if there are items + if (ArrayHelper::check($this->items)) + { + if ($this->canEdit) + { + ToolbarHelper::editList('note.edit'); + } + + if ($this->canState) + { + ToolbarHelper::publishList('notes.publish'); + ToolbarHelper::unpublishList('notes.unpublish'); + ToolbarHelper::archiveList('notes.archive'); + + if ($this->canDo->get('core.admin')) + { + ToolbarHelper::checkin('notes.checkin'); + } + } + + if ($this->state->get('filter.published') == -2 && ($this->canState && $this->canDelete)) + { + ToolbarHelper::deleteList('', 'notes.delete', 'JTOOLBAR_EMPTY_TRASH'); + } + elseif ($this->canState && $this->canDelete) + { + ToolbarHelper::trash('notes.trash'); + } + } + + // set help url for this view if found + $this->help_url = GetbibleHelper::getHelpUrl('notes'); + if (StringHelper::check($this->help_url)) + { + ToolbarHelper::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')) + { + ToolbarHelper::preferences('com_getbible'); + } + } + + /** + * Set this html view document related stuff. + * + * @return void + * @since 4.4.0 + */ + protected function setHtmlViewDoc(): void + { + $this->getDocument()->setTitle(Text::_('COM_GETBIBLE_NOTES')); + Html::_('stylesheet', "administrator/components/com_getbible/assets/css/notes.css", ['version' => 'auto']); + } + + /** + * 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 (!is_string($var)) + { + return $var; + } + elseif(strlen($var) > 50) + { + // use the helper htmlEscape method instead and shorten the string + return StringHelper::html($var, $this->_charset, true); + } + // use the helper htmlEscape method instead. + return StringHelper::html($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' => Text::_('JGRID_HEADING_ORDERING'), + 'a.published' => Text::_('JSTATUS'), + 'a.book_nr' => Text::_('COM_GETBIBLE_NOTE_BOOK_NR_LABEL'), + 'g.name' => Text::_('COM_GETBIBLE_NOTE_LINKER_LABEL'), + 'a.access' => Text::_('COM_GETBIBLE_NOTE_ACCESS_LABEL'), + 'a.id' => Text::_('JGRID_HEADING_ID') + ); + } +} diff --git a/admin/views/linkers/tmpl/index.html b/admin/src/View/Notes/index.html similarity index 100% rename from admin/views/linkers/tmpl/index.html rename to admin/src/View/Notes/index.html diff --git a/admin/views/open_ai_message/view.html.php b/admin/src/View/Open_ai_message/HtmlView.php similarity index 87% rename from admin/views/open_ai_message/view.html.php rename to admin/src/View/Open_ai_message/HtmlView.php index 6b56271..9c234a6 100644 --- a/admin/views/open_ai_message/view.html.php +++ b/admin/src/View/Open_ai_message/HtmlView.php @@ -14,28 +14,31 @@ @license GNU/GPL Version 2 or later - http://www.gnu.org/licenses/gpl-2.0.html /------------------------------------------------------------------------------------------------------*/ +namespace TrueChristianChurch\Component\Getbible\Administrator\View\Open_ai_message; // No direct access to this file -defined('_JEXEC') or die('Restricted access'); +\defined('_JEXEC') or die; use Joomla\CMS\Factory; use Joomla\CMS\Language\Text; +use Joomla\CMS\Toolbar\Toolbar; use Joomla\CMS\Form\FormHelper; use Joomla\CMS\Session\Session; use Joomla\CMS\Uri\Uri; -use Joomla\CMS\Toolbar\Toolbar; use Joomla\CMS\Component\ComponentHelper; use Joomla\CMS\HTML\HTMLHelper as Html; use Joomla\CMS\Layout\FileLayout; -use Joomla\CMS\MVC\View\HtmlView; +use Joomla\CMS\MVC\View\HtmlView as BaseHtmlView; use Joomla\CMS\Plugin\PluginHelper; use Joomla\CMS\Toolbar\ToolbarHelper; +use Joomla\CMS\Document\Document; +use TrueChristianChurch\Component\Getbible\Administrator\Helper\GetbibleHelper; use VDM\Joomla\Utilities\StringHelper; /** * Open_ai_message Html View class */ -class GetbibleViewOpen_ai_message extends HtmlView +class HtmlView extends BaseHtmlView { /** * display method of View @@ -78,18 +81,18 @@ class GetbibleViewOpen_ai_message extends HtmlView // Set the toolbar $this->addToolBar(); - + // Check for errors. if (count($errors = $this->get('Errors'))) { - throw new Exception(implode("\n", $errors), 500); + throw new \Exception(implode("\n", $errors), 500); } // Display the template parent::display($tpl); - // Set the document - $this->setDocument(); + // Set the html view document stuff + $this->setHtmlViewDoc(); } @@ -99,7 +102,7 @@ class GetbibleViewOpen_ai_message extends HtmlView protected function addToolBar() { Factory::getApplication()->input->set('hidemainmenu', true); - $user = Factory::getUser(); + $user = Factory::getApplication()->getIdentity(); $userId = $user->id; $isNew = $this->item->id == 0; @@ -168,6 +171,7 @@ class GetbibleViewOpen_ai_message extends HtmlView } } ToolbarHelper::divider(); + ToolbarHelper::inlinehelp(); // set help url for this view if found $this->help_url = GetbibleHelper::getHelpUrl('open_ai_message'); if (StringHelper::check($this->help_url)) @@ -185,9 +189,13 @@ class GetbibleViewOpen_ai_message extends HtmlView */ public function escape($var) { - if(strlen($var) > 30) + if (!is_string($var)) { - // use the helper htmlEscape method instead and shorten the string + return $var; + } + elseif(strlen($var) > 30) + { + // use the helper htmlEscape method instead and shorten the string return StringHelper::html($var, $this->_charset, true, 30); } // use the helper htmlEscape method instead. @@ -195,18 +203,15 @@ class GetbibleViewOpen_ai_message extends HtmlView } /** - * Method to set up the document properties + * Set this html view document related stuff. * * @return void + * @since 4.4.0 */ - protected function setDocument() + protected function setHtmlViewDoc(): void { $isNew = ($this->item->id < 1); - if (!isset($this->document)) - { - $this->document = Factory::getDocument(); - } - $this->document->setTitle(Text::_($isNew ? 'COM_GETBIBLE_OPEN_AI_MESSAGE_NEW' : 'COM_GETBIBLE_OPEN_AI_MESSAGE_EDIT')); + $this->getDocument()->setTitle(Text::_($isNew ? 'COM_GETBIBLE_OPEN_AI_MESSAGE_NEW' : 'COM_GETBIBLE_OPEN_AI_MESSAGE_EDIT')); Html::_('stylesheet', "administrator/components/com_getbible/assets/css/open_ai_message.css", ['version' => 'auto']); Html::_('script', $this->script, ['version' => 'auto']); Html::_('script', "administrator/components/com_getbible/views/open_ai_message/submitbutton.js", ['version' => 'auto']); diff --git a/admin/views/note/tmpl/index.html b/admin/src/View/Open_ai_message/index.html similarity index 100% rename from admin/views/note/tmpl/index.html rename to admin/src/View/Open_ai_message/index.html diff --git a/admin/views/open_ai_messages/view.html.php b/admin/src/View/Open_ai_messages/HtmlView.php similarity index 50% rename from admin/views/open_ai_messages/view.html.php rename to admin/src/View/Open_ai_messages/HtmlView.php index 14e0c99..12182ec 100644 --- a/admin/views/open_ai_messages/view.html.php +++ b/admin/src/View/Open_ai_messages/HtmlView.php @@ -14,29 +14,32 @@ @license GNU/GPL Version 2 or later - http://www.gnu.org/licenses/gpl-2.0.html /------------------------------------------------------------------------------------------------------*/ +namespace TrueChristianChurch\Component\Getbible\Administrator\View\Open_ai_messages; // No direct access to this file -defined('_JEXEC') or die('Restricted access'); +\defined('_JEXEC') or die; use Joomla\CMS\Factory; use Joomla\CMS\Language\Text; +use Joomla\CMS\Toolbar\Toolbar; use Joomla\CMS\Form\FormHelper; use Joomla\CMS\Session\Session; use Joomla\CMS\Uri\Uri; -use Joomla\CMS\Toolbar\Toolbar; use Joomla\CMS\Component\ComponentHelper; use Joomla\CMS\HTML\HTMLHelper as Html; use Joomla\CMS\Layout\FileLayout; -use Joomla\CMS\MVC\View\HtmlView; +use Joomla\CMS\MVC\View\HtmlView as BaseHtmlView; use Joomla\CMS\Plugin\PluginHelper; use Joomla\CMS\Toolbar\ToolbarHelper; +use Joomla\CMS\Document\Document; +use TrueChristianChurch\Component\Getbible\Administrator\Helper\GetbibleHelper; use VDM\Joomla\Utilities\ArrayHelper; use VDM\Joomla\Utilities\StringHelper; /** * Getbible Html View class for the Open_ai_messages */ -class GetbibleViewOpen_ai_messages extends HtmlView +class HtmlView extends BaseHtmlView { /** * Open_ai_messages view display method @@ -44,17 +47,11 @@ class GetbibleViewOpen_ai_messages extends HtmlView */ 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 = Factory::getUser(); + $this->user = Factory::getApplication()->getIdentity(); // Load the filter form from xml. $this->filterForm = $this->get('FilterForm'); // Load the active filters. @@ -73,29 +70,29 @@ class GetbibleViewOpen_ai_messages extends HtmlView $this->canDelete = $this->canDo->get('open_ai_message.delete'); $this->canBatch = ($this->canDo->get('open_ai_message.batch') && $this->canDo->get('core.batch')); + // If we don't have items we load the empty state + if (is_array($this->items) && !count((array) $this->items) && $this->isEmptyState = $this->get('IsEmptyState')) + { + $this->setLayout('emptystate'); + } + // 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); + throw new \Exception(implode("\n", $errors), 500); } // Display the template parent::display($tpl); - // Set the document - $this->setDocument(); + // Set the html view document stuff + $this->setHtmlViewDoc(); } /** @@ -103,9 +100,7 @@ class GetbibleViewOpen_ai_messages extends HtmlView */ protected function addToolBar() { - JHtmlSidebar::setAction('index.php?option=com_getbible&view=open_ai_messages'); ToolbarHelper::title(Text::_('COM_GETBIBLE_OPEN_AI_MESSAGES'), 'comment'); - FormHelper::addFieldPath(JPATH_COMPONENT . '/models/fields'); if ($this->canCreate) { @@ -132,20 +127,6 @@ class GetbibleViewOpen_ai_messages extends HtmlView } } - // Add a batch button - if ($this->canBatch && $this->canCreate && $this->canEdit && $this->canState) - { - // Get the toolbar object instance - $bar = Toolbar::getInstance('toolbar'); - // set the batch button name - $title = Text::_('JTOOLBAR_BATCH'); - // Instantiate a new JLayoutFile instance and render the batch button - $layout = new FileLayout('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)) { ToolbarHelper::deleteList('', 'open_ai_messages.delete', 'JTOOLBAR_EMPTY_TRASH'); @@ -168,120 +149,17 @@ class GetbibleViewOpen_ai_messages extends HtmlView { ToolbarHelper::preferences('com_getbible'); } - - // Only load published batch if state and batch is allowed - if ($this->canState && $this->canBatch) - { - JHtmlBatch_::addListSelection( - Text::_('COM_GETBIBLE_KEEP_ORIGINAL_STATE'), - 'batch[published]', - Html::_('select.options', Html::_('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( - Text::_('COM_GETBIBLE_KEEP_ORIGINAL_ACCESS'), - 'batch[access]', - Html::_('select.options', Html::_('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 = FormHelper::loadFieldType('openaimessagesfilterrole')->options; - // We do some sanitation for Role filter - if (ArrayHelper::check($this->roleOptions) && - isset($this->roleOptions[0]->value) && - !StringHelper::check($this->roleOptions[0]->value)) - { - unset($this->roleOptions[0]); - } - // Role Batch Selection - JHtmlBatch_::addListSelection( - '- Keep Original '.Text::_('COM_GETBIBLE_OPEN_AI_MESSAGE_ROLE_LABEL').' -', - 'batch[role]', - Html::_('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 = FormHelper::loadFieldType('Openairesponses')->options; - // We do some sanitation for Open Ai Response Response Id filter - if (ArrayHelper::check($this->open_ai_responseResponse_idOptions) && - isset($this->open_ai_responseResponse_idOptions[0]->value) && - !StringHelper::check($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 '.Text::_('COM_GETBIBLE_OPEN_AI_MESSAGE_OPEN_AI_RESPONSE_LABEL').' -', - 'batch[open_ai_response]', - Html::_('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 = FormHelper::loadFieldType('Prompts')->options; - // We do some sanitation for Prompt Name filter - if (ArrayHelper::check($this->promptNameOptions) && - isset($this->promptNameOptions[0]->value) && - !StringHelper::check($this->promptNameOptions[0]->value)) - { - unset($this->promptNameOptions[0]); - } - // Prompt Name Batch Selection - JHtmlBatch_::addListSelection( - '- Keep Original '.Text::_('COM_GETBIBLE_OPEN_AI_MESSAGE_PROMPT_LABEL').' -', - 'batch[prompt]', - Html::_('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 = FormHelper::loadFieldType('openaimessagesfiltersource')->options; - // We do some sanitation for Source filter - if (ArrayHelper::check($this->sourceOptions) && - isset($this->sourceOptions[0]->value) && - !StringHelper::check($this->sourceOptions[0]->value)) - { - unset($this->sourceOptions[0]); - } - // Source Batch Selection - JHtmlBatch_::addListSelection( - '- Keep Original '.Text::_('COM_GETBIBLE_OPEN_AI_MESSAGE_SOURCE_LABEL').' -', - 'batch[source]', - Html::_('select.options', $this->sourceOptions, 'value', 'text') - ); - } } /** - * Method to set up the document properties + * Set this html view document related stuff. * * @return void + * @since 4.4.0 */ - protected function setDocument() + protected function setHtmlViewDoc(): void { - if (!isset($this->document)) - { - $this->document = Factory::getDocument(); - } - $this->document->setTitle(Text::_('COM_GETBIBLE_OPEN_AI_MESSAGES')); + $this->getDocument()->setTitle(Text::_('COM_GETBIBLE_OPEN_AI_MESSAGES')); Html::_('stylesheet', "administrator/components/com_getbible/assets/css/open_ai_messages.css", ['version' => 'auto']); } @@ -294,7 +172,11 @@ class GetbibleViewOpen_ai_messages extends HtmlView */ public function escape($var) { - if(strlen($var) > 50) + if (!is_string($var)) + { + return $var; + } + elseif(strlen($var) > 50) { // use the helper htmlEscape method instead and shorten the string return StringHelper::html($var, $this->_charset, true); diff --git a/admin/views/notes/index.html b/admin/src/View/Open_ai_messages/index.html similarity index 100% rename from admin/views/notes/index.html rename to admin/src/View/Open_ai_messages/index.html diff --git a/admin/views/open_ai_response/view.html.php b/admin/src/View/Open_ai_response/HtmlView.php similarity index 88% rename from admin/views/open_ai_response/view.html.php rename to admin/src/View/Open_ai_response/HtmlView.php index ee464de..7c32e34 100644 --- a/admin/views/open_ai_response/view.html.php +++ b/admin/src/View/Open_ai_response/HtmlView.php @@ -14,28 +14,31 @@ @license GNU/GPL Version 2 or later - http://www.gnu.org/licenses/gpl-2.0.html /------------------------------------------------------------------------------------------------------*/ +namespace TrueChristianChurch\Component\Getbible\Administrator\View\Open_ai_response; // No direct access to this file -defined('_JEXEC') or die('Restricted access'); +\defined('_JEXEC') or die; use Joomla\CMS\Factory; use Joomla\CMS\Language\Text; +use Joomla\CMS\Toolbar\Toolbar; use Joomla\CMS\Form\FormHelper; use Joomla\CMS\Session\Session; use Joomla\CMS\Uri\Uri; -use Joomla\CMS\Toolbar\Toolbar; use Joomla\CMS\Component\ComponentHelper; use Joomla\CMS\HTML\HTMLHelper as Html; use Joomla\CMS\Layout\FileLayout; -use Joomla\CMS\MVC\View\HtmlView; +use Joomla\CMS\MVC\View\HtmlView as BaseHtmlView; use Joomla\CMS\Plugin\PluginHelper; use Joomla\CMS\Toolbar\ToolbarHelper; +use Joomla\CMS\Document\Document; +use TrueChristianChurch\Component\Getbible\Administrator\Helper\GetbibleHelper; use VDM\Joomla\Utilities\StringHelper; /** * Open_ai_response Html View class */ -class GetbibleViewOpen_ai_response extends HtmlView +class HtmlView extends BaseHtmlView { /** * display method of View @@ -81,18 +84,18 @@ class GetbibleViewOpen_ai_response extends HtmlView // Set the toolbar $this->addToolBar(); - + // Check for errors. if (count($errors = $this->get('Errors'))) { - throw new Exception(implode("\n", $errors), 500); + throw new \Exception(implode("\n", $errors), 500); } // Display the template parent::display($tpl); - // Set the document - $this->setDocument(); + // Set the html view document stuff + $this->setHtmlViewDoc(); } @@ -102,7 +105,7 @@ class GetbibleViewOpen_ai_response extends HtmlView protected function addToolBar() { Factory::getApplication()->input->set('hidemainmenu', true); - $user = Factory::getUser(); + $user = Factory::getApplication()->getIdentity(); $userId = $user->id; $isNew = $this->item->id == 0; @@ -171,6 +174,7 @@ class GetbibleViewOpen_ai_response extends HtmlView } } ToolbarHelper::divider(); + ToolbarHelper::inlinehelp(); // set help url for this view if found $this->help_url = GetbibleHelper::getHelpUrl('open_ai_response'); if (StringHelper::check($this->help_url)) @@ -188,9 +192,13 @@ class GetbibleViewOpen_ai_response extends HtmlView */ public function escape($var) { - if(strlen($var) > 30) + if (!is_string($var)) { - // use the helper htmlEscape method instead and shorten the string + return $var; + } + elseif(strlen($var) > 30) + { + // use the helper htmlEscape method instead and shorten the string return StringHelper::html($var, $this->_charset, true, 30); } // use the helper htmlEscape method instead. @@ -198,18 +206,15 @@ class GetbibleViewOpen_ai_response extends HtmlView } /** - * Method to set up the document properties + * Set this html view document related stuff. * * @return void + * @since 4.4.0 */ - protected function setDocument() + protected function setHtmlViewDoc(): void { $isNew = ($this->item->id < 1); - if (!isset($this->document)) - { - $this->document = Factory::getDocument(); - } - $this->document->setTitle(Text::_($isNew ? 'COM_GETBIBLE_OPEN_AI_RESPONSE_NEW' : 'COM_GETBIBLE_OPEN_AI_RESPONSE_EDIT')); + $this->getDocument()->setTitle(Text::_($isNew ? 'COM_GETBIBLE_OPEN_AI_RESPONSE_NEW' : 'COM_GETBIBLE_OPEN_AI_RESPONSE_EDIT')); Html::_('stylesheet', "administrator/components/com_getbible/assets/css/open_ai_response.css", ['version' => 'auto']); // Add the CSS for Footable diff --git a/admin/views/notes/tmpl/index.html b/admin/src/View/Open_ai_response/index.html similarity index 100% rename from admin/views/notes/tmpl/index.html rename to admin/src/View/Open_ai_response/index.html diff --git a/admin/views/open_ai_responses/view.html.php b/admin/src/View/Open_ai_responses/HtmlView.php similarity index 55% rename from admin/views/open_ai_responses/view.html.php rename to admin/src/View/Open_ai_responses/HtmlView.php index 526cc69..c834c3d 100644 --- a/admin/views/open_ai_responses/view.html.php +++ b/admin/src/View/Open_ai_responses/HtmlView.php @@ -14,29 +14,32 @@ @license GNU/GPL Version 2 or later - http://www.gnu.org/licenses/gpl-2.0.html /------------------------------------------------------------------------------------------------------*/ +namespace TrueChristianChurch\Component\Getbible\Administrator\View\Open_ai_responses; // No direct access to this file -defined('_JEXEC') or die('Restricted access'); +\defined('_JEXEC') or die; use Joomla\CMS\Factory; use Joomla\CMS\Language\Text; +use Joomla\CMS\Toolbar\Toolbar; use Joomla\CMS\Form\FormHelper; use Joomla\CMS\Session\Session; use Joomla\CMS\Uri\Uri; -use Joomla\CMS\Toolbar\Toolbar; use Joomla\CMS\Component\ComponentHelper; use Joomla\CMS\HTML\HTMLHelper as Html; use Joomla\CMS\Layout\FileLayout; -use Joomla\CMS\MVC\View\HtmlView; +use Joomla\CMS\MVC\View\HtmlView as BaseHtmlView; use Joomla\CMS\Plugin\PluginHelper; use Joomla\CMS\Toolbar\ToolbarHelper; +use Joomla\CMS\Document\Document; +use TrueChristianChurch\Component\Getbible\Administrator\Helper\GetbibleHelper; use VDM\Joomla\Utilities\ArrayHelper; use VDM\Joomla\Utilities\StringHelper; /** * Getbible Html View class for the Open_ai_responses */ -class GetbibleViewOpen_ai_responses extends HtmlView +class HtmlView extends BaseHtmlView { /** * Open_ai_responses view display method @@ -44,17 +47,11 @@ class GetbibleViewOpen_ai_responses extends HtmlView */ 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 = Factory::getUser(); + $this->user = Factory::getApplication()->getIdentity(); // Load the filter form from xml. $this->filterForm = $this->get('FilterForm'); // Load the active filters. @@ -73,29 +70,29 @@ class GetbibleViewOpen_ai_responses extends HtmlView $this->canDelete = $this->canDo->get('open_ai_response.delete'); $this->canBatch = ($this->canDo->get('open_ai_response.batch') && $this->canDo->get('core.batch')); + // If we don't have items we load the empty state + if (is_array($this->items) && !count((array) $this->items) && $this->isEmptyState = $this->get('IsEmptyState')) + { + $this->setLayout('emptystate'); + } + // 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); + throw new \Exception(implode("\n", $errors), 500); } // Display the template parent::display($tpl); - // Set the document - $this->setDocument(); + // Set the html view document stuff + $this->setHtmlViewDoc(); } /** @@ -103,9 +100,7 @@ class GetbibleViewOpen_ai_responses extends HtmlView */ protected function addToolBar() { - JHtmlSidebar::setAction('index.php?option=com_getbible&view=open_ai_responses'); ToolbarHelper::title(Text::_('COM_GETBIBLE_OPEN_AI_RESPONSES'), 'reply'); - FormHelper::addFieldPath(JPATH_COMPONENT . '/models/fields'); if ($this->canCreate) { @@ -132,20 +127,6 @@ class GetbibleViewOpen_ai_responses extends HtmlView } } - // Add a batch button - if ($this->canBatch && $this->canCreate && $this->canEdit && $this->canState) - { - // Get the toolbar object instance - $bar = Toolbar::getInstance('toolbar'); - // set the batch button name - $title = Text::_('JTOOLBAR_BATCH'); - // Instantiate a new JLayoutFile instance and render the batch button - $layout = new FileLayout('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)) { ToolbarHelper::deleteList('', 'open_ai_responses.delete', 'JTOOLBAR_EMPTY_TRASH'); @@ -168,100 +149,17 @@ class GetbibleViewOpen_ai_responses extends HtmlView { ToolbarHelper::preferences('com_getbible'); } - - // Only load published batch if state and batch is allowed - if ($this->canState && $this->canBatch) - { - JHtmlBatch_::addListSelection( - Text::_('COM_GETBIBLE_KEEP_ORIGINAL_STATE'), - 'batch[published]', - Html::_('select.options', Html::_('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( - Text::_('COM_GETBIBLE_KEEP_ORIGINAL_ACCESS'), - 'batch[access]', - Html::_('select.options', Html::_('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 = FormHelper::loadFieldType('openairesponsesfilterresponseid')->options; - // We do some sanitation for Response Id filter - if (ArrayHelper::check($this->response_idOptions) && - isset($this->response_idOptions[0]->value) && - !StringHelper::check($this->response_idOptions[0]->value)) - { - unset($this->response_idOptions[0]); - } - // Response Id Batch Selection - JHtmlBatch_::addListSelection( - '- Keep Original '.Text::_('COM_GETBIBLE_OPEN_AI_RESPONSE_RESPONSE_ID_LABEL').' -', - 'batch[response_id]', - Html::_('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 = FormHelper::loadFieldType('Prompts')->options; - // We do some sanitation for Prompt Name filter - if (ArrayHelper::check($this->promptNameOptions) && - isset($this->promptNameOptions[0]->value) && - !StringHelper::check($this->promptNameOptions[0]->value)) - { - unset($this->promptNameOptions[0]); - } - // Prompt Name Batch Selection - JHtmlBatch_::addListSelection( - '- Keep Original '.Text::_('COM_GETBIBLE_OPEN_AI_RESPONSE_PROMPT_LABEL').' -', - 'batch[prompt]', - Html::_('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 = FormHelper::loadFieldType('openairesponsesfilterresponsemodel')->options; - // We do some sanitation for Response Model filter - if (ArrayHelper::check($this->response_modelOptions) && - isset($this->response_modelOptions[0]->value) && - !StringHelper::check($this->response_modelOptions[0]->value)) - { - unset($this->response_modelOptions[0]); - } - // Response Model Batch Selection - JHtmlBatch_::addListSelection( - '- Keep Original '.Text::_('COM_GETBIBLE_OPEN_AI_RESPONSE_RESPONSE_MODEL_LABEL').' -', - 'batch[response_model]', - Html::_('select.options', $this->response_modelOptions, 'value', 'text') - ); - } } /** - * Method to set up the document properties + * Set this html view document related stuff. * * @return void + * @since 4.4.0 */ - protected function setDocument() + protected function setHtmlViewDoc(): void { - if (!isset($this->document)) - { - $this->document = Factory::getDocument(); - } - $this->document->setTitle(Text::_('COM_GETBIBLE_OPEN_AI_RESPONSES')); + $this->getDocument()->setTitle(Text::_('COM_GETBIBLE_OPEN_AI_RESPONSES')); Html::_('stylesheet', "administrator/components/com_getbible/assets/css/open_ai_responses.css", ['version' => 'auto']); } @@ -274,7 +172,11 @@ class GetbibleViewOpen_ai_responses extends HtmlView */ public function escape($var) { - if(strlen($var) > 50) + if (!is_string($var)) + { + return $var; + } + elseif(strlen($var) > 50) { // use the helper htmlEscape method instead and shorten the string return StringHelper::html($var, $this->_charset, true); diff --git a/admin/views/open_ai_message/tmpl/index.html b/admin/src/View/Open_ai_responses/index.html similarity index 100% rename from admin/views/open_ai_message/tmpl/index.html rename to admin/src/View/Open_ai_responses/index.html diff --git a/admin/views/password/view.html.php b/admin/src/View/Password/HtmlView.php similarity index 87% rename from admin/views/password/view.html.php rename to admin/src/View/Password/HtmlView.php index 76d6c10..8299180 100644 --- a/admin/views/password/view.html.php +++ b/admin/src/View/Password/HtmlView.php @@ -14,28 +14,31 @@ @license GNU/GPL Version 2 or later - http://www.gnu.org/licenses/gpl-2.0.html /------------------------------------------------------------------------------------------------------*/ +namespace TrueChristianChurch\Component\Getbible\Administrator\View\Password; // No direct access to this file -defined('_JEXEC') or die('Restricted access'); +\defined('_JEXEC') or die; use Joomla\CMS\Factory; use Joomla\CMS\Language\Text; +use Joomla\CMS\Toolbar\Toolbar; use Joomla\CMS\Form\FormHelper; use Joomla\CMS\Session\Session; use Joomla\CMS\Uri\Uri; -use Joomla\CMS\Toolbar\Toolbar; use Joomla\CMS\Component\ComponentHelper; use Joomla\CMS\HTML\HTMLHelper as Html; use Joomla\CMS\Layout\FileLayout; -use Joomla\CMS\MVC\View\HtmlView; +use Joomla\CMS\MVC\View\HtmlView as BaseHtmlView; use Joomla\CMS\Plugin\PluginHelper; use Joomla\CMS\Toolbar\ToolbarHelper; +use Joomla\CMS\Document\Document; +use TrueChristianChurch\Component\Getbible\Administrator\Helper\GetbibleHelper; use VDM\Joomla\Utilities\StringHelper; /** * Password Html View class */ -class GetbibleViewPassword extends HtmlView +class HtmlView extends BaseHtmlView { /** * display method of View @@ -78,18 +81,18 @@ class GetbibleViewPassword extends HtmlView // Set the toolbar $this->addToolBar(); - + // Check for errors. if (count($errors = $this->get('Errors'))) { - throw new Exception(implode("\n", $errors), 500); + throw new \Exception(implode("\n", $errors), 500); } // Display the template parent::display($tpl); - // Set the document - $this->setDocument(); + // Set the html view document stuff + $this->setHtmlViewDoc(); } @@ -99,7 +102,7 @@ class GetbibleViewPassword extends HtmlView protected function addToolBar() { Factory::getApplication()->input->set('hidemainmenu', true); - $user = Factory::getUser(); + $user = Factory::getApplication()->getIdentity(); $userId = $user->id; $isNew = $this->item->id == 0; @@ -163,6 +166,7 @@ class GetbibleViewPassword extends HtmlView } } ToolbarHelper::divider(); + ToolbarHelper::inlinehelp(); // set help url for this view if found $this->help_url = GetbibleHelper::getHelpUrl('password'); if (StringHelper::check($this->help_url)) @@ -180,9 +184,13 @@ class GetbibleViewPassword extends HtmlView */ public function escape($var) { - if(strlen($var) > 30) + if (!is_string($var)) { - // use the helper htmlEscape method instead and shorten the string + return $var; + } + elseif(strlen($var) > 30) + { + // use the helper htmlEscape method instead and shorten the string return StringHelper::html($var, $this->_charset, true, 30); } // use the helper htmlEscape method instead. @@ -190,18 +198,15 @@ class GetbibleViewPassword extends HtmlView } /** - * Method to set up the document properties + * Set this html view document related stuff. * * @return void + * @since 4.4.0 */ - protected function setDocument() + protected function setHtmlViewDoc(): void { $isNew = ($this->item->id < 1); - if (!isset($this->document)) - { - $this->document = Factory::getDocument(); - } - $this->document->setTitle(Text::_($isNew ? 'COM_GETBIBLE_PASSWORD_NEW' : 'COM_GETBIBLE_PASSWORD_EDIT')); + $this->getDocument()->setTitle(Text::_($isNew ? 'COM_GETBIBLE_PASSWORD_NEW' : 'COM_GETBIBLE_PASSWORD_EDIT')); Html::_('stylesheet', "administrator/components/com_getbible/assets/css/password.css", ['version' => 'auto']); Html::_('script', $this->script, ['version' => 'auto']); Html::_('script', "administrator/components/com_getbible/views/password/submitbutton.js", ['version' => 'auto']); diff --git a/admin/views/open_ai_messages/index.html b/admin/src/View/Password/index.html similarity index 100% rename from admin/views/open_ai_messages/index.html rename to admin/src/View/Password/index.html diff --git a/admin/views/passwords/view.html.php b/admin/src/View/Passwords/HtmlView.php similarity index 59% rename from admin/views/passwords/view.html.php rename to admin/src/View/Passwords/HtmlView.php index 9c21212..16d0a6a 100644 --- a/admin/views/passwords/view.html.php +++ b/admin/src/View/Passwords/HtmlView.php @@ -14,29 +14,32 @@ @license GNU/GPL Version 2 or later - http://www.gnu.org/licenses/gpl-2.0.html /------------------------------------------------------------------------------------------------------*/ +namespace TrueChristianChurch\Component\Getbible\Administrator\View\Passwords; // No direct access to this file -defined('_JEXEC') or die('Restricted access'); +\defined('_JEXEC') or die; use Joomla\CMS\Factory; use Joomla\CMS\Language\Text; +use Joomla\CMS\Toolbar\Toolbar; use Joomla\CMS\Form\FormHelper; use Joomla\CMS\Session\Session; use Joomla\CMS\Uri\Uri; -use Joomla\CMS\Toolbar\Toolbar; use Joomla\CMS\Component\ComponentHelper; use Joomla\CMS\HTML\HTMLHelper as Html; use Joomla\CMS\Layout\FileLayout; -use Joomla\CMS\MVC\View\HtmlView; +use Joomla\CMS\MVC\View\HtmlView as BaseHtmlView; use Joomla\CMS\Plugin\PluginHelper; use Joomla\CMS\Toolbar\ToolbarHelper; +use Joomla\CMS\Document\Document; +use TrueChristianChurch\Component\Getbible\Administrator\Helper\GetbibleHelper; use VDM\Joomla\Utilities\ArrayHelper; use VDM\Joomla\Utilities\StringHelper; /** * Getbible Html View class for the Passwords */ -class GetbibleViewPasswords extends HtmlView +class HtmlView extends BaseHtmlView { /** * Passwords view display method @@ -44,17 +47,11 @@ class GetbibleViewPasswords extends HtmlView */ 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 = Factory::getUser(); + $this->user = Factory::getApplication()->getIdentity(); // Load the filter form from xml. $this->filterForm = $this->get('FilterForm'); // Load the active filters. @@ -73,29 +70,29 @@ class GetbibleViewPasswords extends HtmlView $this->canDelete = $this->canDo->get('password.delete'); $this->canBatch = ($this->canDo->get('password.batch') && $this->canDo->get('core.batch')); + // If we don't have items we load the empty state + if (is_array($this->items) && !count((array) $this->items) && $this->isEmptyState = $this->get('IsEmptyState')) + { + $this->setLayout('emptystate'); + } + // 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); + throw new \Exception(implode("\n", $errors), 500); } // Display the template parent::display($tpl); - // Set the document - $this->setDocument(); + // Set the html view document stuff + $this->setHtmlViewDoc(); } /** @@ -103,9 +100,7 @@ class GetbibleViewPasswords extends HtmlView */ protected function addToolBar() { - JHtmlSidebar::setAction('index.php?option=com_getbible&view=passwords'); ToolbarHelper::title(Text::_('COM_GETBIBLE_PASSWORDS'), 'lock'); - FormHelper::addFieldPath(JPATH_COMPONENT . '/models/fields'); if ($this->canCreate) { @@ -132,20 +127,6 @@ class GetbibleViewPasswords extends HtmlView } } - // Add a batch button - if ($this->canBatch && $this->canCreate && $this->canEdit && $this->canState) - { - // Get the toolbar object instance - $bar = Toolbar::getInstance('toolbar'); - // set the batch button name - $title = Text::_('JTOOLBAR_BATCH'); - // Instantiate a new JLayoutFile instance and render the batch button - $layout = new FileLayout('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)) { ToolbarHelper::deleteList('', 'passwords.delete', 'JTOOLBAR_EMPTY_TRASH'); @@ -168,80 +149,17 @@ class GetbibleViewPasswords extends HtmlView { ToolbarHelper::preferences('com_getbible'); } - - // Only load published batch if state and batch is allowed - if ($this->canState && $this->canBatch) - { - JHtmlBatch_::addListSelection( - Text::_('COM_GETBIBLE_KEEP_ORIGINAL_STATE'), - 'batch[published]', - Html::_('select.options', Html::_('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( - Text::_('COM_GETBIBLE_KEEP_ORIGINAL_ACCESS'), - 'batch[access]', - Html::_('select.options', Html::_('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 = FormHelper::loadFieldType('passwordsfiltername')->options; - // We do some sanitation for Name filter - if (ArrayHelper::check($this->nameOptions) && - isset($this->nameOptions[0]->value) && - !StringHelper::check($this->nameOptions[0]->value)) - { - unset($this->nameOptions[0]); - } - // Name Batch Selection - JHtmlBatch_::addListSelection( - '- Keep Original '.Text::_('COM_GETBIBLE_PASSWORD_NAME_LABEL').' -', - 'batch[name]', - Html::_('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 = FormHelper::loadFieldType('Linkers')->options; - // We do some sanitation for Linker Name filter - if (ArrayHelper::check($this->linkerNameOptions) && - isset($this->linkerNameOptions[0]->value) && - !StringHelper::check($this->linkerNameOptions[0]->value)) - { - unset($this->linkerNameOptions[0]); - } - // Linker Name Batch Selection - JHtmlBatch_::addListSelection( - '- Keep Original '.Text::_('COM_GETBIBLE_PASSWORD_LINKER_LABEL').' -', - 'batch[linker]', - Html::_('select.options', $this->linkerNameOptions, 'value', 'text') - ); - } } /** - * Method to set up the document properties + * Set this html view document related stuff. * * @return void + * @since 4.4.0 */ - protected function setDocument() + protected function setHtmlViewDoc(): void { - if (!isset($this->document)) - { - $this->document = Factory::getDocument(); - } - $this->document->setTitle(Text::_('COM_GETBIBLE_PASSWORDS')); + $this->getDocument()->setTitle(Text::_('COM_GETBIBLE_PASSWORDS')); Html::_('stylesheet', "administrator/components/com_getbible/assets/css/passwords.css", ['version' => 'auto']); } @@ -254,7 +172,11 @@ class GetbibleViewPasswords extends HtmlView */ public function escape($var) { - if(strlen($var) > 50) + if (!is_string($var)) + { + return $var; + } + elseif(strlen($var) > 50) { // use the helper htmlEscape method instead and shorten the string return StringHelper::html($var, $this->_charset, true); diff --git a/admin/views/open_ai_messages/tmpl/index.html b/admin/src/View/Passwords/index.html similarity index 100% rename from admin/views/open_ai_messages/tmpl/index.html rename to admin/src/View/Passwords/index.html diff --git a/admin/views/prompt/view.html.php b/admin/src/View/Prompt/HtmlView.php similarity index 87% rename from admin/views/prompt/view.html.php rename to admin/src/View/Prompt/HtmlView.php index 4e29886..3cc38ec 100644 --- a/admin/views/prompt/view.html.php +++ b/admin/src/View/Prompt/HtmlView.php @@ -14,28 +14,31 @@ @license GNU/GPL Version 2 or later - http://www.gnu.org/licenses/gpl-2.0.html /------------------------------------------------------------------------------------------------------*/ +namespace TrueChristianChurch\Component\Getbible\Administrator\View\Prompt; // No direct access to this file -defined('_JEXEC') or die('Restricted access'); +\defined('_JEXEC') or die; use Joomla\CMS\Factory; use Joomla\CMS\Language\Text; +use Joomla\CMS\Toolbar\Toolbar; use Joomla\CMS\Form\FormHelper; use Joomla\CMS\Session\Session; use Joomla\CMS\Uri\Uri; -use Joomla\CMS\Toolbar\Toolbar; use Joomla\CMS\Component\ComponentHelper; use Joomla\CMS\HTML\HTMLHelper as Html; use Joomla\CMS\Layout\FileLayout; -use Joomla\CMS\MVC\View\HtmlView; +use Joomla\CMS\MVC\View\HtmlView as BaseHtmlView; use Joomla\CMS\Plugin\PluginHelper; use Joomla\CMS\Toolbar\ToolbarHelper; +use Joomla\CMS\Document\Document; +use TrueChristianChurch\Component\Getbible\Administrator\Helper\GetbibleHelper; use VDM\Joomla\Utilities\StringHelper; /** * Prompt Html View class */ -class GetbibleViewPrompt extends HtmlView +class HtmlView extends BaseHtmlView { /** * display method of View @@ -78,18 +81,18 @@ class GetbibleViewPrompt extends HtmlView // Set the toolbar $this->addToolBar(); - + // Check for errors. if (count($errors = $this->get('Errors'))) { - throw new Exception(implode("\n", $errors), 500); + throw new \Exception(implode("\n", $errors), 500); } // Display the template parent::display($tpl); - // Set the document - $this->setDocument(); + // Set the html view document stuff + $this->setHtmlViewDoc(); } @@ -99,7 +102,7 @@ class GetbibleViewPrompt extends HtmlView protected function addToolBar() { Factory::getApplication()->input->set('hidemainmenu', true); - $user = Factory::getUser(); + $user = Factory::getApplication()->getIdentity(); $userId = $user->id; $isNew = $this->item->id == 0; @@ -168,6 +171,7 @@ class GetbibleViewPrompt extends HtmlView } } ToolbarHelper::divider(); + ToolbarHelper::inlinehelp(); // set help url for this view if found $this->help_url = GetbibleHelper::getHelpUrl('prompt'); if (StringHelper::check($this->help_url)) @@ -185,9 +189,13 @@ class GetbibleViewPrompt extends HtmlView */ public function escape($var) { - if(strlen($var) > 30) + if (!is_string($var)) { - // use the helper htmlEscape method instead and shorten the string + return $var; + } + elseif(strlen($var) > 30) + { + // use the helper htmlEscape method instead and shorten the string return StringHelper::html($var, $this->_charset, true, 30); } // use the helper htmlEscape method instead. @@ -195,18 +203,15 @@ class GetbibleViewPrompt extends HtmlView } /** - * Method to set up the document properties + * Set this html view document related stuff. * * @return void + * @since 4.4.0 */ - protected function setDocument() + protected function setHtmlViewDoc(): void { $isNew = ($this->item->id < 1); - if (!isset($this->document)) - { - $this->document = Factory::getDocument(); - } - $this->document->setTitle(Text::_($isNew ? 'COM_GETBIBLE_PROMPT_NEW' : 'COM_GETBIBLE_PROMPT_EDIT')); + $this->getDocument()->setTitle(Text::_($isNew ? 'COM_GETBIBLE_PROMPT_NEW' : 'COM_GETBIBLE_PROMPT_EDIT')); Html::_('stylesheet', "administrator/components/com_getbible/assets/css/prompt.css", ['version' => 'auto']); Html::_('script', $this->script, ['version' => 'auto']); Html::_('script', "administrator/components/com_getbible/views/prompt/submitbutton.js", ['version' => 'auto']); diff --git a/admin/views/open_ai_response/tmpl/index.html b/admin/src/View/Prompt/index.html similarity index 100% rename from admin/views/open_ai_response/tmpl/index.html rename to admin/src/View/Prompt/index.html diff --git a/admin/views/prompts/view.html.php b/admin/src/View/Prompts/HtmlView.php similarity index 50% rename from admin/views/prompts/view.html.php rename to admin/src/View/Prompts/HtmlView.php index 407a606..7cd74f7 100644 --- a/admin/views/prompts/view.html.php +++ b/admin/src/View/Prompts/HtmlView.php @@ -14,29 +14,32 @@ @license GNU/GPL Version 2 or later - http://www.gnu.org/licenses/gpl-2.0.html /------------------------------------------------------------------------------------------------------*/ +namespace TrueChristianChurch\Component\Getbible\Administrator\View\Prompts; // No direct access to this file -defined('_JEXEC') or die('Restricted access'); +\defined('_JEXEC') or die; use Joomla\CMS\Factory; use Joomla\CMS\Language\Text; +use Joomla\CMS\Toolbar\Toolbar; use Joomla\CMS\Form\FormHelper; use Joomla\CMS\Session\Session; use Joomla\CMS\Uri\Uri; -use Joomla\CMS\Toolbar\Toolbar; use Joomla\CMS\Component\ComponentHelper; use Joomla\CMS\HTML\HTMLHelper as Html; use Joomla\CMS\Layout\FileLayout; -use Joomla\CMS\MVC\View\HtmlView; +use Joomla\CMS\MVC\View\HtmlView as BaseHtmlView; use Joomla\CMS\Plugin\PluginHelper; use Joomla\CMS\Toolbar\ToolbarHelper; +use Joomla\CMS\Document\Document; +use TrueChristianChurch\Component\Getbible\Administrator\Helper\GetbibleHelper; use VDM\Joomla\Utilities\ArrayHelper; use VDM\Joomla\Utilities\StringHelper; /** * Getbible Html View class for the Prompts */ -class GetbibleViewPrompts extends HtmlView +class HtmlView extends BaseHtmlView { /** * Prompts view display method @@ -44,17 +47,11 @@ class GetbibleViewPrompts extends HtmlView */ 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 = Factory::getUser(); + $this->user = Factory::getApplication()->getIdentity(); // Load the filter form from xml. $this->filterForm = $this->get('FilterForm'); // Load the active filters. @@ -73,29 +70,29 @@ class GetbibleViewPrompts extends HtmlView $this->canDelete = $this->canDo->get('prompt.delete'); $this->canBatch = ($this->canDo->get('prompt.batch') && $this->canDo->get('core.batch')); + // If we don't have items we load the empty state + if (is_array($this->items) && !count((array) $this->items) && $this->isEmptyState = $this->get('IsEmptyState')) + { + $this->setLayout('emptystate'); + } + // 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); + throw new \Exception(implode("\n", $errors), 500); } // Display the template parent::display($tpl); - // Set the document - $this->setDocument(); + // Set the html view document stuff + $this->setHtmlViewDoc(); } /** @@ -103,9 +100,7 @@ class GetbibleViewPrompts extends HtmlView */ protected function addToolBar() { - JHtmlSidebar::setAction('index.php?option=com_getbible&view=prompts'); ToolbarHelper::title(Text::_('COM_GETBIBLE_PROMPTS'), 'puzzle'); - FormHelper::addFieldPath(JPATH_COMPONENT . '/models/fields'); if ($this->canCreate) { @@ -132,20 +127,6 @@ class GetbibleViewPrompts extends HtmlView } } - // Add a batch button - if ($this->canBatch && $this->canCreate && $this->canEdit && $this->canState) - { - // Get the toolbar object instance - $bar = Toolbar::getInstance('toolbar'); - // set the batch button name - $title = Text::_('JTOOLBAR_BATCH'); - // Instantiate a new JLayoutFile instance and render the batch button - $layout = new FileLayout('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)) { ToolbarHelper::deleteList('', 'prompts.delete', 'JTOOLBAR_EMPTY_TRASH'); @@ -168,120 +149,17 @@ class GetbibleViewPrompts extends HtmlView { ToolbarHelper::preferences('com_getbible'); } - - // Only load published batch if state and batch is allowed - if ($this->canState && $this->canBatch) - { - JHtmlBatch_::addListSelection( - Text::_('COM_GETBIBLE_KEEP_ORIGINAL_STATE'), - 'batch[published]', - Html::_('select.options', Html::_('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( - Text::_('COM_GETBIBLE_KEEP_ORIGINAL_ACCESS'), - 'batch[access]', - Html::_('select.options', Html::_('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 = FormHelper::loadFieldType('promptsfiltername')->options; - // We do some sanitation for Name filter - if (ArrayHelper::check($this->nameOptions) && - isset($this->nameOptions[0]->value) && - !StringHelper::check($this->nameOptions[0]->value)) - { - unset($this->nameOptions[0]); - } - // Name Batch Selection - JHtmlBatch_::addListSelection( - '- Keep Original '.Text::_('COM_GETBIBLE_PROMPT_NAME_LABEL').' -', - 'batch[name]', - Html::_('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 = FormHelper::loadFieldType('promptsfiltercachebehaviour')->options; - // We do some sanitation for Cache Behaviour filter - if (ArrayHelper::check($this->cache_behaviourOptions) && - isset($this->cache_behaviourOptions[0]->value) && - !StringHelper::check($this->cache_behaviourOptions[0]->value)) - { - unset($this->cache_behaviourOptions[0]); - } - // Cache Behaviour Batch Selection - JHtmlBatch_::addListSelection( - '- Keep Original '.Text::_('COM_GETBIBLE_PROMPT_CACHE_BEHAVIOUR_LABEL').' -', - 'batch[cache_behaviour]', - Html::_('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 = FormHelper::loadFieldType('Targettranslations')->options; - // We do some sanitation for Abbreviation Translation filter - if (ArrayHelper::check($this->abbreviationTranslationOptions) && - isset($this->abbreviationTranslationOptions[0]->value) && - !StringHelper::check($this->abbreviationTranslationOptions[0]->value)) - { - unset($this->abbreviationTranslationOptions[0]); - } - // Abbreviation Translation Batch Selection - JHtmlBatch_::addListSelection( - '- Keep Original '.Text::_('COM_GETBIBLE_PROMPT_ABBREVIATION_LABEL').' -', - 'batch[abbreviation]', - Html::_('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 = FormHelper::loadFieldType('promptsfiltermodel')->options; - // We do some sanitation for Model filter - if (ArrayHelper::check($this->modelOptions) && - isset($this->modelOptions[0]->value) && - !StringHelper::check($this->modelOptions[0]->value)) - { - unset($this->modelOptions[0]); - } - // Model Batch Selection - JHtmlBatch_::addListSelection( - '- Keep Original '.Text::_('COM_GETBIBLE_PROMPT_MODEL_LABEL').' -', - 'batch[model]', - Html::_('select.options', $this->modelOptions, 'value', 'text') - ); - } } /** - * Method to set up the document properties + * Set this html view document related stuff. * * @return void + * @since 4.4.0 */ - protected function setDocument() + protected function setHtmlViewDoc(): void { - if (!isset($this->document)) - { - $this->document = Factory::getDocument(); - } - $this->document->setTitle(Text::_('COM_GETBIBLE_PROMPTS')); + $this->getDocument()->setTitle(Text::_('COM_GETBIBLE_PROMPTS')); Html::_('stylesheet', "administrator/components/com_getbible/assets/css/prompts.css", ['version' => 'auto']); } @@ -294,7 +172,11 @@ class GetbibleViewPrompts extends HtmlView */ public function escape($var) { - if(strlen($var) > 50) + if (!is_string($var)) + { + return $var; + } + elseif(strlen($var) > 50) { // use the helper htmlEscape method instead and shorten the string return StringHelper::html($var, $this->_charset, true); diff --git a/admin/views/open_ai_responses/index.html b/admin/src/View/Prompts/index.html similarity index 100% rename from admin/views/open_ai_responses/index.html rename to admin/src/View/Prompts/index.html diff --git a/admin/views/tag/view.html.php b/admin/src/View/Tag/HtmlView.php similarity index 87% rename from admin/views/tag/view.html.php rename to admin/src/View/Tag/HtmlView.php index f3db061..630d5e7 100644 --- a/admin/views/tag/view.html.php +++ b/admin/src/View/Tag/HtmlView.php @@ -14,28 +14,31 @@ @license GNU/GPL Version 2 or later - http://www.gnu.org/licenses/gpl-2.0.html /------------------------------------------------------------------------------------------------------*/ +namespace TrueChristianChurch\Component\Getbible\Administrator\View\Tag; // No direct access to this file -defined('_JEXEC') or die('Restricted access'); +\defined('_JEXEC') or die; use Joomla\CMS\Factory; use Joomla\CMS\Language\Text; +use Joomla\CMS\Toolbar\Toolbar; use Joomla\CMS\Form\FormHelper; use Joomla\CMS\Session\Session; use Joomla\CMS\Uri\Uri; -use Joomla\CMS\Toolbar\Toolbar; use Joomla\CMS\Component\ComponentHelper; use Joomla\CMS\HTML\HTMLHelper as Html; use Joomla\CMS\Layout\FileLayout; -use Joomla\CMS\MVC\View\HtmlView; +use Joomla\CMS\MVC\View\HtmlView as BaseHtmlView; use Joomla\CMS\Plugin\PluginHelper; use Joomla\CMS\Toolbar\ToolbarHelper; +use Joomla\CMS\Document\Document; +use TrueChristianChurch\Component\Getbible\Administrator\Helper\GetbibleHelper; use VDM\Joomla\Utilities\StringHelper; /** * Tag Html View class */ -class GetbibleViewTag extends HtmlView +class HtmlView extends BaseHtmlView { /** * display method of View @@ -78,18 +81,18 @@ class GetbibleViewTag extends HtmlView // Set the toolbar $this->addToolBar(); - + // Check for errors. if (count($errors = $this->get('Errors'))) { - throw new Exception(implode("\n", $errors), 500); + throw new \Exception(implode("\n", $errors), 500); } // Display the template parent::display($tpl); - // Set the document - $this->setDocument(); + // Set the html view document stuff + $this->setHtmlViewDoc(); } @@ -99,7 +102,7 @@ class GetbibleViewTag extends HtmlView protected function addToolBar() { Factory::getApplication()->input->set('hidemainmenu', true); - $user = Factory::getUser(); + $user = Factory::getApplication()->getIdentity(); $userId = $user->id; $isNew = $this->item->id == 0; @@ -168,6 +171,7 @@ class GetbibleViewTag extends HtmlView } } ToolbarHelper::divider(); + ToolbarHelper::inlinehelp(); // set help url for this view if found $this->help_url = GetbibleHelper::getHelpUrl('tag'); if (StringHelper::check($this->help_url)) @@ -185,9 +189,13 @@ class GetbibleViewTag extends HtmlView */ public function escape($var) { - if(strlen($var) > 30) + if (!is_string($var)) { - // use the helper htmlEscape method instead and shorten the string + return $var; + } + elseif(strlen($var) > 30) + { + // use the helper htmlEscape method instead and shorten the string return StringHelper::html($var, $this->_charset, true, 30); } // use the helper htmlEscape method instead. @@ -195,18 +203,15 @@ class GetbibleViewTag extends HtmlView } /** - * Method to set up the document properties + * Set this html view document related stuff. * * @return void + * @since 4.4.0 */ - protected function setDocument() + protected function setHtmlViewDoc(): void { $isNew = ($this->item->id < 1); - if (!isset($this->document)) - { - $this->document = Factory::getDocument(); - } - $this->document->setTitle(Text::_($isNew ? 'COM_GETBIBLE_TAG_NEW' : 'COM_GETBIBLE_TAG_EDIT')); + $this->getDocument()->setTitle(Text::_($isNew ? 'COM_GETBIBLE_TAG_NEW' : 'COM_GETBIBLE_TAG_EDIT')); Html::_('stylesheet', "administrator/components/com_getbible/assets/css/tag.css", ['version' => 'auto']); Html::_('script', $this->script, ['version' => 'auto']); Html::_('script', "administrator/components/com_getbible/views/tag/submitbutton.js", ['version' => 'auto']); diff --git a/admin/views/open_ai_responses/tmpl/index.html b/admin/src/View/Tag/index.html similarity index 100% rename from admin/views/open_ai_responses/tmpl/index.html rename to admin/src/View/Tag/index.html diff --git a/admin/views/tagged_verse/view.html.php b/admin/src/View/Tagged_verse/HtmlView.php similarity index 87% rename from admin/views/tagged_verse/view.html.php rename to admin/src/View/Tagged_verse/HtmlView.php index 7216c7e..a6b36e2 100644 --- a/admin/views/tagged_verse/view.html.php +++ b/admin/src/View/Tagged_verse/HtmlView.php @@ -14,28 +14,31 @@ @license GNU/GPL Version 2 or later - http://www.gnu.org/licenses/gpl-2.0.html /------------------------------------------------------------------------------------------------------*/ +namespace TrueChristianChurch\Component\Getbible\Administrator\View\Tagged_verse; // No direct access to this file -defined('_JEXEC') or die('Restricted access'); +\defined('_JEXEC') or die; use Joomla\CMS\Factory; use Joomla\CMS\Language\Text; +use Joomla\CMS\Toolbar\Toolbar; use Joomla\CMS\Form\FormHelper; use Joomla\CMS\Session\Session; use Joomla\CMS\Uri\Uri; -use Joomla\CMS\Toolbar\Toolbar; use Joomla\CMS\Component\ComponentHelper; use Joomla\CMS\HTML\HTMLHelper as Html; use Joomla\CMS\Layout\FileLayout; -use Joomla\CMS\MVC\View\HtmlView; +use Joomla\CMS\MVC\View\HtmlView as BaseHtmlView; use Joomla\CMS\Plugin\PluginHelper; use Joomla\CMS\Toolbar\ToolbarHelper; +use Joomla\CMS\Document\Document; +use TrueChristianChurch\Component\Getbible\Administrator\Helper\GetbibleHelper; use VDM\Joomla\Utilities\StringHelper; /** * Tagged_verse Html View class */ -class GetbibleViewTagged_verse extends HtmlView +class HtmlView extends BaseHtmlView { /** * display method of View @@ -78,18 +81,18 @@ class GetbibleViewTagged_verse extends HtmlView // Set the toolbar $this->addToolBar(); - + // Check for errors. if (count($errors = $this->get('Errors'))) { - throw new Exception(implode("\n", $errors), 500); + throw new \Exception(implode("\n", $errors), 500); } // Display the template parent::display($tpl); - // Set the document - $this->setDocument(); + // Set the html view document stuff + $this->setHtmlViewDoc(); } @@ -99,7 +102,7 @@ class GetbibleViewTagged_verse extends HtmlView protected function addToolBar() { Factory::getApplication()->input->set('hidemainmenu', true); - $user = Factory::getUser(); + $user = Factory::getApplication()->getIdentity(); $userId = $user->id; $isNew = $this->item->id == 0; @@ -168,6 +171,7 @@ class GetbibleViewTagged_verse extends HtmlView } } ToolbarHelper::divider(); + ToolbarHelper::inlinehelp(); // set help url for this view if found $this->help_url = GetbibleHelper::getHelpUrl('tagged_verse'); if (StringHelper::check($this->help_url)) @@ -185,9 +189,13 @@ class GetbibleViewTagged_verse extends HtmlView */ public function escape($var) { - if(strlen($var) > 30) + if (!is_string($var)) { - // use the helper htmlEscape method instead and shorten the string + return $var; + } + elseif(strlen($var) > 30) + { + // use the helper htmlEscape method instead and shorten the string return StringHelper::html($var, $this->_charset, true, 30); } // use the helper htmlEscape method instead. @@ -195,18 +203,15 @@ class GetbibleViewTagged_verse extends HtmlView } /** - * Method to set up the document properties + * Set this html view document related stuff. * * @return void + * @since 4.4.0 */ - protected function setDocument() + protected function setHtmlViewDoc(): void { $isNew = ($this->item->id < 1); - if (!isset($this->document)) - { - $this->document = Factory::getDocument(); - } - $this->document->setTitle(Text::_($isNew ? 'COM_GETBIBLE_TAGGED_VERSE_NEW' : 'COM_GETBIBLE_TAGGED_VERSE_EDIT')); + $this->getDocument()->setTitle(Text::_($isNew ? 'COM_GETBIBLE_TAGGED_VERSE_NEW' : 'COM_GETBIBLE_TAGGED_VERSE_EDIT')); Html::_('stylesheet', "administrator/components/com_getbible/assets/css/tagged_verse.css", ['version' => 'auto']); Html::_('script', $this->script, ['version' => 'auto']); Html::_('script', "administrator/components/com_getbible/views/tagged_verse/submitbutton.js", ['version' => 'auto']); diff --git a/admin/views/password/tmpl/index.html b/admin/src/View/Tagged_verse/index.html similarity index 100% rename from admin/views/password/tmpl/index.html rename to admin/src/View/Tagged_verse/index.html diff --git a/admin/src/View/Tagged_verses/HtmlView.php b/admin/src/View/Tagged_verses/HtmlView.php new file mode 100644 index 0000000..54627a4 --- /dev/null +++ b/admin/src/View/Tagged_verses/HtmlView.php @@ -0,0 +1,206 @@ + + @git Get Bible + @github Get Bible + @support Get Bible + @copyright Copyright (C) 2015. All Rights Reserved + @license GNU/GPL Version 2 or later - http://www.gnu.org/licenses/gpl-2.0.html + +/------------------------------------------------------------------------------------------------------*/ +namespace TrueChristianChurch\Component\Getbible\Administrator\View\Tagged_verses; + +// No direct access to this file +\defined('_JEXEC') or die; + +use Joomla\CMS\Factory; +use Joomla\CMS\Language\Text; +use Joomla\CMS\Toolbar\Toolbar; +use Joomla\CMS\Form\FormHelper; +use Joomla\CMS\Session\Session; +use Joomla\CMS\Uri\Uri; +use Joomla\CMS\Component\ComponentHelper; +use Joomla\CMS\HTML\HTMLHelper as Html; +use Joomla\CMS\Layout\FileLayout; +use Joomla\CMS\MVC\View\HtmlView as BaseHtmlView; +use Joomla\CMS\Plugin\PluginHelper; +use Joomla\CMS\Toolbar\ToolbarHelper; +use Joomla\CMS\Document\Document; +use TrueChristianChurch\Component\Getbible\Administrator\Helper\GetbibleHelper; +use VDM\Joomla\Utilities\ArrayHelper; +use VDM\Joomla\Utilities\StringHelper; + +/** + * Getbible Html View class for the Tagged_verses + */ +class HtmlView extends BaseHtmlView +{ + /** + * Tagged_verses view display method + * @return void + */ + function display($tpl = null) + { + // Assign data to the view + $this->items = $this->get('Items'); + $this->pagination = $this->get('Pagination'); + $this->state = $this->get('State'); + $this->user = Factory::getApplication()->getIdentity(); + // 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) Uri::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('tagged_verse.batch') && $this->canDo->get('core.batch')); + + // If we don't have items we load the empty state + if (is_array($this->items) && !count((array) $this->items) && $this->isEmptyState = $this->get('IsEmptyState')) + { + $this->setLayout('emptystate'); + } + + // We don't need toolbar in the modal window. + if ($this->getLayout() !== 'modal') + { + $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 html view document stuff + $this->setHtmlViewDoc(); + } + + /** + * Setting the toolbar + */ + protected function addToolBar() + { + ToolbarHelper::title(Text::_('COM_GETBIBLE_TAGGED_VERSES'), 'tags-2'); + + if ($this->canCreate) + { + ToolbarHelper::addNew('tagged_verse.add'); + } + + // Only load if there are items + if (ArrayHelper::check($this->items)) + { + if ($this->canEdit) + { + ToolbarHelper::editList('tagged_verse.edit'); + } + + if ($this->canState) + { + ToolbarHelper::publishList('tagged_verses.publish'); + ToolbarHelper::unpublishList('tagged_verses.unpublish'); + ToolbarHelper::archiveList('tagged_verses.archive'); + + if ($this->canDo->get('core.admin')) + { + ToolbarHelper::checkin('tagged_verses.checkin'); + } + } + + if ($this->state->get('filter.published') == -2 && ($this->canState && $this->canDelete)) + { + ToolbarHelper::deleteList('', 'tagged_verses.delete', 'JTOOLBAR_EMPTY_TRASH'); + } + elseif ($this->canState && $this->canDelete) + { + ToolbarHelper::trash('tagged_verses.trash'); + } + } + + // set help url for this view if found + $this->help_url = GetbibleHelper::getHelpUrl('tagged_verses'); + if (StringHelper::check($this->help_url)) + { + ToolbarHelper::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')) + { + ToolbarHelper::preferences('com_getbible'); + } + } + + /** + * Set this html view document related stuff. + * + * @return void + * @since 4.4.0 + */ + protected function setHtmlViewDoc(): void + { + $this->getDocument()->setTitle(Text::_('COM_GETBIBLE_TAGGED_VERSES')); + Html::_('stylesheet', "administrator/components/com_getbible/assets/css/tagged_verses.css", ['version' => 'auto']); + } + + /** + * 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 (!is_string($var)) + { + return $var; + } + elseif(strlen($var) > 50) + { + // use the helper htmlEscape method instead and shorten the string + return StringHelper::html($var, $this->_charset, true); + } + // use the helper htmlEscape method instead. + return StringHelper::html($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' => Text::_('JGRID_HEADING_ORDERING'), + 'a.published' => Text::_('JSTATUS'), + 'a.book_nr' => Text::_('COM_GETBIBLE_TAGGED_VERSE_BOOK_NR_LABEL'), + 'g.translation' => Text::_('COM_GETBIBLE_TAGGED_VERSE_ABBREVIATION_LABEL'), + 'a.access' => Text::_('COM_GETBIBLE_TAGGED_VERSE_ACCESS_LABEL'), + 'h.name' => Text::_('COM_GETBIBLE_TAGGED_VERSE_LINKER_LABEL'), + 'i.name' => Text::_('COM_GETBIBLE_TAGGED_VERSE_TAG_LABEL'), + 'a.id' => Text::_('JGRID_HEADING_ID') + ); + } +} diff --git a/admin/views/passwords/index.html b/admin/src/View/Tagged_verses/index.html similarity index 100% rename from admin/views/passwords/index.html rename to admin/src/View/Tagged_verses/index.html diff --git a/admin/views/tags/view.html.php b/admin/src/View/Tags/HtmlView.php similarity index 61% rename from admin/views/tags/view.html.php rename to admin/src/View/Tags/HtmlView.php index a979084..dd0b568 100644 --- a/admin/views/tags/view.html.php +++ b/admin/src/View/Tags/HtmlView.php @@ -14,29 +14,32 @@ @license GNU/GPL Version 2 or later - http://www.gnu.org/licenses/gpl-2.0.html /------------------------------------------------------------------------------------------------------*/ +namespace TrueChristianChurch\Component\Getbible\Administrator\View\Tags; // No direct access to this file -defined('_JEXEC') or die('Restricted access'); +\defined('_JEXEC') or die; use Joomla\CMS\Factory; use Joomla\CMS\Language\Text; +use Joomla\CMS\Toolbar\Toolbar; use Joomla\CMS\Form\FormHelper; use Joomla\CMS\Session\Session; use Joomla\CMS\Uri\Uri; -use Joomla\CMS\Toolbar\Toolbar; use Joomla\CMS\Component\ComponentHelper; use Joomla\CMS\HTML\HTMLHelper as Html; use Joomla\CMS\Layout\FileLayout; -use Joomla\CMS\MVC\View\HtmlView; +use Joomla\CMS\MVC\View\HtmlView as BaseHtmlView; use Joomla\CMS\Plugin\PluginHelper; use Joomla\CMS\Toolbar\ToolbarHelper; +use Joomla\CMS\Document\Document; +use TrueChristianChurch\Component\Getbible\Administrator\Helper\GetbibleHelper; use VDM\Joomla\Utilities\ArrayHelper; use VDM\Joomla\Utilities\StringHelper; /** * Getbible Html View class for the Tags */ -class GetbibleViewTags extends HtmlView +class HtmlView extends BaseHtmlView { /** * Tags view display method @@ -44,17 +47,11 @@ class GetbibleViewTags extends HtmlView */ 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 = Factory::getUser(); + $this->user = Factory::getApplication()->getIdentity(); // Load the filter form from xml. $this->filterForm = $this->get('FilterForm'); // Load the active filters. @@ -73,29 +70,29 @@ class GetbibleViewTags extends HtmlView $this->canDelete = $this->canDo->get('tag.delete'); $this->canBatch = ($this->canDo->get('tag.batch') && $this->canDo->get('core.batch')); + // If we don't have items we load the empty state + if (is_array($this->items) && !count((array) $this->items) && $this->isEmptyState = $this->get('IsEmptyState')) + { + $this->setLayout('emptystate'); + } + // 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); + throw new \Exception(implode("\n", $errors), 500); } // Display the template parent::display($tpl); - // Set the document - $this->setDocument(); + // Set the html view document stuff + $this->setHtmlViewDoc(); } /** @@ -103,9 +100,7 @@ class GetbibleViewTags extends HtmlView */ protected function addToolBar() { - JHtmlSidebar::setAction('index.php?option=com_getbible&view=tags'); ToolbarHelper::title(Text::_('COM_GETBIBLE_TAGS'), 'tags'); - FormHelper::addFieldPath(JPATH_COMPONENT . '/models/fields'); if ($this->canCreate) { @@ -132,20 +127,6 @@ class GetbibleViewTags extends HtmlView } } - // Add a batch button - if ($this->canBatch && $this->canCreate && $this->canEdit && $this->canState) - { - // Get the toolbar object instance - $bar = Toolbar::getInstance('toolbar'); - // set the batch button name - $title = Text::_('JTOOLBAR_BATCH'); - // Instantiate a new JLayoutFile instance and render the batch button - $layout = new FileLayout('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)) { ToolbarHelper::deleteList('', 'tags.delete', 'JTOOLBAR_EMPTY_TRASH'); @@ -168,70 +149,17 @@ class GetbibleViewTags extends HtmlView { ToolbarHelper::preferences('com_getbible'); } - - // Only load published batch if state and batch is allowed - if ($this->canState && $this->canBatch) - { - JHtmlBatch_::addListSelection( - Text::_('COM_GETBIBLE_KEEP_ORIGINAL_STATE'), - 'batch[published]', - Html::_('select.options', Html::_('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 = FormHelper::loadFieldType('Linkers')->options; - // We do some sanitation for Linker Name filter - if (ArrayHelper::check($this->linkerNameOptions) && - isset($this->linkerNameOptions[0]->value) && - !StringHelper::check($this->linkerNameOptions[0]->value)) - { - unset($this->linkerNameOptions[0]); - } - // Linker Name Batch Selection - JHtmlBatch_::addListSelection( - '- Keep Original '.Text::_('COM_GETBIBLE_TAG_LINKER_LABEL').' -', - 'batch[linker]', - Html::_('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 = FormHelper::loadFieldType('tagsfilteraccess')->options; - // We do some sanitation for Access filter - if (ArrayHelper::check($this->accessOptions) && - isset($this->accessOptions[0]->value) && - !StringHelper::check($this->accessOptions[0]->value)) - { - unset($this->accessOptions[0]); - } - // Access Batch Selection - JHtmlBatch_::addListSelection( - '- Keep Original '.Text::_('COM_GETBIBLE_TAG_ACCESS_LABEL').' -', - 'batch[access]', - Html::_('select.options', $this->accessOptions, 'value', 'text') - ); - } } /** - * Method to set up the document properties + * Set this html view document related stuff. * * @return void + * @since 4.4.0 */ - protected function setDocument() + protected function setHtmlViewDoc(): void { - if (!isset($this->document)) - { - $this->document = Factory::getDocument(); - } - $this->document->setTitle(Text::_('COM_GETBIBLE_TAGS')); + $this->getDocument()->setTitle(Text::_('COM_GETBIBLE_TAGS')); Html::_('stylesheet', "administrator/components/com_getbible/assets/css/tags.css", ['version' => 'auto']); } @@ -244,7 +172,11 @@ class GetbibleViewTags extends HtmlView */ public function escape($var) { - if(strlen($var) > 50) + if (!is_string($var)) + { + return $var; + } + elseif(strlen($var) > 50) { // use the helper htmlEscape method instead and shorten the string return StringHelper::html($var, $this->_charset, true); diff --git a/admin/views/passwords/tmpl/index.html b/admin/src/View/Tags/index.html similarity index 100% rename from admin/views/passwords/tmpl/index.html rename to admin/src/View/Tags/index.html diff --git a/admin/views/translation/view.html.php b/admin/src/View/Translation/HtmlView.php similarity index 82% rename from admin/views/translation/view.html.php rename to admin/src/View/Translation/HtmlView.php index 4319204..66270d2 100644 --- a/admin/views/translation/view.html.php +++ b/admin/src/View/Translation/HtmlView.php @@ -14,28 +14,31 @@ @license GNU/GPL Version 2 or later - http://www.gnu.org/licenses/gpl-2.0.html /------------------------------------------------------------------------------------------------------*/ +namespace TrueChristianChurch\Component\Getbible\Administrator\View\Translation; // No direct access to this file -defined('_JEXEC') or die('Restricted access'); +\defined('_JEXEC') or die; use Joomla\CMS\Factory; use Joomla\CMS\Language\Text; +use Joomla\CMS\Toolbar\Toolbar; use Joomla\CMS\Form\FormHelper; use Joomla\CMS\Session\Session; use Joomla\CMS\Uri\Uri; -use Joomla\CMS\Toolbar\Toolbar; use Joomla\CMS\Component\ComponentHelper; use Joomla\CMS\HTML\HTMLHelper as Html; use Joomla\CMS\Layout\FileLayout; -use Joomla\CMS\MVC\View\HtmlView; +use Joomla\CMS\MVC\View\HtmlView as BaseHtmlView; use Joomla\CMS\Plugin\PluginHelper; use Joomla\CMS\Toolbar\ToolbarHelper; +use Joomla\CMS\Document\Document; +use TrueChristianChurch\Component\Getbible\Administrator\Helper\GetbibleHelper; use VDM\Joomla\Utilities\StringHelper; /** * Translation Html View class */ -class GetbibleViewTranslation extends HtmlView +class HtmlView extends BaseHtmlView { /** * display method of View @@ -78,18 +81,18 @@ class GetbibleViewTranslation extends HtmlView // Set the toolbar $this->addToolBar(); - + // Check for errors. if (count($errors = $this->get('Errors'))) { - throw new Exception(implode("\n", $errors), 500); + throw new \Exception(implode("\n", $errors), 500); } // Display the template parent::display($tpl); - // Set the document - $this->setDocument(); + // Set the html view document stuff + $this->setHtmlViewDoc(); } @@ -112,9 +115,13 @@ class GetbibleViewTranslation extends HtmlView */ public function escape($var) { - if(strlen($var) > 30) + if (!is_string($var)) { - // use the helper htmlEscape method instead and shorten the string + return $var; + } + elseif(strlen($var) > 30) + { + // use the helper htmlEscape method instead and shorten the string return StringHelper::html($var, $this->_charset, true, 30); } // use the helper htmlEscape method instead. @@ -122,18 +129,15 @@ class GetbibleViewTranslation extends HtmlView } /** - * Method to set up the document properties + * Set this html view document related stuff. * * @return void + * @since 4.4.0 */ - protected function setDocument() + protected function setHtmlViewDoc(): void { $isNew = ($this->item->id < 1); - if (!isset($this->document)) - { - $this->document = Factory::getDocument(); - } - $this->document->setTitle(Text::_($isNew ? 'COM_GETBIBLE_TRANSLATION_NEW' : 'COM_GETBIBLE_TRANSLATION_EDIT')); + $this->getDocument()->setTitle(Text::_($isNew ? 'COM_GETBIBLE_TRANSLATION_NEW' : 'COM_GETBIBLE_TRANSLATION_EDIT')); Html::_('stylesheet', "administrator/components/com_getbible/assets/css/translation.css", ['version' => 'auto']); // Add Ajax Token $this->document->addScriptDeclaration("var token = '" . Session::getFormToken() . "';"); diff --git a/admin/views/prompt/tmpl/index.html b/admin/src/View/Translation/index.html similarity index 100% rename from admin/views/prompt/tmpl/index.html rename to admin/src/View/Translation/index.html diff --git a/admin/views/translations/view.html.php b/admin/src/View/Translations/HtmlView.php similarity index 67% rename from admin/views/translations/view.html.php rename to admin/src/View/Translations/HtmlView.php index 7bff9cb..2a3063e 100644 --- a/admin/views/translations/view.html.php +++ b/admin/src/View/Translations/HtmlView.php @@ -14,29 +14,32 @@ @license GNU/GPL Version 2 or later - http://www.gnu.org/licenses/gpl-2.0.html /------------------------------------------------------------------------------------------------------*/ +namespace TrueChristianChurch\Component\Getbible\Administrator\View\Translations; // No direct access to this file -defined('_JEXEC') or die('Restricted access'); +\defined('_JEXEC') or die; use Joomla\CMS\Factory; use Joomla\CMS\Language\Text; +use Joomla\CMS\Toolbar\Toolbar; use Joomla\CMS\Form\FormHelper; use Joomla\CMS\Session\Session; use Joomla\CMS\Uri\Uri; -use Joomla\CMS\Toolbar\Toolbar; use Joomla\CMS\Component\ComponentHelper; use Joomla\CMS\HTML\HTMLHelper as Html; use Joomla\CMS\Layout\FileLayout; -use Joomla\CMS\MVC\View\HtmlView; +use Joomla\CMS\MVC\View\HtmlView as BaseHtmlView; use Joomla\CMS\Plugin\PluginHelper; use Joomla\CMS\Toolbar\ToolbarHelper; +use Joomla\CMS\Document\Document; +use TrueChristianChurch\Component\Getbible\Administrator\Helper\GetbibleHelper; use VDM\Joomla\Utilities\ArrayHelper; use VDM\Joomla\Utilities\StringHelper; /** * Getbible Html View class for the Translations */ -class GetbibleViewTranslations extends HtmlView +class HtmlView extends BaseHtmlView { /** * Translations view display method @@ -44,17 +47,11 @@ class GetbibleViewTranslations extends HtmlView */ 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 = Factory::getUser(); + $this->user = Factory::getApplication()->getIdentity(); // Load the filter form from xml. $this->filterForm = $this->get('FilterForm'); // Load the active filters. @@ -73,29 +70,29 @@ class GetbibleViewTranslations extends HtmlView $this->canDelete = $this->canDo->get('translation.delete'); $this->canBatch = ($this->canDo->get('translation.batch') && $this->canDo->get('core.batch')); + // If we don't have items we load the empty state + if (is_array($this->items) && !count((array) $this->items) && $this->isEmptyState = $this->get('IsEmptyState')) + { + $this->setLayout('emptystate'); + } + // 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); + throw new \Exception(implode("\n", $errors), 500); } // Display the template parent::display($tpl); - // Set the document - $this->setDocument(); + // Set the html view document stuff + $this->setHtmlViewDoc(); } /** @@ -103,9 +100,7 @@ class GetbibleViewTranslations extends HtmlView */ protected function addToolBar() { - JHtmlSidebar::setAction('index.php?option=com_getbible&view=translations'); ToolbarHelper::title(Text::_('COM_GETBIBLE_TRANSLATIONS'), 'book'); - FormHelper::addFieldPath(JPATH_COMPONENT . '/models/fields'); if ($this->canCreate) { @@ -131,20 +126,6 @@ class GetbibleViewTranslations extends HtmlView ToolbarHelper::checkin('translations.checkin'); } } - - // Add a batch button - if ($this->canBatch && $this->canCreate && $this->canEdit && $this->canState) - { - // Get the toolbar object instance - $bar = Toolbar::getInstance('toolbar'); - // set the batch button name - $title = Text::_('JTOOLBAR_BATCH'); - // Instantiate a new JLayoutFile instance and render the batch button - $layout = new FileLayout('joomla.toolbar.batch'); - // add the button to the page - $dhtml = $layout->render(array('title' => $title)); - $bar->appendButton('Custom', $dhtml, 'batch'); - } if ($this->user->authorise('translation.update_book_names', 'com_getbible')) { // add Update Book Names button. @@ -178,60 +159,17 @@ class GetbibleViewTranslations extends HtmlView { ToolbarHelper::preferences('com_getbible'); } - - // Only load published batch if state and batch is allowed - if ($this->canState && $this->canBatch) - { - JHtmlBatch_::addListSelection( - Text::_('COM_GETBIBLE_KEEP_ORIGINAL_STATE'), - 'batch[published]', - Html::_('select.options', Html::_('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( - Text::_('COM_GETBIBLE_KEEP_ORIGINAL_ACCESS'), - 'batch[access]', - Html::_('select.options', Html::_('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 = FormHelper::loadFieldType('translationsfilterdirection')->options; - // We do some sanitation for Direction filter - if (ArrayHelper::check($this->directionOptions) && - isset($this->directionOptions[0]->value) && - !StringHelper::check($this->directionOptions[0]->value)) - { - unset($this->directionOptions[0]); - } - // Direction Batch Selection - JHtmlBatch_::addListSelection( - '- Keep Original '.Text::_('COM_GETBIBLE_TRANSLATION_DIRECTION_LABEL').' -', - 'batch[direction]', - Html::_('select.options', $this->directionOptions, 'value', 'text') - ); - } } /** - * Method to set up the document properties + * Set this html view document related stuff. * * @return void + * @since 4.4.0 */ - protected function setDocument() + protected function setHtmlViewDoc(): void { - if (!isset($this->document)) - { - $this->document = Factory::getDocument(); - } - $this->document->setTitle(Text::_('COM_GETBIBLE_TRANSLATIONS')); + $this->getDocument()->setTitle(Text::_('COM_GETBIBLE_TRANSLATIONS')); Html::_('stylesheet', "administrator/components/com_getbible/assets/css/translations.css", ['version' => 'auto']); } @@ -244,7 +182,11 @@ class GetbibleViewTranslations extends HtmlView */ public function escape($var) { - if(strlen($var) > 50) + if (!is_string($var)) + { + return $var; + } + elseif(strlen($var) > 50) { // use the helper htmlEscape method instead and shorten the string return StringHelper::html($var, $this->_charset, true); diff --git a/admin/views/prompts/index.html b/admin/src/View/Translations/index.html similarity index 100% rename from admin/views/prompts/index.html rename to admin/src/View/Translations/index.html diff --git a/admin/views/verse/view.html.php b/admin/src/View/Verse/HtmlView.php similarity index 82% rename from admin/views/verse/view.html.php rename to admin/src/View/Verse/HtmlView.php index 47d013d..be27ca8 100644 --- a/admin/views/verse/view.html.php +++ b/admin/src/View/Verse/HtmlView.php @@ -14,28 +14,31 @@ @license GNU/GPL Version 2 or later - http://www.gnu.org/licenses/gpl-2.0.html /------------------------------------------------------------------------------------------------------*/ +namespace TrueChristianChurch\Component\Getbible\Administrator\View\Verse; // No direct access to this file -defined('_JEXEC') or die('Restricted access'); +\defined('_JEXEC') or die; use Joomla\CMS\Factory; use Joomla\CMS\Language\Text; +use Joomla\CMS\Toolbar\Toolbar; use Joomla\CMS\Form\FormHelper; use Joomla\CMS\Session\Session; use Joomla\CMS\Uri\Uri; -use Joomla\CMS\Toolbar\Toolbar; use Joomla\CMS\Component\ComponentHelper; use Joomla\CMS\HTML\HTMLHelper as Html; use Joomla\CMS\Layout\FileLayout; -use Joomla\CMS\MVC\View\HtmlView; +use Joomla\CMS\MVC\View\HtmlView as BaseHtmlView; use Joomla\CMS\Plugin\PluginHelper; use Joomla\CMS\Toolbar\ToolbarHelper; +use Joomla\CMS\Document\Document; +use TrueChristianChurch\Component\Getbible\Administrator\Helper\GetbibleHelper; use VDM\Joomla\Utilities\StringHelper; /** * Verse Html View class */ -class GetbibleViewVerse extends HtmlView +class HtmlView extends BaseHtmlView { /** * display method of View @@ -78,18 +81,18 @@ class GetbibleViewVerse extends HtmlView // Set the toolbar $this->addToolBar(); - + // Check for errors. if (count($errors = $this->get('Errors'))) { - throw new Exception(implode("\n", $errors), 500); + throw new \Exception(implode("\n", $errors), 500); } // Display the template parent::display($tpl); - // Set the document - $this->setDocument(); + // Set the html view document stuff + $this->setHtmlViewDoc(); } @@ -112,9 +115,13 @@ class GetbibleViewVerse extends HtmlView */ public function escape($var) { - if(strlen($var) > 30) + if (!is_string($var)) { - // use the helper htmlEscape method instead and shorten the string + return $var; + } + elseif(strlen($var) > 30) + { + // use the helper htmlEscape method instead and shorten the string return StringHelper::html($var, $this->_charset, true, 30); } // use the helper htmlEscape method instead. @@ -122,18 +129,15 @@ class GetbibleViewVerse extends HtmlView } /** - * Method to set up the document properties + * Set this html view document related stuff. * * @return void + * @since 4.4.0 */ - protected function setDocument() + protected function setHtmlViewDoc(): void { $isNew = ($this->item->id < 1); - if (!isset($this->document)) - { - $this->document = Factory::getDocument(); - } - $this->document->setTitle(Text::_($isNew ? 'COM_GETBIBLE_VERSE_NEW' : 'COM_GETBIBLE_VERSE_EDIT')); + $this->getDocument()->setTitle(Text::_($isNew ? 'COM_GETBIBLE_VERSE_NEW' : 'COM_GETBIBLE_VERSE_EDIT')); Html::_('stylesheet', "administrator/components/com_getbible/assets/css/verse.css", ['version' => 'auto']); Html::_('script', $this->script, ['version' => 'auto']); Html::_('script', "administrator/components/com_getbible/views/verse/submitbutton.js", ['version' => 'auto']); diff --git a/admin/views/prompts/tmpl/index.html b/admin/src/View/Verse/index.html similarity index 100% rename from admin/views/prompts/tmpl/index.html rename to admin/src/View/Verse/index.html diff --git a/admin/views/verses/view.html.php b/admin/src/View/Verses/HtmlView.php similarity index 50% rename from admin/views/verses/view.html.php rename to admin/src/View/Verses/HtmlView.php index b1af3ec..76683f1 100644 --- a/admin/views/verses/view.html.php +++ b/admin/src/View/Verses/HtmlView.php @@ -14,29 +14,32 @@ @license GNU/GPL Version 2 or later - http://www.gnu.org/licenses/gpl-2.0.html /------------------------------------------------------------------------------------------------------*/ +namespace TrueChristianChurch\Component\Getbible\Administrator\View\Verses; // No direct access to this file -defined('_JEXEC') or die('Restricted access'); +\defined('_JEXEC') or die; use Joomla\CMS\Factory; use Joomla\CMS\Language\Text; +use Joomla\CMS\Toolbar\Toolbar; use Joomla\CMS\Form\FormHelper; use Joomla\CMS\Session\Session; use Joomla\CMS\Uri\Uri; -use Joomla\CMS\Toolbar\Toolbar; use Joomla\CMS\Component\ComponentHelper; use Joomla\CMS\HTML\HTMLHelper as Html; use Joomla\CMS\Layout\FileLayout; -use Joomla\CMS\MVC\View\HtmlView; +use Joomla\CMS\MVC\View\HtmlView as BaseHtmlView; use Joomla\CMS\Plugin\PluginHelper; use Joomla\CMS\Toolbar\ToolbarHelper; +use Joomla\CMS\Document\Document; +use TrueChristianChurch\Component\Getbible\Administrator\Helper\GetbibleHelper; use VDM\Joomla\Utilities\ArrayHelper; use VDM\Joomla\Utilities\StringHelper; /** * Getbible Html View class for the Verses */ -class GetbibleViewVerses extends HtmlView +class HtmlView extends BaseHtmlView { /** * Verses view display method @@ -44,17 +47,11 @@ class GetbibleViewVerses extends HtmlView */ 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 = Factory::getUser(); + $this->user = Factory::getApplication()->getIdentity(); // Load the filter form from xml. $this->filterForm = $this->get('FilterForm'); // Load the active filters. @@ -73,29 +70,29 @@ class GetbibleViewVerses extends HtmlView $this->canDelete = $this->canDo->get('verse.delete'); $this->canBatch = ($this->canDo->get('verse.batch') && $this->canDo->get('core.batch')); + // If we don't have items we load the empty state + if (is_array($this->items) && !count((array) $this->items) && $this->isEmptyState = $this->get('IsEmptyState')) + { + $this->setLayout('emptystate'); + } + // 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); + throw new \Exception(implode("\n", $errors), 500); } // Display the template parent::display($tpl); - // Set the document - $this->setDocument(); + // Set the html view document stuff + $this->setHtmlViewDoc(); } /** @@ -103,9 +100,7 @@ class GetbibleViewVerses extends HtmlView */ protected function addToolBar() { - JHtmlSidebar::setAction('index.php?option=com_getbible&view=verses'); ToolbarHelper::title(Text::_('COM_GETBIBLE_VERSES'), 'generic'); - FormHelper::addFieldPath(JPATH_COMPONENT . '/models/fields'); if ($this->canCreate) { @@ -132,20 +127,6 @@ class GetbibleViewVerses extends HtmlView } } - // Add a batch button - if ($this->canBatch && $this->canCreate && $this->canEdit && $this->canState) - { - // Get the toolbar object instance - $bar = Toolbar::getInstance('toolbar'); - // set the batch button name - $title = Text::_('JTOOLBAR_BATCH'); - // Instantiate a new JLayoutFile instance and render the batch button - $layout = new FileLayout('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)) { ToolbarHelper::deleteList('', 'verses.delete', 'JTOOLBAR_EMPTY_TRASH'); @@ -168,120 +149,17 @@ class GetbibleViewVerses extends HtmlView { ToolbarHelper::preferences('com_getbible'); } - - // Only load published batch if state and batch is allowed - if ($this->canState && $this->canBatch) - { - JHtmlBatch_::addListSelection( - Text::_('COM_GETBIBLE_KEEP_ORIGINAL_STATE'), - 'batch[published]', - Html::_('select.options', Html::_('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( - Text::_('COM_GETBIBLE_KEEP_ORIGINAL_ACCESS'), - 'batch[access]', - Html::_('select.options', Html::_('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 = FormHelper::loadFieldType('versesfilterbooknr')->options; - // We do some sanitation for Book Nr filter - if (ArrayHelper::check($this->book_nrOptions) && - isset($this->book_nrOptions[0]->value) && - !StringHelper::check($this->book_nrOptions[0]->value)) - { - unset($this->book_nrOptions[0]); - } - // Book Nr Batch Selection - JHtmlBatch_::addListSelection( - '- Keep Original '.Text::_('COM_GETBIBLE_VERSE_BOOK_NR_LABEL').' -', - 'batch[book_nr]', - Html::_('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 = FormHelper::loadFieldType('versesfilterchapter')->options; - // We do some sanitation for Chapter filter - if (ArrayHelper::check($this->chapterOptions) && - isset($this->chapterOptions[0]->value) && - !StringHelper::check($this->chapterOptions[0]->value)) - { - unset($this->chapterOptions[0]); - } - // Chapter Batch Selection - JHtmlBatch_::addListSelection( - '- Keep Original '.Text::_('COM_GETBIBLE_VERSE_CHAPTER_LABEL').' -', - 'batch[chapter]', - Html::_('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 = FormHelper::loadFieldType('versesfilterverse')->options; - // We do some sanitation for Verse filter - if (ArrayHelper::check($this->verseOptions) && - isset($this->verseOptions[0]->value) && - !StringHelper::check($this->verseOptions[0]->value)) - { - unset($this->verseOptions[0]); - } - // Verse Batch Selection - JHtmlBatch_::addListSelection( - '- Keep Original '.Text::_('COM_GETBIBLE_VERSE_VERSE_LABEL').' -', - 'batch[verse]', - Html::_('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 = FormHelper::loadFieldType('Translations')->options; - // We do some sanitation for Abbreviation Translation filter - if (ArrayHelper::check($this->abbreviationTranslationOptions) && - isset($this->abbreviationTranslationOptions[0]->value) && - !StringHelper::check($this->abbreviationTranslationOptions[0]->value)) - { - unset($this->abbreviationTranslationOptions[0]); - } - // Abbreviation Translation Batch Selection - JHtmlBatch_::addListSelection( - '- Keep Original '.Text::_('COM_GETBIBLE_VERSE_ABBREVIATION_LABEL').' -', - 'batch[abbreviation]', - Html::_('select.options', $this->abbreviationTranslationOptions, 'value', 'text') - ); - } } /** - * Method to set up the document properties + * Set this html view document related stuff. * * @return void + * @since 4.4.0 */ - protected function setDocument() + protected function setHtmlViewDoc(): void { - if (!isset($this->document)) - { - $this->document = Factory::getDocument(); - } - $this->document->setTitle(Text::_('COM_GETBIBLE_VERSES')); + $this->getDocument()->setTitle(Text::_('COM_GETBIBLE_VERSES')); Html::_('stylesheet', "administrator/components/com_getbible/assets/css/verses.css", ['version' => 'auto']); } @@ -294,7 +172,11 @@ class GetbibleViewVerses extends HtmlView */ public function escape($var) { - if(strlen($var) > 50) + if (!is_string($var)) + { + return $var; + } + elseif(strlen($var) > 50) { // use the helper htmlEscape method instead and shorten the string return StringHelper::html($var, $this->_charset, true); diff --git a/admin/views/tag/tmpl/index.html b/admin/src/View/Verses/index.html similarity index 100% rename from admin/views/tag/tmpl/index.html rename to admin/src/View/Verses/index.html diff --git a/admin/views/tagged_verse/tmpl/index.html b/admin/src/View/index.html similarity index 100% rename from admin/views/tagged_verse/tmpl/index.html rename to admin/src/View/index.html diff --git a/admin/views/tagged_verses/index.html b/admin/src/index.html similarity index 100% rename from admin/views/tagged_verses/index.html rename to admin/src/index.html diff --git a/admin/views/book/tmpl/edit.php b/admin/tmpl/book/default.php similarity index 57% rename from admin/views/book/tmpl/edit.php rename to admin/tmpl/book/default.php index 140a500..1d61f7c 100644 --- a/admin/views/book/tmpl/edit.php +++ b/admin/tmpl/book/default.php @@ -16,82 +16,76 @@ /------------------------------------------------------------------------------------------------------*/ // No direct access to this file -defined('_JEXEC') or die('Restricted access'); +defined('_JEXEC') or die; use Joomla\CMS\Factory; use Joomla\CMS\Language\Text; use Joomla\CMS\HTML\HTMLHelper as Html; use Joomla\CMS\Layout\LayoutHelper; use Joomla\CMS\Router\Route; -Html::addIncludePath(JPATH_COMPONENT.'/helpers/html'); -Html::_('behavior.formvalidator'); -Html::_('formbehavior.chosen', 'select'); -Html::_('behavior.keepalive'); -$componentParams = $this->params; // will be removed just use $this->params instead +/** @var Joomla\CMS\WebAsset\WebAssetManager $wa */ +$wa = $this->getDocument()->getWebAssetManager(); +$wa->useScript('keepalive')->useScript('form.validate'); +Html::_('bootstrap.tooltip'); +use TrueChristianChurch\Component\Getbible\Administrator\Helper\GetbibleHelper; + ?>
loadTemplate('foot');?>loadTemplate('body');?>
- - canCreate && $this->canEdit) : ?> - Text::_('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/tmpl/books/default_batch_body.php similarity index 95% rename from admin/views/books/tmpl/default_batch_body.php rename to admin/tmpl/books/default_batch_body.php index f0764bd..68213fa 100644 --- a/admin/views/books/tmpl/default_batch_body.php +++ b/admin/tmpl/books/default_batch_body.php @@ -16,7 +16,7 @@ /------------------------------------------------------------------------------------------------------*/ // No direct access to this file -defined('_JEXEC') or die('Restricted access'); +defined('_JEXEC') or die; use Joomla\CMS\Language\Text; use Joomla\CMS\HTML\HTMLHelper as Html; diff --git a/admin/views/books/tmpl/default_batch_footer.php b/admin/tmpl/books/default_batch_footer.php similarity index 96% rename from admin/views/books/tmpl/default_batch_footer.php rename to admin/tmpl/books/default_batch_footer.php index 9a8b230..03494a7 100644 --- a/admin/views/books/tmpl/default_batch_footer.php +++ b/admin/tmpl/books/default_batch_footer.php @@ -16,7 +16,7 @@ /------------------------------------------------------------------------------------------------------*/ // No direct access to this file -defined('_JEXEC') or die('Restricted access'); +defined('_JEXEC') or die; use Joomla\CMS\Language\Text; diff --git a/admin/views/books/tmpl/default_body.php b/admin/tmpl/books/default_body.php similarity index 94% rename from admin/views/books/tmpl/default_body.php rename to admin/tmpl/books/default_body.php index e430f6f..b78216b 100644 --- a/admin/views/books/tmpl/default_body.php +++ b/admin/tmpl/books/default_body.php @@ -16,11 +16,12 @@ /------------------------------------------------------------------------------------------------------*/ // No direct access to this file -defined('_JEXEC') or die('Restricted access'); +defined('_JEXEC') or die; use Joomla\CMS\Factory; use Joomla\CMS\Language\Text; use Joomla\CMS\HTML\HTMLHelper as Html; +use TrueChristianChurch\Component\Getbible\Administrator\Helper\GetbibleHelper; $edit = "index.php?option=com_getbible&view=books&task=book.edit"; @@ -28,7 +29,9 @@ $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 = Factory::getUser($item->checked_out); + $userChkOut = Factory::getContainer()-> + get(\Joomla\CMS\User\UserFactoryInterface::class)-> + loadUserById($item->checked_out); $canDo = GetbibleHelper::getActions('book',$item,'books'); ?> diff --git a/admin/views/passwords/tmpl/default_foot.php b/admin/tmpl/books/default_foot.php similarity index 95% rename from admin/views/passwords/tmpl/default_foot.php rename to admin/tmpl/books/default_foot.php index 38a928f..8f67571 100644 --- a/admin/views/passwords/tmpl/default_foot.php +++ b/admin/tmpl/books/default_foot.php @@ -16,7 +16,7 @@ /------------------------------------------------------------------------------------------------------*/ // No direct access to this file -defined('_JEXEC') or die('Restricted access'); +defined('_JEXEC') or die; ?> diff --git a/admin/views/books/tmpl/default_head.php b/admin/tmpl/books/default_head.php similarity index 98% rename from admin/views/books/tmpl/default_head.php rename to admin/tmpl/books/default_head.php index d909c33..054a03f 100644 --- a/admin/views/books/tmpl/default_head.php +++ b/admin/tmpl/books/default_head.php @@ -16,7 +16,7 @@ /------------------------------------------------------------------------------------------------------*/ // No direct access to this file -defined('_JEXEC') or die('Restricted access'); +defined('_JEXEC') or die; use Joomla\CMS\Language\Text; use Joomla\CMS\HTML\HTMLHelper as Html; diff --git a/admin/tmpl/books/default_toolbar.php b/admin/tmpl/books/default_toolbar.php new file mode 100644 index 0000000..64aa4b1 --- /dev/null +++ b/admin/tmpl/books/default_toolbar.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; + +use Joomla\CMS\Language\Text; +use Joomla\CMS\HTML\HTMLHelper as Html; + +?> +
+ +
+ + +
+
+ + pagination->getLimitBox(); ?> +
+
+ + +
+
+ + +
+
+
\ No newline at end of file diff --git a/admin/tmpl/books/emptystate.php b/admin/tmpl/books/emptystate.php new file mode 100644 index 0000000..711ec7e --- /dev/null +++ b/admin/tmpl/books/emptystate.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; + +use Joomla\CMS\Layout\LayoutHelper; + +$displayData = [ + 'textPrefix' => 'COM_GETBIBLE_BOOKS', + 'formURL' => 'index.php?option=com_getbible&view=books', + 'icon' => 'icon-generic', +]; + +if ($this->user->authorise('book.create', 'com_getbible')) +{ + $displayData['createURL'] = 'index.php?option=com_getbible&task=book.add'; +} + +echo LayoutHelper::render('joomla.content.emptystate', $displayData); diff --git a/admin/views/tags/index.html b/admin/tmpl/books/index.html similarity index 100% rename from admin/views/tags/index.html rename to admin/tmpl/books/index.html diff --git a/admin/views/chapter/tmpl/edit.php b/admin/tmpl/chapter/default.php similarity index 57% rename from admin/views/chapter/tmpl/edit.php rename to admin/tmpl/chapter/default.php index 644fd12..7c33f66 100644 --- a/admin/views/chapter/tmpl/edit.php +++ b/admin/tmpl/chapter/default.php @@ -16,82 +16,76 @@ /------------------------------------------------------------------------------------------------------*/ // No direct access to this file -defined('_JEXEC') or die('Restricted access'); +defined('_JEXEC') or die; use Joomla\CMS\Factory; use Joomla\CMS\Language\Text; use Joomla\CMS\HTML\HTMLHelper as Html; use Joomla\CMS\Layout\LayoutHelper; use Joomla\CMS\Router\Route; -Html::addIncludePath(JPATH_COMPONENT.'/helpers/html'); -Html::_('behavior.formvalidator'); -Html::_('formbehavior.chosen', 'select'); -Html::_('behavior.keepalive'); -$componentParams = $this->params; // will be removed just use $this->params instead +/** @var Joomla\CMS\WebAsset\WebAssetManager $wa */ +$wa = $this->getDocument()->getWebAssetManager(); +$wa->useScript('keepalive')->useScript('form.validate'); +Html::_('bootstrap.tooltip'); +use TrueChristianChurch\Component\Getbible\Administrator\Helper\GetbibleHelper; + ?>