Skip to content

Commit

Permalink
Refactor, Simplification du sous menu dans les pages.
Browse files Browse the repository at this point in the history
  • Loading branch information
noelma committed Feb 27, 2021
1 parent 34d767c commit bfaf36f
Show file tree
Hide file tree
Showing 44 changed files with 192 additions and 280 deletions.
12 changes: 6 additions & 6 deletions core/modules/FileManager/Controller/FilePermissionManager.php
Expand Up @@ -62,13 +62,13 @@ public function admin($req)
'title_main' => t('Administer file permissions')
])
->view('page.messages', $messages)
->view('page.submenu', self::user()->getUserManagerSubmenu('filemanager.profil.admin'))
->make('page.content', 'filemanager/content-file_permission_manager-admin.php', $this->pathViews, [
'form' => $form,
'link_add' => self::router()->getRoute('filemanager.profil.create'),
'profils' => $values,
'router' => self::router(),
'user_manager_submenu' => self::user()->getUserManagerSubmenu('filemanager.profil.admin')
]);
'form' => $form,
'link_add' => self::router()->getRoute('filemanager.profil.create'),
'profils' => $values,
'router' => self::router()
]);
}

public function adminCheck($req)
Expand Down
26 changes: 12 additions & 14 deletions core/modules/FileManager/Controller/Profil.php
Expand Up @@ -142,10 +142,10 @@ public function edit($id, $req)
'title_main' => t('Edit the files permission')
])
->view('page.messages', $messages)
->view('page.submenu', $this->getPermissionSubmenu('filemanager.profil.edit', $id))
->make('page.content', 'filemanager/content-file_permission-form.php', $this->pathViews, [
'form' => $form,
'permission_submenu' => $this->getPermissionSubmenu('filemanager.profil.edit', $id)
]);
'form' => $form
]);
}

public function update($id, $req)
Expand Down Expand Up @@ -242,10 +242,10 @@ public function remove($id, $req)
'title_main' => t('Delete files permission')
])
->view('page.messages', $messages)
->view('page.submenu', $this->getPermissionSubmenu('filemanager.profil.remove', $id))
->make('page.content', 'filemanager/content-file_permission-form.php', $this->pathViews, [
'form' => $form,
'permission_submenu' => $this->getPermissionSubmenu('filemanager.profil.remove', $id)
]);
'form' => $form
]);
}

public function delete($id, $req)
Expand Down Expand Up @@ -420,13 +420,11 @@ private function getPermissionSubmenu($keyRoute, $idPermission)
}
unset($link);

return self::template()
->createBlock('filemanager/submenu-permission.php', $this->pathViews)
->addVars([
'key_route' => $keyRoute,
'menu' => count($menu) === 1
? []
: $menu
]);
return [
'key_route' => $keyRoute,
'menu' => count($menu) === 1
? []
: $menu
];
}
}
@@ -1,4 +1,2 @@

<?php echo not_empty_or($permission_submenu); ?>

<?php echo $form; ?>
@@ -1,6 +1,4 @@

<?php echo $user_manager_submenu; ?>

<div class="nav-flex">
<div class="nav-flex-right">
<a href="<?php echo $link_add; ?>" class="btn btn-primary">
Expand Down
14 changes: 0 additions & 14 deletions core/modules/FileManager/Views/filemanager/submenu-permission.php

This file was deleted.

24 changes: 11 additions & 13 deletions core/modules/Menu/Controller/Menu.php
Expand Up @@ -46,6 +46,7 @@ public function show($name, $req)
'title_main' => t($menu[ 'title' ])
])
->view('page.messages', $messages)
->view('page.submenu', $this->getMenuSubmenu('menu.show', $menu[ 'name' ]))
->make('page.content', 'menu/content-menu-show.php', $this->pathViews, [
'form' => $form,
'link_create_link' => self::router()->getRoute('menu.link.create', [
Expand All @@ -54,7 +55,6 @@ public function show($name, $req)
'link_create_menu' => self::router()->getRoute('menu.create'),
'menu' => $this->renderMenu($name),
'menu_name' => $menu[ 'title' ],
'menu_submenu' => $this->getMenuSubmenu('menu.show', $menu[ 'name' ]),
'list_menu_submenu' => $this->getListMenuSubmenu($name)
]);
}
Expand Down Expand Up @@ -225,10 +225,10 @@ public function edit($menu, $req)
])
])
->view('page.messages', $messages)
->view('page.submenu', $this->getMenuSubmenu('menu.edit', $menu))
->make('page.content', 'menu/content-menu-form.php', $this->pathViews, [
'form' => $form,
'menu_submenu' => $this->getMenuSubmenu('menu.edit', $menu)
]);
'form' => $form
]);
}

public function update($menu, $req)
Expand Down Expand Up @@ -307,10 +307,10 @@ public function remove($name, $req)
':name' => t($menu[ 'title' ])
])
])
->view('page.submenu', $this->getMenuSubmenu('menu.remove', $name))
->make('page.content', 'menu/content-menu-form.php', $this->pathViews, [
'form' => $form,
'menu_submenu' => $this->getMenuSubmenu('menu.remove', $name)
]);
'form' => $form
]);
}

public function delete($menu, $req)
Expand Down Expand Up @@ -422,12 +422,10 @@ public function getMenuSubmenu($keyRoute, $nameMenu)
$link[ 'link' ] = $link[ 'request' ]->getUri();
}

return self::template()
->createBlock('menu/submenu-menu.php', $this->pathViews)
->addVars([
'key_route' => $keyRoute,
'menu' => $menu
]);
return [
'key_route' => $keyRoute,
'menu' => $menu
];
}

public function getListMenuSubmenu($nameMenu)
Expand Down
2 changes: 0 additions & 2 deletions core/modules/Menu/Views/menu/content-menu-form.php
@@ -1,4 +1,2 @@

<?php echo isset_or($menu_submenu); ?>

<?php echo $form; ?>
2 changes: 0 additions & 2 deletions core/modules/Menu/Views/menu/content-menu-show.php
@@ -1,6 +1,4 @@

<?php echo $menu_submenu; ?>

<div class="nav-flex">
<div class="nav-flex-right">
<a href="<?php echo $link_create_link; ?>" class="btn btn-primary">
Expand Down
11 changes: 0 additions & 11 deletions core/modules/Menu/Views/menu/submenu-menu.php

This file was deleted.

19 changes: 7 additions & 12 deletions core/modules/Node/Controller/Node.php
Expand Up @@ -235,10 +235,10 @@ public function show($idNode, $req)
'page-node.php'
])
->view('page.messages', $messages)
->view('page.submenu', $this->getSubmenuNode('node.show', $idNode))
->make('page.content', 'node/content-node-show.php', $this->pathViews, [
'fields' => $fields,
'node' => $node,
'node_submenu' => $this->getSubmenuNode('node.show', $idNode)
'fields' => $fields,
'node' => $node
])->override('page.content', [
'node/content-node-show_' . $idNode . '.php',
'node/content-node-show_' . $node[ 'type' ] . '.php'
Expand Down Expand Up @@ -295,9 +295,9 @@ public function edit($idNode, $req)
'title_main' => t('Edit :title content', [ ':title' => $content[ 'title' ] ])
])
->view('page.messages', $messages)
->view('page.submenu', $this->getSubmenuNode('node.edit', $idNode))
->make('page.content', 'node/content-node-form.php', $this->pathViews, [
'form' => $form,
'node_submenu' => $this->getSubmenuNode('node.edit', $idNode),
'node_fieldset_submenu' => $this->getNodeFieldsetSubmenu()
])
->override('page.content', [ 'node/content-node-form_edit.php' ]);
Expand Down Expand Up @@ -456,9 +456,9 @@ public function remove($idNode, $req)
'title_main' => t('Delete :name content', [ ':name' => $node[ 'title' ] ])
])
->view('page.messages', $messages)
->view('page.submenu', $this->getSubmenuNode('node.delete', $idNode))
->make('page.content', 'node/content-node-form.php', $this->pathViews, [
'form' => $form,
'node_submenu' => $this->getSubmenuNode('node.delete', $idNode)
'form' => $form,
])
->override('page.content', [ 'node/content-node-form_remove.php' ]);
}
Expand Down Expand Up @@ -721,12 +721,7 @@ public function getSubmenuNode($keyRoute, $idNode)
}
}

return self::template()
->createBlock('node/submenu-node.php', $this->pathViews)
->addVars([
'key_route' => $keyRoute,
'menu' => $menu
]);
return [ 'key_route' => $keyRoute, 'menu' => $menu ];
}

public function getNodeFieldsetSubmenu()
Expand Down
2 changes: 0 additions & 2 deletions core/modules/Node/Views/node/content-node-form.php
@@ -1,6 +1,4 @@

<?php echo not_empty_or($node_submenu); ?>

<div class="row">
<?php if (!empty($node_fieldset_submenu)): ?>
<div class="col-md-3 sticky">
Expand Down
2 changes: 0 additions & 2 deletions core/modules/Node/Views/node/content-node-show.php
@@ -1,6 +1,4 @@

<?php echo $node_submenu; ?>

<?php foreach ($fields as $field): ?>
<?php if ($field[ 'field_show_label' ]): ?>
<h2><?php echo t($field[ 'field_label' ]); ?></h2>
Expand Down
15 changes: 0 additions & 15 deletions core/modules/Node/Views/node/submenu-node.php

This file was deleted.

27 changes: 11 additions & 16 deletions core/modules/System/Controller/Theme.php
Expand Up @@ -77,16 +77,16 @@ public function admin($type)
'title_main' => t('Themes')
])
->view('page.messages', $messages)
->view('page.submenu', $this->getListThemeSubmenu($type))
->make('page.content', 'system/content-themes-admin.php', $this->pathViews, [
'active_theme' => $activeTheme,
'link_edit' => self::module()->has('Block')
'active_theme' => $activeTheme,
'link_edit' => self::module()->has('Block')
? self::router()->getRoute('block.section.admin', [ ':theme' => $type ])
: null,
'link_setting' => self::router()->getRoute('system.theme.edit', [
'link_setting' => self::router()->getRoute('system.theme.edit', [
':type' => $type
]),
'theme_manager_submenu' => $this->getListThemeSubmenu($type),
'themes' => $themes,
'themes' => $themes
]);
}

Expand Down Expand Up @@ -160,13 +160,13 @@ public function edit($type)
'title_main' => t('Theme settings')
])
->view('page.messages', $messages)
->view('page.submenu', $this->getListThemeSubmenu($type))
->make('page.content', 'system/content-form.php', $this->pathViews, [
'form' => $form,
'link_edit' => self::router()->getRoute('system.theme.admin', [
'form' => $form,
'link_edit' => self::router()->getRoute('system.theme.admin', [
':type' => $type
]),
'theme_manager_submenu' => $this->getListThemeSubmenu($type),
]);
])
]);
}

public function update($type, ServerRequestInterface $req)
Expand Down Expand Up @@ -239,12 +239,7 @@ public function getListThemeSubmenu($keyRoute)
]
];

return self::template()
->createBlock('system/submenu-theme-list.php', $this->pathViews)
->addVars([
'key_route' => $keyRoute,
'menu' => $menus
]);
return [ 'key_route' => $keyRoute, 'menu' => $menus ];
}

private function installTheme($type, $title)
Expand Down
2 changes: 0 additions & 2 deletions core/modules/System/Views/system/content-form.php
@@ -1,4 +1,2 @@

<?php echo not_empty_or($theme_manager_submenu); ?>

<?php echo $form; ?>
3 changes: 0 additions & 3 deletions core/modules/System/Views/system/content-themes-admin.php
Expand Up @@ -4,9 +4,6 @@
}
</style>

<?php echo $theme_manager_submenu; ?>


<fieldset class="filedset-theme">
<h2>
<?php echo $active_theme[ 'extra' ][ 'soosyze' ][ 'title' ]; ?>
Expand Down
12 changes: 0 additions & 12 deletions core/modules/System/Views/system/submenu-theme-list.php

This file was deleted.

3 changes: 3 additions & 0 deletions core/modules/Template/Services/Templating.php
Expand Up @@ -129,6 +129,8 @@ public function init()
'success' => []
]);

$submenu = $this->createBlock('submenu.php', $this->pathViews);

$page = $this->createBlock('page.php', $this->pathViews)
->addVars([
'title' => '',
Expand All @@ -139,6 +141,7 @@ public function init()
->addVars($this->core->getSettings())
->addBlock('content')
->addBlock('messages', $messages)
->addBlock('submenu', $submenu)
->addBlock('main_menu')
->addBlock('second_menu');

Expand Down
16 changes: 16 additions & 0 deletions core/modules/Template/Views/submenu.php
@@ -0,0 +1,16 @@
<?php if (!empty($menu)): ?>
<nav>
<ul class="<?php echo isset_or($class); ?> nav nav-tabs">
<?php foreach ($menu as $link): ?>

<li<?php echo if_or($link[ 'key' ] === $key_route, ' class="active"'); ?>>
<a href="<?php echo $link[ 'link' ]; ?>" class="<?php echo isset_or($link[ 'class' ]); ?>">
<?php echo t($link[ 'title_link' ]); ?>

</a>
</li>
<?php endforeach; ?>

</ul>
</nav>
<?php endif; ?>

0 comments on commit bfaf36f

Please sign in to comment.