From 39c56bbf35339e93236ff4303dc80e749916075d Mon Sep 17 00:00:00 2001 From: Sergey Tolkachyov Date: Mon, 2 Sep 2024 10:45:07 +0400 Subject: [PATCH] v.2.0.0 --- donate_message.php | 19 - .../en-GB.plg_jlsitemap_swjprojects.sys.ini | 17 - ...ects.ini => plg_jlsitemap_swjprojects.ini} | 8 +- .../en-GB/plg_jlsitemap_swjprojects.sys.ini | 12 + ...ects.ini => plg_jlsitemap_swjprojects.ini} | 8 +- .../ru-RU/plg_jlsitemap_swjprojects.sys.ini | 12 + .../ru-RU.plg_jlsitemap_swjprojects.sys.ini | 18 - script.php | 362 +++++++++++------- services/provider.php | 45 +++ .../Extension/Swjprojects.php | 233 ++++++----- src/Fields/PlugininfoField.php | 96 +++++ swjprojects.xml | 44 ++- toolbar.php | 72 ---- 13 files changed, 557 insertions(+), 389 deletions(-) delete mode 100644 donate_message.php delete mode 100644 language/en-GB/en-GB.plg_jlsitemap_swjprojects.sys.ini rename language/en-GB/{en-GB.plg_jlsitemap_swjprojects.ini => plg_jlsitemap_swjprojects.ini} (88%) create mode 100644 language/en-GB/plg_jlsitemap_swjprojects.sys.ini rename language/ru-RU/{ru-RU.plg_jlsitemap_swjprojects.ini => plg_jlsitemap_swjprojects.ini} (87%) create mode 100644 language/ru-RU/plg_jlsitemap_swjprojects.sys.ini delete mode 100644 language/ru-RU/ru-RU.plg_jlsitemap_swjprojects.sys.ini create mode 100644 services/provider.php rename swjprojects.php => src/Extension/Swjprojects.php (70%) create mode 100644 src/Fields/PlugininfoField.php delete mode 100644 toolbar.php diff --git a/donate_message.php b/donate_message.php deleted file mode 100644 index b5b5d5b..0000000 --- a/donate_message.php +++ /dev/null @@ -1,19 +0,0 @@ - - - - - \ No newline at end of file diff --git a/language/en-GB/en-GB.plg_jlsitemap_swjprojects.sys.ini b/language/en-GB/en-GB.plg_jlsitemap_swjprojects.sys.ini deleted file mode 100644 index c6157cf..0000000 --- a/language/en-GB/en-GB.plg_jlsitemap_swjprojects.sys.ini +++ /dev/null @@ -1,17 +0,0 @@ -; @package JLSitemap - SW JProjects Plugin -; @version __DEPLOY_VERSION__ -; @author Septdir Workshop - www.septdir.com -; @copyright Copyright (c) 2018 - 2019 Septdir Workshop. All rights reserved. -; @license GNU/GPL license: https://www.gnu.org/copyleft/gpl.html -; @link https://www.septdir.com/ -; Note : All ini files need to be saved as UTF-8 - -PLG_JLSITEMAP_SWJPROJECTS = "JLSitemap - SW JProjects" -PLG_JLSITEMAP_SWJPROJECTS_DESCRIPTION = "Plugin for integrating SWJProjects and JLSitemap" - -PLG_JLSITEMAP_SWJPROJECTS_ERROR_COMPATIBLE_PHP = "This version is compatible only with PHP %s and later" -PLG_JLSITEMAP_SWJPROJECTS_ERROR_COMPATIBLE_JOOMLA = "This version is compatible only with Joomla %s and later" - -PLG_JLSITEMAP_SWJPROJECTS_SUPPORT = "Support" -PLG_JLSITEMAP_SWJPROJECTS_DONATE = "Donate" -PLG_JLSITEMAP_SWJPROJECTS_DONATE_MESSAGE = "JLSitemap - SWJProjects is a free extension and is being developed through voluntary donations.
The larger the amount collected, the faster we release updates." \ No newline at end of file diff --git a/language/en-GB/en-GB.plg_jlsitemap_swjprojects.ini b/language/en-GB/plg_jlsitemap_swjprojects.ini similarity index 88% rename from language/en-GB/en-GB.plg_jlsitemap_swjprojects.ini rename to language/en-GB/plg_jlsitemap_swjprojects.ini index dfb6f9c..d865644 100644 --- a/language/en-GB/en-GB.plg_jlsitemap_swjprojects.ini +++ b/language/en-GB/plg_jlsitemap_swjprojects.ini @@ -1,5 +1,5 @@ ; @package JLSitemap - SW JProjects Plugin -; @version __DEPLOY_VERSION__ +; @version 1.0.0 ; @author Septdir Workshop - www.septdir.com ; @copyright Copyright (c) 2018 - 2019 Septdir Workshop. All rights reserved. ; @license GNU/GPL license: https://www.gnu.org/copyleft/gpl.html @@ -47,4 +47,8 @@ PLG_JLSITEMAP_SWJPROJECTS_PARAMS_VERSIONS = "Versions" PLG_JLSITEMAP_SWJPROJECTS_PARAMS_VERSION = "Version" PLG_JLSITEMAP_SWJPROJECTS_PARAMS_ENABLE = "Enable" PLG_JLSITEMAP_SWJPROJECTS_PARAMS_CHANGEFREQ = "Change Frequency" -PLG_JLSITEMAP_SWJPROJECTS_PARAMS_PRIORITY = "Priority" \ No newline at end of file +PLG_JLSITEMAP_SWJPROJECTS_PARAMS_PRIORITY = "Priority" + +PLG_JLSITEMAP_SWJPROJECTS_DONATE = "Donate" +PLG_JLSITEMAP_SWJPROJECTS_MESSAGE = "JLSitemap - SWJProjects is a free component and is being developed through voluntary donations.
The larger the amount collected, the faster we release updates." +PLG_JLSITEMAP_SWJPROJECTS_SUPPORT = "Support" \ No newline at end of file diff --git a/language/en-GB/plg_jlsitemap_swjprojects.sys.ini b/language/en-GB/plg_jlsitemap_swjprojects.sys.ini new file mode 100644 index 0000000..9db44e8 --- /dev/null +++ b/language/en-GB/plg_jlsitemap_swjprojects.sys.ini @@ -0,0 +1,12 @@ +PLG_SWJPROJECTS = "JLSitemap - SW JProjects" +PLG_SWJPROJECTS_DESC = "Plugin provider of the SW JProjects component data for the JL Sitemap static XML site map component" +PLG_SWJPROJECTS_AFTER_INSTALL = "Thank you for installing the extension" +PLG_SWJPROJECTS_AFTER_DISCOVER_INSTALL = "Thank you for installing the extension" +PLG_SWJPROJECTS_AFTER_UPDATE = "Thank you for updating the extension" +PLG_SWJPROJECTS_AFTER_UNINSTALL = "So sorry..." +PLG_SWJPROJECTS_MAYBE_INTERESTING="

It may be interesting

" +PLG_SWJPROJECTS_WHATS_NEW="

v.2.0.0 What's new?

Joomla 5

The plugin has been rewritten according to the architecture of Joomla 5 extensions. This means that it will work seamlessly in Joomla 6 as well.

Visible projects

Added support for visible projects. Hidden projects are no longer included in the site map.

SW JProjects 2.0.0

Support for SW Projects 2.0.0. The plugin will not work with earlier versions of the component.

Download

Download SW JProjects

" +PLG_SWJPROJECTS_JOOMLARU_TELEGRAM_CHAT = "Joomla community in Telegram" +PLG_SWJPROJECTS_WEBTOLK_TELEGRAM_CHANNEL = "@WebTolkRu in Telegram" +PLG_SWJPROJECTS_ERROR_COMPATIBLE_PHP = "This version is compatible only with PHP %s and later" +PLG_SWJPROJECTS_ERROR_COMPATIBLE_JOOMLA = "This version is compatible only with Joomla %s and later" \ No newline at end of file diff --git a/language/ru-RU/ru-RU.plg_jlsitemap_swjprojects.ini b/language/ru-RU/plg_jlsitemap_swjprojects.ini similarity index 87% rename from language/ru-RU/ru-RU.plg_jlsitemap_swjprojects.ini rename to language/ru-RU/plg_jlsitemap_swjprojects.ini index b31b91e..2fa1c3e 100644 --- a/language/ru-RU/ru-RU.plg_jlsitemap_swjprojects.ini +++ b/language/ru-RU/plg_jlsitemap_swjprojects.ini @@ -1,5 +1,5 @@ ; @package JLSitemap - SW JProjects Plugin -; @version __DEPLOY_VERSION__ +; @version 1.0.0 ; @author Septdir Workshop - www.septdir.com ; @copyright Copyright (c) 2018 - 2019 Septdir Workshop. All rights reserved. ; @license GNU/GPL license: https://www.gnu.org/copyleft/gpl.html @@ -47,4 +47,8 @@ PLG_JLSITEMAP_SWJPROJECTS_PARAMS_VERSIONS = "Версии" PLG_JLSITEMAP_SWJPROJECTS_PARAMS_VERSION = "Версия" PLG_JLSITEMAP_SWJPROJECTS_PARAMS_ENABLE = "Включить" PLG_JLSITEMAP_SWJPROJECTS_PARAMS_CHANGEFREQ = "Частота изменений" -PLG_JLSITEMAP_SWJPROJECTS_PARAMS_PRIORITY = "Приоритет" \ No newline at end of file +PLG_JLSITEMAP_SWJPROJECTS_PARAMS_PRIORITY = "Приоритет" + +PLG_JLSITEMAP_SWJPROJECTS_DONATE = "Поддержать" +PLG_JLSITEMAP_SWJPROJECTS_DONATE_MESSAGE = "JLSitemap - SW JProjects это бесплатный плагин и развивается за счет добровольных пожертвований.
Чем больше собираемая сумма, тем быстрее мы выпускаем обновления." +PLG_JLSITEMAP_SWJPROJECTS_SUPPORT = "Поджержка" \ No newline at end of file diff --git a/language/ru-RU/plg_jlsitemap_swjprojects.sys.ini b/language/ru-RU/plg_jlsitemap_swjprojects.sys.ini new file mode 100644 index 0000000..35cc71c --- /dev/null +++ b/language/ru-RU/plg_jlsitemap_swjprojects.sys.ini @@ -0,0 +1,12 @@ +PLG_SWJPROJECTS = "JLSitemap - SW JProjects" +PLG_SWJPROJECTS_DESC = "Плагин для интеграции JLSitemap и SWJProjects" +PLG_SWJPROJECTS_AFTER_INSTALL = "Спасибо за установку расширения" +PLG_SWJPROJECTS_AFTER_DISCOVER_INSTALL = "Спасибо за установку расширения" +PLG_SWJPROJECTS_AFTER_UPDATE = "Спасибо за обновление расширения" +PLG_SWJPROJECTS_AFTER_UNINSTALL = "Очень жаль..." +PLG_SWJPROJECTS_MAYBE_INTERESTING="

Может быть интересно

" +PLG_SWJPROJECTS_WHATS_NEW="

v.2.0.0 Что нового?

Joomla 5

Плагин переписан по архитектуре расширений Joomla 5. Это означает, что он будет работать без проблем и в Joomla 6.

Скрытые проекты

Добавлена поддержка видимых проектов. Скрытые проекты теперь не попадают в карту сайта.

SW JProjects 2.0.0

Поддержка SW JProjects 2.0.0. С более ранними версиями компонента плагин работать не будет.

Скачать

Скачать SW JProjects

" +PLG_SWJPROJECTS_JOOMLARU_TELEGRAM_CHAT="Joomla сообщество в Телеграм" +PLG_SWJPROJECTS_WEBTOLK_TELEGRAM_CHANNEL = "@WebTolkRu в Telegram" +PLG_SWJPROJECTS_ERROR_COMPATIBLE_JOOMLA = "Эта версия совместима только с Joomla %s и выше." +PLG_SWJPROJECTS_ERROR_COMPATIBLE_PHP = "Эта версия совместима только с PHP %s и выше." \ No newline at end of file diff --git a/language/ru-RU/ru-RU.plg_jlsitemap_swjprojects.sys.ini b/language/ru-RU/ru-RU.plg_jlsitemap_swjprojects.sys.ini deleted file mode 100644 index fb3e406..0000000 --- a/language/ru-RU/ru-RU.plg_jlsitemap_swjprojects.sys.ini +++ /dev/null @@ -1,18 +0,0 @@ -; @package JLSitemap - SW JProjects Plugin -; @version __DEPLOY_VERSION__ -; @author Septdir Workshop - www.septdir.com -; @copyright Copyright (c) 2018 - 2019 Septdir Workshop. All rights reserved. -; @license GNU/GPL license: https://www.gnu.org/copyleft/gpl.html -; @link https://www.septdir.com/ -; Note : All ini files need to be saved as UTF-8 - -PLG_JLSITEMAP_SWJPROJECTS = "JLSitemap - SW JProjects" -PLG_JLSITEMAP_SWJPROJECTS_DESCRIPTION = "Плагин для интеграции JLSitemap и SWJProjects" - -PLG_JLSITEMAP_SWJPROJECTS_ERROR_COMPATIBLE_PHP = "Данная версия совместима только с PHP %s и более поздними версиями" -PLG_JLSITEMAP_SWJPROJECTS_ERROR_COMPATIBLE_JOOMLA = "Данная версия совместима только с Joomla %s и более поздними версиями" - -PLG_JLSITEMAP_SWJPROJECTS_SUPPORT = "Поджержка" - -PLG_JLSITEMAP_SWJPROJECTS_DONATE = "Поддержать" -PLG_JLSITEMAP_SWJPROJECTS_DONATE_MESSAGE = "JLSitemap - SW JProjects это бесплатное расширение и развивается за счет добровольных пожертвований.
Чем больше собираемая сумма, тем быстрее мы выпускаем обновления." \ No newline at end of file diff --git a/script.php b/script.php index 67e2a05..8882bc0 100644 --- a/script.php +++ b/script.php @@ -1,147 +1,239 @@ checkCompatible()) return false; - - return true; - } - - - /** - * Method to check compatible. - * - * @throws Exception - * - * @return boolean True on success, false on failure. - * - * @since 1.0.0 - */ - protected function checkCompatible() - { - // Check old joomla - if (!class_exists('Joomla\CMS\Version')) - { - JFactory::getApplication()->enqueueMessage(JText::sprintf('PLG_JLSITEMAP_SWJPROJECTS_ERROR_COMPATIBLE_JOOMLA', - $this->minimumJoomla), 'error'); - - return false; - } - - $app = Factory::getApplication(); - $jversion = new Version(); - - // Check php - if (!(version_compare(PHP_VERSION, $this->minimumPhp) >= 0)) - { - $app->enqueueMessage(Text::sprintf('PLG_JLSITEMAP_SWJPROJECTS_ERROR_COMPATIBLE_PHP', $this->minimumPhp), - 'error'); - - return false; - } - - // Check joomla version - if (!$jversion->isCompatible($this->minimumJoomla)) - { - $app->enqueueMessage(Text::sprintf('PLG_JLSITEMAP_SWJPROJECTS_ERROR_COMPATIBLE_JOOMLA', $this->minimumJoomla), - 'error'); - - return false; - } - - return true; - } - - /** - * Runs right after any installation action. - * - * @param string $type Type of PostFlight action. Possible values are: - * @param InstallerAdapter $parent Parent object calling object. - * - * @throws Exception - * - * @since 1.0.0 - */ - function postflight($type, $parent) - { - // Enable plugin - if ($type == 'install') - { - $this->enablePlugin($parent); - } - - // Add donate message - $message = new FileLayout('donate_message'); - $message->addIncludePath(__DIR__); - Factory::getApplication()->enqueueMessage($message->render(), ''); - } +\defined('_JEXEC') or die; - /** - * Enable plugin after installation - * - * @param InstallerAdapter $parent Parent object calling object. - * - * @since 1.0.0 - */ - protected function enablePlugin($parent) +return new class () implements ServiceProviderInterface { + public function register(Container $container) { - // Prepare plugin object - $plugin = new stdClass(); - $plugin->type = 'plugin'; - $plugin->element = $parent->getElement(); - $plugin->folder = (string) $parent->getParent()->manifest->attributes()['group']; - $plugin->enabled = 1; - - // Update record - Factory::getDbo()->updateObject('#__extensions', $plugin, array('type', 'element', 'folder')); + $container->set(InstallerScriptInterface::class, new class ($container->get(AdministratorApplication::class)) implements InstallerScriptInterface { + /** + * The application object + * + * @var AdministratorApplication + * + * @since 1.0.0 + */ + protected AdministratorApplication $app; + + /** + * The Database object. + * + * @var DatabaseDriver + * + * @since 1.0.0 + */ + protected DatabaseDriver $db; + + /** + * Minimum Joomla version required to install the extension. + * + * @var string + * + * @since 1.0.0 + */ + protected string $minimumJoomla = '4.0'; + + /** + * Minimum PHP version required to install the extension. + * + * @var string + * + * @since 1.0.0 + */ + protected string $minimumPhp = '7.4'; + + /** + * Constructor. + * + * @param AdministratorApplication $app The application object. + * + * @since 1.0.0 + */ + public function __construct(AdministratorApplication $app) + { + $this->app = $app; + $this->db = Factory::getContainer()->get('DatabaseDriver'); + } + + /** + * Function called after the extension is installed. + * + * @param InstallerAdapter $adapter The adapter calling this method + * + * @return boolean True on success + * + * @since 1.0.0 + */ + public function install(InstallerAdapter $adapter): bool + { + $this->enablePlugin($adapter); + + return true; + } + + /** + * Function called after the extension is updated. + * + * @param InstallerAdapter $adapter The adapter calling this method + * + * @return boolean True on success + * + * @since 1.0.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 1.0.0 + */ + public function uninstall(InstallerAdapter $adapter): bool + { + + 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 1.0.0 + */ + public function preflight(string $type, InstallerAdapter $adapter): bool + { + // Check compatible + if (!$this->checkCompatible('PLG_' . $adapter->getElement())) + { + return false; + } + + 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 1.0.0 + */ + public function postflight(string $type, InstallerAdapter $adapter): bool + { + $smile = ''; + + if ($type !== 'uninstall') + { + if ($type != 'uninstall') + { + $smiles = ['☺', '😀', '😉', '😍', '😎', '😊', '🙏']; + $smile_key = array_rand($smiles, 1); + $smile = $smiles[$smile_key]; + } + } + else + { + $smile = ':('; + } + + $element = 'PLG_' . strtoupper($adapter->getElement()); + $type = strtoupper($type); + + $html = ' +
+
+

' . $smile . ' ' . Text::_($element . '_AFTER_' . $type) . '
' . Text::_($element) . '

+ ' . Text::_($element . '_DESC'); + $html .= Text::_($element . '_WHATS_NEW'); + $html .= '
+ + '; + $this->app->enqueueMessage($html, 'info'); + + return true; + + } + + /** + * Method to check compatible. + * + * @return boolean True on success, False on failure. + * + * @throws Exception + * + * @since 1.0.0 + */ + protected function checkCompatible(string $element): bool + { + $element = strtoupper($element); + // Check joomla version + if (!(new Version)->isCompatible($this->minimumJoomla)) + { + $this->app->enqueueMessage( + Text::sprintf($element . '_ERROR_COMPATIBLE_JOOMLA', $this->minimumJoomla), + 'error' + ); + + return false; + } + + // Check PHP + if (!(version_compare(PHP_VERSION, $this->minimumPhp) >= 0)) + { + $this->app->enqueueMessage( + Text::sprintf($element . '_ERROR_COMPATIBLE_PHP', $this->minimumPhp), + 'error' + ); + + return false; + } + + return true; + } + }); } -} \ No newline at end of file +}; \ No newline at end of file diff --git a/services/provider.php b/services/provider.php new file mode 100644 index 0000000..1060d3d --- /dev/null +++ b/services/provider.php @@ -0,0 +1,45 @@ +set( + PluginInterface::class, + function (Container $container) { + $subject = $container->get(DispatcherInterface::class); + $config = (array) PluginHelper::getPlugin('jlsitemap', 'swjprojects'); + $plugin = new Swjprojects($subject, $config); + $plugin->setApplication(Factory::getApplication()); + $plugin->setDatabase(Factory::getContainer()->get(\Joomla\Database\DatabaseInterface::class)); + return $plugin; + } + ); + } +}; diff --git a/swjprojects.php b/src/Extension/Swjprojects.php similarity index 70% rename from swjprojects.php rename to src/Extension/Swjprojects.php index d05559f..9a96599 100644 --- a/swjprojects.php +++ b/src/Extension/Swjprojects.php @@ -1,28 +1,35 @@ translates = array( - 'current' => Factory::getLanguage()->getTag(), - 'default' => ComponentHelper::getParams('com_languages')->get('site', 'en-GB'), - 'all' => array_keys(LanguageHelper::getLanguages('lang_code')) - ); - - parent::__construct($subject, $config); + return [ + 'onGetUrls' => 'onGetUrls', + ]; } + /** * Method to get urls array. * - * @param array $urls Urls array. - * @param Registry $config Component config. * * @return array Urls array with attributes. * * @since 1.0.0 */ - public function onGetUrls(&$urls, $config) + public function onGetUrls(Event $event) { + /** + * @var array $urls Urls array. + * @var Registry $config Component config. + */ + [$urls, $config] = $event->getArguments(); + // Set translates + $this->translates = [ + 'current' => $this->getApplication()->getLanguage()->getTag(), + 'default' => ComponentHelper::getParams('com_languages')->get('site', 'en-GB'), + 'all' => \array_keys(LanguageHelper::getLanguages('lang_code')) + ]; + // Exclude judate & download views - $jupdate = new stdClass(); + $jupdate = new \stdClass(); $jupdate->type = Text::_('PLG_JLSITEMAP_SWJPROJECTS_TYPES_JUPDATE'); $jupdate->title = Text::_('PLG_JLSITEMAP_SWJPROJECTS_TYPES_JUPDATE'); $jupdate->loc = 'index.php?option=com_swjprojects&view=jupdate&key=1'; $jupdate->changefreq = 0; $jupdate->priority = 0; - $jupdate->exclude = array( - array( + $jupdate->exclude = [ + [ 'type' => Text::_('PLG_JLSITEMAP_SWJPROJECTS_EXCLUDE_JUPDATE'), 'msg' => Text::_('PLG_JLSITEMAP_SWJPROJECTS_EXCLUDE_JUPDATE_MSG'), - ) - ); + ] + ]; - $download = new stdClass(); + $download = new \stdClass(); $download->type = Text::_('PLG_JLSITEMAP_SWJPROJECTS_TYPES_DOWNLOAD'); $download->title = Text::_('PLG_JLSITEMAP_SWJPROJECTS_TYPES_DOWNLOAD'); $download->loc = 'index.php?option=com_swjprojects&view=download&key=1'; $download->changefreq = 0; $download->priority = 0; - $download->exclude = array( - array( + $download->exclude = [ + [ 'type' => Text::_('PLG_JLSITEMAP_SWJPROJECTS_EXCLUDE_DOWNLOAD'), 'msg' => Text::_('PLG_JLSITEMAP_SWJPROJECTS_EXCLUDE_DOWNLOAD_MSG'), - ) - ); + ] + ]; if ($config->get('multilanguage')) { @@ -124,7 +136,7 @@ public function onGetUrls(&$urls, $config) return $urls; } - $db = Factory::getDbo(); + $db = $this->getDatabase(); $multilanguage = $config->get('multilanguage'); $current = $this->translates['current']; $default = $this->translates['default']; @@ -134,20 +146,18 @@ public function onGetUrls(&$urls, $config) $all[$key] = $db->quote($code); } - // Load route helper - JLoader::register('SWJProjectsHelperRoute', JPATH_SITE . '/components/com_swjprojects/helpers/route.php'); // Add projects categories to sitemap if ($this->params->get('projects_enable')) { $query = $db->getQuery(true) - ->select(array('c.id', 'c.alias', 'c.state')) + ->select(['c.id', 'c.alias', 'c.state']) ->from($db->quoteName('#__swjprojects_categories', 'c')) ->where($db->quoteName('c.alias') . '!=' . $db->quote('root')) - ->group(array('c.id', 't_c.language')); + ->group(['c.id', 't_c.language']); // Join over translates - $query->select(array('t_c.title', 't_c.language', 't_c.metadata')); + $query->select(['t_c.title', 't_c.language', 't_c.metadata']); if ($multilanguage) { $query->leftJoin($db->quoteName('#__swjprojects_translate_categories', 't_c') @@ -160,7 +170,7 @@ public function onGetUrls(&$urls, $config) } // Join over default translates - $query->select(array('td_c.title as default_title')) + $query->select(['td_c.title as default_title']) ->leftJoin($db->quoteName('#__swjprojects_translate_categories', 'td_c') . ' ON td_c.id = c.id AND ' . $db->quoteName('td_c.language') . ' = ' . $db->quote($default)); @@ -179,45 +189,46 @@ public function onGetUrls(&$urls, $config) // Prepare loc attribute $slug = $row->id . ':' . $row->alias; - $loc = SWJProjectsHelperRoute::getProjectsRoute($slug); + $loc = RouteHelper::getProjectsRoute($slug); if ($multilanguage) { $loc .= '&lang=' . $row->language; } // Prepare exclude attribute - $metadata = new Registry($row->metadata); - $exclude = array(); - if (preg_match('/noindex/', $metadata->get('robots', $config->get('siteRobots')))) + $metadata = new Registry($row->metadata); + $exclude = []; + $siteRobots = $metadata->get('robots', $config->get('siteRobots')); + if (!empty($siteRobots) && \preg_match('/noindex/', $siteRobots)) { - $exclude[] = array('type' => Text::_('PLG_JLSITEMAP_SWJPROJECTS_EXCLUDE_CATEGORY'), - 'msg' => Text::_('PLG_JLSITEMAP_SWJPROJECTS_EXCLUDE_CATEGORY_ROBOTS')); + $exclude[] = ['type' => Text::_('PLG_JLSITEMAP_SWJPROJECTS_EXCLUDE_CATEGORY'), + 'msg' => Text::_('PLG_JLSITEMAP_SWJPROJECTS_EXCLUDE_CATEGORY_ROBOTS')]; } if ($row->state != 1) { - $exclude[] = array( + $exclude[] = [ 'type' => Text::_('PLG_JLSITEMAP_SWJPROJECTS_EXCLUDE_CATEGORY'), 'msg' => ($row->state == -1) ? Text::_('PLG_JLSITEMAP_SWJPROJECTS_EXCLUDE_CATEGORY_TRASH') : Text::_('PLG_JLSITEMAP_SWJPROJECTS_EXCLUDE_CATEGORY_UNPUBLISH') - ); + ]; } // Prepare category object - $category = new stdClass(); + $category = new \stdClass(); $category->type = Text::_('PLG_JLSITEMAP_SWJPROJECTS_TYPES_PROJECTS'); $category->title = $title; $category->loc = $loc; $category->changefreq = $changefreq; $category->priority = $priority; $category->exclude = (!empty($exclude)) ? $exclude : false; - $category->alternates = ($multilanguage) ? array() : false; + $category->alternates = ($multilanguage) ? [] : false; if ($category->alternates !== false) { foreach ($this->translates['all'] as $code) { - $category->alternates[$code] = SWJProjectsHelperRoute::getProjectsRoute($slug) . '&lang=' . $code; + $category->alternates[$code] = RouteHelper::getProjectsRoute($slug) . '&lang=' . $code; } } @@ -230,16 +241,17 @@ public function onGetUrls(&$urls, $config) if ($this->params->get('project_enable') || $this->params->get('versions_enable')) { $query = $db->getQuery(true) - ->select(array('p.id', 'p.alias', 'p.state')) + ->select(['p.id', 'p.alias', 'p.state']) ->from($db->quoteName('#__swjprojects_projects', 'p')) - ->group(array('p.id', 't_p.language')); + ->where($db->quoteName('p.visible'). ' = '. $db->quote('1')) + ->group(['p.id', 't_p.language']); // Join over categories - $query->select(array('c.id as category_id', 'c.alias as category_alias', 'c.state as category_state')) + $query->select(['c.id as category_id', 'c.alias as category_alias', 'c.state as category_state']) ->leftJoin($db->quoteName('#__swjprojects_categories', 'c') . ' ON c.id = p.catid'); // Join over translates - $query->select(array('t_p.title', 't_p.language', 't_p.metadata')); + $query->select(['t_p.title', 't_p.language', 't_p.metadata']); if ($multilanguage) { $query->leftJoin($db->quoteName('#__swjprojects_translate_projects', 't_p') @@ -252,7 +264,7 @@ public function onGetUrls(&$urls, $config) } // Join over default translates - $query->select(array('td_p.title as default_title')) + $query->select(['td_p.title as default_title']) ->leftJoin($db->quoteName('#__swjprojects_translate_projects', 'td_p') . ' ON td_p.id = p.id AND ' . $db->quoteName('td_p.language') . ' = ' . $db->quote($default)); @@ -274,8 +286,8 @@ public function onGetUrls(&$urls, $config) // Prepare loc attribute $slug = $row->id . ':' . $row->alias; $catslug = $row->category_id . ':' . $row->category_alias; - $loc = SWJProjectsHelperRoute::getProjectRoute($slug, $catslug); - $versionsLoc = SWJProjectsHelperRoute::getVersionsRoute($slug, $catslug); + $loc = RouteHelper::getProjectRoute($slug, $catslug); + $versionsLoc = RouteHelper::getVersionsRoute($slug, $catslug); if ($multilanguage) { $loc .= '&lang=' . $row->language; @@ -284,81 +296,82 @@ public function onGetUrls(&$urls, $config) // Prepare exclude attribute $metadata = new Registry($row->metadata); - $projectExclude = array(); - $versionsExclude = array(); - if (preg_match('/noindex/', $metadata->get('robots', $config->get('siteRobots')))) + $projectExclude = []; + $versionsExclude = []; + $siteRobots = $metadata->get('robots', $config->get('siteRobots')); + if (!empty($siteRobots) && \preg_match('/noindex/', $siteRobots)) { - $projectExclude[] = array('type' => Text::_('PLG_JLSITEMAP_SWJPROJECTS_EXCLUDE_PROJECT'), - 'msg' => Text::_('PLG_JLSITEMAP_SWJPROJECTS_EXCLUDE_PROJECT_ROBOTS')); + $projectExclude[] = ['type' => Text::_('PLG_JLSITEMAP_SWJPROJECTS_EXCLUDE_PROJECT'), + 'msg' => Text::_('PLG_JLSITEMAP_SWJPROJECTS_EXCLUDE_PROJECT_ROBOTS')]; } - if (preg_match('/noindex/', $metadata->get('versions_robots', $config->get('siteRobots')))) + if (!empty($siteRobots) && \preg_match('/noindex/', $siteRobots)) { - $versionsExclude[] = array('type' => Text::_('PLG_JLSITEMAP_SWJPROJECTS_EXCLUDE_VERSIONS'), - 'msg' => Text::_('PLG_JLSITEMAP_SWJPROJECTS_EXCLUDE_VERSIONS_ROBOTS')); + $versionsExclude[] = ['type' => Text::_('PLG_JLSITEMAP_SWJPROJECTS_EXCLUDE_VERSIONS'), + 'msg' => Text::_('PLG_JLSITEMAP_SWJPROJECTS_EXCLUDE_VERSIONS_ROBOTS')]; } if ($row->state != 1) { - $projectExclude[] = array( + $projectExclude[] = [ 'type' => Text::_('PLG_JLSITEMAP_SWJPROJECTS_EXCLUDE_PROJECT'), 'msg' => ($row->state == -1) ? Text::_('PLG_JLSITEMAP_SWJPROJECTS_EXCLUDE_PROJECT_TRASH') : Text::_('PLG_JLSITEMAP_SWJPROJECTS_EXCLUDE_PROJECT_UNPUBLISH') - ); + ]; - $versionsExclude[] = array( + $versionsExclude[] = [ 'type' => Text::_('PLG_JLSITEMAP_SWJPROJECTS_EXCLUDE_PROJECT'), 'msg' => ($row->state == -1) ? Text::_('PLG_JLSITEMAP_SWJPROJECTS_EXCLUDE_PROJECT_TRASH') : Text::_('PLG_JLSITEMAP_SWJPROJECTS_EXCLUDE_PROJECT_UNPUBLISH') - ); + ]; } if ($row->category_state != 1) { - $projectExclude[] = array( + $projectExclude[] = [ 'type' => Text::_('PLG_JLSITEMAP_SWJPROJECTS_EXCLUDE_CATEGORY'), 'msg' => ($row->state == -1) ? Text::_('PLG_JLSITEMAP_SWJPROJECTS_EXCLUDE_CATEGORY_TRASH') : Text::_('PLG_JLSITEMAP_SWJPROJECTS_EXCLUDE_CATEGORY_UNPUBLISH') - ); + ]; - $versionsExclude[] = array( + $versionsExclude[] = [ 'type' => Text::_('PLG_JLSITEMAP_SWJPROJECTS_EXCLUDE_CATEGORY'), 'msg' => ($row->state == -1) ? Text::_('PLG_JLSITEMAP_SWJPROJECTS_EXCLUDE_CATEGORY_TRASH') : Text::_('PLG_JLSITEMAP_SWJPROJECTS_EXCLUDE_CATEGORY_UNPUBLISH') - ); + ]; } // Prepare project object - $project = new stdClass(); + $project = new \stdClass(); $project->type = Text::_('PLG_JLSITEMAP_SWJPROJECTS_TYPES_PROJECT'); $project->title = $title; $project->loc = $loc; $project->changefreq = $changefreq; $project->priority = $priority; $project->exclude = (!empty($projectExclude)) ? $projectExclude : false; - $project->alternates = ($multilanguage) ? array() : false; + $project->alternates = ($multilanguage) ? [] : false; // Prepare versions object - $versions = new stdClass(); + $versions = new \stdClass(); $versions->type = Text::_('PLG_JLSITEMAP_SWJPROJECTS_TYPES_VERSIONS'); $versions->title = Text::sprintf('PLG_JLSITEMAP_SWJPROJECTS_TYPES_VERSIONS_TITLE', $title); $versions->loc = $versionsLoc; $versions->changefreq = $versionsChangefreq; $versions->priority = $versionsPriority; $versions->exclude = (!empty($versionsExclude)) ? $versionsExclude : false; - $versions->alternates = ($multilanguage) ? array() : false; + $versions->alternates = ($multilanguage) ? [] : false; if ($project->alternates !== false) { foreach ($this->translates['all'] as $code) { - $project->alternates[$code] = SWJProjectsHelperRoute::getProjectRoute($slug, $catslug) + $project->alternates[$code] = RouteHelper::getProjectRoute($slug, $catslug) . '&lang=' . $code; - $versions->alternates[$code] = SWJProjectsHelperRoute::getVersionsRoute($slug, $catslug) + $versions->alternates[$code] = RouteHelper::getVersionsRoute($slug, $catslug) . '&lang=' . $code; } } @@ -381,20 +394,21 @@ public function onGetUrls(&$urls, $config) if ($this->params->get('version_enable')) { $query = $db->getQuery(true) - ->select(array('v.id', 'v.major', 'v.minor', 'v.micro', 'v.tag', 'v.stage', 'v.state')) + ->select(['v.id', 'v.major', 'v.minor', 'v.patch', 'v.hotfix', 'v.tag', 'v.stage', 'v.state']) ->from($db->quoteName('#__swjprojects_versions', 'v')) - ->group(array('v.id', 't_v.language')); + ->where($db->quoteName('p.visible'). ' = '. $db->quote('1')) + ->group(['v.id', 't_v.language']); // Join over projects - $query->select(array('p.id as project_id', 'p.alias as project_alias', 'p.state as project_state')) + $query->select(['p.id as project_id', 'p.alias as project_alias', 'p.state as project_state']) ->leftJoin($db->quoteName('#__swjprojects_projects', 'p') . ' ON p.id = v.project_id'); // Join over categories - $query->select(array('c.id as category_id', 'c.alias as category_alias', 'c.state as category_state')) + $query->select(['c.id as category_id', 'c.alias as category_alias', 'c.state as category_state']) ->leftJoin($db->quoteName('#__swjprojects_categories', 'c') . ' ON c.id = p.catid'); // Join over translates - $query->select(array('t_p.title as project_title', 't_v.language', 't_v.metadata')); + $query->select(['t_p.title as project_title', 't_v.language', 't_v.metadata']); if ($multilanguage) { $query->leftJoin($db->quoteName('#__swjprojects_translate_versions', 't_v') @@ -425,7 +439,14 @@ public function onGetUrls(&$urls, $config) { $projectTitle = $row->project_alias; } - $title = $projectTitle . ' ' . $row->major . '.' . $row->minor . '.' . $row->micro; + + $projectVersion = $row->major . '.' . $row->minor . '.' . $row->patch; + if (\property_exists($row, 'hotfix') && !empty($row->hotfix)) + { + $projectVersion .= '.' . $row->hotfix; + } + + $title = $projectTitle . ' ' . $projectVersion; if ($row->tag !== 'stable') { $title .= ' ' . Text::_('PLG_JLSITEMAP_SWJPROJECTS_TYPES_VERSION_TAG_' . $row->tag); @@ -438,50 +459,51 @@ public function onGetUrls(&$urls, $config) // Prepare loc attribute $pojectslug = $row->project_id . ':' . $row->project_alias; $catslug = $row->category_id . ':' . $row->category_alias; - $loc = SWJProjectsHelperRoute::getVersionRoute($row->id, $pojectslug, $catslug); + $loc = RouteHelper::getVersionRoute($row->id, $pojectslug, $catslug); if ($multilanguage) { $loc .= '&lang=' . $row->language; } // Prepare exclude attribute - $metadata = new Registry($row->metadata); - $exclude = array(); - if (preg_match('/noindex/', $metadata->get('robots', $config->get('siteRobots')))) + $metadata = new Registry($row->metadata); + $exclude = []; + $siteRobots = $metadata->get('robots', $config->get('siteRobots')); + if (!empty($siteRobots) && \preg_match('/noindex/', $siteRobots)) { - $exclude[] = array('type' => Text::_('PLG_JLSITEMAP_SWJPROJECTS_EXCLUDE_VERSION'), - 'msg' => Text::_('PLG_JLSITEMAP_SWJPROJECTS_EXCLUDE_VERSION_ROBOTS')); + $exclude[] = ['type' => Text::_('PLG_JLSITEMAP_SWJPROJECTS_EXCLUDE_VERSION'), + 'msg' => Text::_('PLG_JLSITEMAP_SWJPROJECTS_EXCLUDE_VERSION_ROBOTS')]; } if ($row->state != 1) { - $exclude[] = array( + $exclude[] = [ 'type' => Text::_('PLG_JLSITEMAP_SWJPROJECTS_EXCLUDE_VERSION'), 'msg' => ($row->state == -1) ? Text::_('PLG_JLSITEMAP_SWJPROJECTS_EXCLUDE_VERSION_TRASH') : Text::_('PLG_JLSITEMAP_SWJPROJECTS_EXCLUDE_VERSION_UNPUBLISH') - ); + ]; } if ($row->project_state != 1) { - $exclude[] = array( + $exclude[] = [ 'type' => Text::_('PLG_JLSITEMAP_SWJPROJECTS_EXCLUDE_PROJECT'), 'msg' => ($row->project_state == -1) ? Text::_('PLG_JLSITEMAP_SWJPROJECTS_EXCLUDE_PROJECT_TRASH') : Text::_('PLG_JLSITEMAP_SWJPROJECTS_EXCLUDE_PROJECT_UNPUBLISH') - ); + ]; } if ($row->category_state != 1) { - $exclude[] = array( + $exclude[] = [ 'type' => Text::_('PLG_JLSITEMAP_SWJPROJECTS_EXCLUDE_CATEGORY'), 'msg' => ($row->state == -1) ? Text::_('PLG_JLSITEMAP_SWJPROJECTS_EXCLUDE_CATEGORY_TRASH') : Text::_('PLG_JLSITEMAP_SWJPROJECTS_EXCLUDE_CATEGORY_UNPUBLISH') - ); + ]; } // Prepare project object - $version = new stdClass(); + $version = new \stdClass(); $version->type = Text::_('PLG_JLSITEMAP_SWJPROJECTS_TYPES_VERSION'); $version->title = $title; $version->loc = $loc; @@ -494,7 +516,7 @@ public function onGetUrls(&$urls, $config) { foreach ($this->translates['all'] as $code) { - $version->alternates[$code] = SWJProjectsHelperRoute::getVersionRoute($row->id, $pojectslug, $catslug) + $version->alternates[$code] = RouteHelper::getVersionRoute($row->id, $pojectslug, $catslug) . '&lang=' . $code; } } @@ -504,6 +526,7 @@ public function onGetUrls(&$urls, $config) } } - return $urls; + $event->setArgument(0, $urls); } + } \ No newline at end of file diff --git a/src/Fields/PlugininfoField.php b/src/Fields/PlugininfoField.php new file mode 100644 index 0000000..9214bdb --- /dev/null +++ b/src/Fields/PlugininfoField.php @@ -0,0 +1,96 @@ +form->getData(); + $element = $data->get('element'); + $folder = $data->get('folder'); + $wa = Factory::getApplication()->getDocument()->getWebAssetManager(); + $wa->addInlineStyle(" + .plugin-info-img-svg:hover * { + cursor:pointer; + } + "); + + $wt_plugin_info = simplexml_load_file(JPATH_SITE . "/plugins/" . $folder . "/" . $element . "/" . $element . ".xml"); + + + return $html = '
+ +
+ v.' . $wt_plugin_info->version . ' + ' . Text::_("PLG_".strtoupper($element)."_DESC") . ' +
+
'; + } + + /** + * @return string The field label markup. + * + * @since 1.7.0 + */ + protected function getLabel() + { + + return ''; + + } + + /** + * Method to get the field title. + * + * @return string The field title. + * + * @since 1.7.0 + */ + protected function getTitle() + { + return $this->getLabel(); + } + +} \ No newline at end of file diff --git a/swjprojects.xml b/swjprojects.xml index db5b95c..5d4aaf4 100644 --- a/swjprojects.xml +++ b/swjprojects.xml @@ -1,30 +1,35 @@ - + PLG_JLSITEMAP_SWJPROJECTS - Septdir Workshop - August 2019 - Copyright (c) 2018 - 2019 Septdir Workshop. All rights reserved. + Septdir Workshop, Sergey Tolkachyov + June 2024 + Copyright (c) 2018 - 2024 Septdir Workshop, Sergey Tolkachyov. All rights reserved. https://www.gnu.org/copyleft/gpl.html GNU/GPL - development@septdir.com - https://www.septdir.com/ - 1.0.1-dev - PLG_JLSITEMAP_SWJPROJECTS_DESCRIPTION + info@web-tolk.ru + https://web-tolk.ru + 2.0.0 + PLG_SWJPROJECTS_DESC + Joomla\Plugin\Jlsitemap\Swjprojects script.php - en-GB/en-GB.plg_jlsitemap_swjprojects.ini - en-GB/en-GB.plg_jlsitemap_swjprojects.sys.ini - ru-RU/ru-RU.plg_jlsitemap_swjprojects.ini - ru-RU/ru-RU.plg_jlsitemap_swjprojects.sys.ini + en-GB/plg_jlsitemap_swjprojects.ini + en-GB/plg_jlsitemap_swjprojects.sys.ini + ru-RU/plg_jlsitemap_swjprojects.ini + ru-RU/plg_jlsitemap_swjprojects.sys.ini - swjprojects.php - donate_message.php - toolbar.php + src + services + swjprojects.xml - + +
+ +
- - - https://www.septdir.com/solutions/joomla/update?element=plg_jlsitemap_swjprojects + + https://web-tolk.ru/component/swjprojects/jupdate?element=plg_jlsitemap_swjprojects + https://web-tolk.ru/jchangelog?element=plg_jlsitemap_swjprojects \ No newline at end of file diff --git a/toolbar.php b/toolbar.php deleted file mode 100644 index cee9b8f..0000000 --- a/toolbar.php +++ /dev/null @@ -1,72 +0,0 @@ -appendButton('Custom', $this->getButton($link, 'PLG_JLSITEMAP_SWJPROJECTS_SUPPORT', 'support'), - 'support'); - - // Add donate message - $message = new FileLayout('donate_message'); - $message->addIncludePath(__DIR__); - Factory::getApplication()->enqueueMessage($message->render(), ''); - - // Toolbar Style - Factory::getDocument()->addStyleDeclaration('#toolbar-support{float: right;}'); - } - - /** - * Method to get toolbar button markup. - * - * @param string $link Button link. - * @param string $text Button text. - * @param string $icon Button icon. - * - * @return string Buttons markup string. - * - * @since 1.0.0 - */ - protected function getButton($link = null, $text = null, $icon = null) - { - return '' - . '' - . Text::_($text) . ''; - } -} \ No newline at end of file