Skip to content

Commit

Permalink
Exclude jupdate and downloads views from sitemap [close #31]
Browse files Browse the repository at this point in the history
  • Loading branch information
Septdir committed May 14, 2019
1 parent 47ed5ad commit c52b83b
Show file tree
Hide file tree
Showing 3 changed files with 63 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ PLG_JLSITEMAP_SWJPROJECTS_TYPES_VERSION_TAG_ALPHA = "Alpha"
PLG_JLSITEMAP_SWJPROJECTS_TYPES_VERSION_TAG_BETA = "Beta"
PLG_JLSITEMAP_SWJPROJECTS_TYPES_VERSION_TAG_RC = "Release Candidate"
PLG_JLSITEMAP_SWJPROJECTS_TYPES_VERSION_TAG_STABLE = "Stable"
PLG_JLSITEMAP_SWJPROJECTS_TYPES_JUPDATE = "SW JProjects - JUpdate"
PLG_JLSITEMAP_SWJPROJECTS_TYPES_DOWNLOAD = "SW JProjects - Download"

PLG_JLSITEMAP_SWJPROJECTS_EXCLUDE_CATEGORY = "SW JProjects - Category exception"
PLG_JLSITEMAP_SWJPROJECTS_EXCLUDE_CATEGORY_UNPUBLISH = "Unpublished"
Expand All @@ -29,6 +31,10 @@ PLG_JLSITEMAP_SWJPROJECTS_EXCLUDE_PROJECT_TRASH = "Trashed"
PLG_JLSITEMAP_SWJPROJECTS_EXCLUDE_VERSION = "SW JProjects - Version exception"
PLG_JLSITEMAP_SWJPROJECTS_EXCLUDE_VERSION_UNPUBLISH = "Unpublished"
PLG_JLSITEMAP_SWJPROJECTS_EXCLUDE_VERSION_TRASH = "Trashed"
PLG_JLSITEMAP_SWJPROJECTS_EXCLUDE_JUPDATE = "SW JProjects - JUpdate exception"
PLG_JLSITEMAP_SWJPROJECTS_EXCLUDE_JUPDATE_MSG = "No index page"
PLG_JLSITEMAP_SWJPROJECTS_EXCLUDE_DOWNLOAD = "SW JProjects - Download exception"
PLG_JLSITEMAP_SWJPROJECTS_EXCLUDE_DOWNLOAD_MSG = "No index page"

PLG_JLSITEMAP_SWJPROJECTS_PARAMS_PROJECTS = "Projects"
PLG_JLSITEMAP_SWJPROJECTS_PARAMS_PROJECT = "Project"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ PLG_JLSITEMAP_SWJPROJECTS_TYPES_VERSION_TAG_ALPHA = "Alpha"
PLG_JLSITEMAP_SWJPROJECTS_TYPES_VERSION_TAG_BETA = "Beta"
PLG_JLSITEMAP_SWJPROJECTS_TYPES_VERSION_TAG_RC = "Release Candidate"
PLG_JLSITEMAP_SWJPROJECTS_TYPES_VERSION_TAG_STABLE = "Стабильная"
PLG_JLSITEMAP_SWJPROJECTS_TYPES_JUPDATE = "SW JProjects - JUpdate"
PLG_JLSITEMAP_SWJPROJECTS_TYPES_DOWNLOAD = "SW JProjects - Download"

PLG_JLSITEMAP_SWJPROJECTS_EXCLUDE_CATEGORY = "SW JProjects - Исключение категории"
PLG_JLSITEMAP_SWJPROJECTS_EXCLUDE_CATEGORY_UNPUBLISH = "Не опубликована"
Expand All @@ -29,6 +31,10 @@ PLG_JLSITEMAP_SWJPROJECTS_EXCLUDE_PROJECT_TRASH = "В корзине"
PLG_JLSITEMAP_SWJPROJECTS_EXCLUDE_VERSION = "SW JProjects - Исключение версии"
PLG_JLSITEMAP_SWJPROJECTS_EXCLUDE_VERSION_UNPUBLISH = "Не опубликована"
PLG_JLSITEMAP_SWJPROJECTS_EXCLUDE_VERSION_TRASH = "В корзине"
PLG_JLSITEMAP_SWJPROJECTS_EXCLUDE_JUPDATE = "SW JProjects - Исключение JUpdate"
PLG_JLSITEMAP_SWJPROJECTS_EXCLUDE_JUPDATE_MSG = "Не индексируемая страница"
PLG_JLSITEMAP_SWJPROJECTS_EXCLUDE_DOWNLOAD = "SW JProjects - Исключение Download"
PLG_JLSITEMAP_SWJPROJECTS_EXCLUDE_DOWNLOAD_MSG = "Не индексируемая страница"

PLG_JLSITEMAP_SWJPROJECTS_PARAMS_PROJECTS = "Проекты"
PLG_JLSITEMAP_SWJPROJECTS_PARAMS_PROJECT = "Проект"
Expand Down
55 changes: 51 additions & 4 deletions plg_jlsitemap_swjprojects/swjprojects.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,8 @@ class plgJLSitemapSWJProjects extends CMSPlugin
/**
* Constructor.
*
* @param object &$subject The object to observe
* @param array $config An optional associative array of configuration settings.
* @param object &$subject The object to observe
* @param array $config An optional associative array of configuration settings.
*
* @since 1.1.0
*/
Expand All @@ -60,15 +60,62 @@ public function __construct(object $subject, array $config = array())
/**
* Method to get urls array.
*
* @param array $urls Urls array.
* @param Registry $config Component config.
* @param array $urls Urls array.
* @param Registry $config Component config.
*
* @return array Urls array with attributes.
*
* @since 1.1.0
*/
public function onGetUrls(&$urls, $config)
{
// Exclude judate & download views
$jupdate = new stdClass();
$jupdate->type = Text::_('PLG_JLSITEMAP_SWJPROJECTS_TYPES_JUPDATE');
$jupdate->title = Text::_('PLG_JLSITEMAP_SWJPROJECTS_TYPES_JUPDATE');
$jupdate->loc = 'index.php?option=com_swjprojects&view=jupdate&key=1';
$jupdate->changefreq = 0;
$jupdate->priority = 0;
$jupdate->exclude = array(
array(
'type' => Text::_('PLG_JLSITEMAP_SWJPROJECTS_EXCLUDE_JUPDATE'),
'msg' => Text::_('PLG_JLSITEMAP_SWJPROJECTS_EXCLUDE_JUPDATE_MSG'),
)
);

$download = new stdClass();
$download->type = Text::_('PLG_JLSITEMAP_SWJPROJECTS_TYPES_DOWNLOAD');
$download->title = Text::_('PLG_JLSITEMAP_SWJPROJECTS_TYPES_DOWNLOAD');
$download->loc = 'index.php?option=com_swjprojects&view=download&key=1';
$download->changefreq = 0;
$download->priority = 0;
$download->exclude = array(
array(
'type' => Text::_('PLG_JLSITEMAP_SWJPROJECTS_EXCLUDE_DOWNLOAD'),
'msg' => Text::_('PLG_JLSITEMAP_SWJPROJECTS_EXCLUDE_DOWNLOAD_MSG'),
)
);

if ($config->get('multilanguage'))
{
foreach ($this->translates['all'] as $translate)
{
$url = $jupdate;
$url->loc = $url->loc . '&lang=' . $translate;
$urls[] = $url;

$url = $download;
$url->loc = $url->loc . '&lang=' . $translate;
$urls[] = $url;
}
}
else
{
$urls[] = $jupdate;
$urls[] = $download;
}

// Add urls
if (!$this->params->get('projects_enable')
&& !$this->params->get('project_enable')
&& !$this->params->get('versions_enable')
Expand Down

0 comments on commit c52b83b

Please sign in to comment.