first commit
This commit is contained in:
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>
|
||||
Reference in New Issue
Block a user