Enhance typeopenany.php with new attributes and update router.php for SEO URL handling and improved URL parsing.

This commit is contained in:
stephan.kasdorf
2025-09-29 13:39:18 +02:00
parent b550605bc2
commit b131d5cacc
5 changed files with 65 additions and 64 deletions

0
core/c/auto.php Normal file → Executable file
View File

0
core/c/nibiru.php Normal file → Executable file
View File

View File

@@ -1,7 +1,5 @@
<?php <?php
namespace Nibiru; namespace Nibiru;
use phpseclib3\File\ASN1\Maps\FieldElement;
/** /**
* User - stephan * User - stephan
* Date - 24.01.17 * Date - 24.01.17
@@ -155,11 +153,14 @@ class Router extends Config
if(is_array($uri_parts)) if(is_array($uri_parts))
{ {
// FIRST: Check for SEO URLs before standard processing
if (self::handleSeoUrls($uri_parts)) if (self::handleSeoUrls($uri_parts))
{ {
// SEO URL was handled, skip normal processing // SEO URL was handled, skip normal processing
return; return;
} }
// STANDARD PROCESSING (UNCHANGED)
if($uri_parts[1] == "") if($uri_parts[1] == "")
{ {
self::$_cur_page = "index"; self::$_cur_page = "index";
@@ -252,9 +253,11 @@ class Router extends Config
} }
} }
} }
}
else else
{ {
// Handle single trailing URL segments // Handle single trailing URL segments (e.g., /admin/adwordsgenerator/machines)
if(!is_numeric($uri_parts[$i]) && !empty($uri_parts[$i])) if(!is_numeric($uri_parts[$i]) && !empty($uri_parts[$i]))
{ {
if(!array_key_exists($uri_parts[$i], $_REQUEST)) if(!array_key_exists($uri_parts[$i], $_REQUEST))
@@ -266,7 +269,6 @@ class Router extends Config
} }
} }
} }
}
self::$_page_params = $_REQUEST; self::$_page_params = $_REQUEST;
} }
@@ -289,8 +291,7 @@ class Router extends Config
private static function handleSeoUrls($uri_parts) private static function handleSeoUrls($uri_parts)
{ {
// Check if we have the minimum required parts for SEO URL: /controller/slug/id // Check if we have the minimum required parts for SEO URL: /controller/slug/id
if (!is_array($uri_parts) || count($uri_parts) < 4) if (!is_array($uri_parts) || count($uri_parts) < 4) {
{
return false; return false;
} }
@@ -300,20 +301,17 @@ class Router extends Config
$possibleId = $uri_parts[3] ?? ''; $possibleId = $uri_parts[3] ?? '';
// Validate that the last part is numeric (ID) // Validate that the last part is numeric (ID)
if (!is_numeric($possibleId)) if (!is_numeric($possibleId)) {
{
return false; return false;
} }
// Validate that the slug contains non-numeric characters (to differentiate from traditional URLs) // Validate that the slug contains non-numeric characters (to differentiate from traditional URLs)
if (is_numeric($slug)) if (is_numeric($slug)) {
{
return false; return false;
} }
// Validate that the slug is not an existing action name // Validate that the slug is not an existing action name
if (self::isExistingAction($controller, $slug)) if (self::isExistingAction($controller, $slug)) {
{
return false; return false;
} }

View File

@@ -15,7 +15,10 @@ class TypeOpenAny extends FormAttributes implements IForm
self::FORM_ATTRIBUTE_ID => '', self::FORM_ATTRIBUTE_ID => '',
self::FORM_ATTRIBUTE_CLASS => '', self::FORM_ATTRIBUTE_CLASS => '',
self::FORM_ATTRIBUTE_ANY => '', self::FORM_ATTRIBUTE_ANY => '',
self::FORM_ATTRIBUTE_HREF => '' self::FORM_ATTRIBUTE_HREF => '',
'src' => '',
'alt' => '',
'style' => ''
); );
/** /**
@@ -35,6 +38,6 @@ class TypeOpenAny extends FormAttributes implements IForm
*/ */
private function _setElement( ) private function _setElement( )
{ {
$this->_element = '<ANY href="HREF" ID CLASS>' . 'VALUE' . "\n"; $this->_element = '<ANY href="HREF" src="SRC" alt="ALT" style="STYLE" ID CLASS>' . 'VALUE' . "\n";
} }
} }

0
core/c/typeswitch.php Normal file → Executable file
View File