Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
91 changes: 91 additions & 0 deletions core/config/manager_routes.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
<?php
return [
'repair' => 0,
'home' => 2,
'about_document' => 3,
'create_resource' => 4,
'save_content' => 5,
'delete_resource' => 6,
'wait_clean_up' => 7,
'logout' => 8,
'manager_log' => 13,
'edit_template' => 16,
'edit_settings' => 17,
'create_template' => 19,
'save_template' => 20,
'delete_template' => 21,
'edit_snippet' => 22,
'create_snippet' => 23,
'save_snippet' => 24,
'delete_snippet' => 25,
'refresh_site' => 26,
'edit_document' => 27,
'change_password' => 28,
'save_settings' => 30,
'files' => 31,
'save_password' => 34,
'edit_role' => 35,
'save_role' => 36,
'delete_role' => 37,
'create_role' => 38,
'move_resource' => 51,
'process_move' => 52,
'system_info' => 53,
'optimization_table' => 54,
'refresh_tree' => 56,
'publish_resource' => 61,
'unpublish_resource' => 62,
'undelete_resource' => 63,
'empty_trash' => 64,
'remove_lock' => 67,
'schedule_site' => 70,
'search' => 71,
'create_weblink' => 72,
'elements' => 76,
'create_chunk' => 77,
'edit_chunk' => 78,
'update_chunk' => 79,
'delete_chunk' => 80,
'add_dependencies' => 84,
'role_list' => 86,
'create_user' => 87,
'edit_user' => 88,
'edit_web_user' => 89,
'delete_user' => 90,
'web_permissions' => 91,
'edit_permissions' => 92,
'backup' => 93,
'duplicate_resource' => 94,
'update_tree' => 95,
'duplicate_template' => 96,
'duplicate_chunk' => 97,
'duplicate_snippet' => 98,
'user_list' => 99,
'create_plugin' => 101,
'edit_plugin' => 102,
'save_plugin' => 103,
'delete_plugin' => 104,
'duplicate_plugin' => 105,
'create_module' => 107,
'edit_module' => 108,
'save_module' => 109,
'delete_module' => 110,
'duplicate_module' => 111,
'execute_modules' => 112,
'dependencies_module' => 113,
'event_log' => 114,
'event_log_detail' => 115,
'delete_log_event' => 116,
'edit_tv_rank' => 117,
'update_plugin' => 118,
'categories' => 120,
'categories_ajax' => 121,
'edit_permission' => 135,
'edit_permission_group' => 136,
'php_info' => 200,
'create_tv' => 300,
'edit_tv' => 301,
'save_tv' => 302,
'delete_tv' => 303,
'duplicate_tv' => 304,
];
2 changes: 1 addition & 1 deletion core/config/tracy.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
return [
/**
* true - Activate tracy handler all errors contains at the /core/storage/logs/
* false - Default Evolution CMS Error handler. All errors contains at the /manager/index.php?a=114
* false - Default Evolution CMS Error handler. All errors contains at the manager_route('event_log')
* 'manager' - Activate tracy for users who authorize on the admin panel
*
* IMPORTANT! Tracy ignore the "error_reporting" EvolutionCMS setting
Expand Down
12 changes: 9 additions & 3 deletions core/functions/actions/files.php
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,13 @@ function ls($curpath, array $options = [])
if ($file === '..' || $file === '.') {
continue;
} elseif (!in_array($file, $excludes) && !in_array($newpath, $protected_path)) {
$dirs_array[$dircounter]['text'] = '<i class="' . $_style['icon_folder'] . ' FilesFolder"></i> <a href="index.php?a=31&mode=drill&path=' . urlencode($newpath) . '"><b>' . $file . '</b></a>';
$dirs_array[$dircounter]['text'] =
'<i class="' . $_style['icon_folder'] . ' FilesFolder"></i> ' .
'<a href="' . manager_route('files', [
'mode' => 'drill',
'path' => $newpath
]) . '">' .
'<b>' . $file . '</b></a>';

$dfiles = scandir($newpath);
foreach ($dfiles as $i => $infile) {
Expand Down Expand Up @@ -137,10 +143,10 @@ function ls($curpath, array $options = [])
explode('/', substr($newpath, $len,
strlen($newpath))))) . '" style="cursor:pointer;" download><i class="' . $_style['icon_download'] . '" title="' . $_lang['file_download_file'] . '"></i></a>' : '<span class="disabled"><i class="' . $_style['icon_eye'] . '" title="' . $_lang['files_viewfile'] . '"></i></span>');
$files_array[$filecounter]['view'] = (in_array($type,
$inlineviewablefiles)) ? '<a href="index.php?a=31&mode=view&path=' . urlencode($newpath) . '"><i class="' . $_style['icon_eye'] . '" title="' . $_lang['files_viewfile'] . '"></i></a>' : $files_array[$filecounter]['view'];
$inlineviewablefiles)) ? '<a href="'. manager_route('files',['mode' => 'view', 'path' => $newpath]) .'"><i class="' . $_style['icon_eye'] . '" title="' . $_lang['files_viewfile'] . '"></i></a>' : $files_array[$filecounter]['view'];
$files_array[$filecounter]['unzip'] = ($enablefileunzip && $type == '.zip') ? '<a href="javascript:unzipFile(\'' . urlencode($file) . '\');"><i class="' . $_style['icon_archive'] . '" title="' . $_lang['file_download_unzip'] . '"></i></a>' : '';
$files_array[$filecounter]['edit'] = (in_array($type,
$editablefiles) && is_writable($curpath) && is_writable($newpath)) ? '<a href="index.php?a=31&mode=edit&path=' . urlencode($newpath) . '#file_editfile"><i class="' . $_style['icon_edit'] . '" title="' . $_lang['files_editfile'] . '"></i></a>' : '<span class="disabled"><i class="' . $_style['icon_edit'] . '" title="' . $_lang['files_editfile'] . '"></i></span>';
$editablefiles) && is_writable($curpath) && is_writable($newpath)) ? '<a href="'. manager_route('files', ['mode'=> 'edit', 'path' => $newpath]) .'#file_editfile"><i class="' . $_style['icon_edit'] . '" title="' . $_lang['files_editfile'] . '"></i></a>' : '<span class="disabled"><i class="' . $_style['icon_edit'] . '" title="' . $_lang['files_editfile'] . '"></i></span>';
$files_array[$filecounter]['duplicate'] = (in_array($type,
$editablefiles) && is_writable($curpath) && is_writable($newpath)) ? '<a href="javascript:duplicateFile(\'' . urlencode($file) . '\');"><i class="' . $_style['icon_clone'] . '" title="' . $_lang['duplicate'] . '"></i></a>' : '<span class="disabled"><i class="' . $_style['icon_clone'] . '" align="absmiddle" title="' . $_lang['duplicate'] . '"></i></span>';
$files_array[$filecounter]['rename'] = (in_array($type,
Expand Down
72 changes: 72 additions & 0 deletions core/functions/helper.php
Original file line number Diff line number Diff line change
Expand Up @@ -247,3 +247,75 @@ function replace_array(
return $out;
}
}

if (!function_exists('manager_route')) {
/**
* Генерирует URL для страницы админ-панели по читаемому имени маршрута
*
* @param string $name имя маршрута из config/manager_routes.php
* @param array $params дополнительные GET-параметры (id, tab, …)
* @return string полный URL вида MODX_MANAGER_URL . 'index.php?a=...&...'
* @throws InvalidArgumentException если маршрут не найден
*/
function manager_route(string $name, array $params = []): string
{
static $routes = null;
if ($routes === null) {
$routes = include __DIR__ . '/../config/manager_routes.php';
}

$action = $routes[$name] ?? null;
if ($action === null) {
throw new \InvalidArgumentException("Неизвестный маршрут админки: $name");
}

$query = array_merge(['a' => $action], $params);
return MODX_MANAGER_URL . 'index.php?' . http_build_query($query);
}
}

if (!function_exists('manager_route_by_action')) {
/**
* Генерирует URL для страницы админ-панели по числовому ID действия (a=...)
*
* @param int $action ID действия из manager_routes.php
* @param array $params дополнительные GET-параметры
* @return string полный URL
* @throws InvalidArgumentException если действие не найдено в маршрутах
*/
function manager_route_by_action(int $action, array $params = []): string
{
static $routes = null;
if ($routes === null) {
$routes = include __DIR__ . '/../config/manager_routes.php';
}

$name = array_search($action, $routes, true);
if ($name === false) {
throw new \InvalidArgumentException("Неизвестный ID действия админки: $action");
}

return manager_route($name, $params);
}
}

if (!function_exists('manager_action_id')) {
/**
* Возвращает числовой ID действия по читаемому имени маршрута.
*
* @param string $name
* @return int
* @throws InvalidArgumentException
*/
function manager_action_id(string $name): int
{
static $routes = null;
if ($routes === null) {
$routes = include __DIR__ . '/../config/manager_routes.php';
}
if (!isset($routes[$name])) {
throw new \InvalidArgumentException("Неизвестный маршрут админки: $name");
}
return $routes[$name];
}
}
2 changes: 1 addition & 1 deletion core/functions/processors.php
Original file line number Diff line number Diff line change
Expand Up @@ -463,7 +463,7 @@ function webAlertAndQuit($msg, $action, $id = false)
$modx = EvolutionCMS();
$mode = $_POST['mode'];
$modx->getManagerApi()->saveFormValues($mode);
$url = 'index.php?a=' . $action;
$url = manager_route_by_action($action);
if ($id != false) {
$url .= '&id=' . $id;
}
Expand Down
Loading