diff --git a/src/administrator/language/en-GB/plg_system_mokojoomtos.ini b/src/administrator/language/en-GB/plg_system_mokojoomtos.ini index f342ea9..21f5649 100644 --- a/src/administrator/language/en-GB/plg_system_mokojoomtos.ini +++ b/src/administrator/language/en-GB/plg_system_mokojoomtos.ini @@ -13,7 +13,10 @@ PLG_SYSTEM_MOKOJOOMTOS_FIELD_TOS_SLUG_DESC="Enter the menu slug for your Terms o ; Help PLG_SYSTEM_MOKOJOOMTOS_HELP_LABEL="How to Use This Plugin" -PLG_SYSTEM_MOKOJOOMTOS_HELP_DESC="Step 1: Create a Joomla article for your Terms of Service.
Step 2: Create a menu item pointing to that article.
Step 3: Set the menu item alias/slug (e.g., 'terms-of-service').
Step 4: Enter that same slug above.
Step 5: When your site goes offline, visitors can still access your-site.com/terms-of-service" +PLG_SYSTEM_MOKOJOOMTOS_HELP_DESC="Step 1: Create a Joomla article for your Terms of Service.
Step 2: Create a menu item pointing to that article.
Step 3: Set the menu item alias/slug (e.g., 'terms-of-service').
Step 4: Enter that same slug above.
Step 5: When your site goes offline, visitors can still access yoursite.com/terms-of-service" + +; Errors +PLG_SYSTEM_MOKOJOOMTOS_ERROR_LOADING_MENU_ITEMS="Error loading menu items: %s" ; Installation messages PLG_SYSTEM_MOKOJOOMTOS_INSTALL_SUCCESS="MokoJoomTOS Plugin installed successfully!" diff --git a/src/administrator/language/en-US/plg_system_mokojoomtos.ini b/src/administrator/language/en-US/plg_system_mokojoomtos.ini index f342ea9..21f5649 100644 --- a/src/administrator/language/en-US/plg_system_mokojoomtos.ini +++ b/src/administrator/language/en-US/plg_system_mokojoomtos.ini @@ -13,7 +13,10 @@ PLG_SYSTEM_MOKOJOOMTOS_FIELD_TOS_SLUG_DESC="Enter the menu slug for your Terms o ; Help PLG_SYSTEM_MOKOJOOMTOS_HELP_LABEL="How to Use This Plugin" -PLG_SYSTEM_MOKOJOOMTOS_HELP_DESC="Step 1: Create a Joomla article for your Terms of Service.
Step 2: Create a menu item pointing to that article.
Step 3: Set the menu item alias/slug (e.g., 'terms-of-service').
Step 4: Enter that same slug above.
Step 5: When your site goes offline, visitors can still access your-site.com/terms-of-service" +PLG_SYSTEM_MOKOJOOMTOS_HELP_DESC="Step 1: Create a Joomla article for your Terms of Service.
Step 2: Create a menu item pointing to that article.
Step 3: Set the menu item alias/slug (e.g., 'terms-of-service').
Step 4: Enter that same slug above.
Step 5: When your site goes offline, visitors can still access yoursite.com/terms-of-service" + +; Errors +PLG_SYSTEM_MOKOJOOMTOS_ERROR_LOADING_MENU_ITEMS="Error loading menu items: %s" ; Installation messages PLG_SYSTEM_MOKOJOOMTOS_INSTALL_SUCCESS="MokoJoomTOS Plugin installed successfully!" diff --git a/src/language/en-GB/plg_system_mokojoomtos.ini b/src/language/en-GB/plg_system_mokojoomtos.ini index 8c10471..736f3a6 100644 --- a/src/language/en-GB/plg_system_mokojoomtos.ini +++ b/src/language/en-GB/plg_system_mokojoomtos.ini @@ -15,6 +15,9 @@ PLG_SYSTEM_MOKOJOOMTOS_FIELD_TOS_SLUG_DESC="Enter the menu slug for your Terms o PLG_SYSTEM_MOKOJOOMTOS_HELP_LABEL="How to Use This Plugin" PLG_SYSTEM_MOKOJOOMTOS_HELP_DESC="Step 1: Create a Joomla article for your Terms of Service.
Step 2: Create a menu item pointing to that article.
Step 3: Set the menu item alias/slug (e.g., 'terms-of-service').
Step 4: Enter that same slug above.
Step 5: When your site goes offline, visitors can still access yoursite.com/terms-of-service" +; Errors +PLG_SYSTEM_MOKOJOOMTOS_ERROR_LOADING_MENU_ITEMS="Error loading menu items: %s" + ; Installation messages PLG_SYSTEM_MOKOJOOMTOS_INSTALL_SUCCESS="MokoJoomTOS Plugin installed successfully!" PLG_SYSTEM_MOKOJOOMTOS_UPDATE_SUCCESS="MokoJoomTOS Plugin updated successfully!" diff --git a/src/language/en-US/plg_system_mokojoomtos.ini b/src/language/en-US/plg_system_mokojoomtos.ini index 8c10471..736f3a6 100644 --- a/src/language/en-US/plg_system_mokojoomtos.ini +++ b/src/language/en-US/plg_system_mokojoomtos.ini @@ -15,6 +15,9 @@ PLG_SYSTEM_MOKOJOOMTOS_FIELD_TOS_SLUG_DESC="Enter the menu slug for your Terms o PLG_SYSTEM_MOKOJOOMTOS_HELP_LABEL="How to Use This Plugin" PLG_SYSTEM_MOKOJOOMTOS_HELP_DESC="Step 1: Create a Joomla article for your Terms of Service.
Step 2: Create a menu item pointing to that article.
Step 3: Set the menu item alias/slug (e.g., 'terms-of-service').
Step 4: Enter that same slug above.
Step 5: When your site goes offline, visitors can still access yoursite.com/terms-of-service" +; Errors +PLG_SYSTEM_MOKOJOOMTOS_ERROR_LOADING_MENU_ITEMS="Error loading menu items: %s" + ; Installation messages PLG_SYSTEM_MOKOJOOMTOS_INSTALL_SUCCESS="MokoJoomTOS Plugin installed successfully!" PLG_SYSTEM_MOKOJOOMTOS_UPDATE_SUCCESS="MokoJoomTOS Plugin updated successfully!" diff --git a/src/mokojoomtos.xml b/src/mokojoomtos.xml index b488ce0..66b5741 100644 --- a/src/mokojoomtos.xml +++ b/src/mokojoomtos.xml @@ -84,8 +84,6 @@ - - https://git.mokoconsulting.tech/MokoConsulting/MokoJoomTOS/raw/branch/main/updates.xml - + https://git.mokoconsulting.tech/MokoConsulting/MokoJoomTOS/raw/branch/main/updates.xml diff --git a/src/plugins/system/mokojoomtos/mokojoomtos.xml b/src/plugins/system/mokojoomtos/mokojoomtos.xml deleted file mode 100644 index 19d5cd6..0000000 --- a/src/plugins/system/mokojoomtos/mokojoomtos.xml +++ /dev/null @@ -1,66 +0,0 @@ - - - plg_system_mokojoomtos - Moko Consulting - 2026-01-01 - Copyright (C) 2026 Moko Consulting. All rights reserved. - GNU General Public License version 3 or later; see LICENSE - hello@mokoconsulting.tech - https://mokoconsulting.tech - 03.08.04 - PLG_SYSTEM_MOKOJOOMTOS_XML_DESCRIPTION - - Joomla\Plugin\System\MokoJoomTOS - - script.php - - - mokojoomtos.php - src - language - administrator - - - - language/en-GB/plg_system_mokojoomtos.ini - language/en-GB/plg_system_mokojoomtos.sys.ini - language/en-US/plg_system_mokojoomtos.ini - language/en-US/plg_system_mokojoomtos.sys.ini - administrator/language/en-GB/plg_system_mokojoomtos.ini - administrator/language/en-GB/plg_system_mokojoomtos.sys.ini - administrator/language/en-US/plg_system_mokojoomtos.ini - administrator/language/en-US/plg_system_mokojoomtos.sys.ini - - - - -
- - - -
-
-
- - - - https://git.mokoconsulting.tech/MokoConsulting/MokoJoomTOS/raw/branch/main/updates.xml - - - https://raw.githubusercontent.com/mokoconsulting-tech/MokoJoomTOS/main/updates.xml - - -
diff --git a/src/script.php b/src/script.php index f60496e..b105234 100644 --- a/src/script.php +++ b/src/script.php @@ -171,7 +171,7 @@ class PlgSystemMokojoomtosOfflineInstallerScript extends InstallerScript $this->createTermsMenuItem($articleId); } } - } catch (Exception $e) { + } catch (\Exception $e) { Log::add('Error creating Terms of Service setup: ' . $e->getMessage(), Log::WARNING, 'jerror'); } } @@ -186,23 +186,43 @@ class PlgSystemMokojoomtosOfflineInstallerScript extends InstallerScript private function createTermsArticle() { try { + $db = Factory::getDbo(); + Table::addIncludePath(JPATH_ADMINISTRATOR . '/components/com_content/tables'); $table = Table::getInstance('Content', 'Joomla\\Component\\Content\\Administrator\\Table\\'); - + if (!$table) { Log::add('Failed to get Content table instance', Log::WARNING, 'jerror'); return null; } - + + // Get Uncategorised category ID dynamically + $query = $db->getQuery(true) + ->select('id') + ->from($db->quoteName('#__categories')) + ->where($db->quoteName('extension') . ' = ' . $db->quote('com_content')) + ->where($db->quoteName('alias') . ' = ' . $db->quote('uncategorised')) + ->where($db->quoteName('published') . ' = 1'); + $db->setQuery($query); + $catId = (int) $db->loadResult(); + + if (!$catId) { + Log::add('Could not find Uncategorised category for com_content', Log::WARNING, 'jerror'); + return null; + } + + // Get current user ID for article ownership + $createdBy = Factory::getApplication()->getIdentity()->id ?: 0; + $data = [ 'title' => 'Terms of Service', 'alias' => 'terms-of-service', 'introtext' => '

Terms of Service

Welcome to our Terms of Service page.

This page will remain accessible even when the site is in offline/maintenance mode.

', 'fulltext' => '', 'state' => 1, - 'catid' => 2, // Uncategorised + 'catid' => $catId, 'created' => Factory::getDate()->toSql(), - 'created_by' => 0, // System-created content + 'created_by' => $createdBy, 'language' => '*', 'access' => 1, // Public ]; @@ -227,7 +247,7 @@ class PlgSystemMokojoomtosOfflineInstallerScript extends InstallerScript echo '

✓ Created Terms of Service article

'; return $table->id; - } catch (Exception $e) { + } catch (\Exception $e) { Log::add('Error creating Terms of Service article: ' . $e->getMessage(), Log::WARNING, 'jerror'); } @@ -268,7 +288,12 @@ class PlgSystemMokojoomtosOfflineInstallerScript extends InstallerScript ->where($db->quoteName('type') . ' = ' . $db->quote('component')) ->where($db->quoteName('element') . ' = ' . $db->quote('com_content')); $db->setQuery($query); - $componentId = (int) $db->loadResult() ?: 22; // Fallback to 22 if query fails + $componentId = (int) $db->loadResult(); + + if (!$componentId) { + Log::add('Could not determine com_content component ID', Log::WARNING, 'jerror'); + return; + } Table::addIncludePath(JPATH_ADMINISTRATOR . '/components/com_menus/tables'); $table = Table::getInstance('Menu', 'Joomla\\Component\\Menus\\Administrator\\Table\\'); @@ -318,7 +343,7 @@ class PlgSystemMokojoomtosOfflineInstallerScript extends InstallerScript // Enable the plugin $this->enablePlugin(); - } catch (Exception $e) { + } catch (\Exception $e) { Log::add('Error creating Terms of Service menu item: ' . $e->getMessage(), Log::WARNING, 'jerror'); } } @@ -348,7 +373,7 @@ class PlgSystemMokojoomtosOfflineInstallerScript extends InstallerScript $db->execute(); echo '

✓ Created Legal menu type

'; - } catch (Exception $e) { + } catch (\Exception $e) { Log::add('Error creating Legal menu type: ' . $e->getMessage(), Log::WARNING, 'jerror'); } } @@ -374,7 +399,7 @@ class PlgSystemMokojoomtosOfflineInstallerScript extends InstallerScript $db->execute(); echo '

✓ Plugin enabled automatically

'; - } catch (Exception $e) { + } catch (\Exception $e) { Log::add('Error enabling plugin: ' . $e->getMessage(), Log::WARNING, 'jerror'); } }