alias/_public.php

43 lines
1.0 KiB
PHP
Raw Normal View History

2022-11-27 12:57:51 +00:00
<?php
2022-11-27 13:51:46 +00:00
/**
* @brief alias, a plugin for Dotclear 2
*
* @package Dotclear
* @subpackage Plugin
*
* @author Olivier Meunier and contributors
*
2022-11-28 21:52:27 +00:00
* @copyright Jean-Christian Denis
2022-11-27 13:51:46 +00:00
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
*/
if (!defined('DC_RC_PATH')) {
return null;
}
2022-12-09 23:33:43 +00:00
dcCore::app()->url->register('alias', '', '^(.*)$', function ($args) {
$o = new dcAliases();
$aliases = $o->getAliases();
$part = $args;
2022-11-27 12:57:51 +00:00
2022-12-09 23:33:43 +00:00
foreach ($aliases as $v) {
if (@preg_match('#^/.*/$#', $v['alias_url']) && @preg_match($v['alias_url'], $args)) {
$part = preg_replace($v['alias_url'], $v['alias_destination'], $args);
2022-11-27 13:51:46 +00:00
2022-12-09 23:33:43 +00:00
break;
} elseif ($v['alias_url'] == $args) {
$part = $v['alias_destination'];
2022-11-27 13:51:46 +00:00
2022-12-09 23:33:43 +00:00
break;
2022-11-27 13:51:46 +00:00
}
}
2022-12-09 23:33:43 +00:00
dcCore::app()->url->unregister('alias');
dcCore::app()->url->getArgs($part, $type, $args);
2022-11-27 13:51:46 +00:00
2022-12-09 23:33:43 +00:00
if (!$type) {
dcCore::app()->url->callDefaultHandler($args);
} else {
dcCore::app()->url->callHandler($type, $args);
2022-11-27 13:51:46 +00:00
}
2022-12-09 23:33:43 +00:00
});