From 7da10b5be8261eb0ccc29da248fb76cfa89b08fd Mon Sep 17 00:00:00 2001 From: Ichi Date: Sat, 6 Feb 2021 12:21:44 +0500 Subject: [PATCH] =?UTF-8?q?#1=20=D0=B4=D0=BE=D0=B1=D0=B0=D0=B2=D0=BB=D0=B5?= =?UTF-8?q?=D0=BD=20=D1=88=D0=B0=D0=B1=D0=BB=D0=BE=D0=BD=20sitemap?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- index.php | 22 ++++++++++++++++---- libs/cRSS.php | 2 +- rss_templates/sitemap.default_params.php | 9 ++++++++ rss_templates/sitemap.item.php | 12 +++++++++++ rss_templates/sitemap.rss.php | 7 +++++++ templates/index.php | 26 ++++++++++++++++-------- 6 files changed, 65 insertions(+), 13 deletions(-) create mode 100644 rss_templates/sitemap.default_params.php create mode 100644 rss_templates/sitemap.item.php create mode 100644 rss_templates/sitemap.rss.php diff --git a/index.php b/index.php index 45ff728..ee5152d 100644 --- a/index.php +++ b/index.php @@ -4,10 +4,10 @@ die(); } $config = require_once('config.inc.php'); -$currentVersion = "1.2.0"; +$currentVersion = "1.3.0"; spl_autoload_register(function ($class) { - $file = 'libs/'.$class . '.php'; + $file = 'libs/' . $class . '.php'; if (is_file($file)) { /** @noinspection PhpIncludeInspection */ require_once $file; @@ -51,14 +51,28 @@ $rssTemplate = isset($_GET['template']) ? $_GET['template'] : $config['defaultTemplate']; $rss = new cRSS($rssTemplate); -if (isset($_GET['page'])) { +if (isset($_GET['page']) || isset($_GET['template'])) { // формируем страницу rss + if (empty($_GET['page'])) { + $_GET['page'] = 0; + } $listPages = $list->getPageList($_GET['page'], $rss->getMaxCount()); $lenta = $rss->generateRSS($listPages); echo($lenta); } else { // формируем список rss - $countPage = ceil($list->countPageDB() / $rss->getMaxCount()); + + $fileParams = glob("rss_templates/*.default_params.php"); + $rssListTemplate = []; + foreach ($fileParams as $fileParam) { + $nameRss = preg_replace(['#rss_templates/#', '#\.default_params.php#'], '', $fileParam); + $currentRss = new cRSS($nameRss); + $rssListTemplate[$nameRss] = [ + 'rss' => $currentRss, + 'maxCount' => $currentRss->getMaxCount() + ]; + } + ob_start(); include('templates/index.php'); $html = ob_get_contents(); diff --git a/libs/cRSS.php b/libs/cRSS.php index 81af5a4..774a7dc 100644 --- a/libs/cRSS.php +++ b/libs/cRSS.php @@ -21,7 +21,7 @@ public function __construct($template) exit('шаблон не найден'); } /** @noinspection PhpIncludeInspection */ - $this->params = require_once($paramsFile); + $this->params = require($paramsFile); return true; } diff --git a/rss_templates/sitemap.default_params.php b/rss_templates/sitemap.default_params.php new file mode 100644 index 0000000..ebb14e9 --- /dev/null +++ b/rss_templates/sitemap.default_params.php @@ -0,0 +1,9 @@ + 50000, + +// параметры + 'changefreq' => 'monthly', + 'priority' => '0.8' +]; \ No newline at end of file diff --git a/rss_templates/sitemap.item.php b/rss_templates/sitemap.item.php new file mode 100644 index 0000000..f680488 --- /dev/null +++ b/rss_templates/sitemap.item.php @@ -0,0 +1,12 @@ + + + url; ?> + updateAt)); ?> + + + \ No newline at end of file diff --git a/rss_templates/sitemap.rss.php b/rss_templates/sitemap.rss.php new file mode 100644 index 0000000..de4ea3f --- /dev/null +++ b/rss_templates/sitemap.rss.php @@ -0,0 +1,7 @@ +'; ?> + + + diff --git a/templates/index.php b/templates/index.php index 17ba87e..f4b98a0 100644 --- a/templates/index.php +++ b/templates/index.php @@ -1,8 +1,10 @@ @@ -12,21 +14,29 @@ content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0"> - Яндекс Турбо для MediWiki + Яндекс Турбо для MediaWiki -

Яндекс Турбо для MediWiki

+

Яндекс Турбо для MediaWiki

версия

Список доступных лент

    -
  1. - $rss) { + + $maxCount = ($rssListTemplate[$rssName]['maxCount']); + + $countPage = ceil($list->countPageDB() / $maxCount); + for ($i = 0; $i < $countPage; $i++) { + $url['template'] = ($config['defaultTemplate'] == $rssName) ? null : "{$rssName}"; + $url['page'] = ($i == 0 && $url['template'] != '') ? null : "{$i}"; + $str = "http://{$config['here']}?" . http_build_query($url); + ?> +
  2. +