-
Notifications
You must be signed in to change notification settings - Fork 0
Menu system plan
Update - 2013-07-29 23:45 CET
Note that this page has been updated so the solution no longer introduces the concept of permissions. Instead separate menus will be used for different user roles. This is because there is no role system implemented at the moment and it would take too much time from this project. We might instead be able to create a proper admin UI.
Update 2 - 2013-07-30 12:54 CET
To simplify the creation and understanding of paths, I suggest that all paths should be from root. This means that only the index.php in the hackademic root will be used to parse arguments and the one in the admin folder will simply be used for inclusion. All files which currently use require_once('../init.php')
and similar relative inclusions will need to be updated to use absolute inclusion.
Update 3 - 2013-07-30 23:11 CET
Been spending the day working on the menu system and how to dynamically load the pages and I've run into as many problems as I possibly can. Hopefully that means that the final solution will be solid. I had completely missed the planning of how to handle files that are not part of a menu. I have now created a new pages
table that will keep a mapping of url's and files. I've updated first iteration details to match the new database layout.
Currently the menus are hardcoded in separate controller files. The views that are related to the menus loop through a simple array with the menu items title's and url's. This solution is not flexible, is impossible for an administrator to manage and doesn't allow for nested, hierarchical menus.
The long term goal for the menu system should be to create a completely dynamic hierarchical system where it is possible for an administrator to click and drag to move menu items around. An administrator should also be able to create new menus and menu items. The administrations tasks will require quiet a lot of UI coding though, which is not the main goal of the project. Therefor the main focus should be on allowing 3rd party developers to add and remove menu items.
Although the current menu implementations do not use hierarchical menus, it would be a good idea to plan ahead since that is a critical feature to allow theme developers to create custom themes and a user-friendly, well-structured site.
The development will need to be done in iterations. When all iterations are finished I hope that we will have a system with clean and structured url's. To achieve this some work needs to be done on how pages are being displayed. Since there is no role/permission system implemented at the moment, different menu's will be created for each role (student, teacher, admin).
Today, pages are loaded as individual php files that are located by a URL. Some pages make use of GET parameters in the URL. To be able to create a dynamic menu, with any number of pages while at the same time maintaining some kind of sane URL structure we will have to work with the index.php files in the root folder.
The index.php file will take arguments from the URL and query the database for which page to load that matches the given argument. For example the URL http://www.hackademic.dev/?url=dir/subdir/page
will have a row in the database with the page column dir/subdir/page
and file column user/plugin/custom-plugin/some-page.php
. The index.php file will then include this file which then might launch a controller or do whatever the custom-plugin does.
The first iteration will simply move the current user menu from the UserMenuController
into the database. The structure of the database will be as follows:
-------------------
|Menus
------------------------
|id (PK)| |display name|
------------------------
--------------------------------------------
|Pages
--------------------------------------------
|url (PK)| |file|
--------------------------------------------
--------------------------------------------
|Menu items
--------------------------------------------
|url (PK)(FK)| |mid (PK)(FK)| |label| |sort|
--------------------------------------------
This iteration should allow a 3rd party dev to add menu items and display them. It will take place in sprint 4
The second iteration will focus on the hierarchy of the menus. A new column parent
will be introduced in the menu_items
table.
-----------------------------------------------------
|Menu items
-----------------------------------------------------
|mid (FK)| |label| |page (PK)| |file| |sort| |parent|
-----------------------------------------------------
To allow for hierarchical menus, the view code will have do be rewritten to acommodate nested elements. The loops that produce the menu's will have do dig deeper into the menu array and some CSS will have to be written to hide/show sub-items.
When this iteration is finished, a 3rd party dev should be able to re-order menus and add sub-items that are displayed. At the moment, this work is planned for sprint 5 unless something else comes up.
There might not be enough time to start on this iteration. It would contain the creation of the administration interface so that an admin can manage the menus. For now, it is more important to enable the possibility to change the menus for developers. Until the UI is finished, administrators can use code if they want to change menus.
It might actually be possible to reach this iteration now that the permission system has been dumped.
This could be useful in the ui development: http://www.drakedata.com/serializetree/sampleTree.html