mirror of
https://github.com/torrentpier/torrentpier
synced 2025-08-21 13:54:02 -07:00
Refactored Sitemap class (#648)
This commit is contained in:
parent
c9d0a06fbc
commit
5f0649073f
3 changed files with 16 additions and 14 deletions
|
@ -14,7 +14,7 @@ if (!defined('IN_AJAX')) {
|
||||||
global $bb_cfg, $lang;
|
global $bb_cfg, $lang;
|
||||||
|
|
||||||
$mode = (string)$this->request['mode'];
|
$mode = (string)$this->request['mode'];
|
||||||
$map = new TorrentPier\Legacy\Sitemap();
|
$map = new TorrentPier\Sitemap();
|
||||||
$html = '';
|
$html = '';
|
||||||
|
|
||||||
switch ($mode) {
|
switch ($mode) {
|
||||||
|
|
|
@ -11,7 +11,7 @@ if (!defined('BB_ROOT')) {
|
||||||
die(basename(__FILE__));
|
die(basename(__FILE__));
|
||||||
}
|
}
|
||||||
|
|
||||||
$map = new TorrentPier\Legacy\Sitemap();
|
$map = new TorrentPier\Sitemap();
|
||||||
$map->createSitemap();
|
$map->createSitemap();
|
||||||
|
|
||||||
if (file_exists(SITEMAP_DIR . '/sitemap.xml')) {
|
if (file_exists(SITEMAP_DIR . '/sitemap.xml')) {
|
||||||
|
|
|
@ -7,14 +7,16 @@
|
||||||
* @license https://github.com/torrentpier/torrentpier/blob/master/LICENSE MIT License
|
* @license https://github.com/torrentpier/torrentpier/blob/master/LICENSE MIT License
|
||||||
*/
|
*/
|
||||||
|
|
||||||
namespace TorrentPier\Legacy;
|
namespace TorrentPier;
|
||||||
|
|
||||||
|
use InvalidArgumentException;
|
||||||
|
|
||||||
use samdark\sitemap\Sitemap as STM;
|
use samdark\sitemap\Sitemap as STM;
|
||||||
use samdark\sitemap\Index as IDX;
|
use samdark\sitemap\Index as IDX;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Class Sitemap
|
* Class Sitemap
|
||||||
* @package TorrentPier\Legacy
|
* @package TorrentPier
|
||||||
*/
|
*/
|
||||||
class Sitemap
|
class Sitemap
|
||||||
{
|
{
|
||||||
|
@ -23,7 +25,7 @@ class Sitemap
|
||||||
*
|
*
|
||||||
* @return array
|
* @return array
|
||||||
*/
|
*/
|
||||||
private function getForumUrls()
|
private function getForumUrls(): array
|
||||||
{
|
{
|
||||||
global $datastore;
|
global $datastore;
|
||||||
|
|
||||||
|
@ -53,7 +55,7 @@ class Sitemap
|
||||||
*
|
*
|
||||||
* @return array
|
* @return array
|
||||||
*/
|
*/
|
||||||
private function getTopicUrls()
|
private function getTopicUrls(): array
|
||||||
{
|
{
|
||||||
global $datastore;
|
global $datastore;
|
||||||
|
|
||||||
|
@ -84,7 +86,7 @@ class Sitemap
|
||||||
*
|
*
|
||||||
* @return array
|
* @return array
|
||||||
*/
|
*/
|
||||||
private function getStaticUrls()
|
private function getStaticUrls(): array
|
||||||
{
|
{
|
||||||
global $bb_cfg;
|
global $bb_cfg;
|
||||||
|
|
||||||
|
@ -111,9 +113,9 @@ class Sitemap
|
||||||
*
|
*
|
||||||
* @return array
|
* @return array
|
||||||
*
|
*
|
||||||
* @throws \InvalidArgumentException
|
* @throws InvalidArgumentException
|
||||||
*/
|
*/
|
||||||
private function buildDynamicSitemap()
|
private function buildDynamicSitemap(): array
|
||||||
{
|
{
|
||||||
$sitemap = new STM(SITEMAP_DIR . '/sitemap_dynamic.xml');
|
$sitemap = new STM(SITEMAP_DIR . '/sitemap_dynamic.xml');
|
||||||
|
|
||||||
|
@ -135,9 +137,9 @@ class Sitemap
|
||||||
*
|
*
|
||||||
* @return array
|
* @return array
|
||||||
*
|
*
|
||||||
* @throws \InvalidArgumentException
|
* @throws InvalidArgumentException
|
||||||
*/
|
*/
|
||||||
private function buildStaticSitemap()
|
private function buildStaticSitemap(): array
|
||||||
{
|
{
|
||||||
$staticSitemap = new STM(SITEMAP_DIR . '/sitemap_static.xml');
|
$staticSitemap = new STM(SITEMAP_DIR . '/sitemap_static.xml');
|
||||||
|
|
||||||
|
@ -155,9 +157,9 @@ class Sitemap
|
||||||
*
|
*
|
||||||
* @return bool
|
* @return bool
|
||||||
*
|
*
|
||||||
* @throws \InvalidArgumentException
|
* @throws InvalidArgumentException
|
||||||
*/
|
*/
|
||||||
public function createSitemap()
|
public function createSitemap(): bool
|
||||||
{
|
{
|
||||||
$index = new IDX(SITEMAP_DIR . '/sitemap.xml');
|
$index = new IDX(SITEMAP_DIR . '/sitemap.xml');
|
||||||
|
|
||||||
|
@ -186,7 +188,7 @@ class Sitemap
|
||||||
*
|
*
|
||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
public function sendSitemap($url, $map)
|
public function sendSitemap($url, $map): string
|
||||||
{
|
{
|
||||||
$file = $url . urlencode($map);
|
$file = $url . urlencode($map);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue