first commit
This commit is contained in:
286
plugins/jlsitemap/contact/contact.php
Normal file
286
plugins/jlsitemap/contact/contact.php
Normal file
@@ -0,0 +1,286 @@
|
||||
<?php
|
||||
/**
|
||||
* @package JLSitemap - Contact Plugin
|
||||
* @version 1.12.0
|
||||
* @author Joomline - joomline.ru
|
||||
* @copyright Copyright (c) 2010 - 2022 Joomline. All rights reserved.
|
||||
* @license GNU/GPL license: http://www.gnu.org/copyleft/gpl.html
|
||||
* @link https://joomline.ru/
|
||||
*/
|
||||
|
||||
defined('_JEXEC') or die;
|
||||
|
||||
use Joomla\CMS\Factory;
|
||||
use Joomla\CMS\Language\Text;
|
||||
use Joomla\CMS\Plugin\CMSPlugin;
|
||||
use Joomla\Registry\Registry;
|
||||
|
||||
class plgJLSitemapContact extends CMSPlugin
|
||||
{
|
||||
/**
|
||||
* Affects constructor behavior. If true, language files will be loaded automatically.
|
||||
*
|
||||
* @var boolean
|
||||
*
|
||||
* @since 1.3.0
|
||||
*/
|
||||
protected $autoloadLanguage = true;
|
||||
|
||||
/**
|
||||
* Method to get urls array
|
||||
*
|
||||
* @param array $urls Urls array
|
||||
* @param Registry $config Component config
|
||||
*
|
||||
* @return array Urls array with attributes
|
||||
*
|
||||
* @since 1.3.0
|
||||
*/
|
||||
public function onGetUrls(&$urls, $config)
|
||||
{
|
||||
$categoryExcludeStates = array(
|
||||
0 => Text::_('PLG_JLSITEMAP_CONTACT_EXCLUDE_CATEGORY_UNPUBLISH'),
|
||||
-2 => Text::_('PLG_JLSITEMAP_CONTACT_EXCLUDE_CATEGORY_TRASH'),
|
||||
2 => Text::_('PLG_JLSITEMAP_CONTACT_EXCLUDE_CATEGORY_ARCHIVE'));
|
||||
|
||||
$contactExcludeStates = array(
|
||||
0 => Text::_('PLG_JLSITEMAP_CONTACT_EXCLUDE_CONTACT_UNPUBLISH'),
|
||||
-2 => Text::_('PLG_JLSITEMAP_CONTACT_EXCLUDE_CONTACT_TRASH'),
|
||||
2 => Text::_('PLG_JLSITEMAP_CONTACT_EXCLUDE_CONTACT_ARCHIVE'));
|
||||
|
||||
$multilanguage = $config->get('multilanguage');
|
||||
|
||||
// Categories
|
||||
if ($this->params->get('categories_enable', false))
|
||||
{
|
||||
$db = Factory::getDbo();
|
||||
$query = $db->getQuery(true)
|
||||
->select(array('c.id', 'c.title', 'c.published', 'c.access', 'c.metadata', 'c.language', 'MAX(a.modified) as modified'))
|
||||
->from($db->quoteName('#__categories', 'c'))
|
||||
->join('LEFT', '#__contact_details AS a ON a.catid = c.id')
|
||||
->where($db->quoteName('c.extension') . ' = ' . $db->quote('com_contact'))
|
||||
->group('c.id')
|
||||
->order($db->escape('c.lft') . ' ' . $db->escape('asc'));
|
||||
|
||||
// Join over associations
|
||||
if ($multilanguage)
|
||||
{
|
||||
$query->select('assoc.key as association')
|
||||
->join('LEFT', '#__associations AS assoc ON assoc.id = c.id AND assoc.context = ' .
|
||||
$db->quote('com_categories.item'));
|
||||
}
|
||||
|
||||
$db->setQuery($query);
|
||||
$rows = $db->loadObjectList();
|
||||
|
||||
$nullDate = $db->getNullDate();
|
||||
$changefreq = $this->params->get('categories_changefreq', $config->get('changefreq', 'weekly'));
|
||||
$priority = $this->params->get('categories_priority', $config->get('priority', '0.5'));
|
||||
|
||||
// Add categories to arrays
|
||||
$categories = array();
|
||||
$alternates = array();
|
||||
foreach ($rows as $row)
|
||||
{
|
||||
// Prepare loc attribute
|
||||
$loc = 'index.php?option=com_contact&view=category&id=' . $row->id;
|
||||
if (!empty($row->language) && $row->language !== '*' && $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'))))
|
||||
{
|
||||
$exclude[] = array('type' => Text::_('PLG_JLSITEMAP_CONTACT_EXCLUDE_CATEGORY'),
|
||||
'msg' => Text::_('PLG_JLSITEMAP_CONTACT_EXCLUDE_CATEGORY_ROBOTS'));
|
||||
}
|
||||
|
||||
if (isset($categoryExcludeStates[$row->published]))
|
||||
{
|
||||
$exclude[] = array('type' => Text::_('PLG_JLSITEMAP_CONTACT_EXCLUDE_CATEGORY'),
|
||||
'msg' => $categoryExcludeStates[$row->published]);
|
||||
}
|
||||
|
||||
if (!in_array($row->access, $config->get('guestAccess', array())))
|
||||
{
|
||||
$exclude[] = array('type' => Text::_('PLG_JLSITEMAP_CONTACT_EXCLUDE_CATEGORY'),
|
||||
'msg' => Text::_('PLG_JLSITEMAP_CONTACT_EXCLUDE_CATEGORY_ACCESS'));
|
||||
}
|
||||
|
||||
// Prepare lastmod attribute
|
||||
$lastmod = (!empty($row->modified) && $row->modified != $nullDate) ? $row->modified : false;
|
||||
|
||||
// Prepare category object
|
||||
$category = new stdClass();
|
||||
$category->type = Text::_('PLG_JLSITEMAP_CONTACT_TYPES_CATEGORY');
|
||||
$category->title = $row->title;
|
||||
$category->loc = $loc;
|
||||
$category->changefreq = $changefreq;
|
||||
$category->priority = $priority;
|
||||
$category->lastmod = $lastmod;
|
||||
$category->exclude = (!empty($exclude)) ? $exclude : false;
|
||||
$category->alternates = ($multilanguage && !empty($row->association)) ? $row->association : false;
|
||||
|
||||
// Add category to array
|
||||
$categories[] = $category;
|
||||
|
||||
// Add category to alternates array
|
||||
if ($multilanguage && !empty($row->association) && empty($exclude))
|
||||
{
|
||||
if (!isset($alternates[$row->association]))
|
||||
{
|
||||
$alternates[$row->association] = array();
|
||||
}
|
||||
|
||||
$alternates[$row->association][$row->language] = $loc;
|
||||
};
|
||||
}
|
||||
|
||||
// Add alternates to categories
|
||||
if (!empty($alternates))
|
||||
{
|
||||
foreach ($categories as &$category)
|
||||
{
|
||||
$category->alternates = ($category->alternates) ? $alternates[$category->alternates] : false;
|
||||
}
|
||||
}
|
||||
|
||||
// Add categories to urls
|
||||
$urls = array_merge($urls, $categories);
|
||||
}
|
||||
|
||||
// Contacts
|
||||
if ($this->params->get('contacts_enable', false))
|
||||
{
|
||||
$db = Factory::getDbo();
|
||||
$query = $db->getQuery(true)
|
||||
->select(array('a.id', 'a.name', 'a.alias', 'a.published', 'a.modified', 'a.publish_up', 'a.publish_down', 'a.access',
|
||||
'a.metadata', 'a.language', 'c.id as category_id', 'c.published as category_published',
|
||||
'c.access as category_access'))
|
||||
->from($db->quoteName('#__contact_details', 'a'))
|
||||
->join('LEFT', '#__categories AS c ON c.id = a.catid')
|
||||
->group('a.id')
|
||||
->order($db->escape('a.ordering') . ' ' . $db->escape('asc'));
|
||||
|
||||
// Join over associations
|
||||
if ($multilanguage)
|
||||
{
|
||||
$query->select('assoc.key as association')
|
||||
->join('LEFT', '#__associations AS assoc ON assoc.id = a.id AND assoc.context = ' .
|
||||
$db->quote('com_contact.item'));
|
||||
}
|
||||
|
||||
$db->setQuery($query);
|
||||
$rows = $db->loadObjectList();
|
||||
|
||||
$nullDate = $db->getNullDate();
|
||||
$nowDate = Factory::getDate()->toUnix();
|
||||
$changefreq = $this->params->get('contacts_changefreq', $config->get('changefreq', 'weekly'));
|
||||
$priority = $this->params->get('contacts_priority', $config->get('priority', '0.5'));
|
||||
|
||||
// Add contacts to arrays
|
||||
$contacts = array();
|
||||
$alternates = array();
|
||||
foreach ($rows as $row)
|
||||
{
|
||||
// Prepare loc attribute
|
||||
$slug = ($row->alias) ? ($row->id . ':' . $row->alias) : $row->id;
|
||||
$loc = 'index.php?option=com_contact&view=contact&id=' . $slug . '&catid=' . $row->category_id;
|
||||
if (!empty($row->language) && $row->language !== '*' && $config->get('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'))))
|
||||
{
|
||||
$exclude[] = array('type' => Text::_('PLG_JLSITEMAP_CONTACT_EXCLUDE_CONTACT'),
|
||||
'msg' => Text::_('PLG_JLSITEMAP_CONTACT_EXCLUDE_CONTACT_ROBOTS'));
|
||||
}
|
||||
|
||||
if (isset($contactExcludeStates[$row->published]))
|
||||
{
|
||||
$exclude[] = array('type' => Text::_('PLG_JLSITEMAP_CONTACT_EXCLUDE_CONTACT'),
|
||||
'msg' => $contactExcludeStates[$row->published]);
|
||||
}
|
||||
|
||||
if ($row->publish_up != $nullDate && Factory::getDate($row->publish_up)->toUnix() > $nowDate)
|
||||
{
|
||||
$exclude[] = array('type' => Text::_('PLG_JLSITEMAP_CONTACT_EXCLUDE_CONTACT'),
|
||||
'msg' => Text::_('PLG_JLSITEMAP_CONTACT_EXCLUDE_CONTACT_PUBLISH_UP'));
|
||||
}
|
||||
|
||||
if ($row->publish_down != $nullDate && Factory::getDate($row->publish_down)->toUnix() < $nowDate)
|
||||
{
|
||||
$exclude[] = array('type' => Text::_('PLG_JLSITEMAP_CONTACT_EXCLUDE_CONTACT'),
|
||||
'msg' => Text::_('PLG_JLSITEMAP_CONTACT_EXCLUDE_CONTACT_PUBLISH_DOWN'));
|
||||
}
|
||||
|
||||
if (!in_array($row->access, $config->get('guestAccess', array())))
|
||||
{
|
||||
$exclude[] = array('type' => Text::_('PLG_JLSITEMAP_CONTACT_EXCLUDE_CONTACT'),
|
||||
'msg' => Text::_('PLG_JLSITEMAP_CONTACT_EXCLUDE_CONTACT_ACCESS'));
|
||||
}
|
||||
|
||||
if (isset($categoryExcludeStates[$row->category_published]))
|
||||
{
|
||||
$exclude[] = array('type' => Text::_('PLG_JLSITEMAP_CONTACT_EXCLUDE_CATEGORY'),
|
||||
'msg' => $categoryExcludeStates[$row->category_published]);
|
||||
}
|
||||
|
||||
if (!in_array($row->category_access, $config->get('guestAccess', array())))
|
||||
{
|
||||
$exclude[] = array('type' => Text::_('PLG_JLSITEMAP_CONTACT_EXCLUDE_CATEGORY'),
|
||||
'msg' => Text::_('PLG_JLSITEMAP_CONTACT_EXCLUDE_CATEGORY_ACCESS'));
|
||||
}
|
||||
|
||||
// Prepare lastmod attribute
|
||||
$lastmod = (!empty($row->modified) && $row->modified != $nullDate) ? $row->modified : false;
|
||||
|
||||
// Prepare contact object
|
||||
$contact = new stdClass();
|
||||
$contact->type = Text::_('PLG_JLSITEMAP_CONTACT_TYPES_CONTACT');
|
||||
$contact->title = $row->name;
|
||||
$contact->loc = $loc;
|
||||
$contact->changefreq = $changefreq;
|
||||
$contact->priority = $priority;
|
||||
$contact->lastmod = $lastmod;
|
||||
$contact->exclude = (!empty($exclude)) ? $exclude : false;
|
||||
$contact->alternates = ($multilanguage && !empty($row->association)) ? $row->association : false;
|
||||
|
||||
// Add contact to array
|
||||
$contacts[] = $contact;
|
||||
|
||||
// Add contact to alternates array
|
||||
if ($multilanguage && !empty($row->association) && empty($exclude))
|
||||
{
|
||||
if (!isset($alternates[$row->association]))
|
||||
{
|
||||
$alternates[$row->association] = array();
|
||||
}
|
||||
|
||||
$alternates[$row->association][$row->language] = $loc;
|
||||
};
|
||||
}
|
||||
|
||||
// Add alternates to contacts
|
||||
if (!empty($alternates))
|
||||
{
|
||||
foreach ($contacts as &$contact)
|
||||
{
|
||||
$contact->alternates = ($contact->alternates) ? $alternates[$contact->alternates] : false;
|
||||
}
|
||||
}
|
||||
|
||||
// Add contacts to urls
|
||||
$urls = array_merge($urls, $contacts);
|
||||
}
|
||||
|
||||
return $urls;
|
||||
}
|
||||
}
|
||||
95
plugins/jlsitemap/contact/contact.xml
Normal file
95
plugins/jlsitemap/contact/contact.xml
Normal file
@@ -0,0 +1,95 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<extension version="3.9" type="plugin" group="jlsitemap" method="upgrade">
|
||||
<name>PLG_JLSITEMAP_CONTACT</name>
|
||||
<author>Joomline</author>
|
||||
<creationDate>13.04.2022</creationDate>
|
||||
<copyright>Copyright (c) 2010 - 2022 Joomline. All rights reserved.</copyright>
|
||||
<license>http://www.gnu.org/copyleft/gpl.html GNU/GPL</license>
|
||||
<authorEmail>sale@joomline.ru</authorEmail>
|
||||
<authorUrl>https://joomline.ru</authorUrl>
|
||||
<version>1.12.0</version>
|
||||
<description>PLG_JLSITEMAP_CONTACT_DESCRIPTION</description>
|
||||
<languages folder="language">
|
||||
<language tag="en-GB">en-GB/en-GB.plg_jlsitemap_contact.ini</language>
|
||||
<language tag="en-GB">en-GB/en-GB.plg_jlsitemap_contact.sys.ini</language>
|
||||
<language tag="ru-RU">ru-RU/ru-RU.plg_jlsitemap_contact.ini</language>
|
||||
<language tag="ru-RU">ru-RU/ru-RU.plg_jlsitemap_contact.sys.ini</language>
|
||||
</languages>
|
||||
<files>
|
||||
<filename plugin="contact">contact.php</filename>
|
||||
</files>
|
||||
<config>
|
||||
<fields name="params">
|
||||
<fieldset name="contacts" label="PLG_JLSITEMAP_CONTACT_PARAMS_CONTACTS">
|
||||
<field name="contacts_enable" type="radio"
|
||||
label="PLG_JLSITEMAP_CONTACT_PARAMS_ENABLE"
|
||||
default="1"
|
||||
class="btn-group btn-group-yesno">
|
||||
<option value="0">JNO</option>
|
||||
<option value="1">JYES</option>
|
||||
</field>
|
||||
<field name="contacts_changefreq" type="list" default="weekly"
|
||||
label="PLG_JLSITEMAP_CONTACT_PARAMS_CHANGEFREQ"
|
||||
showon="contacts_enable:1">
|
||||
<option value="always">always</option>
|
||||
<option value="hourly">hourly</option>
|
||||
<option value="daily">daily</option>
|
||||
<option value="weekly">weekly</option>
|
||||
<option value="monthly">monthly</option>
|
||||
<option value="yearly">yearly</option>
|
||||
<option value="never">never</option>
|
||||
</field>
|
||||
<field name="contacts_priority" type="list"
|
||||
default="0.5" label="PLG_JLSITEMAP_CONTACT_PARAMS_PRIORITY"
|
||||
showon="contacts_enable:1">
|
||||
<option value="0.0">0.0</option>
|
||||
<option value="0.1">0.1</option>
|
||||
<option value="0.2">0.2</option>
|
||||
<option value="0.3">0.3</option>
|
||||
<option value="0.4">0.4</option>
|
||||
<option value="0.5">0.5</option>
|
||||
<option value="0.6">0.6</option>
|
||||
<option value="0.7">0.7</option>
|
||||
<option value="0.8">0.8</option>
|
||||
<option value="0.9">0.9</option>
|
||||
<option value="1">1</option>
|
||||
</field>
|
||||
</fieldset>
|
||||
<fieldset name="categories" label="PLG_JLSITEMAP_CONTACT_PARAMS_CATEGORIES">
|
||||
<field name="categories_enable" type="radio"
|
||||
label="PLG_JLSITEMAP_CONTACT_PARAMS_ENABLE"
|
||||
default="1"
|
||||
class="btn-group btn-group-yesno">
|
||||
<option value="0">JNO</option>
|
||||
<option value="1">JYES</option>
|
||||
</field>
|
||||
<field name="categories_changefreq" type="list" default="weekly"
|
||||
label="PLG_JLSITEMAP_CONTACT_PARAMS_CHANGEFREQ"
|
||||
showon="categories_enable:1">
|
||||
<option value="always">always</option>
|
||||
<option value="hourly">hourly</option>
|
||||
<option value="daily">daily</option>
|
||||
<option value="weekly">weekly</option>
|
||||
<option value="monthly">monthly</option>
|
||||
<option value="yearly">yearly</option>
|
||||
<option value="never">never</option>
|
||||
</field>
|
||||
<field name="categories_priority" type="list"
|
||||
default="0.5" label="PLG_JLSITEMAP_CONTACT_PARAMS_PRIORITY"
|
||||
showon="categories_enable:1">
|
||||
<option value="0.0">0.0</option>
|
||||
<option value="0.1">0.1</option>
|
||||
<option value="0.2">0.2</option>
|
||||
<option value="0.3">0.3</option>
|
||||
<option value="0.4">0.4</option>
|
||||
<option value="0.5">0.5</option>
|
||||
<option value="0.6">0.6</option>
|
||||
<option value="0.7">0.7</option>
|
||||
<option value="0.8">0.8</option>
|
||||
<option value="0.9">0.9</option>
|
||||
<option value="1">1</option>
|
||||
</field>
|
||||
</fieldset>
|
||||
</fields>
|
||||
</config>
|
||||
</extension>
|
||||
309
plugins/jlsitemap/content/content.php
Normal file
309
plugins/jlsitemap/content/content.php
Normal file
@@ -0,0 +1,309 @@
|
||||
<?php
|
||||
/**
|
||||
* @package JLSitemap - Content Plugin
|
||||
* @version 1.12.0
|
||||
* @author Joomline - joomline.ru
|
||||
* @copyright Copyright (c) 2010 - 2022 Joomline. All rights reserved.
|
||||
* @license GNU/GPL license: http://www.gnu.org/copyleft/gpl.html
|
||||
* @link https://joomline.ru/
|
||||
*/
|
||||
|
||||
defined('_JEXEC') or die;
|
||||
|
||||
use Joomla\CMS\Factory;
|
||||
use Joomla\CMS\Language\Text;
|
||||
use Joomla\CMS\Plugin\CMSPlugin;
|
||||
use Joomla\Registry\Registry;
|
||||
use Joomla\CMS\Uri\Uri;
|
||||
|
||||
class plgJLSitemapContent extends CMSPlugin
|
||||
{
|
||||
/**
|
||||
* Affects constructor behavior. If true, language files will be loaded automatically.
|
||||
*
|
||||
* @var boolean
|
||||
*
|
||||
* @since 0.0.1
|
||||
*/
|
||||
protected $autoloadLanguage = true;
|
||||
|
||||
/**
|
||||
* Method to get urls array
|
||||
*
|
||||
* @param array $urls Urls array
|
||||
* @param Registry $config Component config
|
||||
*
|
||||
* @return array Urls array with attributes
|
||||
*
|
||||
* @since 0.0.1
|
||||
*/
|
||||
public function onGetUrls(&$urls, $config)
|
||||
{
|
||||
$categoryExcludeStates = array(
|
||||
0 => Text::_('PLG_JLSITEMAP_CONTENT_EXCLUDE_CATEGORY_UNPUBLISH'),
|
||||
-2 => Text::_('PLG_JLSITEMAP_CONTENT_EXCLUDE_CATEGORY_TRASH'),
|
||||
2 => Text::_('PLG_JLSITEMAP_CONTENT_EXCLUDE_CATEGORY_ARCHIVE'));
|
||||
|
||||
$articleExcludeStates = array(
|
||||
0 => Text::_('PLG_JLSITEMAP_CONTENT_EXCLUDE_ARTICLE_UNPUBLISH'),
|
||||
-2 => Text::_('PLG_JLSITEMAP_CONTENT_EXCLUDE_ARTICLE_TRASH'),
|
||||
2 => Text::_('PLG_JLSITEMAP_CONTENT_EXCLUDE_ARTICLE_ARCHIVE'));
|
||||
|
||||
$multilanguage = $config->get('multilanguage');
|
||||
|
||||
// Categories
|
||||
if ($this->params->get('categories_enable', false))
|
||||
{
|
||||
$db = Factory::getDbo();
|
||||
$query = $db->getQuery(true)
|
||||
->select(array('c.id', 'c.title', 'c.published', 'c.access', 'c.metadata', 'c.language', 'MAX(a.modified) as modified', 'c.params'))
|
||||
->from($db->quoteName('#__categories', 'c'))
|
||||
->join('LEFT', '#__content AS a ON a.catid = c.id')
|
||||
->where($db->quoteName('c.extension') . ' = ' . $db->quote('com_content'))
|
||||
->group('c.id')
|
||||
->order($db->escape('c.lft') . ' ' . $db->escape('asc'));
|
||||
|
||||
// Join over associations
|
||||
if ($multilanguage)
|
||||
{
|
||||
$query->select('assoc.key as association')
|
||||
->join('LEFT', '#__associations AS assoc ON assoc.id = c.id AND assoc.context = ' .
|
||||
$db->quote('com_categories.item'));
|
||||
}
|
||||
|
||||
$db->setQuery($query);
|
||||
$rows = $db->loadObjectList();
|
||||
|
||||
$nullDate = $db->getNullDate();
|
||||
$changefreq = $this->params->get('categories_changefreq', $config->get('changefreq', 'weekly'));
|
||||
$priority = $this->params->get('categories_priority', $config->get('priority', '0.5'));
|
||||
|
||||
$categories_images_enable = $this->params->get('categories_images_enable', 1);
|
||||
|
||||
// Add categories to arrays
|
||||
$categories = array();
|
||||
$alternates = array();
|
||||
foreach ($rows as $row)
|
||||
{
|
||||
// Prepare loc attribute
|
||||
$loc = 'index.php?option=com_content&view=category&id=' . $row->id;
|
||||
if (!empty($row->language) && $row->language !== '*' && $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'))))
|
||||
{
|
||||
$exclude[] = array('type' => Text::_('PLG_JLSITEMAP_CONTENT_EXCLUDE_CATEGORY'),
|
||||
'msg' => Text::_('PLG_JLSITEMAP_CONTENT_EXCLUDE_CATEGORY_ROBOTS'));
|
||||
}
|
||||
|
||||
if (isset($categoryExcludeStates[$row->published]))
|
||||
{
|
||||
$exclude[] = array('type' => Text::_('PLG_JLSITEMAP_CONTENT_EXCLUDE_CATEGORY'),
|
||||
'msg' => $categoryExcludeStates[$row->published]);
|
||||
}
|
||||
|
||||
if (!in_array($row->access, $config->get('guestAccess', array())))
|
||||
{
|
||||
$exclude[] = array('type' => Text::_('PLG_JLSITEMAP_CONTENT_EXCLUDE_CATEGORY'),
|
||||
'msg' => Text::_('PLG_JLSITEMAP_CONTENT_EXCLUDE_CATEGORY_ACCESS'));
|
||||
}
|
||||
|
||||
// Prepare lastmod attribute
|
||||
$lastmod = (!empty($row->modified) && $row->modified != $nullDate) ? $row->modified : false;
|
||||
|
||||
// Prepare category object
|
||||
$category = new stdClass();
|
||||
$category->type = Text::_('PLG_JLSITEMAP_CONTENT_TYPES_CATEGORY');
|
||||
$category->title = $row->title;
|
||||
$category->loc = $loc;
|
||||
$category->changefreq = $changefreq;
|
||||
$category->priority = $priority;
|
||||
$category->lastmod = $lastmod;
|
||||
$category->exclude = (!empty($exclude)) ? $exclude : false;
|
||||
$category->alternates = ($multilanguage && !empty($row->association)) ? $row->association : false;
|
||||
|
||||
if ($categories_images_enable)
|
||||
{
|
||||
$category_params = json_decode($row->params);
|
||||
if (is_object($category_params) && !empty($category_params->image))
|
||||
{
|
||||
$category->images = array(Uri::root() . $category_params->image);
|
||||
}
|
||||
}
|
||||
|
||||
// Add category to array
|
||||
$categories[] = $category;
|
||||
|
||||
// Add category to alternates array
|
||||
if ($multilanguage && !empty($row->association) && empty($exclude))
|
||||
{
|
||||
if (!isset($alternates[$row->association]))
|
||||
{
|
||||
$alternates[$row->association] = array();
|
||||
}
|
||||
|
||||
$alternates[$row->association][$row->language] = $loc;
|
||||
};
|
||||
}
|
||||
|
||||
// Add alternates to categories
|
||||
if (!empty($alternates))
|
||||
{
|
||||
foreach ($categories as &$category)
|
||||
{
|
||||
$category->alternates = ($category->alternates) ? $alternates[$category->alternates] : false;
|
||||
}
|
||||
}
|
||||
|
||||
// Add categories to urls
|
||||
$urls = array_merge($urls, $categories);
|
||||
}
|
||||
|
||||
// Articles
|
||||
if ($this->params->get('articles_enable', false))
|
||||
{
|
||||
$db = Factory::getDbo();
|
||||
$query = $db->getQuery(true)
|
||||
->select(array('a.id', 'a.title', 'a.alias', 'a.state', 'a.modified', 'a.publish_up', 'a.publish_down', 'a.access',
|
||||
'a.metadata', 'a.language', 'c.id as category_id', 'c.published as category_published',
|
||||
'c.access as category_access', 'a.images'))
|
||||
->from($db->quoteName('#__content', 'a'))
|
||||
->join('LEFT', '#__categories AS c ON c.id = a.catid')
|
||||
->group('a.id')
|
||||
->order($db->escape('a.ordering') . ' ' . $db->escape('asc'));
|
||||
|
||||
// Join over associations
|
||||
if ($multilanguage)
|
||||
{
|
||||
$query->select('assoc.key as association')
|
||||
->join('LEFT', '#__associations AS assoc ON assoc.id = a.id AND assoc.context = ' .
|
||||
$db->quote('com_content.item'));
|
||||
}
|
||||
|
||||
$db->setQuery($query);
|
||||
$rows = $db->loadObjectList();
|
||||
|
||||
$nullDate = $db->getNullDate();
|
||||
$nowDate = Factory::getDate()->toUnix();
|
||||
$changefreq = $this->params->get('articles_changefreq', $config->get('changefreq', 'weekly'));
|
||||
$priority = $this->params->get('articles_priority', $config->get('priority', '0.5'));
|
||||
|
||||
$articles_images_enable = $this->params->get('articles_images_enable', 1);
|
||||
|
||||
// Add articles to urls arrays
|
||||
$articles = array();
|
||||
$alternates = array();
|
||||
foreach ($rows as $row)
|
||||
{
|
||||
// Prepare loc attribute
|
||||
$slug = ($row->alias) ? ($row->id . ':' . $row->alias) : $row->id;
|
||||
$loc = 'index.php?option=com_content&view=article&id=' . $slug . '&catid=' . $row->category_id;
|
||||
if (!empty($row->language) && $row->language !== '*' && $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'))))
|
||||
{
|
||||
$exclude[] = array('type' => Text::_('PLG_JLSITEMAP_CONTENT_EXCLUDE_ARTICLE'),
|
||||
'msg' => Text::_('PLG_JLSITEMAP_CONTENT_EXCLUDE_ARTICLE_ROBOTS'));
|
||||
}
|
||||
|
||||
if (isset($articleExcludeStates[$row->state]))
|
||||
{
|
||||
$exclude[] = array('type' => Text::_('PLG_JLSITEMAP_CONTENT_EXCLUDE_ARTICLE'),
|
||||
'msg' => $articleExcludeStates[$row->state]);
|
||||
}
|
||||
|
||||
if ($row->publish_up == $nullDate || Factory::getDate($row->publish_up)->toUnix() > $nowDate)
|
||||
{
|
||||
$exclude[] = array('type' => Text::_('PLG_JLSITEMAP_CONTENT_EXCLUDE_ARTICLE'),
|
||||
'msg' => Text::_('PLG_JLSITEMAP_CONTENT_EXCLUDE_ARTICLE_PUBLISH_UP'));
|
||||
}
|
||||
|
||||
if ($row->publish_down != $nullDate && Factory::getDate($row->publish_down)->toUnix() < $nowDate)
|
||||
{
|
||||
$exclude[] = array('type' => Text::_('PLG_JLSITEMAP_CONTENT_EXCLUDE_ARTICLE'),
|
||||
'msg' => Text::_('PLG_JLSITEMAP_CONTENT_EXCLUDE_ARTICLE_PUBLISH_DOWN'));
|
||||
}
|
||||
|
||||
if (!in_array($row->access, $config->get('guestAccess', array())))
|
||||
{
|
||||
$exclude[] = array('type' => Text::_('PLG_JLSITEMAP_CONTENT_EXCLUDE_ARTICLE'),
|
||||
'msg' => Text::_('PLG_JLSITEMAP_CONTENT_EXCLUDE_ARTICLE_ACCESS'));
|
||||
}
|
||||
|
||||
if (isset($categoryExcludeStates[$row->category_published]))
|
||||
{
|
||||
$exclude[] = array('type' => Text::_('PLG_JLSITEMAP_CONTENT_EXCLUDE_CATEGORY'),
|
||||
'msg' => $categoryExcludeStates[$row->category_published]);
|
||||
}
|
||||
|
||||
if (!in_array($row->category_access, $config->get('guestAccess', array())))
|
||||
{
|
||||
$exclude[] = array('type' => Text::_('PLG_JLSITEMAP_CONTENT_EXCLUDE_CATEGORY'),
|
||||
'msg' => Text::_('PLG_JLSITEMAP_CONTENT_EXCLUDE_CATEGORY_ACCESS'));
|
||||
}
|
||||
|
||||
// Prepare lastmod attribute
|
||||
$lastmod = (!empty($row->modified) && $row->modified != $nullDate) ? $row->modified : false;
|
||||
|
||||
// Prepare article object
|
||||
$article = new stdClass();
|
||||
$article->type = Text::_('PLG_JLSITEMAP_CONTENT_TYPES_ARTICLE');
|
||||
$article->title = $row->title;
|
||||
$article->loc = $loc;
|
||||
$article->changefreq = $changefreq;
|
||||
$article->priority = $priority;
|
||||
$article->lastmod = $lastmod;
|
||||
$article->exclude = (!empty($exclude)) ? $exclude : false;
|
||||
$article->alternates = ($multilanguage && !empty($row->association)) ? $row->association : false;
|
||||
|
||||
if ($articles_images_enable)
|
||||
{
|
||||
$article_images = json_decode($row->images);
|
||||
if (is_object($article_images) && !empty($article_images->image_fulltext))
|
||||
{
|
||||
$article->images = array(Uri::root() . $article_images->image_fulltext);
|
||||
}
|
||||
}
|
||||
|
||||
// Add article to array
|
||||
$articles[] = $article;
|
||||
|
||||
// Add article to alternates array
|
||||
if ($multilanguage && !empty($row->association) && empty($exclude))
|
||||
{
|
||||
if (!isset($alternates[$row->association]))
|
||||
{
|
||||
$alternates[$row->association] = array();
|
||||
}
|
||||
|
||||
$alternates[$row->association][$row->language] = $loc;
|
||||
};
|
||||
}
|
||||
|
||||
// Add alternates to articles
|
||||
if (!empty($alternates))
|
||||
{
|
||||
foreach ($articles as &$article)
|
||||
{
|
||||
$article->alternates = ($article->alternates) ? $alternates[$article->alternates] : false;
|
||||
}
|
||||
}
|
||||
|
||||
// Add articles to urls
|
||||
$urls = array_merge($urls, $articles);
|
||||
}
|
||||
|
||||
return $urls;
|
||||
}
|
||||
}
|
||||
109
plugins/jlsitemap/content/content.xml
Normal file
109
plugins/jlsitemap/content/content.xml
Normal file
@@ -0,0 +1,109 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<extension version="3.9" type="plugin" group="jlsitemap" method="upgrade">
|
||||
<name>PLG_JLSITEMAP_CONTENT</name>
|
||||
<author>Joomline</author>
|
||||
<creationDate>13.04.2022</creationDate>
|
||||
<copyright>Copyright (c) 2010 - 2022 Joomline. All rights reserved.</copyright>
|
||||
<license>http://www.gnu.org/copyleft/gpl.html GNU/GPL</license>
|
||||
<authorEmail>sale@joomline.ru</authorEmail>
|
||||
<authorUrl>https://joomline.ru/</authorUrl>
|
||||
<version>1.12.0</version>
|
||||
<description>PLG_JLSITEMAP_CONTENT_DESCRIPTION</description>
|
||||
<languages folder="language">
|
||||
<language tag="en-GB">en-GB/en-GB.plg_jlsitemap_content.ini</language>
|
||||
<language tag="en-GB">en-GB/en-GB.plg_jlsitemap_content.sys.ini</language>
|
||||
<language tag="ru-RU">ru-RU/ru-RU.plg_jlsitemap_content.ini</language>
|
||||
<language tag="ru-RU">ru-RU/ru-RU.plg_jlsitemap_content.sys.ini</language>
|
||||
</languages>
|
||||
<files>
|
||||
<filename plugin="content">content.php</filename>
|
||||
</files>
|
||||
<config>
|
||||
<fields name="params">
|
||||
<fieldset name="articles" label="PLG_JLSITEMAP_CONTENT_PARAMS_ARTICLES">
|
||||
<field name="articles_enable" type="radio"
|
||||
label="PLG_JLSITEMAP_CONTENT_PARAMS_ENABLE"
|
||||
default="1"
|
||||
class="btn-group btn-group-yesno">
|
||||
<option value="0">JNO</option>
|
||||
<option value="1">JYES</option>
|
||||
</field>
|
||||
<field name="articles_images_enable" type="radio"
|
||||
label="JGLOBAL_FIELDSET_IMAGE_OPTIONS"
|
||||
default="1"
|
||||
class="btn-group btn-group-yesno">
|
||||
<option value="0">JNO</option>
|
||||
<option value="1">JYES</option>
|
||||
</field>
|
||||
<field name="articles_changefreq" type="list" default="weekly"
|
||||
label="PLG_JLSITEMAP_CONTENT_PARAMS_CHANGEFREQ"
|
||||
showon="articles_enable:1">
|
||||
<option value="always">always</option>
|
||||
<option value="hourly">hourly</option>
|
||||
<option value="daily">daily</option>
|
||||
<option value="weekly">weekly</option>
|
||||
<option value="monthly">monthly</option>
|
||||
<option value="yearly">yearly</option>
|
||||
<option value="never">never</option>
|
||||
</field>
|
||||
<field name="articles_priority" type="list"
|
||||
default="0.5" label="PLG_JLSITEMAP_CONTENT_PARAMS_PRIORITY"
|
||||
showon="articles_enable:1">
|
||||
<option value="0.0">0.0</option>
|
||||
<option value="0.1">0.1</option>
|
||||
<option value="0.2">0.2</option>
|
||||
<option value="0.3">0.3</option>
|
||||
<option value="0.4">0.4</option>
|
||||
<option value="0.5">0.5</option>
|
||||
<option value="0.6">0.6</option>
|
||||
<option value="0.7">0.7</option>
|
||||
<option value="0.8">0.8</option>
|
||||
<option value="0.9">0.9</option>
|
||||
<option value="1">1</option>
|
||||
</field>
|
||||
</fieldset>
|
||||
<fieldset name="categories" label="PLG_JLSITEMAP_CONTENT_PARAMS_CATEGORIES">
|
||||
<field name="categories_enable" type="radio"
|
||||
label="PLG_JLSITEMAP_CONTENT_PARAMS_ENABLE"
|
||||
default="1"
|
||||
class="btn-group btn-group-yesno">
|
||||
<option value="0">JNO</option>
|
||||
<option value="1">JYES</option>
|
||||
</field>
|
||||
<field name="categories_images_enable" type="radio"
|
||||
label="JGLOBAL_FIELDSET_IMAGE_OPTIONS"
|
||||
default="1"
|
||||
class="btn-group btn-group-yesno">
|
||||
<option value="0">JNO</option>
|
||||
<option value="1">JYES</option>
|
||||
</field>
|
||||
<field name="categories_changefreq" type="list" default="weekly"
|
||||
label="PLG_JLSITEMAP_CONTENT_PARAMS_CHANGEFREQ"
|
||||
showon="categories_enable:1">
|
||||
<option value="always">always</option>
|
||||
<option value="hourly">hourly</option>
|
||||
<option value="daily">daily</option>
|
||||
<option value="weekly">weekly</option>
|
||||
<option value="monthly">monthly</option>
|
||||
<option value="yearly">yearly</option>
|
||||
<option value="never">never</option>
|
||||
</field>
|
||||
<field name="categories_priority" type="list"
|
||||
default="0.5" label="PLG_JLSITEMAP_CONTENT_PARAMS_PRIORITY"
|
||||
showon="categories_enable:1">
|
||||
<option value="0.0">0.0</option>
|
||||
<option value="0.1">0.1</option>
|
||||
<option value="0.2">0.2</option>
|
||||
<option value="0.3">0.3</option>
|
||||
<option value="0.4">0.4</option>
|
||||
<option value="0.5">0.5</option>
|
||||
<option value="0.6">0.6</option>
|
||||
<option value="0.7">0.7</option>
|
||||
<option value="0.8">0.8</option>
|
||||
<option value="0.9">0.9</option>
|
||||
<option value="1">1</option>
|
||||
</field>
|
||||
</fieldset>
|
||||
</fields>
|
||||
</config>
|
||||
</extension>
|
||||
341
plugins/jlsitemap/k2/k2.php
Normal file
341
plugins/jlsitemap/k2/k2.php
Normal file
@@ -0,0 +1,341 @@
|
||||
<?php
|
||||
/**
|
||||
* @package JLSitemap - K2 Plugin
|
||||
* @version 1.12.0
|
||||
* @author Joomline - joomline.ru
|
||||
* @copyright Copyright (c) 2010 - 2022 Joomline. All rights reserved.
|
||||
* @license GNU/GPL license: http://www.gnu.org/copyleft/gpl.html
|
||||
* @link https://joomline.ru/
|
||||
*/
|
||||
|
||||
defined('_JEXEC') or die;
|
||||
|
||||
use Joomla\CMS\Factory;
|
||||
use Joomla\CMS\Language\Text;
|
||||
use Joomla\CMS\Plugin\CMSPlugin;
|
||||
use Joomla\Registry\Registry;
|
||||
|
||||
class plgJLSitemapK2 extends CMSPlugin
|
||||
{
|
||||
/**
|
||||
* Affects constructor behavior. If true, language files will be loaded automatically.
|
||||
*
|
||||
* @var boolean
|
||||
*
|
||||
* @since 1.3.0
|
||||
*/
|
||||
protected $autoloadLanguage = true;
|
||||
|
||||
/**
|
||||
* Method to get urls array
|
||||
*
|
||||
* @param array $urls Urls array
|
||||
* @param Registry $config Component config
|
||||
*
|
||||
* @return array Urls array with attributes
|
||||
*
|
||||
* @since 1.3.0
|
||||
*/
|
||||
public function onGetUrls(&$urls, $config)
|
||||
{
|
||||
// Load K2HelperRoute
|
||||
if ($this->params->get('items_enable', false) ||
|
||||
$this->params->get('categories_enable', false) ||
|
||||
$this->params->get('tags_enable', false) ||
|
||||
$this->params->get('users_enable', false))
|
||||
{
|
||||
JLoader::register('K2HelperRoute', JPATH_SITE . '/components/com_k2/helpers/route.php');
|
||||
}
|
||||
|
||||
$multilanguage = $config->get('multilanguage');
|
||||
|
||||
// Items
|
||||
if ($this->params->get('items_enable', false))
|
||||
{
|
||||
$db = Factory::getDbo();
|
||||
$query = $db->getQuery(true)
|
||||
->select(array('i.id', 'i.title', 'i.alias', 'i.published', 'i.created', 'i.modified',
|
||||
'i.publish_up', 'i.publish_down', 'i.trash', 'i.access', 'i.params', 'i.metadata', 'i.language',
|
||||
'c.id as category_id', 'c.alias as category_alias', 'c.published as category_published',
|
||||
'c.access as category_access', 'c.trash as category_trash'))
|
||||
->from($db->quoteName('#__k2_items', 'i'))
|
||||
->join('LEFT', '#__k2_categories AS c ON c.id = i.catid')
|
||||
->group('i.id')
|
||||
->order($db->escape('i.ordering') . ' ' . $db->escape('asc'));
|
||||
|
||||
$db->setQuery($query);
|
||||
$rows = $db->loadObjectList();
|
||||
|
||||
$nullDate = $db->getNullDate();
|
||||
$nowDate = Factory::getDate()->toUnix();
|
||||
$changefreq = $this->params->get('items_changefreq', $config->get('changefreq', 'weekly'));
|
||||
$priority = $this->params->get('items_priority', $config->get('priority', '0.5'));
|
||||
|
||||
foreach ($rows as $row)
|
||||
{
|
||||
// Prepare loc attribute
|
||||
$loc = K2HelperRoute::getItemRoute($row->id . ':' . urlencode($row->alias),
|
||||
$row->category_id . ':' . urlencode($row->category_alias));
|
||||
if ($multilanguage && $row->language !== '*')
|
||||
{
|
||||
$loc .= '&lang=' . $row->language;
|
||||
}
|
||||
|
||||
// Prepare exclude attribute
|
||||
$exclude = array();
|
||||
if (preg_match('/noindex/', $row->metadata . ' ' . $config->get('siteRobots', '')))
|
||||
{
|
||||
$exclude[] = array('type' => Text::_('PLG_JLSITEMAP_K2_EXCLUDE_ITEM'),
|
||||
'msg' => Text::_('PLG_JLSITEMAP_K2_EXCLUDE_ITEM_ROBOTS'));
|
||||
}
|
||||
|
||||
if ($row->published == 0)
|
||||
{
|
||||
$exclude[] = array('type' => Text::_('PLG_JLSITEMAP_K2_EXCLUDE_ITEM'),
|
||||
'msg' => Text::_('PLG_JLSITEMAP_K2_EXCLUDE_ITEM_UNPUBLISH'));
|
||||
}
|
||||
|
||||
if ($row->trash)
|
||||
{
|
||||
$exclude[] = array('type' => Text::_('PLG_JLSITEMAP_K2_EXCLUDE_ITEM'),
|
||||
'msg' => Text::_('PLG_JLSITEMAP_K2_EXCLUDE_ITEM_TRASH'));
|
||||
}
|
||||
|
||||
if ($row->publish_up == $nullDate || Factory::getDate($row->publish_up)->toUnix() > $nowDate)
|
||||
{
|
||||
$exclude[] = array('type' => Text::_('PLG_JLSITEMAP_K2_EXCLUDE_ITEM'),
|
||||
'msg' => Text::_('PLG_JLSITEMAP_K2_EXCLUDE_ITEM_PUBLISH_UP'));
|
||||
}
|
||||
|
||||
if ($row->publish_down != $nullDate && Factory::getDate($row->publish_down)->toUnix() < $nowDate)
|
||||
{
|
||||
$exclude[] = array('type' => Text::_('PLG_JLSITEMAP_K2_EXCLUDE_ITEM'),
|
||||
'msg' => Text::_('PLG_JLSITEMAP_K2_EXCLUDE_ITEM_PUBLISH_DOWN'));
|
||||
}
|
||||
|
||||
if (!in_array($row->access, $config->get('guestAccess', array())))
|
||||
{
|
||||
$exclude[] = array('type' => Text::_('PLG_JLSITEMAP_K2_EXCLUDE_ITEM'),
|
||||
'msg' => Text::_('PLG_JLSITEMAP_K2_EXCLUDE_ITEM_ACCESS'));
|
||||
}
|
||||
|
||||
if ($row->category_published == 0)
|
||||
{
|
||||
$exclude[] = array('type' => Text::_('PLG_JLSITEMAP_K2_EXCLUDE_CATEGORY'),
|
||||
'msg' => Text::_('PLG_JLSITEMAP_K2_EXCLUDE_CATEGORY_UNPUBLISH'));
|
||||
}
|
||||
|
||||
if ($row->category_trash)
|
||||
{
|
||||
$exclude[] = array('type' => Text::_('PLG_JLSITEMAP_K2_EXCLUDE_CATEGORY'),
|
||||
'msg' => Text::_('PLG_JLSITEMAP_K2_EXCLUDE_CATEGORY_TRASH'));
|
||||
}
|
||||
|
||||
if (!in_array($row->category_access, $config->get('guestAccess', array())))
|
||||
{
|
||||
$exclude[] = array('type' => Text::_('PLG_JLSITEMAP_K2_EXCLUDE_CATEGORY'),
|
||||
'msg' => Text::_('PLG_JLSITEMAP_K2_EXCLUDE_CATEGORY_ACCESS'));
|
||||
}
|
||||
|
||||
// Prepare lastmod attribute
|
||||
$lastmod = (!empty($row->modified) && $row->modified != $nullDate &&
|
||||
Factory::getDate($row->modified)->toUnix() > Factory::getDate($row->created)->toUnix()) ?
|
||||
$row->modified : $row->created;
|
||||
|
||||
// Prepare item object
|
||||
$item = new stdClass();
|
||||
$item->type = Text::_('PLG_JLSITEMAP_K2_TYPES_ITEM');
|
||||
$item->title = $row->title;
|
||||
$item->loc = $loc;
|
||||
$item->changefreq = $changefreq;
|
||||
$item->priority = $priority;
|
||||
$item->lastmod = $lastmod;
|
||||
$item->exclude = (!empty($exclude)) ? $exclude : false;
|
||||
|
||||
// Add item to array
|
||||
$urls[] = $item;
|
||||
}
|
||||
}
|
||||
|
||||
// Categories
|
||||
if ($this->params->get('categories_enable', false))
|
||||
{
|
||||
$db = Factory::getDbo();
|
||||
$query = $db->getQuery(true)
|
||||
->select(array('c.id', 'c.name', 'c.alias', 'c.published', 'c.access', 'c.params', 'c.trash', 'c.language',
|
||||
'MAX(i.created) as created', 'MAX(i.modified) as modified'))
|
||||
->from($db->quoteName('#__k2_categories', 'c'))
|
||||
->join('LEFT', '#__k2_items AS i ON i.catid = c.id')
|
||||
->group('c.id')
|
||||
->order(array(
|
||||
$db->escape('c.parent') . ' ' . $db->escape('asc'),
|
||||
$db->escape('c.ordering') . ' ' . $db->escape('asc'),
|
||||
));
|
||||
|
||||
$db->setQuery($query);
|
||||
$rows = $db->loadObjectList();
|
||||
|
||||
$changefreq = $this->params->get('categories_changefreq', $config->get('changefreq', 'weekly'));
|
||||
$priority = $this->params->get('categories_priority', $config->get('priority', '0.5'));
|
||||
|
||||
foreach ($rows as $row)
|
||||
{
|
||||
// Prepare loc attribute
|
||||
$loc = K2HelperRoute::getCategoryRoute($row->id . ':' . urlencode($row->alias));
|
||||
if ($multilanguage && $row->language !== '*')
|
||||
{
|
||||
$loc .= '&lang=' . $row->language;
|
||||
}
|
||||
|
||||
// Prepare exclude attribute
|
||||
$exclude = array();
|
||||
$params = new Registry($row->params);
|
||||
if (preg_match('/noindex/', $params->get('catMetaRobots', $config->get('siteRobots'))))
|
||||
{
|
||||
$exclude[] = array('type' => Text::_('PLG_JLSITEMAP_K2_EXCLUDE_CATEGORY'),
|
||||
'msg' => Text::_('PLG_JLSITEMAP_K2_EXCLUDE_CATEGORY_ROBOTS'));
|
||||
}
|
||||
|
||||
if ($row->published == 0)
|
||||
{
|
||||
$exclude[] = array('type' => Text::_('PLG_JLSITEMAP_K2_EXCLUDE_CATEGORY'),
|
||||
'msg' => Text::_('PLG_JLSITEMAP_K2_EXCLUDE_CATEGORY_UNPUBLISH'));
|
||||
}
|
||||
|
||||
if ($row->trash)
|
||||
{
|
||||
$exclude[] = array('type' => Text::_('PLG_JLSITEMAP_K2_EXCLUDE_CATEGORY'),
|
||||
'msg' => Text::_('PLG_JLSITEMAP_K2_EXCLUDE_CATEGORY_TRASH'));
|
||||
}
|
||||
|
||||
if (!in_array($row->access, $config->get('guestAccess', array())))
|
||||
{
|
||||
$exclude[] = array('type' => Text::_('PLG_JLSITEMAP_K2_EXCLUDE_CATEGORY'),
|
||||
'msg' => Text::_('PLG_JLSITEMAP_K2_EXCLUDE_CATEGORY_ACCESS'));
|
||||
}
|
||||
|
||||
// Prepare lastmod attribute
|
||||
$lastmod = (Factory::getDate($row->modified)->toUnix() > Factory::getDate($row->created)->toUnix()) ?
|
||||
$row->modified : $row->created;
|
||||
|
||||
// Prepare category object
|
||||
$category = new stdClass();
|
||||
$category->type = Text::_('PLG_JLSITEMAP_K2_TYPES_CATEGORY');
|
||||
$category->title = $row->name;
|
||||
$category->loc = $loc;
|
||||
$category->changefreq = $changefreq;
|
||||
$category->priority = $priority;
|
||||
$category->lastmod = $lastmod;
|
||||
$category->exclude = (!empty($exclude)) ? $exclude : false;
|
||||
|
||||
// Add category to array
|
||||
$urls[] = $category;
|
||||
}
|
||||
}
|
||||
|
||||
// Tags
|
||||
if ($this->params->get('tags_enable', false))
|
||||
{
|
||||
$db = Factory::getDbo();
|
||||
$query = $db->getQuery(true)
|
||||
->select(array('t.id', 't.name', 't.published', 'MAX(i.created) as created', 'MAX(i.modified) as modified'))
|
||||
->from($db->quoteName('#__k2_tags', 't'))
|
||||
->join('LEFT', '#__k2_tags_xref AS xref ON xref.tagID = t.id')
|
||||
->join('LEFT', '#__k2_items AS i ON i.id = xref.itemID')
|
||||
->group('t.id')
|
||||
->order($db->escape('t.name') . ' ' . $db->escape('asc'));
|
||||
|
||||
$db->setQuery($query);
|
||||
$rows = $db->loadObjectList();
|
||||
|
||||
$nullDate = $db->getNullDate();
|
||||
$changefreq = $this->params->get('tags_changefreq', $config->get('changefreq', 'weekly'));
|
||||
$priority = $this->params->get('tags_priority', $config->get('priority', '0.5'));
|
||||
|
||||
foreach ($rows as $row)
|
||||
{
|
||||
// Prepare loc attribute
|
||||
$loc = K2HelperRoute::getTagRoute($row->name);
|
||||
|
||||
// Prepare exclude attribute
|
||||
$exclude = array();
|
||||
if ($row->published == 0)
|
||||
{
|
||||
$exclude[] = array('type' => Text::_('PLG_JLSITEMAP_K2_EXCLUDE_TAG'),
|
||||
'msg' => Text::_('PLG_JLSITEMAP_K2_EXCLUDE_TAG_UNPUBLISH'));
|
||||
}
|
||||
|
||||
// Prepare lastmod attribute
|
||||
$lastmod = (!empty($row->modified) && $row->modified != $nullDate &&
|
||||
Factory::getDate($row->modified)->toUnix() > Factory::getDate($row->created)->toUnix()) ?
|
||||
$row->modified : $row->created;
|
||||
|
||||
// Prepare tag object
|
||||
$tag = new stdClass();
|
||||
$tag->type = Text::_('PLG_JLSITEMAP_K2_TYPES_TAG');
|
||||
$tag->title = $row->name;
|
||||
$tag->loc = $loc;
|
||||
$tag->changefreq = $changefreq;
|
||||
$tag->priority = $priority;
|
||||
$tag->lastmod = $lastmod;
|
||||
$tag->exclude = (!empty($exclude)) ? $exclude : false;
|
||||
|
||||
// Add tag to array
|
||||
$urls[] = $tag;
|
||||
}
|
||||
}
|
||||
|
||||
// Users
|
||||
if ($this->params->get('users_enable', false))
|
||||
{
|
||||
$db = Factory::getDbo();
|
||||
$query = $db->getQuery(true)
|
||||
->select(array('u.id', 'u.name', 'u.block', 'MAX(i.created) as created', 'MAX(i.modified) as modified'))
|
||||
->from($db->quoteName('#__users', 'u'))
|
||||
->join('LEFT', '#__k2_items AS i ON i.created_by = u.id')
|
||||
->group('u.id')
|
||||
->order($db->escape('u.name') . ' ' . $db->escape('asc'));
|
||||
|
||||
$db->setQuery($query);
|
||||
$rows = $db->loadObjectList();
|
||||
|
||||
$nullDate = $db->getNullDate();
|
||||
$changefreq = $this->params->get('users_changefreq', $config->get('changefreq', 'weekly'));
|
||||
$priority = $this->params->get('users_priority', $config->get('priority', '0.5'));
|
||||
|
||||
foreach ($rows as $row)
|
||||
{
|
||||
// Prepare loc attribute
|
||||
$loc = K2HelperRoute::getUserRoute($row->id);
|
||||
|
||||
// Prepare exclude attribute
|
||||
$exclude = array();
|
||||
if ($row->block)
|
||||
{
|
||||
$exclude[] = array('type' => Text::_('PLG_JLSITEMAP_K2_EXCLUDE_USER'),
|
||||
'msg' => Text::_('PLG_JLSITEMAP_K2_EXCLUDE_USER_BLOCK'));
|
||||
}
|
||||
|
||||
// Prepare lastmod attribute
|
||||
$lastmod = (!empty($row->modified) && $row->modified != $nullDate &&
|
||||
Factory::getDate($row->modified)->toUnix() > Factory::getDate($row->created)->toUnix()) ?
|
||||
$row->modified : $row->created;
|
||||
|
||||
// Prepare user object
|
||||
$user = new stdClass();
|
||||
$user->type = Text::_('PLG_JLSITEMAP_K2_TYPES_USER');
|
||||
$user->title = $row->name;
|
||||
$user->loc = $loc;
|
||||
$user->changefreq = $changefreq;
|
||||
$user->priority = $priority;
|
||||
$user->lastmod = $lastmod;
|
||||
$user->exclude = (!empty($exclude)) ? $exclude : false;
|
||||
|
||||
// Add user to array
|
||||
$urls[] = $user;
|
||||
}
|
||||
}
|
||||
|
||||
return $urls;
|
||||
}
|
||||
}
|
||||
165
plugins/jlsitemap/k2/k2.xml
Normal file
165
plugins/jlsitemap/k2/k2.xml
Normal file
@@ -0,0 +1,165 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<extension version="3.9" type="plugin" group="jlsitemap" method="upgrade">
|
||||
<name>PLG_JLSITEMAP_K2</name>
|
||||
<author>Joomline</author>
|
||||
<creationDate>13.04.2022</creationDate>
|
||||
<copyright>Copyright (c) 2010 - 2022 Joomline. All rights reserved.</copyright>
|
||||
<license>http://www.gnu.org/copyleft/gpl.html GNU/GPL</license>
|
||||
<authorEmail>sale@joomline.ru</authorEmail>
|
||||
<authorUrl>https://joomline.ru/</authorUrl>
|
||||
<version>1.12.0</version>
|
||||
<description>PLG_JLSITEMAP_K2_DESCRIPTION</description>
|
||||
<languages folder="language">
|
||||
<language tag="en-GB">en-GB/en-GB.plg_jlsitemap_k2.ini</language>
|
||||
<language tag="en-GB">en-GB/en-GB.plg_jlsitemap_k2.sys.ini</language>
|
||||
<language tag="ru-RU">ru-RU/ru-RU.plg_jlsitemap_k2.ini</language>
|
||||
<language tag="ru-RU">ru-RU/ru-RU.plg_jlsitemap_k2.sys.ini</language>
|
||||
</languages>
|
||||
<files>
|
||||
<filename plugin="k2">k2.php</filename>
|
||||
</files>
|
||||
<config>
|
||||
<fields name="params">
|
||||
<fieldset name="items" label="PLG_JLSITEMAP_K2_PARAMS_ITEMS">
|
||||
<field name="items_enable" type="radio"
|
||||
label="PLG_JLSITEMAP_K2_PARAMS_ENABLE"
|
||||
default="1"
|
||||
class="btn-group btn-group-yesno">
|
||||
<option value="0">JNO</option>
|
||||
<option value="1">JYES</option>
|
||||
</field>
|
||||
<field name="items_changefreq" type="list" default="weekly"
|
||||
label="PLG_JLSITEMAP_K2_PARAMS_CHANGEFREQ"
|
||||
showon="items_enable:1">
|
||||
<option value="always">always</option>
|
||||
<option value="hourly">hourly</option>
|
||||
<option value="daily">daily</option>
|
||||
<option value="weekly">weekly</option>
|
||||
<option value="monthly">monthly</option>
|
||||
<option value="yearly">yearly</option>
|
||||
<option value="never">never</option>
|
||||
</field>
|
||||
<field name="items_priority" type="list"
|
||||
default="0.5" label="PLG_JLSITEMAP_K2_PARAMS_PRIORITY"
|
||||
showon="items_enable:1">
|
||||
<option value="0.0">0.0</option>
|
||||
<option value="0.1">0.1</option>
|
||||
<option value="0.2">0.2</option>
|
||||
<option value="0.3">0.3</option>
|
||||
<option value="0.4">0.4</option>
|
||||
<option value="0.5">0.5</option>
|
||||
<option value="0.6">0.6</option>
|
||||
<option value="0.7">0.7</option>
|
||||
<option value="0.8">0.8</option>
|
||||
<option value="0.9">0.9</option>
|
||||
<option value="1">1</option>
|
||||
</field>
|
||||
</fieldset>
|
||||
<fieldset name="categories" label="PLG_JLSITEMAP_K2_PARAMS_CATEGORIES">
|
||||
<field name="categories_enable" type="radio"
|
||||
label="PLG_JLSITEMAP_K2_PARAMS_ENABLE"
|
||||
default="1"
|
||||
class="btn-group btn-group-yesno">
|
||||
<option value="0">JNO</option>
|
||||
<option value="1">JYES</option>
|
||||
</field>
|
||||
<field name="categories_changefreq" type="list" default="weekly"
|
||||
label="PLG_JLSITEMAP_K2_PARAMS_CHANGEFREQ"
|
||||
showon="categories_enable:1">
|
||||
<option value="always">always</option>
|
||||
<option value="hourly">hourly</option>
|
||||
<option value="daily">daily</option>
|
||||
<option value="weekly">weekly</option>
|
||||
<option value="monthly">monthly</option>
|
||||
<option value="yearly">yearly</option>
|
||||
<option value="never">never</option>
|
||||
</field>
|
||||
<field name="categories_priority" type="list"
|
||||
default="0.5" label="PLG_JLSITEMAP_K2_PARAMS_PRIORITY"
|
||||
showon="categories_enable:1">
|
||||
<option value="0.0">0.0</option>
|
||||
<option value="0.1">0.1</option>
|
||||
<option value="0.2">0.2</option>
|
||||
<option value="0.3">0.3</option>
|
||||
<option value="0.4">0.4</option>
|
||||
<option value="0.5">0.5</option>
|
||||
<option value="0.6">0.6</option>
|
||||
<option value="0.7">0.7</option>
|
||||
<option value="0.8">0.8</option>
|
||||
<option value="0.9">0.9</option>
|
||||
<option value="1">1</option>
|
||||
</field>
|
||||
</fieldset>
|
||||
<fieldset name="tags" label="PLG_JLSITEMAP_K2_PARAMS_TAGS">
|
||||
<field name="tags_enable" type="radio"
|
||||
label="PLG_JLSITEMAP_K2_PARAMS_ENABLE"
|
||||
default="1"
|
||||
class="btn-group btn-group-yesno">
|
||||
<option value="0">JNO</option>
|
||||
<option value="1">JYES</option>
|
||||
</field>
|
||||
<field name="tags_changefreq" type="list" default="weekly"
|
||||
label="PLG_JLSITEMAP_K2_PARAMS_CHANGEFREQ"
|
||||
showon="tags_enable:1">
|
||||
<option value="always">always</option>
|
||||
<option value="hourly">hourly</option>
|
||||
<option value="daily">daily</option>
|
||||
<option value="weekly">weekly</option>
|
||||
<option value="monthly">monthly</option>
|
||||
<option value="yearly">yearly</option>
|
||||
<option value="never">never</option>
|
||||
</field>
|
||||
<field name="tags_priority" type="list"
|
||||
default="0.5" label="PLG_JLSITEMAP_K2_PARAMS_PRIORITY"
|
||||
showon="tags_enable:1">
|
||||
<option value="0.0">0.0</option>
|
||||
<option value="0.1">0.1</option>
|
||||
<option value="0.2">0.2</option>
|
||||
<option value="0.3">0.3</option>
|
||||
<option value="0.4">0.4</option>
|
||||
<option value="0.5">0.5</option>
|
||||
<option value="0.6">0.6</option>
|
||||
<option value="0.7">0.7</option>
|
||||
<option value="0.8">0.8</option>
|
||||
<option value="0.9">0.9</option>
|
||||
<option value="1">1</option>
|
||||
</field>
|
||||
</fieldset>
|
||||
<fieldset name="users" label="PLG_JLSITEMAP_K2_PARAMS_USERS">
|
||||
<field name="users_enable" type="radio"
|
||||
label="PLG_JLSITEMAP_K2_PARAMS_ENABLE"
|
||||
default="1"
|
||||
class="btn-group btn-group-yesno">
|
||||
<option value="0">JNO</option>
|
||||
<option value="1">JYES</option>
|
||||
</field>
|
||||
<field name="users_changefreq" type="list" default="weekly"
|
||||
label="PLG_JLSITEMAP_K2_PARAMS_CHANGEFREQ"
|
||||
showon="users_enable:1">
|
||||
<option value="always">always</option>
|
||||
<option value="hourly">hourly</option>
|
||||
<option value="daily">daily</option>
|
||||
<option value="weekly">weekly</option>
|
||||
<option value="monthly">monthly</option>
|
||||
<option value="yearly">yearly</option>
|
||||
<option value="never">never</option>
|
||||
</field>
|
||||
<field name="users_priority" type="list"
|
||||
default="0.5" label="PLG_JLSITEMAP_K2_PARAMS_PRIORITY"
|
||||
showon="users_enable:1">
|
||||
<option value="0.0">0.0</option>
|
||||
<option value="0.1">0.1</option>
|
||||
<option value="0.2">0.2</option>
|
||||
<option value="0.3">0.3</option>
|
||||
<option value="0.4">0.4</option>
|
||||
<option value="0.5">0.5</option>
|
||||
<option value="0.6">0.6</option>
|
||||
<option value="0.7">0.7</option>
|
||||
<option value="0.8">0.8</option>
|
||||
<option value="0.9">0.9</option>
|
||||
<option value="1">1</option>
|
||||
</field>
|
||||
</fieldset>
|
||||
</fields>
|
||||
</config>
|
||||
</extension>
|
||||
201
plugins/jlsitemap/kunena/kunena.php
Normal file
201
plugins/jlsitemap/kunena/kunena.php
Normal file
@@ -0,0 +1,201 @@
|
||||
<?php
|
||||
/**
|
||||
* @package JLSitemap - Kunena Plugin
|
||||
* @version 1.12.0
|
||||
* @author Joomline - joomline.ru
|
||||
* @copyright Copyright (c) 2010 - 2022 Joomline. All rights reserved.
|
||||
* @license GNU/GPL license: http://www.gnu.org/copyleft/gpl.html
|
||||
* @link https://joomline.ru/
|
||||
*/
|
||||
|
||||
defined('_JEXEC') or die;
|
||||
|
||||
use Joomla\CMS\Factory;
|
||||
use Joomla\CMS\Language\Text;
|
||||
use Joomla\CMS\Plugin\CMSPlugin;
|
||||
use Joomla\Registry\Registry;
|
||||
|
||||
class plgJLSitemapKunena extends CMSPlugin
|
||||
{
|
||||
/**
|
||||
* Affects constructor behavior. If true, language files will be loaded automatically.
|
||||
*
|
||||
* @var boolean
|
||||
*
|
||||
* @since 1.4.0
|
||||
*/
|
||||
protected $autoloadLanguage = true;
|
||||
|
||||
/**
|
||||
* Method to get urls array
|
||||
*
|
||||
* @param array $urls Urls array
|
||||
* @param Registry $config Component config
|
||||
*
|
||||
* @return array Urls array with attributes
|
||||
*
|
||||
* @since 1.4.0
|
||||
*/
|
||||
public function onGetUrls(&$urls, $config)
|
||||
{
|
||||
// Topics
|
||||
if ($this->params->get('topics_enable', false))
|
||||
{
|
||||
$db = Factory::getDbo();
|
||||
$query = $db->getQuery(true)
|
||||
->select(array('t.id', 't.subject', 't.last_post_time'))
|
||||
->from($db->quoteName('#__kunena_topics', 't'))
|
||||
->group('t.id')
|
||||
->order($db->escape('t.last_post_time') . ' ' . $db->escape('asc'));
|
||||
|
||||
$db->setQuery($query);
|
||||
$rows = $db->loadObjectList();
|
||||
|
||||
$changefreq = $this->params->get('topics_changefreq', $config->get('changefreq', 'weekly'));
|
||||
$priority = $this->params->get('topics_priority', $config->get('priority', '0.5'));
|
||||
|
||||
foreach ($rows as $row)
|
||||
{
|
||||
$guest = KunenaUserHelper::get(0);
|
||||
$object = KunenaForumTopicHelper::get($row->id);
|
||||
|
||||
// Prepare exclude attribute
|
||||
$exclude = array();
|
||||
if (!$object)
|
||||
{
|
||||
$exclude[] = array('type' => Text::_('PLG_JLSITEMAP_KUNENA_EXCLUDE_TOPIC'),
|
||||
'msg' => Text::_('PLG_JLSITEMAP_KUNENA_EXCLUDE_TOPIC_EXIST'));
|
||||
}
|
||||
|
||||
if ($object->getCategory()->tryAuthorise('read', $guest, false))
|
||||
{
|
||||
$exclude[] = array('type' => Text::_('PLG_JLSITEMAP_KUNENA_EXCLUDE_CATEGORY'),
|
||||
'msg' => Text::_('PLG_JLSITEMAP_KUNENA_EXCLUDE_CATEGORY_READ'));
|
||||
}
|
||||
|
||||
// Prepare loc attribute
|
||||
$loc = ($object) ? $object->getUri()->toString() : '';
|
||||
|
||||
// Prepare topic object
|
||||
$topic = new stdClass();
|
||||
$topic->type = Text::_('PLG_JLSITEMAP_KUNENA_TYPES_TOPIC');
|
||||
$topic->title = $row->subject;
|
||||
$topic->loc = $loc;
|
||||
$topic->changefreq = $changefreq;
|
||||
$topic->priority = $priority;
|
||||
$topic->lastmod = $row->last_post_time;
|
||||
$topic->exclude = (!empty($exclude)) ? $exclude : false;
|
||||
|
||||
// Add topic to array
|
||||
$urls[] = $topic;
|
||||
}
|
||||
}
|
||||
|
||||
// Categories
|
||||
if ($this->params->get('categories_enable', false))
|
||||
{
|
||||
$db = Factory::getDbo();
|
||||
$query = $db->getQuery(true)
|
||||
->select(array('c.id', 'c.name', 'c.last_post_time'))
|
||||
->from($db->quoteName('#__kunena_categories', 'c'))
|
||||
->group('c.id')
|
||||
->order($db->escape('c.ordering') . ' ' . $db->escape('asc'));
|
||||
|
||||
$db->setQuery($query);
|
||||
$rows = $db->loadObjectList();
|
||||
|
||||
$changefreq = $this->params->get('categories_changefreq', $config->get('changefreq', 'weekly'));
|
||||
$priority = $this->params->get('categories_priority', $config->get('priority', '0.5'));
|
||||
|
||||
foreach ($rows as $row)
|
||||
{
|
||||
$guest = KunenaUserHelper::get(0);
|
||||
$object = KunenaForumCategoryHelper::get($row->id);
|
||||
|
||||
// Prepare exclude attribute
|
||||
$exclude = array();
|
||||
if (!$object)
|
||||
{
|
||||
$exclude[] = array('type' => Text::_('PLG_JLSITEMAP_KUNENA_EXCLUDE_CATEGORY'),
|
||||
'msg' => Text::_('PLG_JLSITEMAP_KUNENA_EXCLUDE_TOPIC_EXIST'));
|
||||
}
|
||||
|
||||
if ($object->tryAuthorise('read', $guest, false))
|
||||
{
|
||||
$exclude[] = array('type' => Text::_('PLG_JLSITEMAP_KUNENA_EXCLUDE_CATEGORY'),
|
||||
'msg' => Text::_('PLG_JLSITEMAP_KUNENA_EXCLUDE_CATEGORY_READ'));
|
||||
}
|
||||
|
||||
// Prepare loc attribute
|
||||
$loc = ($object) ? KunenaRoute::getCategoryUrl($object) : '';
|
||||
|
||||
// Prepare category object
|
||||
$category = new stdClass();
|
||||
$category->type = Text::_('PLG_JLSITEMAP_KUNENA_TYPES_CATEGORY');
|
||||
$category->title = $row->name;
|
||||
$category->loc = $loc;
|
||||
$category->changefreq = $changefreq;
|
||||
$category->priority = $priority;
|
||||
$category->lastmod = (!empty($row->last_post_time)) ? $row->last_post_time : false;
|
||||
$category->exclude = (!empty($exclude)) ? $exclude : false;
|
||||
|
||||
// Add category to array
|
||||
$urls[] = $category;
|
||||
}
|
||||
}
|
||||
|
||||
// Users
|
||||
if ($this->params->get('users_enable', false))
|
||||
{
|
||||
$db = Factory::getDbo();
|
||||
$query = $db->getQuery(true)
|
||||
->select(array('u.userid as id'))
|
||||
->from($db->quoteName('#__kunena_users', 'u'))
|
||||
->group('u.userid');
|
||||
|
||||
$db->setQuery($query);
|
||||
$rows = $db->loadObjectList();
|
||||
|
||||
$changefreq = $this->params->get('users_changefreq', $config->get('changefreq', 'weekly'));
|
||||
$priority = $this->params->get('users_priority', $config->get('priority', '0.5'));
|
||||
|
||||
foreach ($rows as $row)
|
||||
{
|
||||
$guest = KunenaUserHelper::get(0);
|
||||
$object = KunenaUserHelper::get($row->id);
|
||||
|
||||
// Prepare exclude attribute
|
||||
$exclude = array();
|
||||
if (!$object)
|
||||
{
|
||||
$exclude[] = array('type' => Text::_('PLG_JLSITEMAP_KUNENA_EXCLUDE_USER'),
|
||||
'msg' => Text::_('PLG_JLSITEMAP_KUNENA_EXCLUDE_TOPIC_EXIST'));
|
||||
}
|
||||
|
||||
if ($object->tryAuthorise('read', $guest, false))
|
||||
{
|
||||
$exclude[] = array('type' => Text::_('PLG_JLSITEMAP_KUNENA_EXCLUDE_USER'),
|
||||
'msg' => Text::_('PLG_JLSITEMAP_KUNENA_EXCLUDE_USER_READ'));
|
||||
}
|
||||
|
||||
// Prepare loc attribute
|
||||
$loc = ($object) ? KunenaRoute::getUserUrl($object) : '';
|
||||
|
||||
// Prepare user object
|
||||
$user = new stdClass();
|
||||
$user->type = Text::_('PLG_JLSITEMAP_KUNENA_TYPES_USER');
|
||||
$user->title = $object->getName();
|
||||
$user->loc = $loc;
|
||||
$user->changefreq = $changefreq;
|
||||
$user->priority = $priority;
|
||||
$user->lastmod = (!empty($row->last_post_time)) ? $row->last_post_time : false;
|
||||
$user->exclude = (!empty($exclude)) ? $exclude : false;
|
||||
|
||||
// Add user to array
|
||||
$urls[] = $user;
|
||||
}
|
||||
}
|
||||
|
||||
return $urls;
|
||||
}
|
||||
}
|
||||
130
plugins/jlsitemap/kunena/kunena.xml
Normal file
130
plugins/jlsitemap/kunena/kunena.xml
Normal file
@@ -0,0 +1,130 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<extension version="3.9" type="plugin" group="jlsitemap" method="upgrade">
|
||||
<name>PLG_JLSITEMAP_KUNENA</name>
|
||||
<author>Joomline</author>
|
||||
<creationDate>13.04.2022</creationDate>
|
||||
<copyright>Copyright (c) 2010 - 2022 Joomline. All rights reserved.</copyright>
|
||||
<license>http://www.gnu.org/copyleft/gpl.html GNU/GPL</license>
|
||||
<authorEmail>sale@joomline.ru</authorEmail>
|
||||
<authorUrl>https://joomline.ru/</authorUrl>
|
||||
<version>1.12.0</version>
|
||||
<description>PLG_JLSITEMAP_KUNENA_DESCRIPTION</description>
|
||||
<languages folder="language">
|
||||
<language tag="en-GB">en-GB/en-GB.plg_jlsitemap_kunena.ini</language>
|
||||
<language tag="en-GB">en-GB/en-GB.plg_jlsitemap_kunena.sys.ini</language>
|
||||
<language tag="ru-RU">ru-RU/ru-RU.plg_jlsitemap_kunena.ini</language>
|
||||
<language tag="ru-RU">ru-RU/ru-RU.plg_jlsitemap_kunena.sys.ini</language>
|
||||
</languages>
|
||||
<files>
|
||||
<filename plugin="kunena">kunena.php</filename>
|
||||
</files>
|
||||
<config>
|
||||
<fields name="params">
|
||||
<fieldset name="topics" label="PLG_JLSITEMAP_KUNENA_PARAMS_TOPICS">
|
||||
<field name="topics_enable" type="radio"
|
||||
label="PLG_JLSITEMAP_KUNENA_PARAMS_ENABLE"
|
||||
default="1"
|
||||
class="btn-group btn-group-yesno">
|
||||
<option value="0">JNO</option>
|
||||
<option value="1">JYES</option>
|
||||
</field>
|
||||
<field name="topics_changefreq" type="list" default="weekly"
|
||||
label="PLG_JLSITEMAP_KUNENA_PARAMS_CHANGEFREQ"
|
||||
showon="topics_enable:1">
|
||||
<option value="always">always</option>
|
||||
<option value="hourly">hourly</option>
|
||||
<option value="daily">daily</option>
|
||||
<option value="weekly">weekly</option>
|
||||
<option value="monthly">monthly</option>
|
||||
<option value="yearly">yearly</option>
|
||||
<option value="never">never</option>
|
||||
</field>
|
||||
<field name="topics_priority" type="list"
|
||||
default="0.5" label="PLG_JLSITEMAP_KUNENA_PARAMS_PRIORITY"
|
||||
showon="topics_enable:1">
|
||||
<option value="0.0">0.0</option>
|
||||
<option value="0.1">0.1</option>
|
||||
<option value="0.2">0.2</option>
|
||||
<option value="0.3">0.3</option>
|
||||
<option value="0.4">0.4</option>
|
||||
<option value="0.5">0.5</option>
|
||||
<option value="0.6">0.6</option>
|
||||
<option value="0.7">0.7</option>
|
||||
<option value="0.8">0.8</option>
|
||||
<option value="0.9">0.9</option>
|
||||
<option value="1">1</option>
|
||||
</field>
|
||||
</fieldset>
|
||||
<fieldset name="categories" label="PLG_JLSITEMAP_KUNENA_PARAMS_CATEGORIES">
|
||||
<field name="categories_enable" type="radio"
|
||||
label="PLG_JLSITEMAP_KUNENA_PARAMS_ENABLE"
|
||||
default="1"
|
||||
class="btn-group btn-group-yesno">
|
||||
<option value="0">JNO</option>
|
||||
<option value="1">JYES</option>
|
||||
</field>
|
||||
<field name="categories_changefreq" type="list" default="weekly"
|
||||
label="PLG_JLSITEMAP_KUNENA_PARAMS_CHANGEFREQ"
|
||||
showon="categories_enable:1">
|
||||
<option value="always">always</option>
|
||||
<option value="hourly">hourly</option>
|
||||
<option value="daily">daily</option>
|
||||
<option value="weekly">weekly</option>
|
||||
<option value="monthly">monthly</option>
|
||||
<option value="yearly">yearly</option>
|
||||
<option value="never">never</option>
|
||||
</field>
|
||||
<field name="categories_priority" type="list"
|
||||
default="0.5" label="PLG_JLSITEMAP_KUNENA_PARAMS_PRIORITY"
|
||||
showon="categories_enable:1">
|
||||
<option value="0.0">0.0</option>
|
||||
<option value="0.1">0.1</option>
|
||||
<option value="0.2">0.2</option>
|
||||
<option value="0.3">0.3</option>
|
||||
<option value="0.4">0.4</option>
|
||||
<option value="0.5">0.5</option>
|
||||
<option value="0.6">0.6</option>
|
||||
<option value="0.7">0.7</option>
|
||||
<option value="0.8">0.8</option>
|
||||
<option value="0.9">0.9</option>
|
||||
<option value="1">1</option>
|
||||
</field>
|
||||
</fieldset>
|
||||
<fieldset name="users" label="PLG_JLSITEMAP_KUNENA_PARAMS_USERS">
|
||||
<field name="users_enable" type="radio"
|
||||
label="PLG_JLSITEMAP_KUNENA_PARAMS_ENABLE"
|
||||
default="1"
|
||||
class="btn-group btn-group-yesno">
|
||||
<option value="0">JNO</option>
|
||||
<option value="1">JYES</option>
|
||||
</field>
|
||||
<field name="users_changefreq" type="list" default="weekly"
|
||||
label="PLG_JLSITEMAP_KUNENA_PARAMS_CHANGEFREQ"
|
||||
showon="users_enable:1">
|
||||
<option value="always">always</option>
|
||||
<option value="hourly">hourly</option>
|
||||
<option value="daily">daily</option>
|
||||
<option value="weekly">weekly</option>
|
||||
<option value="monthly">monthly</option>
|
||||
<option value="yearly">yearly</option>
|
||||
<option value="never">never</option>
|
||||
</field>
|
||||
<field name="users_priority" type="list"
|
||||
default="0.5" label="PLG_JLSITEMAP_KUNENA_PARAMS_PRIORITY"
|
||||
showon="users_enable:1">
|
||||
<option value="0.0">0.0</option>
|
||||
<option value="0.1">0.1</option>
|
||||
<option value="0.2">0.2</option>
|
||||
<option value="0.3">0.3</option>
|
||||
<option value="0.4">0.4</option>
|
||||
<option value="0.5">0.5</option>
|
||||
<option value="0.6">0.6</option>
|
||||
<option value="0.7">0.7</option>
|
||||
<option value="0.8">0.8</option>
|
||||
<option value="0.9">0.9</option>
|
||||
<option value="1">1</option>
|
||||
</field>
|
||||
</fieldset>
|
||||
</fields>
|
||||
</config>
|
||||
</extension>
|
||||
122
plugins/jlsitemap/tags/tags.php
Normal file
122
plugins/jlsitemap/tags/tags.php
Normal file
@@ -0,0 +1,122 @@
|
||||
<?php
|
||||
/**
|
||||
* @package JLSitemap - Tags Plugin
|
||||
* @version 1.12.0
|
||||
* @author Joomline - joomline.ru
|
||||
* @copyright Copyright (c) 2010 - 2022 Joomline. All rights reserved.
|
||||
* @license GNU/GPL license: http://www.gnu.org/copyleft/gpl.html
|
||||
* @link https://joomline.ru/
|
||||
*/
|
||||
|
||||
defined('_JEXEC') or die;
|
||||
|
||||
use Joomla\CMS\Factory;
|
||||
use Joomla\CMS\Language\Text;
|
||||
use Joomla\CMS\Plugin\CMSPlugin;
|
||||
use Joomla\Registry\Registry;
|
||||
|
||||
class plgJLSitemapTags extends CMSPlugin
|
||||
{
|
||||
/**
|
||||
* Affects constructor behavior. If true, language files will be loaded automatically.
|
||||
*
|
||||
* @var boolean
|
||||
*
|
||||
* @since 1.3.0
|
||||
*/
|
||||
protected $autoloadLanguage = true;
|
||||
|
||||
/**
|
||||
* Method to get urls array
|
||||
*
|
||||
* @param array $urls Urls array
|
||||
* @param Registry $config Component config
|
||||
*
|
||||
* @return array Urls array with attributes
|
||||
*
|
||||
* @since 1.3.0
|
||||
*/
|
||||
public function onGetUrls(&$urls, $config)
|
||||
{
|
||||
$db = Factory::getDbo();
|
||||
$query = $db->getQuery(true)
|
||||
->select(array('t.id', 't.title', 't.alias', 't.published', 't.access', 't.metadata', 't.created_time',
|
||||
't.modified_time', 'tm.tag_date'))
|
||||
->from($db->quoteName('#__tags', 't'))
|
||||
->join('LEFT', '#__contentitem_tag_map AS tm ON tm.tag_id = t.id')
|
||||
->where('t.id > 1')
|
||||
->group('t.id')
|
||||
->order($db->escape('t.lft') . ' ' . $db->escape('asc'));
|
||||
|
||||
$db->setQuery($query);
|
||||
$rows = $db->loadObjectList();
|
||||
|
||||
$nullDate = $db->getNullDate();
|
||||
$excludeStates = array(
|
||||
0 => Text::_('PLG_JLSITEMAP_TAGS_EXCLUDE_UNPUBLISH'),
|
||||
-2 => Text::_('PLG_JLSITEMAP_TAGS_EXCLUDE_TRASH'),
|
||||
2 => Text::_('PLG_JLSITEMAP_TAGS_EXCLUDE_ARCHIVE'));
|
||||
$changefreq = $this->params->get('changefreq', $config->get('changefreq', 'weekly'));
|
||||
$priority = $this->params->get('priority', $config->get('priority', '0.5'));
|
||||
|
||||
JLoader::register('TagsHelperRoute', JPATH_SITE . '/components/com_tags/helpers/route.php');
|
||||
|
||||
foreach ($rows as $row)
|
||||
{
|
||||
// Prepare exclude attribute
|
||||
$metadata = new Registry($row->metadata);
|
||||
$exclude = array();
|
||||
if (preg_match('/noindex/', $metadata->get('robots', $config->get('siteRobots'))))
|
||||
{
|
||||
$exclude[] = array('type' => Text::_('PLG_JLSITEMAP_TAGS_EXCLUDE'),
|
||||
'msg' => Text::_('PLG_JLSITEMAP_TAGS_EXCLUDE_ROBOTS'));
|
||||
}
|
||||
|
||||
if (isset($excludeStates[$row->published]))
|
||||
{
|
||||
$exclude[] = array('type' => Text::_('PLG_JLSITEMAP_TAGS_EXCLUDE'),
|
||||
'msg' => $excludeStates[$row->published]);
|
||||
}
|
||||
|
||||
if (!in_array($row->access, $config->get('guestAccess', array())))
|
||||
{
|
||||
$exclude[] = array('type' => Text::_('PLG_JLSITEMAP_TAGS_EXCLUDE'),
|
||||
'msg' => Text::_('PLG_JLSITEMAP_TAGS_EXCLUDE_ACCESS'));
|
||||
}
|
||||
|
||||
// Prepare lastmod attribute
|
||||
$lastmod = (!empty($row->created_time) && $row->created_time != $nullDate) ?
|
||||
Factory::getDate($row->created_time)->toUnix() : false;
|
||||
|
||||
if ((!empty($row->modified_time) && $row->modified_time != $nullDate) &&
|
||||
(!$lastmod || Factory::getDate($row->modified_time)->toUnix() > $lastmod))
|
||||
{
|
||||
$lastmod = Factory::getDate($row->modified_time)->toUnix();
|
||||
}
|
||||
|
||||
if ((!empty($row->tag_date) && $row->tag_date != $nullDate) &&
|
||||
(!$lastmod || Factory::getDate($row->tag_date)->toUnix() > $lastmod))
|
||||
{
|
||||
$lastmod = Factory::getDate($row->tag_date)->toUnix();
|
||||
}
|
||||
|
||||
$lastmod = Factory::getDate($lastmod)->toSql();
|
||||
|
||||
// Prepare tag object
|
||||
$tag = new stdClass();
|
||||
$tag->id = $row->id;
|
||||
$tag->type = Text::_('PLG_JLSITEMAP_TAGS_TYPE');
|
||||
$tag->title = $row->title;
|
||||
$tag->loc = TagsHelperRoute::getTagRoute($row->id . ':' . $row->alias);
|
||||
$tag->changefreq = $changefreq;
|
||||
$tag->priority = $priority;
|
||||
$tag->lastmod = $lastmod;
|
||||
$tag->exclude = (!empty($exclude)) ? $exclude : false;
|
||||
|
||||
// Add tag to array
|
||||
$urls[] = $tag;
|
||||
}
|
||||
|
||||
return $urls;
|
||||
}
|
||||
}
|
||||
53
plugins/jlsitemap/tags/tags.xml
Normal file
53
plugins/jlsitemap/tags/tags.xml
Normal file
@@ -0,0 +1,53 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<extension version="3.9" type="plugin" group="jlsitemap" method="upgrade">
|
||||
<name>PLG_JLSITEMAP_TAGS</name>
|
||||
<author>Joomline</author>
|
||||
<creationDate>13.04.2022</creationDate>
|
||||
<copyright>Copyright (c) 2010 - 2022 Joomline. All rights reserved.</copyright>
|
||||
<license>http://www.gnu.org/copyleft/gpl.html GNU/GPL</license>
|
||||
<authorEmail>sale@joomline.ru</authorEmail>
|
||||
<authorUrl>https://joomline.ru</authorUrl>
|
||||
<version>1.12.0</version>
|
||||
<description>PLG_JLSITEMAP_TAGS_DESCRIPTION</description>
|
||||
<languages folder="language">
|
||||
<language tag="en-GB">en-GB/en-GB.plg_jlsitemap_tags.ini</language>
|
||||
<language tag="en-GB">en-GB/en-GB.plg_jlsitemap_tags.sys.ini</language>
|
||||
<language tag="ru-RU">ru-RU/ru-RU.plg_jlsitemap_tags.ini</language>
|
||||
<language tag="ru-RU">ru-RU/ru-RU.plg_jlsitemap_tags.sys.ini</language>
|
||||
</languages>
|
||||
<files>
|
||||
<filename plugin="tags">tags.php</filename>
|
||||
</files>
|
||||
<config>
|
||||
<fields name="params">
|
||||
<fieldset name="basic">
|
||||
<field name="changefreq" type="list" default="weekly"
|
||||
label="PLG_JLSITEMAP_TAGS_PARAMS_CHANGEFREQ"
|
||||
showon="items_enable:1">
|
||||
<option value="always">always</option>
|
||||
<option value="hourly">hourly</option>
|
||||
<option value="daily">daily</option>
|
||||
<option value="weekly">weekly</option>
|
||||
<option value="monthly">monthly</option>
|
||||
<option value="yearly">yearly</option>
|
||||
<option value="never">never</option>
|
||||
</field>
|
||||
<field name="priority" type="list"
|
||||
default="0.5" label="PLG_JLSITEMAP_TAGS_PARAMS_PRIORITY"
|
||||
showon="items_enable:1">
|
||||
<option value="0.0">0.0</option>
|
||||
<option value="0.1">0.1</option>
|
||||
<option value="0.2">0.2</option>
|
||||
<option value="0.3">0.3</option>
|
||||
<option value="0.4">0.4</option>
|
||||
<option value="0.5">0.5</option>
|
||||
<option value="0.6">0.6</option>
|
||||
<option value="0.7">0.7</option>
|
||||
<option value="0.8">0.8</option>
|
||||
<option value="0.9">0.9</option>
|
||||
<option value="1">1</option>
|
||||
</field>
|
||||
</fieldset>
|
||||
</fields>
|
||||
</config>
|
||||
</extension>
|
||||
399
plugins/jlsitemap/virtuemart/virtuemart.php
Normal file
399
plugins/jlsitemap/virtuemart/virtuemart.php
Normal file
@@ -0,0 +1,399 @@
|
||||
<?php
|
||||
/**
|
||||
* @package JLSitemap - VirtueMart Plugin
|
||||
* @version 1.12.0
|
||||
* @author Joomline - joomline.ru
|
||||
* @copyright Copyright (c) 2010 - 2022 Joomline. All rights reserved.
|
||||
* @license GNU/GPL license: http://www.gnu.org/copyleft/gpl.html
|
||||
* @link https://joomline.ru/
|
||||
*/
|
||||
|
||||
defined('_JEXEC') or die;
|
||||
|
||||
use Joomla\CMS\Factory;
|
||||
use Joomla\CMS\Language\Text;
|
||||
use Joomla\CMS\Plugin\CMSPlugin;
|
||||
use Joomla\Registry\Registry;
|
||||
|
||||
class plgJLSitemapVirtueMart extends CMSPlugin
|
||||
{
|
||||
/**
|
||||
* Affects constructor behavior. If true, language files will be loaded automatically.
|
||||
*
|
||||
* @var boolean
|
||||
*
|
||||
* @since 1.6.0
|
||||
*/
|
||||
protected $autoloadLanguage = true;
|
||||
|
||||
/**
|
||||
* Method to get urls array
|
||||
*
|
||||
* @param array $urls Urls array
|
||||
* @param Registry $config Component config
|
||||
*
|
||||
* @return array Urls array with attributes
|
||||
*
|
||||
* @since 1.6.0
|
||||
*/
|
||||
public function onGetUrls(&$urls, $config)
|
||||
{
|
||||
if (!$this->params->get('products_enable')
|
||||
&& !$this->params->get('categories_enable')
|
||||
&& !$this->params->get('manufacturers_enable')
|
||||
&& !$this->params->get('vendors_enable'))
|
||||
{
|
||||
return $urls;
|
||||
}
|
||||
|
||||
// Add config
|
||||
JLoader::register('VmConfig', JPATH_ROOT . '/administrator/components/com_virtuemart/helpers/config.php');
|
||||
|
||||
$db = Factory::getDbo();
|
||||
|
||||
// Get default language
|
||||
if ($defaultLanguage = VmConfig::get('vmDefLang'))
|
||||
{
|
||||
$defaultLanguageKey = str_replace('-', '_', strtolower($defaultLanguage));
|
||||
}
|
||||
else
|
||||
{
|
||||
$defaultLanguage = Factory::getLanguage()->getTag();
|
||||
$defaultLanguageKey = str_replace('-', '_', strtolower($defaultLanguage));;
|
||||
}
|
||||
$languages = (!empty($defaultLanguage) && !empty($defaultLanguageKey)) ?
|
||||
array($defaultLanguageKey => $defaultLanguage) : array();
|
||||
|
||||
// Get other languages
|
||||
$activeLanguages = VmConfig::get('active_languages');
|
||||
$multilanguage = ($config->get('multilanguage') && !empty($activeLanguages));
|
||||
if ($multilanguage)
|
||||
{
|
||||
foreach ($activeLanguages as $language)
|
||||
{
|
||||
$key = str_replace('-', '_', strtolower($language));
|
||||
if (!empty($key) && !empty($language))
|
||||
{
|
||||
$languages[$key] = $language;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
// Check languages
|
||||
if (empty($languages))
|
||||
{
|
||||
return $urls;
|
||||
}
|
||||
|
||||
// Get products
|
||||
if ($this->params->get('products_enable'))
|
||||
{
|
||||
$query = $db->getQuery(true)
|
||||
->select(array('p.virtuemart_product_id as id', 'p.published', 'p.metarobot',
|
||||
'c.virtuemart_category_id as catid', 'product_canon_category_id as canon_catid'))
|
||||
->leftJoin($db->quoteName('#__virtuemart_product_categories', 'c')
|
||||
. ' ON c.virtuemart_product_id = p.virtuemart_product_id')
|
||||
->from($db->quoteName('#__virtuemart_products', 'p'))
|
||||
->group('p.virtuemart_product_id');
|
||||
|
||||
foreach ($languages as $key => $code)
|
||||
{
|
||||
$query->select(array($key . '.product_name as ' . 'product_name_' . $key))
|
||||
->leftJoin($db->quoteName('#__virtuemart_products_' . $key, $key)
|
||||
. ' ON ' . $key . '.virtuemart_product_id = p.virtuemart_product_id');
|
||||
}
|
||||
|
||||
$rows = $db->setQuery($query)->loadObjectList();
|
||||
$changefreq = $this->params->get('products_changefreq', $config->get('changefreq', 'weekly'));
|
||||
$priority = $this->params->get('products_priority', $config->get('priority', '0.5'));
|
||||
|
||||
foreach ($rows as $row)
|
||||
{
|
||||
// Prepare default title
|
||||
$selector = 'product_name_' . $defaultLanguageKey;
|
||||
$defaultTitle = $row->$selector;
|
||||
|
||||
// Prepare catid
|
||||
$catid = (!empty($row->canon_catid)) ? $row->canon_catid : $row->catid;
|
||||
|
||||
// Prepare default loc attribute
|
||||
$defaultLoc = 'index.php?option=com_virtuemart&view=productdetails&virtuemart_product_id='
|
||||
. $row->id . '&virtuemart_category_id=' . $catid;
|
||||
|
||||
// Prepare exclude attribute
|
||||
$exclude = array();
|
||||
if (preg_match('/noindex/', $row->metarobot))
|
||||
{
|
||||
$exclude[] = array('type' => Text::_('PLG_JLSITEMAP_VIRTUEMART_EXCLUDE_PRODUCT'),
|
||||
'msg' => Text::_('PLG_JLSITEMAP_VIRTUEMART_EXCLUDE_PRODUCT_ROBOTS'));
|
||||
}
|
||||
if (!$row->published)
|
||||
{
|
||||
$exclude[] = array(
|
||||
'type' => Text::_('PLG_JLSITEMAP_VIRTUEMART_EXCLUDE_PRODUCT'),
|
||||
'msg' => Text::_('PLG_JLSITEMAP_VIRTUEMART_EXCLUDE_PRODUCT_UNPUBLISH')
|
||||
);
|
||||
}
|
||||
|
||||
foreach ($languages as $key => $code)
|
||||
{
|
||||
$selector = 'product_name_' . $key;
|
||||
$title = (!empty($row->$selector)) ? $row->$selector : $defaultTitle;
|
||||
|
||||
$loc = $defaultLoc;
|
||||
if ($multilanguage)
|
||||
{
|
||||
$loc .= '&lang=' . $code;
|
||||
}
|
||||
|
||||
// Prepare product object
|
||||
$product = new stdClass();
|
||||
$product->type = Text::_('PLG_JLSITEMAP_VIRTUEMART_TYPES_PRODUCT');
|
||||
$product->title = $title;
|
||||
$product->loc = $loc;
|
||||
$product->changefreq = $changefreq;
|
||||
$product->priority = $priority;
|
||||
$product->exclude = (!empty($exclude)) ? $exclude : false;
|
||||
$product->alternates = ($multilanguage) ? array() : false;
|
||||
if ($multilanguage)
|
||||
{
|
||||
foreach ($languages as $alternate)
|
||||
{
|
||||
$product->alternates[$alternate] = $defaultLoc . '&lang=' . $alternate;
|
||||
}
|
||||
}
|
||||
|
||||
// Add product to urls
|
||||
$urls[] = $product;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Get categories
|
||||
if ($this->params->get('categories_enable'))
|
||||
{
|
||||
$query = $db->getQuery(true)
|
||||
->select(array('c.virtuemart_category_id as id', 'c.published', 'c.metarobot'))
|
||||
->from($db->quoteName('#__virtuemart_categories', 'c'));
|
||||
|
||||
foreach ($languages as $key => $code)
|
||||
{
|
||||
$query->select(array($key . '.category_name as ' . 'category_name_' . $key))
|
||||
->leftJoin($db->quoteName('#__virtuemart_categories_' . $key, $key)
|
||||
. ' ON ' . $key . '.virtuemart_category_id = c.virtuemart_category_id');
|
||||
}
|
||||
|
||||
$rows = $db->setQuery($query)->loadObjectList();
|
||||
$changefreq = $this->params->get('categories_changefreq', $config->get('changefreq', 'weekly'));
|
||||
$priority = $this->params->get('categories_priority', $config->get('priority', '0.5'));
|
||||
|
||||
foreach ($rows as $row)
|
||||
{
|
||||
// Prepare default title
|
||||
$selector = 'category_name_' . $defaultLanguageKey;
|
||||
$defaultTitle = $row->$selector;
|
||||
|
||||
// Prepare default loc attribute
|
||||
$defaultLoc = 'index.php?option=com_virtuemart&view=category&virtuemart_manufacturer_id=0&Itemid=0&virtuemart_category_id='
|
||||
. $row->id;
|
||||
|
||||
// Prepare exclude attribute
|
||||
$exclude = array();
|
||||
if (preg_match('/noindex/', $row->metarobot))
|
||||
{
|
||||
$exclude[] = array('type' => Text::_('PLG_JLSITEMAP_VIRTUEMART_EXCLUDE_CATEGORY'),
|
||||
'msg' => Text::_('PLG_JLSITEMAP_VIRTUEMART_EXCLUDE_CATEGORY_ROBOTS'));
|
||||
}
|
||||
if (!$row->published)
|
||||
{
|
||||
$exclude[] = array(
|
||||
'type' => Text::_('PLG_JLSITEMAP_VIRTUEMART_EXCLUDE_CATEGORY'),
|
||||
'msg' => Text::_('PLG_JLSITEMAP_VIRTUEMART_EXCLUDE_CATEGORY_UNPUBLISH')
|
||||
);
|
||||
}
|
||||
|
||||
foreach ($languages as $key => $code)
|
||||
{
|
||||
$selector = 'category_name_' . $key;
|
||||
$title = (!empty($row->$selector)) ? $row->$selector : $defaultTitle;
|
||||
|
||||
$loc = $defaultLoc;
|
||||
if ($multilanguage)
|
||||
{
|
||||
$loc .= '&lang=' . $code;
|
||||
}
|
||||
|
||||
// Prepare category object
|
||||
$category = new stdClass();
|
||||
$category->type = Text::_('PLG_JLSITEMAP_VIRTUEMART_TYPES_CATEGORY');
|
||||
$category->title = $title;
|
||||
$category->loc = $loc;
|
||||
$category->changefreq = $changefreq;
|
||||
$category->priority = $priority;
|
||||
$category->exclude = (!empty($exclude)) ? $exclude : false;
|
||||
$category->alternates = ($multilanguage) ? array() : false;
|
||||
if ($multilanguage)
|
||||
{
|
||||
foreach ($languages as $alternate)
|
||||
{
|
||||
$category->alternates[$alternate] = $defaultLoc . '&lang=' . $alternate;
|
||||
}
|
||||
}
|
||||
|
||||
// Add category to urls
|
||||
$urls[] = $category;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Get manufacturers
|
||||
if ($this->params->get('manufacturers_enable'))
|
||||
{
|
||||
$query = $db->getQuery(true)
|
||||
->select(array('m.virtuemart_manufacturer_id as id', 'm.published', 'm.metarobot'))
|
||||
->from($db->quoteName('#__virtuemart_manufacturers', 'm'));
|
||||
|
||||
foreach ($languages as $key => $code)
|
||||
{
|
||||
$query->select(array($key . '.mf_name as ' . 'manufacturer_name_' . $key))
|
||||
->leftJoin($db->quoteName('#__virtuemart_manufacturers_' . $key, $key)
|
||||
. ' ON ' . $key . '.virtuemart_manufacturer_id = m.virtuemart_manufacturer_id');
|
||||
}
|
||||
|
||||
$rows = $db->setQuery($query)->loadObjectList();
|
||||
$changefreq = $this->params->get('manufacturers_changefreq', $config->get('changefreq', 'weekly'));
|
||||
$priority = $this->params->get('manufacturers_priority', $config->get('priority', '0.5'));
|
||||
|
||||
foreach ($rows as $row)
|
||||
{
|
||||
// Prepare default title
|
||||
$selector = 'manufacturer_name_' . $defaultLanguageKey;
|
||||
$defaultTitle = $row->$selector;
|
||||
|
||||
// Prepare default loc attribute
|
||||
$defaultLoc = 'index.php?option=com_virtuemart&view=manufacturer&layout=details&Itemid=0&virtuemart_manufacturer_id='
|
||||
. $row->id;
|
||||
|
||||
// Prepare exclude attribute
|
||||
$exclude = array();
|
||||
if (preg_match('/noindex/', $row->metarobot))
|
||||
{
|
||||
$exclude[] = array('type' => Text::_('PLG_JLSITEMAP_VIRTUEMART_EXCLUDE_MANUFACTURER'),
|
||||
'msg' => Text::_('PLG_JLSITEMAP_VIRTUEMART_EXCLUDE_MANUFACTURER_ROBOTS'));
|
||||
}
|
||||
if (!$row->published)
|
||||
{
|
||||
$exclude[] = array(
|
||||
'type' => Text::_('PLG_JLSITEMAP_VIRTUEMART_EXCLUDE_MANUFACTURER'),
|
||||
'msg' => Text::_('PLG_JLSITEMAP_VIRTUEMART_EXCLUDE_MANUFACTURER_UNPUBLISH')
|
||||
);
|
||||
}
|
||||
|
||||
foreach ($languages as $key => $code)
|
||||
{
|
||||
$selector = 'category_name_' . $key;
|
||||
$title = (!empty($row->$selector)) ? $row->$selector : $defaultTitle;
|
||||
|
||||
$loc = $defaultLoc;
|
||||
if ($multilanguage)
|
||||
{
|
||||
$loc .= '&lang=' . $code;
|
||||
}
|
||||
|
||||
// Prepare manufacturer object
|
||||
$manufacturer = new stdClass();
|
||||
$manufacturer->type = Text::_('PLG_JLSITEMAP_VIRTUEMART_TYPES_MANUFACTURER');
|
||||
$manufacturer->title = $title;
|
||||
$manufacturer->loc = $loc;
|
||||
$manufacturer->changefreq = $changefreq;
|
||||
$manufacturer->priority = $priority;
|
||||
$manufacturer->exclude = (!empty($exclude)) ? $exclude : false;
|
||||
$manufacturer->alternates = ($multilanguage) ? array() : false;
|
||||
if ($multilanguage)
|
||||
{
|
||||
foreach ($languages as $alternate)
|
||||
{
|
||||
$manufacturer->alternates[$alternate] = $defaultLoc . '&lang=' . $alternate;
|
||||
}
|
||||
}
|
||||
|
||||
// Add category to urls
|
||||
$urls[] = $category;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Get vendors
|
||||
if ($this->params->get('vendors_enable'))
|
||||
{
|
||||
$query = $db->getQuery(true)
|
||||
->select(array('m.virtuemart_vendor_id as id', 'm.metarobot'))
|
||||
->from($db->quoteName('#__virtuemart_vendors', 'm'));
|
||||
|
||||
foreach ($languages as $key => $code)
|
||||
{
|
||||
$query->select(array($key . '.vendor_store_name as ' . 'vendor_name_' . $key))
|
||||
->leftJoin($db->quoteName('#__virtuemart_vendors_' . $key, $key)
|
||||
. ' ON ' . $key . '.virtuemart_vendor_id = m.virtuemart_vendor_id');
|
||||
}
|
||||
|
||||
$rows = $db->setQuery($query)->loadObjectList();
|
||||
$changefreq = $this->params->get('vendors_changefreq', $config->get('changefreq', 'weekly'));
|
||||
$priority = $this->params->get('vendors_priority', $config->get('priority', '0.5'));
|
||||
|
||||
foreach ($rows as $row)
|
||||
{
|
||||
// Prepare default title
|
||||
$selector = 'vendor_name_' . $defaultLanguageKey;
|
||||
$defaultTitle = $row->$selector;
|
||||
|
||||
// Prepare default loc attribute
|
||||
$defaultLoc = 'index.php?option=com_virtuemart&view=vendor&layout=tos&Itemid=&virtuemart_vendor_id='
|
||||
. $row->id;
|
||||
|
||||
// Prepare exclude attribute
|
||||
$exclude = array();
|
||||
if (preg_match('/noindex/', $row->metarobot))
|
||||
{
|
||||
$exclude[] = array('type' => Text::_('PLG_JLSITEMAP_VIRTUEMART_EXCLUDE_VENDOR'),
|
||||
'msg' => Text::_('PLG_JLSITEMAP_VIRTUEMART_EXCLUDE_VENDOR_ROBOTS'));
|
||||
}
|
||||
|
||||
foreach ($languages as $key => $code)
|
||||
{
|
||||
$selector = 'vendor_name_' . $key;
|
||||
$title = (!empty($row->$selector)) ? $row->$selector : $defaultTitle;
|
||||
|
||||
$loc = $defaultLoc;
|
||||
if ($multilanguage)
|
||||
{
|
||||
$loc .= '&lang=' . $code;
|
||||
}
|
||||
|
||||
// Prepare vendor object
|
||||
$vendor = new stdClass();
|
||||
$vendor->type = Text::_('PLG_JLSITEMAP_VIRTUEMART_TYPES_VENDOR');
|
||||
$vendor->title = $title;
|
||||
$vendor->loc = $loc;
|
||||
$vendor->changefreq = $changefreq;
|
||||
$vendor->priority = $priority;
|
||||
$vendor->exclude = (!empty($exclude)) ? $exclude : false;
|
||||
$vendor->alternates = ($multilanguage) ? array() : false;
|
||||
if ($multilanguage)
|
||||
{
|
||||
foreach ($languages as $alternate)
|
||||
{
|
||||
$vendor->alternates[$alternate] = $defaultLoc . '&lang=' . $alternate;
|
||||
}
|
||||
}
|
||||
|
||||
// Add vendor to urls
|
||||
$urls[] = $vendor;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return $urls;
|
||||
}
|
||||
}
|
||||
165
plugins/jlsitemap/virtuemart/virtuemart.xml
Normal file
165
plugins/jlsitemap/virtuemart/virtuemart.xml
Normal file
@@ -0,0 +1,165 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<extension version="3.9" type="plugin" group="jlsitemap" method="upgrade">
|
||||
<name>PLG_JLSITEMAP_VIRTUEMART</name>
|
||||
<author>Joomline</author>
|
||||
<creationDate>13.04.2022</creationDate>
|
||||
<copyright>Copyright (c) 2010 - 2022 Joomline. All rights reserved.</copyright>
|
||||
<license>http://www.gnu.org/copyleft/gpl.html GNU/GPL</license>
|
||||
<authorEmail>sale@joomline.ru</authorEmail>
|
||||
<authorUrl>https://joomline.ru</authorUrl>
|
||||
<version>1.12.0</version>
|
||||
<description>PLG_JLSITEMAP_VIRTUEMART_DESCRIPTION</description>
|
||||
<languages folder="language">
|
||||
<language tag="en-GB">en-GB/en-GB.plg_jlsitemap_virtuemart.ini</language>
|
||||
<language tag="en-GB">en-GB/en-GB.plg_jlsitemap_virtuemart.sys.ini</language>
|
||||
<language tag="ru-RU">ru-RU/ru-RU.plg_jlsitemap_virtuemart.ini</language>
|
||||
<language tag="ru-RU">ru-RU/ru-RU.plg_jlsitemap_virtuemart.sys.ini</language>
|
||||
</languages>
|
||||
<files>
|
||||
<filename plugin="virtuemart">virtuemart.php</filename>
|
||||
</files>
|
||||
<config>
|
||||
<fields name="params">
|
||||
<fieldset name="products" label="PLG_JLSITEMAP_VIRTUEMART_PARAMS_PRODUCTS">
|
||||
<field name="products_enable" type="radio"
|
||||
label="PLG_JLSITEMAP_VIRTUEMART_PARAMS_ENABLE"
|
||||
default="1"
|
||||
class="btn-group btn-group-yesno">
|
||||
<option value="0">JNO</option>
|
||||
<option value="1">JYES</option>
|
||||
</field>
|
||||
<field name="products_changefreq" type="list" default="weekly"
|
||||
label="PLG_JLSITEMAP_VIRTUEMART_PARAMS_CHANGEFREQ"
|
||||
showon="products_enable:1">
|
||||
<option value="always">always</option>
|
||||
<option value="hourly">hourly</option>
|
||||
<option value="daily">daily</option>
|
||||
<option value="weekly">weekly</option>
|
||||
<option value="monthly">monthly</option>
|
||||
<option value="yearly">yearly</option>
|
||||
<option value="never">never</option>
|
||||
</field>
|
||||
<field name="products_priority" type="list"
|
||||
default="0.5" label="PLG_JLSITEMAP_VIRTUEMART_PARAMS_PRIORITY"
|
||||
showon="products_enable:1">
|
||||
<option value="0.0">0.0</option>
|
||||
<option value="0.1">0.1</option>
|
||||
<option value="0.2">0.2</option>
|
||||
<option value="0.3">0.3</option>
|
||||
<option value="0.4">0.4</option>
|
||||
<option value="0.5">0.5</option>
|
||||
<option value="0.6">0.6</option>
|
||||
<option value="0.7">0.7</option>
|
||||
<option value="0.8">0.8</option>
|
||||
<option value="0.9">0.9</option>
|
||||
<option value="1">1</option>
|
||||
</field>
|
||||
</fieldset>
|
||||
<fieldset name="categories" label="PLG_JLSITEMAP_VIRTUEMART_PARAMS_CATEGORIES">
|
||||
<field name="categories_enable" type="radio"
|
||||
label="PLG_JLSITEMAP_VIRTUEMART_PARAMS_ENABLE"
|
||||
default="1"
|
||||
class="btn-group btn-group-yesno">
|
||||
<option value="0">JNO</option>
|
||||
<option value="1">JYES</option>
|
||||
</field>
|
||||
<field name="categories_changefreq" type="list" default="weekly"
|
||||
label="PLG_JLSITEMAP_VIRTUEMART_PARAMS_CHANGEFREQ"
|
||||
showon="categories_enable:1">
|
||||
<option value="always">always</option>
|
||||
<option value="hourly">hourly</option>
|
||||
<option value="daily">daily</option>
|
||||
<option value="weekly">weekly</option>
|
||||
<option value="monthly">monthly</option>
|
||||
<option value="yearly">yearly</option>
|
||||
<option value="never">never</option>
|
||||
</field>
|
||||
<field name="categories_priority" type="list"
|
||||
default="0.5" label="PLG_JLSITEMAP_VIRTUEMART_PARAMS_PRIORITY"
|
||||
showon="categories_enable:1">
|
||||
<option value="0.0">0.0</option>
|
||||
<option value="0.1">0.1</option>
|
||||
<option value="0.2">0.2</option>
|
||||
<option value="0.3">0.3</option>
|
||||
<option value="0.4">0.4</option>
|
||||
<option value="0.5">0.5</option>
|
||||
<option value="0.6">0.6</option>
|
||||
<option value="0.7">0.7</option>
|
||||
<option value="0.8">0.8</option>
|
||||
<option value="0.9">0.9</option>
|
||||
<option value="1">1</option>
|
||||
</field>
|
||||
</fieldset>
|
||||
<fieldset name="manufacturers" label="PLG_JLSITEMAP_VIRTUEMART_PARAMS_MANUFACTURERS">
|
||||
<field name="manufacturers_enable" type="radio"
|
||||
label="PLG_JLSITEMAP_VIRTUEMART_PARAMS_ENABLE"
|
||||
default="1"
|
||||
class="btn-group btn-group-yesno">
|
||||
<option value="0">JNO</option>
|
||||
<option value="1">JYES</option>
|
||||
</field>
|
||||
<field name="manufacturers_changefreq" type="list" default="weekly"
|
||||
label="PLG_JLSITEMAP_VIRTUEMART_PARAMS_CHANGEFREQ"
|
||||
showon="manufacturers_enable:1">
|
||||
<option value="always">always</option>
|
||||
<option value="hourly">hourly</option>
|
||||
<option value="daily">daily</option>
|
||||
<option value="weekly">weekly</option>
|
||||
<option value="monthly">monthly</option>
|
||||
<option value="yearly">yearly</option>
|
||||
<option value="never">never</option>
|
||||
</field>
|
||||
<field name="manufacturers_priority" type="list"
|
||||
default="0.5" label="PLG_JLSITEMAP_VIRTUEMART_PARAMS_PRIORITY"
|
||||
showon="manufacturers_enable:1">
|
||||
<option value="0.0">0.0</option>
|
||||
<option value="0.1">0.1</option>
|
||||
<option value="0.2">0.2</option>
|
||||
<option value="0.3">0.3</option>
|
||||
<option value="0.4">0.4</option>
|
||||
<option value="0.5">0.5</option>
|
||||
<option value="0.6">0.6</option>
|
||||
<option value="0.7">0.7</option>
|
||||
<option value="0.8">0.8</option>
|
||||
<option value="0.9">0.9</option>
|
||||
<option value="1">1</option>
|
||||
</field>
|
||||
</fieldset>
|
||||
<fieldset name="vendors" label="PLG_JLSITEMAP_VIRTUEMART_PARAMS_VENDORS">
|
||||
<field name="vendors_enable" type="radio"
|
||||
label="PLG_JLSITEMAP_VIRTUEMART_PARAMS_ENABLE"
|
||||
default="0"
|
||||
class="btn-group btn-group-yesno">
|
||||
<option value="0">JNO</option>
|
||||
<option value="1">JYES</option>
|
||||
</field>
|
||||
<field name="vendors_changefreq" type="list" default="weekly"
|
||||
label="PLG_JLSITEMAP_VIRTUEMART_PARAMS_CHANGEFREQ"
|
||||
showon="vendors_enable:1">
|
||||
<option value="always">always</option>
|
||||
<option value="hourly">hourly</option>
|
||||
<option value="daily">daily</option>
|
||||
<option value="weekly">weekly</option>
|
||||
<option value="monthly">monthly</option>
|
||||
<option value="yearly">yearly</option>
|
||||
<option value="never">never</option>
|
||||
</field>
|
||||
<field name="vendors_priority" type="list"
|
||||
default="0.5" label="PLG_JLSITEMAP_VIRTUEMART_PARAMS_PRIORITY"
|
||||
showon="vendors_enable:1">
|
||||
<option value="0.0">0.0</option>
|
||||
<option value="0.1">0.1</option>
|
||||
<option value="0.2">0.2</option>
|
||||
<option value="0.3">0.3</option>
|
||||
<option value="0.4">0.4</option>
|
||||
<option value="0.5">0.5</option>
|
||||
<option value="0.6">0.6</option>
|
||||
<option value="0.7">0.7</option>
|
||||
<option value="0.8">0.8</option>
|
||||
<option value="0.9">0.9</option>
|
||||
<option value="1">1</option>
|
||||
</field>
|
||||
</fieldset>
|
||||
</fields>
|
||||
</config>
|
||||
</extension>
|
||||
Reference in New Issue
Block a user