From 23f0bb6c68031cf60569c6953ea1c976282ed68d Mon Sep 17 00:00:00 2001 From: Silvan Calarco Date: Sun, 3 Nov 2024 13:15:53 +0100 Subject: [PATCH] functions.php: set title in distroquery api pages --- functions.php | 21 ++++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-) diff --git a/functions.php b/functions.php index 9ab7a3a..f95e67b 100644 --- a/functions.php +++ b/functions.php @@ -64,9 +64,24 @@ function add_search_box($items, $args) { add_filter('wp_nav_menu_items','add_search_box', 10, 2); function set_title($title) { - $urlargspos = strpos($_SERVER['REQUEST_URI'], '?'); - if ($urlargspos > 0) { - $urlargs = substr($_SERVER['REQUEST_URI'], $urlargspos + 1); + $url = $_SERVER['REQUEST_URI']; + $spliturl = explode('?', $url); + $splituri = explode('/', $spliturl[0]); + + if (sizeof($splituri) > 2 && $splituri[2] == "rpms") { + // Set title for distroquery-api + if (sizeof($splituri) > 5) { + if ($splituri[5] == "") + return $splituri[4] . " (" . _r("Source RPM") . ") | "; + else + return $splituri[4] . " (" . $splituri[5] . ") | "; + } else if (sizeof($splituri) > 4) { + return _r("Repository") . " " . $splituri[3] . " | "; + } + return _r("Repositories") . " | "; + } else if (sizeof($spliturl) > 1) { + // Set title for obsolete packages pages + $urlargs = $spliturl[1]; parse_str($urlargs, $args); $newtitle = $title; if (array_key_exists('arch', $args)) {